From nobody Sun May 19 15:05:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1691417758; cv=none; d=zohomail.com; s=zohoarc; b=mUVwLaj9Ad2GSg80iZ8cQ9VuxDyTYN+ldAvs2qXJN228ZRPAWCQxyHgq4nZJ+03Wt1QP419iVmVzvDjkGHH5bxPUP3iOcb4AgMtWg7Ghe4FbrN9p2zQqFiMtbLxd+KgYcvyUfdp7h8APa1lCbQdku4jky+wSVTC2wJN94ESWikU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691417758; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Bd+htH+P/WAjyuut/9qNXD2yHqngSJFvzj95KpMX1XE=; b=Atl1FEpX/pZq96UyUd/a6WbnW7FkffqZ44xr3TNYiLhVA7ja48qVYpv5cnGrasTUVosNRBgT704RUoNMMfmnrnR235PO6NnXhv2GC8Ty2qyUUMK1SXIlDrGAimtIEZUvNu3H5erbrSVfN6aWRWeCW+0GFPtOIxqZxRXKlCCCAKM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1691417758635202.04381835784227; Mon, 7 Aug 2023 07:15:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qT10z-000076-RF; Mon, 07 Aug 2023 10:15:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qT10y-00005U-6v for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:20 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qT10w-0005RC-Gj for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:19 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3fe4cdb724cso25946915e9.1 for ; Mon, 07 Aug 2023 07:15:18 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id h20-20020a05600c261400b003fe2ebf479fsm10835617wma.36.2023.08.07.07.15.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 07:15:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691417717; x=1692022517; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Bd+htH+P/WAjyuut/9qNXD2yHqngSJFvzj95KpMX1XE=; b=b9GWWpqXYW/sxNzDU1E9+PZeNZADDu5zouObLzVPCQcoP4Q0517U1RCjfzutnvs5qo QOILXRh/Df8QxzEgRWrkmlVetzFYs6EFCkAQ+hdWWyQpcf2qNj/zFsjPAdJ1W14ZeSQ6 sQYhmiemo+8aBhlWD+rAIYKQDGrsqzwUz46f22odvZJaQWMhG+VWDomJsPg+yja7LT0L b+DJdEC59q+8Ks5JWNndKupjs3gfKcd3UuvsZQBQ0d4qp1x1vGLJjUcR8brGoLAkwkjB 0vI+MglgY1QbNuGlWzjqYJbB/diNdsDMNufycfaqt/jfOwOW7nnLmcUCi6DL0PLW3CoJ RHpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691417717; x=1692022517; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bd+htH+P/WAjyuut/9qNXD2yHqngSJFvzj95KpMX1XE=; b=DMOR69zuhhXf034eKLvmPxkmHwXNyU5If0OT8DQntGvJAOr6gPXj+LEXwzxf//6IO7 CBr2ylfdAxeIkx4Nqk6funMMJ3EjZSiz3wdHpy1t++faWgpES/FZOq13NcWJfut6IHYf WA6QlkxSPE3xpxZ5DWPDwXVdy/mpmcSe4dH+2N8c5igjRlZhdC0c3aISDJ0T02sMRw1Q DIGmtIVuo8iOUQan8hNzpkkQaTspIEKXdyRJja5Z+y+0fn9lnBXmGkRnS05zcZEo/aA2 s2foEwxNJLBAxfzefAGNpdcxywpRzWweCJ9D99hpOpPO9Ag+3gcZ2z3beAf2nb9b40E3 RKDA== X-Gm-Message-State: AOJu0YwKyycrjdPj3ODuWhKr8ITcAk4//kSdP/UjxD8dbtsuP03XQCcq eNtZ9KGLR2k4hvNgdQo923sJphhZytOdif8oYYc= X-Google-Smtp-Source: AGHT+IHonYggG74sTbz1Se8sctQqU0LTlogRZdxSQx3M99zyTWvdbuoCaH+/eJ6b5hZXQU8wSlmb/g== X-Received: by 2002:a7b:c846:0:b0:3fe:20ef:1d32 with SMTP id c6-20020a7bc846000000b003fe20ef1d32mr7428318wml.10.1691417717000; Mon, 07 Aug 2023 07:15:17 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 01/15] target/arm/ptw: Don't set fi->s1ptw for UnsuppAtomicUpdate fault Date: Mon, 7 Aug 2023 15:15:00 +0100 Message-Id: <20230807141514.19075-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807141514.19075-1-peter.maydell@linaro.org> References: <20230807141514.19075-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1691417853684100002 Content-Type: text/plain; charset="utf-8" For an Unsupported Atomic Update fault where the stage 1 translation table descriptor update can't be done because it's to an unsupported memory type, this is a stage 1 abort (per the Arm ARM R_VSXXT). This means we should not set fi->s1ptw, because this will cause the code in the get_phys_addr_lpae() error-exit path to mark it as stage 2. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/ptw.c | 1 - 1 file changed, 1 deletion(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 8f94100c61f..bafeb876ad7 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -701,7 +701,6 @@ static uint64_t arm_casq_ptw(CPUARMState *env, uint64_t= old_val, =20 if (unlikely(!host)) { fi->type =3D ARMFault_UnsuppAtomicUpdate; - fi->s1ptw =3D true; return 0; } =20 --=20 2.34.1 From nobody Sun May 19 15:05:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1691417773; cv=none; d=zohomail.com; s=zohoarc; b=QE8grZt13UbKcZmh8/4GOl4fTxl+GmwE/vXf5JJSvwhCsfAxruEV7AggsaEZc5HK1dtjntP9SYun+JzHDJ6hAkYDm2f5DST5YHi/0V8VmNerU0I+GCx8Qpt5Ys5rn8T/YWtw2Lmk3lRzqTV1jI8GPiJ0CLMth3lFQwz+prHztaM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691417773; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mTF0rpR5T9/+RGJwHtQl5zTiqKLJXEt3Fbl4hFG5dDw=; b=kq64QD9q3iIltOOhr3a1NtojdcM+93CqoDWwGGSH6VgDysBUIwJF4CQ3Nk7BkTH+pSol0Fp0bSwKrIZra+P/DbkAUFar8qJbTKisOKfxw1enB7JuMiog1QAOxwtwSZF2Xlwmn2ea5FTjNacBaHJL5ddUoU3eOF/W3QvFZjeGMZw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1691417773012748.9969732783326; Mon, 7 Aug 2023 07:16:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qT11U-0000FF-75; Mon, 07 Aug 2023 10:15:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qT10z-00007g-Ub for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:21 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qT10x-0005RU-2j for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:21 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fe4b95c371so16784395e9.1 for ; Mon, 07 Aug 2023 07:15:18 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id h20-20020a05600c261400b003fe2ebf479fsm10835617wma.36.2023.08.07.07.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 07:15:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691417717; x=1692022517; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=mTF0rpR5T9/+RGJwHtQl5zTiqKLJXEt3Fbl4hFG5dDw=; b=Kmnnw5f6J1PD5PC8Gkwbux13uGZIYn7v57Sy74U+sqM17YqR+Hs6bjf1diPoqv5QaR HZpN08etf2GPFvfCgJ1banmEscT/8QPya9FCSUee4xlt3GNdXtjP6VU6zRzabRDWTWUL rm8wa/JTA8IWd+IYBSQQE9yURgXWzQfJn/0X7t5D0lu7fBr0kDO9EAT04spiaAAOcxJb NQKPy/CdXZfGmVZtwB3sxe7EvI6FQAUUVGkxOMGEFy58Sv0rK1xgV4qJdHkFWLaXDFKZ PFABke3Yne31pkA8RSM9TVvvAjn0OGJShU2OFDC72AQ1+Dd2CZ820GHofWD5JsS3b3qk ONWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691417717; x=1692022517; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mTF0rpR5T9/+RGJwHtQl5zTiqKLJXEt3Fbl4hFG5dDw=; b=VxapGYaabmvHsdIOfIGbWKgMJVK25MwWnpqKKKFNP7iDlqvHCDqXevtNRDvsZXnO3d NpeUcF3F9FtAWTpTrnzdTiphQXv2pW3rsnfSzbic/khXxwLGMj3AKKQCpQBt0mQ1YzSi jqO7EkGn3hRdxtDO38rPysIr24WMNfxpBUt281qhuVLMtiB/AQ+IbeS+CO51dbeCvzjN Hr5u9mW6lQz6c69zrfU7dielkJaatLTKFdo1EeGXfzRONVIVb5jaX1yUes2nG5PpB5yh 5UolADB0zwNRhrHnG0XkjONIyZxmgTACKPi+/+lR8wrLssFjZ8yLZLkvvXcRVSM78qi3 vpeQ== X-Gm-Message-State: AOJu0YzMzoGPI0ZkchbJcZ7oGvjY5SV5Z6IM/x3xAds9qrVhfPSMf+4H gJ7B1PlYtb2trfft6WXH7bJPBqZa7+FL3vckPyw= X-Google-Smtp-Source: AGHT+IHDhP6kL82ZAaEDUbCRhyDeVxyDJ0XZQykVAh6jWOo+S1ZbI5g/dauN+zjh/Aei01UZwUhDzA== X-Received: by 2002:a05:600c:1d05:b0:3fb:e1d0:6417 with SMTP id l5-20020a05600c1d0500b003fbe1d06417mr5437826wms.19.1691417717623; Mon, 07 Aug 2023 07:15:17 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 02/15] target/arm/ptw: Don't report GPC faults on stage 1 ptw as stage2 faults Date: Mon, 7 Aug 2023 15:15:01 +0100 Message-Id: <20230807141514.19075-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807141514.19075-1-peter.maydell@linaro.org> References: <20230807141514.19075-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1691417822754100001 Content-Type: text/plain; charset="utf-8" In S1_ptw_translate() we set up the ARMMMUFaultInfo if the attempt to translate the page descriptor address into a physical address fails. This used to only be possible if we are doing a stage 2 ptw for that descriptor address, and so the code always sets fi->stage2 and fi->s1ptw to true. However, with FEAT_RME it is also possible for the lookup of the page descriptor address to fail because of a Granule Protection Check fault. These should not be reported as stage 2, otherwise arm_deliver_fault() will incorrectly set HPFAR_EL2. Similarly the s1ptw bit should only be set for stage 2 faults on stage 1 translation table walks, i.e. not for GPC faults. Add a comment to the the other place where we might detect a stage2-fault-on-stage-1-ptw, in arm_casq_ptw(), noting why we know in that case that it must really be a stage 2 fault and not a GPC fault. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/ptw.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index bafeb876ad7..eb57ebd897b 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -600,8 +600,8 @@ static bool S1_ptw_translate(CPUARMState *env, S1Transl= ate *ptw, fi->type =3D ARMFault_GPCFOnWalk; } fi->s2addr =3D addr; - fi->stage2 =3D true; - fi->s1ptw =3D true; + fi->stage2 =3D regime_is_stage2(s2_mmu_idx); + fi->s1ptw =3D fi->stage2; fi->s1ns =3D !is_secure; return false; } @@ -719,6 +719,12 @@ static uint64_t arm_casq_ptw(CPUARMState *env, uint64_= t old_val, env->tlb_fi =3D NULL; =20 if (unlikely(flags & TLB_INVALID_MASK)) { + /* + * We know this must be a stage 2 fault because the granule + * protection table does not separately track read and write + * permission, so all GPC faults are caught in S1_ptw_translat= e(): + * we only get here for "readable but not writeable". + */ assert(fi->type !=3D ARMFault_None); fi->s2addr =3D ptw->out_virt; fi->stage2 =3D true; --=20 2.34.1 From nobody Sun May 19 15:05:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1691417860; cv=none; d=zohomail.com; s=zohoarc; b=Ai2D0P51IdMgNU6ROV+2teBVUoC8+xWB+crNqvFJr2ftgA/1hBXGpMUp/kSpQW+uQBZfGpLiK7GdOX39tzkn6IS80hjgYcO/Y+tHMJbCZFz2WPhEkUFcBduw4LpkMr17P6+vXvflQKEBZs5gWZohvBt7ed+q+WLw8yGYmCEHcSM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691417860; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lEu4y95quZyOnfSNj/UQtZgzoOcsDey9aZLknEbvT3o=; b=DD6djV1jU5PSrakxIRDMITSvijaRpOrxRXnHV5RG6dVWDElEIFkMCPe9/qnfHFUdbcFMuome7yeyiTbmIQfQ6cRnImBM1Henkn7uQQ5Xn6Z8/gfDPEjZH28U26kGf3K8RlCStLHnmCWmQZRq2eOJhuHDrPphfXrcuNizFoaawF4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1691417860643517.274062665304; Mon, 7 Aug 2023 07:17:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qT12P-0001tE-Tq; Mon, 07 Aug 2023 10:16:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qT114-00008q-Q2 for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:28 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qT10y-0005Rq-0j for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:22 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3fe45481edfso36005515e9.1 for ; Mon, 07 Aug 2023 07:15:19 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id h20-20020a05600c261400b003fe2ebf479fsm10835617wma.36.2023.08.07.07.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 07:15:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691417718; x=1692022518; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=lEu4y95quZyOnfSNj/UQtZgzoOcsDey9aZLknEbvT3o=; b=zyd9Hod5fYJ8oZzm3df5Jw3vw9gzN/MCBrJeyt8C/LlpxrF1YiEg2kaTt9mVAjCHgI AofhnuY6joPeOA6JwHH2p395l3UYXuThvvkK2B3IOEmnG6ERPOdvEe+AtcQHP8787GdE adxMn3YSh9F6WAhPIB+GucGijLCwkYOaCUHhHQru2XSM6Mh9AIhGKpPGqANylM6i7g8R a3rTUVeN465xivsPKCI2BAISt/fHB53encUvqv5ePX+nLZHq3xV7v6r1cg3WTXNxPdD9 l+nTuq3QijFdOoKuvvIKnaElfRn0FjQ79wdJxhoZs9O2m1qD7ahvl0ED63K9SD9bgom0 2Pwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691417718; x=1692022518; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lEu4y95quZyOnfSNj/UQtZgzoOcsDey9aZLknEbvT3o=; b=Da+ajzjEfwcJGP5zmw7yTJB82pVxupaN+azALbvfbL6mr7i2Yfvj8qmLsCtgpWJ7U5 8sbbAatOlifpN0LD9Vj2Yq0wmSUeS2tazw+yRNJYdDQ7lGLw4VZxTw1brgaPOBKdeMz1 G4kfnTiKxrZSiDVN4zF2GX2TSQLkV5BmHwwaBcMfTGaiOSN1Ev3uI4LNToDREYiYeJRf u+k5oqCZ2hf9ndRxM3/NE1YKJC/JnYDwxjL2xf9D/GMOC1BWODN6Rb3A1klxk+F6GyEm I0DWb60OkxT/oTP8mfeAXV6l4cW0/0F7Bm7BNCKy2NBhsEwKXpOjNxpHkok6lUM+i7RE dmXw== X-Gm-Message-State: AOJu0YwqLftnXg1dj7uMczcHVdRZCW+0727Zo+rXc1FNC/6yuXLF8e/J M3zmjvNzs/sCLjhg7uYtGQF4Oe1W71RwRgiAiw8= X-Google-Smtp-Source: AGHT+IFCLbogZxvwYEhMPzY9/SpC3iD7f0t+HvR9yEA39VixFeNl9lPDrQuYlCYoYWyuIdqpGsGF/w== X-Received: by 2002:a05:600c:2213:b0:3fe:2b76:3d7 with SMTP id z19-20020a05600c221300b003fe2b7603d7mr7638091wml.10.1691417718272; Mon, 07 Aug 2023 07:15:18 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 03/15] target/arm/ptw: Set s1ns bit in fault info more consistently Date: Mon, 7 Aug 2023 15:15:02 +0100 Message-Id: <20230807141514.19075-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807141514.19075-1-peter.maydell@linaro.org> References: <20230807141514.19075-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1691418121671100001 Content-Type: text/plain; charset="utf-8" The s1ns bit in ARMMMUFaultInfo is documented as "true if we faulted on a non-secure IPA while in secure state". Both the places which look at this bit only do so after having confirmed that this is a stage 2 fault and we're dealing with Secure EL2, which leaves the ptw.c code free to set the bit to any random value in the other cases. Instead of taking advantage of that freedom, consistently make the bit be set to false for the "not a stage 2 fault for Secure EL2" cases. This removes some cases where we were using an 'is_secure' boolean and leaving the reader guessing about whether that was the right thing for Realm and Root cases. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/ptw.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index eb57ebd897b..67078ae3509 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -514,6 +514,17 @@ static ARMSecuritySpace S2_security_space(ARMSecurityS= pace s1_space, } } =20 +static bool fault_s1ns(ARMSecuritySpace space, ARMMMUIdx s2_mmu_idx) +{ + /* + * For stage 2 faults in Secure EL22, S1NS indicates + * whether the faulting IPA is in the Secure or NonSecure + * IPA space. For all other kinds of fault, it is false. + */ + return space =3D=3D ARMSS_Secure && regime_is_stage2(s2_mmu_idx) + && s2_mmu_idx =3D=3D ARMMMUIdx_Stage2_S; +} + /* Translate a S1 pagetable walk through S2 if needed. */ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, hwaddr addr, ARMMMUFaultInfo *fi) @@ -586,7 +597,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Transl= ate *ptw, fi->s2addr =3D addr; fi->stage2 =3D true; fi->s1ptw =3D true; - fi->s1ns =3D !is_secure; + fi->s1ns =3D fault_s1ns(ptw->in_space, s2_mmu_idx); return false; } } @@ -602,7 +613,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Transl= ate *ptw, fi->s2addr =3D addr; fi->stage2 =3D regime_is_stage2(s2_mmu_idx); fi->s1ptw =3D fi->stage2; - fi->s1ns =3D !is_secure; + fi->s1ns =3D fault_s1ns(ptw->in_space, s2_mmu_idx); return false; } =20 @@ -729,7 +740,7 @@ static uint64_t arm_casq_ptw(CPUARMState *env, uint64_t= old_val, fi->s2addr =3D ptw->out_virt; fi->stage2 =3D true; fi->s1ptw =3D true; - fi->s1ns =3D !ptw->in_secure; + fi->s1ns =3D fault_s1ns(ptw->in_space, ptw->in_ptw_idx); return 0; } =20 @@ -2030,7 +2041,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, fi->level =3D level; /* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */ fi->stage2 =3D fi->s1ptw || regime_is_stage2(mmu_idx); - fi->s1ns =3D mmu_idx =3D=3D ARMMMUIdx_Stage2; + fi->s1ns =3D fault_s1ns(ptw->in_space, mmu_idx); return true; } =20 --=20 2.34.1 From nobody Sun May 19 15:05:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1691417797; cv=none; d=zohomail.com; s=zohoarc; b=dTIi0878dQnb1YtO2cRIhkjYOP2htQUYm9GKykPpMBWRHesICaEZ99ArMAjYdNg2j+I4VBUpgwqA9csHFKLo6xIZNWmA2VNseMS7JZKQnKt3dUawjyORVFhf2v2HtCHRP5A+pjhH40JR54mJMZdt+TqBtpKOTqtKxJeuqiVefzU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691417797; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sGWyEVC15cSw0RGmrkTizt56Pprj0lvgMLuupfaouu0=; b=PW+LUlWTeiefadbwIkxGAbprwpyPrMCRn4a7zgEnVPNKtR1hAFxqurwMhubBMJS+S1af0hOOxzwxNAghaNhTsW9JxlZ4zwVt8Gi2pVCmXai3TaGtYn4oLA5Rn1xI6Mmi4m/rMSmIwpSzVjq7WJBylAElsI9utYk2FsONUCiGw+M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1691417797474258.64673447249254; Mon, 7 Aug 2023 07:16:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qT11p-0000jt-TO; Mon, 07 Aug 2023 10:16:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qT114-00008n-QY for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:28 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qT10y-0005Ry-9S for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:23 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-31763b2c5a4so4011725f8f.3 for ; Mon, 07 Aug 2023 07:15:19 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id h20-20020a05600c261400b003fe2ebf479fsm10835617wma.36.2023.08.07.07.15.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 07:15:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691417719; x=1692022519; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=sGWyEVC15cSw0RGmrkTizt56Pprj0lvgMLuupfaouu0=; b=DyRaoKnhlj/UQJXJoClktL2ssTbGA9PuoG11NGpejgUz4KzuqL+tTm0EEibVoe4J4s qg0/csyhKnE1tEFpO06RoHsFYmeUUenQ8jU1IDz5w+3cycKT3Bnq5V/fQ6wKIZwTzM01 BOzlYQ3qzQEfYQ+SWzeoDNIgweAaKZA28udG8EYyr+GDJ5mD07yFiiq7ifpU+VxelZ/e JnQpXcfVOKUhWQZrOsMkRbvBPaCeupxPLm74FQaOw3b0IKfyO1lFSzuGuPvlKSKl4o9i xk4ON2lBOtkqPo1jqPo37b5FghNnNEXe9GYcel8c/lleMHgRE54dKWmUGCHXSC0++U4+ 751Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691417719; x=1692022519; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sGWyEVC15cSw0RGmrkTizt56Pprj0lvgMLuupfaouu0=; b=EEtkoOMPD2rOAndg/beu1p5+yIrjfGKh/xB+xVNenyuTeokorzN8EE5FWr+NGCCy5r icY61yE9Egg/s7iz42L8qKiJicRP6rKdL1Tc4sEZx8EymqW8JgWKRejbrfzfk6SOaKNh CAklFjoSjj7h43D8Um4C503b9aCfCOYvsxDPWgVK37glePYGgXUvX7lkCZy67Af0cY+U Nr6OY4W4SZ99qZNMFHmb9o47rNd8Gl8PvmdzG9lu0LdmY9maF3tknkkC2cazhHcgD9a2 2qKzWmm0llExT5B2AOdMP/76zzmbyNcqxIK1DOHjQAYTpabhtZ89y11sa/3/zf1+WBz4 UGbQ== X-Gm-Message-State: AOJu0Yy+bo4uuxpNr7jANn0PH+nrbB3F7A7+xnT9oliK5LY+/1Tq0Awa isgANkn6+OUZsz6Nt2YJtN8o3g== X-Google-Smtp-Source: AGHT+IH4Xk+6ksM9+ZtyPGNSZbXdRyQtzzqyXCh67Vi+K2aQJFVE9+Rqyby4690Rpw2MzvANSTlgcw== X-Received: by 2002:adf:e604:0:b0:317:3e58:64cb with SMTP id p4-20020adfe604000000b003173e5864cbmr7870546wrm.46.1691417718752; Mon, 07 Aug 2023 07:15:18 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 04/15] target/arm/ptw: Pass ptw into get_phys_addr_pmsa*() and get_phys_addr_disabled() Date: Mon, 7 Aug 2023 15:15:03 +0100 Message-Id: <20230807141514.19075-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807141514.19075-1-peter.maydell@linaro.org> References: <20230807141514.19075-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1691417853649100001 Content-Type: text/plain; charset="utf-8" In commit 6d2654ffacea813916176 we created the S1Translate struct and used it to plumb through various arguments that we were previously passing one-at-a-time to get_phys_addr_v5(), get_phys_addr_v6(), and get_phys_addr_lpae(). Extend that pattern to get_phys_addr_pmsav5(), get_phys_addr_pmsav7(), get_phys_addr_pmsav8() and get_phys_addr_disabled(), so that all the get_phys_addr_* functions we call from get_phys_addr_nogpc() take the S1Translate struct rather than the mmu_idx and is_secure bool. (This refactoring is a prelude to having the called functions look at ptw->is_space rather than using an is_secure boolean.) Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/ptw.c | 57 ++++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 67078ae3509..a873fbe0239 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2045,15 +2045,19 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1= Translate *ptw, return true; } =20 -static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_= idx, - bool is_secure, GetPhysAddrResult *result, +static bool get_phys_addr_pmsav5(CPUARMState *env, + S1Translate *ptw, + uint32_t address, + MMUAccessType access_type, + GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { int n; uint32_t mask; uint32_t base; + ARMMMUIdx mmu_idx =3D ptw->in_mmu_idx; bool is_user =3D regime_is_user(env, mmu_idx); + bool is_secure =3D arm_space_is_secure(ptw->in_space); =20 if (regime_translation_disabled(env, mmu_idx, is_secure)) { /* MPU disabled. */ @@ -2210,14 +2214,18 @@ static bool pmsav7_use_background_region(ARMCPU *cp= u, ARMMMUIdx mmu_idx, return regime_sctlr(env, mmu_idx) & SCTLR_BR; } =20 -static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_= idx, - bool secure, GetPhysAddrResult *result, +static bool get_phys_addr_pmsav7(CPUARMState *env, + S1Translate *ptw, + uint32_t address, + MMUAccessType access_type, + GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { ARMCPU *cpu =3D env_archcpu(env); int n; + ARMMMUIdx mmu_idx =3D ptw->in_mmu_idx; bool is_user =3D regime_is_user(env, mmu_idx); + bool secure =3D arm_space_is_secure(ptw->in_space); =20 result->f.phys_addr =3D address; result->f.lg_page_size =3D TARGET_PAGE_BITS; @@ -2736,12 +2744,16 @@ void v8m_security_lookup(CPUARMState *env, uint32_t= address, } } =20 -static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_= idx, - bool secure, GetPhysAddrResult *result, +static bool get_phys_addr_pmsav8(CPUARMState *env, + S1Translate *ptw, + uint32_t address, + MMUAccessType access_type, + GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { V8M_SAttributes sattrs =3D {}; + ARMMMUIdx mmu_idx =3D ptw->in_mmu_idx; + bool secure =3D arm_space_is_secure(ptw->in_space); bool ret; =20 if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { @@ -3045,12 +3057,15 @@ static ARMCacheAttrs combine_cacheattrs(uint64_t hc= r, * MMU disabled. S1 addresses within aa64 translation regimes are * still checked for bounds -- see AArch64.S1DisabledOutput(). */ -static bool get_phys_addr_disabled(CPUARMState *env, target_ulong address, +static bool get_phys_addr_disabled(CPUARMState *env, + S1Translate *ptw, + target_ulong address, MMUAccessType access_type, - ARMMMUIdx mmu_idx, bool is_secure, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { + ARMMMUIdx mmu_idx =3D ptw->in_mmu_idx; + bool is_secure =3D arm_space_is_secure(ptw->in_space); uint8_t memattr =3D 0x00; /* Device nGnRnE */ uint8_t shareability =3D 0; /* non-shareable */ int r_el; @@ -3252,8 +3267,8 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1T= ranslate *ptw, case ARMMMUIdx_Phys_Root: case ARMMMUIdx_Phys_Realm: /* Checking Phys early avoids special casing later vs regime_el. */ - return get_phys_addr_disabled(env, address, access_type, mmu_idx, - is_secure, result, fi); + return get_phys_addr_disabled(env, ptw, address, access_type, + result, fi); =20 case ARMMMUIdx_Stage1_E0: case ARMMMUIdx_Stage1_E1: @@ -3321,16 +3336,16 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S= 1Translate *ptw, =20 if (arm_feature(env, ARM_FEATURE_V8)) { /* PMSAv8 */ - ret =3D get_phys_addr_pmsav8(env, address, access_type, mmu_id= x, - is_secure, result, fi); + ret =3D get_phys_addr_pmsav8(env, ptw, address, access_type, + result, fi); } else if (arm_feature(env, ARM_FEATURE_V7)) { /* PMSAv7 */ - ret =3D get_phys_addr_pmsav7(env, address, access_type, mmu_id= x, - is_secure, result, fi); + ret =3D get_phys_addr_pmsav7(env, ptw, address, access_type, + result, fi); } else { /* Pre-v7 MPU */ - ret =3D get_phys_addr_pmsav5(env, address, access_type, mmu_id= x, - is_secure, result, fi); + ret =3D get_phys_addr_pmsav5(env, ptw, address, access_type, + result, fi); } qemu_log_mask(CPU_LOG_MMU, "PMSA MPU lookup for %s at 0x%08" PRIx32 " mmu_idx %u -> %s (prot %c%c%c)\n", @@ -3348,8 +3363,8 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1T= ranslate *ptw, /* Definitely a real MMU, not an MPU */ =20 if (regime_translation_disabled(env, mmu_idx, is_secure)) { - return get_phys_addr_disabled(env, address, access_type, mmu_idx, - is_secure, result, fi); + return get_phys_addr_disabled(env, ptw, address, access_type, + result, fi); } =20 if (regime_using_lpae_format(env, mmu_idx)) { --=20 2.34.1 From nobody Sun May 19 15:05:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1691417822; cv=none; d=zohomail.com; s=zohoarc; b=JsugVghzGwSRMEDIge1+55r9iOJ6k3KtdErU7mY5Cg0K6aipRtVnXK/lSxPabO39cXS3CrAhmamBlY6VKTsfj7ZW5x1jJTEnWUKzI16x5hEwNSKCh9yvDADV8h6A3SptULfO7ViYhFCBiubh12h14BmjmnIqf8U6Mj68UgWkLvI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691417822; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NbiccwBAU2xAl/qEFIXdbuxGrXw7jKmkAECaPM8LQRA=; b=JElaD1ghpYj7hhQRvqHPlUbfA1zJqAhbGN55oLVJIb3LWQTQiXmPhuZYaCpnvsaDjVVJJIJZkqfmxXcYHgLYawaVTX52J7uQA8qz3Fxkg8JCmmfS1FtajHC7lUIbUKDsbpxF9SNIGFZcwoMBHkkeDxyml0hPGNi8oTZiBvSMwxI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1691417822484871.1450909296096; Mon, 7 Aug 2023 07:17:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qT11p-0000fS-Ep; Mon, 07 Aug 2023 10:16:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qT114-00008u-Qy for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:28 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qT10y-0005SB-Nb for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:24 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fbea147034so39301195e9.0 for ; Mon, 07 Aug 2023 07:15:20 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id h20-20020a05600c261400b003fe2ebf479fsm10835617wma.36.2023.08.07.07.15.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 07:15:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691417719; x=1692022519; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=NbiccwBAU2xAl/qEFIXdbuxGrXw7jKmkAECaPM8LQRA=; b=PStWaomuWsgH8MrHlhPDKhV+hpru9KiwIS76TimVXzFilDUGdT6CCaJg9W8e0ffrGY p+PXZyYeaLFdirJqGXJ4LiytIUUTFbKVE2FNjLg2NXukFVamseuHgfSnKeV6jvouFT6l lSPXMwi37D29/IRACJmrzdkwNwYGpf00YdSYcC5IuhSgvLJXc82vU8DrYmHb0TQD4En3 FHZrOyfwarxipyCJUWHB0fEz2palTn9IQSapBmmD+hiB/2XZc6F4s/aE+62kyfS6Shbp fh8zAzC2CAuYpkEpaOQMCHq2YJIZr9gXGjToyQS1tERVYpCUv8J6K6XY6EDAcS6ptfIT YjVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691417719; x=1692022519; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NbiccwBAU2xAl/qEFIXdbuxGrXw7jKmkAECaPM8LQRA=; b=D6ULVbauDqw+FkTieQfEcSoGfSgMFA4Mo+pDKFU2Fpj2/UAxjFjM9BqWYVyKi+Nl3i dFI8miwM17CALc0J3h4gTk5jSlzSRvEnEpvzhZOmvnvPt3NPp8GWIScIg8W93C3Q2KbB heQn5aYSZxOyZKq0lGpegIv2lPvkORjtJOD18KNAyW6e8WPrDhghak8MIG7r6p3gFMzk ddkZB7uF8VqsCDBBj+5DMIlYd89Xz7To0pnLRpUaC5v218OUOgJBm2vxfnvra6RM95SI nEtQynHX3ywBS50xsPWARrv79YyZ5v8czd2aHZ7cKQaZtEnuS4U2I2vY7uWWXFngrt8+ GfhA== X-Gm-Message-State: AOJu0Yw7kTQw91y9FNay3tW8kJQ6O26POPqeONQ/BPT1kf5Yn8YsJt9+ UiMsEzZSUixEjM89/qKluuKSD5JLIHHvftfvUbA= X-Google-Smtp-Source: AGHT+IF8rGgQ8+SEvCpD3mNXWz2r9nioOWObTKCGkOQhvgqfXuGQtqPSRmVFUx6W2B67tRFJwxZZPw== X-Received: by 2002:a05:600c:221a:b0:3fc:9e:eead with SMTP id z26-20020a05600c221a00b003fc009eeeadmr6401525wml.20.1691417719289; Mon, 07 Aug 2023 07:15:19 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 05/15] target/arm/ptw: Pass ARMSecurityState to regime_translation_disabled() Date: Mon, 7 Aug 2023 15:15:04 +0100 Message-Id: <20230807141514.19075-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807141514.19075-1-peter.maydell@linaro.org> References: <20230807141514.19075-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1691417903923100001 Content-Type: text/plain; charset="utf-8" Plumb the ARMSecurityState through to regime_translation_disabled() rather than just a bool is_secure. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/ptw.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index a873fbe0239..63dd8e3cbe1 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -206,9 +206,10 @@ static uint64_t regime_ttbr(CPUARMState *env, ARMMMUId= x mmu_idx, int ttbrn) =20 /* Return true if the specified stage of address translation is disabled */ static bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_id= x, - bool is_secure) + ARMSecuritySpace space) { uint64_t hcr_el2; + bool is_secure =3D arm_space_is_secure(space); =20 if (arm_feature(env, ARM_FEATURE_M)) { switch (env->v7m.mpu_ctrl[is_secure] & @@ -2057,9 +2058,8 @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t base; ARMMMUIdx mmu_idx =3D ptw->in_mmu_idx; bool is_user =3D regime_is_user(env, mmu_idx); - bool is_secure =3D arm_space_is_secure(ptw->in_space); =20 - if (regime_translation_disabled(env, mmu_idx, is_secure)) { + if (regime_translation_disabled(env, mmu_idx, ptw->in_space)) { /* MPU disabled. */ result->f.phys_addr =3D address; result->f.prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; @@ -2231,7 +2231,7 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, result->f.lg_page_size =3D TARGET_PAGE_BITS; result->f.prot =3D 0; =20 - if (regime_translation_disabled(env, mmu_idx, secure) || + if (regime_translation_disabled(env, mmu_idx, ptw->in_space) || m_is_ppb_region(env, address)) { /* * MPU disabled or M profile PPB access: use default memory map. @@ -2475,7 +2475,8 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t add= ress, * are done in arm_v7m_load_vector(), which always does a direct * read using address_space_ldl(), rather than going via this function. */ - if (regime_translation_disabled(env, mmu_idx, secure)) { /* MPU disabl= ed */ + if (regime_translation_disabled(env, mmu_idx, arm_secure_to_space(secu= re))) { + /* MPU disabled */ hit =3D true; } else if (m_is_ppb_region(env, address)) { hit =3D true; @@ -3303,7 +3304,7 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1T= ranslate *ptw, */ ptw->in_mmu_idx =3D mmu_idx =3D s1_mmu_idx; if (arm_feature(env, ARM_FEATURE_EL2) && - !regime_translation_disabled(env, ARMMMUIdx_Stage2, is_secure)= ) { + !regime_translation_disabled(env, ARMMMUIdx_Stage2, ptw->in_sp= ace)) { return get_phys_addr_twostage(env, ptw, address, access_type, result, fi); } @@ -3362,7 +3363,7 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1T= ranslate *ptw, =20 /* Definitely a real MMU, not an MPU */ =20 - if (regime_translation_disabled(env, mmu_idx, is_secure)) { + if (regime_translation_disabled(env, mmu_idx, ptw->in_space)) { return get_phys_addr_disabled(env, ptw, address, access_type, result, fi); } --=20 2.34.1 From nobody Sun May 19 15:05:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1691417874; cv=none; d=zohomail.com; s=zohoarc; b=nSuc2why/wfLoSG4QQMRVWERQpMGalmArk46NrdojtmQOC1sNkw0FLvBOcsn+DWubaioM7top/zUc4E7QQH4ZB/v0mM2DGRQ5nN17KXvzrD7gq9tn6NdJS7fIuIUkjBUpWAEL0X5XUqmZyUQy/5yGu3gUfejRjasDpwgIb+uXm4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691417874; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wGPGvej2mg6PydRuAT/KJYpLUQ8OQzMCYsuiZcL8/Tw=; b=n0ELZuaomXN7SIIIJPl7P3ze9WXBlOoOJBrphWbM2YyxQoNXdj8gMfCENhNsqM49Wd+OOQnMYMck8eLcS5XXxxd0YfhGH22+F1Grn0yNSaTA9nYJuUpAMBwHdzoFGVdIOoRdsx0oFDpEYcBv/DudNgm8h5fgi2ysucriS9nLH84= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1691417874130207.4049530353982; Mon, 7 Aug 2023 07:17:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qT11t-0000zh-0v; Mon, 07 Aug 2023 10:16:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qT114-00008t-Qe for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:28 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qT10z-0005Sb-FW for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:24 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3fe4a89e7efso23586005e9.3 for ; Mon, 07 Aug 2023 07:15:21 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id h20-20020a05600c261400b003fe2ebf479fsm10835617wma.36.2023.08.07.07.15.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 07:15:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691417720; x=1692022520; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=wGPGvej2mg6PydRuAT/KJYpLUQ8OQzMCYsuiZcL8/Tw=; b=G4PRJ3a/72Bdm98BY93etkvweyFsaMUICoC6i85sYEHSUOvnjQPIG4PuIgKRibfoms FORfKSDnFm7izdWihlV+k7iEVD7y0UgeSQSuBJ8uj9dxk8xzQ4jEbT1+ixtlEkRjL9lq evCnnIdAsd6rfvp8+izrmF3DfnmrllmtR/vzS8h1nb40O+DI88RohjI4EsRCROpmbuii 01DjCLftGJH0lotQptqP5+HTL3RXfZulY0+y4UJ8oAuUrnAi0UJnV7DB2+RvJdduEJWH PE0KrPnKiLg3wqC8L6DI3HcxUwiGUzRbj+wB8l/WgqNSOh69TG2BEDD0LNhH01E5S/49 cCVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691417720; x=1692022520; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wGPGvej2mg6PydRuAT/KJYpLUQ8OQzMCYsuiZcL8/Tw=; b=agFQ0bcra869UZHwedAkaciR0fSEtkMc2QzBwGrpjsRatE3ZbiKDnO+GWquKQ42kNy VHTQ9DwH/BVNmYyIcV9cKhL6KuIVr1kQXny433sIf1MV6xznadJv1y8ntLP0XATH77jL 7Y66cHwTX83uWhcYf8ghqYAILxqXjGcSC8HpMhZuV6qJolCFg2BkXRtW27/HX0kXuRA2 wK/tlDDBXuyXhuYz5E6UpnDdwpQWHKG+Md0cMjf4HY9s7dc346XxycV28oaXIB6ZAqLT 9q+5VEietSDSglVIzH31kGys0xvte1xze8jVRqm0RuyM4g0uXB4tlDL+aAmFZYWNUyDB 66xA== X-Gm-Message-State: AOJu0Yx5KbYQYD144DZ32tWkLrDabrB7rWVGSlG1SmrhddKR1gOcltSM n7vvA/dCBHP8TXoPhrnEiXHI7g== X-Google-Smtp-Source: AGHT+IFBd8uThhG6a4viUYIiHtFcqKxoUKyT6MCflEN77wBHtXZ2YPhQ5oG9ge32+AV/drbgX3Swlg== X-Received: by 2002:adf:e7cb:0:b0:316:fb39:e045 with SMTP id e11-20020adfe7cb000000b00316fb39e045mr5526043wrn.48.1691417719857; Mon, 07 Aug 2023 07:15:19 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 06/15] target/arm/ptw: Pass an ARMSecuritySpace to arm_hcr_el2_eff_secstate() Date: Mon, 7 Aug 2023 15:15:05 +0100 Message-Id: <20230807141514.19075-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807141514.19075-1-peter.maydell@linaro.org> References: <20230807141514.19075-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1691418128379100001 Content-Type: text/plain; charset="utf-8" arm_hcr_el2_eff_secstate() takes a bool secure, which it uses to determine whether EL2 is enabled in the current security state. With the advent of FEAT_RME this is no longer sufficient, because EL2 can be enabled for Secure state but not for Root, and both of those will pass 'secure =3D=3D true' in the callsites in ptw.c. As it happens in all of our callsites in ptw.c we either avoid making the call or else avoid using the returned value if we're doing a translation for Root, so this is not a behaviour change even if the experimental FEAT_RME is enabled. But it is less confusing in the ptw.c code if we avoid the use of a bool secure that duplicates some of the information in the ArmSecuritySpace argument. Make arm_hcr_el2_eff_secstate() take an ARMSecuritySpace argument instead. Because we always want to know the HCR_EL2 for the security state defined by the current effective value of SCR_EL3.{NSE,NS}, it makes no sense to pass ARMSS_Root here, and we assert that callers don't do that. To avoid the assert(), we thus push the call to arm_hcr_el2_eff_secstate() down into the cases in regime_translation_disabled() that need it, rather than calling the function and ignoring the result for the Root space translations. All other calls to this function in ptw.c are already in places where we have confirmed that the mmu_idx is a stage 2 translation or that the regime EL is not 3. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- Changes v1->v2: instead of having arm_hcr_el2_eff_secstate() accept space =3D=3D ARMSS_Root and return 0, have it assert that Root is not passed, and adjust regime_translation_disabled() accordingly. --- target/arm/cpu.h | 2 +- target/arm/helper.c | 8 +++++--- target/arm/ptw.c | 15 +++++++-------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 88e5accda69..bcd65a63ca0 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2555,7 +2555,7 @@ static inline bool arm_is_el2_enabled(CPUARMState *en= v) * "for all purposes other than a direct read or write access of HCR_EL2." * Not included here is HCR_RW. */ -uint64_t arm_hcr_el2_eff_secstate(CPUARMState *env, bool secure); +uint64_t arm_hcr_el2_eff_secstate(CPUARMState *env, ARMSecuritySpace space= ); uint64_t arm_hcr_el2_eff(CPUARMState *env); uint64_t arm_hcrx_el2_eff(CPUARMState *env); =20 diff --git a/target/arm/helper.c b/target/arm/helper.c index 50f61e42ca8..9862bc73b52 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5772,11 +5772,13 @@ static void hcr_writelow(CPUARMState *env, const AR= MCPRegInfo *ri, * Bits that are not included here: * RW (read from SCR_EL3.RW as needed) */ -uint64_t arm_hcr_el2_eff_secstate(CPUARMState *env, bool secure) +uint64_t arm_hcr_el2_eff_secstate(CPUARMState *env, ARMSecuritySpace space) { uint64_t ret =3D env->cp15.hcr_el2; =20 - if (!arm_is_el2_enabled_secstate(env, secure)) { + assert(space !=3D ARMSS_Root); + + if (!arm_is_el2_enabled_secstate(env, arm_space_is_secure(space))) { /* * "This register has no effect if EL2 is not enabled in the * current Security state". This is ARMv8.4-SecEL2 speak for @@ -5840,7 +5842,7 @@ uint64_t arm_hcr_el2_eff(CPUARMState *env) if (arm_feature(env, ARM_FEATURE_M)) { return 0; } - return arm_hcr_el2_eff_secstate(env, arm_is_secure_below_el3(env)); + return arm_hcr_el2_eff_secstate(env, arm_security_space_below_el3(env)= ); } =20 /* diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 63dd8e3cbe1..4c60de753dd 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -209,9 +209,9 @@ static bool regime_translation_disabled(CPUARMState *en= v, ARMMMUIdx mmu_idx, ARMSecuritySpace space) { uint64_t hcr_el2; - bool is_secure =3D arm_space_is_secure(space); =20 if (arm_feature(env, ARM_FEATURE_M)) { + bool is_secure =3D arm_space_is_secure(space); switch (env->v7m.mpu_ctrl[is_secure] & (R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK= )) { case R_V7M_MPU_CTRL_ENABLE_MASK: @@ -230,18 +230,19 @@ static bool regime_translation_disabled(CPUARMState *= env, ARMMMUIdx mmu_idx, } } =20 - hcr_el2 =3D arm_hcr_el2_eff_secstate(env, is_secure); =20 switch (mmu_idx) { case ARMMMUIdx_Stage2: case ARMMMUIdx_Stage2_S: /* HCR.DC means HCR.VM behaves as 1 */ + hcr_el2 =3D arm_hcr_el2_eff_secstate(env, space); return (hcr_el2 & (HCR_DC | HCR_VM)) =3D=3D 0; =20 case ARMMMUIdx_E10_0: case ARMMMUIdx_E10_1: case ARMMMUIdx_E10_1_PAN: /* TGE means that EL0/1 act as if SCTLR_EL1.M is zero */ + hcr_el2 =3D arm_hcr_el2_eff_secstate(env, space); if (hcr_el2 & HCR_TGE) { return true; } @@ -251,6 +252,7 @@ static bool regime_translation_disabled(CPUARMState *en= v, ARMMMUIdx mmu_idx, case ARMMMUIdx_Stage1_E1: case ARMMMUIdx_Stage1_E1_PAN: /* HCR.DC means SCTLR_EL1.M behaves as 0 */ + hcr_el2 =3D arm_hcr_el2_eff_secstate(env, space); if (hcr_el2 & HCR_DC) { return true; } @@ -530,7 +532,6 @@ static bool fault_s1ns(ARMSecuritySpace space, ARMMMUId= x s2_mmu_idx) static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, hwaddr addr, ARMMMUFaultInfo *fi) { - bool is_secure =3D ptw->in_secure; ARMMMUIdx mmu_idx =3D ptw->in_mmu_idx; ARMMMUIdx s2_mmu_idx =3D ptw->in_ptw_idx; uint8_t pte_attrs; @@ -587,7 +588,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Transl= ate *ptw, } =20 if (regime_is_stage2(s2_mmu_idx)) { - uint64_t hcr =3D arm_hcr_el2_eff_secstate(env, is_secure); + uint64_t hcr =3D arm_hcr_el2_eff_secstate(env, ptw->in_space); =20 if ((hcr & HCR_PTW) && S2_attrs_are_device(hcr, pte_attrs)) { /* @@ -3066,7 +3067,6 @@ static bool get_phys_addr_disabled(CPUARMState *env, ARMMMUFaultInfo *fi) { ARMMMUIdx mmu_idx =3D ptw->in_mmu_idx; - bool is_secure =3D arm_space_is_secure(ptw->in_space); uint8_t memattr =3D 0x00; /* Device nGnRnE */ uint8_t shareability =3D 0; /* non-shareable */ int r_el; @@ -3112,7 +3112,7 @@ static bool get_phys_addr_disabled(CPUARMState *env, =20 /* Fill in cacheattr a-la AArch64.TranslateAddressS1Off. */ if (r_el =3D=3D 1) { - uint64_t hcr =3D arm_hcr_el2_eff_secstate(env, is_secure); + uint64_t hcr =3D arm_hcr_el2_eff_secstate(env, ptw->in_space); if (hcr & HCR_DC) { if (hcr & HCR_DCT) { memattr =3D 0xf0; /* Tagged, Normal, WB, RWA */ @@ -3149,7 +3149,6 @@ static bool get_phys_addr_twostage(CPUARMState *env, = S1Translate *ptw, { hwaddr ipa; int s1_prot, s1_lgpgsz; - bool is_secure =3D ptw->in_secure; ARMSecuritySpace in_space =3D ptw->in_space; bool ret, ipa_secure; ARMCacheAttrs cacheattrs1; @@ -3212,7 +3211,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, = S1Translate *ptw, } =20 /* Combine the S1 and S2 cache attributes. */ - hcr =3D arm_hcr_el2_eff_secstate(env, is_secure); + hcr =3D arm_hcr_el2_eff_secstate(env, in_space); if (hcr & HCR_DC) { /* * HCR.DC forces the first stage attributes to --=20 2.34.1 From nobody Sun May 19 15:05:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1691417843; cv=none; d=zohomail.com; s=zohoarc; b=BzTZ3dBIR8UZVilZQUP/jfv/LltiltqfydAkDYeCFk2FpmXoyJXxhZN8tHB6LDxoUqFpqX2P33Kvks4K58/o8Gw6cWqMUdKsPdLn5FB8qjVFMLKNiJ1RBUwgOMhdAG/jrdRzD/XVaTHdtw9jM9R74fUo4HHRK8ernjspTAadWpk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691417843; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Km5Z3LiOVN7aMvNdfTpr688xvyTx8SIvRnXYskA55+4=; b=kkhQPHzqJtTSZNnWJbDSGL/vyGflY6DKn+UydcG5BDB2RTArY0wkMrjp0/acXNcLN+3udYDDJLfBLjGRQMhvzXBOMlW0tTBtguzPDLjGQyQIFXCDwxKNOh8kxm/SxH01UkIbABA18G3gMuqgwoUJLtp7o1JFITVzKlceXuFkEK8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1691417843724114.43523975285359; Mon, 7 Aug 2023 07:17:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qT12M-0001as-Tg; Mon, 07 Aug 2023 10:16:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qT114-00008m-OB for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:27 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qT110-0005TA-HR for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:25 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-3090d3e9c92so3998889f8f.2 for ; Mon, 07 Aug 2023 07:15:21 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id h20-20020a05600c261400b003fe2ebf479fsm10835617wma.36.2023.08.07.07.15.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 07:15:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691417720; x=1692022520; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Km5Z3LiOVN7aMvNdfTpr688xvyTx8SIvRnXYskA55+4=; b=EZQvAfd1idvDCtNE1TKkywU5zhL9JK51FlrUtQkouAkbIUZIfdC+dh+XVcKuHnqIyd yyFQAF1iYrc7wOYEhtqNO99dvSEn2fchOdc69IRc6/7NWe+VciwnzkxWJWGBA+FQEj4v LjOyHX7ouC4mL4FujCa5q8blE44OYVec1Oto9JkG2X19mpv6Mr6ug4cd1euDpwbjFIXP KQGBE6koMFI4V31XpAzSGwLyzq2ZWNWyA2nMlJGeQrZVkd/FFfr+cm+gNoU+S3wmYPLw sD8dALfvoVEH8+VwXBtcUZmuJhlrsTsG/FkEMZdPtPvgZcCkLIwio2rVdSXQjt0urRws DPYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691417720; x=1692022520; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Km5Z3LiOVN7aMvNdfTpr688xvyTx8SIvRnXYskA55+4=; b=Aqp9jXfwISnlh3WEfjXe9/6w7XTIXujSyK3RoHAcbbOALhYnaOPpYtGlK8u3m9HF8A 4Hm+mQxTqeZ+mDd+/cuX0GOjSYY+f8VswxrHDrK5CnHIX0qTdtIZT/zKtQ99G3NOn3yc X4PgeNBWUGEqoeAlXLck/7jIj5RHaGs3W5U59bGM79f/N0CIQ8aYKpZ6b5eWKjo+AuqR 6nM+/MCs19hLwJwGdEf8qssXnVVmXrdWBrxLeZzXK5A73JK/HSXicFdWdvhfh0RrZuUT Tp9uXHIWRofCNSIIvGEAToVq6Vs+Q5gFPjXY7acG5oMapyaMQKtGbd9putMNyQDtvYnO pHhg== X-Gm-Message-State: AOJu0YwjMlga1fSaZlrub+O4jwkumUJ6z2qYLAPZ0PCsYsdRl9lV08Sx N2ld0/M5zIXpISqpGiPD7A14qg== X-Google-Smtp-Source: AGHT+IFz/WeDcS37ZVeJQBLxpo6d91VkdDODfUlevgNg8kZX6zkO2LYgeUM9bcEiG56CbXWdx+X87w== X-Received: by 2002:a5d:62c6:0:b0:317:6992:855c with SMTP id o6-20020a5d62c6000000b003176992855cmr6517551wrv.19.1691417720374; Mon, 07 Aug 2023 07:15:20 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 07/15] target/arm: Pass an ARMSecuritySpace to arm_is_el2_enabled_secstate() Date: Mon, 7 Aug 2023 15:15:06 +0100 Message-Id: <20230807141514.19075-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807141514.19075-1-peter.maydell@linaro.org> References: <20230807141514.19075-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1691417895793100001 Content-Type: text/plain; charset="utf-8" Pass an ARMSecuritySpace instead of a bool secure to arm_is_el2_enabled_secstate(). This doesn't change behaviour. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/cpu.h | 13 ++++++++----- target/arm/helper.c | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index bcd65a63ca0..02bc8f0e8e0 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2504,17 +2504,19 @@ static inline bool arm_is_secure(CPUARMState *env) =20 /* * Return true if the current security state has AArch64 EL2 or AArch32 Hy= p. - * This corresponds to the pseudocode EL2Enabled() + * This corresponds to the pseudocode EL2Enabled(). */ -static inline bool arm_is_el2_enabled_secstate(CPUARMState *env, bool secu= re) +static inline bool arm_is_el2_enabled_secstate(CPUARMState *env, + ARMSecuritySpace space) { + assert(space !=3D ARMSS_Root); return arm_feature(env, ARM_FEATURE_EL2) - && (!secure || (env->cp15.scr_el3 & SCR_EEL2)); + && (space !=3D ARMSS_Secure || (env->cp15.scr_el3 & SCR_EEL2)); } =20 static inline bool arm_is_el2_enabled(CPUARMState *env) { - return arm_is_el2_enabled_secstate(env, arm_is_secure_below_el3(env)); + return arm_is_el2_enabled_secstate(env, arm_security_space_below_el3(e= nv)); } =20 #else @@ -2538,7 +2540,8 @@ static inline bool arm_is_secure(CPUARMState *env) return false; } =20 -static inline bool arm_is_el2_enabled_secstate(CPUARMState *env, bool secu= re) +static inline bool arm_is_el2_enabled_secstate(CPUARMState *env, + ARMSecuritySpace space) { return false; } diff --git a/target/arm/helper.c b/target/arm/helper.c index 9862bc73b52..8290ca0aaad 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5778,7 +5778,7 @@ uint64_t arm_hcr_el2_eff_secstate(CPUARMState *env, A= RMSecuritySpace space) =20 assert(space !=3D ARMSS_Root); =20 - if (!arm_is_el2_enabled_secstate(env, arm_space_is_secure(space))) { + if (!arm_is_el2_enabled_secstate(env, space)) { /* * "This register has no effect if EL2 is not enabled in the * current Security state". This is ARMv8.4-SecEL2 speak for --=20 2.34.1 From nobody Sun May 19 15:05:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1691417779; cv=none; d=zohomail.com; s=zohoarc; b=i/dlzAS+DDmx0jVg3bBdCvl/1U+zaZuso6b1uCc0ImaQdazF//cikL7Rn49JuhzuAuDVyav0p974EprU4Vs9QcG/adTLfrsEqRD1LZwSLKpPlmlK3LmAcb+70mytAYj9iRnlNcqm8Pz/qCsNpWH7DZsYecFkhjjMeTjaqGuhdek= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691417779; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+8IbTNuSWmbWoR5bYA9YvXkfK8gqg1QeL2k9kCrgnNA=; b=fJbsfX5f+GteRR5RLweAGJLmKqizKrWfdUY+kVetj16z4UnvxxT0dmWFlNCi1PTz9RaLQxSubiLQdGCE+l/ULoNUO5LrE1DWpcKtbS2RtQagbTcq70qUmX4Pc0Q4G8ZsakkJTpib2zr2m3hqy1AofPTuhuQ+gjxd6IT3Cnr2kAI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169141777963856.531398006571635; Mon, 7 Aug 2023 07:16:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qT11W-0000Ge-Gw; Mon, 07 Aug 2023 10:15:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qT114-00008v-SB for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:28 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qT110-0005TU-H8 for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:24 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3fbea14706eso38483815e9.2 for ; Mon, 07 Aug 2023 07:15:21 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id h20-20020a05600c261400b003fe2ebf479fsm10835617wma.36.2023.08.07.07.15.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 07:15:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691417721; x=1692022521; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+8IbTNuSWmbWoR5bYA9YvXkfK8gqg1QeL2k9kCrgnNA=; b=kIUTS94AbtuEcmId9cZSsc3vaqc4GKcotoVJx0XICluSA6XMiF0MTJ1PZwyY7r2b0J MGiUjv0DFrqhzppQ4aQvQfjB5htj/acEN+2UV+wMIRtgPIJHJF3Mn+a3H8MA3zydFhw1 6+0Ue2xdWZBfiz/9L4ur0IfpFKuxkXmsbeHlNx/38ulh6I61lFC8lTrHroUuQH+2eVWK 8lg9oaR7Or/quOeuqlEk76oVnHpBGF0EuKcdUu8OC+xYt6EOzyvnJTOnexPjYqz/E8i1 aR9ouYxL2+S/T7Mlw87T/exHy+QgXO3SluOUhDLDy1zz4+6vfhF3riOy6B6Dm5P9e7JX eYtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691417721; x=1692022521; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+8IbTNuSWmbWoR5bYA9YvXkfK8gqg1QeL2k9kCrgnNA=; b=LrUPWwfN73YggCa509F1dTQYbeD1HYcaccZTrGvMqm3nYZnjG3//RO2eQApWKyBqCQ Eloe/q4Qykllm3+8+vAAp+HhAwJF5MIBJSYUITkzD29Qb9P64fdE+FR7cuh4bC9QdNOs CapMKr+hkyq2nWpzSWi10uIs4hvX1Rotb2YcMYkWgkEuM+7Vd/+B1WQeuRnvdafYimOc n94KuKuzGZYhGrp/9iGGkMUeSpbSwP2E9QkvWFFr/7PHZDWxo2jfatPfSuY42sMgxjAX T9JXF5Q4ek68ZX1opZv8ZynN5skwnthLXr9ecHgiTPJIjE2Kv0j0tJW216VY4/v0lf/E hM7g== X-Gm-Message-State: AOJu0YyCVFSuf82iuOT5WSgudKYYG9Qgv9LzWNqvSb6BRjLCFpSApfJv 5wdSp1ZAccOlG/uczxXu27XToQ== X-Google-Smtp-Source: AGHT+IGwbWzX6J4R63e18q7vtMcODVJDNkz3/t3pNWPpndtr+uerfaE1asFqipLAiNvf9ZX1IftX2Q== X-Received: by 2002:a7b:ca57:0:b0:3fe:22a9:907 with SMTP id m23-20020a7bca57000000b003fe22a90907mr6490374wml.20.1691417720866; Mon, 07 Aug 2023 07:15:20 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 08/15] target/arm/ptw: Only fold in NSTable bit effects in Secure state Date: Mon, 7 Aug 2023 15:15:07 +0100 Message-Id: <20230807141514.19075-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807141514.19075-1-peter.maydell@linaro.org> References: <20230807141514.19075-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1691417872675100003 Content-Type: text/plain; charset="utf-8" When we do a translation in Secure state, the NSTable bits in table descriptors may downgrade us to NonSecure; we update ptw->in_secure and ptw->in_space accordingly. We guard that check correctly with a conditional that means it's only applied for Secure stage 1 translations. However, later on in get_phys_addr_lpae() we fold the effects of the NSTable bits into the final descriptor attributes bits, and there we do it unconditionally regardless of the CPU state. That means that in Realm state (where in_secure is false) we will set bit 5 in attrs, and later use it to decide to output to non-secure space. We don't in fact need to do this folding in at all any more (since commit 2f1ff4e7b9f30c): if an NSTable bit was set then we have already set ptw->in_space to ARMSS_NonSecure, and in that situation we don't look at attrs bit 5. The only thing we still need to deal with is the real NS bit in the final descriptor word, so we can just drop the code that ORed in the NSTable bit. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/ptw.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 4c60de753dd..6e736bacd77 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1886,11 +1886,10 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1= Translate *ptw, * Extract attributes from the (modified) descriptor, and apply * table descriptors. Stage 2 table descriptors do not include * any attribute fields. HPD disables all the table attributes - * except NSTable. + * except NSTable (which we have already handled). */ attrs =3D new_descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(5= 0, 14)); if (!regime_is_stage2(mmu_idx)) { - attrs |=3D !ptw->in_secure << 5; /* NS */ if (!param.hpd) { attrs |=3D extract64(tableattrs, 0, 2) << 53; /* XN, PXN */ /* --=20 2.34.1 From nobody Sun May 19 15:05:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1691417808; cv=none; d=zohomail.com; s=zohoarc; b=iTj5JE+TOiGQUTjiGV0j6rRpSf3gUREMwikMpJ4Dmvf+p+PZKNZAg/+eXz8IhX9Gro1V0EvMKM+4P/uIwPQk8GvtjibebD/wbeCe7zFk87NU/2+MoN99xDj4uN/NCU8XV0cSyPnC/QJUn9Z5L5pcVrSD1HI4mIABgXkNnIJFbOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691417808; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uhsYVutNNAS0mc53Ap1xSb7YNraKnHLfqR3rpR5pcZc=; b=PTYknv4igONfyBJqPcBE4yl4096IxKcqcc8SfJqjEoL/OK7KWZ8gmgzsdAlcZQ+g/NtLTWeLHonxGwMr+ASbfksZTo7vCowdDURv6cyxOV2AiqnUmU5O6pt4wG12402PMZ2E5exxpPmKo89JQ4IWjTl7D46J0tUlMR9zXQPlpRI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16914178084606.066691125826878; Mon, 7 Aug 2023 07:16:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qT11q-0000mZ-8d; Mon, 07 Aug 2023 10:16:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qT116-0000Aa-Pn for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:30 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qT112-0005Tv-51 for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:27 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fe1fc8768aso45446705e9.1 for ; Mon, 07 Aug 2023 07:15:22 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id h20-20020a05600c261400b003fe2ebf479fsm10835617wma.36.2023.08.07.07.15.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 07:15:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691417721; x=1692022521; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=uhsYVutNNAS0mc53Ap1xSb7YNraKnHLfqR3rpR5pcZc=; b=Xyksu1m+OJW83TSUP9fIJm+C01UOtfx/S7+q4D245uBmjoA6U5CLHr0HnMvFt45B0Z M9NoKBiPxtR+hMymlU/dxO8vrz0LWKz6Dkdm2Q1PQ9GnH7AqaJKELpfl8oMpIEDpZ01e tuP9WHoO+KC4hTBF8UrWCL76VAO0o+J0h+U8wHKiGlDFFcHGmXtdQlJEdrGviiPySWuD Kartl5Abhb+OpntG/QHYp86zrfcSYoEh/zB6jYCiTFa0bRU8tnuYGU9bsORema/nFCv+ 2kxk6OcYqQTg5SCWjZESfLotC/xCkk23b1ahOew0/+6a8RSMk7gzIy0PJO4FHuDyAXEa lmsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691417721; x=1692022521; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uhsYVutNNAS0mc53Ap1xSb7YNraKnHLfqR3rpR5pcZc=; b=Xre7LozrPbfrH+GJ0W4749GDKVCiFA31QfKWQ8WxCzbezTKZtcfonV7JbIQ4ePj7qY ozzl9F9G+ZtwE0nI6yeYN2qjkA3HQWicxXCi3nLiOzhP/dYP5dH89B/Bfaa/a+3Fm9Jx 9d6MD8LU5A9bSQ48W5YJQCg0zbvItxHX+XoaW+Dk9kXG4RSl3s8dLhQjE/zlYvrS+xgH kp8niAqNfaaWn6JNlVG5M/ZAPT+911F+1Cjyoj6DuJa4t8lZBo85KyqWDUHNK+Magn1/ HAttjj64Un0Uhx1bFWVEO5yXim5yxwkI5J2/0M2iAjHihl89Tobpy/ThUN05aUnoHlGG J37Q== X-Gm-Message-State: AOJu0YwARZpurEELFxvmYaGaf0sQMBSSVkcMiInQGJmoqZuK4sbUD9Cx EBwRHYPkg/+bs4Qs/ZFovQOGpsbSphNtYreDHNQ= X-Google-Smtp-Source: AGHT+IHckXpgIDi6puPv9JMWSP/IvMyHvJkqNd1MtyPfmAp3K2Lj5J2dULCZKYeH5UiEaffXQ+emlw== X-Received: by 2002:a05:600c:2210:b0:3fb:f0ef:4669 with SMTP id z16-20020a05600c221000b003fbf0ef4669mr7843307wml.17.1691417721365; Mon, 07 Aug 2023 07:15:21 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 09/15] target/arm/ptw: Remove last uses of ptw->in_secure Date: Mon, 7 Aug 2023 15:15:08 +0100 Message-Id: <20230807141514.19075-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807141514.19075-1-peter.maydell@linaro.org> References: <20230807141514.19075-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1691417895932100002 Content-Type: text/plain; charset="utf-8" Replace the last uses of ptw->in_secure with appropriate checks on ptw->in_space. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/ptw.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 6e736bacd77..1ca25438c3c 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -3249,7 +3249,6 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1T= ranslate *ptw, ARMMMUFaultInfo *fi) { ARMMMUIdx mmu_idx =3D ptw->in_mmu_idx; - bool is_secure =3D ptw->in_secure; ARMMMUIdx s1_mmu_idx; =20 /* @@ -3257,8 +3256,8 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1T= ranslate *ptw, * cannot upgrade a NonSecure translation regime's attributes * to Secure or Realm. */ - result->f.attrs.secure =3D is_secure; result->f.attrs.space =3D ptw->in_space; + result->f.attrs.secure =3D arm_space_is_secure(ptw->in_space); =20 switch (mmu_idx) { case ARMMMUIdx_Phys_S: @@ -3272,8 +3271,12 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1= Translate *ptw, case ARMMMUIdx_Stage1_E0: case ARMMMUIdx_Stage1_E1: case ARMMMUIdx_Stage1_E1_PAN: - /* First stage lookup uses second stage for ptw. */ - ptw->in_ptw_idx =3D is_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Sta= ge2; + /* + * First stage lookup uses second stage for ptw; only + * Secure has both S and NS IPA and starts with Stage2_S. + */ + ptw->in_ptw_idx =3D (ptw->in_space =3D=3D ARMSS_Secure) ? + ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; break; =20 case ARMMMUIdx_Stage2: --=20 2.34.1 From nobody Sun May 19 15:05:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1691417862; cv=none; d=zohomail.com; s=zohoarc; b=CiJgKyhx4OdtBJFtVUuB9B4EbOa6amSY7FiG+QetQOmrPPMBbj4QBAXwXjnViQiB1x1tOiNLqGVTEXcD8oUjRQF/weV+FuUYDuIQNlgG7oWJPeySu/YqwtDTVb+rGxASualFXuBB0YMlyepcJUfvqDP7+puS+8MteB1sbFZmW8I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691417862; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fPUvCziy6lhHDDMmfmybg6TLiyhiL/Fc4MTynATEnX0=; b=dBSGgNc1qwV81XneINO5zFl8eNcMj7QByA/gcucGoucOBlu8hKGPb3mpp/eq8IwKXhsT6CTT34uWh61+YeuUqBZsdac+DmotASjpklItDLWhKOkFwodiKOCENAlaOKYwjjo9Zu/bx5tINnHq4AHXziEzwsNdkCA1MSJYhUP2yYw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16914178625765.72033384714814; Mon, 7 Aug 2023 07:17:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qT12l-0003Hp-UJ; Mon, 07 Aug 2023 10:17:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qT118-0000B1-VM for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:34 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qT114-0005UB-EN for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:30 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fe5695b180so12752105e9.2 for ; Mon, 07 Aug 2023 07:15:22 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id h20-20020a05600c261400b003fe2ebf479fsm10835617wma.36.2023.08.07.07.15.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 07:15:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691417722; x=1692022522; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=fPUvCziy6lhHDDMmfmybg6TLiyhiL/Fc4MTynATEnX0=; b=QgO+KSNtbuHjCyUPFYGSDYE1ttW8+KPbQbVYx50RkeUQbxt+voN9VYEBOOWfy/44Cm NE+W1vzKeDPpIjQuFbb6NzkO+zYTJYAOyuIbl5YsUY4lWvbt6ZU+l8dWn4PiY41auOp1 PCkdeFfN5Y63jwF6cqcXm7q1+whrc1F//x0TyUi8qdo+Fe/gYomak701z7Jh30OMjqip vLYibZhN5rKhtWZkLaaGxsVpChO7Vrt8Zy8xLefAPC3rNxNQx+tlYCgmsqI5lQ70jlEF mEjiCwxAsh/qfN1xBD6wNdDP4WIlxg1hTkran9Bld/GmpkQK5ru00Uc17i3g79UvIxPa v4QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691417722; x=1692022522; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fPUvCziy6lhHDDMmfmybg6TLiyhiL/Fc4MTynATEnX0=; b=fipN4iesILJDheedklymzzGukn7HiB58lj1MYScGRD+sLBV+o+XMj2FcsTDGjRsARr /QA1GfORUUxhicEnwLfEMt+ZtewjXpDI9HCxjdPyDcdaVjgEA6zl+W7RUyz5UymsdbWb ++0vRZNTRr6UINyuKSh4iA1hhhHGAhexknzoebrst9dM2e/R/ifUKWHsLZ8z3Zkl1vWW 13UKPymChgnVsrZ0yyU+7TPOWdAE+hlGDVPdlxtM024w00jPBl8jn9AeQhXmNpsNAXWt n/XdJ/WX+3dt+cz6TeActMA4aDl9XlJTFLlE2UY3MJBs/6v7PGG7TsKbzqe0ufQ4Dra1 T4Xw== X-Gm-Message-State: AOJu0YydiaCx79lGu5UcoU5OKWh6gl9qYsGZUrHSu+2+F1AnkJvRzpSu xqYf9int8C9KSXObWU6qG6cheQ== X-Google-Smtp-Source: AGHT+IF1dAVR+56XiaPYG+wSwSmtQt0hvxje3msMTuFrO9c+wb/cCBZFif1ea3AuRUK71iJkiIVrhg== X-Received: by 2002:a7b:c453:0:b0:3f8:fc2a:c7eb with SMTP id l19-20020a7bc453000000b003f8fc2ac7ebmr5779539wmi.5.1691417721878; Mon, 07 Aug 2023 07:15:21 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 10/15] target/arm/ptw: Remove S1Translate::in_secure Date: Mon, 7 Aug 2023 15:15:09 +0100 Message-Id: <20230807141514.19075-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807141514.19075-1-peter.maydell@linaro.org> References: <20230807141514.19075-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1691417930332100001 Content-Type: text/plain; charset="utf-8" We no longer look at the in_secure field of the S1Translate struct anyway, so we can remove it and all the code which sets it. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/ptw.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 1ca25438c3c..78bc679deef 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -51,13 +51,6 @@ typedef struct S1Translate { * value being Stage2 vs Stage2_S distinguishes those. */ ARMSecuritySpace in_space; - /* - * in_secure: whether the translation regime is a Secure one. - * This is always equal to arm_space_is_secure(in_space). - * If a Secure ptw is "downgraded" to NonSecure by an NSTable bit, - * this field is updated accordingly. - */ - bool in_secure; /* * in_debug: is this a QEMU debug access (gdbstub, etc)? Debug * accesses will not update the guest page table access flags @@ -547,7 +540,6 @@ static bool S1_ptw_translate(CPUARMState *env, S1Transl= ate *ptw, S1Translate s2ptw =3D { .in_mmu_idx =3D s2_mmu_idx, .in_ptw_idx =3D ptw_idx_for_stage_2(env, s2_mmu_idx), - .in_secure =3D arm_space_is_secure(s2_space), .in_space =3D s2_space, .in_debug =3D true, }; @@ -1784,7 +1776,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_S + 1 !=3D ARMMMUIdx_Phys_NS); QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2_S + 1 !=3D ARMMMUIdx_Stage2); ptw->in_ptw_idx +=3D 1; - ptw->in_secure =3D false; ptw->in_space =3D ARMSS_NonSecure; } =20 @@ -3167,7 +3158,6 @@ static bool get_phys_addr_twostage(CPUARMState *env, = S1Translate *ptw, =20 ptw->in_s1_is_el0 =3D ptw->in_mmu_idx =3D=3D ARMMMUIdx_Stage1_E0; ptw->in_mmu_idx =3D ipa_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; - ptw->in_secure =3D ipa_secure; ptw->in_space =3D ipa_space; ptw->in_ptw_idx =3D ptw_idx_for_stage_2(env, ptw->in_mmu_idx); =20 @@ -3403,7 +3393,6 @@ bool get_phys_addr_with_secure(CPUARMState *env, targ= et_ulong address, { S1Translate ptw =3D { .in_mmu_idx =3D mmu_idx, - .in_secure =3D is_secure, .in_space =3D arm_secure_to_space(is_secure), }; return get_phys_addr_gpc(env, &ptw, address, access_type, result, fi); @@ -3475,7 +3464,6 @@ bool get_phys_addr(CPUARMState *env, target_ulong add= ress, } =20 ptw.in_space =3D ss; - ptw.in_secure =3D arm_space_is_secure(ss); return get_phys_addr_gpc(env, &ptw, address, access_type, result, fi); } =20 @@ -3489,7 +3477,6 @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs= , vaddr addr, S1Translate ptw =3D { .in_mmu_idx =3D mmu_idx, .in_space =3D ss, - .in_secure =3D arm_space_is_secure(ss), .in_debug =3D true, }; GetPhysAddrResult res =3D {}; --=20 2.34.1 From nobody Sun May 19 15:05:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1691417860; cv=none; d=zohomail.com; s=zohoarc; b=j1aLaWqptwSsP3ARvC2qsTliHrr9I1XTLkj2XWhqI07gXIHCwcZCqT/lRcyLpnjdffzM1ToJiOE1cBsQUCqulCG4ijVky7WXXUEC5ULdNf49fMMECoJT0/9zJq0MvWwb8UwTrsmWMwjWI+/xXPdTW698ykQW6KCCI1cd31VDhD0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691417860; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=S38jOsOxbXZJPQo1Nn8IdqFJrWb3K/zbZSPVOOqu/8w=; b=lrp4TmXPLrhv5PSrEtmVt716wM//sYm5cemmKwPxkcUHzKGdolf7RMFBW5BQOz3HJGWNMWXyQK76+EjYiAIa3iRn2DDIUKJEQWorbvtm9VFdwpkYTSdwnK82ZH43d6ShvbZVFWs+G0dean1IwabJlfK+Ge4fy7Tzumh3ZKz7yUU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1691417860452904.9828148408201; Mon, 7 Aug 2023 07:17:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qT12V-0002BI-MI; Mon, 07 Aug 2023 10:16:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qT11A-0000Bb-Mm for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:34 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qT114-0005UV-Ej for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:31 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3175d5ca8dbso3501542f8f.2 for ; Mon, 07 Aug 2023 07:15:23 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id h20-20020a05600c261400b003fe2ebf479fsm10835617wma.36.2023.08.07.07.15.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 07:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691417722; x=1692022522; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=S38jOsOxbXZJPQo1Nn8IdqFJrWb3K/zbZSPVOOqu/8w=; b=qrFYfcE1+fvxA1Nd3TpHbscVnYPF1KANB64ZJ9it3VlB7e9TEH/n4A7+LI18XLHvOm FatuujXvNXsWsRkGqmqQiMkwcqXAea3JVCn/SamEgmzkRO/4xE3crNR2C9VmoXBvwcBF JKQfcg6/3N9WxeW80zuVnTHGM5ZL5vL24+cy+fFe7Zsmwmz5IXtDDo9qpBj2qoglcPoF w0SJqq8pOfca+fd8FSsLczXLeDiQSLk9y8sKNG6fQQ8jxjTLhp9aCarG/m1IdnEOvZn6 31WbZNSsHSxg1WJJuGYFVl3UuyjbsmpF51Ga+7D8Tj00E4xdzAA9T8MsV+HQqJuOQktt xl0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691417722; x=1692022522; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S38jOsOxbXZJPQo1Nn8IdqFJrWb3K/zbZSPVOOqu/8w=; b=gf56sCZEbs+uY1OurLTfyd9xJaWe9ULT02a1yQI76oH6sZ8LnXIUU6wiNsRwvnVX85 DfFH9YQdmbrjROg89KwJfNLEOpE+bndo/X5AcOc6pdZ4ZWfXxG3Pwx0VFnifU/TquUyV CK6NRNFN/DL5M0kJMMDDiiYLJs95F+x+Pv1njth7FKNJ2Kl+DDd4Ijrk1GJNXS2xwgYm 9oAwkckNOy6HZe7E9v18l1Eur8Or7vXb1srwKjGvaq3L7CkiDu+rM67jbqptSwoTPyn2 WjDjmDaJL8gtcjAL3HGIrPG7Y9mCD59Ad9d4d+Nbmf+M6g9ucHf0BJfD/X2x4xWmBobE Gnuw== X-Gm-Message-State: AOJu0YxeZFZqH5RSroAKV77oiviZKZbD6gQ1xcmz5HRUyYpwUtviHZaK flqETHV7GzSqKdmAPK7YiogTslaQzjut+TG4AdA= X-Google-Smtp-Source: AGHT+IEI4iWB7LicgsNC2xEG25o4mf/gTnuR8+qxnXqJMZebcV/QJQk8Lq0FKgFn9Dy5QWWTtmX9wg== X-Received: by 2002:adf:f204:0:b0:317:576c:285 with SMTP id p4-20020adff204000000b00317576c0285mr5638633wro.7.1691417722426; Mon, 07 Aug 2023 07:15:22 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 11/15] target/arm/ptw: Drop S1Translate::out_secure Date: Mon, 7 Aug 2023 15:15:10 +0100 Message-Id: <20230807141514.19075-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807141514.19075-1-peter.maydell@linaro.org> References: <20230807141514.19075-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1691417906673100001 Content-Type: text/plain; charset="utf-8" We only use S1Translate::out_secure in two places, where we are setting up MemTxAttrs for a page table load. We can use arm_space_is_secure(ptw->out_space) instead, which guarantees that we're setting the MemTxAttrs secure and space fields consistently, and allows us to drop the out_secure field in S1Translate entirely. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/ptw.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 78bc679deef..312ccabe92e 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -63,7 +63,6 @@ typedef struct S1Translate { * Stage 2 is indicated by in_mmu_idx set to ARMMMUIdx_Stage2{,_S}. */ bool in_s1_is_el0; - bool out_secure; bool out_rw; bool out_be; ARMSecuritySpace out_space; @@ -553,7 +552,6 @@ static bool S1_ptw_translate(CPUARMState *env, S1Transl= ate *ptw, pte_attrs =3D s2.cacheattrs.attrs; ptw->out_host =3D NULL; ptw->out_rw =3D false; - ptw->out_secure =3D s2.f.attrs.secure; ptw->out_space =3D s2.f.attrs.space; } else { #ifdef CONFIG_TCG @@ -572,7 +570,6 @@ static bool S1_ptw_translate(CPUARMState *env, S1Transl= ate *ptw, ptw->out_phys =3D full->phys_addr | (addr & ~TARGET_PAGE_MASK); ptw->out_rw =3D full->prot & PAGE_WRITE; pte_attrs =3D full->pte_attrs; - ptw->out_secure =3D full->attrs.secure; ptw->out_space =3D full->attrs.space; #else g_assert_not_reached(); @@ -630,8 +627,8 @@ static uint32_t arm_ldl_ptw(CPUARMState *env, S1Transla= te *ptw, } else { /* Page tables are in MMIO. */ MemTxAttrs attrs =3D { - .secure =3D ptw->out_secure, .space =3D ptw->out_space, + .secure =3D arm_space_is_secure(ptw->out_space), }; AddressSpace *as =3D arm_addressspace(cs, attrs); MemTxResult result =3D MEMTX_OK; @@ -676,8 +673,8 @@ static uint64_t arm_ldq_ptw(CPUARMState *env, S1Transla= te *ptw, } else { /* Page tables are in MMIO. */ MemTxAttrs attrs =3D { - .secure =3D ptw->out_secure, .space =3D ptw->out_space, + .secure =3D arm_space_is_secure(ptw->out_space), }; AddressSpace *as =3D arm_addressspace(cs, attrs); MemTxResult result =3D MEMTX_OK; --=20 2.34.1 From nobody Sun May 19 15:05:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1691417869; cv=none; d=zohomail.com; s=zohoarc; b=c9vYmpl52HwhmzVDGwTWNzxzyN57CjhQhrqLD3G178UJ+6cRRDOolFr6zecDD8l5WsnJmrl6TDP9oM2C0sD/JsBUtlmEA4cwaUo1sjvQymbCJ80qHUzvLB/9F25w1TUCFkMF2Gwn9b4Yxu8tJ31Z5BU0WzAxTHvUF3cooOUnOog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691417869; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/yyxHEqA/6T1J8G7sWRRyJB/3QTMgoPg9dM02AxAbq0=; b=AKDdXxC0p1f+Seyka8Pivx5K5kTbb/09V4JodJljDRLS2eiZHf+xh+HDzlqe1qtFWWjekwIwiySsBgpJBJiqh6KyKo9ZDiCzZ+dPA0qdptNrHY6SVIq0NsZOnUCCSGtIbdZJVdtz9SjuqM6kAzHcQ9YvlUKw+y3qQ5zPyZbW03A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1691417869429883.7130725868357; Mon, 7 Aug 2023 07:17:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qT11t-00010b-BO; Mon, 07 Aug 2023 10:16:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qT118-0000Av-T5 for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:34 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qT114-0005Uj-EK for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:30 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3fe5c0e58c0so9973055e9.3 for ; Mon, 07 Aug 2023 07:15:24 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id h20-20020a05600c261400b003fe2ebf479fsm10835617wma.36.2023.08.07.07.15.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 07:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691417723; x=1692022523; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/yyxHEqA/6T1J8G7sWRRyJB/3QTMgoPg9dM02AxAbq0=; b=dCZeRDrJmVUKLL6uHLM8YCsUNdsXHez4T2u/PAmTSP44PeMCIMj3JtFpIc7//ogs1Q /NCSzTbZlR+oEG0taAPZhudx+98jILtmJ3ED7enzbogBxsLKPV2gX6su06p+b0qhbQCA XRmmWDOYKmU+UzUv148HIxBkCOJ9o+x9FpQ9qqdlpi/CXrlCZkB3bg8U59/sbxhTDrLA CpnwlDBpcZ5xXR4co3Hq1knujVK5cfYDSiLgX/qG0kcIajUtgwxJ8b37uESfMZOLVVrQ jADOedeACdU1Zo1P7CPWa1Ipln5mQkgVPJQvqWarRm91uNyYZEKvB8eVBcnsD2QHPuTO Mt8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691417723; x=1692022523; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/yyxHEqA/6T1J8G7sWRRyJB/3QTMgoPg9dM02AxAbq0=; b=h4+mCzKklwNsOR7F1SodU8L0QG++RrslQTnp30ws5UGeqSioIXw3AKSO4SdqCgrX0Q nS3b+c8hwMLg7QPtXdCItr+bfGnAARmXAlppZm7bquigxYiHuktIAtDQn+fBuuF3/CYY NplmiRSUlRkrF/9305pymZUyrtv+UHvf6pRMnC66w2Y0wZZ0VJFGn/NDcedwBvqQgKcV 6pmRYT3geNRKxz5gt0TW3mDX6F6adsMn3J3psNKN790kVyuDAFXcuDa0ZvY+bfrhw3I2 NE0fuGZzmug45gxoqg2oB9+bSh6De65yKpFgTzGNMv67iQjVeZmufCrS76KgrY6u6GES cjEw== X-Gm-Message-State: AOJu0YydG1g79/iT3b9p2PavntY55cEOrhSTkFcIYK5PzQsyzzVMP11W FPTxaGsTcMDrfrT/0d5TvCBXow== X-Google-Smtp-Source: AGHT+IGcGzupSTuTY26GGHEUnNls9u4rTd1P9AfJtvrNCuGUUFvmGJAJzNpWANDgmkolMXbbR5/QIw== X-Received: by 2002:adf:f60d:0:b0:317:6816:578c with SMTP id t13-20020adff60d000000b003176816578cmr7085387wrp.5.1691417722856; Mon, 07 Aug 2023 07:15:22 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 12/15] target/arm/ptw: Set attributes correctly for MMU disabled data accesses Date: Mon, 7 Aug 2023 15:15:11 +0100 Message-Id: <20230807141514.19075-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807141514.19075-1-peter.maydell@linaro.org> References: <20230807141514.19075-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1691417959069100001 Content-Type: text/plain; charset="utf-8" When the MMU is disabled, data accesses should be Device nGnRnE, Outer Shareable, Untagged. We handle the other cases from AArch64.S1DisabledOutput() correctly but missed this one. Device nGnRnE is memattr =3D=3D 0, so the only part we were missing was that shareability should be set to 2 for both insn fetches and data accesses. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/ptw.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 312ccabe92e..7f217a31895 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -3108,11 +3108,13 @@ static bool get_phys_addr_disabled(CPUARMState *env, } } } - if (memattr =3D=3D 0 && access_type =3D=3D MMU_INST_FETCH) { - if (regime_sctlr(env, mmu_idx) & SCTLR_I) { - memattr =3D 0xee; /* Normal, WT, RA, NT */ - } else { - memattr =3D 0x44; /* Normal, NC, No */ + if (memattr =3D=3D 0) { + if (access_type =3D=3D MMU_INST_FETCH) { + if (regime_sctlr(env, mmu_idx) & SCTLR_I) { + memattr =3D 0xee; /* Normal, WT, RA, NT */ + } else { + memattr =3D 0x44; /* Normal, NC, No */ + } } shareability =3D 2; /* outer shareable */ } --=20 2.34.1 From nobody Sun May 19 15:05:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1691417850; cv=none; d=zohomail.com; s=zohoarc; b=bu5ImMsRW0pQ2TTOBUjTf0lLGvpUU9VTTukAJceEFyANcPmwTbKWb2f8oD6UZzX6KkolADAX9s/92cm3RFdFzNUVyFxsptCiZPOZGirzEDdpLAGpxBLiAWv8ieZv5Xf2SuxdaCDkco3uaB7rhJD/94VsTlQU/TrCXSH4zlsXQ7o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691417850; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DFzTkjIJFWqjEqcRCrUZIPYv2Pvbteumi0MT6ZHxtV8=; b=lBX/zBjUQwiXBKhu14Mm/aSsy/4fUOl4lCB1X85uwL+SCpKetiLBI9rieaZSsz2+SUKgaje4cDjNqsXPwplp/SCy5Db2Dzjg6KXMKUhKvL0iXVeGqi6615/tAD2aYenevkgg80MdVxBgTBsjHwIMUTgOiikb0kYCs4AIVRETPl0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1691417850027332.5319616304431; Mon, 7 Aug 2023 07:17:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qT12k-0002vV-Pm; Mon, 07 Aug 2023 10:17:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qT118-0000B3-WE for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:34 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qT114-0005Ux-De for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:29 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fe5c0e5747so6150045e9.0 for ; Mon, 07 Aug 2023 07:15:24 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id h20-20020a05600c261400b003fe2ebf479fsm10835617wma.36.2023.08.07.07.15.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 07:15:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691417723; x=1692022523; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=DFzTkjIJFWqjEqcRCrUZIPYv2Pvbteumi0MT6ZHxtV8=; b=tTeVrVunRFlq3yP/VXgTQ5dWYVYdt/sy7NvCm3fJDrGVtu9n/7/Sb26GFtTw9/YbGK bkS1WS9B+MrR1/e8Ka+QysnE5j5p1yAFRniGeEBNcRb8vewU/ISQmsDFfpAv/3YqJtmH +yeBUrmIoVGpXEW7KPNKl7xhEqRtofH4xm/7SjB3tZ2likXv7oWM579DFkGB08grH3AT FBgUkyHBfX+jsqyEm6fQX2r56JZps8CIxd3oWO/QhJ4kHskEtNXRVw4cUrcO18tBjMY+ D4Zix0zuVfxAOfzLfMMyPepuT2x4pYUYEUnlQOMd3ap2i4nLux6QQxzz57yQvKhLYEUC xOcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691417723; x=1692022523; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DFzTkjIJFWqjEqcRCrUZIPYv2Pvbteumi0MT6ZHxtV8=; b=RFzdfiW2UJRHW+XEwKN7lbMed9U4cFEkyTLYXRZwzvMM1hLcxnuR2kfkoRzljJZRRV W/C2yRq13592UTOZeQ+ubU5Bu/2/sjW/Dsi67xndS+lt4phQdxcXD9vI2nzKgcTShXc9 OYV9998MwOG3zGwU5XlHiQlymS5deSjX1e/X38Rx/Cp5Ry/Z/uTjVZsDEf7BLE3CbMLZ tsIoxhR9oNfuO5SCWXXdQ4tdszF5Mu1KltciVjlpBQviX3AmuejmfKjt04pMZno/MsKO 0iiXYO+YwgiXrQZpYyKOYSpC/badRLO+Ob2rIIbshAdu/h5n5VIpN6o4/uk6gAErhS8a wMDg== X-Gm-Message-State: AOJu0YzOTmKCuewCZhJrMwRofDq7X5PO2v2iTqtp/iMYBKZSNTPCiEZL cPujTF0yKTbTjPU5S3N3OrRIdg== X-Google-Smtp-Source: AGHT+IEH9KLrgYpQ9nVi8lZNekInlmK6gzgI8Z7aSK371k2PXahbRTNG18LM9oo/0NURAtKzYOwEyw== X-Received: by 2002:a7b:c8c4:0:b0:3fe:1c57:3be with SMTP id f4-20020a7bc8c4000000b003fe1c5703bemr5842847wml.8.1691417723392; Mon, 07 Aug 2023 07:15:23 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 13/15] target/arm/ptw: Check for block descriptors at invalid levels Date: Mon, 7 Aug 2023 15:15:12 +0100 Message-Id: <20230807141514.19075-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807141514.19075-1-peter.maydell@linaro.org> References: <20230807141514.19075-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1691418081652100001 Content-Type: text/plain; charset="utf-8" The architecture doesn't permit block descriptors at any arbitrary level of the page table walk; it depends on the granule size which levels are permitted. We implemented only a partial version of this check which assumes that block descriptors are valid at all levels except level 3, which meant that we wouldn't deliver the Translation fault for all cases of this sort of guest page table error. Implement the logic corresponding to the pseudocode AArch64.DecodeDescriptorType() and AArch64.BlockDescSupported(). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/ptw.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 7f217a31895..fbb0f8a0bf2 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1551,6 +1551,25 @@ static int check_s2_mmu_setup(ARMCPU *cpu, bool is_a= a64, uint64_t tcr, return INT_MIN; } =20 +static bool lpae_block_desc_valid(ARMCPU *cpu, bool ds, + ARMGranuleSize gran, int level) +{ + /* + * See pseudocode AArch46.BlockDescSupported(): block descriptors + * are not valid at all levels, depending on the page size. + */ + switch (gran) { + case Gran4K: + return (level =3D=3D 0 && ds) || level =3D=3D 1 || level =3D=3D 2; + case Gran16K: + return (level =3D=3D 1 && ds) || level =3D=3D 2; + case Gran64K: + return (level =3D=3D 1 && arm_pamax(cpu) =3D=3D 52) || level =3D= =3D 2; + default: + g_assert_not_reached(); + } +} + /** * get_phys_addr_lpae: perform one stage of page table walk, LPAE format * @@ -1786,8 +1805,10 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, new_descriptor =3D descriptor; =20 restart_atomic_update: - if (!(descriptor & 1) || (!(descriptor & 2) && (level =3D=3D 3))) { - /* Invalid, or the Reserved level 3 encoding */ + if (!(descriptor & 1) || + (!(descriptor & 2) && + !lpae_block_desc_valid(cpu, param.ds, param.gran, level))) { + /* Invalid, or a block descriptor at an invalid level */ goto do_translation_fault; } =20 --=20 2.34.1 From nobody Sun May 19 15:05:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1691417871; cv=none; d=zohomail.com; s=zohoarc; b=FW+sv0Lkl8/vrNQ98kuieYvBDjDQvzx3cvQ5AVC0MB0znbQs7WGi2rXxIvtd8sXX4oDFmAmsc4dlEY0FBoulhMHe6TRVIJxbtON21muhMnQa/YhvUdSD391m7vA8EoFAAxJhvZYBlQIwEwEb/JaaxrP01KQN5FQWId/8A8ljgLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691417871; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cr23TIsFZ3PjCpnV8UZBDI6iYURVIWjSxhQhgKrusGQ=; b=nXTabJpZ/bh2Q9IfLIN1c70cq8eJx5oBh1yt5gPxfKD78awPb4Fwe3cIAvQTGFyNz6IkTOP7Rh7RFFCXgxfvBaGxz27IH67uOP2E/UEkRs3KCrCpxbtC1JPccKpB069YDWc7cJF6qjz8t0BjTexRaCquIA44fVYRRTWxZoHaMX0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169141787176668.91318842197245; Mon, 7 Aug 2023 07:17:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qT12Z-0002QR-J8; Mon, 07 Aug 2023 10:16:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qT118-0000Ax-UT for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:34 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qT114-0005V9-Dg for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:29 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fe426b86a8so37493745e9.3 for ; Mon, 07 Aug 2023 07:15:24 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id h20-20020a05600c261400b003fe2ebf479fsm10835617wma.36.2023.08.07.07.15.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 07:15:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691417724; x=1692022524; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=cr23TIsFZ3PjCpnV8UZBDI6iYURVIWjSxhQhgKrusGQ=; b=giZh0fYhUvDjCGYQSXSlD0We98uOeWc4tt1dJ0qBDzDSupVTUrhUQL2YfxLJfAfCIM R0L4fzFykUtfElyEqEcyy4QDh2Te8HPOCVD5a5L8kiWruqC9eW4chsfcQiJsu4StL+39 fhX29I1ZfpQrOKDYqjaAclKUhI/gxkzqqf/4T5EceihvZrOGlFeFfbY1ETXfowmuDbcI bDL8fXyBWTzeOzTdwMU+K2M4kiejDLkvpf08fimFAHaFgqKf2tfYNpK7Ch14swTKDhx+ qm4lCpI7e5ouj4m0wedBRCs7qyPefcqCBS4ywIUmV+O11htddSEix4/R4+IlAEH0jn4C z0ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691417724; x=1692022524; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cr23TIsFZ3PjCpnV8UZBDI6iYURVIWjSxhQhgKrusGQ=; b=aMi6zkXX9LZK2uv0MhSVSP+VVbTr3SoPsfaysbl7We2GejygHWRGEB4XPV5326qKTk AcejAaoWA60O+7bC8NtTYPDMhhi8FekMWPK+IHLD83t79EG/6s7ZmtTY3/KMHkYYD1VD CyS5J3NyZJ4mPd/4jpCrEpILa59nSFDdJ929yi3YZGorrWjOmIFNzFA6ZnAJfOqNHM1I ddFzekbIHzr56GIolFJq2+4E36/9IA7ogzWcFgejQi+ynLZF9grBTI1VMedFz6S394M8 SPjLpKRjcymJgpoMsuyQ5/hvkhtVwVcBIkampQzFwDZ+yv65N63gaSvtjukkF1tkrwxE M6xQ== X-Gm-Message-State: AOJu0YxDeNBF6hfG1QXsvVUHwf/QxcefyLNiWIo8aO6/THEHHujX0wVu 0sDvpSyj1pknuFH15O2JtT82u/OH39iysoD7ESg= X-Google-Smtp-Source: AGHT+IE4dCtXE2aQsHZkpJWin6gFmEpdgQ4CeUO7evcmbc4qC9hfg6RRdtyqmpaFio8zCyoCFix8gA== X-Received: by 2002:a7b:cbc7:0:b0:3fb:bc6d:41f1 with SMTP id n7-20020a7bcbc7000000b003fbbc6d41f1mr7496434wmi.17.1691417723922; Mon, 07 Aug 2023 07:15:23 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 14/15] target/arm/ptw: Report stage 2 fault level for stage 2 faults on stage 1 ptw Date: Mon, 7 Aug 2023 15:15:13 +0100 Message-Id: <20230807141514.19075-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807141514.19075-1-peter.maydell@linaro.org> References: <20230807141514.19075-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1691417970996100001 Content-Type: text/plain; charset="utf-8" When we report faults due to stage 2 faults during a stage 1 page table walk, the 'level' parameter should be the level of the walk in stage 2 that faulted, not the level of the walk in stage 1. Correct the reporting of these faults. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/ptw.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index fbb0f8a0bf2..07832eb8f76 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2048,9 +2048,13 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, do_translation_fault: fi->type =3D ARMFault_Translation; do_fault: - fi->level =3D level; - /* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */ - fi->stage2 =3D fi->s1ptw || regime_is_stage2(mmu_idx); + if (fi->s1ptw) { + /* Retain the existing stage 2 fi->level */ + assert(fi->stage2); + } else { + fi->level =3D level; + fi->stage2 =3D regime_is_stage2(mmu_idx); + } fi->s1ns =3D fault_s1ns(ptw->in_space, mmu_idx); return true; } --=20 2.34.1 From nobody Sun May 19 15:05:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1691417837; cv=none; d=zohomail.com; s=zohoarc; b=h/Agnrmt7tgGeQswHYDQyZl1AdrJ84YRzbz/pa7uYnThlE4cPbZoUwYbpi7tCmDhnHXJ3kMLkZZpu0eM8gOqPvnctwK7W0JTWtofxgNlmAs5dGGu6eXXjJOzJHGuTE0EXeX2hUPVVB9v4MCuel/FkUkozYPs4//m2WxO9oZH7UY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691417837; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pZEGgSdgHuR4AUV+YoPa8xV6M+CUbZlyZQlCkoU7l74=; b=B7DUmTg6XRxgzxdvTPUY3IvMzYIEeNH0ld7nWNaRIiLVsm/IPtFNLxQB6OG3UrsWs4s/ZHevodKz4v/2yVH3uTisSL0+/QO0RD0bBL79Eux2m/YsSBFqxUQcy+YY9leq9pn5iADtgQvK5MZzaOr7AwvxQh/yaH+lXZ/kDac3bEU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1691417837459681.8214296442479; Mon, 7 Aug 2023 07:17:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qT12g-0002kV-T5; Mon, 07 Aug 2023 10:17:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qT119-0000B4-04 for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:34 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qT114-0005VM-DJ for qemu-devel@nongnu.org; Mon, 07 Aug 2023 10:15:29 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-31768ce2e81so3998573f8f.1 for ; Mon, 07 Aug 2023 07:15:25 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id h20-20020a05600c261400b003fe2ebf479fsm10835617wma.36.2023.08.07.07.15.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 07:15:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691417724; x=1692022524; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=pZEGgSdgHuR4AUV+YoPa8xV6M+CUbZlyZQlCkoU7l74=; b=sfnzhwLWm74Rc8LnxsYHnMVutQ5D9rPgo3BC7TE+6ntoPyaaFryO9TzWXceBDYJN04 LY5Jox1CuaQ0wN0u89sQql9/+BDOjlS6TO+n91vRUMd9i1Vb4jkxnF1OtIKn6slR5yt7 U2cFzStb62o+i82nnl3PMdimbKFHx347Hafk5jo7OUZVhqyRepluYgdWMGxqQKVjKrpc IpDRcyZfBOY3QiB1Ms9W+wjBbEJbxmCfBzrQtN7Oyp63ruhoz06SYUmNi85zZcLjsc85 Gr/2vpYIu7NsuO00r0CruY6I6dxft1hvS34GXgNjDOJUYZR2nBdeGITB43Ek5G4/8S73 OY8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691417724; x=1692022524; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pZEGgSdgHuR4AUV+YoPa8xV6M+CUbZlyZQlCkoU7l74=; b=ZalgcBpWwzJtPjeW/PaaG1LTeP+HthFGxUxtTtwhJGr/kIp0A/1DU5PbU4J5i3eFax lXXodHSf0lURi6gqhoVnojt1qgoRRjJK0+qNFcQcEvrYg0WDDHglhC/51vBoUdPxNXFh q7/+ajw2+9kPaCOVyCWjicjuhCbNlg5I3ParoDpP8ESEFLQ9T1DMPXaa+l16K+8HCSWc VCYv0NHGSzNCe5ysLDRRI4DoInVA/yLS6gsXGEAV3q0epLKfk4ZiAGuVZm714tXFV2MG NoLtMPZOM5RD0DeszwOzFkashUXsXHgF40tPW//+oHdLRxdSW8nxX+aplZXr4FweUDG+ u/IA== X-Gm-Message-State: AOJu0Yx9UgFvY1sjk9mYccQ5GqlsCss5hQJUS3W/mK/5Wqb7aHyTuNAG W6A1arxF45vXlzIkyNjDOy5GOg== X-Google-Smtp-Source: AGHT+IE/MhkJP93MVwJ+ozygnj8lhZLuufihKk/oOFvWh/agZkUIxHf1EPWxCt5kcn1yJXC1uqXA8w== X-Received: by 2002:a5d:4b89:0:b0:314:327:2edb with SMTP id b9-20020a5d4b89000000b0031403272edbmr7000898wrt.0.1691417724565; Mon, 07 Aug 2023 07:15:24 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 15/15] target/arm: Adjust PAR_EL1.SH for Device and Normal-NC memory types Date: Mon, 7 Aug 2023 15:15:14 +0100 Message-Id: <20230807141514.19075-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807141514.19075-1-peter.maydell@linaro.org> References: <20230807141514.19075-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1691417884825100001 Content-Type: text/plain; charset="utf-8" The PAR_EL1.SH field documents that for the cases of: * Device memory * Normal memory with both Inner and Outer Non-Cacheable the field should be 0b10 rather than whatever was in the translation table descriptor field. (In the pseudocode this is handled by PAREncodeShareability().) Perform this adjustment when assembling a PAR value. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/helper.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 8290ca0aaad..da5db6d3ff6 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3342,6 +3342,19 @@ static CPAccessResult ats_access(CPUARMState *env, c= onst ARMCPRegInfo *ri, } =20 #ifdef CONFIG_TCG +static int par_el1_shareability(GetPhysAddrResult *res) +{ + /* + * The PAR_EL1.SH field must be 0b10 for Device or Normal-NC + * memory -- see pseudocode PAREncodeShareability(). + */ + if (((res->cacheattrs.attrs & 0xf0) =3D=3D 0) || + res->cacheattrs.attrs =3D=3D 0x44 || res->cacheattrs.attrs =3D=3D = 0x40) { + return 2; + } + return res->cacheattrs.shareability; +} + static uint64_t do_ats_write(CPUARMState *env, uint64_t value, MMUAccessType access_type, ARMMMUIdx mmu_idx, bool is_secure) @@ -3470,7 +3483,7 @@ static uint64_t do_ats_write(CPUARMState *env, uint64= _t value, par64 |=3D (1 << 9); /* NS */ } par64 |=3D (uint64_t)res.cacheattrs.attrs << 56; /* ATTR */ - par64 |=3D res.cacheattrs.shareability << 7; /* SH */ + par64 |=3D par_el1_shareability(&res) << 7; /* SH */ } else { uint32_t fsr =3D arm_fi_to_lfsc(&fi); =20 --=20 2.34.1