From patchwork Sun Mar 27 09:34:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Idan Horowitz X-Patchwork-Id: 1609873 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=pSIXr/D6; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KR9hP4rr2z9s09 for ; Sun, 27 Mar 2022 20:36:53 +1100 (AEDT) Received: from localhost ([::1]:48116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nYPKN-0003P2-OA for incoming@patchwork.ozlabs.org; Sun, 27 Mar 2022 05:36:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46136) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYPIm-0002kR-UH; Sun, 27 Mar 2022 05:35:17 -0400 Received: from [2a00:1450:4864:20::432] (port=43611 helo=mail-wr1-x432.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nYPIk-0002cA-5N; Sun, 27 Mar 2022 05:35:12 -0400 Received: by mail-wr1-x432.google.com with SMTP id a1so16302108wrh.10; Sun, 27 Mar 2022 02:34:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ABcxXaf3qNBOZkBqeTkKv0RGUyLEXj8LkCJhCdpicDw=; b=pSIXr/D60JHCWFbppP9W9FfpWA5WhalxobIpfIsok69jAR3A0Wf6VP4OVdZqaEGJ1Y jA7TnFFMOXOxoOulO3hTNSa1xrq7Y2GMIUnNviKJcjn7X5Ql8Aykl0SK4zzFEi/Ydzda WYRRm8LXIva2FsQKEc6ABIrMru+8ATRtdEHQBVgLgzwk6TCtCAm60ZNl3eytQF75hIgO 8bTsSL3vwknf/6TljOdjpDtaPn0ZXma6sMi0QU0YnDSUb8DOGr9L2HX0hPgXMPogArn2 1Hxxp8gndtJYc36X03iRjZc3DZBtaqoJloqnlTeOQ3d82LwMGk3tl1/omoN+nl2nm4sL IFyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ABcxXaf3qNBOZkBqeTkKv0RGUyLEXj8LkCJhCdpicDw=; b=auQNud8LtGgGh+4Vs0xTwzVePnF7Fdp1JxEmZgNM/U4P/talEiG7iKhjNaKWUc5q24 CK0spEPWBezrIfcBJF5zGGI+nwoMT4NCD2mYk7uqQ7oXOMDrFV4ZFf5QTVWMOW6qn3Pb 8PqQ+Mp9CXMSQho4mi70xLUFohd8jWaIzxgWEhI9NCPAz5nTlBa5dd8YQBrxIwbGIQEf 5WMggjmDP7U/QHRgwbYzn137bOMrNGPCx0B5HiqzhvjApQJIuatbyUmcdWx5lCQlpqvG QoS5wefYPGYravulITQSBNSODOo5aQllAhJUpGCziftXH3QXIFMtaDBlu3qclp/qRDy7 8D9g== X-Gm-Message-State: AOAM531RIfW36zjp5iTXBHQnwUW/ss2rIC0Ui9V3tu8Td+je+qMdrg5j BZGA7wKAyL7zGBY15mBpBzpYs+94cwE= X-Google-Smtp-Source: ABdhPJzZMogw56dekhv3mhaO4sfaMa/QLBDOAZgos1jSr6aERWCiCo2mWlUfmqickvvQjtjTj4DLBw== X-Received: by 2002:adf:ee41:0:b0:203:de82:c2aa with SMTP id w1-20020adfee41000000b00203de82c2aamr16579584wro.390.1648373695801; Sun, 27 Mar 2022 02:34:55 -0700 (PDT) Received: from li-142ea8cc-3370-11b2-a85c-c55585c2aa0e.ibm.com.com (bzq-79-183-80-20.red.bezeqint.net. [79.183.80.20]) by smtp.gmail.com with ESMTPSA id 14-20020a056000154e00b00203f8adde0csm11892039wry.32.2022.03.27.02.34.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Mar 2022 02:34:55 -0700 (PDT) From: Idan Horowitz To: qemu-arm@nongnu.org Subject: [PATCH 1/3] target/arm: Check VSTCR.SW when assigning the stage 2 output PA space Date: Sun, 27 Mar 2022 12:34:26 +0300 Message-Id: <20220327093427.1548629-2-idan.horowitz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220327093427.1548629-1-idan.horowitz@gmail.com> References: <20220327093427.1548629-1-idan.horowitz@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::432 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=idan.horowitz@gmail.com; helo=mail-wr1-x432.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Peter Maydell , Idan Horowitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" As per the AArch64.SS2OutputPASpace() psuedo-code in the ARMv8 ARM when the PA space of the IPA is non secure, the output PA space is secure if and only if all of the bits VTCR., VSTCR. are not set. Signed-off-by: Idan Horowitz Reviewed-by: Richard Henderson --- target/arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 812ca591f4..d0265b760f 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -12697,7 +12697,7 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, } else { attrs->secure = !((env->cp15.vtcr_el2.raw_tcr & (VTCR_NSA | VTCR_NSW)) - || (env->cp15.vstcr_el2.raw_tcr & VSTCR_SA)); + || (env->cp15.vstcr_el2.raw_tcr & (VSTCR_SA | VSTCR_SW))); } } return 0; From patchwork Sun Mar 27 09:34:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Idan Horowitz X-Patchwork-Id: 1609872 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=BM9uKh0N; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KR9hG0l5Jz9s09 for ; Sun, 27 Mar 2022 20:36:44 +1100 (AEDT) Received: from localhost ([::1]:47288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nYPKC-0002oY-RE for incoming@patchwork.ozlabs.org; Sun, 27 Mar 2022 05:36:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46132) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYPIm-0002kP-Uf; Sun, 27 Mar 2022 05:35:17 -0400 Received: from [2a00:1450:4864:20::331] (port=55201 helo=mail-wm1-x331.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nYPIk-0002cE-3f; Sun, 27 Mar 2022 05:35:12 -0400 Received: by mail-wm1-x331.google.com with SMTP id r64so6721042wmr.4; Sun, 27 Mar 2022 02:34:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=32ha3mXOG7idErYcB8ciYo6fEXlt3LYVju+O4kEI5V0=; b=BM9uKh0NXhgUy0rn8axSF5lMsBPvsJDMSi++snsjaIpuZDoLT1Rbfasq+mlOeD0Mpa SsLTCEtWlUjP2ryZGsVifHELBcry46equoDtuHYc3beBSEi2demhE8jUB5qXq9dMNlkw 6u7YGf6kpiXP8icmlcngsCVayjbvHBmES/9VTwK/+s3/4R9mFAm6icGG1ZCCfxNpmQzT J0wqGiNsT69d4wpKmZxybw1n5qoMZR7caE+gP4uz7cIq4SgoBma5mqpT8svPQ2zji9d4 n0VeJNH4BkP0L4+O9ah7PgaNGQ4MF5ozAd0waBX7PDxeEuEaehMNLKd3gos3UQziudOj 9Hfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=32ha3mXOG7idErYcB8ciYo6fEXlt3LYVju+O4kEI5V0=; b=J6csn0SLC/q9OVoLjZ8ySbA7Wgh+3neBORWWduwruiX9gfWCLVf4185KsyeXf+FA0J pcZtJRBfjwwOPf/+KUpvRRtF6XI8Ot3xd0NRlWULVr7gX6/bnD+iRRPl1tzaGuvJou6w kwVATxghq/ffYSJ8obrTo33wNgVCXHwuSh7yG6K+LqVgQsTy6ejngwkhIzIYEzsBigas WMMtpG+32HnTIBTMEq0rGimoA8/OccyqVVMyb389MFI5Ona8MXZ510ksCiSbVDSI/DUm YlT/kP0guClmaQ+UONAnlOFazD1ClBV9U7GxZIxIZOEHpzNvtmrkMht+mr9m7h+DjcNl qlZA== X-Gm-Message-State: AOAM532BF2YG/u3IaVnFxIyEJlb5DCNzNojMzvFpf8qOBj5uwvdlIhb6 RafkMe9DgU7Vm1zT4wF4ImjaMwlgneM= X-Google-Smtp-Source: ABdhPJz6C0xeH8eWBq/tJSfCdDSQLIFt5CKs3R1UDSCUy0fpLvFm6mLDwtUd5TviUR7FUd4ThR6SKA== X-Received: by 2002:a05:600c:4f87:b0:38c:adde:1d99 with SMTP id n7-20020a05600c4f8700b0038cadde1d99mr27743614wmq.16.1648373696934; Sun, 27 Mar 2022 02:34:56 -0700 (PDT) Received: from li-142ea8cc-3370-11b2-a85c-c55585c2aa0e.ibm.com.com (bzq-79-183-80-20.red.bezeqint.net. [79.183.80.20]) by smtp.gmail.com with ESMTPSA id 14-20020a056000154e00b00203f8adde0csm11892039wry.32.2022.03.27.02.34.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Mar 2022 02:34:56 -0700 (PDT) From: Idan Horowitz To: qemu-arm@nongnu.org Subject: [PATCH 2/3] target/arm: Take VSTCR.SW, VTCR.NSW into account in final stage 2 walk Date: Sun, 27 Mar 2022 12:34:27 +0300 Message-Id: <20220327093427.1548629-3-idan.horowitz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220327093427.1548629-1-idan.horowitz@gmail.com> References: <20220327093427.1548629-1-idan.horowitz@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::331 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=idan.horowitz@gmail.com; helo=mail-wm1-x331.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Peter Maydell , Idan Horowitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" As per the AArch64.SS2InitialTTWState() psuedo-code in the ARMv8 ARM the initial PA space used for stage 2 table walks is assigned based on the SW and NSW bits of the VSTCR and VTCR registers. This was already implemented for the recursive stage 2 page table walks in S1_ptw_translate(), but was missing for the final stage 2 walk. Signed-off-by: Idan Horowitz Reviewed-by: Richard Henderson --- target/arm/helper.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/arm/helper.c b/target/arm/helper.c index d0265b760f..e2695e846a 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -12657,6 +12657,16 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, return ret; } + if (arm_is_secure_below_el3(env)) { + if (attrs->secure) { + attrs->secure = !(env->cp15.vstcr_el2.raw_tcr & VSTCR_SW); + } else { + attrs->secure = !(env->cp15.vtcr_el2.raw_tcr & VTCR_NSW); + } + } else { + assert(!attrs->secure); + } + s2_mmu_idx = attrs->secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; is_el0 = mmu_idx == ARMMMUIdx_E10_0 || mmu_idx == ARMMMUIdx_SE10_0; From patchwork Sun Mar 27 09:34:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Idan Horowitz X-Patchwork-Id: 1609875 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=SgGk1zaj; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KR9l20mFvz9s09 for ; Sun, 27 Mar 2022 20:39:09 +1100 (AEDT) Received: from localhost ([::1]:54862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nYPMZ-0007wr-U9 for incoming@patchwork.ozlabs.org; Sun, 27 Mar 2022 05:39:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYPIm-0002kQ-Tz; Sun, 27 Mar 2022 05:35:17 -0400 Received: from [2a00:1450:4864:20::436] (port=41698 helo=mail-wr1-x436.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nYPIk-0002cK-49; Sun, 27 Mar 2022 05:35:12 -0400 Received: by mail-wr1-x436.google.com with SMTP id h23so16304434wrb.8; Sun, 27 Mar 2022 02:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E//zXgi7Zvk3jC2Mzbnu5NDh5bLaoeibchr3ErcYk+A=; b=SgGk1zajx3WWPYU7pknGrknpa+/xCfkUxlbHVg23eywbsqhSCbBlNCrxqUXlORtJ6i EMdYk6E3dOLjSeIGKQJfAUfgP6jFVYgc77639tBIc1nHwsJzoWxBw3vwo3FpYdvVCwfy MyLuHx6XtDyS2+7OV3nYQPOhLcyf2o89OTMpGoEYGRjIOPoSunbg34SFNeNyA8F7oNaA Saj43nJtX39TmUOFtaK6u50rgoGiZayc2GFFCqHBZLPNCio/PtEIBB5Tv5Zz+NXveT6S 4Krj2dB89Yy5YkPwh/+wGm6rN1Of60kbPLnodckBNTP5fbPx3wlxM3dRMVV2ImsrJkBx NrHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E//zXgi7Zvk3jC2Mzbnu5NDh5bLaoeibchr3ErcYk+A=; b=PF2jv0sZVXqFJEeVwGrKtZ8pFFU7toGrHj6i1VzJPDiGQBRdI1PYmV1CHXO8SxcdEu k2BjeRIWF+8SqCwnEJwDuqVIFYoJFP6SZvdVlBflY49BrgNKoPovcgr3HbCYLLju249q jguJxatQva/SiJPvvmLeqLw21AcxhVp/lStfPuXssSc9k41VkA45o3hgiBhhP9nmxsY7 QvTyr4xvDrYH5k8aEL/Q8UUNT6sO0pgb2rrUmZcYl/DsaEMif5r423/4CuUBdVES+Rm+ FyC6kBnByrYVp8klHUg9q8yE8iDTQ4xOGfWmPj1GNJ87x4/Le5sdm6NvpJvM1cF8V8fb CSFg== X-Gm-Message-State: AOAM531a+510eGHwcBiVV1JkdnkTA02B5VEXu/Wg9W3JjxSDHQ5CrkWG 8iF9+XpQnV/mgdcqgcexVraBN7vesHM= X-Google-Smtp-Source: ABdhPJybAcedHimwZgWqyq6/MrUrZlofmoR7BXKIUgkWtElT/M2ua+OnG5aPUIEwX/muZCaW41W3LA== X-Received: by 2002:a5d:6211:0:b0:1ef:85dd:c96b with SMTP id y17-20020a5d6211000000b001ef85ddc96bmr16712926wru.456.1648373698041; Sun, 27 Mar 2022 02:34:58 -0700 (PDT) Received: from li-142ea8cc-3370-11b2-a85c-c55585c2aa0e.ibm.com.com (bzq-79-183-80-20.red.bezeqint.net. [79.183.80.20]) by smtp.gmail.com with ESMTPSA id 14-20020a056000154e00b00203f8adde0csm11892039wry.32.2022.03.27.02.34.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Mar 2022 02:34:57 -0700 (PDT) From: Idan Horowitz To: qemu-arm@nongnu.org Subject: [PATCH 3/3] target/arm: Determine final stage 2 output PA space based on original IPA Date: Sun, 27 Mar 2022 12:34:28 +0300 Message-Id: <20220327093427.1548629-4-idan.horowitz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220327093427.1548629-1-idan.horowitz@gmail.com> References: <20220327093427.1548629-1-idan.horowitz@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::436 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=idan.horowitz@gmail.com; helo=mail-wr1-x436.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Peter Maydell , Idan Horowitz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" As per the AArch64.S2Walk() psuedo-code in the ARMv8 ARM, the final decision as to the output address's PA space based on the SA/SW/NSA/NSA bits needs to take the input IPA's PA space into account, and not the PA space of the result of the stage 2 walk itself. Signed-off-by: Idan Horowitz Reviewed-by: Richard Henderson --- target/arm/helper.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index e2695e846a..16c2628f8f 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -12644,6 +12644,7 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, hwaddr ipa; int s2_prot; int ret; + bool ipa_secure; ARMCacheAttrs cacheattrs2 = {}; ARMMMUIdx s2_mmu_idx; bool is_el0; @@ -12657,14 +12658,15 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, return ret; } + ipa_secure = attrs->secure; if (arm_is_secure_below_el3(env)) { - if (attrs->secure) { + if (ipa_secure) { attrs->secure = !(env->cp15.vstcr_el2.raw_tcr & VSTCR_SW); } else { attrs->secure = !(env->cp15.vtcr_el2.raw_tcr & VTCR_NSW); } } else { - assert(!attrs->secure); + assert(!ipa_secure); } s2_mmu_idx = attrs->secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; @@ -12701,7 +12703,7 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, /* Check if IPA translates to secure or non-secure PA space. */ if (arm_is_secure_below_el3(env)) { - if (attrs->secure) { + if (ipa_secure) { attrs->secure = !(env->cp15.vstcr_el2.raw_tcr & (VSTCR_SA | VSTCR_SW)); } else {