From patchwork Fri Oct 7 15:21:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 613179 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp375590pvb; Fri, 7 Oct 2022 09:00:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4nnNA/yZLRcIndC1xJ8h0O2IgaBA2iZgnT+ckgXldL2SeDFY/JYyvFhA0FC9oCM29oHIyr X-Received: by 2002:ad4:5aed:0:b0:4b1:8a39:914a with SMTP id c13-20020ad45aed000000b004b18a39914amr4823992qvh.104.1665158453997; Fri, 07 Oct 2022 09:00:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665158453; cv=none; d=google.com; s=arc-20160816; b=H0FAP6YoPS50Vxh3XaIwhOTNuJBfpBrrtpUZs9sWtBvceP34MidvfWFmUtC5zcscvW +ovkgaxSjKEBFD49crKk4Gx909kPgiSz8y3tD0jaQ4/mjSymgI7EtjaexYimWIpmyY7a EMOIeGhuR7kx+6uStdtEKa08h9DeqfhwjnEZym48TrRDQU8KnepB+YjB2AyeSOdmbcUY dUiTAIwNkRJLEh4AsuDCqnKLG202Jg3TVid8MgA53ba2KK/Cf7AUh6w83AjObjN4v58F BuA0zDiIY0ryMAoiSN29/oL3sDGRIhAh2L9eIg1xJM73YTp9GxiMULHn6KKC54QC5A9s YPjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=g9B6N1pLHmw9apXhytCYAiivYvGiSWVPO4ktlKtyCTM=; b=ivJDLKzRpAf7Ry6YzIaiOqyMR+MBiS91tzmdCjs5tJ2CRdL7PN7c9f+dWEpOMy24mF tN1nxF+3GpEANnceoDESSI8xwgD0mY4rzFwyAEx55Jc1OA5j5Zh38GAvSW/GW6zQFQsu 9c6kyIVzkj1iLoWbglPYy6zsTLLuk5HoVU0XAcOQrSJQ/eUH1yZv2Y/z/ZKr0K7tswK3 /MFrUPY+A6DkV/QWMHR76e0yOeghO90487a3qqtYoNiSLB7RIn3v7L13CPZ+Enr4cRFo /+ygZM9mo5RwsABrp8/lzGua0s5tbAK+SrWnJkDncsxBpBPXgocvqPZRhW74nMLPUkmM Bifg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lDVL8ItL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l8-20020ac84cc8000000b003949ebb47d2si1228396qtv.115.2022.10.07.09.00.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Oct 2022 09:00:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lDVL8ItL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogpmP-0002TR-Fj for patch@linaro.org; Fri, 07 Oct 2022 12:00:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogpAq-00016s-Nb for qemu-devel@nongnu.org; Fri, 07 Oct 2022 11:22:08 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:51948) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogpAo-0005l3-Mw for qemu-devel@nongnu.org; Fri, 07 Oct 2022 11:22:04 -0400 Received: by mail-pj1-x1030.google.com with SMTP id b15so4709656pje.1 for ; Fri, 07 Oct 2022 08:22:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=g9B6N1pLHmw9apXhytCYAiivYvGiSWVPO4ktlKtyCTM=; b=lDVL8ItL1TpuExARtXb3iNNo3PvJeng7rsWBqj/S3Du6W9QV8iOY8RTrxbWIZGO0Ju w1zD9YJmLMYZT76Q9zlsjtkWJE7faF4zWqPThw4bgEJdW30C4dAg1HnbvzDgpY5m7esG GpcLlJgGvVCTLSSvAvW97ETgXwgBgnCvQfmTwaxqPsbu2GYtBgaYuV06PJJA0oL3I6HL ffEPfTyj4RPhelYrJimqm7FLSz2Vy5mec3LD4sAh31Q26Qf+7owhkCqy1XkVjId6k9sz PH94Yp7vnr6TuX4nBsvfvpbbXIcH1QMp6L3jYQlUd42o4pfPxmyXV9yN+qYyerhAXsK7 6lhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=g9B6N1pLHmw9apXhytCYAiivYvGiSWVPO4ktlKtyCTM=; b=rVbgHQx4LLNz39A3fLVFl5VBhXMXQPZZHoSiXIpU8bL11qNbB9hWB+5M6jKbqYBP6J rGEByTArzVUZC3dIGW19mrvz50byyqDCksWAXyde9WQam4yi5p4P+8OZNWRHTQ8KPLWP wyH3tN0u/QM02PuK7MAyoGxoPxdZxA8F+F0CfffxH3SS88Xa3JeGa2S34CEv+hL/ZJyL i76vxj9TaNzGiftapu8LaYQeH52Jb2/gd/y+zP8m28DE6cCiPL7Tlqb+6f8J79NpGZp+ sJSfVvAC/30qa8M2DlssrYs6kPOjLqZY9KqdBfmzxvwMJQiXbqR3ln49v4DktTvfvoQR qdNA== X-Gm-Message-State: ACrzQf3qj9yzQjTqM47Di6So32+Sui2GfdLNZqnM5ZI0SEIu5Wh+cKxR uItcJnxfchr86pA1vr+XwXrSufWo1snH6w== X-Received: by 2002:a17:903:4d4:b0:17f:7ecc:88e3 with SMTP id jm20-20020a17090304d400b0017f7ecc88e3mr5283578plb.169.1665156121054; Fri, 07 Oct 2022 08:22:01 -0700 (PDT) Received: from stoup.. ([2602:47:d49d:ec01:3b6c:3864:9643:140a]) by smtp.gmail.com with ESMTPSA id h14-20020a170902f54e00b00179f370dbfasm1706318plf.26.2022.10.07.08.22.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Oct 2022 08:22:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PATCH] target/arm: Make the final stage1+2 write to secure be unconditional Date: Fri, 7 Oct 2022 08:21:59 -0700 Message-Id: <20221007152159.1414065-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" While the stage2 call to get_phys_addr_lpae should never set attrs.secure when given a non-secure input, it's just as easy to make the final update to attrs.secure be unconditional and false in the case of non-secure input. Suggested-by: Peter Maydell Signed-off-by: Richard Henderson --- Hi Peter, This is the promised patch 1.5 for v3 FEAT_HAFDBS. It generates minor conflicts down the line, which I have already fixed up locally. I think the first one you would encounter is beyond the proposed 20 that you indicated that you intend to take into target-arm.next right now. r~ --- target/arm/ptw.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index b8c494ad9f..7d763a5847 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2365,17 +2365,16 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, result->cacheattrs = combine_cacheattrs(env, cacheattrs1, result->cacheattrs); - /* Check if IPA translates to secure or non-secure PA space. */ - if (is_secure) { - if (ipa_secure) { - result->attrs.secure = - !(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW)); - } else { - result->attrs.secure = - !((env->cp15.vtcr_el2 & (VTCR_NSA | VTCR_NSW)) - || (env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW))); - } - } + /* + * Check if IPA translates to secure or non-secure PA space. + * Note that VSTCR overrides VTCR and {N}SW overrides {N}SA. + */ + result->attrs.secure = + (is_secure + && !(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW)) + && (ipa_secure + || !(env->cp15.vtcr_el2 & (VTCR_NSA | VTCR_NSW)))); + return 0; } else { /*