From patchwork Thu Aug 24 09:28:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 716542 Delivered-To: patch@linaro.org Received: by 2002:adf:f747:0:b0:317:ecd7:513f with SMTP id z7csp1238297wrp; Thu, 24 Aug 2023 02:36:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYbt0KViIB3ALfD0GnZ57+FMHpcr4m1sRBaNRKlcCpbJTcf5aZ1/hG1i5eGjpwliMRyFB/ X-Received: by 2002:a05:6214:4604:b0:634:a1a5:c7bc with SMTP id oq4-20020a056214460400b00634a1a5c7bcmr14933597qvb.20.1692869809499; Thu, 24 Aug 2023 02:36:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692869809; cv=none; d=google.com; s=arc-20160816; b=fXo6hLc7BOC+lmSph2rLwDz355Oz1VNyN36D5H1jqnxjD2OHEqsh3vDkhlu+EFuVvX L1ueOl8kgBzoLIC22rbe8g2YgGL57EkA3TntiF7yrTZ5p1SADNoOXh+9cGpVNRw3wY0l 0+kzqquek5OsjQJyXiNTM1mLRVc0bGCFTUc56CGKgoKZIy/11vRqO5EYB7H9H0zPbJcp 3PXGWMR9DTndgdAimNYjGjdfOdqkUza4Tjdq+B9+8gEMCz7j5y3aC5TGdKywDNBRJu/T pohMbrHmm/q8Jao9MIVoMjcO25gY9DNN/18nzlEWADmrZ80T6RWWqb+DgUTku84MVrWB J/+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=gSt7Jf92i8R5HQEoB62ZPc6BWF+QtO19rPh3tNmtHqE=; fh=bFDrUYhlTVi/QyetgXx/byg2+yO/22Hp9SjwoefyKLk=; b=Lo3OrzpH6Hcoa2qkWyv1Fm+3CKNLFf/JK/YGwgHIjwNzMR3kB/RuVPD9YwjYe/7+Fx Q2lquJJg0ae03CJ5/IMX542mIl7KDitWR7F6+egWkD6vz8JT+dq/MTsmiBUD+0sGCyBQ 3fxxYnxrR6PCFd5AzYP1EFZUF2Razwb2P32LT0lKWPbunCU2RihWzizzd5QNyWjn1xL3 osX849mjLJrJi0M2YHTHnWYUnw7kAYo5G3mnEyjZSHBsbQGYL2MPQLC7sjTno/45WsHo PefHFtZbNP9sAbmvzqqk8UN/JniQbeNzVJgmY/DjWg1mQCr72IPzFGl4XqYj7mBM6m3y sH5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FdJjoiP1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t19-20020a0cde13000000b0064f53a85d19si2161685qvk.62.2023.08.24.02.36.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Aug 2023 02:36:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FdJjoiP1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZ6ew-0000GV-CI; Thu, 24 Aug 2023 05:29:46 -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 1qZ6eR-0006JD-Aw for qemu-devel@nongnu.org; Thu, 24 Aug 2023 05:29:15 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qZ6eA-00050p-Ga for qemu-devel@nongnu.org; Thu, 24 Aug 2023 05:29:04 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-31aeef88a55so4076400f8f.2 for ; Thu, 24 Aug 2023 02:28:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692869328; x=1693474128; 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=gSt7Jf92i8R5HQEoB62ZPc6BWF+QtO19rPh3tNmtHqE=; b=FdJjoiP1w0OiLRkmiIkt8l72VkQsvsAf2etHK5JdrFm5v9hKTKPhXmwigtps+mhhqE FrHL7O/oGYnrQKJidUWWr0Su7fOzV54h+jLE0N4a6ReOIJ3bMra/U2GahKMZ7cg5NV31 BZeEKdyUyVgaMKn7C1Xh5u5GwDLiw4wG5Jp+VtccsjRzAGKw3JlwmxLEN3XHs+vgXftF Zo2k7gWrjLTx6/7NsaEZhB1JDOfccpFsZ0MQWTIQ9Df/c+kkgv5YOV+T3F+3X6Ib1Lz7 ISZgQfC8czzoY7qFr1p587Si+BuFubZxTU48RfIabbIbjZABbXsuKdklrVWP/nNMxctS yi/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692869328; x=1693474128; 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=gSt7Jf92i8R5HQEoB62ZPc6BWF+QtO19rPh3tNmtHqE=; b=K3KngI21WMxKssLD1HO7Zf58AV7rjYeSHzPySAwluObGZjmTbK6HJbvYnacZVb26fw zfWQaDkZQt+nXNWKC/LH+FeNk78gteE504ahXYvs6nvVkzeWvDXK0X7kVa39FwJuQspe EL1j8joEVaN4ZCiBv8BJwaL7Agv3vMhgSt/KpCfrLRcFs5HOcOuRopRB13h7Z7OsOGI5 9E6+LNYNGJqfQujXs9LTf5/QIfahb6yGkJgN7Ir7WeTJlpH/o950VnCW2gi6G3+8zAmO 6t/pwSnm+DJy8pvy3Z3RBVy1I1MDK/3P4tIg8tE31A8zgvBOBT2UnbWeenJtnQv7ygGp llhg== X-Gm-Message-State: AOJu0YxQpGh9doMWmsic2JtvQ8H3mDifdXtVoUmdpz/s1QjC6HqGLshu GF27LAMNOnY36QX+/P8I3dhfkW/KW2PMBsgaTmI= X-Received: by 2002:a5d:68cc:0:b0:319:8c35:37b with SMTP id p12-20020a5d68cc000000b003198c35037bmr11419270wrw.7.1692869327896; Thu, 24 Aug 2023 02:28:47 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id s12-20020adfeccc000000b00317b5c8a4f1sm21844004wro.60.2023.08.24.02.28.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 02:28:47 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 20/35] target/arm/ptw: Only fold in NSTable bit effects in Secure state Date: Thu, 24 Aug 2023 10:28:21 +0100 Message-Id: <20230824092836.2239644-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230824092836.2239644-1-peter.maydell@linaro.org> References: <20230824092836.2239644-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 Message-id: 20230807141514.19075-9-peter.maydell@linaro.org --- 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, S1Translate *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 = new_descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 14)); if (!regime_is_stage2(mmu_idx)) { - attrs |= !ptw->in_secure << 5; /* NS */ if (!param.hpd) { attrs |= extract64(tableattrs, 0, 2) << 53; /* XN, PXN */ /*