From patchwork Mon Jul 17 12:47:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 703719 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e4d:0:b0:314:25da:8dc4 with SMTP id r13csp980605wrt; Mon, 17 Jul 2023 05:55:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlEYuALzBR+zSpGY0fobIO+5Ubi59z5wJjA+CtiG8HIvEEN/EAySle7FLODIvs8h0BhLUAzh X-Received: by 2002:a0c:ab58:0:b0:62d:e416:a0de with SMTP id i24-20020a0cab58000000b0062de416a0demr10244434qvb.41.1689598508798; Mon, 17 Jul 2023 05:55:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689598508; cv=none; d=google.com; s=arc-20160816; b=izdsL/uJWs8XSnKgKgKemSQOWNR+e8gU0SF8u6Ruk/kLVF/XPVJdzXG5hG6eocSn59 cU04NtPUd448LGbDbkB0x33xAnUb1ALzcZtE6i3gnxt4Mf5d4sE8b+Vx8ALho5M+08iN TQgDYrzmPfxlw5xSV9m2dgYXGOUIjEGScw9LbFkGUfmUnZ6EK9l1do856qnOnhxk1pjq qrUm7Y5gF3vVkjIQCC35Ybm8zLDGdJSN64cOcP8yTTLH146PtajDOlajGpj6xZAoU8O6 8xj2wjEFMPCOpesVdiqKr4u8ew1pK9TPh5gFp8CkEmc0U12u2W4CU98NiV8s17iIHg/o t2SQ== 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=uo7Bz898x5rT9AwvwOzRLp/mDtj2e+zf8fXMK+RWos4=; fh=bFDrUYhlTVi/QyetgXx/byg2+yO/22Hp9SjwoefyKLk=; b=PtF/IU0YNzM6nacIgl3tOx6KIswHJ95L+klVLoSHP3J317B/+5EfCEK+ntzc6yzHTP 7myCdIjXN0Lfk7BkCbCRITd7SyatXs9AT8y3SWtnur8KErAJZP1sPuhhLu2rr4svR34+ 9Te9dN98BTuJaWozndjSrtuAVqGgQ4EzU6ew1G708hpQ/piobn6F9WhB0dFHTo4Q7ikJ YR285QgGWkD4Wqpubg59Oe7C6M35sKwvjM8N1zRAAI48A4WOg89mCq42YL0WGCG8BPgS j72pucmyOukymfXyUII1TTDOk+BJ2JN/oqfr4viWnSYKpK/Ge21Bbwv8JNoW2kZuvzMk yHew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GYUsfFKR; 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 z17-20020a0cda91000000b006365cd54f29si8070843qvj.163.2023.07.17.05.55.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 Jul 2023 05:55:08 -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=GYUsfFKR; 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 1qLNhj-00031w-SJ; Mon, 17 Jul 2023 08:51:56 -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 1qLNdu-0008Tn-Ga for qemu-devel@nongnu.org; Mon, 17 Jul 2023 08:48:03 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qLNdn-0008TO-Tf for qemu-devel@nongnu.org; Mon, 17 Jul 2023 08:47:58 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3141c3a7547so4228516f8f.2 for ; Mon, 17 Jul 2023 05:47:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689598070; x=1692190070; 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=uo7Bz898x5rT9AwvwOzRLp/mDtj2e+zf8fXMK+RWos4=; b=GYUsfFKR9xT2o6l43WZ+dZODQn7mm/uHx8nxfV0ktVv2Aw76+qDzPhPUAOa8M8+x3q pvGOGWHzU3y3EBghgd3O+Qk1vw4JPuxvnis3mF0LLunw4PzaXaD+QboYvYG6QLHSyz+N D/DB7yXf4PQvnVbIjCydFzdL5hi6045zux4I19i1z8n+gVMPx/YmkH1waOar/PMZriHp 531ec87mzNIcTuuUviLokzrTgsH0HArybNwr/tfSQ3oMwUTNrXjcTrMnGe9tgODLelcl n3VRvPjzK0e32bBjzHf2H48LRQAWVOzGQYwPpKjJ6/k3O8ex9zy3pFiprfb2NfxQrTZH bgoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689598070; x=1692190070; 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=uo7Bz898x5rT9AwvwOzRLp/mDtj2e+zf8fXMK+RWos4=; b=W43XiSl8CEm/qQbzhtbPidhqeUMzlujUfwKs7O+WmVD6wtKozfpL50LD7+fn279A0r KuN9NEz6g6Ov1YeYYG2yXKQabt+jxXZ8CpUJUwyPlN2VKK8/6Z1EEv/latVlHgcK9gwh cOPc/e/z1ozmEodI8vmkrcH6LfKjNWp8oUlkdgNXzYH3QbncWGuvVaO7AlaBntQF8c9z /SxQUyxDmFOewMfwov9NuDzBV/4rICq240BW/1LAHG0zSFDanBBTB7zs6SVbePz6nVph zw15TCYWFIte/16bJ58DpmuR0AfJ1gfBjt7Tyd/FSfMPmhIc0Ib3hYwa3HHsMHAuuajp TNVg== X-Gm-Message-State: ABy/qLYC7AzPRrpos0zPSc20FBZcyCDFAlRf6gN5VDqWvLXPVlW4bIEX S6R/vh0FVimaZvYcvZcIGif6TEcFDXdyo+1EM/A= X-Received: by 2002:a5d:4c41:0:b0:316:d887:624a with SMTP id n1-20020a5d4c41000000b00316d887624amr9872600wrt.15.1689598070052; Mon, 17 Jul 2023 05:47:50 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v16-20020a5d6790000000b003112ab916cdsm19337737wru.73.2023.07.17.05.47.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 05:47:49 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 5/7] target/arm/ptw.c: Account for FEAT_RME when applying {N}SW, SA bits Date: Mon, 17 Jul 2023 13:47:44 +0100 Message-Id: <20230717124746.759085-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230717124746.759085-1-peter.maydell@linaro.org> References: <20230717124746.759085-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.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, T_SCC_BODY_TEXT_LINE=-0.01 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 In get_phys_addr_twostage() the code that applies the effects of VSTCR.{SA,SW} and VTCR.{NSA,NSW} only updates result->f.attrs.secure. Now we also have f.attrs.space for FEAT_RME, we need to keep the two in sync. These bits only have an effect for Secure space translations, not for Root, so use the input in_space field to determine whether to apply them rather than the input is_secure. This doesn't actually make a difference because Root translations are never two-stage, but it's a little clearer. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230710152130.3928330-4-peter.maydell@linaro.org --- target/arm/ptw.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index c0b9cee5843..8f94100c61f 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -3118,6 +3118,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, hwaddr ipa; int s1_prot, s1_lgpgsz; bool is_secure = ptw->in_secure; + ARMSecuritySpace in_space = ptw->in_space; bool ret, ipa_secure; ARMCacheAttrs cacheattrs1; ARMSecuritySpace ipa_space; @@ -3200,11 +3201,13 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, * Check if IPA translates to secure or non-secure PA space. * Note that VSTCR overrides VTCR and {N}SW overrides {N}SA. */ - result->f.attrs.secure = - (is_secure - && !(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW)) - && (ipa_secure - || !(env->cp15.vtcr_el2 & (VTCR_NSA | VTCR_NSW)))); + if (in_space == ARMSS_Secure) { + result->f.attrs.secure = + !(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW)) + && (ipa_secure + || !(env->cp15.vtcr_el2 & (VTCR_NSA | VTCR_NSW))); + result->f.attrs.space = arm_secure_to_space(result->f.attrs.secure); + } return false; }