From nobody Thu Jun 13 22:28:29 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=1654766647; cv=none; d=zohomail.com; s=zohoarc; b=TIeV1SBnb3BYhKvCedKoxAe11MsxXykxPqICQVag9v/cZuezMralb/45k6HG5T/w0bno6UukFbwM5wCxHa4AZCeWspnMbaKT93rWHUamXykuieywkWayjnMCvTJfyWoY43iPEQ+y54X6YiN3Ad8/mOfqxcXYjudWOTM48qeutBo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654766647; 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=n6D/t27wwLVN4prcAZRU1vm1AJNkQw3wnfuM1H0pUck=; b=dWoZemi8u8veFCCDU+0V0sI5Dmp/wood0XtmO7OFWPFWt21NsSA4HSdVBGRzftdW3Gpsmhe5YL0VBAOaHRU2Csj6ube6dOcMhsxEjgni/6jR1HZphVGLZZaomVM6knM6IBL6o7RKhCpJQXfsRl0ZEIH5fQDuMYAcVaGuUz+Rrhs= 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 165476664751586.19817518528941; Thu, 9 Jun 2022 02:24:07 -0700 (PDT) Received: from localhost ([::1]:37042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzEOb-0002mf-FV for importer@patchew.org; Thu, 09 Jun 2022 05:24:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE6t-0001OL-KI for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:48 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:46807) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE6q-0005v7-J9 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:47 -0400 Received: by mail-wr1-x429.google.com with SMTP id u8so27137454wrm.13 for ; Thu, 09 Jun 2022 02:05:43 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.05.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:05:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=n6D/t27wwLVN4prcAZRU1vm1AJNkQw3wnfuM1H0pUck=; b=h5Hwx/K2RSxhAEALBLGhe9sLO7nb48J383r2uyz/pSSfGhvp7FgZZnakzY+n7A7xEp U1x5Z/uuRLLBhDjZ5cbfP3P8Kmu2JlTx66BBe/Uy4R92F0tIK/SMms+15yrBnPe9dcBI PFV6B8lvXrMBjocMsh4KceBi06mCS86XLB8doY43a5Yt6dlyTQadknLB/2uQhHXMTQng O7v2LAwv4IIK3uALE/YpdXQW9JyV5050/PyrNPQgp1U2fCt6fyQcBcE79WSKAEsQw34Y vSyERkpyerYei2/mjJRFYpofejufXwfcSjOntAg9zsATD6shNrkkkTvSzhnoz9Ha7g1q cn7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=n6D/t27wwLVN4prcAZRU1vm1AJNkQw3wnfuM1H0pUck=; b=JZh8kCIyPhSXCtVr4Jp36qBn2xIFUH3PPURa7zSbGgjU1tvxrdicZ7VL7nHJMZ+2fN gp/Dm8r3PwhVy/kicXNG/P1Ak085GZ21Hfes3s71L/UNP8TOtmj0nANoTM2aOGy7Lzo2 NxS7VemyL0kf+hTbnprflpz70mOVpOqqX6/Ydr+U90hmmEwEAo3dpeELhEdXSWM5vRIO dxl0ZWxyhB4IsBw6w9w6LdcpJNpKvb8zx6QU//70oAHiqQxYv8kWKyGLL5tJsDRww4lw JiMRvgQbhahJgOuU5XH68eIo+7mZYtIEIuRs25hVECq4POTZrWkQQltBUQ9aDNQLb0Rs rc4A== X-Gm-Message-State: AOAM533L4oTfDsV3BIS3jCkoj5Pi5J9bBycJMahcKJwbqSWmXmsynHFE uwhGz5qC4ZMDXj0Xqw5J9WihMfXI17F02Q== X-Google-Smtp-Source: ABdhPJz541PpLudOFm4JUSnMHYwZDslojfnzgjk3sF+xmhsER1uO6SbRR4YzGSyYzJmDlMPDQ3Jluw== X-Received: by 2002:a5d:4290:0:b0:213:badd:abc5 with SMTP id k16-20020a5d4290000000b00213baddabc5mr32113648wrq.54.1654765541512; Thu, 09 Jun 2022 02:05:41 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 01/55] target/arm: Declare support for FEAT_RASv1p1 Date: Thu, 9 Jun 2022 10:04:43 +0100 Message-Id: <20220609090537.1971756-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654766648498100001 Content-Type: text/plain; charset="utf-8" The architectural feature RASv1p1 introduces the following new features: * new registers ERXPFGCDN_EL1, ERXPFGCTL_EL1 and ERXPFGF_EL1 * new bits in the fine-grained trap registers that control traps for these new registers * new trap bits HCR_EL2.FIEN and SCR_EL3.FIEN that control traps for ERXPFGCDN_EL1, ERXPFGCTL_EL1, ERXPFGP_EL1 * a larger number of the ERXMISC_EL1 registers * the format of ERRSTATUS registers changes The architecture permits that if ERRIDR_EL1.NUM is 0 (as it is for QEMU) then all these new registers may UNDEF, and the HCR_EL2.FIEN and SCR_EL3.FIEN bits may be RES0. We don't have any ERRSTATUS registers (again, because ERRIDR_EL1.NUM is 0). QEMU does not yet implement the fine-grained-trap extension. So there is nothing we need to implement to be compliant with the feature spec. Make the 'max' CPU report the feature in its ID registers, and document it. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20220531114258.855804-1-peter.maydell@linaro.org --- docs/system/arm/emulation.rst | 1 + target/arm/cpu64.c | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index 49cc3e8340e..81467f02ce9 100644 --- a/docs/system/arm/emulation.rst +++ b/docs/system/arm/emulation.rst @@ -52,6 +52,7 @@ the following architecture extensions: - FEAT_PMUv3p1 (PMU Extensions v3.1) - FEAT_PMUv3p4 (PMU Extensions v3.4) - FEAT_RAS (Reliability, availability, and serviceability) +- FEAT_RASv1p1 (RAS Extension v1.1) - FEAT_RDM (Advanced SIMD rounding double multiply accumulate instructions) - FEAT_RNG (Random number generator) - FEAT_S2FWB (Stage 2 forced Write-Back) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 3ff9219ca3b..bd1c62a3428 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -916,6 +916,7 @@ static void aarch64_max_initfn(Object *obj) * we do for EL2 with the virtualization=3Don property. */ t =3D FIELD_DP64(t, ID_AA64PFR1, MTE, 3); /* FEAT_MTE3 */ + t =3D FIELD_DP64(t, ID_AA64PFR1, RAS_FRAC, 1); /* FEAT_RASv1p1 */ t =3D FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_2 */ cpu->isar.id_aa64pfr1 =3D t; =20 --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654766198; cv=none; d=zohomail.com; s=zohoarc; b=QSFJgV0CyaMlsESBxS/DM4hWtMjHtzoNgiU4A8nbW43tAqvS/RnNStbQslVSc5fxbt7gyDC8X6bOtfw7hs2ojWSJ36pEP00iMJKGtADy3PB81FSNu14maYlOzvCCdk9dZ84fgUE6BdYDk402dxvctqvDEMBs8qYiJEXk4/zmFE8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654766198; 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=tSthpF0IBNTJTlo30iWopYy1wniqooBbIAyfiEVSRlg=; b=apdgH/ajcxx+uIXb8c3gphuKIryEvxygbGTww9CFkGVwo+vbJ8cqb7SsaEPYRbec6uzOyVA6I4htjHOgYZ4YZpPGsCWD9aiK41HxtE8hL487GhKanMvo0mk0Hp2Xt9GK8e06BHHBG5TscsZBkH5CSbhXkuHv2sbWjJF8BS+G3is= 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 1654766198137932.357988618005; Thu, 9 Jun 2022 02:16:38 -0700 (PDT) Received: from localhost ([::1]:57530 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzEHN-0005Yh-1v for importer@patchew.org; Thu, 09 Jun 2022 05:16:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE6t-0001OM-Kr for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:48 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:38492) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE6q-0005vV-JI for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:47 -0400 Received: by mail-wr1-x430.google.com with SMTP id v14so5217169wra.5 for ; Thu, 09 Jun 2022 02:05:43 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.05.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:05:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=tSthpF0IBNTJTlo30iWopYy1wniqooBbIAyfiEVSRlg=; b=GOPr49eK9pq2k3gRjzuhfdVvDUrv10wE9LDEaYYk3C2Fz9a6ACIxfQLOLak4hv8P1M UBy+o6NwOXdG9U5FmGtt98QNsiICeDKCmxUshS2k7p1SbsQQJJqbytlkaVbIrEwNkocu UyMMHYpeHgduPlX9pSUMqSLaTO3htVxXEwIIOV8hhVNDhGljlbYq9jpeA9/bEmjw8DJP 77V8groWW5y1xzudbZfQU2Z4mYCaIjmjzK1MnaJvhmeIrXElGCacIv4RFXOKTQ9vB7XR Ia8g/YEbtgosWlYKVQLRxfB858kKf4oUtjzaC5UnGj4n7DSR32lPyqPYFrSCda3qhv4Y gM/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tSthpF0IBNTJTlo30iWopYy1wniqooBbIAyfiEVSRlg=; b=Vpy8ZA65fCG+dSCPJHuWD0qe0zr9iP/RQhKqDNuiDHd8sqwHbNpc9hNl8l/wGWqmgv nrIN5swu4qMBYejF+a5r2/ybcOC5xcPUOHweToebLXBCPNAuVNl7ggEGTfYHR6FjgBUh oS4RdAR4U8I+HlnQpIjxpu2dwB5LlWYnm7phMgHMHMhX8olyyrvcu4UUQxG1jvIbfwb6 Be8onCbhjSlzyqZAc+aGXfC2BTl0TM+8PNQ0lekfaGcTJeqVPecZhGF01tNv/p5AGplJ yJxiU9SbEz1+5q23/NrMRIc/K2ewVwx3AKRv1sj2183kPVgLCY0NzmczqaAa4gRoWzkK EyFw== X-Gm-Message-State: AOAM533qmS911VKetpDQzMMZaK9b1FhnJ/3vklxUMgDp2TXKHDr5/N2e zP35aGm6jqAOAzvP8A0xFrZ/OvapGEJfNw== X-Google-Smtp-Source: ABdhPJwqju/fOhXt3dwbPsKwxylepNM5xE92NWU0dE7prWtjRaItKVivWtAPgAaBbxEniPINlG5R6w== X-Received: by 2002:a5d:67c2:0:b0:215:7a0f:71f9 with SMTP id n2-20020a5d67c2000000b002157a0f71f9mr30971485wrw.486.1654765542593; Thu, 09 Jun 2022 02:05:42 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 02/55] target/arm: Implement FEAT_DoubleFault Date: Thu, 9 Jun 2022 10:04:44 +0100 Message-Id: <20220609090537.1971756-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::430; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x430.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654766198900100001 Content-Type: text/plain; charset="utf-8" The FEAT_DoubleFault extension adds the following: * All external aborts on instruction fetches and translation table walks for instruction fetches must be synchronous. For QEMU this is already true. * SCR_EL3 has a new bit NMEA which disables the masking of SError interrupts by PSTATE.A when the SError interrupt is taken to EL3. For QEMU we only need to make the bit writable, because we have no sources of SError interrupts. * SCR_EL3 has a new bit EASE which causes synchronous external aborts taken to EL3 to be taken at the same entry point as SError. (Note that this does not mean that they are SErrors for purposes of PSTATE.A masking or that the syndrome register reports them as SErrors: it just means that the vector offset is different.) * The existing SCTLR_EL3.IESB has an effective value of 1 when SCR_EL3.NMEA is 1. For QEMU this is a no-op because we don't need different behaviour based on IESB (we don't need to do anything to ensure that error exceptions are synchronized). So for QEMU the things we need to change are: * Make SCR_EL3.{NMEA,EASE} writable * When taking a synchronous external abort at EL3, adjust the vector entry point if SCR_EL3.EASE is set * Advertise the feature in the ID registers Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20220531151431.949322-1-peter.maydell@linaro.org --- docs/system/arm/emulation.rst | 1 + target/arm/cpu.h | 5 +++++ target/arm/cpu64.c | 4 ++-- target/arm/helper.c | 36 +++++++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index 81467f02ce9..83b44100659 100644 --- a/docs/system/arm/emulation.rst +++ b/docs/system/arm/emulation.rst @@ -23,6 +23,7 @@ the following architecture extensions: - FEAT_Debugv8p2 (Debug changes for v8.2) - FEAT_Debugv8p4 (Debug changes for v8.4) - FEAT_DotProd (Advanced SIMD dot product instructions) +- FEAT_DoubleFault (Double Fault Extension) - FEAT_FCMA (Floating-point complex number instructions) - FEAT_FHM (Floating-point half-precision multiplication instructions) - FEAT_FP16 (Half-precision floating-point data processing) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index c1865ad5dad..0ee1705a4fa 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3952,6 +3952,11 @@ static inline bool isar_feature_aa64_ras(const ARMIS= ARegisters *id) return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RAS) !=3D 0; } =20 +static inline bool isar_feature_aa64_doublefault(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RAS) >=3D 2; +} + static inline bool isar_feature_aa64_sve(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) !=3D 0; diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index bd1c62a3428..cce68dd82a2 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -899,7 +899,7 @@ static void aarch64_max_initfn(Object *obj) t =3D cpu->isar.id_aa64pfr0; t =3D FIELD_DP64(t, ID_AA64PFR0, FP, 1); /* FEAT_FP16 */ t =3D FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1); /* FEAT_FP16 */ - t =3D FIELD_DP64(t, ID_AA64PFR0, RAS, 1); /* FEAT_RAS */ + t =3D FIELD_DP64(t, ID_AA64PFR0, RAS, 2); /* FEAT_RASv1p1 + FEAT= _DoubleFault */ t =3D FIELD_DP64(t, ID_AA64PFR0, SVE, 1); t =3D FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */ t =3D FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ @@ -916,7 +916,7 @@ static void aarch64_max_initfn(Object *obj) * we do for EL2 with the virtualization=3Don property. */ t =3D FIELD_DP64(t, ID_AA64PFR1, MTE, 3); /* FEAT_MTE3 */ - t =3D FIELD_DP64(t, ID_AA64PFR1, RAS_FRAC, 1); /* FEAT_RASv1p1 */ + t =3D FIELD_DP64(t, ID_AA64PFR1, RAS_FRAC, 0); /* FEAT_RASv1p1 + FEAT= _DoubleFault */ t =3D FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_2 */ cpu->isar.id_aa64pfr1 =3D t; =20 diff --git a/target/arm/helper.c b/target/arm/helper.c index 40da63913c9..7f2c14bea94 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -1776,6 +1776,9 @@ static void scr_write(CPUARMState *env, const ARMCPRe= gInfo *ri, uint64_t value) if (cpu_isar_feature(aa64_scxtnum, cpu)) { valid_mask |=3D SCR_ENSCXT; } + if (cpu_isar_feature(aa64_doublefault, cpu)) { + valid_mask |=3D SCR_EASE | SCR_NMEA; + } } else { valid_mask &=3D ~(SCR_RW | SCR_ST); if (cpu_isar_feature(aa32_ras, cpu)) { @@ -10113,6 +10116,31 @@ static uint32_t cpsr_read_for_spsr_elx(CPUARMState= *env) return ret; } =20 +static bool syndrome_is_sync_extabt(uint32_t syndrome) +{ + /* Return true if this syndrome value is a synchronous external abort = */ + switch (syn_get_ec(syndrome)) { + case EC_INSNABORT: + case EC_INSNABORT_SAME_EL: + case EC_DATAABORT: + case EC_DATAABORT_SAME_EL: + /* Look at fault status code for all the synchronous ext abort cas= es */ + switch (syndrome & 0x3f) { + case 0x10: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + return true; + default: + return false; + } + default: + return false; + } +} + /* Handle exception entry to a target EL which is using AArch64 */ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) { @@ -10168,6 +10196,14 @@ static void arm_cpu_do_interrupt_aarch64(CPUState = *cs) switch (cs->exception_index) { case EXCP_PREFETCH_ABORT: case EXCP_DATA_ABORT: + /* + * FEAT_DoubleFault allows synchronous external aborts taken to EL3 + * to be taken to the SError vector entrypoint. + */ + if (new_el =3D=3D 3 && (env->cp15.scr_el3 & SCR_EASE) && + syndrome_is_sync_extabt(env->exception.syndrome)) { + addr +=3D 0x180; + } env->cp15.far_el[new_el] =3D env->exception.vaddress; qemu_log_mask(CPU_LOG_INT, "...with FAR 0x%" PRIx64 "\n", env->cp15.far_el[new_el]); --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654766720; cv=none; d=zohomail.com; s=zohoarc; b=Lheyw+zDk++BOdHS+tvxKAWHggCg4c6tMO9jGALxyz6XSUF8p06kLfNlALkKOMfJztebKoylrx4KYgqYZGZ08/WxvOv96Bkkys01XlW+fZUHe+h8UpmJMk1dSS4EXh3VrVct/lwD7v/kNbBU4lHfCARuuYUq/7ldkxJhK5yuEwQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654766720; h=Content-Type: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=a3NPxQEfQiPYIU+CS5LV4PTQGOjBrNVkuFvlYXBD2EU=; b=X8bpsatvcgPBtY4x2aaTcro2CbdDrAj8MfBxYmmO2C0NQuqnk/xZxA7Agh2TGAB0MfGc7s36tJMe4IsbSHI6gGbWnHSlNQuNGf/tcDJw4YWXI4sD/I1URmtPzh9EoN0uef87GdfD4iEj8NYL6jBzEoD9r2+bin89oomQhDvnXvQ= 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 1654766720074925.9899566717642; Thu, 9 Jun 2022 02:25:20 -0700 (PDT) Received: from localhost ([::1]:40010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzEPm-0004rC-KO for importer@patchew.org; Thu, 09 Jun 2022 05:25:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE6v-0001P1-WB for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:50 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:55142) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE6s-0005w5-7u for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:49 -0400 Received: by mail-wm1-x32e.google.com with SMTP id n185so12105923wmn.4 for ; Thu, 09 Jun 2022 02:05:45 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.05.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:05:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=a3NPxQEfQiPYIU+CS5LV4PTQGOjBrNVkuFvlYXBD2EU=; b=oPESQEkJiXqw96JYsCxfSoPpocP0aqx+3VH1r+Ynns3kKgdLEX9GLzSRWlk8RKWGbL vNveqnGaCaAP7wNrJe0wzSTUPukJS5cs8PFLjcMledJuL85BAYx++nkATSz5cDecWber G/ENPwecldYz7lw5V7rIN6Hcc9a9FmVfJ9ZOA23YPPc05CdHTka8hvLfpQUd2716FYFQ XdkJJHVuAdJpnudQ/F+aOhjEgrQXIl/Fmv74plC4hd0sLLM8R23Y/elqJQ8BqGZCngHI 7dskp9ME51CtUwGrH7Va6x/fBnBDkA+x2PPCxG4Cp/+xGiecbZ2e681QZSa2oCyR9JEG ad9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a3NPxQEfQiPYIU+CS5LV4PTQGOjBrNVkuFvlYXBD2EU=; b=WxTiHT3z4oVUswb7vXNB/87oiXauzFCBMhwkPQoJBZe11yjMYBzmR7zavQf/WH+FfL PbAb8E/P8pFVnly38cjA4d/dXXm9XShvK53Q42TfIV+1vuraBwlNsBIIBTSuqvkziin2 7Gj9Z4+NscQO+EjNSXPWCGWN0CpB0Ub+3vhVXWWwkO5pQDVLkJt6s5QTTbJgplz4GQsb t1tLmUDEh5vZvTYOQ95I3aKR3E7f5MVAqRqGgFygTGUK68ooUZAGiRwge4u2LrvUBj8w bJbY8xqaz7MQBkSDcBtmk5VrA6DaSeJwU0kYBF8nOi1CFYbLaLMRnqHc2vQMRe3F41vK gkSg== X-Gm-Message-State: AOAM5325Ow43y5OLThXK8bIAF2/9RF+xQ6zjRRXQd3yWx7U44P8BeR30 USGO2XdH+NwJrSTQzLRJaeMdR5AyJV0gxw== X-Google-Smtp-Source: ABdhPJxnIAtll6SHbB3h3KI78Nbcu76oy62/LLR8rtnDrEicdQLQYA8FaODv7Ze3x+sQRwG0d9QDNw== X-Received: by 2002:a1c:4682:0:b0:39c:4459:6a84 with SMTP id t124-20020a1c4682000000b0039c44596a84mr2209884wma.167.1654765543794; Thu, 09 Jun 2022 02:05:43 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 03/55] Fix 'writeable' typos Date: Thu, 9 Jun 2022 10:04:45 +0100 Message-Id: <20220609090537.1971756-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654766720711100001 We have about 30 instances of the typo/variant spelling 'writeable', and over 500 of the more common 'writable'. Standardize on the latter. Change produced with: sed -i -e 's/\([Ww][Rr][Ii][Tt]\)[Ee]\([Aa][Bb][Ll][Ee]\)/\1\2/g' $(git g= rep -il writeable) and then hand-undoing the instance in linux-headers/linux/kvm.h. Most of these changes are in comments or documentation; the exceptions are: * a local variable in accel/hvf/hvf-accel-ops.c * a local variable in accel/kvm/kvm-all.c * the PMCR_WRITABLE_MASK macro in target/arm/internals.h * the EPT_VIOLATION_GPA_WRITABLE macro in target/i386/hvf/vmcs.h (which is never used anywhere) * the AR_TYPE_WRITABLE_MASK macro in target/i386/hvf/vmx.h (which is never used anywhere) Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Weil Message-id: 20220505095015.2714666-1-peter.maydell@linaro.org --- docs/interop/vhost-user.rst | 2 +- docs/specs/vmgenid.txt | 4 ++-- hw/scsi/mfi.h | 2 +- target/arm/internals.h | 4 ++-- target/i386/hvf/vmcs.h | 2 +- target/i386/hvf/vmx.h | 2 +- accel/hvf/hvf-accel-ops.c | 4 ++-- accel/kvm/kvm-all.c | 4 ++-- accel/tcg/user-exec.c | 6 +++--- hw/acpi/ghes.c | 2 +- hw/intc/arm_gicv3_cpuif.c | 2 +- hw/intc/arm_gicv3_dist.c | 2 +- hw/intc/arm_gicv3_redist.c | 4 ++-- hw/intc/riscv_aclint.c | 2 +- hw/intc/riscv_aplic.c | 2 +- hw/pci/shpc.c | 2 +- hw/sparc64/sun4u_iommu.c | 2 +- hw/timer/sse-timer.c | 2 +- target/arm/gdbstub.c | 2 +- target/arm/helper.c | 4 ++-- target/arm/hvf/hvf.c | 4 ++-- target/i386/cpu-sysemu.c | 2 +- target/s390x/ioinst.c | 2 +- python/qemu/machine/machine.py | 2 +- tests/tcg/x86_64/system/boot.S | 2 +- 25 files changed, 34 insertions(+), 34 deletions(-) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index a99ba4433ce..d7cf904f7fe 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -222,7 +222,7 @@ Virtio device config space :size: a 32-bit configuration space access size in bytes =20 :flags: a 32-bit value: - - 0: Vhost front-end messages used for writeable fields + - 0: Vhost front-end messages used for writable fields - 1: Vhost front-end messages used for live migration =20 :payload: Size bytes array holding the contents of the virtio diff --git a/docs/specs/vmgenid.txt b/docs/specs/vmgenid.txt index aa9f5186767..80ff69f31cc 100644 --- a/docs/specs/vmgenid.txt +++ b/docs/specs/vmgenid.txt @@ -153,7 +153,7 @@ change the contents of the memory at runtime, specifica= lly when starting a backed-up or snapshotted image. In order to do this, QEMU must know the address that has been allocated. =20 -The mechanism chosen for this memory sharing is writeable fw_cfg blobs. +The mechanism chosen for this memory sharing is writable fw_cfg blobs. These are data object that are visible to both QEMU and guests, and are addressable as sequential files. =20 @@ -164,7 +164,7 @@ Two fw_cfg blobs are used in this case: /etc/vmgenid_guid - contains the actual VM Generation ID GUID - read-only to the guest /etc/vmgenid_addr - contains the address of the downloaded vmgenid blob - - writeable by the guest + - writable by the guest =20 =20 QEMU sends the following commands to the guest at startup: diff --git a/hw/scsi/mfi.h b/hw/scsi/mfi.h index e67a5c0b477..0b4ee53dfc0 100644 --- a/hw/scsi/mfi.h +++ b/hw/scsi/mfi.h @@ -633,7 +633,7 @@ struct mfi_ctrl_props { * metadata and user data * 1=3D5%, 2=3D10%, 3=3D15% and so on */ - uint8_t viewSpace; /* snapshot writeable VIEWs + uint8_t viewSpace; /* snapshot writable VIEWs * capacity as a % of source LD * capacity. 0=3DREAD only * 1=3D5%, 2=3D10%, 3=3D15% and so on diff --git a/target/arm/internals.h b/target/arm/internals.h index b654bee4682..1e4887b2dd3 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1280,10 +1280,10 @@ enum MVEECIState { #define PMCRP 0x2 #define PMCRE 0x1 /* - * Mask of PMCR bits writeable by guest (not including WO bits like C, P, + * Mask of PMCR bits writable by guest (not including WO bits like C, P, * which can be written as 1 to trigger behaviour but which stay RAZ). */ -#define PMCR_WRITEABLE_MASK (PMCRLC | PMCRDP | PMCRX | PMCRD | PMCRE) +#define PMCR_WRITABLE_MASK (PMCRLC | PMCRDP | PMCRX | PMCRD | PMCRE) =20 #define PMXEVTYPER_P 0x80000000 #define PMXEVTYPER_U 0x40000000 diff --git a/target/i386/hvf/vmcs.h b/target/i386/hvf/vmcs.h index 42de7ebc3af..b4692f63f65 100644 --- a/target/i386/hvf/vmcs.h +++ b/target/i386/hvf/vmcs.h @@ -330,7 +330,7 @@ #define EPT_VIOLATION_DATA_WRITE (1UL << 1) #define EPT_VIOLATION_INST_FETCH (1UL << 2) #define EPT_VIOLATION_GPA_READABLE (1UL << 3) -#define EPT_VIOLATION_GPA_WRITEABLE (1UL << 4) +#define EPT_VIOLATION_GPA_WRITABLE (1UL << 4) #define EPT_VIOLATION_GPA_EXECUTABLE (1UL << 5) #define EPT_VIOLATION_GLA_VALID (1UL << 7) #define EPT_VIOLATION_XLAT_VALID (1UL << 8) diff --git a/target/i386/hvf/vmx.h b/target/i386/hvf/vmx.h index 573ddc33c07..fcd9a95e5b5 100644 --- a/target/i386/hvf/vmx.h +++ b/target/i386/hvf/vmx.h @@ -80,7 +80,7 @@ static inline uint64_t cap2ctrl(uint64_t cap, uint64_t ct= rl) =20 #define AR_TYPE_ACCESSES_MASK 1 #define AR_TYPE_READABLE_MASK (1 << 1) -#define AR_TYPE_WRITEABLE_MASK (1 << 2) +#define AR_TYPE_WRITABLE_MASK (1 << 2) #define AR_TYPE_CODE_MASK (1 << 3) #define AR_TYPE_MASK 0x0f #define AR_TYPE_BUSY_64_TSS 11 diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index a70e2eb375d..24913ca9c49 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -120,12 +120,12 @@ static void hvf_set_phys_mem(MemoryRegionSection *sec= tion, bool add) { hvf_slot *mem; MemoryRegion *area =3D section->mr; - bool writeable =3D !area->readonly && !area->rom_device; + bool writable =3D !area->readonly && !area->rom_device; hv_memory_flags_t flags; uint64_t page_size =3D qemu_real_host_page_size(); =20 if (!memory_region_is_ram(area)) { - if (writeable) { + if (writable) { return; } else if (!memory_region_is_romd(area)) { /* diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 32e177bd26b..a4c4863f532 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1346,13 +1346,13 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml, KVMSlot *mem; int err; MemoryRegion *mr =3D section->mr; - bool writeable =3D !mr->readonly && !mr->rom_device; + bool writable =3D !mr->readonly && !mr->rom_device; hwaddr start_addr, size, slot_size, mr_offset; ram_addr_t ram_start_offset; void *ram; =20 if (!memory_region_is_ram(mr)) { - if (writeable || !kvm_readonly_mem_allowed) { + if (writable || !kvm_readonly_mem_allowed) { return; } else if (!mr->romd_mode) { /* If the memory device is not in romd_mode, then we actually = want diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index ac57324d4f6..20ada5472b4 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -101,10 +101,10 @@ MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is= _write) * Return true if the write fault has been handled, and should be re-tried. * * Note that it is important that we don't call page_unprotect() unless - * this is really a "write to nonwriteable page" fault, because + * this is really a "write to nonwritable page" fault, because * page_unprotect() assumes that if it is called for an access to - * a page that's writeable this means we had two threads racing and - * another thread got there first and already made the page writeable; + * a page that's writable this means we had two threads racing and + * another thread got there first and already made the page writable; * so we will retry the access. If we were to call page_unprotect() * for some other kind of fault that should really be passed to the * guest, we'd end up in an infinite loop of retrying the faulting access. diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index 45d9a809cc9..e9511d9b8f7 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -249,7 +249,7 @@ void build_ghes_error_table(GArray *hardware_errors, BI= OSLinker *linker) for (i =3D 0; i < ACPI_GHES_ERROR_SOURCE_COUNT; i++) { /* * Initialize the value of read_ack_register to 1, so GHES can be - * writeable after (re)boot. + * writable after (re)boot. * ACPI 6.2: 18.3.2.8 Generic Hardware Error Source version 2 * (GHESv2 - Type 10) */ diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c index 8867e2e496f..8ca630e5ad1 100644 --- a/hw/intc/arm_gicv3_cpuif.c +++ b/hw/intc/arm_gicv3_cpuif.c @@ -2047,7 +2047,7 @@ static void icc_ctlr_el3_write(CPUARMState *env, cons= t ARMCPRegInfo *ri, cs->icc_ctlr_el1[GICV3_S] |=3D ICC_CTLR_EL1_CBPR; } =20 - /* The only bit stored in icc_ctlr_el3 which is writeable is EOIMODE_E= L3: */ + /* The only bit stored in icc_ctlr_el3 which is writable is EOIMODE_EL= 3: */ mask =3D ICC_CTLR_EL3_EOIMODE_EL3; =20 cs->icc_ctlr_el3 &=3D ~mask; diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c index b9ed955e36b..eea03681187 100644 --- a/hw/intc/arm_gicv3_dist.c +++ b/hw/intc/arm_gicv3_dist.c @@ -611,7 +611,7 @@ static bool gicd_writel(GICv3State *s, hwaddr offset, if (value & mask & GICD_CTLR_DS) { /* We just set DS, so the ARE_NS and EnG1S bits are now RES0. * Note that this is a one-way transition because if DS is set - * then it's not writeable, so it can only go back to 0 with a + * then it's not writable, so it can only go back to 0 with a * hardware reset. */ s->gicd_ctlr &=3D ~(GICD_CTLR_EN_GRP1S | GICD_CTLR_ARE_NS); diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c index c3d4cdd66b7..f1ecb2502b1 100644 --- a/hw/intc/arm_gicv3_redist.c +++ b/hw/intc/arm_gicv3_redist.c @@ -257,7 +257,7 @@ static void gicr_write_vpendbaser(GICv3CPUState *cs, ui= nt64_t newval) =20 /* * The DIRTY bit is read-only and for us is always zero; - * other fields are writeable. + * other fields are writable. */ newval &=3D R_GICR_VPENDBASER_INNERCACHE_MASK | R_GICR_VPENDBASER_SHAREABILITY_MASK | @@ -491,7 +491,7 @@ static MemTxResult gicr_writel(GICv3CPUState *cs, hwadd= r offset, /* RAZ/WI for our implementation */ return MEMTX_OK; case GICR_WAKER: - /* Only the ProcessorSleep bit is writeable. When the guest sets + /* Only the ProcessorSleep bit is writable. When the guest sets * it it requests that we transition the channel between the * redistributor and the cpu interface to quiescent, and that * we set the ChildrenAsleep bit once the inteface has reached the diff --git a/hw/intc/riscv_aclint.c b/hw/intc/riscv_aclint.c index e6bceceefdb..e7942c4e5a3 100644 --- a/hw/intc/riscv_aclint.c +++ b/hw/intc/riscv_aclint.c @@ -463,7 +463,7 @@ static void riscv_aclint_swi_realize(DeviceState *dev, = Error **errp) /* Claim software interrupt bits */ for (i =3D 0; i < swi->num_harts; i++) { RISCVCPU *cpu =3D RISCV_CPU(qemu_get_cpu(swi->hartid_base + i)); - /* We don't claim mip.SSIP because it is writeable by software */ + /* We don't claim mip.SSIP because it is writable by software */ if (riscv_cpu_claim_interrupts(cpu, swi->sswi ? 0 : MIP_MSIP) < 0)= { error_report("MSIP already claimed"); exit(1); diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c index e7809fb6b2c..cfd007e629c 100644 --- a/hw/intc/riscv_aplic.c +++ b/hw/intc/riscv_aplic.c @@ -646,7 +646,7 @@ static void riscv_aplic_write(void *opaque, hwaddr addr= , uint64_t value, } =20 if (addr =3D=3D APLIC_DOMAINCFG) { - /* Only IE bit writeable at the moment */ + /* Only IE bit writable at the moment */ value &=3D APLIC_DOMAINCFG_IE; aplic->domaincfg =3D value; } else if ((APLIC_SOURCECFG_BASE <=3D addr) && diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c index 28e62174c42..f822f18b980 100644 --- a/hw/pci/shpc.c +++ b/hw/pci/shpc.c @@ -456,7 +456,7 @@ static int shpc_cap_add_config(PCIDevice *d, Error **er= rp) pci_set_byte(config + SHPC_CAP_CxP, 0); pci_set_long(config + SHPC_CAP_DWORD_DATA, 0); d->shpc->cap =3D config_offset; - /* Make dword select and data writeable. */ + /* Make dword select and data writable. */ pci_set_byte(d->wmask + config_offset + SHPC_CAP_DWORD_SELECT, 0xff); pci_set_long(d->wmask + config_offset + SHPC_CAP_DWORD_DATA, 0xfffffff= f); return 0; diff --git a/hw/sparc64/sun4u_iommu.c b/hw/sparc64/sun4u_iommu.c index 9178277f824..1c1dca712e3 100644 --- a/hw/sparc64/sun4u_iommu.c +++ b/hw/sparc64/sun4u_iommu.c @@ -165,7 +165,7 @@ static IOMMUTLBEntry sun4u_translate_iommu(IOMMUMemoryR= egion *iommu, } =20 if (tte & IOMMU_TTE_DATA_W) { - /* Writeable */ + /* Writable */ ret.perm =3D IOMMU_RW; } else { ret.perm =3D IOMMU_RO; diff --git a/hw/timer/sse-timer.c b/hw/timer/sse-timer.c index f959cb9d603..e92e83747d2 100644 --- a/hw/timer/sse-timer.c +++ b/hw/timer/sse-timer.c @@ -324,7 +324,7 @@ static void sse_timer_write(void *opaque, hwaddr offset= , uint64_t value, { uint32_t old_ctl =3D s->cntp_aival_ctl; =20 - /* EN bit is writeable; CLR bit is write-0-to-clear, write-1-ignor= ed */ + /* EN bit is writable; CLR bit is write-0-to-clear, write-1-ignore= d */ s->cntp_aival_ctl &=3D ~R_CNTP_AIVAL_CTL_EN_MASK; s->cntp_aival_ctl |=3D value & R_CNTP_AIVAL_CTL_EN_MASK; if (!(value & R_CNTP_AIVAL_CTL_CLR_MASK)) { diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index f5b35cd55f0..2f806512d0a 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -118,7 +118,7 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *m= em_buf, int n) /* * Don't allow writing to XPSR.Exception as it can cause * a transition into or out of handler mode (it's not - * writeable via the MSR insn so this is a reasonable + * writable via the MSR insn so this is a reasonable * restriction). Other fields are safe to update. */ xpsr_write(env, tmp, ~XPSR_EXCP); diff --git a/target/arm/helper.c b/target/arm/helper.c index 7f2c14bea94..5727ead5e4c 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -1411,8 +1411,8 @@ static void pmcr_write(CPUARMState *env, const ARMCPR= egInfo *ri, } } =20 - env->cp15.c9_pmcr &=3D ~PMCR_WRITEABLE_MASK; - env->cp15.c9_pmcr |=3D (value & PMCR_WRITEABLE_MASK); + env->cp15.c9_pmcr &=3D ~PMCR_WRITABLE_MASK; + env->cp15.c9_pmcr |=3D (value & PMCR_WRITABLE_MASK); =20 pmu_op_finish(env); } diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 1fdc5eef92b..060aa0ccf4b 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -978,8 +978,8 @@ static int hvf_sysreg_write(CPUState *cpu, uint32_t reg= , uint64_t val) } } =20 - env->cp15.c9_pmcr &=3D ~PMCR_WRITEABLE_MASK; - env->cp15.c9_pmcr |=3D (val & PMCR_WRITEABLE_MASK); + env->cp15.c9_pmcr &=3D ~PMCR_WRITABLE_MASK; + env->cp15.c9_pmcr |=3D (val & PMCR_WRITABLE_MASK); =20 pmu_op_finish(env); break; diff --git a/target/i386/cpu-sysemu.c b/target/i386/cpu-sysemu.c index e254d8ba10f..a6f47b7d114 100644 --- a/target/i386/cpu-sysemu.c +++ b/target/i386/cpu-sysemu.c @@ -103,7 +103,7 @@ static void x86_cpu_to_dict(X86CPU *cpu, QDict *props) =20 /* Convert CPU model data from X86CPU object to a property dictionary * that can recreate exactly the same CPU model, including every - * writeable QOM property. + * writable QOM property. */ static void x86_cpu_to_dict_full(X86CPU *cpu, QDict *props) { diff --git a/target/s390x/ioinst.c b/target/s390x/ioinst.c index bdae5090bc8..b12f18d346f 100644 --- a/target/s390x/ioinst.c +++ b/target/s390x/ioinst.c @@ -284,7 +284,7 @@ void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, u= int32_t ipb, g_assert(!s390_is_pv()); /* * As operand exceptions have a lower priority than access excepti= ons, - * we check whether the memory area is writeable (injecting the + * we check whether the memory area is writable (injecting the * access execption if it is not) first. */ if (!s390_cpu_virt_mem_check_write(cpu, addr, ar, sizeof(schib))) { diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index 07ac5a710be..37191f433b2 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -495,7 +495,7 @@ def _early_cleanup(self) -> None: """ # If we keep the console socket open, we may deadlock waiting # for QEMU to exit, while QEMU is waiting for the socket to - # become writeable. + # become writable. if self._console_socket is not None: self._console_socket.close() self._console_socket =3D None diff --git a/tests/tcg/x86_64/system/boot.S b/tests/tcg/x86_64/system/boot.S index f8a2fcc8395..ed0f638406b 100644 --- a/tests/tcg/x86_64/system/boot.S +++ b/tests/tcg/x86_64/system/boot.S @@ -56,7 +56,7 @@ * * - `ebx`: contains the physical memory address where the loader has plac= ed * the boot start info structure. - * - `cr0`: bit 0 (PE) must be set. All the other writeable bits are clear= ed. + * - `cr0`: bit 0 (PE) must be set. All the other writable bits are cleare= d. * - `cr4`: all bits are cleared. * - `cs `: must be a 32-bit read/execute code segment with a base of =E2= =80=980=E2=80=99 * and a limit of =E2=80=980xFFFFFFFF=E2=80=99. The selector valu= e is unspecified. --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654766657; cv=none; d=zohomail.com; s=zohoarc; b=AXhcpxOMjV8UzrLDgdodF87ejH8KazQ5mUwJn8A/r7UMYSfAZ4CRWGDla5VIPHhl8nnptV2MbeVROYlUnzFKOzJNXSJQJOYjlxiOkprefxvLj3KlYw0C92+iWI5APTcqazEqBAh+gp1xCGi7Bwrds6bBz0G8T4fBJkXDQbc6ajc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654766657; 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=+dO1GyIhjcUyBFfxTAYsXe9nSJnuFJi4sDNVk2x8YQE=; b=KeuBBDINV1Nr8r6Wcr+60zf/rQcdXw6rDvbHwsbP1SXgjML6B5VYNS8b9TTnxSA6d8WHW/exUo+jHmaOtXleFTylVmazdxuXRYcCXSZ0kcF3TtTVeghKNT9KI9hSeZRGK/o7BTITWsKd0qGITR+tmfvgK0Y/7/2husS91uJZK8Y= 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 1654766657971584.9272555014945; Thu, 9 Jun 2022 02:24:17 -0700 (PDT) Received: from localhost ([::1]:38004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzEOm-0003QW-Ap for importer@patchew.org; Thu, 09 Jun 2022 05:24:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE6u-0001Oi-Mg for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:49 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:40587) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE6s-0005wl-7s for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:48 -0400 Received: by mail-wr1-x436.google.com with SMTP id k16so31477811wrg.7 for ; Thu, 09 Jun 2022 02:05:45 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.05.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:05:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=+dO1GyIhjcUyBFfxTAYsXe9nSJnuFJi4sDNVk2x8YQE=; b=Frz2q1B/v2Oee7pz8TnO3n+7PUIVXhv2dUiRVEAKnrP6jDCaSphne0ycihroILnOBu tnvYlitbRS9xJxyx8rxYJBz4BJt5tGFb+yLnyiwMM/2bMABOZXrNbgLOmOsevOgD5wh9 qN5Qy+NtWuZS7OZZoOHueYL3cG61PRBe+Pn2svo8hYEX5aIIZRLCt5NBBmnY2e2VrYpA yeceSNTugCXcSRKMkp82ABVb0tS27bDRIC5o0pyLzKgIAHiLuqeXV6OumCa8dFx0XJYa B/PTtD/Mm4LFMjjMz/GGNwS0G1R8aIFknZ2x50DwBCb1/Bw4i6cZ7rXHROirA2nvO58x UWYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+dO1GyIhjcUyBFfxTAYsXe9nSJnuFJi4sDNVk2x8YQE=; b=4LESYi/OmcNZbZRc6XbnRLy2jLYrmdxildHlEPCOq/7OK6Mvpjb146d4Zgl8Rx+27n yh1u1JnnbcYWsHv0PDSpZdMuCpayyxgP1U/PzZYAgBgjo/BCccq8f1qa/m4UuLj0+Fw/ H8vbVkNddDe/Asog2/PRFCudFj7ej7994Z3csc7FOjzCOdBmQOdtDdh4l9kBukJmV1hd tGl6n8rp2lrYNoOg13uez8Cg/IAgltca6RMfKSGfa9ZM0v3PrFZ8Eav/5hBIxWlhAqDK GOp7VXGvba2SP4ZzDJQc+s99gffkhPjqSI6lPeYzFeRuujdtcS/EPMZdrchcvMBF/iCW G4Fw== X-Gm-Message-State: AOAM5313WkFVeDY0/HF8oX+r3Yzw1tJuzPVw8FEWPGhRO43i/k3qo6/j fcnG+t6IfsGX7BUtMoh3c0HMF4MJ2OSmIQ== X-Google-Smtp-Source: ABdhPJxTcfvx/9dm6X0xdZ1zAUwfjcqwYKs5/xeFo6m2/7/8tKvTMp+hF50vrFKQr184ODNDPn6tvg== X-Received: by 2002:adf:f90f:0:b0:20e:5fd4:5d06 with SMTP id b15-20020adff90f000000b0020e5fd45d06mr37549172wrr.371.1654765544711; Thu, 09 Jun 2022 02:05:44 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 04/55] xlnx_dp: fix the wrong register size Date: Thu, 9 Jun 2022 10:04:46 +0100 Message-Id: <20220609090537.1971756-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::436; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x436.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654766658416100003 Content-Type: text/plain; charset="utf-8" From: Frederic Konrad The core and the vblend registers size are wrong, they should respectively = be 0x3B0 and 0x1E0 according to: https://www.xilinx.com/htmldocs/registers/ug1087/ug1087-zynq-ultrascale-r= egisters.html. Let's fix that and use macros when creating the mmio region. Fixes: 58ac482a66d ("introduce xlnx-dp") Signed-off-by: Frederic Konrad Reviewed-by: Edgar E. Iglesias Acked-by: Alistair Francis Message-id: 20220601172353.3220232-2-fkonrad@xilinx.com Signed-off-by: Peter Maydell --- include/hw/display/xlnx_dp.h | 9 +++++++-- hw/display/xlnx_dp.c | 17 ++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/include/hw/display/xlnx_dp.h b/include/hw/display/xlnx_dp.h index 8ab4733bb85..1ef5a89ee74 100644 --- a/include/hw/display/xlnx_dp.h +++ b/include/hw/display/xlnx_dp.h @@ -39,10 +39,15 @@ #define AUD_CHBUF_MAX_DEPTH (32 * KiB) #define MAX_QEMU_BUFFER_SIZE (4 * KiB) =20 -#define DP_CORE_REG_ARRAY_SIZE (0x3AF >> 2) +#define DP_CORE_REG_OFFSET (0x0000) +#define DP_CORE_REG_ARRAY_SIZE (0x3B0 >> 2) +#define DP_AVBUF_REG_OFFSET (0xB000) #define DP_AVBUF_REG_ARRAY_SIZE (0x238 >> 2) -#define DP_VBLEND_REG_ARRAY_SIZE (0x1DF >> 2) +#define DP_VBLEND_REG_OFFSET (0xA000) +#define DP_VBLEND_REG_ARRAY_SIZE (0x1E0 >> 2) +#define DP_AUDIO_REG_OFFSET (0xC000) #define DP_AUDIO_REG_ARRAY_SIZE (0x50 >> 2) +#define DP_CONTAINER_SIZE (0xC050) =20 struct PixmanPlane { pixman_format_code_t format; diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c index 9bb781e3125..0378570459d 100644 --- a/hw/display/xlnx_dp.c +++ b/hw/display/xlnx_dp.c @@ -1219,19 +1219,22 @@ static void xlnx_dp_init(Object *obj) SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); XlnxDPState *s =3D XLNX_DP(obj); =20 - memory_region_init(&s->container, obj, TYPE_XLNX_DP, 0xC050); + memory_region_init(&s->container, obj, TYPE_XLNX_DP, DP_CONTAINER_SIZE= ); =20 memory_region_init_io(&s->core_iomem, obj, &dp_ops, s, TYPE_XLNX_DP - ".core", 0x3AF); - memory_region_add_subregion(&s->container, 0x0000, &s->core_iomem); + ".core", sizeof(s->core_registers)); + memory_region_add_subregion(&s->container, DP_CORE_REG_OFFSET, + &s->core_iomem); =20 memory_region_init_io(&s->vblend_iomem, obj, &vblend_ops, s, TYPE_XLNX= _DP - ".v_blend", 0x1DF); - memory_region_add_subregion(&s->container, 0xA000, &s->vblend_iomem); + ".v_blend", sizeof(s->vblend_registers)); + memory_region_add_subregion(&s->container, DP_VBLEND_REG_OFFSET, + &s->vblend_iomem); =20 memory_region_init_io(&s->avbufm_iomem, obj, &avbufm_ops, s, TYPE_XLNX= _DP - ".av_buffer_manager", 0x238); - memory_region_add_subregion(&s->container, 0xB000, &s->avbufm_iomem); + ".av_buffer_manager", sizeof(s->avbufm_registers= )); + memory_region_add_subregion(&s->container, DP_AVBUF_REG_OFFSET, + &s->avbufm_iomem); =20 memory_region_init_io(&s->audio_iomem, obj, &audio_ops, s, TYPE_XLNX_DP ".audio", sizeof(s->audio_registers)); --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654766287; cv=none; d=zohomail.com; s=zohoarc; b=TcVJ36EGZtvLud6grUH8EV+6Ag02I3ysEIQ+KOPdu/WW55TIv7+aikmcompgxctcrQuVzsEqHcuPLjj+YRaqcPd4lCnjIIZ4jNmwTPKg/9uk5R++kwo6oxOEvI0KlA7nj4QNytDYeZ6GzPxvcHUnxt96BgUDy6W3MGSVf2ivG4Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654766287; 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=815PqLyO6+Q2xJdxQZlA76V7TTOTcj2SZ6F7/EiLTo0=; b=jEbd35xMIgJuRgGHZkjraJQCny3BYVsMW0bwlwq8otmXdK4nz2XmP+F+4FAKET1YGPzX5LiPPH1eHOmTCcYoxpo+FD8QDeup9r+NpRkK8iIosflERqaqKUvpQelhsTxRVCnxEccYyaZXkRS4xay3p3368THTFShN8AHZJnyx7OM= 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 1654766287523242.3827244829622; Thu, 9 Jun 2022 02:18:07 -0700 (PDT) Received: from localhost ([::1]:59602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzEIn-00078E-Sd for importer@patchew.org; Thu, 09 Jun 2022 05:18:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39222) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE6v-0001Ov-5P for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:50 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:46819) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE6t-0005xd-8W for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:48 -0400 Received: by mail-wr1-x435.google.com with SMTP id u8so27137707wrm.13 for ; Thu, 09 Jun 2022 02:05:46 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.05.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:05:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=815PqLyO6+Q2xJdxQZlA76V7TTOTcj2SZ6F7/EiLTo0=; b=zhjXtb+TnQRYQTfulh//qntXvpj6PXAqQQ2mn31XIawjv9WtorBmvM5GQFk3d0HTFI lah41ldMiLnJBAf42J7toiOBxje0NiRGKvgWmCgaP0+vZnoiGOu0A1j3tCOaW1DZ6Zlu bAoK0VjfPCGiYtPyG35jWUrrs4kufWN2nBzZyTXwFi62k6MLWA69pU/cwORT8S18ArjC mY0Vk0Oj52hvsc0CaDioKutP+25wr1sqfcoKYjduZkIRuGS9qm5NOXLhQQ6PES3yWLbs 108P+8VwvAzjwyBFMmor0jy5B+a3Eeboq1oDTxGUmL2G/2yV5wCS3r3gB8MyZaetMn5S oX7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=815PqLyO6+Q2xJdxQZlA76V7TTOTcj2SZ6F7/EiLTo0=; b=duFyBLNzIogCoaaWnVoqVmhlgyhtBhy74CL/PfyH8bQVGACc7XSLx+tvgLkYb9HZFj 1+Cv4pyjIjaX6uOU5WM/pU1GvKhURRNc0iEZLDFXenlCbqWJvCfMOiwM3FIDfn4UpbOI Rqu7hViM5dOM2rRJG4cMqRsQAKG7hLrRFcQ9WQmy2C2sJfjkTF5eCuAbVRNHAve4AzTw QqopOlramslBz9f82/nvjduuLsyCthBw+JzVvzvCytZGQBcCHtVWykN/dgaIPZFBpl67 dvmQfhJceALBy2/WvBcqehcQqJKklcPrOBknNFqSAgTC81eshgJEjzxAA5udgaLXmsVE 6wOw== X-Gm-Message-State: AOAM532jd3KpjEcYQ8mLdijmlogrFfHVZrx6DZmltcAggYTQBDvK/HJC CHfR8yslN6/9tIHHY+rIvKbsAJrdJwibvA== X-Google-Smtp-Source: ABdhPJyqh8wPZ2i6KtAjNeG0lAaJg173vR95N380obJrfkhR06UKpPwoE9aK7AaUwaik6fWo9dxCJg== X-Received: by 2002:a5d:59a6:0:b0:218:49ff:2712 with SMTP id p6-20020a5d59a6000000b0021849ff2712mr16631531wrr.106.1654765545792; Thu, 09 Jun 2022 02:05:45 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 05/55] xlnx_dp: Introduce a vblank signal Date: Thu, 9 Jun 2022 10:04:47 +0100 Message-Id: <20220609090537.1971756-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654766289317100001 Content-Type: text/plain; charset="utf-8" From: Sai Pavan Boddu Add a periodic timer which raises vblank at a frequency of 30Hz. Note that this is a migration compatibility break for the xlnx-zcu102 board type. Signed-off-by: Sai Pavan Boddu Signed-off-by: Edgar E. Iglesias Signed-off-by: Frederic Konrad Acked-by: Alistair Francis Message-id: 20220601172353.3220232-3-fkonrad@xilinx.com Changes by fkonrad: - Switched to transaction-based ptimer API. - Added the DP_INT_VBLNK_START macro. Signed-off-by: Frederic Konrad [PMM: bump vmstate version, add commit message note about compat break] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- include/hw/display/xlnx_dp.h | 3 +++ hw/display/xlnx_dp.c | 30 ++++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/include/hw/display/xlnx_dp.h b/include/hw/display/xlnx_dp.h index 1ef5a89ee74..e86a87f235e 100644 --- a/include/hw/display/xlnx_dp.h +++ b/include/hw/display/xlnx_dp.h @@ -35,6 +35,7 @@ #include "hw/dma/xlnx_dpdma.h" #include "audio/audio.h" #include "qom/object.h" +#include "hw/ptimer.h" =20 #define AUD_CHBUF_MAX_DEPTH (32 * KiB) #define MAX_QEMU_BUFFER_SIZE (4 * KiB) @@ -107,6 +108,8 @@ struct XlnxDPState { */ DPCDState *dpcd; I2CDDCState *edid; + + ptimer_state *vblank; }; =20 #define TYPE_XLNX_DP "xlnx.v-dp" diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c index 0378570459d..ed856b596da 100644 --- a/hw/display/xlnx_dp.c +++ b/hw/display/xlnx_dp.c @@ -114,6 +114,7 @@ #define DP_TX_N_AUD (0x032C >> 2) #define DP_TX_AUDIO_EXT_DATA(n) ((0x0330 + 4 * n) >> 2) #define DP_INT_STATUS (0x03A0 >> 2) +#define DP_INT_VBLNK_START (1 << 13) #define DP_INT_MASK (0x03A4 >> 2) #define DP_INT_EN (0x03A8 >> 2) #define DP_INT_DS (0x03AC >> 2) @@ -260,7 +261,7 @@ typedef enum DPVideoFmt DPVideoFmt; =20 static const VMStateDescription vmstate_dp =3D { .name =3D TYPE_XLNX_DP, - .version_id =3D 1, + .version_id =3D 2, .fields =3D (VMStateField[]){ VMSTATE_UINT32_ARRAY(core_registers, XlnxDPState, DP_CORE_REG_ARRAY_SIZE), @@ -270,10 +271,15 @@ static const VMStateDescription vmstate_dp =3D { DP_VBLEND_REG_ARRAY_SIZE), VMSTATE_UINT32_ARRAY(audio_registers, XlnxDPState, DP_AUDIO_REG_ARRAY_SIZE), + VMSTATE_PTIMER(vblank, XlnxDPState), VMSTATE_END_OF_LIST() } }; =20 +#define DP_VBLANK_PTIMER_POLICY (PTIMER_POLICY_WRAP_AFTER_ONE_PERIOD | \ + PTIMER_POLICY_CONTINUOUS_TRIGGER | \ + PTIMER_POLICY_NO_IMMEDIATE_TRIGGER) + static void xlnx_dp_update_irq(XlnxDPState *s); =20 static uint64_t xlnx_dp_audio_read(void *opaque, hwaddr offset, unsigned s= ize) @@ -773,6 +779,13 @@ static void xlnx_dp_write(void *opaque, hwaddr offset,= uint64_t value, break; case DP_TRANSMITTER_ENABLE: s->core_registers[offset] =3D value & 0x01; + ptimer_transaction_begin(s->vblank); + if (value & 0x1) { + ptimer_run(s->vblank, 0); + } else { + ptimer_stop(s->vblank); + } + ptimer_transaction_commit(s->vblank); break; case DP_FORCE_SCRAMBLER_RESET: /* @@ -1177,9 +1190,6 @@ static void xlnx_dp_update_display(void *opaque) return; } =20 - s->core_registers[DP_INT_STATUS] |=3D (1 << 13); - xlnx_dp_update_irq(s); - xlnx_dpdma_trigger_vsync_irq(s->dpdma); =20 /* @@ -1275,6 +1285,14 @@ static void xlnx_dp_finalize(Object *obj) fifo8_destroy(&s->rx_fifo); } =20 +static void vblank_hit(void *opaque) +{ + XlnxDPState *s =3D XLNX_DP(opaque); + + s->core_registers[DP_INT_STATUS] |=3D DP_INT_VBLNK_START; + xlnx_dp_update_irq(s); +} + static void xlnx_dp_realize(DeviceState *dev, Error **errp) { XlnxDPState *s =3D XLNX_DP(dev); @@ -1309,6 +1327,10 @@ static void xlnx_dp_realize(DeviceState *dev, Error = **errp) &as); AUD_set_volume_out(s->amixer_output_stream, 0, 255, 255); xlnx_dp_audio_activate(s); + s->vblank =3D ptimer_init(vblank_hit, s, DP_VBLANK_PTIMER_POLICY); + ptimer_transaction_begin(s->vblank); + ptimer_set_freq(s->vblank, 30); + ptimer_transaction_commit(s->vblank); } =20 static void xlnx_dp_reset(DeviceState *dev) --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654766969; cv=none; d=zohomail.com; s=zohoarc; b=esk1HOWD/Rc9Am4pHCWTwByvpinbQCZxRsOjkJBoxZvRjaVcmIHInHEEeJ1eNWf8bBjlzEz8SlvKyaDCYF/rEIRqmixPUvZCHVsJop8eTgIFI4nA994jc74S10SfCHNxBU9tReAIwt/KbqWcAPbTkS6y5mOpkHhAviUWZUluXNM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654766969; 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=v6Qr9bE25ltpawAcQgSfkzrSpXI1MycLCG8XufyC2js=; b=mjQg7SUCuAvw8hiZ7hGIzLRoDA/iLzxAsDUpGprbwUjYbrDO+5Vd4bar/5Q/5M80akQF742EJ4IDMZtLvomtqjnPUI2xo5V5eUr98d6j6MXKWMXogS+79/39Pt/6KF1HnI1cS1hKOwln2dNXOFyG+EA54tuTQ/b+jf+4XW72HPg= 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 1654766969851953.9250408681019; Thu, 9 Jun 2022 02:29:29 -0700 (PDT) Received: from localhost ([::1]:46522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzETo-00010R-Ln for importer@patchew.org; Thu, 09 Jun 2022 05:29:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE6w-0001P2-17 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:50 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:35634) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE6u-0005y0-1E for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:49 -0400 Received: by mail-wr1-x435.google.com with SMTP id a15so22952820wrh.2 for ; Thu, 09 Jun 2022 02:05:47 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.05.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=v6Qr9bE25ltpawAcQgSfkzrSpXI1MycLCG8XufyC2js=; b=bKA17z9ZQuuNoWzip2SlJ844IpZsf7Gb7WyDu2G8duXJxRa39m9YZpaDdkXr88xfpq atdfYK9AUTa1HRrK2IUb8jHK5yb/9+lu2XL9rNsRJshwdvyjiC/CzQzjwiKpqFR2nPFa bo/ngXemLA17moqfZ4GaJTcRK1aXA6qzE0IdHbJmfHKb/iB71sbeLjPLuPPiAyW9Gt8i OSgVRZxkTWCKSzqrh7qOrLWDjoh46Qn2Jdvopi5k38ceNrdNt81b3b56p2G5PGy5QUKl QxPTM72k1phA8vw+seTTC5AV772uMQZjeWDXlK6f+yehzOEuETcMT0vDH9FoQEF7DHQH ZpOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v6Qr9bE25ltpawAcQgSfkzrSpXI1MycLCG8XufyC2js=; b=DTc0/uVEiZQRyaVmMk4diVgpo5cdmXUFLhWJrMf5AEXdTOSKqLoTUnzal+rViSSpxK GuTQu20UfoJ40a6qDRmbppRXSxR9buLN81A7Gw2Yln5KTXdngLVFAgjzymRbhiB5AlXh /rfDtpka3L01kWA3J7xfbJlzcknsoWNxescNk1+Y8UEEjULxmhZQNzXf5NJON4jNE066 p+TYgO0lbzaRfec5Wov5oFIS7Xf5am9zpVUHNTvty9PIreWCwFYZiRGtYNG+g/YBAAq5 uqqE98Tqy6i8KrT6INARLRJgaVpHaFMylNAulBWizZDZ1cbsRuw1TM6z5Yyv8/GPtAbT PTHg== X-Gm-Message-State: AOAM531NuW3LmLFnP11IYLInNVHwvC3XLyfssjJuTpeVSzSxKcnhhjMF N5/HB9gel2kO6GebHf3R/29CASQ6wtQDBg== X-Google-Smtp-Source: ABdhPJwWv0/Eg6nc53WFZoCrjYWlqjsd46B7PRybMAs0DyG+q9pkeuwrrpxOCGXzL2PySxNzQoUaIg== X-Received: by 2002:a05:6000:152:b0:216:160:2e60 with SMTP id r18-20020a056000015200b0021601602e60mr27313060wrx.663.1654765546692; Thu, 09 Jun 2022 02:05:46 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 06/55] xlnx_dp: Fix the interrupt disable logic Date: Thu, 9 Jun 2022 10:04:48 +0100 Message-Id: <20220609090537.1971756-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654766971663100001 Content-Type: text/plain; charset="utf-8" From: Sai Pavan Boddu Fix interrupt disable logic. Mask value 1 indicates that interrupts are disabled. Signed-off-by: Sai Pavan Boddu Reviewed-by: Edgar E. Iglesias Signed-off-by: Frederic Konrad Acked-by: Alistair Francis Message-id: 20220601172353.3220232-4-fkonrad@xilinx.com Signed-off-by: Peter Maydell --- hw/display/xlnx_dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c index ed856b596da..a071c818833 100644 --- a/hw/display/xlnx_dp.c +++ b/hw/display/xlnx_dp.c @@ -889,7 +889,7 @@ static void xlnx_dp_write(void *opaque, hwaddr offset, = uint64_t value, xlnx_dp_update_irq(s); break; case DP_INT_DS: - s->core_registers[DP_INT_MASK] |=3D ~value; + s->core_registers[DP_INT_MASK] |=3D value; xlnx_dp_update_irq(s); break; default: --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654768376; cv=none; d=zohomail.com; s=zohoarc; b=Szyz6+s4aIHMFRvJIswa4OqN+eS2tRqi/3X3Aae3BNVOKeQwcszakKi/nYXh4rI+wob91xUQKVYQvMEijG3Mz+wXTP+cijejObzDg3kXaw1Vh1uRwkCP1V3l02DMqyfMnPPdpqYYXO4dBP5i+sffpPrNUSTJQK6sg/PQQPSs4H8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654768376; 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=PJOPhcXmy6choxCt00mzWvMSiOwf3GdqrbZyGZMGfOM=; b=jUY8IsAQcH1iQOcKBX3r6cirrUPc8V50NyB6rSCmGcIDwnYh+IXEfgRvCJMHSCq9GjXcr9bUw9s7zAXMnXVy4ZutXwwv2iMhEoxzP2IfcZTxTXr1hnsu1SMXRcMg4nQf7TpgkMhLpZcYAIicdK3O+tFQjpZ5QGr2nuJzQs+hTTU= 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 1654768376641707.5025726094448; Thu, 9 Jun 2022 02:52:56 -0700 (PDT) Received: from localhost ([::1]:35810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzEqT-0005gK-Cp for importer@patchew.org; Thu, 09 Jun 2022 05:52:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE6z-0001Rn-Je for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:54 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:38492) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE6u-0005vV-D4 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:53 -0400 Received: by mail-wr1-x430.google.com with SMTP id v14so5217169wra.5 for ; Thu, 09 Jun 2022 02:05:47 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.05.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:05:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=PJOPhcXmy6choxCt00mzWvMSiOwf3GdqrbZyGZMGfOM=; b=BNaNygxBqSsuoPvknhhIgp6zcO0xaKmmL202ENURdiYY/5o9X497A5P6VE2VN7phsg TWu63cfcVsP0OoEWXy9obQOtwwsQmxub+wjeoeaykhNsSf599VZc7cUETPcmV15Cr7Um BgN3LpFGLCKTJJjjf2LdLrOQu0lyvB0XwymiI1i2RKNdCZIw34hfI+pW/KIMG2K3w3xR AE1PgurOVj/S1a9TnUZJOehC6+7HjPu8Cswln9htodD1AteF6dZbAVwF7mwsaxk2+90s hu9jZLSXA7jg4vg/vy3zsN6KG/qjz7KNRbXC14kJxv9V0u4qPqTmiAcskkllPhhAgHuR NZGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PJOPhcXmy6choxCt00mzWvMSiOwf3GdqrbZyGZMGfOM=; b=O7YAh9oD3h1JmjpdKMIme+gtmVRGPQItZNuhMmLuU9OXh5+DVzjxaRvwdrJoNTvL/g PUcZQdk4bDw/JAUW++d03H07QM5BNQGA1YS+nptYjxXNMrf27CDWy1deS4Ec8TDCdHrO +QALoSfSqvQtQeiYoGLuIQloQhH/urMXjGo1XiIOcwSPVneAtpM+0bePw7ZKu0hQE+Ij xIK1q1eYqPAQZRKh2croKPYR8XTEX1oXgrebl74MiQRfz0vUERKifVOFgjuQ5ocS+Xpm lHeWE0hMh2w//6OeCnCywUJpLYIANkHl8xf/TQsYr6zcruLmffJvQ0LtilabxyKsEix8 iScg== X-Gm-Message-State: AOAM533d4/ntD6n0clBy1bYYqkmElCI+JcVw1Y7V/X3Rx+f1yyxjcaDZ m8F0Os+R3dAeTR5957bkiTrx8WJGdRG3Mw== X-Google-Smtp-Source: ABdhPJyOKZCVDU8vMFrWi9NK+oD8FrqdeETN/G+W8U36h8ALRp8WJm2YqWWTbOJkyqQTzXYpWY2QIw== X-Received: by 2002:adf:ed82:0:b0:213:1315:1dbb with SMTP id c2-20020adfed82000000b0021313151dbbmr35315784wro.484.1654765547694; Thu, 09 Jun 2022 02:05:47 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 07/55] xlnx-zynqmp: fix the irq mapping for the display port and its dma Date: Thu, 9 Jun 2022 10:04:49 +0100 Message-Id: <20220609090537.1971756-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::430; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x430.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654768377912100001 Content-Type: text/plain; charset="utf-8" From: Frederic Konrad When the display port has been initially implemented the device driver wasn't using interrupts. Now that the display port driver waits for vblank interrupt it has been noticed that the irq mapping is wrong. So use the value from the linux device tree and the ultrascale+ reference manual. Signed-off-by: Frederic Konrad Reviewed-by: Edgar E. Iglesias Acked-by: Alistair Francis Message-id: 20220601172353.3220232-5-fkonrad@xilinx.com [PMM: refold lines in commit message] Signed-off-by: Peter Maydell --- hw/arm/xlnx-zynqmp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c index 375309e68eb..383e177a001 100644 --- a/hw/arm/xlnx-zynqmp.c +++ b/hw/arm/xlnx-zynqmp.c @@ -60,10 +60,10 @@ #define SERDES_SIZE 0x20000 =20 #define DP_ADDR 0xfd4a0000 -#define DP_IRQ 113 +#define DP_IRQ 0x77 =20 #define DPDMA_ADDR 0xfd4c0000 -#define DPDMA_IRQ 116 +#define DPDMA_IRQ 0x7a =20 #define APU_ADDR 0xfd5c0000 #define APU_IRQ 153 --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654767642; cv=none; d=zohomail.com; s=zohoarc; b=Be5KaM3xKx3WHCLoXHRe5qLsnqdZ9ZPL3gg+mBqu0i5o1Wgq71K1ZTyS9o9wxoxKoRU7gvtoskpb5cFjn2fTrbhqpfKzhkRStDUsZ6rn4tAfJmm+pu9oFiIKWkr3l4dkB7d4y12E84OQpblVxrSx/FDGxMmQHoPYLHrc2UV2SVk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654767642; 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=9eBXb6ngArhkEwA5Ae/7R9RnXAQ3z1Rjo8kM5NbQegY=; b=WCa4CatzdQyG/mKkETUiGG0E8+qAo6pneZQX/u99EgxeZyasXfmLMVpZByX2ruM4/fCRq5yGRmra0tUg3bhJXH19FpEfSx8TnoTxA6zTjxbXq6YTGDPQQo0fcOPzUxPNY+h0PCX5EOTMl1dudtNqeaJNFZn1hewyDN6EqQH61Z0= 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 1654767642405456.16946244983444; Thu, 9 Jun 2022 02:40:42 -0700 (PDT) Received: from localhost ([::1]:55248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzEef-0007VX-8n for importer@patchew.org; Thu, 09 Jun 2022 05:40:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE6y-0001QL-2U for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:53 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:34742) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE6w-0005zr-0x for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:51 -0400 Received: by mail-wr1-x42b.google.com with SMTP id q26so21096176wra.1 for ; Thu, 09 Jun 2022 02:05:49 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.05.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:05:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9eBXb6ngArhkEwA5Ae/7R9RnXAQ3z1Rjo8kM5NbQegY=; b=H9lQwEXwCP30cwktaIsUzRorw2Il2qxYXPUFGwblgwdk3dj+PSElrU8nCdlgKx23u+ Os9SQ7N5bDfzMldoJvFeSQBg8MolOg/Ny6pbCado5/9+X1D/TZbSUJMgn9KmtKJbX1x7 w0L6itWjyf2Ghwy+ATluvPas7KgpvVaKFMevEQlIy5CCjq1IaMrAMSNMyedMOhn1GpgF 35Lx72No5uoKGCiPAN0Rw29lIThS199FbGL6G4TydYLB/SLy3B8UCQr/dt14MuFPcUN6 eSmErW4O1AdNN67B3yzn8GOtp4+JVx76pYXSJEw3ve90HA66t/mcSelm0swX6nDZuTCc 6N2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9eBXb6ngArhkEwA5Ae/7R9RnXAQ3z1Rjo8kM5NbQegY=; b=lLWtyfs0/7cOAbBgbdhk6vqYJf2X7bT25pbMXrJju01c8kjQjIa7tUMSzSKOC1kEFx 2rQuNLlm2sGVJBNqDDFS/+Bw1dBiMfOg6kZVv1eF/wLQv5Z1+NTOQ2OarBk/0lpT7FJO Z0z+RKIphAo4jbk6GC9AlnOv4Hoqn1E/OA24sH6jAGxvzmxTt69vZYdP0Ewh+fgkfv4E f82rnbKWGGF4yhLFlJLZzACg6Zw20d5oLIW5CR2bXTp7rRS812Ziqs81Hd2Whdt8DlXc OAIm0cSkyrG2Dig/K545huveAtdwidm32jm4hucAxjyOe+8SzyKwC8C6PVH1X+Q3sgZi O++A== X-Gm-Message-State: AOAM531sCOoYeMFfvJTHGYJmHv1O0xe6KK0z6SRpHnak4WpUXrueqm/t 4k4T52Ndf3Q7Tg/6uVLKBgdhbC1ObXuKvw== X-Google-Smtp-Source: ABdhPJxAJ2TB2MyEP0/j4Xhs2VUZUZV0P1Sf4zQTsc0yJ2RsoDNUdfPmQcnLpqgMjXK2vOTWjJYUew== X-Received: by 2002:a5d:67c2:0:b0:215:7a0f:71f9 with SMTP id n2-20020a5d67c2000000b002157a0f71f9mr30971956wrw.486.1654765548590; Thu, 09 Jun 2022 02:05:48 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 08/55] target/arm: Move stage_1_mmu_idx decl to internals.h Date: Thu, 9 Jun 2022 10:04:50 +0100 Message-Id: <20220609090537.1971756-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::42b; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42b.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654767643513100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Move the decl from ptw.h to internals.h. Provide an inline version for user-only, just as we do for arm_stage1_mmu_idx. Move an endif down to make the definition in helper.c be system only. Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-2-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/internals.h | 5 +++++ target/arm/helper.c | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 1e4887b2dd3..049edce946c 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -979,11 +979,16 @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env); * Return the ARMMMUIdx for the stage1 traversal for the current regime. */ #ifdef CONFIG_USER_ONLY +static inline ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) +{ + return ARMMMUIdx_Stage1_E0; +} static inline ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) { return ARMMMUIdx_Stage1_E0; } #else +ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx); ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env); #endif =20 diff --git a/target/arm/helper.c b/target/arm/helper.c index 5727ead5e4c..829b660db92 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10517,12 +10517,10 @@ static inline uint64_t regime_ttbr(CPUARMState *e= nv, ARMMMUIdx mmu_idx, } } =20 -#endif /* !CONFIG_USER_ONLY */ - /* Convert a possible stage1+2 MMU index into the appropriate * stage 1 MMU index */ -static inline ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) +ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) { switch (mmu_idx) { case ARMMMUIdx_SE10_0: @@ -10541,6 +10539,7 @@ static inline ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx m= mu_idx) return mmu_idx; } } +#endif /* !CONFIG_USER_ONLY */ =20 /* Return true if the translation regime is using LPAE format page tables = */ static inline bool regime_using_lpae_format(CPUARMState *env, --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654768719; cv=none; d=zohomail.com; s=zohoarc; b=fOXSi9desgKJI8SIhFCohaOJglLaGMVTlJOQX1Z/HOcOr1Le+OlUOW64pTkfK9TT7iYP0dBbFHE/CBuYs8YEdaC31USQTYBXQuru3DCKShSEFo7+/2HhPLd9hEFoib7UFMbecX03jnfuTUtsz1L15RpCHziyJ8cwNl2P2EaXUzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654768719; 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=hc5zkvCsi6gg6RtC6i+txFH2JRDjXFdVtwnnnFfRk5Y=; b=cqpnBPEdB81WCijV0Cyy+EsJARCmC+5f9IaZoWO5epv8gKZOYA9TcPgZpxp/7OqFWYsTzY6VpGVgbI8lPzJd5xFRvweDs+qmIH5TmwWWknRIQTp0dieWe1GWgRb8Sp67VG3y82sW2037AoOqf5p9sDhlEiPxb1FFtMxIB+VcmdM= 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 1654768719381168.00548140835383; Thu, 9 Jun 2022 02:58:39 -0700 (PDT) Received: from localhost ([::1]:45112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzEw1-0003m5-Pq for importer@patchew.org; Thu, 09 Jun 2022 05:58:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE71-0001TV-AJ for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:55 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:40587) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE6x-0005wl-R3 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:55 -0400 Received: by mail-wr1-x436.google.com with SMTP id k16so31477811wrg.7 for ; Thu, 09 Jun 2022 02:05:50 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.05.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:05:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=hc5zkvCsi6gg6RtC6i+txFH2JRDjXFdVtwnnnFfRk5Y=; b=baAdG3ycirS9ozBNAcguePoPK+4apMDZ9WHZkHthEKipv9a73/Z3BWfsJHFh07Bvo/ rBFcvaKn5x0vOXIZ+F8O5yFkNV1EboizS3PHIm4AdJj1YOlgfga9/K31YFiuapxiGIrK rOMKM4jm/xRTiKFqdVbWev4Jb9Zel5yoQV/8YPfWAIm066L6TvU03dFTauIjjIZC3Jy5 gRGYGWFcng84FuWUG9M2ntTd5NOkqYLgMmnDVoBpgNV0QUKOK5JxZv2gB9LRvRUxZDjg HNADpRNRItqqN1XObU0wXMyetK3jIJ3nJ9YlhW3CLbO6z99AzPcGX1sbIBBqf79F+q1Z nGsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hc5zkvCsi6gg6RtC6i+txFH2JRDjXFdVtwnnnFfRk5Y=; b=qd6lmkx/83I/01CklAQ7yVgoXXDXY8gnYOPI66AshmqQukba+r0rY37YmGrsvI0HJS 4QHMBd5CWmr9+P7WNW126mxcaIqdjxtMbqdg8itCmOQ1Os4NjXVGGUhHSFvXnvW2F8c+ 7uHqBzwkOA275tjP3eYbLy/bDQJ3nhj6j1+Dv2T/sz9eXF6Qfcx7XQnsYLrgaXmRmjse mWoGx94vSocU2DVpOxf9wgTsa1QbRdF7cWYRzQIobc9x1ayMxG5/gka51wOx2H2Fj35L JGYAYtSLTQEqoxhkyca2a46F30nY+FLFYzc/8tUd+GLYEXxjGV2M2nlICNxtUlCOvyGt T/Xg== X-Gm-Message-State: AOAM531imTqL5+dbtAkvh+jx6YAoDtlky5+ytPTXA7irDNLXOySYU20J 5lKtAnk6leITyL7406s6KMHiOGfbVCrDGg== X-Google-Smtp-Source: ABdhPJxTy0Gl8uIFJ4DlpB8kxBjO/jL00MAdig58l9YoK6h5jPUSe2G8XdFKhfK9GBbU5/swLS7FCw== X-Received: by 2002:adf:f90f:0:b0:20e:5fd4:5d06 with SMTP id b15-20020adff90f000000b0020e5fd45d06mr37549597wrr.371.1654765549972; Thu, 09 Jun 2022 02:05:49 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 09/55] target/arm: Move get_phys_addr to ptw.c Date: Thu, 9 Jun 2022 10:04:51 +0100 Message-Id: <20220609090537.1971756-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::436; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x436.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654768719931100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Begin moving all of the page table walking functions out of helper.c, starting with get_phys_addr(). Create a temporary header file, "ptw.h", in which to share declarations between the two C files while we are moving functions. Move a few declarations to "internals.h", which will remain used by multiple C files. Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-3-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/internals.h | 18 ++- target/arm/ptw.h | 51 ++++++ target/arm/helper.c | 344 +++++------------------------------------ target/arm/ptw.c | 267 ++++++++++++++++++++++++++++++++ target/arm/meson.build | 1 + 5 files changed, 372 insertions(+), 309 deletions(-) create mode 100644 target/arm/ptw.h create mode 100644 target/arm/ptw.c diff --git a/target/arm/internals.h b/target/arm/internals.h index 049edce946c..1d83146d565 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -613,8 +613,13 @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARM= State *env, /* Return the MMU index for a v7M CPU in the specified security state */ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate); =20 -/* Return true if the stage 1 translation regime is using LPAE format page - * tables */ +/* Return true if the translation regime is using LPAE format page tables = */ +bool regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx); + +/* + * Return true if the stage 1 translation regime is using LPAE + * format page tables + */ bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx); =20 /* Raise a data fault alignment exception for the specified virtual addres= s */ @@ -777,6 +782,12 @@ static inline uint32_t regime_el(CPUARMState *env, ARM= MMUIdx mmu_idx) } } =20 +/* Return the SCTLR value which controls this address translation regime */ +static inline uint64_t regime_sctlr(CPUARMState *env, ARMMMUIdx mmu_idx) +{ + return env->cp15.sctlr_el[regime_el(env, mmu_idx)]; +} + /* Return the TCR controlling this translation regime */ static inline TCR *regime_tcr(CPUARMState *env, ARMMMUIdx mmu_idx) { @@ -1095,6 +1106,9 @@ typedef struct ARMVAParameters { ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, ARMMMUIdx mmu_idx, bool data); =20 +int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx); +int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx mmu_idx); + static inline int exception_target_el(CPUARMState *env) { int target_el =3D MAX(1, arm_current_el(env)); diff --git a/target/arm/ptw.h b/target/arm/ptw.h new file mode 100644 index 00000000000..e2023ae7508 --- /dev/null +++ b/target/arm/ptw.h @@ -0,0 +1,51 @@ +/* + * ARM page table walking. + * + * This code is licensed under the GNU GPL v2 or later. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef TARGET_ARM_PTW_H +#define TARGET_ARM_PTW_H + +#ifndef CONFIG_USER_ONLY + +bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx); +bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); +ARMCacheAttrs combine_cacheattrs(CPUARMState *env, + ARMCacheAttrs s1, ARMCacheAttrs s2); + +bool get_phys_addr_v5(CPUARMState *env, uint32_t address, + MMUAccessType access_type, ARMMMUIdx mmu_idx, + hwaddr *phys_ptr, int *prot, + target_ulong *page_size, + ARMMMUFaultInfo *fi); +bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, + MMUAccessType access_type, ARMMMUIdx mmu_idx, + hwaddr *phys_ptr, int *prot, + ARMMMUFaultInfo *fi); +bool get_phys_addr_v6(CPUARMState *env, uint32_t address, + MMUAccessType access_type, ARMMMUIdx mmu_idx, + hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, + target_ulong *page_size, ARMMMUFaultInfo *fi); +bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, + MMUAccessType access_type, ARMMMUIdx mmu_idx, + hwaddr *phys_ptr, int *prot, + target_ulong *page_size, + ARMMMUFaultInfo *fi); +bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, + MMUAccessType access_type, ARMMMUIdx mmu_idx, + hwaddr *phys_ptr, MemTxAttrs *txattrs, + int *prot, target_ulong *page_size, + ARMMMUFaultInfo *fi); +bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, + MMUAccessType access_type, ARMMMUIdx mmu_idx, + bool s1_is_el0, + hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, + target_ulong *page_size_ptr, + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) + __attribute__((nonnull)); + +#endif /* !CONFIG_USER_ONLY */ +#endif /* TARGET_ARM_PTW_H */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 829b660db92..3ffd122178d 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -37,22 +37,11 @@ #include "semihosting/common-semi.h" #endif #include "cpregs.h" +#include "ptw.h" =20 #define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */ =20 -#ifndef CONFIG_USER_ONLY - -static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, - MMUAccessType access_type, ARMMMUIdx mmu_id= x, - bool s1_is_el0, - hwaddr *phys_ptr, MemTxAttrs *txattrs, int = *prot, - target_ulong *page_size_ptr, - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheat= trs) - __attribute__((nonnull)); -#endif - static void switch_mode(CPUARMState *env, int mode); -static int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx); =20 static uint64_t raw_read(CPUARMState *env, const ARMCPRegInfo *ri) { @@ -10440,17 +10429,10 @@ uint64_t arm_sctlr(CPUARMState *env, int el) return env->cp15.sctlr_el[el]; } =20 -/* Return the SCTLR value which controls this address translation regime */ -static inline uint64_t regime_sctlr(CPUARMState *env, ARMMMUIdx mmu_idx) -{ - return env->cp15.sctlr_el[regime_el(env, mmu_idx)]; -} - #ifndef CONFIG_USER_ONLY =20 /* Return true if the specified stage of address translation is disabled */ -static inline bool regime_translation_disabled(CPUARMState *env, - ARMMMUIdx mmu_idx) +bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx) { uint64_t hcr_el2; =20 @@ -10542,8 +10524,7 @@ ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) #endif /* !CONFIG_USER_ONLY */ =20 /* Return true if the translation regime is using LPAE format page tables = */ -static inline bool regime_using_lpae_format(CPUARMState *env, - ARMMMUIdx mmu_idx) +bool regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx) { int el =3D regime_el(env, mmu_idx); if (el =3D=3D 2 || arm_el_is_aa64(env, el)) { @@ -10567,7 +10548,7 @@ bool arm_s1_regime_using_lpae_format(CPUARMState *e= nv, ARMMMUIdx mmu_idx) } =20 #ifndef CONFIG_USER_ONLY -static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) +bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) { switch (mmu_idx) { case ARMMMUIdx_SE10_0: @@ -10959,11 +10940,11 @@ static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr = addr, bool is_secure, return 0; } =20 -static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - hwaddr *phys_ptr, int *prot, - target_ulong *page_size, - ARMMMUFaultInfo *fi) +bool get_phys_addr_v5(CPUARMState *env, uint32_t address, + MMUAccessType access_type, ARMMMUIdx mmu_idx, + hwaddr *phys_ptr, int *prot, + target_ulong *page_size, + ARMMMUFaultInfo *fi) { CPUState *cs =3D env_cpu(env); int level =3D 1; @@ -11081,10 +11062,10 @@ do_fault: return true; } =20 -static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - hwaddr *phys_ptr, MemTxAttrs *attrs, int *pro= t, - target_ulong *page_size, ARMMMUFaultInfo *fi) +bool get_phys_addr_v6(CPUARMState *env, uint32_t address, + MMUAccessType access_type, ARMMMUIdx mmu_idx, + hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, + target_ulong *page_size, ARMMMUFaultInfo *fi) { CPUState *cs =3D env_cpu(env); ARMCPU *cpu =3D env_archcpu(env); @@ -11360,7 +11341,7 @@ unsigned int arm_pamax(ARMCPU *cpu) return pamax_map[parange]; } =20 -static int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx) +int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx) { if (regime_has_2_ranges(mmu_idx)) { return extract64(tcr, 37, 2); @@ -11372,7 +11353,7 @@ static int aa64_va_parameter_tbi(uint64_t tcr, ARMM= MUIdx mmu_idx) } } =20 -static int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx mmu_idx) +int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx mmu_idx) { if (regime_has_2_ranges(mmu_idx)) { return extract64(tcr, 51, 2); @@ -11602,12 +11583,12 @@ static ARMVAParameters aa32_va_parameters(CPUARMS= tate *env, uint32_t va, * @fi: set to fault info if the translation fails * @cacheattrs: (if non-NULL) set to the cacheability/shareability attribu= tes */ -static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, - MMUAccessType access_type, ARMMMUIdx mmu_id= x, - bool s1_is_el0, - hwaddr *phys_ptr, MemTxAttrs *txattrs, int = *prot, - target_ulong *page_size_ptr, - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheat= trs) +bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, + MMUAccessType access_type, ARMMMUIdx mmu_idx, + bool s1_is_el0, + hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, + target_ulong *page_size_ptr, + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) { ARMCPU *cpu =3D env_archcpu(env); CPUState *cs =3D CPU(cpu); @@ -12055,11 +12036,11 @@ static inline bool m_is_system_region(CPUARMState= *env, uint32_t address) return arm_feature(env, ARM_FEATURE_M) && extract32(address, 29, 3) = =3D=3D 0x7; } =20 -static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_= idx, - hwaddr *phys_ptr, int *prot, - target_ulong *page_size, - ARMMMUFaultInfo *fi) +bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, + MMUAccessType access_type, ARMMMUIdx mmu_idx, + hwaddr *phys_ptr, int *prot, + target_ulong *page_size, + ARMMMUFaultInfo *fi) { ARMCPU *cpu =3D env_archcpu(env); int n; @@ -12501,11 +12482,11 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t= address, } =20 =20 -static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_= idx, - hwaddr *phys_ptr, MemTxAttrs *txattrs, - int *prot, target_ulong *page_size, - ARMMMUFaultInfo *fi) +bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, + MMUAccessType access_type, ARMMMUIdx mmu_idx, + hwaddr *phys_ptr, MemTxAttrs *txattrs, + int *prot, target_ulong *page_size, + ARMMMUFaultInfo *fi) { uint32_t secure =3D regime_is_secure(env, mmu_idx); V8M_SAttributes sattrs =3D {}; @@ -12575,10 +12556,10 @@ static bool get_phys_addr_pmsav8(CPUARMState *env= , uint32_t address, return ret; } =20 -static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_= idx, - hwaddr *phys_ptr, int *prot, - ARMMMUFaultInfo *fi) +bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, + MMUAccessType access_type, ARMMMUIdx mmu_idx, + hwaddr *phys_ptr, int *prot, + ARMMMUFaultInfo *fi) { int n; uint32_t mask; @@ -12795,8 +12776,8 @@ static uint8_t combined_attrs_fwb(CPUARMState *env, * @s1: Attributes from stage 1 walk * @s2: Attributes from stage 2 walk */ -static ARMCacheAttrs combine_cacheattrs(CPUARMState *env, - ARMCacheAttrs s1, ARMCacheAttrs s2) +ARMCacheAttrs combine_cacheattrs(CPUARMState *env, + ARMCacheAttrs s1, ARMCacheAttrs s2) { ARMCacheAttrs ret; bool tagged =3D false; @@ -12848,256 +12829,6 @@ static ARMCacheAttrs combine_cacheattrs(CPUARMSta= te *env, return ret; } =20 - -/* get_phys_addr - get the physical address for this virtual address - * - * Find the physical address corresponding to the given virtual address, - * by doing a translation table walk on MMU based systems or using the - * MPU state on MPU based systems. - * - * Returns false if the translation was successful. Otherwise, phys_ptr, a= ttrs, - * prot and page_size may not be filled in, and the populated fsr value pr= ovides - * information on why the translation aborted, in the format of a - * DFSR/IFSR fault register, with the following caveats: - * * we honour the short vs long DFSR format differences. - * * the WnR bit is never set (the caller must do this). - * * for PSMAv5 based systems we don't bother to return a full FSR format - * value. - * - * @env: CPUARMState - * @address: virtual address to get physical address for - * @access_type: 0 for read, 1 for write, 2 for execute - * @mmu_idx: MMU index indicating required translation regime - * @phys_ptr: set to the physical address corresponding to the virtual add= ress - * @attrs: set to the memory transaction attributes to use - * @prot: set to the permissions for the page containing phys_ptr - * @page_size: set to the size of the page containing phys_ptr - * @fi: set to fault info if the translation fails - * @cacheattrs: (if non-NULL) set to the cacheability/shareability attribu= tes - */ -bool get_phys_addr(CPUARMState *env, target_ulong address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, - target_ulong *page_size, - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) -{ - ARMMMUIdx s1_mmu_idx =3D stage_1_mmu_idx(mmu_idx); - - if (mmu_idx !=3D s1_mmu_idx) { - /* Call ourselves recursively to do the stage 1 and then stage 2 - * translations if mmu_idx is a two-stage regime. - */ - if (arm_feature(env, ARM_FEATURE_EL2)) { - hwaddr ipa; - int s2_prot; - int ret; - bool ipa_secure; - ARMCacheAttrs cacheattrs2 =3D {}; - ARMMMUIdx s2_mmu_idx; - bool is_el0; - - ret =3D get_phys_addr(env, address, access_type, s1_mmu_idx, &= ipa, - attrs, prot, page_size, fi, cacheattrs); - - /* If S1 fails or S2 is disabled, return early. */ - if (ret || regime_translation_disabled(env, ARMMMUIdx_Stage2))= { - *phys_ptr =3D ipa; - return ret; - } - - ipa_secure =3D attrs->secure; - if (arm_is_secure_below_el3(env)) { - if (ipa_secure) { - attrs->secure =3D !(env->cp15.vstcr_el2.raw_tcr & VSTC= R_SW); - } else { - attrs->secure =3D !(env->cp15.vtcr_el2.raw_tcr & VTCR_= NSW); - } - } else { - assert(!ipa_secure); - } - - s2_mmu_idx =3D attrs->secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_= Stage2; - is_el0 =3D mmu_idx =3D=3D ARMMMUIdx_E10_0 || mmu_idx =3D=3D AR= MMMUIdx_SE10_0; - - /* S1 is done. Now do S2 translation. */ - ret =3D get_phys_addr_lpae(env, ipa, access_type, s2_mmu_idx, = is_el0, - phys_ptr, attrs, &s2_prot, - page_size, fi, &cacheattrs2); - fi->s2addr =3D ipa; - /* Combine the S1 and S2 perms. */ - *prot &=3D s2_prot; - - /* If S2 fails, return early. */ - if (ret) { - return ret; - } - - /* Combine the S1 and S2 cache attributes. */ - if (arm_hcr_el2_eff(env) & HCR_DC) { - /* - * HCR.DC forces the first stage attributes to - * Normal Non-Shareable, - * Inner Write-Back Read-Allocate Write-Allocate, - * Outer Write-Back Read-Allocate Write-Allocate. - * Do not overwrite Tagged within attrs. - */ - if (cacheattrs->attrs !=3D 0xf0) { - cacheattrs->attrs =3D 0xff; - } - cacheattrs->shareability =3D 0; - } - *cacheattrs =3D combine_cacheattrs(env, *cacheattrs, cacheattr= s2); - - /* Check if IPA translates to secure or non-secure PA space. */ - if (arm_is_secure_below_el3(env)) { - if (ipa_secure) { - attrs->secure =3D - !(env->cp15.vstcr_el2.raw_tcr & (VSTCR_SA | VSTCR_= SW)); - } else { - attrs->secure =3D - !((env->cp15.vtcr_el2.raw_tcr & (VTCR_NSA | VTCR_N= SW)) - || (env->cp15.vstcr_el2.raw_tcr & (VSTCR_SA | VSTC= R_SW))); - } - } - return 0; - } else { - /* - * For non-EL2 CPUs a stage1+stage2 translation is just stage = 1. - */ - mmu_idx =3D stage_1_mmu_idx(mmu_idx); - } - } - - /* The page table entries may downgrade secure to non-secure, but - * cannot upgrade an non-secure translation regime's attributes - * to secure. - */ - attrs->secure =3D regime_is_secure(env, mmu_idx); - attrs->user =3D regime_is_user(env, mmu_idx); - - /* Fast Context Switch Extension. This doesn't exist at all in v8. - * In v7 and earlier it affects all stage 1 translations. - */ - if (address < 0x02000000 && mmu_idx !=3D ARMMMUIdx_Stage2 - && !arm_feature(env, ARM_FEATURE_V8)) { - if (regime_el(env, mmu_idx) =3D=3D 3) { - address +=3D env->cp15.fcseidr_s; - } else { - address +=3D env->cp15.fcseidr_ns; - } - } - - if (arm_feature(env, ARM_FEATURE_PMSA)) { - bool ret; - *page_size =3D TARGET_PAGE_SIZE; - - if (arm_feature(env, ARM_FEATURE_V8)) { - /* PMSAv8 */ - ret =3D get_phys_addr_pmsav8(env, address, access_type, mmu_id= x, - phys_ptr, attrs, prot, page_size, f= i); - } else if (arm_feature(env, ARM_FEATURE_V7)) { - /* PMSAv7 */ - ret =3D get_phys_addr_pmsav7(env, address, access_type, mmu_id= x, - phys_ptr, prot, page_size, fi); - } else { - /* Pre-v7 MPU */ - ret =3D get_phys_addr_pmsav5(env, address, access_type, mmu_id= x, - phys_ptr, prot, 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", - access_type =3D=3D MMU_DATA_LOAD ? "reading" : - (access_type =3D=3D MMU_DATA_STORE ? "writing" : "ex= ecute"), - (uint32_t)address, mmu_idx, - ret ? "Miss" : "Hit", - *prot & PAGE_READ ? 'r' : '-', - *prot & PAGE_WRITE ? 'w' : '-', - *prot & PAGE_EXEC ? 'x' : '-'); - - return ret; - } - - /* Definitely a real MMU, not an MPU */ - - if (regime_translation_disabled(env, mmu_idx)) { - uint64_t hcr; - uint8_t memattr; - - /* - * MMU disabled. S1 addresses within aa64 translation regimes are - * still checked for bounds -- see AArch64.TranslateAddressS1Off. - */ - if (mmu_idx !=3D ARMMMUIdx_Stage2 && mmu_idx !=3D ARMMMUIdx_Stage2= _S) { - int r_el =3D regime_el(env, mmu_idx); - if (arm_el_is_aa64(env, r_el)) { - int pamax =3D arm_pamax(env_archcpu(env)); - uint64_t tcr =3D env->cp15.tcr_el[r_el].raw_tcr; - int addrtop, tbi; - - tbi =3D aa64_va_parameter_tbi(tcr, mmu_idx); - if (access_type =3D=3D MMU_INST_FETCH) { - tbi &=3D ~aa64_va_parameter_tbid(tcr, mmu_idx); - } - tbi =3D (tbi >> extract64(address, 55, 1)) & 1; - addrtop =3D (tbi ? 55 : 63); - - if (extract64(address, pamax, addrtop - pamax + 1) !=3D 0)= { - fi->type =3D ARMFault_AddressSize; - fi->level =3D 0; - fi->stage2 =3D false; - return 1; - } - - /* - * When TBI is disabled, we've just validated that all of = the - * bits above PAMax are zero, so logically we only need to - * clear the top byte for TBI. But it's clearer to follow - * the pseudocode set of addrdesc.paddress. - */ - address =3D extract64(address, 0, 52); - } - } - *phys_ptr =3D address; - *prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; - *page_size =3D TARGET_PAGE_SIZE; - - /* Fill in cacheattr a-la AArch64.TranslateAddressS1Off. */ - hcr =3D arm_hcr_el2_eff(env); - cacheattrs->shareability =3D 0; - cacheattrs->is_s2_format =3D false; - if (hcr & HCR_DC) { - if (hcr & HCR_DCT) { - memattr =3D 0xf0; /* Tagged, Normal, WB, RWA */ - } else { - memattr =3D 0xff; /* Normal, WB, RWA */ - } - } else 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 */ - } - cacheattrs->shareability =3D 2; /* outer sharable */ - } else { - memattr =3D 0x00; /* Device, nGnRnE */ - } - cacheattrs->attrs =3D memattr; - return 0; - } - - if (regime_using_lpae_format(env, mmu_idx)) { - return get_phys_addr_lpae(env, address, access_type, mmu_idx, fals= e, - phys_ptr, attrs, prot, page_size, - fi, cacheattrs); - } else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) { - return get_phys_addr_v6(env, address, access_type, mmu_idx, - phys_ptr, attrs, prot, page_size, fi); - } else { - return get_phys_addr_v5(env, address, access_type, mmu_idx, - phys_ptr, prot, page_size, fi); - } -} - hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, MemTxAttrs *attrs) { @@ -13121,7 +12852,6 @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *= cs, vaddr addr, } return phys_addr; } - #endif =20 /* Note that signed overflow is undefined in C. The following routines are diff --git a/target/arm/ptw.c b/target/arm/ptw.c new file mode 100644 index 00000000000..318000f6d94 --- /dev/null +++ b/target/arm/ptw.c @@ -0,0 +1,267 @@ +/* + * ARM page table walking. + * + * This code is licensed under the GNU GPL v2 or later. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "cpu.h" +#include "internals.h" +#include "ptw.h" + + +/** + * get_phys_addr - get the physical address for this virtual address + * + * Find the physical address corresponding to the given virtual address, + * by doing a translation table walk on MMU based systems or using the + * MPU state on MPU based systems. + * + * Returns false if the translation was successful. Otherwise, phys_ptr, a= ttrs, + * prot and page_size may not be filled in, and the populated fsr value pr= ovides + * information on why the translation aborted, in the format of a + * DFSR/IFSR fault register, with the following caveats: + * * we honour the short vs long DFSR format differences. + * * the WnR bit is never set (the caller must do this). + * * for PSMAv5 based systems we don't bother to return a full FSR format + * value. + * + * @env: CPUARMState + * @address: virtual address to get physical address for + * @access_type: 0 for read, 1 for write, 2 for execute + * @mmu_idx: MMU index indicating required translation regime + * @phys_ptr: set to the physical address corresponding to the virtual add= ress + * @attrs: set to the memory transaction attributes to use + * @prot: set to the permissions for the page containing phys_ptr + * @page_size: set to the size of the page containing phys_ptr + * @fi: set to fault info if the translation fails + * @cacheattrs: (if non-NULL) set to the cacheability/shareability attribu= tes + */ +bool get_phys_addr(CPUARMState *env, target_ulong address, + MMUAccessType access_type, ARMMMUIdx mmu_idx, + hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, + target_ulong *page_size, + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) +{ + ARMMMUIdx s1_mmu_idx =3D stage_1_mmu_idx(mmu_idx); + + if (mmu_idx !=3D s1_mmu_idx) { + /* + * Call ourselves recursively to do the stage 1 and then stage 2 + * translations if mmu_idx is a two-stage regime. + */ + if (arm_feature(env, ARM_FEATURE_EL2)) { + hwaddr ipa; + int s2_prot; + int ret; + bool ipa_secure; + ARMCacheAttrs cacheattrs2 =3D {}; + ARMMMUIdx s2_mmu_idx; + bool is_el0; + + ret =3D get_phys_addr(env, address, access_type, s1_mmu_idx, &= ipa, + attrs, prot, page_size, fi, cacheattrs); + + /* If S1 fails or S2 is disabled, return early. */ + if (ret || regime_translation_disabled(env, ARMMMUIdx_Stage2))= { + *phys_ptr =3D ipa; + return ret; + } + + ipa_secure =3D attrs->secure; + if (arm_is_secure_below_el3(env)) { + if (ipa_secure) { + attrs->secure =3D !(env->cp15.vstcr_el2.raw_tcr & VSTC= R_SW); + } else { + attrs->secure =3D !(env->cp15.vtcr_el2.raw_tcr & VTCR_= NSW); + } + } else { + assert(!ipa_secure); + } + + s2_mmu_idx =3D attrs->secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_= Stage2; + is_el0 =3D mmu_idx =3D=3D ARMMMUIdx_E10_0 || mmu_idx =3D=3D AR= MMMUIdx_SE10_0; + + /* S1 is done. Now do S2 translation. */ + ret =3D get_phys_addr_lpae(env, ipa, access_type, s2_mmu_idx, = is_el0, + phys_ptr, attrs, &s2_prot, + page_size, fi, &cacheattrs2); + fi->s2addr =3D ipa; + /* Combine the S1 and S2 perms. */ + *prot &=3D s2_prot; + + /* If S2 fails, return early. */ + if (ret) { + return ret; + } + + /* Combine the S1 and S2 cache attributes. */ + if (arm_hcr_el2_eff(env) & HCR_DC) { + /* + * HCR.DC forces the first stage attributes to + * Normal Non-Shareable, + * Inner Write-Back Read-Allocate Write-Allocate, + * Outer Write-Back Read-Allocate Write-Allocate. + * Do not overwrite Tagged within attrs. + */ + if (cacheattrs->attrs !=3D 0xf0) { + cacheattrs->attrs =3D 0xff; + } + cacheattrs->shareability =3D 0; + } + *cacheattrs =3D combine_cacheattrs(env, *cacheattrs, cacheattr= s2); + + /* Check if IPA translates to secure or non-secure PA space. */ + if (arm_is_secure_below_el3(env)) { + if (ipa_secure) { + attrs->secure =3D + !(env->cp15.vstcr_el2.raw_tcr & (VSTCR_SA | VSTCR_= SW)); + } else { + attrs->secure =3D + !((env->cp15.vtcr_el2.raw_tcr & (VTCR_NSA | VTCR_N= SW)) + || (env->cp15.vstcr_el2.raw_tcr & (VSTCR_SA | VSTC= R_SW))); + } + } + return 0; + } else { + /* + * For non-EL2 CPUs a stage1+stage2 translation is just stage = 1. + */ + mmu_idx =3D stage_1_mmu_idx(mmu_idx); + } + } + + /* + * The page table entries may downgrade secure to non-secure, but + * cannot upgrade an non-secure translation regime's attributes + * to secure. + */ + attrs->secure =3D regime_is_secure(env, mmu_idx); + attrs->user =3D regime_is_user(env, mmu_idx); + + /* + * Fast Context Switch Extension. This doesn't exist at all in v8. + * In v7 and earlier it affects all stage 1 translations. + */ + if (address < 0x02000000 && mmu_idx !=3D ARMMMUIdx_Stage2 + && !arm_feature(env, ARM_FEATURE_V8)) { + if (regime_el(env, mmu_idx) =3D=3D 3) { + address +=3D env->cp15.fcseidr_s; + } else { + address +=3D env->cp15.fcseidr_ns; + } + } + + if (arm_feature(env, ARM_FEATURE_PMSA)) { + bool ret; + *page_size =3D TARGET_PAGE_SIZE; + + if (arm_feature(env, ARM_FEATURE_V8)) { + /* PMSAv8 */ + ret =3D get_phys_addr_pmsav8(env, address, access_type, mmu_id= x, + phys_ptr, attrs, prot, page_size, f= i); + } else if (arm_feature(env, ARM_FEATURE_V7)) { + /* PMSAv7 */ + ret =3D get_phys_addr_pmsav7(env, address, access_type, mmu_id= x, + phys_ptr, prot, page_size, fi); + } else { + /* Pre-v7 MPU */ + ret =3D get_phys_addr_pmsav5(env, address, access_type, mmu_id= x, + phys_ptr, prot, 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", + access_type =3D=3D MMU_DATA_LOAD ? "reading" : + (access_type =3D=3D MMU_DATA_STORE ? "writing" : "ex= ecute"), + (uint32_t)address, mmu_idx, + ret ? "Miss" : "Hit", + *prot & PAGE_READ ? 'r' : '-', + *prot & PAGE_WRITE ? 'w' : '-', + *prot & PAGE_EXEC ? 'x' : '-'); + + return ret; + } + + /* Definitely a real MMU, not an MPU */ + + if (regime_translation_disabled(env, mmu_idx)) { + uint64_t hcr; + uint8_t memattr; + + /* + * MMU disabled. S1 addresses within aa64 translation regimes are + * still checked for bounds -- see AArch64.TranslateAddressS1Off. + */ + if (mmu_idx !=3D ARMMMUIdx_Stage2 && mmu_idx !=3D ARMMMUIdx_Stage2= _S) { + int r_el =3D regime_el(env, mmu_idx); + if (arm_el_is_aa64(env, r_el)) { + int pamax =3D arm_pamax(env_archcpu(env)); + uint64_t tcr =3D env->cp15.tcr_el[r_el].raw_tcr; + int addrtop, tbi; + + tbi =3D aa64_va_parameter_tbi(tcr, mmu_idx); + if (access_type =3D=3D MMU_INST_FETCH) { + tbi &=3D ~aa64_va_parameter_tbid(tcr, mmu_idx); + } + tbi =3D (tbi >> extract64(address, 55, 1)) & 1; + addrtop =3D (tbi ? 55 : 63); + + if (extract64(address, pamax, addrtop - pamax + 1) !=3D 0)= { + fi->type =3D ARMFault_AddressSize; + fi->level =3D 0; + fi->stage2 =3D false; + return 1; + } + + /* + * When TBI is disabled, we've just validated that all of = the + * bits above PAMax are zero, so logically we only need to + * clear the top byte for TBI. But it's clearer to follow + * the pseudocode set of addrdesc.paddress. + */ + address =3D extract64(address, 0, 52); + } + } + *phys_ptr =3D address; + *prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; + *page_size =3D TARGET_PAGE_SIZE; + + /* Fill in cacheattr a-la AArch64.TranslateAddressS1Off. */ + hcr =3D arm_hcr_el2_eff(env); + cacheattrs->shareability =3D 0; + cacheattrs->is_s2_format =3D false; + if (hcr & HCR_DC) { + if (hcr & HCR_DCT) { + memattr =3D 0xf0; /* Tagged, Normal, WB, RWA */ + } else { + memattr =3D 0xff; /* Normal, WB, RWA */ + } + } else 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 */ + } + cacheattrs->shareability =3D 2; /* outer sharable */ + } else { + memattr =3D 0x00; /* Device, nGnRnE */ + } + cacheattrs->attrs =3D memattr; + return 0; + } + + if (regime_using_lpae_format(env, mmu_idx)) { + return get_phys_addr_lpae(env, address, access_type, mmu_idx, fals= e, + phys_ptr, attrs, prot, page_size, + fi, cacheattrs); + } else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) { + return get_phys_addr_v6(env, address, access_type, mmu_idx, + phys_ptr, attrs, prot, page_size, fi); + } else { + return get_phys_addr_v5(env, address, access_type, mmu_idx, + phys_ptr, prot, page_size, fi); + } +} diff --git a/target/arm/meson.build b/target/arm/meson.build index 50f152214af..ac571fc45db 100644 --- a/target/arm/meson.build +++ b/target/arm/meson.build @@ -58,6 +58,7 @@ arm_softmmu_ss.add(files( 'machine.c', 'monitor.c', 'psci.c', + 'ptw.c', )) =20 subdir('hvf') --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654766947; cv=none; d=zohomail.com; s=zohoarc; b=TvLScFqRf51wLnC5Uu5pEmal1jHWcU0JSZcBcyvXNSTQVRpfTLVgR3kjdWZiKFrrA0asHGhma4pPNL480gpyddCq6JVVmzoaYhclgxIY0DQiAtCVlyCZx+FcuL0LhK+EJVTDkOHXWpCxt1IRNxJKzwlKZe1bmwZSBwYvFSTWY8k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654766947; 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=VG4un4lC8exaz+aSq1lh+oEDzRxMaXaOxXswh3zyYxQ=; b=hOnk42DZN/AFB1BR+aZFXkwWKxhiXaeJNz0Vjrz/y1aXBd6WoZj4GR3mhak7wAVyUX9yhC+fUv/4buGtXJLQP0+oQYohzLpnS727YCv21moNPqSN1eQHcmkVVYMRtqp/0qdxjuWt3YCkRpUbmBmRG7fH6EAIIwm1F8ebu1yGk+I= 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 1654766947750613.6153192244564; Thu, 9 Jun 2022 02:29:07 -0700 (PDT) Received: from localhost ([::1]:45626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzETR-0000O0-RA for importer@patchew.org; Thu, 09 Jun 2022 05:29:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE70-0001Si-Vj for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:55 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:44816) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE6y-00060e-Nh for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:54 -0400 Received: by mail-wr1-x433.google.com with SMTP id q15so23422931wrc.11 for ; Thu, 09 Jun 2022 02:05:52 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.05.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:05:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=VG4un4lC8exaz+aSq1lh+oEDzRxMaXaOxXswh3zyYxQ=; b=RNFip/6FQJ0qiatRXnuFSwr2NKZi/wJ4POxtXwUSNPccIJDNi+9LIRwKQL5d1L9KAR x9BNLllr8/EJOWN7f2Eu3AHuGm1bMN+kmHfMOhTfjwtc8ATMygZrhOyd0kgybk4c2fuJ VqrrIo2kJE6l5SQbS4OI/bXMJ1V4kSLQeE7QjyzXWYvkLfc2gk0acJcjPpzMQ18rpOT9 kq4TDC+Cdvrbs34UFdvexWrwh/za0WJTZjIpd8LfOOvekl+bISw/EbpDG845eKVU7ME5 x1mXIBk0MUfImKqtaW0XcTIbhcv7RMHn20vgKbmNqzdCbMcaubMxgjfPia3EkPPTZwP2 T9Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VG4un4lC8exaz+aSq1lh+oEDzRxMaXaOxXswh3zyYxQ=; b=2MFgUC6g6iPq+I3u1DU+/eBMlaG/ivGHCtEjHv6QWk9PJpE/JZoKAiyR90jIgfzRrP 8/FKPdmKhKegxo9ijvMx6FUcd1GYeLmdDskFXQg/+0kWegBJ3RvhwCXjNgy2lMswIuPS HYtnrOxD4P7I7bSss9BaEzixWMu2yOPZmakxJgborcEfOxPrKNYyJYjgSBqk2InHDPu4 /7Ji7/cOef88BB80eSdetr7EYXq5sSdjutOolCW0U3bE4Sz8h6eFP4akwDNirFsRwiog /b3RqLCvTAyvJBlG/ME2mSEzZCvoJ6d9iwmwRnkoE1eD6r18GWXBL3bRqr6fk3N6NQa9 8T+Q== X-Gm-Message-State: AOAM531aZgBVwAIuhQua8xCvrSpeQ8NGz6tP58UGLnMt7IOCgcy1e9iw sKEoy13DTmHpOgHkJ9obcotMkvnl3CL+Mg== X-Google-Smtp-Source: ABdhPJxfS9v7a1fKd9R2P9G0ajDqkSz0I8yLOLYEZSvVGvESu9Ls/7vsujIKr3+guyV/bMcSJ8PfAQ== X-Received: by 2002:a5d:58ed:0:b0:217:dd5:7508 with SMTP id f13-20020a5d58ed000000b002170dd57508mr24328263wrd.606.1654765551221; Thu, 09 Jun 2022 02:05:51 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 10/55] target/arm: Move get_phys_addr_v5 to ptw.c Date: Thu, 9 Jun 2022 10:04:52 +0100 Message-Id: <20220609090537.1971756-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654766949541100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-4-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 15 +++-- target/arm/helper.c | 137 +++----------------------------------------- target/arm/ptw.c | 123 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 135 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index e2023ae7508..2dbd97b8cbf 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -11,16 +11,21 @@ =20 #ifndef CONFIG_USER_ONLY =20 +uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, + ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi); +uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, + ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi); + bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx); bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); ARMCacheAttrs combine_cacheattrs(CPUARMState *env, ARMCacheAttrs s1, ARMCacheAttrs s2); =20 -bool get_phys_addr_v5(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - hwaddr *phys_ptr, int *prot, - target_ulong *page_size, - ARMMMUFaultInfo *fi); +bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, + uint32_t *table, uint32_t address); +int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, + int ap, int domain_prot); + bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot, diff --git a/target/arm/helper.c b/target/arm/helper.c index 3ffd122178d..321716914b1 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10578,8 +10578,7 @@ bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu= _idx) * @ap: The 3-bit access permissions (AP[2:0]) * @domain_prot: The 2-bit domain access permissions */ -static inline int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, - int ap, int domain_prot) +int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap, int domain_= prot) { bool is_user =3D regime_is_user(env, mmu_idx); =20 @@ -10782,8 +10781,8 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx m= mu_idx, bool is_aa64, return prot_rw | PAGE_EXEC; } =20 -static bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, - uint32_t *table, uint32_t address) +bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, + uint32_t *table, uint32_t address) { /* Note that we can only get here for an AArch32 PL0/PL1 lookup */ TCR *tcr =3D regime_tcr(env, mmu_idx); @@ -10882,8 +10881,8 @@ static hwaddr S1_ptw_translate(CPUARMState *env, AR= MMMUIdx mmu_idx, } =20 /* All loads done in the course of a page table walk go through here. */ -static uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, - ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) +uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, + ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; @@ -10911,8 +10910,8 @@ static uint32_t arm_ldl_ptw(CPUState *cs, hwaddr ad= dr, bool is_secure, return 0; } =20 -static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, - ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) +uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, + ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; @@ -10940,128 +10939,6 @@ static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr = addr, bool is_secure, return 0; } =20 -bool get_phys_addr_v5(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - hwaddr *phys_ptr, int *prot, - target_ulong *page_size, - ARMMMUFaultInfo *fi) -{ - CPUState *cs =3D env_cpu(env); - int level =3D 1; - uint32_t table; - uint32_t desc; - int type; - int ap; - int domain =3D 0; - int domain_prot; - hwaddr phys_addr; - uint32_t dacr; - - /* Pagetable walk. */ - /* Lookup l1 descriptor. */ - if (!get_level1_table_address(env, mmu_idx, &table, address)) { - /* Section translation fault if page walk is disabled by PD0 or PD= 1 */ - fi->type =3D ARMFault_Translation; - goto do_fault; - } - desc =3D arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), - mmu_idx, fi); - if (fi->type !=3D ARMFault_None) { - goto do_fault; - } - type =3D (desc & 3); - domain =3D (desc >> 5) & 0x0f; - if (regime_el(env, mmu_idx) =3D=3D 1) { - dacr =3D env->cp15.dacr_ns; - } else { - dacr =3D env->cp15.dacr_s; - } - domain_prot =3D (dacr >> (domain * 2)) & 3; - if (type =3D=3D 0) { - /* Section translation fault. */ - fi->type =3D ARMFault_Translation; - goto do_fault; - } - if (type !=3D 2) { - level =3D 2; - } - if (domain_prot =3D=3D 0 || domain_prot =3D=3D 2) { - fi->type =3D ARMFault_Domain; - goto do_fault; - } - if (type =3D=3D 2) { - /* 1Mb section. */ - phys_addr =3D (desc & 0xfff00000) | (address & 0x000fffff); - ap =3D (desc >> 10) & 3; - *page_size =3D 1024 * 1024; - } else { - /* Lookup l2 entry. */ - if (type =3D=3D 1) { - /* Coarse pagetable. */ - table =3D (desc & 0xfffffc00) | ((address >> 10) & 0x3fc); - } else { - /* Fine pagetable. */ - table =3D (desc & 0xfffff000) | ((address >> 8) & 0xffc); - } - desc =3D arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), - mmu_idx, fi); - if (fi->type !=3D ARMFault_None) { - goto do_fault; - } - switch (desc & 3) { - case 0: /* Page translation fault. */ - fi->type =3D ARMFault_Translation; - goto do_fault; - case 1: /* 64k page. */ - phys_addr =3D (desc & 0xffff0000) | (address & 0xffff); - ap =3D (desc >> (4 + ((address >> 13) & 6))) & 3; - *page_size =3D 0x10000; - break; - case 2: /* 4k page. */ - phys_addr =3D (desc & 0xfffff000) | (address & 0xfff); - ap =3D (desc >> (4 + ((address >> 9) & 6))) & 3; - *page_size =3D 0x1000; - break; - case 3: /* 1k page, or ARMv6/XScale "extended small (4k) page" */ - if (type =3D=3D 1) { - /* ARMv6/XScale extended small page format */ - if (arm_feature(env, ARM_FEATURE_XSCALE) - || arm_feature(env, ARM_FEATURE_V6)) { - phys_addr =3D (desc & 0xfffff000) | (address & 0xfff); - *page_size =3D 0x1000; - } else { - /* UNPREDICTABLE in ARMv5; we choose to take a - * page translation fault. - */ - fi->type =3D ARMFault_Translation; - goto do_fault; - } - } else { - phys_addr =3D (desc & 0xfffffc00) | (address & 0x3ff); - *page_size =3D 0x400; - } - ap =3D (desc >> 4) & 3; - break; - default: - /* Never happens, but compiler isn't smart enough to tell. */ - g_assert_not_reached(); - } - } - *prot =3D ap_to_rw_prot(env, mmu_idx, ap, domain_prot); - *prot |=3D *prot ? PAGE_EXEC : 0; - if (!(*prot & (1 << access_type))) { - /* Access permission fault. */ - fi->type =3D ARMFault_Permission; - goto do_fault; - } - *phys_ptr =3D phys_addr; - return false; -do_fault: - fi->domain =3D domain; - fi->level =3D level; - return true; -} - bool get_phys_addr_v6(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 318000f6d94..09c44726287 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -13,6 +13,129 @@ #include "ptw.h" =20 =20 +static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, + MMUAccessType access_type, ARMMMUIdx mmu_idx, + hwaddr *phys_ptr, int *prot, + target_ulong *page_size, + ARMMMUFaultInfo *fi) +{ + CPUState *cs =3D env_cpu(env); + int level =3D 1; + uint32_t table; + uint32_t desc; + int type; + int ap; + int domain =3D 0; + int domain_prot; + hwaddr phys_addr; + uint32_t dacr; + + /* Pagetable walk. */ + /* Lookup l1 descriptor. */ + if (!get_level1_table_address(env, mmu_idx, &table, address)) { + /* Section translation fault if page walk is disabled by PD0 or PD= 1 */ + fi->type =3D ARMFault_Translation; + goto do_fault; + } + desc =3D arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), + mmu_idx, fi); + if (fi->type !=3D ARMFault_None) { + goto do_fault; + } + type =3D (desc & 3); + domain =3D (desc >> 5) & 0x0f; + if (regime_el(env, mmu_idx) =3D=3D 1) { + dacr =3D env->cp15.dacr_ns; + } else { + dacr =3D env->cp15.dacr_s; + } + domain_prot =3D (dacr >> (domain * 2)) & 3; + if (type =3D=3D 0) { + /* Section translation fault. */ + fi->type =3D ARMFault_Translation; + goto do_fault; + } + if (type !=3D 2) { + level =3D 2; + } + if (domain_prot =3D=3D 0 || domain_prot =3D=3D 2) { + fi->type =3D ARMFault_Domain; + goto do_fault; + } + if (type =3D=3D 2) { + /* 1Mb section. */ + phys_addr =3D (desc & 0xfff00000) | (address & 0x000fffff); + ap =3D (desc >> 10) & 3; + *page_size =3D 1024 * 1024; + } else { + /* Lookup l2 entry. */ + if (type =3D=3D 1) { + /* Coarse pagetable. */ + table =3D (desc & 0xfffffc00) | ((address >> 10) & 0x3fc); + } else { + /* Fine pagetable. */ + table =3D (desc & 0xfffff000) | ((address >> 8) & 0xffc); + } + desc =3D arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), + mmu_idx, fi); + if (fi->type !=3D ARMFault_None) { + goto do_fault; + } + switch (desc & 3) { + case 0: /* Page translation fault. */ + fi->type =3D ARMFault_Translation; + goto do_fault; + case 1: /* 64k page. */ + phys_addr =3D (desc & 0xffff0000) | (address & 0xffff); + ap =3D (desc >> (4 + ((address >> 13) & 6))) & 3; + *page_size =3D 0x10000; + break; + case 2: /* 4k page. */ + phys_addr =3D (desc & 0xfffff000) | (address & 0xfff); + ap =3D (desc >> (4 + ((address >> 9) & 6))) & 3; + *page_size =3D 0x1000; + break; + case 3: /* 1k page, or ARMv6/XScale "extended small (4k) page" */ + if (type =3D=3D 1) { + /* ARMv6/XScale extended small page format */ + if (arm_feature(env, ARM_FEATURE_XSCALE) + || arm_feature(env, ARM_FEATURE_V6)) { + phys_addr =3D (desc & 0xfffff000) | (address & 0xfff); + *page_size =3D 0x1000; + } else { + /* + * UNPREDICTABLE in ARMv5; we choose to take a + * page translation fault. + */ + fi->type =3D ARMFault_Translation; + goto do_fault; + } + } else { + phys_addr =3D (desc & 0xfffffc00) | (address & 0x3ff); + *page_size =3D 0x400; + } + ap =3D (desc >> 4) & 3; + break; + default: + /* Never happens, but compiler isn't smart enough to tell. */ + g_assert_not_reached(); + } + } + *prot =3D ap_to_rw_prot(env, mmu_idx, ap, domain_prot); + *prot |=3D *prot ? PAGE_EXEC : 0; + if (!(*prot & (1 << access_type))) { + /* Access permission fault. */ + fi->type =3D ARMFault_Permission; + goto do_fault; + } + *phys_ptr =3D phys_addr; + return false; +do_fault: + fi->domain =3D domain; + fi->level =3D level; + return true; +} + /** * get_phys_addr - get the physical address for this virtual address * --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654766650; cv=none; d=zohomail.com; s=zohoarc; b=nywZiZYKtG++AFhzRBG7LSEgn/gTsnLezpOPmLq6qlSMuHo8UTflWsb0nD/4lsncRa54yrPALwCjWF0Fjh1IQYTSaRuuhEiBQ5gE/gTKadW/RXKv6kBvmLrw2RloYuwIajeZ/PTRLI6EhgGRZ3SYHtMRzGz+aAA8w3WDNB9YILI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654766650; 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=XtUVBNi8Hf8p1qU71YRb6ABVBGS+B/b2TUi9wKuJp40=; b=g4g95T8VyhQCnvtdLX9/pwY/5GFJW25YVHA/U4RWtMftdotoQO5q82vixt0Q9H/XzUjleLfMx47UdeIaPOl75ooSeV3EDn28I4/3UT28C7xhropu5zQuUnSZD1Kpxo7XhIf0gEvjm0gjajxUOnfMqbxJ321rTH8PBVj+80pEUrE= 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 165476665018691.07304156330599; Thu, 9 Jun 2022 02:24:10 -0700 (PDT) Received: from localhost ([::1]:37238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzEOf-0002uh-2r for importer@patchew.org; Thu, 09 Jun 2022 05:24:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39334) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE72-0001U6-JW for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:56 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:42899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE70-00060y-CF for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:56 -0400 Received: by mail-wr1-x432.google.com with SMTP id s1so8358409wra.9 for ; Thu, 09 Jun 2022 02:05:53 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.05.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:05:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=XtUVBNi8Hf8p1qU71YRb6ABVBGS+B/b2TUi9wKuJp40=; b=yMpIlZ96Z0LOVZ7k1utzjc/cAFyrCn9mxGwsiOlzYo2jb7AiftK7CcKKnXh3XKC3tt WtLtGQHBEtKtYUO6SDa4VeAaiJzUKVtcsG2ghGCDQg0U+0KOBbiZntZRAYXDDviBKP7G qoK82OJ/32nOckI1sh7/Qp5/lG72LyVl/gL0EDN9wpGBWu+TsQFJ1g9BUkjBo7wnih5E axqElVgegtiXHlsVUaB0Hgvtploa85p8BCfYLrjiHztltsm2LohkhKFNqeGip42yX2+I LmFYHc6rgLJqxlGdSdy/4ZGUDb+8IDAyFn9i/LkYdcLqKTUup4mm7x0zoH2CthlQiYEf fD1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XtUVBNi8Hf8p1qU71YRb6ABVBGS+B/b2TUi9wKuJp40=; b=2O0pZRw44D2B4GG8peeTb2Ss/VQPZLt9qe7mA6MmkS7AsSBoMbe4hVR9KlXoTfimgS anZOLTim/K62CZKq1k/PAsAncj5dTCOt5i1P/gKMVp6+FDAWut1afF+5kU/hIikR+zzP BUrVR/ksv3MDBtvdgV/uVbVmeV47vaiEBEZyri/dtYGZlLZ4aa6hXXVIiwQjr1Wq5f9q l0l+kaL2NGdywzVLCOEoF0lXYa+bc2P+23M3OnblxNkMfqySnAILQzxClT34llWNVzZ4 yaEfRae1HT2pMNK2VQAUb4B11Gnku84mg7H4KJaiuXvVrH5DfNMwJkGJ64K3mw7a4gE9 z4gA== X-Gm-Message-State: AOAM531PKq04ytrCttB2kAraZ8MfLLlzUN2u80JHAxTECzzF5g6n9jhB gElyoCeX+9xxn8GI35ihey4SyLnHlLPnXw== X-Google-Smtp-Source: ABdhPJzCDQ5p3EIWarWSH6Tyg2DD9oty4dJVHmy6YqmUmXVp5N2cWEXkmkXdeVsxs8Uq37vUFp0dRg== X-Received: by 2002:a05:6000:152:b0:216:160:2e60 with SMTP id r18-20020a056000015200b0021601602e60mr27313517wrx.663.1654765552585; Thu, 09 Jun 2022 02:05:52 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/55] target/arm: Move get_phys_addr_v6 to ptw.c Date: Thu, 9 Jun 2022 10:04:53 +0100 Message-Id: <20220609090537.1971756-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654766652449100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-5-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 11 +-- target/arm/helper.c | 161 +------------------------------------------- target/arm/ptw.c | 153 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+), 164 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index 2dbd97b8cbf..349b842d3ce 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -25,15 +25,18 @@ bool get_level1_table_address(CPUARMState *env, ARMMMUI= dx mmu_idx, uint32_t *table, uint32_t address); int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap, int domain_prot); +int simple_ap_to_rw_prot_is_user(int ap, bool is_user); + +static inline int +simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) +{ + return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); +} =20 bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot, ARMMMUFaultInfo *fi); -bool get_phys_addr_v6(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, - target_ulong *page_size, ARMMMUFaultInfo *fi); bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot, diff --git a/target/arm/helper.c b/target/arm/helper.c index 321716914b1..4a588220250 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10631,7 +10631,7 @@ int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_i= dx, int ap, int domain_prot) * @ap: The 2-bit simple AP (AP[2:1]) * @is_user: TRUE if accessing from PL0 */ -static inline int simple_ap_to_rw_prot_is_user(int ap, bool is_user) +int simple_ap_to_rw_prot_is_user(int ap, bool is_user) { switch (ap) { case 0: @@ -10647,12 +10647,6 @@ static inline int simple_ap_to_rw_prot_is_user(int= ap, bool is_user) } } =20 -static inline int -simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) -{ - return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); -} - /* Translate S2 section/page access permissions to protection flags * * @env: CPUARMState @@ -10939,159 +10933,6 @@ uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, b= ool is_secure, return 0; } =20 -bool get_phys_addr_v6(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, - target_ulong *page_size, ARMMMUFaultInfo *fi) -{ - CPUState *cs =3D env_cpu(env); - ARMCPU *cpu =3D env_archcpu(env); - int level =3D 1; - uint32_t table; - uint32_t desc; - uint32_t xn; - uint32_t pxn =3D 0; - int type; - int ap; - int domain =3D 0; - int domain_prot; - hwaddr phys_addr; - uint32_t dacr; - bool ns; - - /* Pagetable walk. */ - /* Lookup l1 descriptor. */ - if (!get_level1_table_address(env, mmu_idx, &table, address)) { - /* Section translation fault if page walk is disabled by PD0 or PD= 1 */ - fi->type =3D ARMFault_Translation; - goto do_fault; - } - desc =3D arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), - mmu_idx, fi); - if (fi->type !=3D ARMFault_None) { - goto do_fault; - } - type =3D (desc & 3); - if (type =3D=3D 0 || (type =3D=3D 3 && !cpu_isar_feature(aa32_pxn, cpu= ))) { - /* Section translation fault, or attempt to use the encoding - * which is Reserved on implementations without PXN. - */ - fi->type =3D ARMFault_Translation; - goto do_fault; - } - if ((type =3D=3D 1) || !(desc & (1 << 18))) { - /* Page or Section. */ - domain =3D (desc >> 5) & 0x0f; - } - if (regime_el(env, mmu_idx) =3D=3D 1) { - dacr =3D env->cp15.dacr_ns; - } else { - dacr =3D env->cp15.dacr_s; - } - if (type =3D=3D 1) { - level =3D 2; - } - domain_prot =3D (dacr >> (domain * 2)) & 3; - if (domain_prot =3D=3D 0 || domain_prot =3D=3D 2) { - /* Section or Page domain fault */ - fi->type =3D ARMFault_Domain; - goto do_fault; - } - if (type !=3D 1) { - if (desc & (1 << 18)) { - /* Supersection. */ - phys_addr =3D (desc & 0xff000000) | (address & 0x00ffffff); - phys_addr |=3D (uint64_t)extract32(desc, 20, 4) << 32; - phys_addr |=3D (uint64_t)extract32(desc, 5, 4) << 36; - *page_size =3D 0x1000000; - } else { - /* Section. */ - phys_addr =3D (desc & 0xfff00000) | (address & 0x000fffff); - *page_size =3D 0x100000; - } - ap =3D ((desc >> 10) & 3) | ((desc >> 13) & 4); - xn =3D desc & (1 << 4); - pxn =3D desc & 1; - ns =3D extract32(desc, 19, 1); - } else { - if (cpu_isar_feature(aa32_pxn, cpu)) { - pxn =3D (desc >> 2) & 1; - } - ns =3D extract32(desc, 3, 1); - /* Lookup l2 entry. */ - table =3D (desc & 0xfffffc00) | ((address >> 10) & 0x3fc); - desc =3D arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), - mmu_idx, fi); - if (fi->type !=3D ARMFault_None) { - goto do_fault; - } - ap =3D ((desc >> 4) & 3) | ((desc >> 7) & 4); - switch (desc & 3) { - case 0: /* Page translation fault. */ - fi->type =3D ARMFault_Translation; - goto do_fault; - case 1: /* 64k page. */ - phys_addr =3D (desc & 0xffff0000) | (address & 0xffff); - xn =3D desc & (1 << 15); - *page_size =3D 0x10000; - break; - case 2: case 3: /* 4k page. */ - phys_addr =3D (desc & 0xfffff000) | (address & 0xfff); - xn =3D desc & 1; - *page_size =3D 0x1000; - break; - default: - /* Never happens, but compiler isn't smart enough to tell. */ - g_assert_not_reached(); - } - } - if (domain_prot =3D=3D 3) { - *prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; - } else { - if (pxn && !regime_is_user(env, mmu_idx)) { - xn =3D 1; - } - if (xn && access_type =3D=3D MMU_INST_FETCH) { - fi->type =3D ARMFault_Permission; - goto do_fault; - } - - if (arm_feature(env, ARM_FEATURE_V6K) && - (regime_sctlr(env, mmu_idx) & SCTLR_AFE)) { - /* The simplified model uses AP[0] as an access control bit. = */ - if ((ap & 1) =3D=3D 0) { - /* Access flag fault. */ - fi->type =3D ARMFault_AccessFlag; - goto do_fault; - } - *prot =3D simple_ap_to_rw_prot(env, mmu_idx, ap >> 1); - } else { - *prot =3D ap_to_rw_prot(env, mmu_idx, ap, domain_prot); - } - if (*prot && !xn) { - *prot |=3D PAGE_EXEC; - } - if (!(*prot & (1 << access_type))) { - /* Access permission fault. */ - fi->type =3D ARMFault_Permission; - goto do_fault; - } - } - if (ns) { - /* The NS bit will (as required by the architecture) have no effec= t if - * the CPU doesn't support TZ or this is a non-secure translation - * regime, because the attribute will already be non-secure. - */ - attrs->secure =3D false; - } - *phys_ptr =3D phys_addr; - return false; -do_fault: - fi->domain =3D domain; - fi->level =3D level; - return true; -} - /* * check_s2_mmu_setup * @cpu: ARMCPU diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 09c44726287..6a1f4b549d8 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -136,6 +136,159 @@ do_fault: return true; } =20 +static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, + MMUAccessType access_type, ARMMMUIdx mmu_idx, + hwaddr *phys_ptr, MemTxAttrs *attrs, int *pro= t, + target_ulong *page_size, ARMMMUFaultInfo *fi) +{ + CPUState *cs =3D env_cpu(env); + ARMCPU *cpu =3D env_archcpu(env); + int level =3D 1; + uint32_t table; + uint32_t desc; + uint32_t xn; + uint32_t pxn =3D 0; + int type; + int ap; + int domain =3D 0; + int domain_prot; + hwaddr phys_addr; + uint32_t dacr; + bool ns; + + /* Pagetable walk. */ + /* Lookup l1 descriptor. */ + if (!get_level1_table_address(env, mmu_idx, &table, address)) { + /* Section translation fault if page walk is disabled by PD0 or PD= 1 */ + fi->type =3D ARMFault_Translation; + goto do_fault; + } + desc =3D arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), + mmu_idx, fi); + if (fi->type !=3D ARMFault_None) { + goto do_fault; + } + type =3D (desc & 3); + if (type =3D=3D 0 || (type =3D=3D 3 && !cpu_isar_feature(aa32_pxn, cpu= ))) { + /* Section translation fault, or attempt to use the encoding + * which is Reserved on implementations without PXN. + */ + fi->type =3D ARMFault_Translation; + goto do_fault; + } + if ((type =3D=3D 1) || !(desc & (1 << 18))) { + /* Page or Section. */ + domain =3D (desc >> 5) & 0x0f; + } + if (regime_el(env, mmu_idx) =3D=3D 1) { + dacr =3D env->cp15.dacr_ns; + } else { + dacr =3D env->cp15.dacr_s; + } + if (type =3D=3D 1) { + level =3D 2; + } + domain_prot =3D (dacr >> (domain * 2)) & 3; + if (domain_prot =3D=3D 0 || domain_prot =3D=3D 2) { + /* Section or Page domain fault */ + fi->type =3D ARMFault_Domain; + goto do_fault; + } + if (type !=3D 1) { + if (desc & (1 << 18)) { + /* Supersection. */ + phys_addr =3D (desc & 0xff000000) | (address & 0x00ffffff); + phys_addr |=3D (uint64_t)extract32(desc, 20, 4) << 32; + phys_addr |=3D (uint64_t)extract32(desc, 5, 4) << 36; + *page_size =3D 0x1000000; + } else { + /* Section. */ + phys_addr =3D (desc & 0xfff00000) | (address & 0x000fffff); + *page_size =3D 0x100000; + } + ap =3D ((desc >> 10) & 3) | ((desc >> 13) & 4); + xn =3D desc & (1 << 4); + pxn =3D desc & 1; + ns =3D extract32(desc, 19, 1); + } else { + if (cpu_isar_feature(aa32_pxn, cpu)) { + pxn =3D (desc >> 2) & 1; + } + ns =3D extract32(desc, 3, 1); + /* Lookup l2 entry. */ + table =3D (desc & 0xfffffc00) | ((address >> 10) & 0x3fc); + desc =3D arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), + mmu_idx, fi); + if (fi->type !=3D ARMFault_None) { + goto do_fault; + } + ap =3D ((desc >> 4) & 3) | ((desc >> 7) & 4); + switch (desc & 3) { + case 0: /* Page translation fault. */ + fi->type =3D ARMFault_Translation; + goto do_fault; + case 1: /* 64k page. */ + phys_addr =3D (desc & 0xffff0000) | (address & 0xffff); + xn =3D desc & (1 << 15); + *page_size =3D 0x10000; + break; + case 2: case 3: /* 4k page. */ + phys_addr =3D (desc & 0xfffff000) | (address & 0xfff); + xn =3D desc & 1; + *page_size =3D 0x1000; + break; + default: + /* Never happens, but compiler isn't smart enough to tell. */ + g_assert_not_reached(); + } + } + if (domain_prot =3D=3D 3) { + *prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; + } else { + if (pxn && !regime_is_user(env, mmu_idx)) { + xn =3D 1; + } + if (xn && access_type =3D=3D MMU_INST_FETCH) { + fi->type =3D ARMFault_Permission; + goto do_fault; + } + + if (arm_feature(env, ARM_FEATURE_V6K) && + (regime_sctlr(env, mmu_idx) & SCTLR_AFE)) { + /* The simplified model uses AP[0] as an access control bit. = */ + if ((ap & 1) =3D=3D 0) { + /* Access flag fault. */ + fi->type =3D ARMFault_AccessFlag; + goto do_fault; + } + *prot =3D simple_ap_to_rw_prot(env, mmu_idx, ap >> 1); + } else { + *prot =3D ap_to_rw_prot(env, mmu_idx, ap, domain_prot); + } + if (*prot && !xn) { + *prot |=3D PAGE_EXEC; + } + if (!(*prot & (1 << access_type))) { + /* Access permission fault. */ + fi->type =3D ARMFault_Permission; + goto do_fault; + } + } + if (ns) { + /* The NS bit will (as required by the architecture) have no effec= t if + * the CPU doesn't support TZ or this is a non-secure translation + * regime, because the attribute will already be non-secure. + */ + attrs->secure =3D false; + } + *phys_ptr =3D phys_addr; + return false; +do_fault: + fi->domain =3D domain; + fi->level =3D level; + return true; +} + /** * get_phys_addr - get the physical address for this virtual address * --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654767088; cv=none; d=zohomail.com; s=zohoarc; b=SS6AlFCQrzjilmtCSswNAiBgiUKWzHl5+pLg19g+OS+MaH2TGTnXWy+6qSzEmu1a+kN/Zx0zOUPNK72d475Q6TdWBhak3HnPmzkH8zwMKudfcIl8o3Vf3Qd4wLURZ97xPuOVVE8VhoJ7K8G4OdF/0fRKr5hE7VNd0DKX3f19Rtw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654767088; 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=3/ajaWjvxs0DjIe4wzlTwAQI78+yJDb5luhxxky7riw=; b=lUIHMt4vJGDzf1yBSt+yYdKmjg83Fb3GQVC586kI2qf+wjV6QNapG9twENIFIf1gis7wiUnlUNCUuVjn47za29WFKhoJiuUmiDHUNBGV+XAc/v7hj3oFJ/4VeApMjCYkGm5hXL/pFQKVBwt50wB4UgfjnoTmdNDmRBcrrv0dLwY= 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 1654767088387665.5221467168086; Thu, 9 Jun 2022 02:31:28 -0700 (PDT) Received: from localhost ([::1]:48796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzEVj-0002Zw-2q for importer@patchew.org; Thu, 09 Jun 2022 05:31:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE72-0001U8-R4 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:57 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:47100) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE70-00061B-Vt for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:56 -0400 Received: by mail-wm1-x32e.google.com with SMTP id r123-20020a1c2b81000000b0039c1439c33cso12264463wmr.5 for ; Thu, 09 Jun 2022 02:05:54 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.05.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:05:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3/ajaWjvxs0DjIe4wzlTwAQI78+yJDb5luhxxky7riw=; b=NHUiQjtUMYG/VXcQjkFsEMfzlssyJz6ZTLF8bZjheJXP4T/njF18PFDS08qnXbd9JG np0UyhmKifFdIznxG5JP5unZ4jR1F+aOcL4kELB7gXlrPSdiq4GkQgAubRMlndIHUJC/ dBlU4T7aAJ91YGWxf3j6cvvZjRmHP+rxoIB7K9eONNuUjAqheI6XsDy5jTCG226tJjK8 xeiZdvkURQZ8BdPxfgKfj2kIqmuIjOBA+fSPbs8Pi4o4s/ZD86usbqPp8dWMbEuqckZR uQKKh6+kUo6wVLAFlV/0ItgnNG4uZQ+Dy7UJNlX3Pz3u0N3S1M4XgeS1dYEVi+OsISVn 4r2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3/ajaWjvxs0DjIe4wzlTwAQI78+yJDb5luhxxky7riw=; b=uzRZ29l8jMkr1ZFYH5LR3frdS8fUjB3Gdow/GdSTi3jSEVRZ2Dnm7UWu2qtbMXdKt+ QNv7UMA1TGZorwkMzYuY7JvP3k4PJBi7trCssN0QeSTahQgsTilpm3jlhIVEHhDhMLWA 90iyS5JGTK2K7CuAoj4uFE82E2Kk37kTa29Zr+ST5Qk/XuiYU0uHuyuTY5LaK4gsl6ME WINQkN6ODzkfpv1SRozcdb/kK0HDUTBr1mNXwDAa5FLsUVVhvKI0kHuVB9oHdKwlNCJj VKulO0TwUdZe0BnrNdOvrLWoGSS2whMI8GtyJphcUq0SVUnHueWtqd4cfImrZfGbieSr rmFQ== X-Gm-Message-State: AOAM531ot1xQG1PX3ZwC46OxzWjZdzqQd10xjrMEbQgO4xeyO0WPsncO IWfD5GgN/DOfPJQu0g9S2OKLY5ilqzNQLw== X-Google-Smtp-Source: ABdhPJzDvC3bjN3CTkteihx0D2NQZhWrFGk1NDIvsJYj4C4JBddtvOVhZdeG2WM5zk5nE9SYSD+tVQ== X-Received: by 2002:a05:600c:2c46:b0:39c:55a0:9533 with SMTP id r6-20020a05600c2c4600b0039c55a09533mr2278909wmg.104.1654765553651; Thu, 09 Jun 2022 02:05:53 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 12/55] target/arm: Move get_phys_addr_pmsav5 to ptw.c Date: Thu, 9 Jun 2022 10:04:54 +0100 Message-Id: <20220609090537.1971756-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654767089931100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-6-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 4 --- target/arm/helper.c | 85 --------------------------------------------- target/arm/ptw.c | 85 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 89 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index 349b842d3ce..324a9dde140 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -33,10 +33,6 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx= , int ap) return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); } =20 -bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - hwaddr *phys_ptr, int *prot, - ARMMMUFaultInfo *fi); bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot, diff --git a/target/arm/helper.c b/target/arm/helper.c index 4a588220250..5d010190108 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -12274,91 +12274,6 @@ bool get_phys_addr_pmsav8(CPUARMState *env, uint32= _t address, return ret; } =20 -bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - hwaddr *phys_ptr, int *prot, - ARMMMUFaultInfo *fi) -{ - int n; - uint32_t mask; - uint32_t base; - bool is_user =3D regime_is_user(env, mmu_idx); - - if (regime_translation_disabled(env, mmu_idx)) { - /* MPU disabled. */ - *phys_ptr =3D address; - *prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; - return false; - } - - *phys_ptr =3D address; - for (n =3D 7; n >=3D 0; n--) { - base =3D env->cp15.c6_region[n]; - if ((base & 1) =3D=3D 0) { - continue; - } - mask =3D 1 << ((base >> 1) & 0x1f); - /* Keep this shift separate from the above to avoid an - (undefined) << 32. */ - mask =3D (mask << 1) - 1; - if (((base ^ address) & ~mask) =3D=3D 0) { - break; - } - } - if (n < 0) { - fi->type =3D ARMFault_Background; - return true; - } - - if (access_type =3D=3D MMU_INST_FETCH) { - mask =3D env->cp15.pmsav5_insn_ap; - } else { - mask =3D env->cp15.pmsav5_data_ap; - } - mask =3D (mask >> (n * 4)) & 0xf; - switch (mask) { - case 0: - fi->type =3D ARMFault_Permission; - fi->level =3D 1; - return true; - case 1: - if (is_user) { - fi->type =3D ARMFault_Permission; - fi->level =3D 1; - return true; - } - *prot =3D PAGE_READ | PAGE_WRITE; - break; - case 2: - *prot =3D PAGE_READ; - if (!is_user) { - *prot |=3D PAGE_WRITE; - } - break; - case 3: - *prot =3D PAGE_READ | PAGE_WRITE; - break; - case 5: - if (is_user) { - fi->type =3D ARMFault_Permission; - fi->level =3D 1; - return true; - } - *prot =3D PAGE_READ; - break; - case 6: - *prot =3D PAGE_READ; - break; - default: - /* Bad permission. */ - fi->type =3D ARMFault_Permission; - fi->level =3D 1; - return true; - } - *prot |=3D PAGE_EXEC; - return false; -} - /* Combine either inner or outer cacheability attributes for normal * memory, according to table D4-42 and pseudocode procedure * CombineS1S2AttrHints() of ARM DDI 0487B.b (the ARMv8 ARM). diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 6a1f4b549d8..5c32648a16a 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -289,6 +289,91 @@ do_fault: return true; } =20 +static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, + MMUAccessType access_type, ARMMMUIdx mmu_= idx, + hwaddr *phys_ptr, int *prot, + ARMMMUFaultInfo *fi) +{ + int n; + uint32_t mask; + uint32_t base; + bool is_user =3D regime_is_user(env, mmu_idx); + + if (regime_translation_disabled(env, mmu_idx)) { + /* MPU disabled. */ + *phys_ptr =3D address; + *prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; + return false; + } + + *phys_ptr =3D address; + for (n =3D 7; n >=3D 0; n--) { + base =3D env->cp15.c6_region[n]; + if ((base & 1) =3D=3D 0) { + continue; + } + mask =3D 1 << ((base >> 1) & 0x1f); + /* Keep this shift separate from the above to avoid an + (undefined) << 32. */ + mask =3D (mask << 1) - 1; + if (((base ^ address) & ~mask) =3D=3D 0) { + break; + } + } + if (n < 0) { + fi->type =3D ARMFault_Background; + return true; + } + + if (access_type =3D=3D MMU_INST_FETCH) { + mask =3D env->cp15.pmsav5_insn_ap; + } else { + mask =3D env->cp15.pmsav5_data_ap; + } + mask =3D (mask >> (n * 4)) & 0xf; + switch (mask) { + case 0: + fi->type =3D ARMFault_Permission; + fi->level =3D 1; + return true; + case 1: + if (is_user) { + fi->type =3D ARMFault_Permission; + fi->level =3D 1; + return true; + } + *prot =3D PAGE_READ | PAGE_WRITE; + break; + case 2: + *prot =3D PAGE_READ; + if (!is_user) { + *prot |=3D PAGE_WRITE; + } + break; + case 3: + *prot =3D PAGE_READ | PAGE_WRITE; + break; + case 5: + if (is_user) { + fi->type =3D ARMFault_Permission; + fi->level =3D 1; + return true; + } + *prot =3D PAGE_READ; + break; + case 6: + *prot =3D PAGE_READ; + break; + default: + /* Bad permission. */ + fi->type =3D ARMFault_Permission; + fi->level =3D 1; + return true; + } + *prot |=3D PAGE_EXEC; + return false; +} + /** * get_phys_addr - get the physical address for this virtual address * --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654767815; cv=none; d=zohomail.com; s=zohoarc; b=H/yvl9OnoruC6aRhS08BrdvmbgyEyc643GNcheFN/ZuwAoXWXjnhyb/HOyOluGUZJ7cRBwhO44zkZ4uhemy5fDE5eeKW8GhO8pyrqxdZoz3HJjoznrQm3XmG8WRd2J951V7DRf/dgfcJ80j9lkAPFoO7EXtjgQeihcmvL66whu8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654767815; 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=llQtcWwNeSrJSmpF2SS5+s+znVWOvXUe+nYV4DkHFB4=; b=epGcy7pzJ6A0YavrYM81XiD/xqEElEOXaDOVNhmQnc0h/lEaO9pKu4gfQbh2lKC6FcqzMTQ3XysFbQq2gVjoXXCa8djSUs1CKOTgPGZgXoTNaWDfM6UvUPxqBQzlNDjt2Htu+kyEEuWzWdd2kYe9D5hE7vS45PCicSPUFnAKtrQ= 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 1654767815404135.71536912361807; Thu, 9 Jun 2022 02:43:35 -0700 (PDT) Received: from localhost ([::1]:57344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzEhR-0000aN-Lm for importer@patchew.org; Thu, 09 Jun 2022 05:43:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE73-0001UF-4s for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:57 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:44816) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE71-00060e-Fu for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:05:56 -0400 Received: by mail-wr1-x433.google.com with SMTP id q15so23422931wrc.11 for ; Thu, 09 Jun 2022 02:05:55 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.05.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=llQtcWwNeSrJSmpF2SS5+s+znVWOvXUe+nYV4DkHFB4=; b=tBALSHNWAyN9UYpJHD52j7m83ptiodFB7YAUi+majjleYBx3mPloAHpiukNoXNZPJb spNWz7uajzeqcgJYdEfTOgIJe5WLsact9HM/liGCOiiHo6PDviZGc46J5hpoUzUzT2/h uCCvpwdKia4VN0f8tROT0570M12xTMRfFZkpguB9oQ1WUX0pQ5yQzBJksLXafaT+NqlD IrydJyLhuxRIPPT2sww2LP2WVqN4JwXAtW1CdLFUzK6ZAVEMAjJEI3SbJH3HHmvkcTCp klhe23xK0WUHQcwaIYhfhjrZd+LjRnRunmMZUwKblR7IypuETdhcUJPczPxEeD1NYsLI gtbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=llQtcWwNeSrJSmpF2SS5+s+znVWOvXUe+nYV4DkHFB4=; b=Zfh+1oFesjhyhsgvNQg8K2zgHKVDOynKUdoKbKRgGXFscQijb5lJy6/zdxWK5eHBT5 tfIDuDLicUUg6asFEqT74jOQu6qotxtxzAKvKcP3LAQ1yByDBPcWcMMayyJbmvaWTCm0 3pz0Zpdyt2pFWs0rdy2D11aMehq69DmFvMKOKjXtedqaxUG4pPBjT0G4t2jqgcLSi8L4 55qDwT4PvX7k6iqbZe8yk3l2ubqSD6/y1Zp38iecIubEOmulfzpXnoruA8w4URnK4xdU qOU1OCG+Biu7/6t/waHWfZrRYgiQyLHvlnc4eA3x4QesSQS95WChhb30AsBm6CrtuG+T eMxQ== X-Gm-Message-State: AOAM5303z5aUc0D/bUCal6Tc2V4AnFWmVOfow7ZZcAacU5AtN7ypEgXu qx0Tfcxt1t0QrfACMv3cfIthSLVolQ8BJQ== X-Google-Smtp-Source: ABdhPJzV0wkaPPJUmyjRs64kd4mzzjZELuO38IdwzBp2MMzZ2rqK2m2ib2+LpnWZG8Pl37IYY/U2ww== X-Received: by 2002:a5d:64c7:0:b0:218:4a82:ffa4 with SMTP id f7-20020a5d64c7000000b002184a82ffa4mr15854122wri.592.1654765554687; Thu, 09 Jun 2022 02:05:54 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 13/55] target/arm: Move get_phys_addr_pmsav7_default to ptw.c Date: Thu, 9 Jun 2022 10:04:55 +0100 Message-Id: <20220609090537.1971756-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654767816451100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-7-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 3 +++ target/arm/helper.c | 41 ----------------------------------------- target/arm/ptw.c | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 41 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index 324a9dde140..d6e3fee1523 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -33,6 +33,9 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx,= int ap) return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); } =20 +void get_phys_addr_pmsav7_default(CPUARMState *env, + ARMMMUIdx mmu_idx, + int32_t address, int *prot); bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot, diff --git a/target/arm/helper.c b/target/arm/helper.c index 5d010190108..d4f7c05625c 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11678,47 +11678,6 @@ do_fault: return true; } =20 -static inline void get_phys_addr_pmsav7_default(CPUARMState *env, - ARMMMUIdx mmu_idx, - int32_t address, int *prot) -{ - if (!arm_feature(env, ARM_FEATURE_M)) { - *prot =3D PAGE_READ | PAGE_WRITE; - switch (address) { - case 0xF0000000 ... 0xFFFFFFFF: - if (regime_sctlr(env, mmu_idx) & SCTLR_V) { - /* hivecs execing is ok */ - *prot |=3D PAGE_EXEC; - } - break; - case 0x00000000 ... 0x7FFFFFFF: - *prot |=3D PAGE_EXEC; - break; - } - } else { - /* Default system address map for M profile cores. - * The architecture specifies which regions are execute-never; - * at the MPU level no other checks are defined. - */ - switch (address) { - case 0x00000000 ... 0x1fffffff: /* ROM */ - case 0x20000000 ... 0x3fffffff: /* SRAM */ - case 0x60000000 ... 0x7fffffff: /* RAM */ - case 0x80000000 ... 0x9fffffff: /* RAM */ - *prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; - break; - case 0x40000000 ... 0x5fffffff: /* Peripheral */ - case 0xa0000000 ... 0xbfffffff: /* Device */ - case 0xc0000000 ... 0xdfffffff: /* Device */ - case 0xe0000000 ... 0xffffffff: /* System */ - *prot =3D PAGE_READ | PAGE_WRITE; - break; - default: - g_assert_not_reached(); - } - } -} - static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, bool is_user) { diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 5c32648a16a..74650c6c525 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -374,6 +374,47 @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uin= t32_t address, return false; } =20 +void get_phys_addr_pmsav7_default(CPUARMState *env, + ARMMMUIdx mmu_idx, + int32_t address, int *prot) +{ + if (!arm_feature(env, ARM_FEATURE_M)) { + *prot =3D PAGE_READ | PAGE_WRITE; + switch (address) { + case 0xF0000000 ... 0xFFFFFFFF: + if (regime_sctlr(env, mmu_idx) & SCTLR_V) { + /* hivecs execing is ok */ + *prot |=3D PAGE_EXEC; + } + break; + case 0x00000000 ... 0x7FFFFFFF: + *prot |=3D PAGE_EXEC; + break; + } + } else { + /* Default system address map for M profile cores. + * The architecture specifies which regions are execute-never; + * at the MPU level no other checks are defined. + */ + switch (address) { + case 0x00000000 ... 0x1fffffff: /* ROM */ + case 0x20000000 ... 0x3fffffff: /* SRAM */ + case 0x60000000 ... 0x7fffffff: /* RAM */ + case 0x80000000 ... 0x9fffffff: /* RAM */ + *prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; + break; + case 0x40000000 ... 0x5fffffff: /* Peripheral */ + case 0xa0000000 ... 0xbfffffff: /* Device */ + case 0xc0000000 ... 0xdfffffff: /* Device */ + case 0xe0000000 ... 0xffffffff: /* System */ + *prot =3D PAGE_READ | PAGE_WRITE; + break; + default: + g_assert_not_reached(); + } + } +} + /** * get_phys_addr - get the physical address for this virtual address * --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654770251; cv=none; d=zohomail.com; s=zohoarc; b=ToK8LnqsQ2IWEoTT72wf7GOPap3ylNXS+Be8iQMYZKZZSk6L/Rk9uxlHIjea+x6ULSJw1/h+eyHCYKYJ+GTvVog8OJfIdF/3Pxr9RaKV1K3hYkk6EoK4gQytp8Yg7M6GpzD+y8fVAjb2qn7lkseyd5WR9R886c1FPjNyd50Ui0I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654770251; 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=0Ac7KbUehUrhXzsuRCDQnaYGhbdKNCku5Way9XfeMZo=; b=KA6lcXkLAC6ujsG9xS0tR9wTwxCgKQDMIi9T1EtPB15+5O2laosLXBYb5hZ1gaMPVScbMtAvk8/iAdkLpuCiz1z9wK1cg983yOTqvi5gjm4pCrrgffHyWhSZ4zvkNnb/fBXHrKCkzVFiuqE2ZedT68wPHJB0vIqPPHPRGn47SBc= 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 1654770251310624.6530146181611; Thu, 9 Jun 2022 03:24:11 -0700 (PDT) Received: from localhost ([::1]:42880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFKi-0006qM-Lm for importer@patchew.org; Thu, 09 Jun 2022 06:24:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE79-0001Xq-5M for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:08 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:43532) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE72-0005uZ-QU for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:02 -0400 Received: by mail-wm1-x333.google.com with SMTP id 67-20020a1c1946000000b00397382b44f4so12289092wmz.2 for ; Thu, 09 Jun 2022 02:05:56 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.05.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:05:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0Ac7KbUehUrhXzsuRCDQnaYGhbdKNCku5Way9XfeMZo=; b=R7KO9PzZ/pB0nd8inZoLEQw0ERb5LxGezHzFfZC361K6hTCLflUmg4fD5FVfWn5oQn Rlv5MXYBbC19BRz77vAefjOmI2fPAikzp97igxl79mxolXePWfiTZEZOdyHf4AWeQxI0 7YvXGOmoGSMID+qEXOEsiNdS0vZq3pvNj5fgl+8rvf/YIYcItSqhR+NS8t76VY2SbfK4 VwGw19Cp3R7VhAh3FLJf5hxEmQPkEizbsHeNSCFtpc6D8uuAM191XOhgGZvNZV5OjXyL RZRuYhRCyr8FAcdD8f8hBhKiO+rjDT9E2kQUMC0+h4wlGSqKi2Sgp16eATPb8lTx/kSX DMcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0Ac7KbUehUrhXzsuRCDQnaYGhbdKNCku5Way9XfeMZo=; b=XNWhLrXZTE7YlTCk6/bd0b27lDNDCLy6wz3QM3R/EIZtEB6r53B63Slh0b8ZuZrSOZ rF4/OGsrdn7Q0cXil5cpG5A8SCoxc0ltN+vv7MK7OuzRKDyu3SRqChO8DHkd++tHKDmg t0O0e/C9QnMivsmewIfztG0y9ei6I5wijDi7tDVCp4W2GbPvpxO8c++HHqQLrRxYPLLk LoGifJsCIBDVqdiQlGLmBbQg2sXYSAplaIQTdaZ3gsEZrJ7p2a59pbKswP9fvLg8UIvk rRJg3hnxkQcZ+IIUr+BcOpJ3s8/pM6lFHuC/+iBBapeE2zqTGc5qAZ20fAUcxJctRo0v 3jvw== X-Gm-Message-State: AOAM531P+3pvPzLxxzadFs8zZGuUXxO9JByQPfCJG3NSB30jUpvoMEWp xDNrjHmSUYRm3zfhjIesMOn97R4IV1lbFw== X-Google-Smtp-Source: ABdhPJz3UySPhzdxcLsmfx9li6RfoZObN/DYmaxiUxkUNt5V9WT/a4mTVg63Vik/GwkWMrbx73R2+A== X-Received: by 2002:a05:600c:3d1b:b0:39b:1743:4d84 with SMTP id bh27-20020a05600c3d1b00b0039b17434d84mr2231723wmb.118.1654765555993; Thu, 09 Jun 2022 02:05:55 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 14/55] target/arm: Move get_phys_addr_pmsav7 to ptw.c Date: Thu, 9 Jun 2022 10:04:56 +0100 Message-Id: <20220609090537.1971756-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654770253117100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-8-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 10 +-- target/arm/helper.c | 194 +------------------------------------------- target/arm/ptw.c | 190 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 198 insertions(+), 196 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index d6e3fee1523..d24b7c263a8 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -33,14 +33,14 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_id= x, int ap) return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); } =20 +bool m_is_ppb_region(CPUARMState *env, uint32_t address); +bool m_is_system_region(CPUARMState *env, uint32_t address); + void get_phys_addr_pmsav7_default(CPUARMState *env, ARMMMUIdx mmu_idx, int32_t address, int *prot); -bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - hwaddr *phys_ptr, int *prot, - target_ulong *page_size, - ARMMMUFaultInfo *fi); +bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, bool is_= user); + bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, MemTxAttrs *txattrs, diff --git a/target/arm/helper.c b/target/arm/helper.c index d4f7c05625c..2ebaf694075 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11678,8 +11678,7 @@ do_fault: return true; } =20 -static bool pmsav7_use_background_region(ARMCPU *cpu, - ARMMMUIdx mmu_idx, bool is_user) +bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, bool is_= user) { /* Return true if we should use the default memory map as a * "background" region if there are no hits against any MPU regions. @@ -11698,14 +11697,14 @@ static bool pmsav7_use_background_region(ARMCPU *= cpu, } } =20 -static inline bool m_is_ppb_region(CPUARMState *env, uint32_t address) +bool m_is_ppb_region(CPUARMState *env, uint32_t address) { /* True if address is in the M profile PPB region 0xe0000000 - 0xe00ff= fff */ return arm_feature(env, ARM_FEATURE_M) && extract32(address, 20, 12) =3D=3D 0xe00; } =20 -static inline bool m_is_system_region(CPUARMState *env, uint32_t address) +bool m_is_system_region(CPUARMState *env, uint32_t address) { /* True if address is in the M profile system region * 0xe0000000 - 0xffffffff @@ -11713,193 +11712,6 @@ static inline bool m_is_system_region(CPUARMState= *env, uint32_t address) return arm_feature(env, ARM_FEATURE_M) && extract32(address, 29, 3) = =3D=3D 0x7; } =20 -bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - hwaddr *phys_ptr, int *prot, - target_ulong *page_size, - ARMMMUFaultInfo *fi) -{ - ARMCPU *cpu =3D env_archcpu(env); - int n; - bool is_user =3D regime_is_user(env, mmu_idx); - - *phys_ptr =3D address; - *page_size =3D TARGET_PAGE_SIZE; - *prot =3D 0; - - if (regime_translation_disabled(env, mmu_idx) || - m_is_ppb_region(env, address)) { - /* MPU disabled or M profile PPB access: use default memory map. - * The other case which uses the default memory map in the - * v7M ARM ARM pseudocode is exception vector reads from the vector - * table. In QEMU those accesses are done in arm_v7m_load_vector(), - * which always does a direct read using address_space_ldl(), rath= er - * than going via this function, so we don't need to check that he= re. - */ - get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); - } else { /* MPU enabled */ - for (n =3D (int)cpu->pmsav7_dregion - 1; n >=3D 0; n--) { - /* region search */ - uint32_t base =3D env->pmsav7.drbar[n]; - uint32_t rsize =3D extract32(env->pmsav7.drsr[n], 1, 5); - uint32_t rmask; - bool srdis =3D false; - - if (!(env->pmsav7.drsr[n] & 0x1)) { - continue; - } - - if (!rsize) { - qemu_log_mask(LOG_GUEST_ERROR, - "DRSR[%d]: Rsize field cannot be 0\n", n); - continue; - } - rsize++; - rmask =3D (1ull << rsize) - 1; - - if (base & rmask) { - qemu_log_mask(LOG_GUEST_ERROR, - "DRBAR[%d]: 0x%" PRIx32 " misaligned " - "to DRSR region size, mask =3D 0x%" PRIx32 "= \n", - n, base, rmask); - continue; - } - - if (address < base || address > base + rmask) { - /* - * Address not in this region. We must check whether the - * region covers addresses in the same page as our address. - * In that case we must not report a size that covers the - * whole page for a subsequent hit against a different MPU - * region or the background region, because it would resul= t in - * incorrect TLB hits for subsequent accesses to addresses= that - * are in this MPU region. - */ - if (ranges_overlap(base, rmask, - address & TARGET_PAGE_MASK, - TARGET_PAGE_SIZE)) { - *page_size =3D 1; - } - continue; - } - - /* Region matched */ - - if (rsize >=3D 8) { /* no subregions for regions < 256 bytes */ - int i, snd; - uint32_t srdis_mask; - - rsize -=3D 3; /* sub region size (power of 2) */ - snd =3D ((address - base) >> rsize) & 0x7; - srdis =3D extract32(env->pmsav7.drsr[n], snd + 8, 1); - - srdis_mask =3D srdis ? 0x3 : 0x0; - for (i =3D 2; i <=3D 8 && rsize < TARGET_PAGE_BITS; i *=3D= 2) { - /* This will check in groups of 2, 4 and then 8, wheth= er - * the subregion bits are consistent. rsize is increme= nted - * back up to give the region size, considering consis= tent - * adjacent subregions as one region. Stop testing if = rsize - * is already big enough for an entire QEMU page. - */ - int snd_rounded =3D snd & ~(i - 1); - uint32_t srdis_multi =3D extract32(env->pmsav7.drsr[n], - snd_rounded + 8, i); - if (srdis_mask ^ srdis_multi) { - break; - } - srdis_mask =3D (srdis_mask << i) | srdis_mask; - rsize++; - } - } - if (srdis) { - continue; - } - if (rsize < TARGET_PAGE_BITS) { - *page_size =3D 1 << rsize; - } - break; - } - - if (n =3D=3D -1) { /* no hits */ - if (!pmsav7_use_background_region(cpu, mmu_idx, is_user)) { - /* background fault */ - fi->type =3D ARMFault_Background; - return true; - } - get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); - } else { /* a MPU hit! */ - uint32_t ap =3D extract32(env->pmsav7.dracr[n], 8, 3); - uint32_t xn =3D extract32(env->pmsav7.dracr[n], 12, 1); - - if (m_is_system_region(env, address)) { - /* System space is always execute never */ - xn =3D 1; - } - - if (is_user) { /* User mode AP bit decoding */ - switch (ap) { - case 0: - case 1: - case 5: - break; /* no access */ - case 3: - *prot |=3D PAGE_WRITE; - /* fall through */ - case 2: - case 6: - *prot |=3D PAGE_READ | PAGE_EXEC; - break; - case 7: - /* for v7M, same as 6; for R profile a reserved value = */ - if (arm_feature(env, ARM_FEATURE_M)) { - *prot |=3D PAGE_READ | PAGE_EXEC; - break; - } - /* fall through */ - default: - qemu_log_mask(LOG_GUEST_ERROR, - "DRACR[%d]: Bad value for AP bits: 0x%" - PRIx32 "\n", n, ap); - } - } else { /* Priv. mode AP bits decoding */ - switch (ap) { - case 0: - break; /* no access */ - case 1: - case 2: - case 3: - *prot |=3D PAGE_WRITE; - /* fall through */ - case 5: - case 6: - *prot |=3D PAGE_READ | PAGE_EXEC; - break; - case 7: - /* for v7M, same as 6; for R profile a reserved value = */ - if (arm_feature(env, ARM_FEATURE_M)) { - *prot |=3D PAGE_READ | PAGE_EXEC; - break; - } - /* fall through */ - default: - qemu_log_mask(LOG_GUEST_ERROR, - "DRACR[%d]: Bad value for AP bits: 0x%" - PRIx32 "\n", n, ap); - } - } - - /* execute never */ - if (xn) { - *prot &=3D ~PAGE_EXEC; - } - } - } - - fi->type =3D ARMFault_Permission; - fi->level =3D 1; - return !(*prot & (1 << access_type)); -} - static bool v8m_is_sau_exempt(CPUARMState *env, uint32_t address, MMUAccessType access_type) { diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 74650c6c525..27715dbfa8c 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -8,6 +8,7 @@ =20 #include "qemu/osdep.h" #include "qemu/log.h" +#include "qemu/range.h" #include "cpu.h" #include "internals.h" #include "ptw.h" @@ -415,6 +416,195 @@ void get_phys_addr_pmsav7_default(CPUARMState *env, } } =20 +static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, + MMUAccessType access_type, ARMMMUIdx mmu_= idx, + hwaddr *phys_ptr, int *prot, + target_ulong *page_size, + ARMMMUFaultInfo *fi) +{ + ARMCPU *cpu =3D env_archcpu(env); + int n; + bool is_user =3D regime_is_user(env, mmu_idx); + + *phys_ptr =3D address; + *page_size =3D TARGET_PAGE_SIZE; + *prot =3D 0; + + if (regime_translation_disabled(env, mmu_idx) || + m_is_ppb_region(env, address)) { + /* + * MPU disabled or M profile PPB access: use default memory map. + * The other case which uses the default memory map in the + * v7M ARM ARM pseudocode is exception vector reads from the vector + * table. In QEMU those accesses are done in arm_v7m_load_vector(), + * which always does a direct read using address_space_ldl(), rath= er + * than going via this function, so we don't need to check that he= re. + */ + get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); + } else { /* MPU enabled */ + for (n =3D (int)cpu->pmsav7_dregion - 1; n >=3D 0; n--) { + /* region search */ + uint32_t base =3D env->pmsav7.drbar[n]; + uint32_t rsize =3D extract32(env->pmsav7.drsr[n], 1, 5); + uint32_t rmask; + bool srdis =3D false; + + if (!(env->pmsav7.drsr[n] & 0x1)) { + continue; + } + + if (!rsize) { + qemu_log_mask(LOG_GUEST_ERROR, + "DRSR[%d]: Rsize field cannot be 0\n", n); + continue; + } + rsize++; + rmask =3D (1ull << rsize) - 1; + + if (base & rmask) { + qemu_log_mask(LOG_GUEST_ERROR, + "DRBAR[%d]: 0x%" PRIx32 " misaligned " + "to DRSR region size, mask =3D 0x%" PRIx32 "= \n", + n, base, rmask); + continue; + } + + if (address < base || address > base + rmask) { + /* + * Address not in this region. We must check whether the + * region covers addresses in the same page as our address. + * In that case we must not report a size that covers the + * whole page for a subsequent hit against a different MPU + * region or the background region, because it would resul= t in + * incorrect TLB hits for subsequent accesses to addresses= that + * are in this MPU region. + */ + if (ranges_overlap(base, rmask, + address & TARGET_PAGE_MASK, + TARGET_PAGE_SIZE)) { + *page_size =3D 1; + } + continue; + } + + /* Region matched */ + + if (rsize >=3D 8) { /* no subregions for regions < 256 bytes */ + int i, snd; + uint32_t srdis_mask; + + rsize -=3D 3; /* sub region size (power of 2) */ + snd =3D ((address - base) >> rsize) & 0x7; + srdis =3D extract32(env->pmsav7.drsr[n], snd + 8, 1); + + srdis_mask =3D srdis ? 0x3 : 0x0; + for (i =3D 2; i <=3D 8 && rsize < TARGET_PAGE_BITS; i *=3D= 2) { + /* + * This will check in groups of 2, 4 and then 8, wheth= er + * the subregion bits are consistent. rsize is increme= nted + * back up to give the region size, considering consis= tent + * adjacent subregions as one region. Stop testing if = rsize + * is already big enough for an entire QEMU page. + */ + int snd_rounded =3D snd & ~(i - 1); + uint32_t srdis_multi =3D extract32(env->pmsav7.drsr[n], + snd_rounded + 8, i); + if (srdis_mask ^ srdis_multi) { + break; + } + srdis_mask =3D (srdis_mask << i) | srdis_mask; + rsize++; + } + } + if (srdis) { + continue; + } + if (rsize < TARGET_PAGE_BITS) { + *page_size =3D 1 << rsize; + } + break; + } + + if (n =3D=3D -1) { /* no hits */ + if (!pmsav7_use_background_region(cpu, mmu_idx, is_user)) { + /* background fault */ + fi->type =3D ARMFault_Background; + return true; + } + get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); + } else { /* a MPU hit! */ + uint32_t ap =3D extract32(env->pmsav7.dracr[n], 8, 3); + uint32_t xn =3D extract32(env->pmsav7.dracr[n], 12, 1); + + if (m_is_system_region(env, address)) { + /* System space is always execute never */ + xn =3D 1; + } + + if (is_user) { /* User mode AP bit decoding */ + switch (ap) { + case 0: + case 1: + case 5: + break; /* no access */ + case 3: + *prot |=3D PAGE_WRITE; + /* fall through */ + case 2: + case 6: + *prot |=3D PAGE_READ | PAGE_EXEC; + break; + case 7: + /* for v7M, same as 6; for R profile a reserved value = */ + if (arm_feature(env, ARM_FEATURE_M)) { + *prot |=3D PAGE_READ | PAGE_EXEC; + break; + } + /* fall through */ + default: + qemu_log_mask(LOG_GUEST_ERROR, + "DRACR[%d]: Bad value for AP bits: 0x%" + PRIx32 "\n", n, ap); + } + } else { /* Priv. mode AP bits decoding */ + switch (ap) { + case 0: + break; /* no access */ + case 1: + case 2: + case 3: + *prot |=3D PAGE_WRITE; + /* fall through */ + case 5: + case 6: + *prot |=3D PAGE_READ | PAGE_EXEC; + break; + case 7: + /* for v7M, same as 6; for R profile a reserved value = */ + if (arm_feature(env, ARM_FEATURE_M)) { + *prot |=3D PAGE_READ | PAGE_EXEC; + break; + } + /* fall through */ + default: + qemu_log_mask(LOG_GUEST_ERROR, + "DRACR[%d]: Bad value for AP bits: 0x%" + PRIx32 "\n", n, ap); + } + } + + /* execute never */ + if (xn) { + *prot &=3D ~PAGE_EXEC; + } + } + } + + fi->type =3D ARMFault_Permission; + fi->level =3D 1; + return !(*prot & (1 << access_type)); +} + /** * get_phys_addr - get the physical address for this virtual address * --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654767519; cv=none; d=zohomail.com; s=zohoarc; b=cdVur/ghRjlt0PlAtsUTnjbESYbZw2yKP8fNIBLD5brcjA4bYnXL5b4HU80PsHxX05nyMupWRjOQ3JhhkzXCElSS8xYp+adAglh6m343LI9rDeqLgCFztAG/TbvGDz+2KpAL4h52S62qzF3YtcBOqwxuSNxDXzSa6r1CmOPNjJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654767519; 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=0CrroLgAVXvSasQsUTUPnEeQd/AepQTm/OwhtRxFesc=; b=E7UyS/kpg6ynPEPd7eaPEMHgQb96wMpvm8yi6GQpKIN3jHjzPbsXV0h9oDuud/K1wsZjpo2o+0P3TR1Gaz6a961u22+VMelSILQdoebEyb1pkTEM6iGDZ/TRpl9TuB2pmZIJOvlLSoAdIMwXv7Y65BRrLhrlpSs9Em18jthpNBE= 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 1654767518970271.39940826560996; Thu, 9 Jun 2022 02:38:38 -0700 (PDT) Received: from localhost ([::1]:54186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzEce-0006jL-AE for importer@patchew.org; Thu, 09 Jun 2022 05:38:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE77-0001X7-3o for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:01 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:33250) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE75-000620-2C for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:00 -0400 Received: by mail-wm1-x335.google.com with SMTP id i17-20020a7bc951000000b0039c4760ec3fso594191wml.0 for ; Thu, 09 Jun 2022 02:05:58 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.05.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:05:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0CrroLgAVXvSasQsUTUPnEeQd/AepQTm/OwhtRxFesc=; b=oS8y6H0wz3miCZrehSvpsKh3E4CCBENGX9eKT4jV7y9XYRXYC1sFicKCHV6dDEirAL ZJGnUABEGeEkp+qysASvYMPtU7xR9w1lubLNvIuyUPO87abBD/NWxFrT+cCj2P6C6utE Z3edGgRmyDGfnOVoB+sEBfmlTpyHJCNCAt+A9MjPUQ3OL6lns1UTCUJu34FgvVlYiF+o WslEjfFr3k5YNcQvpHH2730M0E1Cey4r0k09Vn+VkuqBE93MTF9YogMlZsA7OZ4gkw9k c+BtND+LWBc2bJENbkJ+vyVKYm8kUtkqtpmNQU02fTqGMKit00vr+qkIgbXo4D9uAvud zbgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0CrroLgAVXvSasQsUTUPnEeQd/AepQTm/OwhtRxFesc=; b=YYiurH1qabR7SnBlRqTy/eMYJPaofvaAPFDwws1ezD/LA1e/YsVO7ALL08pjXc3T45 vrD0pEMZATsZ5sk3dthkuRnPVxKf7U0h/yuiIBLjxwKZcQK8sLSz3n5J3xvah1Jbzyi+ VumRqYEYhJKo4k2SeRkAdn5oLhMejsnDs0JTnZU8PvO2gszTU0j4AZi2FVbGVsQRh4Eb U4GCjPVSNBfJcwcKWFO7ENI8UoT+Kh3DpEx7TSHZREEy8tkZ/EIKxRGWed9e457u7Dts Lj/XbMOjQrNaatzX1Mz816MuVFisOe7+NWc8mclicqULB9Z8XGam6qfN+c7Nevz0eEku 3sew== X-Gm-Message-State: AOAM531xN9gfJ4iy9rV9Dt68JjcYVQccfDsQSwupfceI7RcMd7310fi1 DtdhpCsvamXsjKFOuIVTM9nuJWbqWZ6pUg== X-Google-Smtp-Source: ABdhPJxni+gpUdmoVG6s5OaQCDXxFwS8n+Zfo/UBActphgoLn90rT7c1OgtjGBQmpF0CnV7KuU99CQ== X-Received: by 2002:a7b:c04b:0:b0:39c:511e:2dd4 with SMTP id u11-20020a7bc04b000000b0039c511e2dd4mr2366777wmc.58.1654765557402; Thu, 09 Jun 2022 02:05:57 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 15/55] target/arm: Move get_phys_addr_pmsav8 to ptw.c Date: Thu, 9 Jun 2022 10:04:57 +0100 Message-Id: <20220609090537.1971756-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654767520821100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-9-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 5 --- target/arm/helper.c | 75 ------------------------------------------- target/arm/ptw.c | 77 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 80 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index d24b7c263a8..d569507951f 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -41,11 +41,6 @@ void get_phys_addr_pmsav7_default(CPUARMState *env, int32_t address, int *prot); bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, bool is_= user); =20 -bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - hwaddr *phys_ptr, MemTxAttrs *txattrs, - int *prot, target_ulong *page_size, - ARMMMUFaultInfo *fi); bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, bool s1_is_el0, diff --git a/target/arm/helper.c b/target/arm/helper.c index 2ebaf694075..44997fd179d 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11970,81 +11970,6 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t = address, return !(*prot & (1 << access_type)); } =20 - -bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - hwaddr *phys_ptr, MemTxAttrs *txattrs, - int *prot, target_ulong *page_size, - ARMMMUFaultInfo *fi) -{ - uint32_t secure =3D regime_is_secure(env, mmu_idx); - V8M_SAttributes sattrs =3D {}; - bool ret; - bool mpu_is_subpage; - - if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { - v8m_security_lookup(env, address, access_type, mmu_idx, &sattrs); - if (access_type =3D=3D MMU_INST_FETCH) { - /* Instruction fetches always use the MMU bank and the - * transaction attribute determined by the fetch address, - * regardless of CPU state. This is painful for QEMU - * to handle, because it would mean we need to encode - * into the mmu_idx not just the (user, negpri) information - * for the current security state but also that for the - * other security state, which would balloon the number - * of mmu_idx values needed alarmingly. - * Fortunately we can avoid this because it's not actually - * possible to arbitrarily execute code from memory with - * the wrong security attribute: it will always generate - * an exception of some kind or another, apart from the - * special case of an NS CPU executing an SG instruction - * in S&NSC memory. So we always just fail the translation - * here and sort things out in the exception handler - * (including possibly emulating an SG instruction). - */ - if (sattrs.ns !=3D !secure) { - if (sattrs.nsc) { - fi->type =3D ARMFault_QEMU_NSCExec; - } else { - fi->type =3D ARMFault_QEMU_SFault; - } - *page_size =3D sattrs.subpage ? 1 : TARGET_PAGE_SIZE; - *phys_ptr =3D address; - *prot =3D 0; - return true; - } - } else { - /* For data accesses we always use the MMU bank indicated - * by the current CPU state, but the security attributes - * might downgrade a secure access to nonsecure. - */ - if (sattrs.ns) { - txattrs->secure =3D false; - } else if (!secure) { - /* NS access to S memory must fault. - * Architecturally we should first check whether the - * MPU information for this address indicates that we - * are doing an unaligned access to Device memory, which - * should generate a UsageFault instead. QEMU does not - * currently check for that kind of unaligned access thoug= h. - * If we added it we would need to do so as a special case - * for M_FAKE_FSR_SFAULT in arm_v7m_cpu_do_interrupt(). - */ - fi->type =3D ARMFault_QEMU_SFault; - *page_size =3D sattrs.subpage ? 1 : TARGET_PAGE_SIZE; - *phys_ptr =3D address; - *prot =3D 0; - return true; - } - } - } - - ret =3D pmsav8_mpu_lookup(env, address, access_type, mmu_idx, phys_ptr, - txattrs, prot, &mpu_is_subpage, fi, NULL); - *page_size =3D sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE; - return ret; -} - /* Combine either inner or outer cacheability attributes for normal * memory, according to table D4-42 and pseudocode procedure * CombineS1S2AttrHints() of ARM DDI 0487B.b (the ARMv8 ARM). diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 27715dbfa8c..28caa7a7ae0 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -605,6 +605,83 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uin= t32_t address, return !(*prot & (1 << access_type)); } =20 +static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, + MMUAccessType access_type, ARMMMUIdx mmu_= idx, + hwaddr *phys_ptr, MemTxAttrs *txattrs, + int *prot, target_ulong *page_size, + ARMMMUFaultInfo *fi) +{ + uint32_t secure =3D regime_is_secure(env, mmu_idx); + V8M_SAttributes sattrs =3D {}; + bool ret; + bool mpu_is_subpage; + + if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { + v8m_security_lookup(env, address, access_type, mmu_idx, &sattrs); + if (access_type =3D=3D MMU_INST_FETCH) { + /* + * Instruction fetches always use the MMU bank and the + * transaction attribute determined by the fetch address, + * regardless of CPU state. This is painful for QEMU + * to handle, because it would mean we need to encode + * into the mmu_idx not just the (user, negpri) information + * for the current security state but also that for the + * other security state, which would balloon the number + * of mmu_idx values needed alarmingly. + * Fortunately we can avoid this because it's not actually + * possible to arbitrarily execute code from memory with + * the wrong security attribute: it will always generate + * an exception of some kind or another, apart from the + * special case of an NS CPU executing an SG instruction + * in S&NSC memory. So we always just fail the translation + * here and sort things out in the exception handler + * (including possibly emulating an SG instruction). + */ + if (sattrs.ns !=3D !secure) { + if (sattrs.nsc) { + fi->type =3D ARMFault_QEMU_NSCExec; + } else { + fi->type =3D ARMFault_QEMU_SFault; + } + *page_size =3D sattrs.subpage ? 1 : TARGET_PAGE_SIZE; + *phys_ptr =3D address; + *prot =3D 0; + return true; + } + } else { + /* + * For data accesses we always use the MMU bank indicated + * by the current CPU state, but the security attributes + * might downgrade a secure access to nonsecure. + */ + if (sattrs.ns) { + txattrs->secure =3D false; + } else if (!secure) { + /* + * NS access to S memory must fault. + * Architecturally we should first check whether the + * MPU information for this address indicates that we + * are doing an unaligned access to Device memory, which + * should generate a UsageFault instead. QEMU does not + * currently check for that kind of unaligned access thoug= h. + * If we added it we would need to do so as a special case + * for M_FAKE_FSR_SFAULT in arm_v7m_cpu_do_interrupt(). + */ + fi->type =3D ARMFault_QEMU_SFault; + *page_size =3D sattrs.subpage ? 1 : TARGET_PAGE_SIZE; + *phys_ptr =3D address; + *prot =3D 0; + return true; + } + } + } + + ret =3D pmsav8_mpu_lookup(env, address, access_type, mmu_idx, phys_ptr, + txattrs, prot, &mpu_is_subpage, fi, NULL); + *page_size =3D sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE; + return ret; +} + /** * get_phys_addr - get the physical address for this virtual address * --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654769241; cv=none; d=zohomail.com; s=zohoarc; b=CeWN0W579thVsXfmg0G2SPAs+YrFV7pqn2KY6l1+prv94cSKLyT8pFnn268aWC4MKZsbDyutwme9vQS1siafO1340f2pWL8Dyu3vC4W3RkpuZSmvZx+FKArs817pHb70TVQtb6IgCqpj3fybfRpwsA6VnD5N7zc8UOCl783cqJQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654769241; 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=7p331RrRhxlmCYz1Fu61IkjHxiG1EXhXcEiGzFLN0kw=; b=ecmR5N9zpWbOnlmTnRNguY+GqA8GYboz1vKaq0cNg5ea8VzqCxLDtowH/Spk9PHLoqOxxMwfYTcH4hSLTUjrUrmii9n8kLoHs06EZj9ovbbfsVDFQ7XGqzcgetirtDl0/dbNravDB7TM2z5Xl8ENh5OCMy+sVEvMw4UIFOW3Cns= 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 1654769240993120.21089054665345; Thu, 9 Jun 2022 03:07:20 -0700 (PDT) Received: from localhost ([::1]:54308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzF4R-0002c8-R7 for importer@patchew.org; Thu, 09 Jun 2022 06:07:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE77-0001XE-Ko for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:01 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:34742) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE75-0005zr-Fk for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:01 -0400 Received: by mail-wr1-x42b.google.com with SMTP id q26so21096176wra.1 for ; Thu, 09 Jun 2022 02:05:59 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.05.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:05:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=7p331RrRhxlmCYz1Fu61IkjHxiG1EXhXcEiGzFLN0kw=; b=Nzac9gLVaxxc32tKrtQRJAZuVDIlh9ntgDd7nqzjeEZGkyB3+ttOeAzGG0C0KS8Fku uZHHp35VMOXdSQpOzFmKThuy7hip9G2q+91v29aIF5WY+1CNviyEMy43+O8lGcihvi+Z DRQwJLFknxYYjC/LmP4t6P5Fa3r27PPNXZ6k2S+EmAdFKRcAHMeqcTmjmfYCr+HuuUqp BsSuu6aInbx8xqVdQl4sMCoCRLmCYYWSHgI1Xnt2c/BFZ1Ce/driy9R1DbRzjehma6L8 n08XOq9DGzM6s6MB5F4SfQMDT9YsyeTnxslgrDHms4d0OH9Z/DVNTjS1c95fhxZvehxz naew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7p331RrRhxlmCYz1Fu61IkjHxiG1EXhXcEiGzFLN0kw=; b=r+Dnfm/BX7Diqz9uDfpoKLglXnpO4Odh/5MkgcV1sW8k394fQ6lKJt4MVOiHWL0enV 2DHH/TLmR+9PeWTEZZUPXMPukiOvECrQgwpBjC92GbRcRiTNRC0TMsN3fgle5ksXzE4Q GihwMMav+iXnKzOL17ke9SlfoNX0i9tYBe8aYUH97PBcrY7SV0DsHo/FOadUabBaTlHb c71eqB5BfYDhLqEIScrJBnMPx2I3E0nD1UBPhHZOEMkuQwIw/T/Gd4dTMeLzOqqSo4VF QioSYYbrdqDIqmMYBFvX1qrWU39TJuiDwZW6z4jLIZBVTsVumuT5rkSGBvzUwZfYja5n ihBw== X-Gm-Message-State: AOAM531F66Yceor/PpQSmUrNPlIq+dASWxUbGw5kf+COxQKP6oBs6nNK H/ZSZFK02ZcP2rmrd8l7OF5tK6mslnMg/w== X-Google-Smtp-Source: ABdhPJz02w52zl0UOdN5/7nLDCCMXdlPXy2br+xLzrJMPjkLfDil+JbQblmFgV/f/++LP9uviOq+lQ== X-Received: by 2002:a5d:67c2:0:b0:215:7a0f:71f9 with SMTP id n2-20020a5d67c2000000b002157a0f71f9mr30972761wrw.486.1654765558598; Thu, 09 Jun 2022 02:05:58 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 16/55] target/arm: Move pmsav8_mpu_lookup to ptw.c Date: Thu, 9 Jun 2022 10:04:58 +0100 Message-Id: <20220609090537.1971756-17-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::42b; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42b.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654769241420100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson This is the final user of get_phys_addr_pmsav7_default within helper.c, so make it static within ptw.c. Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-10-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 3 - target/arm/helper.c | 136 ----------------------------------------- target/arm/ptw.c | 146 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 143 insertions(+), 142 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index d569507951f..8d2e2397147 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -36,9 +36,6 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx,= int ap) bool m_is_ppb_region(CPUARMState *env, uint32_t address); bool m_is_system_region(CPUARMState *env, uint32_t address); =20 -void get_phys_addr_pmsav7_default(CPUARMState *env, - ARMMMUIdx mmu_idx, - int32_t address, int *prot); bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, bool is_= user); =20 bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, diff --git a/target/arm/helper.c b/target/arm/helper.c index 44997fd179d..cb23413d8e5 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11834,142 +11834,6 @@ void v8m_security_lookup(CPUARMState *env, uint32= _t address, } } =20 -bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - hwaddr *phys_ptr, MemTxAttrs *txattrs, - int *prot, bool *is_subpage, - ARMMMUFaultInfo *fi, uint32_t *mregion) -{ - /* Perform a PMSAv8 MPU lookup (without also doing the SAU check - * that a full phys-to-virt translation does). - * mregion is (if not NULL) set to the region number which matched, - * or -1 if no region number is returned (MPU off, address did not - * hit a region, address hit in multiple regions). - * We set is_subpage to true if the region hit doesn't cover the - * entire TARGET_PAGE the address is within. - */ - ARMCPU *cpu =3D env_archcpu(env); - bool is_user =3D regime_is_user(env, mmu_idx); - uint32_t secure =3D regime_is_secure(env, mmu_idx); - int n; - int matchregion =3D -1; - bool hit =3D false; - uint32_t addr_page_base =3D address & TARGET_PAGE_MASK; - uint32_t addr_page_limit =3D addr_page_base + (TARGET_PAGE_SIZE - 1); - - *is_subpage =3D false; - *phys_ptr =3D address; - *prot =3D 0; - if (mregion) { - *mregion =3D -1; - } - - /* Unlike the ARM ARM pseudocode, we don't need to check whether this - * was an exception vector read from the vector table (which is always - * done using the default system address map), because those accesses - * 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)) { /* MPU disabled */ - hit =3D true; - } else if (m_is_ppb_region(env, address)) { - hit =3D true; - } else { - if (pmsav7_use_background_region(cpu, mmu_idx, is_user)) { - hit =3D true; - } - - for (n =3D (int)cpu->pmsav7_dregion - 1; n >=3D 0; n--) { - /* region search */ - /* Note that the base address is bits [31:5] from the register - * with bits [4:0] all zeroes, but the limit address is bits - * [31:5] from the register with bits [4:0] all ones. - */ - uint32_t base =3D env->pmsav8.rbar[secure][n] & ~0x1f; - uint32_t limit =3D env->pmsav8.rlar[secure][n] | 0x1f; - - if (!(env->pmsav8.rlar[secure][n] & 0x1)) { - /* Region disabled */ - continue; - } - - if (address < base || address > limit) { - /* - * Address not in this region. We must check whether the - * region covers addresses in the same page as our address. - * In that case we must not report a size that covers the - * whole page for a subsequent hit against a different MPU - * region or the background region, because it would resul= t in - * incorrect TLB hits for subsequent accesses to addresses= that - * are in this MPU region. - */ - if (limit >=3D base && - ranges_overlap(base, limit - base + 1, - addr_page_base, - TARGET_PAGE_SIZE)) { - *is_subpage =3D true; - } - continue; - } - - if (base > addr_page_base || limit < addr_page_limit) { - *is_subpage =3D true; - } - - if (matchregion !=3D -1) { - /* Multiple regions match -- always a failure (unlike - * PMSAv7 where highest-numbered-region wins) - */ - fi->type =3D ARMFault_Permission; - fi->level =3D 1; - return true; - } - - matchregion =3D n; - hit =3D true; - } - } - - if (!hit) { - /* background fault */ - fi->type =3D ARMFault_Background; - return true; - } - - if (matchregion =3D=3D -1) { - /* hit using the background region */ - get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); - } else { - uint32_t ap =3D extract32(env->pmsav8.rbar[secure][matchregion], 1= , 2); - uint32_t xn =3D extract32(env->pmsav8.rbar[secure][matchregion], 0= , 1); - bool pxn =3D false; - - if (arm_feature(env, ARM_FEATURE_V8_1M)) { - pxn =3D extract32(env->pmsav8.rlar[secure][matchregion], 4, 1); - } - - if (m_is_system_region(env, address)) { - /* System space is always execute never */ - xn =3D 1; - } - - *prot =3D simple_ap_to_rw_prot(env, mmu_idx, ap); - if (*prot && !xn && !(pxn && !is_user)) { - *prot |=3D PAGE_EXEC; - } - /* We don't need to look the attribute up in the MAIR0/MAIR1 - * registers because that only tells us about cacheability. - */ - if (mregion) { - *mregion =3D matchregion; - } - } - - fi->type =3D ARMFault_Permission; - fi->level =3D 1; - return !(*prot & (1 << access_type)); -} - /* Combine either inner or outer cacheability attributes for normal * memory, according to table D4-42 and pseudocode procedure * CombineS1S2AttrHints() of ARM DDI 0487B.b (the ARMv8 ARM). diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 28caa7a7ae0..989e783cce9 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -375,9 +375,8 @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint= 32_t address, return false; } =20 -void get_phys_addr_pmsav7_default(CPUARMState *env, - ARMMMUIdx mmu_idx, - int32_t address, int *prot) +static void get_phys_addr_pmsav7_default(CPUARMState *env, ARMMMUIdx mmu_i= dx, + int32_t address, int *prot) { if (!arm_feature(env, ARM_FEATURE_M)) { *prot =3D PAGE_READ | PAGE_WRITE; @@ -605,6 +604,147 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, ui= nt32_t address, return !(*prot & (1 << access_type)); } =20 +bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, + MMUAccessType access_type, ARMMMUIdx mmu_idx, + hwaddr *phys_ptr, MemTxAttrs *txattrs, + int *prot, bool *is_subpage, + ARMMMUFaultInfo *fi, uint32_t *mregion) +{ + /* + * Perform a PMSAv8 MPU lookup (without also doing the SAU check + * that a full phys-to-virt translation does). + * mregion is (if not NULL) set to the region number which matched, + * or -1 if no region number is returned (MPU off, address did not + * hit a region, address hit in multiple regions). + * We set is_subpage to true if the region hit doesn't cover the + * entire TARGET_PAGE the address is within. + */ + ARMCPU *cpu =3D env_archcpu(env); + bool is_user =3D regime_is_user(env, mmu_idx); + uint32_t secure =3D regime_is_secure(env, mmu_idx); + int n; + int matchregion =3D -1; + bool hit =3D false; + uint32_t addr_page_base =3D address & TARGET_PAGE_MASK; + uint32_t addr_page_limit =3D addr_page_base + (TARGET_PAGE_SIZE - 1); + + *is_subpage =3D false; + *phys_ptr =3D address; + *prot =3D 0; + if (mregion) { + *mregion =3D -1; + } + + /* + * Unlike the ARM ARM pseudocode, we don't need to check whether this + * was an exception vector read from the vector table (which is always + * done using the default system address map), because those accesses + * 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)) { /* MPU disabled */ + hit =3D true; + } else if (m_is_ppb_region(env, address)) { + hit =3D true; + } else { + if (pmsav7_use_background_region(cpu, mmu_idx, is_user)) { + hit =3D true; + } + + for (n =3D (int)cpu->pmsav7_dregion - 1; n >=3D 0; n--) { + /* region search */ + /* + * Note that the base address is bits [31:5] from the register + * with bits [4:0] all zeroes, but the limit address is bits + * [31:5] from the register with bits [4:0] all ones. + */ + uint32_t base =3D env->pmsav8.rbar[secure][n] & ~0x1f; + uint32_t limit =3D env->pmsav8.rlar[secure][n] | 0x1f; + + if (!(env->pmsav8.rlar[secure][n] & 0x1)) { + /* Region disabled */ + continue; + } + + if (address < base || address > limit) { + /* + * Address not in this region. We must check whether the + * region covers addresses in the same page as our address. + * In that case we must not report a size that covers the + * whole page for a subsequent hit against a different MPU + * region or the background region, because it would resul= t in + * incorrect TLB hits for subsequent accesses to addresses= that + * are in this MPU region. + */ + if (limit >=3D base && + ranges_overlap(base, limit - base + 1, + addr_page_base, + TARGET_PAGE_SIZE)) { + *is_subpage =3D true; + } + continue; + } + + if (base > addr_page_base || limit < addr_page_limit) { + *is_subpage =3D true; + } + + if (matchregion !=3D -1) { + /* + * Multiple regions match -- always a failure (unlike + * PMSAv7 where highest-numbered-region wins) + */ + fi->type =3D ARMFault_Permission; + fi->level =3D 1; + return true; + } + + matchregion =3D n; + hit =3D true; + } + } + + if (!hit) { + /* background fault */ + fi->type =3D ARMFault_Background; + return true; + } + + if (matchregion =3D=3D -1) { + /* hit using the background region */ + get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); + } else { + uint32_t ap =3D extract32(env->pmsav8.rbar[secure][matchregion], 1= , 2); + uint32_t xn =3D extract32(env->pmsav8.rbar[secure][matchregion], 0= , 1); + bool pxn =3D false; + + if (arm_feature(env, ARM_FEATURE_V8_1M)) { + pxn =3D extract32(env->pmsav8.rlar[secure][matchregion], 4, 1); + } + + if (m_is_system_region(env, address)) { + /* System space is always execute never */ + xn =3D 1; + } + + *prot =3D simple_ap_to_rw_prot(env, mmu_idx, ap); + if (*prot && !xn && !(pxn && !is_user)) { + *prot |=3D PAGE_EXEC; + } + /* + * We don't need to look the attribute up in the MAIR0/MAIR1 + * registers because that only tells us about cacheability. + */ + if (mregion) { + *mregion =3D matchregion; + } + } + + fi->type =3D ARMFault_Permission; + fi->level =3D 1; + return !(*prot & (1 << access_type)); +} + static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_= idx, hwaddr *phys_ptr, MemTxAttrs *txattrs, --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654769674; cv=none; d=zohomail.com; s=zohoarc; b=JeXgcsxhTTAiDqa4l+fLvTbM8vfjOfMBkE1bXCNeYX+OQKDd32iWh/d4bGYELDnhLUbZnHSebAAsmRDQtZ6FJz2aFpAVf8uQt1DMyZ8bXtDDu9dasDa/0mj/4ZzQbGg4T8r7bRuzXjuSlGLYK8dAVwRrx5Gh1OWOk6nX3pzbkCg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654769674; 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=EUZ/tNvP5WO5oV5qgdTYHUfZb+lkPxFhWBi0KRDzQ54=; b=b0BkRk8cVnH5oDcE+Pr1XnSddoIQGdM+rqxhW4LIbK6+By0AH+Em5QFwsAME/l/8D+hynXOIthFZpklWTP1YROUGN3IILNy0BRB94pmPAS61TsLIGH1jvFjzz7UJb/oiyIr/xNSPGqv//8bZwAHDi5ujP6BSafzaTM/y0YkiN2k= 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 1654769674889364.97319680855423; Thu, 9 Jun 2022 03:14:34 -0700 (PDT) Received: from localhost ([::1]:34454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFBR-0000Qm-DV for importer@patchew.org; Thu, 09 Jun 2022 06:14:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39406) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE78-0001Xj-DK for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:06 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:46807) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE76-0005v7-GQ for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:02 -0400 Received: by mail-wr1-x429.google.com with SMTP id u8so27137454wrm.13 for ; Thu, 09 Jun 2022 02:05:59 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.05.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:05:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=EUZ/tNvP5WO5oV5qgdTYHUfZb+lkPxFhWBi0KRDzQ54=; b=OpoQr7bAeWcoudBuNJFoIyB0bBeEnTOXTh5O2Oo/GSnqeByeknfak96HCpU5qNLrVa mCNy+IMhwcj5NUs5vs2VD/bBNlIEM7k197t+JGt2fd9jEoqbDYhYlTV7hOoq6B83WuAt 26NCs/NVhF7VW2un4XXQT2A53kyhtXtmDxV0//YhxpEPYDNw/9f+ca3WUrzp49jyufLX EhYgNP/4ScZlFjVd8KD7pViHdwyh8YNQuPvH0k3+lf6U6GViuiKpn+Kb+9iivTfXbIZE DUZQEvqnJ7GbHUkJGppHZfynaeNRsUB+1L9PoBFJUXgSQ2QQ4ivF/R9FtMdQ6yS5KWIW /0gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EUZ/tNvP5WO5oV5qgdTYHUfZb+lkPxFhWBi0KRDzQ54=; b=ZLAp3AJX/4h3k0bb1ToU+9rOeT20QUyXFKg0/aurqQ5HV4fj38PJFYy7ZwnxzoPnQX nCBVQMJS52spn+gamLBvnU7GiGSfi8grZVm62YGbV2j7Scfc7bGNuk9qgoueuTfzNdx6 MtEyN+ZTGfz5WfeH+uFTRLutltVhbcIcN0t3DzhCmZ72CT98/N24up7UlE44GhM4IOWQ Sag6HgrnQ+CfIwUO+uOysnK8CpTgPBrQFOvFe6mdAz4Dz8X3JJ2sKKig2JHB7dh4969z 01IehT9T4Kh6ysnFtExhTSRtyJMoiqzqRFrJcnhyAltqBQ97IWNwH3dl2jlBpz/TPOWK fCBQ== X-Gm-Message-State: AOAM530U5h4xuGZMQPMOqgfbD86kegzVkdQwrW+A+3GX+V2rBebkhzy4 4sIBtJBelf+j4ZeI/Y0et2EvtdCLhjY3ng== X-Google-Smtp-Source: ABdhPJwWyn3iyr/30BUKubxVyG/qD9HsTxn2XcVHmC+tuG78udBbjiq76PjIy0Ae/nQbFov8AdZGag== X-Received: by 2002:a5d:620b:0:b0:210:11d9:770 with SMTP id y11-20020a5d620b000000b0021011d90770mr37269450wru.11.1654765559590; Thu, 09 Jun 2022 02:05:59 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 17/55] target/arm: Move pmsav7_use_background_region to ptw.c Date: Thu, 9 Jun 2022 10:04:59 +0100 Message-Id: <20220609090537.1971756-18-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654769676155100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-11-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 2 -- target/arm/helper.c | 19 ------------------- target/arm/ptw.c | 21 +++++++++++++++++++++ 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index 8d2e2397147..d2d27119082 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -36,8 +36,6 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx,= int ap) bool m_is_ppb_region(CPUARMState *env, uint32_t address); bool m_is_system_region(CPUARMState *env, uint32_t address); =20 -bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, bool is_= user); - bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, bool s1_is_el0, diff --git a/target/arm/helper.c b/target/arm/helper.c index cb23413d8e5..62e48f0925c 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11678,25 +11678,6 @@ do_fault: return true; } =20 -bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, bool is_= user) -{ - /* Return true if we should use the default memory map as a - * "background" region if there are no hits against any MPU regions. - */ - CPUARMState *env =3D &cpu->env; - - if (is_user) { - return false; - } - - if (arm_feature(env, ARM_FEATURE_M)) { - return env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)] - & R_V7M_MPU_CTRL_PRIVDEFENA_MASK; - } else { - return regime_sctlr(env, mmu_idx) & SCTLR_BR; - } -} - bool m_is_ppb_region(CPUARMState *env, uint32_t address) { /* True if address is in the M profile PPB region 0xe0000000 - 0xe00ff= fff */ diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 989e783cce9..b82638b5a06 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -415,6 +415,27 @@ static void get_phys_addr_pmsav7_default(CPUARMState *= env, ARMMMUIdx mmu_idx, } } =20 +static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, + bool is_user) +{ + /* + * Return true if we should use the default memory map as a + * "background" region if there are no hits against any MPU regions. + */ + CPUARMState *env =3D &cpu->env; + + if (is_user) { + return false; + } + + if (arm_feature(env, ARM_FEATURE_M)) { + return env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)] + & R_V7M_MPU_CTRL_PRIVDEFENA_MASK; + } else { + return regime_sctlr(env, mmu_idx) & SCTLR_BR; + } +} + static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_= idx, hwaddr *phys_ptr, int *prot, --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654766155; cv=none; d=zohomail.com; s=zohoarc; b=lfUSYwL3yM4ZvVFj2ZxeOYYgSQdGFhMMSGA5E5stGoT2oC2Vtuch0bKkT4dqvnlhkmtyzU4Wh3M4sjEwP9rgpSgpnTdXFJ1SJFC1frFMS/mkO8XJc/eCu+p47h/66+ZP23Ssla/o5nItwLaSgY9dwO+ZU8XHbSaIbqxKE7ylccA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654766155; 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=PQxd2r1Hvfyyf27MTzwwWzDTkgYpufX1zJ4GE3JaSv0=; b=Q7SBp74rFLu5CjhmaFWkyS+aAWBoFbDsgab0CT4ryo60X9ryZlV0TUY9gS4L23XeBJKUkQjDpe0Xsu1WAlcZMj3X8vO27LuNdyKvtllrIojWUrZICxDym+hJdMfmJkjZxBNCUbSHv5Zo2O///uez9aV1DIEX2ZVVN4U9U2vgRSE= 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 1654766155903875.1819205326461; Thu, 9 Jun 2022 02:15:55 -0700 (PDT) Received: from localhost ([::1]:56748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzEGf-00051F-8l for importer@patchew.org; Thu, 09 Jun 2022 05:15:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE79-0001Xr-LQ for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:08 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:42899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE77-00060y-Js for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:03 -0400 Received: by mail-wr1-x432.google.com with SMTP id s1so8358409wra.9 for ; Thu, 09 Jun 2022 02:06:01 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.05.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=PQxd2r1Hvfyyf27MTzwwWzDTkgYpufX1zJ4GE3JaSv0=; b=dIKXG3OrPBWVrRHvaF6E0lPpMDMtut+AS/r6i2ObQqKYW9GfYvKY9l05PE9qvlyc3I RdznEX0cokNLSJ0s8ApqzczHhyfjfTc9//ASO5/tQI/H8sP7t+7eBCEUPc65E2KTS+1n VQoors/20iEudqdgTxeMY4PhB9ShKb9u5saTCqwStuRXYKFiyjh9susS3KNpI1E7v2fK Q4/KHMs9fPHbSb0YQhe2OvMFM0Wt6Hv91W6OTVtlns32p2Q56TSCLwy5WcCU+Gu0/amw 1z5SkDK+TYUQlD+ys7uExbApmGgZBoVh3DnfBLp9moC0XbpjfiPYaGxd8+40WjVNYwVm zpjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PQxd2r1Hvfyyf27MTzwwWzDTkgYpufX1zJ4GE3JaSv0=; b=IN+R0SUZ4IFxVjCLW7qF1Il+YWY+IJd6LMxYqKtI/pzLBwG3/rbDnTqFYuBl4JUiev NGlpMSKOytvYzxJePwW21HP++yr7uZRsk7qeebvAt5RIJP63qmsfPWlfOrpHJkyWul63 RPGYyeAx3ILhSR9Q+aWISkyZ/bzZYBR44cxOqAKd0fnQqLo8no0fonj2de8dwLYJjhCk tJaL8cF3ui014ZyapJd83rRZPOAg6Rxv0DdadUbN+0oeOZ/MPQjjhxBQxGcoPrNKdSAZ I0fUufDpE9jlm2giyUasUz762lRbEE3B0hLDN6eRPhC/jiXgfeIqLHLNKdYVffG6PCEA B+Aw== X-Gm-Message-State: AOAM530wcQZWFhxtw3ZC3cQfhvSTAZC9/J75L+TJajyC4OQM/BRIiL+w AvfgJnv3HRdiju8msnLnslp4TDws5fsYyA== X-Google-Smtp-Source: ABdhPJxxQ+oqIo+/lbLIv0nQ21YQjo4wN7QISZktZqLou2ld6Ga7xRZFkfgnt61ABL1jU6yx5Zpl+g== X-Received: by 2002:a5d:5281:0:b0:20c:d5be:331c with SMTP id c1-20020a5d5281000000b0020cd5be331cmr37224786wrv.9.1654765560628; Thu, 09 Jun 2022 02:06:00 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 18/55] target/arm: Move v8m_security_lookup to ptw.c Date: Thu, 9 Jun 2022 10:05:00 +0100 Message-Id: <20220609090537.1971756-19-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654766156663100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson This function has one private helper, v8m_is_sau_exempt, so move that at the same time. Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-12-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/helper.c | 123 ------------------------------------------ target/arm/ptw.c | 126 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 123 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 62e48f0925c..d6a749ad0ed 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9,7 +9,6 @@ #include "qemu/osdep.h" #include "qemu/units.h" #include "qemu/log.h" -#include "target/arm/idau.h" #include "trace.h" #include "cpu.h" #include "internals.h" @@ -11693,128 +11692,6 @@ bool m_is_system_region(CPUARMState *env, uint32_= t address) return arm_feature(env, ARM_FEATURE_M) && extract32(address, 29, 3) = =3D=3D 0x7; } =20 -static bool v8m_is_sau_exempt(CPUARMState *env, - uint32_t address, MMUAccessType access_type) -{ - /* The architecture specifies that certain address ranges are - * exempt from v8M SAU/IDAU checks. - */ - return - (access_type =3D=3D MMU_INST_FETCH && m_is_system_region(env, addr= ess)) || - (address >=3D 0xe0000000 && address <=3D 0xe0002fff) || - (address >=3D 0xe000e000 && address <=3D 0xe000efff) || - (address >=3D 0xe002e000 && address <=3D 0xe002efff) || - (address >=3D 0xe0040000 && address <=3D 0xe0041fff) || - (address >=3D 0xe00ff000 && address <=3D 0xe00fffff); -} - -void v8m_security_lookup(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_i= dx, - V8M_SAttributes *sattrs) -{ - /* Look up the security attributes for this address. Compare the - * pseudocode SecurityCheck() function. - * We assume the caller has zero-initialized *sattrs. - */ - ARMCPU *cpu =3D env_archcpu(env); - int r; - bool idau_exempt =3D false, idau_ns =3D true, idau_nsc =3D true; - int idau_region =3D IREGION_NOTVALID; - uint32_t addr_page_base =3D address & TARGET_PAGE_MASK; - uint32_t addr_page_limit =3D addr_page_base + (TARGET_PAGE_SIZE - 1); - - if (cpu->idau) { - IDAUInterfaceClass *iic =3D IDAU_INTERFACE_GET_CLASS(cpu->idau); - IDAUInterface *ii =3D IDAU_INTERFACE(cpu->idau); - - iic->check(ii, address, &idau_region, &idau_exempt, &idau_ns, - &idau_nsc); - } - - if (access_type =3D=3D MMU_INST_FETCH && extract32(address, 28, 4) =3D= =3D 0xf) { - /* 0xf0000000..0xffffffff is always S for insn fetches */ - return; - } - - if (idau_exempt || v8m_is_sau_exempt(env, address, access_type)) { - sattrs->ns =3D !regime_is_secure(env, mmu_idx); - return; - } - - if (idau_region !=3D IREGION_NOTVALID) { - sattrs->irvalid =3D true; - sattrs->iregion =3D idau_region; - } - - switch (env->sau.ctrl & 3) { - case 0: /* SAU.ENABLE =3D=3D 0, SAU.ALLNS =3D=3D 0 */ - break; - case 2: /* SAU.ENABLE =3D=3D 0, SAU.ALLNS =3D=3D 1 */ - sattrs->ns =3D true; - break; - default: /* SAU.ENABLE =3D=3D 1 */ - for (r =3D 0; r < cpu->sau_sregion; r++) { - if (env->sau.rlar[r] & 1) { - uint32_t base =3D env->sau.rbar[r] & ~0x1f; - uint32_t limit =3D env->sau.rlar[r] | 0x1f; - - if (base <=3D address && limit >=3D address) { - if (base > addr_page_base || limit < addr_page_limit) { - sattrs->subpage =3D true; - } - if (sattrs->srvalid) { - /* If we hit in more than one region then we must = report - * as Secure, not NS-Callable, with no valid region - * number info. - */ - sattrs->ns =3D false; - sattrs->nsc =3D false; - sattrs->sregion =3D 0; - sattrs->srvalid =3D false; - break; - } else { - if (env->sau.rlar[r] & 2) { - sattrs->nsc =3D true; - } else { - sattrs->ns =3D true; - } - sattrs->srvalid =3D true; - sattrs->sregion =3D r; - } - } else { - /* - * Address not in this region. We must check whether t= he - * region covers addresses in the same page as our add= ress. - * In that case we must not report a size that covers = the - * whole page for a subsequent hit against a different= MPU - * region or the background region, because it would r= esult - * in incorrect TLB hits for subsequent accesses to - * addresses that are in this MPU region. - */ - if (limit >=3D base && - ranges_overlap(base, limit - base + 1, - addr_page_base, - TARGET_PAGE_SIZE)) { - sattrs->subpage =3D true; - } - } - } - } - break; - } - - /* - * The IDAU will override the SAU lookup results if it specifies - * higher security than the SAU does. - */ - if (!idau_ns) { - if (sattrs->ns || (!idau_nsc && sattrs->nsc)) { - sattrs->ns =3D false; - sattrs->nsc =3D idau_nsc; - } - } -} - /* Combine either inner or outer cacheability attributes for normal * memory, according to table D4-42 and pseudocode procedure * CombineS1S2AttrHints() of ARM DDI 0487B.b (the ARMv8 ARM). diff --git a/target/arm/ptw.c b/target/arm/ptw.c index b82638b5a06..c15fba43c31 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -11,6 +11,7 @@ #include "qemu/range.h" #include "cpu.h" #include "internals.h" +#include "idau.h" #include "ptw.h" =20 =20 @@ -766,6 +767,131 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t add= ress, return !(*prot & (1 << access_type)); } =20 +static bool v8m_is_sau_exempt(CPUARMState *env, + uint32_t address, MMUAccessType access_type) +{ + /* + * The architecture specifies that certain address ranges are + * exempt from v8M SAU/IDAU checks. + */ + return + (access_type =3D=3D MMU_INST_FETCH && m_is_system_region(env, addr= ess)) || + (address >=3D 0xe0000000 && address <=3D 0xe0002fff) || + (address >=3D 0xe000e000 && address <=3D 0xe000efff) || + (address >=3D 0xe002e000 && address <=3D 0xe002efff) || + (address >=3D 0xe0040000 && address <=3D 0xe0041fff) || + (address >=3D 0xe00ff000 && address <=3D 0xe00fffff); +} + +void v8m_security_lookup(CPUARMState *env, uint32_t address, + MMUAccessType access_type, ARMMMUIdx mmu_i= dx, + V8M_SAttributes *sattrs) +{ + /* + * Look up the security attributes for this address. Compare the + * pseudocode SecurityCheck() function. + * We assume the caller has zero-initialized *sattrs. + */ + ARMCPU *cpu =3D env_archcpu(env); + int r; + bool idau_exempt =3D false, idau_ns =3D true, idau_nsc =3D true; + int idau_region =3D IREGION_NOTVALID; + uint32_t addr_page_base =3D address & TARGET_PAGE_MASK; + uint32_t addr_page_limit =3D addr_page_base + (TARGET_PAGE_SIZE - 1); + + if (cpu->idau) { + IDAUInterfaceClass *iic =3D IDAU_INTERFACE_GET_CLASS(cpu->idau); + IDAUInterface *ii =3D IDAU_INTERFACE(cpu->idau); + + iic->check(ii, address, &idau_region, &idau_exempt, &idau_ns, + &idau_nsc); + } + + if (access_type =3D=3D MMU_INST_FETCH && extract32(address, 28, 4) =3D= =3D 0xf) { + /* 0xf0000000..0xffffffff is always S for insn fetches */ + return; + } + + if (idau_exempt || v8m_is_sau_exempt(env, address, access_type)) { + sattrs->ns =3D !regime_is_secure(env, mmu_idx); + return; + } + + if (idau_region !=3D IREGION_NOTVALID) { + sattrs->irvalid =3D true; + sattrs->iregion =3D idau_region; + } + + switch (env->sau.ctrl & 3) { + case 0: /* SAU.ENABLE =3D=3D 0, SAU.ALLNS =3D=3D 0 */ + break; + case 2: /* SAU.ENABLE =3D=3D 0, SAU.ALLNS =3D=3D 1 */ + sattrs->ns =3D true; + break; + default: /* SAU.ENABLE =3D=3D 1 */ + for (r =3D 0; r < cpu->sau_sregion; r++) { + if (env->sau.rlar[r] & 1) { + uint32_t base =3D env->sau.rbar[r] & ~0x1f; + uint32_t limit =3D env->sau.rlar[r] | 0x1f; + + if (base <=3D address && limit >=3D address) { + if (base > addr_page_base || limit < addr_page_limit) { + sattrs->subpage =3D true; + } + if (sattrs->srvalid) { + /* + * If we hit in more than one region then we must = report + * as Secure, not NS-Callable, with no valid region + * number info. + */ + sattrs->ns =3D false; + sattrs->nsc =3D false; + sattrs->sregion =3D 0; + sattrs->srvalid =3D false; + break; + } else { + if (env->sau.rlar[r] & 2) { + sattrs->nsc =3D true; + } else { + sattrs->ns =3D true; + } + sattrs->srvalid =3D true; + sattrs->sregion =3D r; + } + } else { + /* + * Address not in this region. We must check whether t= he + * region covers addresses in the same page as our add= ress. + * In that case we must not report a size that covers = the + * whole page for a subsequent hit against a different= MPU + * region or the background region, because it would r= esult + * in incorrect TLB hits for subsequent accesses to + * addresses that are in this MPU region. + */ + if (limit >=3D base && + ranges_overlap(base, limit - base + 1, + addr_page_base, + TARGET_PAGE_SIZE)) { + sattrs->subpage =3D true; + } + } + } + } + break; + } + + /* + * The IDAU will override the SAU lookup results if it specifies + * higher security than the SAU does. + */ + if (!idau_ns) { + if (sattrs->ns || (!idau_nsc && sattrs->nsc)) { + sattrs->ns =3D false; + sattrs->nsc =3D idau_nsc; + } + } +} + static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_= idx, hwaddr *phys_ptr, MemTxAttrs *txattrs, --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654768268; cv=none; d=zohomail.com; s=zohoarc; b=TYxWCQGtJtGrJGMc4LFT7KO87TZCCfG+jDTSTfbpmKfHR4uFD6UpB0RwaoUM1VD9B0zwXI4f25IczkjZKkRBjy5ZocUZKexApSC7V34wdDxZSWp5/bQrAxdNMXabS0bIgqjj1t8N9pum8OdRN3gNUix09UXyhpDfGrAO+FCg1lk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654768268; 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=O5ejk88Q4maSJEwIoy6uu9RtbcDZwf0hyA9JefrZq5A=; b=jjEhcxhFvBtAI++pYcqp7prAH43jg6vTqzMXP6y+nhfB0vKwjoxtDLVdUoBP6sb4v2K2hDrDQwb8B9cQqc47hoczapFBhsNvBm81lbvJiGPhf94G2t3DZqJBPOyV1OvXSgcoUElB+K8K9M77xV839hdRXhD5s0UzETPS5itRbxk= 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 1654768268063379.996856508905; Thu, 9 Jun 2022 02:51:08 -0700 (PDT) Received: from localhost ([::1]:34800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzEok-00050l-BT for importer@patchew.org; Thu, 09 Jun 2022 05:51:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39478) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7H-0001YQ-Mc for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:15 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:35634) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE78-0005y0-UB for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:08 -0400 Received: by mail-wr1-x435.google.com with SMTP id a15so22952820wrh.2 for ; Thu, 09 Jun 2022 02:06:02 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=O5ejk88Q4maSJEwIoy6uu9RtbcDZwf0hyA9JefrZq5A=; b=P5T+JMDEt812vzh29gjMGZgKP5V6fbpIGzbDbJ3CGwk2h2aag7FJtFQBVJhIDOoSPs kX/ovRFgvMndp/XMIf9msmRtL11sQhXv3EKD+HqWrwxXrE9WlSZaRig9uxDfDWnfjaUY f3RCWg0Y3ri8BFUUINucz9Ejtr7NKugxAEn6vFiOiB1wp0yY6impFIAIq9h+/vOEjY4R AizkBkhG8GoWVTw2H+u603/cUMWgFL8qwUgZzQc3wIaVmY1HDHrzZx5LJt+lx/Gp7bN6 oiulz4Ak6/JhzHj05fuXfCEW4Bm6XMQrD3ClX9tQyM6TdTtKs4hr0Vxn4Gm0DB2HTjHG ukbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O5ejk88Q4maSJEwIoy6uu9RtbcDZwf0hyA9JefrZq5A=; b=RVbKphj8mJPPNaWRz/KSuktFO7Va/cQ4++Z9gYNUvMYFJDa5OF33qfJzO253Rl4Sn5 Ea0lYn43dJr9LiwJkDoOT9+etXVTOAZtYtxYTFC0xEZ2REuEBjDa5S/5wp7O03IV5DPp lTVUws3c/KtrZ8xWh0vRcyiOW9p1ADrg7z5dQxb+IrGz8zh5DgwHyvvPgBQsikXZA942 cAbLYIgxG0zWCxJjJSqJK53mG5GXnR0xtSEToDsO4JuawGIniC1ZURnmKhCq5ZCJowmk +MTdWX1itaSt7P20r6GR+yQDdF/Pner/cWLP+oocMS1T4IuqEhXV6OBYDW6OPeO0047I Vq0g== X-Gm-Message-State: AOAM533xDDnev0VQk4MYEF4RYTs4pJK/R1KagOcYG0dhnkr3J2m5JWJq uBYDEw7bCTSTQ0KDCOIWt6NfzAL956UIjQ== X-Google-Smtp-Source: ABdhPJz/bKbQ1AVJ3k99XYZ4d1pmi1jlnU4oYVY2jsH98PbuuHPn33Djy6Uru13C/Q7qp/nnfGtq3Q== X-Received: by 2002:a5d:58ed:0:b0:217:dd5:7508 with SMTP id f13-20020a5d58ed000000b002170dd57508mr24329097wrd.606.1654765561753; Thu, 09 Jun 2022 02:06:01 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 19/55] target/arm: Move m_is_{ppb,system}_region to ptw.c Date: Thu, 9 Jun 2022 10:05:01 +0100 Message-Id: <20220609090537.1971756-20-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654768269365100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-13-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 3 --- target/arm/helper.c | 15 --------------- target/arm/ptw.c | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index d2d27119082..6c47a575991 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -33,9 +33,6 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx,= int ap) return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); } =20 -bool m_is_ppb_region(CPUARMState *env, uint32_t address); -bool m_is_system_region(CPUARMState *env, uint32_t address); - bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, bool s1_is_el0, diff --git a/target/arm/helper.c b/target/arm/helper.c index d6a749ad0ed..d2ef12346b6 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11677,21 +11677,6 @@ do_fault: return true; } =20 -bool m_is_ppb_region(CPUARMState *env, uint32_t address) -{ - /* True if address is in the M profile PPB region 0xe0000000 - 0xe00ff= fff */ - return arm_feature(env, ARM_FEATURE_M) && - extract32(address, 20, 12) =3D=3D 0xe00; -} - -bool m_is_system_region(CPUARMState *env, uint32_t address) -{ - /* True if address is in the M profile system region - * 0xe0000000 - 0xffffffff - */ - return arm_feature(env, ARM_FEATURE_M) && extract32(address, 29, 3) = =3D=3D 0x7; -} - /* Combine either inner or outer cacheability attributes for normal * memory, according to table D4-42 and pseudocode procedure * CombineS1S2AttrHints() of ARM DDI 0487B.b (the ARMv8 ARM). diff --git a/target/arm/ptw.c b/target/arm/ptw.c index c15fba43c31..32ba2e5e8bf 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -416,6 +416,22 @@ static void get_phys_addr_pmsav7_default(CPUARMState *= env, ARMMMUIdx mmu_idx, } } =20 +static bool m_is_ppb_region(CPUARMState *env, uint32_t address) +{ + /* True if address is in the M profile PPB region 0xe0000000 - 0xe00ff= fff */ + return arm_feature(env, ARM_FEATURE_M) && + extract32(address, 20, 12) =3D=3D 0xe00; +} + +static bool m_is_system_region(CPUARMState *env, uint32_t address) +{ + /* + * True if address is in the M profile system region + * 0xe0000000 - 0xffffffff + */ + return arm_feature(env, ARM_FEATURE_M) && extract32(address, 29, 3) = =3D=3D 0x7; +} + static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, bool is_user) { --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654771115; cv=none; d=zohomail.com; s=zohoarc; b=QDIHcMgTzKm+YDw0ru6eKJihgvFUMj4SpXNDDWMFO5Op0tQReFnZHjFQQhWdUznL/9DOmu/z2RRWbzWG8HpR1xbMWiUyJlSlQqNJUmsOYjLgI6RSkI4nc1WJaMkrDor59C79JSLwsVzieMG5ReWHoqb0a2UBRDYVMEQ1nU1KT3k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654771115; 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=TD1PLdCagSw5QrlgIXtULFKaHs2aOf+o891C3P6EsSQ=; b=heuMySwA5+T2jspXLR0N8PU4BZaHUnzCuGP6hznjbSJ/Zo+aw1PP52x+vz/6z7d0+XmLaEtKppHXG1v7ivBOlnjEz3rylHlflTNBsOoMXHse23mFHRlPiY7AB4m4SwLvIbqphvb0eiOKsixPQqAT8TmrrKXSWLfg/bEcJRTs/KQ= 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 1654771115945954.5876742688375; Thu, 9 Jun 2022 03:38:35 -0700 (PDT) Received: from localhost ([::1]:51772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFYg-0005M2-PX for importer@patchew.org; Thu, 09 Jun 2022 06:38:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7J-0001Yd-9E for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:18 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:36485) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7B-00062j-TP for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:13 -0400 Received: by mail-wr1-x431.google.com with SMTP id o8so3625311wro.3 for ; Thu, 09 Jun 2022 02:06:03 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=TD1PLdCagSw5QrlgIXtULFKaHs2aOf+o891C3P6EsSQ=; b=j0TKzAGApZF0gBczopLtY9dfGeA9G24MSE6bd8q5WZ9INxwNEVAHb5ZlHlb2uZSqHj xW1dEkkQxA+Pjpn70kE4930ySQsmj784eZdX+9zKcXbkdX/J+oCGP9yJh0Jb+45U5TTd WdhYRBxT3V4ciMpAf6zssDYCn7jV/+D9RgMISVu/oEMzucugWVu5h/Ky5/0WneE2jTrW W/cuOa38nylOvpZomInaEHjnRMisNcMmEnj8K/uaOavJjm+n8y2neZesFlE5owAEICKM LBEXaSGXb1MDMxfHiTT0ljY951MvQ5suLAYj2wdHM72wWc64YfjbpRy6Ti+xu3To5MUG uiww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TD1PLdCagSw5QrlgIXtULFKaHs2aOf+o891C3P6EsSQ=; b=jpTvf9PzjDHsdzThD/XiMOZpdDeiulno3TZE1H4C6MRG+NQizpEY+4eL3FGwefpK+g Rxij+Btq+NKaD4UcSjDwATUjZbvgwT+EPfCeVvUqQeEeDAJ62AvYL8PLh7JbrnG1noGe PRaEs6JWBtQId042Dpq35AjM4Z2OFg46cTH5rKMqM7VN6wWAy1kIh5UshSNRCVk+Bd+H q81MD0DIwBK7BkEv5LtA0BxUdGDrDZGn+HSTCMj/P31tEI7KfBZgJrdH+MON+tQmM0L1 OGuuXm+hRRpCQ4l+wfBtaeufAAwNT9LAkw8jvlWwp1/ZGr2LBU31N8QVr1tmS4eNL8rX 4E3w== X-Gm-Message-State: AOAM530srhmuhIoHuvzbt5NCdmqvyIbeQ+XJhW277+KOubwL7wjBSitY y9TxyUhnUWD+UPLOPpwuNK/7TEE8hUR5yA== X-Google-Smtp-Source: ABdhPJzj4MHZ7o4UXRvrpqkecPR3Ke0NOSNGXPltfsNXBCCK3wx8a8hrNuaO2+DRUkhkZIyv81fwGg== X-Received: by 2002:a05:6000:184f:b0:218:555e:6b69 with SMTP id c15-20020a056000184f00b00218555e6b69mr11528701wri.562.1654765562794; Thu, 09 Jun 2022 02:06:02 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 20/55] target/arm: Move get_level1_table_address to ptw.c Date: Thu, 9 Jun 2022 10:05:02 +0100 Message-Id: <20220609090537.1971756-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::431; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x431.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654771117237100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-14-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 4 ++-- target/arm/helper.c | 26 +------------------------- target/arm/ptw.c | 23 +++++++++++++++++++++++ 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index 6c47a575991..dd6fb93f336 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -18,11 +18,11 @@ uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is= _secure, =20 bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx); bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); +uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn); + ARMCacheAttrs combine_cacheattrs(CPUARMState *env, ARMCacheAttrs s1, ARMCacheAttrs s2); =20 -bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, - uint32_t *table, uint32_t address); int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap, int domain_prot); int simple_ap_to_rw_prot_is_user(int ap, bool is_user); diff --git a/target/arm/helper.c b/target/arm/helper.c index d2ef12346b6..a144cb26413 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10482,8 +10482,7 @@ static inline bool regime_translation_big_endian(CP= UARMState *env, } =20 /* Return the TTBR associated with this translation regime */ -static inline uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, - int ttbrn) +uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn) { if (mmu_idx =3D=3D ARMMMUIdx_Stage2) { return env->cp15.vttbr_el2; @@ -10774,29 +10773,6 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx = mmu_idx, bool is_aa64, return prot_rw | PAGE_EXEC; } =20 -bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, - uint32_t *table, uint32_t address) -{ - /* Note that we can only get here for an AArch32 PL0/PL1 lookup */ - TCR *tcr =3D regime_tcr(env, mmu_idx); - - if (address & tcr->mask) { - if (tcr->raw_tcr & TTBCR_PD1) { - /* Translation table walk disabled for TTBR1 */ - return false; - } - *table =3D regime_ttbr(env, mmu_idx, 1) & 0xffffc000; - } else { - if (tcr->raw_tcr & TTBCR_PD0) { - /* Translation table walk disabled for TTBR0 */ - return false; - } - *table =3D regime_ttbr(env, mmu_idx, 0) & tcr->base_mask; - } - *table |=3D (address >> 18) & 0x3ffc; - return true; -} - static bool ptw_attrs_are_device(CPUARMState *env, ARMCacheAttrs cacheattr= s) { /* diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 32ba2e5e8bf..5737a3976b8 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -15,6 +15,29 @@ #include "ptw.h" =20 =20 +static bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, + uint32_t *table, uint32_t address) +{ + /* Note that we can only get here for an AArch32 PL0/PL1 lookup */ + TCR *tcr =3D regime_tcr(env, mmu_idx); + + if (address & tcr->mask) { + if (tcr->raw_tcr & TTBCR_PD1) { + /* Translation table walk disabled for TTBR1 */ + return false; + } + *table =3D regime_ttbr(env, mmu_idx, 1) & 0xffffc000; + } else { + if (tcr->raw_tcr & TTBCR_PD0) { + /* Translation table walk disabled for TTBR0 */ + return false; + } + *table =3D regime_ttbr(env, mmu_idx, 0) & tcr->base_mask; + } + *table |=3D (address >> 18) & 0x3ffc; + return true; +} + static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot, --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654768474; cv=none; d=zohomail.com; s=zohoarc; b=SGVGEkUgEfHLnX2glmq8N472ELdry0VJYufyanFOEg4ACaI8XT3tTFqe0jz51/HgjxGBm4bJW3bYO4fGlCcsY+rQN1UEEasdoQiVxQP/KsbpdFj9JgQWZ6eF2UU40+ItnJ/+zQKEUTZo5Pq71Ik+7gzafuj9N+0d0jJxQzpZmkY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654768474; 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=WD/V0E1GSbC8kw/VTqqWFOO+IaFp5Vx0rfDhyIWhFDU=; b=b2lGjn/VjEmlPo6/fegEk55kWsTg3ZYJSZIXRG9kFQSKM2zFwnmNOUv+Iux4FnA60u+MhTlgtJNj8As1xdPjJD+TWNu8j/RrLMYTN3u3IJhInMsq/05AkXg121Ez8PJfc8dV7MGye570fdVgRQZVPljx4nt18Ww5q0+gQWi6M8o= 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 1654768474315659.7307103122444; Thu, 9 Jun 2022 02:54:34 -0700 (PDT) Received: from localhost ([::1]:38206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzEs5-0007Uq-3D for importer@patchew.org; Thu, 09 Jun 2022 05:54:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39502) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7I-0001Yb-W1 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:18 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:43557) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7E-00062u-Kx for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:12 -0400 Received: by mail-wr1-x42e.google.com with SMTP id d14so22478158wra.10 for ; Thu, 09 Jun 2022 02:06:05 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=WD/V0E1GSbC8kw/VTqqWFOO+IaFp5Vx0rfDhyIWhFDU=; b=AEa7RquiRN8Zm/M2WAO56Kis0lEpu8H6AzF7P3XXGVxgdAHEr6p51Kw0FxcnX4IHyU UP0DxsUyg8VN7jWt1BZb/5YPab9cDALHw23DA6yYqC8R4aQT7DbkC2F+BzQQsRhDhIro 6UH2wsOmx2czkgQZk9qHsUbIIT00/rlkCSOqkeQoWiglFnZdkwzc45QqYUvFQzY4IgSa KO8ibbZmjwZ5tkRJ9XBSbPHZxifZhOEJscU88nh/vFp9jT8y1b+d4i11L1CvSYE2OSJJ BsdN64Bi80ikkxYHnrrXLo27P3RHoWdZ+JaYNd5cVlnnB0/RzP9lH6hZO1wIzRTg5iZi 3n1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WD/V0E1GSbC8kw/VTqqWFOO+IaFp5Vx0rfDhyIWhFDU=; b=LKIA1s9Hi4BqnQ86Uh1UPFRq/Hs/rAf+a7ImOZYlOmEXABauo4qu2KD509hyRKF+qt LC/MoMZEc4FDqt935/m0ELUEk6TkiCw7i3BXzawHG1nfOHImvDabmQvdcyHf4Vfm4xTJ C6FBbpEeMW4jBgEzs2p0RaRKD4d06+yvcIIngVqBWnZCw5lPA2/CqI5VKbZa6D6at87l 4BFnfBdZbsOFwPnQrGsmjtjGJ7Klau4UvGChrXaq/iA8sotX1vNeKYjA3GYWNz1crVRI k4l8X63VBP6Psa934t3CxThjE3poAp0HFL65LVZFcf+Rfc7D2sh4EbKlXLmOdMHmXjtS Iwog== X-Gm-Message-State: AOAM533ZdcV4v6GjwBQI3MqSbsmxEN84vcRAZJtwpOwm++6lYpCp4wZL WTvxSFdqYIGMYVDYjZHHAcCN+u1tI2WPag== X-Google-Smtp-Source: ABdhPJz1meO6qZOZIuIZt7OruMaLKiphM09Zs/oMTRQg1DFY1mKlxl9ccmXpYeT+kdLwCuJkrCb/FA== X-Received: by 2002:a5d:4344:0:b0:20c:cad4:9e9b with SMTP id u4-20020a5d4344000000b0020ccad49e9bmr36841605wrr.187.1654765563996; Thu, 09 Jun 2022 02:06:03 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 21/55] target/arm: Move combine_cacheattrs and subroutines to ptw.c Date: Thu, 9 Jun 2022 10:05:03 +0100 Message-Id: <20220609090537.1971756-22-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654768476528100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson There are a handful of helpers for combine_cacheattrs that we can move at the same time as the main entry point. Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-15-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 3 - target/arm/helper.c | 218 ------------------------------------------- target/arm/ptw.c | 221 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 221 insertions(+), 221 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index dd6fb93f336..b2dfe489bbe 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -20,9 +20,6 @@ bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx); bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn); =20 -ARMCacheAttrs combine_cacheattrs(CPUARMState *env, - ARMCacheAttrs s1, ARMCacheAttrs s2); - int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap, int domain_prot); int simple_ap_to_rw_prot_is_user(int ap, bool is_user); diff --git a/target/arm/helper.c b/target/arm/helper.c index a144cb26413..dab485e64ae 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10977,36 +10977,6 @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool i= s_aa64, int level, } return true; } - -/* Translate from the 4-bit stage 2 representation of - * memory attributes (without cache-allocation hints) to - * the 8-bit representation of the stage 1 MAIR registers - * (which includes allocation hints). - * - * ref: shared/translation/attrs/S2AttrDecode() - * .../S2ConvertAttrsHints() - */ -static uint8_t convert_stage2_attrs(CPUARMState *env, uint8_t s2attrs) -{ - uint8_t hiattr =3D extract32(s2attrs, 2, 2); - uint8_t loattr =3D extract32(s2attrs, 0, 2); - uint8_t hihint =3D 0, lohint =3D 0; - - if (hiattr !=3D 0) { /* normal memory */ - if (arm_hcr_el2_eff(env) & HCR_CD) { /* cache disabled */ - hiattr =3D loattr =3D 1; /* non-cacheable */ - } else { - if (hiattr !=3D 1) { /* Write-through or write-back */ - hihint =3D 3; /* RW allocate */ - } - if (loattr !=3D 1) { /* Write-through or write-back */ - lohint =3D 3; /* RW allocate */ - } - } - } - - return (hiattr << 6) | (hihint << 4) | (loattr << 2) | lohint; -} #endif /* !CONFIG_USER_ONLY */ =20 /* This mapping is common between ID_AA64MMFR0.PARANGE and TCR_ELx.{I}PS. = */ @@ -11653,194 +11623,6 @@ do_fault: return true; } =20 -/* Combine either inner or outer cacheability attributes for normal - * memory, according to table D4-42 and pseudocode procedure - * CombineS1S2AttrHints() of ARM DDI 0487B.b (the ARMv8 ARM). - * - * NB: only stage 1 includes allocation hints (RW bits), leading to - * some asymmetry. - */ -static uint8_t combine_cacheattr_nibble(uint8_t s1, uint8_t s2) -{ - if (s1 =3D=3D 4 || s2 =3D=3D 4) { - /* non-cacheable has precedence */ - return 4; - } else if (extract32(s1, 2, 2) =3D=3D 0 || extract32(s1, 2, 2) =3D=3D = 2) { - /* stage 1 write-through takes precedence */ - return s1; - } else if (extract32(s2, 2, 2) =3D=3D 2) { - /* stage 2 write-through takes precedence, but the allocation hint - * is still taken from stage 1 - */ - return (2 << 2) | extract32(s1, 0, 2); - } else { /* write-back */ - return s1; - } -} - -/* - * Combine the memory type and cacheability attributes of - * s1 and s2 for the HCR_EL2.FWB =3D=3D 0 case, returning the - * combined attributes in MAIR_EL1 format. - */ -static uint8_t combined_attrs_nofwb(CPUARMState *env, - ARMCacheAttrs s1, ARMCacheAttrs s2) -{ - uint8_t s1lo, s2lo, s1hi, s2hi, s2_mair_attrs, ret_attrs; - - s2_mair_attrs =3D convert_stage2_attrs(env, s2.attrs); - - s1lo =3D extract32(s1.attrs, 0, 4); - s2lo =3D extract32(s2_mair_attrs, 0, 4); - s1hi =3D extract32(s1.attrs, 4, 4); - s2hi =3D extract32(s2_mair_attrs, 4, 4); - - /* Combine memory type and cacheability attributes */ - if (s1hi =3D=3D 0 || s2hi =3D=3D 0) { - /* Device has precedence over normal */ - if (s1lo =3D=3D 0 || s2lo =3D=3D 0) { - /* nGnRnE has precedence over anything */ - ret_attrs =3D 0; - } else if (s1lo =3D=3D 4 || s2lo =3D=3D 4) { - /* non-Reordering has precedence over Reordering */ - ret_attrs =3D 4; /* nGnRE */ - } else if (s1lo =3D=3D 8 || s2lo =3D=3D 8) { - /* non-Gathering has precedence over Gathering */ - ret_attrs =3D 8; /* nGRE */ - } else { - ret_attrs =3D 0xc; /* GRE */ - } - } else { /* Normal memory */ - /* Outer/inner cacheability combine independently */ - ret_attrs =3D combine_cacheattr_nibble(s1hi, s2hi) << 4 - | combine_cacheattr_nibble(s1lo, s2lo); - } - return ret_attrs; -} - -static uint8_t force_cacheattr_nibble_wb(uint8_t attr) -{ - /* - * Given the 4 bits specifying the outer or inner cacheability - * in MAIR format, return a value specifying Normal Write-Back, - * with the allocation and transient hints taken from the input - * if the input specified some kind of cacheable attribute. - */ - if (attr =3D=3D 0 || attr =3D=3D 4) { - /* - * 0 =3D=3D an UNPREDICTABLE encoding - * 4 =3D=3D Non-cacheable - * Either way, force Write-Back RW allocate non-transient - */ - return 0xf; - } - /* Change WriteThrough to WriteBack, keep allocation and transient hin= ts */ - return attr | 4; -} - -/* - * Combine the memory type and cacheability attributes of - * s1 and s2 for the HCR_EL2.FWB =3D=3D 1 case, returning the - * combined attributes in MAIR_EL1 format. - */ -static uint8_t combined_attrs_fwb(CPUARMState *env, - ARMCacheAttrs s1, ARMCacheAttrs s2) -{ - switch (s2.attrs) { - case 7: - /* Use stage 1 attributes */ - return s1.attrs; - case 6: - /* - * Force Normal Write-Back. Note that if S1 is Normal cacheable - * then we take the allocation hints from it; otherwise it is - * RW allocate, non-transient. - */ - if ((s1.attrs & 0xf0) =3D=3D 0) { - /* S1 is Device */ - return 0xff; - } - /* Need to check the Inner and Outer nibbles separately */ - return force_cacheattr_nibble_wb(s1.attrs & 0xf) | - force_cacheattr_nibble_wb(s1.attrs >> 4) << 4; - case 5: - /* If S1 attrs are Device, use them; otherwise Normal Non-cacheabl= e */ - if ((s1.attrs & 0xf0) =3D=3D 0) { - return s1.attrs; - } - return 0x44; - case 0 ... 3: - /* Force Device, of subtype specified by S2 */ - return s2.attrs << 2; - default: - /* - * RESERVED values (including RES0 descriptor bit [5] being nonzer= o); - * arbitrarily force Device. - */ - return 0; - } -} - -/* Combine S1 and S2 cacheability/shareability attributes, per D4.5.4 - * and CombineS1S2Desc() - * - * @env: CPUARMState - * @s1: Attributes from stage 1 walk - * @s2: Attributes from stage 2 walk - */ -ARMCacheAttrs combine_cacheattrs(CPUARMState *env, - ARMCacheAttrs s1, ARMCacheAttrs s2) -{ - ARMCacheAttrs ret; - bool tagged =3D false; - - assert(s2.is_s2_format && !s1.is_s2_format); - ret.is_s2_format =3D false; - - if (s1.attrs =3D=3D 0xf0) { - tagged =3D true; - s1.attrs =3D 0xff; - } - - /* Combine shareability attributes (table D4-43) */ - if (s1.shareability =3D=3D 2 || s2.shareability =3D=3D 2) { - /* if either are outer-shareable, the result is outer-shareable */ - ret.shareability =3D 2; - } else if (s1.shareability =3D=3D 3 || s2.shareability =3D=3D 3) { - /* if either are inner-shareable, the result is inner-shareable */ - ret.shareability =3D 3; - } else { - /* both non-shareable */ - ret.shareability =3D 0; - } - - /* Combine memory type and cacheability attributes */ - if (arm_hcr_el2_eff(env) & HCR_FWB) { - ret.attrs =3D combined_attrs_fwb(env, s1, s2); - } else { - ret.attrs =3D combined_attrs_nofwb(env, s1, s2); - } - - /* - * Any location for which the resultant memory type is any - * type of Device memory is always treated as Outer Shareable. - * Any location for which the resultant memory type is Normal - * Inner Non-cacheable, Outer Non-cacheable is always treated - * as Outer Shareable. - * TODO: FEAT_XS adds another value (0x40) also meaning iNCoNC - */ - if ((ret.attrs & 0xf0) =3D=3D 0 || ret.attrs =3D=3D 0x44) { - ret.shareability =3D 2; - } - - /* TODO: CombineS1S2Desc does not consider transient, only WB, RWA. */ - if (tagged && ret.attrs =3D=3D 0xff) { - ret.attrs =3D 0xf0; - } - - return ret; -} - hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, MemTxAttrs *attrs) { diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 5737a3976b8..f2ca2bb8fe1 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1008,6 +1008,227 @@ static bool get_phys_addr_pmsav8(CPUARMState *env, = uint32_t address, return ret; } =20 +/* + * Translate from the 4-bit stage 2 representation of + * memory attributes (without cache-allocation hints) to + * the 8-bit representation of the stage 1 MAIR registers + * (which includes allocation hints). + * + * ref: shared/translation/attrs/S2AttrDecode() + * .../S2ConvertAttrsHints() + */ +static uint8_t convert_stage2_attrs(CPUARMState *env, uint8_t s2attrs) +{ + uint8_t hiattr =3D extract32(s2attrs, 2, 2); + uint8_t loattr =3D extract32(s2attrs, 0, 2); + uint8_t hihint =3D 0, lohint =3D 0; + + if (hiattr !=3D 0) { /* normal memory */ + if (arm_hcr_el2_eff(env) & HCR_CD) { /* cache disabled */ + hiattr =3D loattr =3D 1; /* non-cacheable */ + } else { + if (hiattr !=3D 1) { /* Write-through or write-back */ + hihint =3D 3; /* RW allocate */ + } + if (loattr !=3D 1) { /* Write-through or write-back */ + lohint =3D 3; /* RW allocate */ + } + } + } + + return (hiattr << 6) | (hihint << 4) | (loattr << 2) | lohint; +} + +/* + * Combine either inner or outer cacheability attributes for normal + * memory, according to table D4-42 and pseudocode procedure + * CombineS1S2AttrHints() of ARM DDI 0487B.b (the ARMv8 ARM). + * + * NB: only stage 1 includes allocation hints (RW bits), leading to + * some asymmetry. + */ +static uint8_t combine_cacheattr_nibble(uint8_t s1, uint8_t s2) +{ + if (s1 =3D=3D 4 || s2 =3D=3D 4) { + /* non-cacheable has precedence */ + return 4; + } else if (extract32(s1, 2, 2) =3D=3D 0 || extract32(s1, 2, 2) =3D=3D = 2) { + /* stage 1 write-through takes precedence */ + return s1; + } else if (extract32(s2, 2, 2) =3D=3D 2) { + /* stage 2 write-through takes precedence, but the allocation hint + * is still taken from stage 1 + */ + return (2 << 2) | extract32(s1, 0, 2); + } else { /* write-back */ + return s1; + } +} + +/* + * Combine the memory type and cacheability attributes of + * s1 and s2 for the HCR_EL2.FWB =3D=3D 0 case, returning the + * combined attributes in MAIR_EL1 format. + */ +static uint8_t combined_attrs_nofwb(CPUARMState *env, + ARMCacheAttrs s1, ARMCacheAttrs s2) +{ + uint8_t s1lo, s2lo, s1hi, s2hi, s2_mair_attrs, ret_attrs; + + s2_mair_attrs =3D convert_stage2_attrs(env, s2.attrs); + + s1lo =3D extract32(s1.attrs, 0, 4); + s2lo =3D extract32(s2_mair_attrs, 0, 4); + s1hi =3D extract32(s1.attrs, 4, 4); + s2hi =3D extract32(s2_mair_attrs, 4, 4); + + /* Combine memory type and cacheability attributes */ + if (s1hi =3D=3D 0 || s2hi =3D=3D 0) { + /* Device has precedence over normal */ + if (s1lo =3D=3D 0 || s2lo =3D=3D 0) { + /* nGnRnE has precedence over anything */ + ret_attrs =3D 0; + } else if (s1lo =3D=3D 4 || s2lo =3D=3D 4) { + /* non-Reordering has precedence over Reordering */ + ret_attrs =3D 4; /* nGnRE */ + } else if (s1lo =3D=3D 8 || s2lo =3D=3D 8) { + /* non-Gathering has precedence over Gathering */ + ret_attrs =3D 8; /* nGRE */ + } else { + ret_attrs =3D 0xc; /* GRE */ + } + } else { /* Normal memory */ + /* Outer/inner cacheability combine independently */ + ret_attrs =3D combine_cacheattr_nibble(s1hi, s2hi) << 4 + | combine_cacheattr_nibble(s1lo, s2lo); + } + return ret_attrs; +} + +static uint8_t force_cacheattr_nibble_wb(uint8_t attr) +{ + /* + * Given the 4 bits specifying the outer or inner cacheability + * in MAIR format, return a value specifying Normal Write-Back, + * with the allocation and transient hints taken from the input + * if the input specified some kind of cacheable attribute. + */ + if (attr =3D=3D 0 || attr =3D=3D 4) { + /* + * 0 =3D=3D an UNPREDICTABLE encoding + * 4 =3D=3D Non-cacheable + * Either way, force Write-Back RW allocate non-transient + */ + return 0xf; + } + /* Change WriteThrough to WriteBack, keep allocation and transient hin= ts */ + return attr | 4; +} + +/* + * Combine the memory type and cacheability attributes of + * s1 and s2 for the HCR_EL2.FWB =3D=3D 1 case, returning the + * combined attributes in MAIR_EL1 format. + */ +static uint8_t combined_attrs_fwb(CPUARMState *env, + ARMCacheAttrs s1, ARMCacheAttrs s2) +{ + switch (s2.attrs) { + case 7: + /* Use stage 1 attributes */ + return s1.attrs; + case 6: + /* + * Force Normal Write-Back. Note that if S1 is Normal cacheable + * then we take the allocation hints from it; otherwise it is + * RW allocate, non-transient. + */ + if ((s1.attrs & 0xf0) =3D=3D 0) { + /* S1 is Device */ + return 0xff; + } + /* Need to check the Inner and Outer nibbles separately */ + return force_cacheattr_nibble_wb(s1.attrs & 0xf) | + force_cacheattr_nibble_wb(s1.attrs >> 4) << 4; + case 5: + /* If S1 attrs are Device, use them; otherwise Normal Non-cacheabl= e */ + if ((s1.attrs & 0xf0) =3D=3D 0) { + return s1.attrs; + } + return 0x44; + case 0 ... 3: + /* Force Device, of subtype specified by S2 */ + return s2.attrs << 2; + default: + /* + * RESERVED values (including RES0 descriptor bit [5] being nonzer= o); + * arbitrarily force Device. + */ + return 0; + } +} + +/* + * Combine S1 and S2 cacheability/shareability attributes, per D4.5.4 + * and CombineS1S2Desc() + * + * @env: CPUARMState + * @s1: Attributes from stage 1 walk + * @s2: Attributes from stage 2 walk + */ +static ARMCacheAttrs combine_cacheattrs(CPUARMState *env, + ARMCacheAttrs s1, ARMCacheAttrs s2) +{ + ARMCacheAttrs ret; + bool tagged =3D false; + + assert(s2.is_s2_format && !s1.is_s2_format); + ret.is_s2_format =3D false; + + if (s1.attrs =3D=3D 0xf0) { + tagged =3D true; + s1.attrs =3D 0xff; + } + + /* Combine shareability attributes (table D4-43) */ + if (s1.shareability =3D=3D 2 || s2.shareability =3D=3D 2) { + /* if either are outer-shareable, the result is outer-shareable */ + ret.shareability =3D 2; + } else if (s1.shareability =3D=3D 3 || s2.shareability =3D=3D 3) { + /* if either are inner-shareable, the result is inner-shareable */ + ret.shareability =3D 3; + } else { + /* both non-shareable */ + ret.shareability =3D 0; + } + + /* Combine memory type and cacheability attributes */ + if (arm_hcr_el2_eff(env) & HCR_FWB) { + ret.attrs =3D combined_attrs_fwb(env, s1, s2); + } else { + ret.attrs =3D combined_attrs_nofwb(env, s1, s2); + } + + /* + * Any location for which the resultant memory type is any + * type of Device memory is always treated as Outer Shareable. + * Any location for which the resultant memory type is Normal + * Inner Non-cacheable, Outer Non-cacheable is always treated + * as Outer Shareable. + * TODO: FEAT_XS adds another value (0x40) also meaning iNCoNC + */ + if ((ret.attrs & 0xf0) =3D=3D 0 || ret.attrs =3D=3D 0x44) { + ret.shareability =3D 2; + } + + /* TODO: CombineS1S2Desc does not consider transient, only WB, RWA. */ + if (tagged && ret.attrs =3D=3D 0xff) { + ret.attrs =3D 0xf0; + } + + return ret; +} + /** * get_phys_addr - get the physical address for this virtual address * --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654768682; cv=none; d=zohomail.com; s=zohoarc; b=Ruw1dptCVzvKbYhnr6Oz3Xg7SEYU51oGd/XlEdFxoWSCEKIegUVDJwGgqCgbYrSZEsoEC4GV3xvC5FgnJmz6fbUNadJHDg5QWyIjVYq0gFpcZ2ljipHXVvkZtq0i/HgTUPo3rlLrGuzRWjAeo+M+jb7RciYiiytWf9EzvAIMkLg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654768682; 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=IkbtgPvv7dCQdgswPKDWhOCh/FDmgZL+ieXHCGa70Nc=; b=n2da2l+S9dk0UyY/M4nJhBwqEh2Og9rYZS/mH1OOvOvImjZPD+RsLIrMS58f4E2dZaTIfY3aZdvObeMEIdRbSXyzdNIc+1wN+Os3rPFTINLHbC/pp01YZyJiA+HmiGumykNpXEUusjE23EPOxFFyVn7EJrzhdBKGzNxdUwCRKlk= 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 1654768682060471.7856906024871; Thu, 9 Jun 2022 02:58:02 -0700 (PDT) Received: from localhost ([::1]:43938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzEvQ-000300-Ao for importer@patchew.org; Thu, 09 Jun 2022 05:58:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7L-0001Yr-Ok for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:18 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:47100) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7G-00061B-H8 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:15 -0400 Received: by mail-wm1-x32e.google.com with SMTP id r123-20020a1c2b81000000b0039c1439c33cso12264463wmr.5 for ; Thu, 09 Jun 2022 02:06:06 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=IkbtgPvv7dCQdgswPKDWhOCh/FDmgZL+ieXHCGa70Nc=; b=uexGmZ7w53heQKOcqy9uLQQPEFllbg7yoEshVBByqDqi19iQ6HnagqXP1fQOrJBpc1 2IHmV/90X6zqfg0H1aAm+H1+ksAqy7qD/iDjVY1oiJ8GBfPYDk8wkYfT0MN943CAgRpd PINdbyGFtWLCNzQSILGbEMa/6UmjVqB3nQJiYwprIco+/TRslz7fuKe16Fb6LT6RQz+x fGxzI84cmPFa9hFsTiuBaDxBo6AyZzs+gw5eBzlq75tTnYbVSv7oBhbtMa/QeDkzMO3k 8su8vGpLLkYviwAfD5rxueLRYgAeoosoR3TQtDI8tgvuO908BSoZ9T0INn4mqtB4U8Vp c/qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IkbtgPvv7dCQdgswPKDWhOCh/FDmgZL+ieXHCGa70Nc=; b=hAY410lb1OAuXxdJ8FB5VBQY8QtKmq8iD0VUM6WCtgiK65Vyp+LuXNstLKZbABrTju M6tEpIqhqUyhRTP1FdDKjqCrbWMi/ZwhFMxjj/60zp9CTHTJJoqBP8Y18qwgjOaYWP+w aSmtuqPAJgtoeWH8cs/EhusoejsPXJeyhauBNfcYYhgsv3bb5EC+OG3yW4Bqcm2KZLyN LcIGmcGa27tcPblBlfBjVxx76xT0am9k+CejDMk9KgfEbmvVsfqHeE/ZVdsrCP/YZI/A R50g/q8kyHJHx5pdwp/yhkkSUkSybgnhqCjUOuBlk2qVXlRXI1cz1/UT7VndceDTOZKM np9A== X-Gm-Message-State: AOAM530fdAdUAO48syIHhvhXr/LojzI46t7s/mAa/r+4pt+Uw7bjA8mb G5s9au/aF0epLViJDjpKal6HgyrMLBmtFQ== X-Google-Smtp-Source: ABdhPJyX9etWV5k2EzvvFdG0fLTog0UjKECH+YpBhFYR41rOpxjIT9BTvcHwreKK7vyffY3X67trfg== X-Received: by 2002:a05:600c:2e14:b0:39c:58c4:c6ed with SMTP id o20-20020a05600c2e1400b0039c58c4c6edmr2306223wmf.156.1654765565602; Thu, 09 Jun 2022 02:06:05 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 22/55] target/arm: Move get_phys_addr_lpae to ptw.c Date: Thu, 9 Jun 2022 10:05:04 +0100 Message-Id: <20220609090537.1971756-23-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654768684035100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-16-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 10 ++ target/arm/helper.c | 416 +------------------------------------------- target/arm/ptw.c | 411 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 429 insertions(+), 408 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index b2dfe489bbe..31744df6646 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -11,6 +11,8 @@ =20 #ifndef CONFIG_USER_ONLY =20 +extern const uint8_t pamax_map[7]; + uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi); uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, @@ -30,6 +32,14 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx= , int ap) return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); } =20 +ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, + ARMMMUIdx mmu_idx); +bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, + int inputsize, int stride, int outputsize); +int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0); +int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, + int ap, int ns, int xn, int pxn); + bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, bool s1_is_el0, diff --git a/target/arm/helper.c b/target/arm/helper.c index dab485e64ae..7de815fe986 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10652,7 +10652,7 @@ int simple_ap_to_rw_prot_is_user(int ap, bool is_us= er) * @xn: XN (execute-never) bits * @s1_is_el0: true if this is S2 of an S1+2 walk for EL0 */ -static int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0) +int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0) { int prot =3D 0; =20 @@ -10703,8 +10703,8 @@ static int get_S2prot(CPUARMState *env, int s2ap, i= nt xn, bool s1_is_el0) * @xn: XN (execute-never) bit * @pxn: PXN (privileged execute-never) bit */ -static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, - int ap, int ns, int xn, int pxn) +int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, + int ap, int ns, int xn, int pxn) { bool is_user =3D regime_is_user(env, mmu_idx); int prot_rw, user_rw; @@ -10919,8 +10919,8 @@ uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, boo= l is_secure, * Returns true if the suggested S2 translation parameters are OK and * false otherwise. */ -static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, - int inputsize, int stride, int outputsize) +bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, + int inputsize, int stride, int outputsize) { const int grainsize =3D stride + 3; int startsizecheck; @@ -10980,7 +10980,7 @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is= _aa64, int level, #endif /* !CONFIG_USER_ONLY */ =20 /* This mapping is common between ID_AA64MMFR0.PARANGE and TCR_ELx.{I}PS. = */ -static const uint8_t pamax_map[] =3D { +const uint8_t pamax_map[] =3D { [0] =3D 32, [1] =3D 36, [2] =3D 40, @@ -11159,8 +11159,8 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, } =20 #ifndef CONFIG_USER_ONLY -static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, - ARMMMUIdx mmu_idx) +ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, + ARMMMUIdx mmu_idx) { uint64_t tcr =3D regime_tcr(env, mmu_idx)->raw_tcr; uint32_t el =3D regime_el(env, mmu_idx); @@ -11223,406 +11223,6 @@ static ARMVAParameters aa32_va_parameters(CPUARMS= tate *env, uint32_t va, }; } =20 -/** - * get_phys_addr_lpae: perform one stage of page table walk, LPAE format - * - * Returns false if the translation was successful. Otherwise, phys_ptr, a= ttrs, - * prot and page_size may not be filled in, and the populated fsr value pr= ovides - * information on why the translation aborted, in the format of a long-for= mat - * DFSR/IFSR fault register, with the following caveats: - * * the WnR bit is never set (the caller must do this). - * - * @env: CPUARMState - * @address: virtual address to get physical address for - * @access_type: MMU_DATA_LOAD, MMU_DATA_STORE or MMU_INST_FETCH - * @mmu_idx: MMU index indicating required translation regime - * @s1_is_el0: if @mmu_idx is ARMMMUIdx_Stage2 (so this is a stage 2 page = table - * walk), must be true if this is stage 2 of a stage 1+2 walk = for an - * EL0 access). If @mmu_idx is anything else, @s1_is_el0 is ig= nored. - * @phys_ptr: set to the physical address corresponding to the virtual add= ress - * @attrs: set to the memory transaction attributes to use - * @prot: set to the permissions for the page containing phys_ptr - * @page_size_ptr: set to the size of the page containing phys_ptr - * @fi: set to fault info if the translation fails - * @cacheattrs: (if non-NULL) set to the cacheability/shareability attribu= tes - */ -bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - bool s1_is_el0, - hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, - target_ulong *page_size_ptr, - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) -{ - ARMCPU *cpu =3D env_archcpu(env); - CPUState *cs =3D CPU(cpu); - /* Read an LPAE long-descriptor translation table. */ - ARMFaultType fault_type =3D ARMFault_Translation; - uint32_t level; - ARMVAParameters param; - uint64_t ttbr; - hwaddr descaddr, indexmask, indexmask_grainsize; - uint32_t tableattrs; - target_ulong page_size; - uint32_t attrs; - int32_t stride; - int addrsize, inputsize, outputsize; - TCR *tcr =3D regime_tcr(env, mmu_idx); - int ap, ns, xn, pxn; - uint32_t el =3D regime_el(env, mmu_idx); - uint64_t descaddrmask; - bool aarch64 =3D arm_el_is_aa64(env, el); - bool guarded =3D false; - - /* TODO: This code does not support shareability levels. */ - if (aarch64) { - int ps; - - param =3D aa64_va_parameters(env, address, mmu_idx, - access_type !=3D MMU_INST_FETCH); - level =3D 0; - - /* - * If TxSZ is programmed to a value larger than the maximum, - * or smaller than the effective minimum, it is IMPLEMENTATION - * DEFINED whether we behave as if the field were programmed - * within bounds, or if a level 0 Translation fault is generated. - * - * With FEAT_LVA, fault on less than minimum becomes required, - * so our choice is to always raise the fault. - */ - if (param.tsz_oob) { - fault_type =3D ARMFault_Translation; - goto do_fault; - } - - addrsize =3D 64 - 8 * param.tbi; - inputsize =3D 64 - param.tsz; - - /* - * Bound PS by PARANGE to find the effective output address size. - * ID_AA64MMFR0 is a read-only register so values outside of the - * supported mappings can be considered an implementation error. - */ - ps =3D FIELD_EX64(cpu->isar.id_aa64mmfr0, ID_AA64MMFR0, PARANGE); - ps =3D MIN(ps, param.ps); - assert(ps < ARRAY_SIZE(pamax_map)); - outputsize =3D pamax_map[ps]; - } else { - param =3D aa32_va_parameters(env, address, mmu_idx); - level =3D 1; - addrsize =3D (mmu_idx =3D=3D ARMMMUIdx_Stage2 ? 40 : 32); - inputsize =3D addrsize - param.tsz; - outputsize =3D 40; - } - - /* - * We determined the region when collecting the parameters, but we - * have not yet validated that the address is valid for the region. - * Extract the top bits and verify that they all match select. - * - * For aa32, if inputsize =3D=3D addrsize, then we have selected the - * region by exclusion in aa32_va_parameters and there is no more - * validation to do here. - */ - if (inputsize < addrsize) { - target_ulong top_bits =3D sextract64(address, inputsize, - addrsize - inputsize); - if (-top_bits !=3D param.select) { - /* The gap between the two regions is a Translation fault */ - fault_type =3D ARMFault_Translation; - goto do_fault; - } - } - - if (param.using64k) { - stride =3D 13; - } else if (param.using16k) { - stride =3D 11; - } else { - stride =3D 9; - } - - /* Note that QEMU ignores shareability and cacheability attributes, - * so we don't need to do anything with the SH, ORGN, IRGN fields - * in the TTBCR. Similarly, TTBCR:A1 selects whether we get the - * ASID from TTBR0 or TTBR1, but QEMU's TLB doesn't currently - * implement any ASID-like capability so we can ignore it (instead - * we will always flush the TLB any time the ASID is changed). - */ - ttbr =3D regime_ttbr(env, mmu_idx, param.select); - - /* Here we should have set up all the parameters for the translation: - * inputsize, ttbr, epd, stride, tbi - */ - - if (param.epd) { - /* Translation table walk disabled =3D> Translation fault on TLB m= iss - * Note: This is always 0 on 64-bit EL2 and EL3. - */ - goto do_fault; - } - - if (mmu_idx !=3D ARMMMUIdx_Stage2 && mmu_idx !=3D ARMMMUIdx_Stage2_S) { - /* The starting level depends on the virtual address size (which c= an - * be up to 48 bits) and the translation granule size. It indicates - * the number of strides (stride bits at a time) needed to - * consume the bits of the input address. In the pseudocode this i= s: - * level =3D 4 - RoundUp((inputsize - grainsize) / stride) - * where their 'inputsize' is our 'inputsize', 'grainsize' is - * our 'stride + 3' and 'stride' is our 'stride'. - * Applying the usual "rounded up m/n is (m+n-1)/n" and simplifyin= g: - * =3D 4 - (inputsize - stride - 3 + stride - 1) / stride - * =3D 4 - (inputsize - 4) / stride; - */ - level =3D 4 - (inputsize - 4) / stride; - } else { - /* For stage 2 translations the starting level is specified by the - * VTCR_EL2.SL0 field (whose interpretation depends on the page si= ze) - */ - uint32_t sl0 =3D extract32(tcr->raw_tcr, 6, 2); - uint32_t sl2 =3D extract64(tcr->raw_tcr, 33, 1); - uint32_t startlevel; - bool ok; - - /* SL2 is RES0 unless DS=3D1 & 4kb granule. */ - if (param.ds && stride =3D=3D 9 && sl2) { - if (sl0 !=3D 0) { - level =3D 0; - fault_type =3D ARMFault_Translation; - goto do_fault; - } - startlevel =3D -1; - } else if (!aarch64 || stride =3D=3D 9) { - /* AArch32 or 4KB pages */ - startlevel =3D 2 - sl0; - - if (cpu_isar_feature(aa64_st, cpu)) { - startlevel &=3D 3; - } - } else { - /* 16KB or 64KB pages */ - startlevel =3D 3 - sl0; - } - - /* Check that the starting level is valid. */ - ok =3D check_s2_mmu_setup(cpu, aarch64, startlevel, - inputsize, stride, outputsize); - if (!ok) { - fault_type =3D ARMFault_Translation; - goto do_fault; - } - level =3D startlevel; - } - - indexmask_grainsize =3D MAKE_64BIT_MASK(0, stride + 3); - indexmask =3D MAKE_64BIT_MASK(0, inputsize - (stride * (4 - level))); - - /* Now we can extract the actual base address from the TTBR */ - descaddr =3D extract64(ttbr, 0, 48); - - /* - * For FEAT_LPA and PS=3D6, bits [51:48] of descaddr are in [5:2] of T= TBR. - * - * Otherwise, if the base address is out of range, raise AddressSizeFa= ult. - * In the pseudocode, this is !IsZero(baseregister<47:outputsize>), - * but we've just cleared the bits above 47, so simplify the test. - */ - if (outputsize > 48) { - descaddr |=3D extract64(ttbr, 2, 4) << 48; - } else if (descaddr >> outputsize) { - level =3D 0; - fault_type =3D ARMFault_AddressSize; - goto do_fault; - } - - /* - * We rely on this masking to clear the RES0 bits at the bottom of the= TTBR - * and also to mask out CnP (bit 0) which could validly be non-zero. - */ - descaddr &=3D ~indexmask; - - /* - * For AArch32, the address field in the descriptor goes up to bit 39 - * for both v7 and v8. However, for v8 the SBZ bits [47:40] must be 0 - * or an AddressSize fault is raised. So for v8 we extract those SBZ - * bits as part of the address, which will be checked via outputsize. - * For AArch64, the address field goes up to bit 47, or 49 with FEAT_L= PA2; - * the highest bits of a 52-bit output are placed elsewhere. - */ - if (param.ds) { - descaddrmask =3D MAKE_64BIT_MASK(0, 50); - } else if (arm_feature(env, ARM_FEATURE_V8)) { - descaddrmask =3D MAKE_64BIT_MASK(0, 48); - } else { - descaddrmask =3D MAKE_64BIT_MASK(0, 40); - } - descaddrmask &=3D ~indexmask_grainsize; - - /* Secure accesses start with the page table in secure memory and - * can be downgraded to non-secure at any step. Non-secure accesses - * remain non-secure. We implement this by just ORing in the NSTable/NS - * bits at each step. - */ - tableattrs =3D regime_is_secure(env, mmu_idx) ? 0 : (1 << 4); - for (;;) { - uint64_t descriptor; - bool nstable; - - descaddr |=3D (address >> (stride * (4 - level))) & indexmask; - descaddr &=3D ~7ULL; - nstable =3D extract32(tableattrs, 4, 1); - descriptor =3D arm_ldq_ptw(cs, descaddr, !nstable, mmu_idx, fi); - if (fi->type !=3D ARMFault_None) { - goto do_fault; - } - - if (!(descriptor & 1) || - (!(descriptor & 2) && (level =3D=3D 3))) { - /* Invalid, or the Reserved level 3 encoding */ - goto do_fault; - } - - descaddr =3D descriptor & descaddrmask; - - /* - * For FEAT_LPA and PS=3D6, bits [51:48] of descaddr are in [15:12] - * of descriptor. For FEAT_LPA2 and effective DS, bits [51:50] of - * descaddr are in [9:8]. Otherwise, if descaddr is out of range, - * raise AddressSizeFault. - */ - if (outputsize > 48) { - if (param.ds) { - descaddr |=3D extract64(descriptor, 8, 2) << 50; - } else { - descaddr |=3D extract64(descriptor, 12, 4) << 48; - } - } else if (descaddr >> outputsize) { - fault_type =3D ARMFault_AddressSize; - goto do_fault; - } - - if ((descriptor & 2) && (level < 3)) { - /* Table entry. The top five bits are attributes which may - * propagate down through lower levels of the table (and - * which are all arranged so that 0 means "no effect", so - * we can gather them up by ORing in the bits at each level). - */ - tableattrs |=3D extract64(descriptor, 59, 5); - level++; - indexmask =3D indexmask_grainsize; - continue; - } - /* - * Block entry at level 1 or 2, or page entry at level 3. - * These are basically the same thing, although the number - * of bits we pull in from the vaddr varies. Note that although - * descaddrmask masks enough of the low bits of the descriptor - * to give a correct page or table address, the address field - * in a block descriptor is smaller; so we need to explicitly - * clear the lower bits here before ORing in the low vaddr bits. - */ - page_size =3D (1ULL << ((stride * (4 - level)) + 3)); - descaddr &=3D ~(page_size - 1); - descaddr |=3D (address & (page_size - 1)); - /* Extract attributes from the descriptor */ - attrs =3D extract64(descriptor, 2, 10) - | (extract64(descriptor, 52, 12) << 10); - - if (mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_St= age2_S) { - /* Stage 2 table descriptors do not include any attribute fiel= ds */ - break; - } - /* Merge in attributes from table descriptors */ - attrs |=3D nstable << 3; /* NS */ - guarded =3D extract64(descriptor, 50, 1); /* GP */ - if (param.hpd) { - /* HPD disables all the table attributes except NSTable. */ - break; - } - attrs |=3D extract32(tableattrs, 0, 2) << 11; /* XN, PXN */ - /* The sense of AP[1] vs APTable[0] is reversed, as APTable[0] =3D= =3D 1 - * means "force PL1 access only", which means forcing AP[1] to 0. - */ - attrs &=3D ~(extract32(tableattrs, 2, 1) << 4); /* !APT[0] =3D> = AP[1] */ - attrs |=3D extract32(tableattrs, 3, 1) << 5; /* APT[1] =3D> A= P[2] */ - break; - } - /* Here descaddr is the final physical address, and attributes - * are all in attrs. - */ - fault_type =3D ARMFault_AccessFlag; - if ((attrs & (1 << 8)) =3D=3D 0) { - /* Access flag */ - goto do_fault; - } - - ap =3D extract32(attrs, 4, 2); - - if (mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_Stage2= _S) { - ns =3D mmu_idx =3D=3D ARMMMUIdx_Stage2; - xn =3D extract32(attrs, 11, 2); - *prot =3D get_S2prot(env, ap, xn, s1_is_el0); - } else { - ns =3D extract32(attrs, 3, 1); - xn =3D extract32(attrs, 12, 1); - pxn =3D extract32(attrs, 11, 1); - *prot =3D get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn); - } - - fault_type =3D ARMFault_Permission; - if (!(*prot & (1 << access_type))) { - goto do_fault; - } - - if (ns) { - /* The NS bit will (as required by the architecture) have no effec= t if - * the CPU doesn't support TZ or this is a non-secure translation - * regime, because the attribute will already be non-secure. - */ - txattrs->secure =3D false; - } - /* When in aarch64 mode, and BTI is enabled, remember GP in the IOTLB.= */ - if (aarch64 && guarded && cpu_isar_feature(aa64_bti, cpu)) { - arm_tlb_bti_gp(txattrs) =3D true; - } - - if (mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_Stage2= _S) { - cacheattrs->is_s2_format =3D true; - cacheattrs->attrs =3D extract32(attrs, 0, 4); - } else { - /* Index into MAIR registers for cache attributes */ - uint8_t attrindx =3D extract32(attrs, 0, 3); - uint64_t mair =3D env->cp15.mair_el[regime_el(env, mmu_idx)]; - assert(attrindx <=3D 7); - cacheattrs->is_s2_format =3D false; - cacheattrs->attrs =3D extract64(mair, attrindx * 8, 8); - } - - /* - * For FEAT_LPA2 and effective DS, the SH field in the attributes - * was re-purposed for output address bits. The SH attribute in - * that case comes from TCR_ELx, which we extracted earlier. - */ - if (param.ds) { - cacheattrs->shareability =3D param.sh; - } else { - cacheattrs->shareability =3D extract32(attrs, 6, 2); - } - - *phys_ptr =3D descaddr; - *page_size_ptr =3D page_size; - return false; - -do_fault: - fi->type =3D fault_type; - fi->level =3D level; - /* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */ - fi->stage2 =3D fi->s1ptw || (mmu_idx =3D=3D ARMMMUIdx_Stage2 || - mmu_idx =3D=3D ARMMMUIdx_Stage2_S); - fi->s1ns =3D mmu_idx =3D=3D ARMMMUIdx_Stage2; - return true; -} - hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, MemTxAttrs *attrs) { diff --git a/target/arm/ptw.c b/target/arm/ptw.c index f2ca2bb8fe1..cbccf91b132 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -314,6 +314,417 @@ do_fault: return true; } =20 +/** + * get_phys_addr_lpae: perform one stage of page table walk, LPAE format + * + * Returns false if the translation was successful. Otherwise, phys_ptr, + * attrs, prot and page_size may not be filled in, and the populated fsr + * value provides information on why the translation aborted, in the format + * of a long-format DFSR/IFSR fault register, with the following caveat: + * the WnR bit is never set (the caller must do this). + * + * @env: CPUARMState + * @address: virtual address to get physical address for + * @access_type: MMU_DATA_LOAD, MMU_DATA_STORE or MMU_INST_FETCH + * @mmu_idx: MMU index indicating required translation regime + * @s1_is_el0: if @mmu_idx is ARMMMUIdx_Stage2 (so this is a stage 2 page + * table walk), must be true if this is stage 2 of a stage 1+2 + * walk for an EL0 access. If @mmu_idx is anything else, + * @s1_is_el0 is ignored. + * @phys_ptr: set to the physical address corresponding to the virtual add= ress + * @attrs: set to the memory transaction attributes to use + * @prot: set to the permissions for the page containing phys_ptr + * @page_size_ptr: set to the size of the page containing phys_ptr + * @fi: set to fault info if the translation fails + * @cacheattrs: (if non-NULL) set to the cacheability/shareability attribu= tes + */ +bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, + MMUAccessType access_type, ARMMMUIdx mmu_idx, + bool s1_is_el0, + hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, + target_ulong *page_size_ptr, + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) +{ + ARMCPU *cpu =3D env_archcpu(env); + CPUState *cs =3D CPU(cpu); + /* Read an LPAE long-descriptor translation table. */ + ARMFaultType fault_type =3D ARMFault_Translation; + uint32_t level; + ARMVAParameters param; + uint64_t ttbr; + hwaddr descaddr, indexmask, indexmask_grainsize; + uint32_t tableattrs; + target_ulong page_size; + uint32_t attrs; + int32_t stride; + int addrsize, inputsize, outputsize; + TCR *tcr =3D regime_tcr(env, mmu_idx); + int ap, ns, xn, pxn; + uint32_t el =3D regime_el(env, mmu_idx); + uint64_t descaddrmask; + bool aarch64 =3D arm_el_is_aa64(env, el); + bool guarded =3D false; + + /* TODO: This code does not support shareability levels. */ + if (aarch64) { + int ps; + + param =3D aa64_va_parameters(env, address, mmu_idx, + access_type !=3D MMU_INST_FETCH); + level =3D 0; + + /* + * If TxSZ is programmed to a value larger than the maximum, + * or smaller than the effective minimum, it is IMPLEMENTATION + * DEFINED whether we behave as if the field were programmed + * within bounds, or if a level 0 Translation fault is generated. + * + * With FEAT_LVA, fault on less than minimum becomes required, + * so our choice is to always raise the fault. + */ + if (param.tsz_oob) { + fault_type =3D ARMFault_Translation; + goto do_fault; + } + + addrsize =3D 64 - 8 * param.tbi; + inputsize =3D 64 - param.tsz; + + /* + * Bound PS by PARANGE to find the effective output address size. + * ID_AA64MMFR0 is a read-only register so values outside of the + * supported mappings can be considered an implementation error. + */ + ps =3D FIELD_EX64(cpu->isar.id_aa64mmfr0, ID_AA64MMFR0, PARANGE); + ps =3D MIN(ps, param.ps); + assert(ps < ARRAY_SIZE(pamax_map)); + outputsize =3D pamax_map[ps]; + } else { + param =3D aa32_va_parameters(env, address, mmu_idx); + level =3D 1; + addrsize =3D (mmu_idx =3D=3D ARMMMUIdx_Stage2 ? 40 : 32); + inputsize =3D addrsize - param.tsz; + outputsize =3D 40; + } + + /* + * We determined the region when collecting the parameters, but we + * have not yet validated that the address is valid for the region. + * Extract the top bits and verify that they all match select. + * + * For aa32, if inputsize =3D=3D addrsize, then we have selected the + * region by exclusion in aa32_va_parameters and there is no more + * validation to do here. + */ + if (inputsize < addrsize) { + target_ulong top_bits =3D sextract64(address, inputsize, + addrsize - inputsize); + if (-top_bits !=3D param.select) { + /* The gap between the two regions is a Translation fault */ + fault_type =3D ARMFault_Translation; + goto do_fault; + } + } + + if (param.using64k) { + stride =3D 13; + } else if (param.using16k) { + stride =3D 11; + } else { + stride =3D 9; + } + + /* + * Note that QEMU ignores shareability and cacheability attributes, + * so we don't need to do anything with the SH, ORGN, IRGN fields + * in the TTBCR. Similarly, TTBCR:A1 selects whether we get the + * ASID from TTBR0 or TTBR1, but QEMU's TLB doesn't currently + * implement any ASID-like capability so we can ignore it (instead + * we will always flush the TLB any time the ASID is changed). + */ + ttbr =3D regime_ttbr(env, mmu_idx, param.select); + + /* + * Here we should have set up all the parameters for the translation: + * inputsize, ttbr, epd, stride, tbi + */ + + if (param.epd) { + /* + * Translation table walk disabled =3D> Translation fault on TLB m= iss + * Note: This is always 0 on 64-bit EL2 and EL3. + */ + goto do_fault; + } + + if (mmu_idx !=3D ARMMMUIdx_Stage2 && mmu_idx !=3D ARMMMUIdx_Stage2_S) { + /* + * The starting level depends on the virtual address size (which c= an + * be up to 48 bits) and the translation granule size. It indicates + * the number of strides (stride bits at a time) needed to + * consume the bits of the input address. In the pseudocode this i= s: + * level =3D 4 - RoundUp((inputsize - grainsize) / stride) + * where their 'inputsize' is our 'inputsize', 'grainsize' is + * our 'stride + 3' and 'stride' is our 'stride'. + * Applying the usual "rounded up m/n is (m+n-1)/n" and simplifyin= g: + * =3D 4 - (inputsize - stride - 3 + stride - 1) / stride + * =3D 4 - (inputsize - 4) / stride; + */ + level =3D 4 - (inputsize - 4) / stride; + } else { + /* + * For stage 2 translations the starting level is specified by the + * VTCR_EL2.SL0 field (whose interpretation depends on the page si= ze) + */ + uint32_t sl0 =3D extract32(tcr->raw_tcr, 6, 2); + uint32_t sl2 =3D extract64(tcr->raw_tcr, 33, 1); + uint32_t startlevel; + bool ok; + + /* SL2 is RES0 unless DS=3D1 & 4kb granule. */ + if (param.ds && stride =3D=3D 9 && sl2) { + if (sl0 !=3D 0) { + level =3D 0; + fault_type =3D ARMFault_Translation; + goto do_fault; + } + startlevel =3D -1; + } else if (!aarch64 || stride =3D=3D 9) { + /* AArch32 or 4KB pages */ + startlevel =3D 2 - sl0; + + if (cpu_isar_feature(aa64_st, cpu)) { + startlevel &=3D 3; + } + } else { + /* 16KB or 64KB pages */ + startlevel =3D 3 - sl0; + } + + /* Check that the starting level is valid. */ + ok =3D check_s2_mmu_setup(cpu, aarch64, startlevel, + inputsize, stride, outputsize); + if (!ok) { + fault_type =3D ARMFault_Translation; + goto do_fault; + } + level =3D startlevel; + } + + indexmask_grainsize =3D MAKE_64BIT_MASK(0, stride + 3); + indexmask =3D MAKE_64BIT_MASK(0, inputsize - (stride * (4 - level))); + + /* Now we can extract the actual base address from the TTBR */ + descaddr =3D extract64(ttbr, 0, 48); + + /* + * For FEAT_LPA and PS=3D6, bits [51:48] of descaddr are in [5:2] of T= TBR. + * + * Otherwise, if the base address is out of range, raise AddressSizeFa= ult. + * In the pseudocode, this is !IsZero(baseregister<47:outputsize>), + * but we've just cleared the bits above 47, so simplify the test. + */ + if (outputsize > 48) { + descaddr |=3D extract64(ttbr, 2, 4) << 48; + } else if (descaddr >> outputsize) { + level =3D 0; + fault_type =3D ARMFault_AddressSize; + goto do_fault; + } + + /* + * We rely on this masking to clear the RES0 bits at the bottom of the= TTBR + * and also to mask out CnP (bit 0) which could validly be non-zero. + */ + descaddr &=3D ~indexmask; + + /* + * For AArch32, the address field in the descriptor goes up to bit 39 + * for both v7 and v8. However, for v8 the SBZ bits [47:40] must be 0 + * or an AddressSize fault is raised. So for v8 we extract those SBZ + * bits as part of the address, which will be checked via outputsize. + * For AArch64, the address field goes up to bit 47, or 49 with FEAT_L= PA2; + * the highest bits of a 52-bit output are placed elsewhere. + */ + if (param.ds) { + descaddrmask =3D MAKE_64BIT_MASK(0, 50); + } else if (arm_feature(env, ARM_FEATURE_V8)) { + descaddrmask =3D MAKE_64BIT_MASK(0, 48); + } else { + descaddrmask =3D MAKE_64BIT_MASK(0, 40); + } + descaddrmask &=3D ~indexmask_grainsize; + + /* + * Secure accesses start with the page table in secure memory and + * can be downgraded to non-secure at any step. Non-secure accesses + * remain non-secure. We implement this by just ORing in the NSTable/NS + * bits at each step. + */ + tableattrs =3D regime_is_secure(env, mmu_idx) ? 0 : (1 << 4); + for (;;) { + uint64_t descriptor; + bool nstable; + + descaddr |=3D (address >> (stride * (4 - level))) & indexmask; + descaddr &=3D ~7ULL; + nstable =3D extract32(tableattrs, 4, 1); + descriptor =3D arm_ldq_ptw(cs, descaddr, !nstable, mmu_idx, fi); + if (fi->type !=3D ARMFault_None) { + goto do_fault; + } + + if (!(descriptor & 1) || + (!(descriptor & 2) && (level =3D=3D 3))) { + /* Invalid, or the Reserved level 3 encoding */ + goto do_fault; + } + + descaddr =3D descriptor & descaddrmask; + + /* + * For FEAT_LPA and PS=3D6, bits [51:48] of descaddr are in [15:12] + * of descriptor. For FEAT_LPA2 and effective DS, bits [51:50] of + * descaddr are in [9:8]. Otherwise, if descaddr is out of range, + * raise AddressSizeFault. + */ + if (outputsize > 48) { + if (param.ds) { + descaddr |=3D extract64(descriptor, 8, 2) << 50; + } else { + descaddr |=3D extract64(descriptor, 12, 4) << 48; + } + } else if (descaddr >> outputsize) { + fault_type =3D ARMFault_AddressSize; + goto do_fault; + } + + if ((descriptor & 2) && (level < 3)) { + /* + * Table entry. The top five bits are attributes which may + * propagate down through lower levels of the table (and + * which are all arranged so that 0 means "no effect", so + * we can gather them up by ORing in the bits at each level). + */ + tableattrs |=3D extract64(descriptor, 59, 5); + level++; + indexmask =3D indexmask_grainsize; + continue; + } + /* + * Block entry at level 1 or 2, or page entry at level 3. + * These are basically the same thing, although the number + * of bits we pull in from the vaddr varies. Note that although + * descaddrmask masks enough of the low bits of the descriptor + * to give a correct page or table address, the address field + * in a block descriptor is smaller; so we need to explicitly + * clear the lower bits here before ORing in the low vaddr bits. + */ + page_size =3D (1ULL << ((stride * (4 - level)) + 3)); + descaddr &=3D ~(page_size - 1); + descaddr |=3D (address & (page_size - 1)); + /* Extract attributes from the descriptor */ + attrs =3D extract64(descriptor, 2, 10) + | (extract64(descriptor, 52, 12) << 10); + + if (mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_St= age2_S) { + /* Stage 2 table descriptors do not include any attribute fiel= ds */ + break; + } + /* Merge in attributes from table descriptors */ + attrs |=3D nstable << 3; /* NS */ + guarded =3D extract64(descriptor, 50, 1); /* GP */ + if (param.hpd) { + /* HPD disables all the table attributes except NSTable. */ + break; + } + attrs |=3D extract32(tableattrs, 0, 2) << 11; /* XN, PXN */ + /* + * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] =3D= =3D 1 + * means "force PL1 access only", which means forcing AP[1] to 0. + */ + attrs &=3D ~(extract32(tableattrs, 2, 1) << 4); /* !APT[0] =3D> = AP[1] */ + attrs |=3D extract32(tableattrs, 3, 1) << 5; /* APT[1] =3D> A= P[2] */ + break; + } + /* + * Here descaddr is the final physical address, and attributes + * are all in attrs. + */ + fault_type =3D ARMFault_AccessFlag; + if ((attrs & (1 << 8)) =3D=3D 0) { + /* Access flag */ + goto do_fault; + } + + ap =3D extract32(attrs, 4, 2); + + if (mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_Stage2= _S) { + ns =3D mmu_idx =3D=3D ARMMMUIdx_Stage2; + xn =3D extract32(attrs, 11, 2); + *prot =3D get_S2prot(env, ap, xn, s1_is_el0); + } else { + ns =3D extract32(attrs, 3, 1); + xn =3D extract32(attrs, 12, 1); + pxn =3D extract32(attrs, 11, 1); + *prot =3D get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn); + } + + fault_type =3D ARMFault_Permission; + if (!(*prot & (1 << access_type))) { + goto do_fault; + } + + if (ns) { + /* + * The NS bit will (as required by the architecture) have no effec= t if + * the CPU doesn't support TZ or this is a non-secure translation + * regime, because the attribute will already be non-secure. + */ + txattrs->secure =3D false; + } + /* When in aarch64 mode, and BTI is enabled, remember GP in the IOTLB.= */ + if (aarch64 && guarded && cpu_isar_feature(aa64_bti, cpu)) { + arm_tlb_bti_gp(txattrs) =3D true; + } + + if (mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_Stage2= _S) { + cacheattrs->is_s2_format =3D true; + cacheattrs->attrs =3D extract32(attrs, 0, 4); + } else { + /* Index into MAIR registers for cache attributes */ + uint8_t attrindx =3D extract32(attrs, 0, 3); + uint64_t mair =3D env->cp15.mair_el[regime_el(env, mmu_idx)]; + assert(attrindx <=3D 7); + cacheattrs->is_s2_format =3D false; + cacheattrs->attrs =3D extract64(mair, attrindx * 8, 8); + } + + /* + * For FEAT_LPA2 and effective DS, the SH field in the attributes + * was re-purposed for output address bits. The SH attribute in + * that case comes from TCR_ELx, which we extracted earlier. + */ + if (param.ds) { + cacheattrs->shareability =3D param.sh; + } else { + cacheattrs->shareability =3D extract32(attrs, 6, 2); + } + + *phys_ptr =3D descaddr; + *page_size_ptr =3D page_size; + return false; + +do_fault: + fi->type =3D fault_type; + fi->level =3D level; + /* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */ + fi->stage2 =3D fi->s1ptw || (mmu_idx =3D=3D ARMMMUIdx_Stage2 || + mmu_idx =3D=3D ARMMMUIdx_Stage2_S); + fi->s1ns =3D mmu_idx =3D=3D ARMMMUIdx_Stage2; + return true; +} + static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_= idx, hwaddr *phys_ptr, int *prot, --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654771410; cv=none; d=zohomail.com; s=zohoarc; b=bwS11p1LzL5vvjkF+86YeBfLtS7TXKlFBpOzIPhE2xUm3SZnCjRgyXfzfrTSftmLwCjQ1poxXhJgY2MR1nVjrhQUJLWxx1HHgjz7mUQ27l6qcq5M7dsQ0UrW1n/zwLs6ZAIqgItdmb/aU/LH5t1QkW9xKKjveM5XV/HsnA5uvks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654771410; 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=DsW3nbtPSrSfTu9Rena6hSRG4ePZWb5I260ZDnqhOaQ=; b=Vs+xWVpTLwJTlcNvKDVjJDHeCPMRDwHLAME+cEOA942NH7f/KaN9Du94TAHh6OZtvJfOPqMG4jN627flmiWj14Wn/USYG7OB/zL8KB5qiYEU5u70UNJsjXQt8TIMyUm2UArb0+cEVRuBvbwz+s4JL2pRcQfc1XMjD1l80IuWLAI= 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 1654771410314496.4403838363919; Thu, 9 Jun 2022 03:43:30 -0700 (PDT) Received: from localhost ([::1]:60330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFdQ-0002sU-K2 for importer@patchew.org; Thu, 09 Jun 2022 06:43:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7K-0001Yq-H2 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:18 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:40576) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7F-000633-2Y for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:14 -0400 Received: by mail-wm1-x336.google.com with SMTP id j5-20020a05600c1c0500b0039c5dbbfa48so3048438wms.5 for ; Thu, 09 Jun 2022 02:06:07 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=DsW3nbtPSrSfTu9Rena6hSRG4ePZWb5I260ZDnqhOaQ=; b=ZZjTHK2siwm0u69fTlk3CnlYIS06ODUXpXqs7PuwMYQkNILJofl0DleClJfx1XF4G4 BB9FhVDlNJWE98Q2x2vwZwa+qd3j1yHd5gKx1WA9bCFMR5OZGtfv27lau2MuDLtQxj0w WDRS+7X6X7EGeoY7sYtyT/TuoDyGjrKD5RDULq5gQVoP1pv5Uqg5VBK6e4vqwXkjXzeC FPwu8mJsuulorgRE+pvNYrkul6MjmEDnmXrOcip5BBsLzIevPn4hNdwrakldQhrx1561 BnDLN35bHB3J2O2frxFc1GolMWvvGujG2tXmXkByYInUv5rW1cnxwh9fMX3cYUxy9vye UsRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DsW3nbtPSrSfTu9Rena6hSRG4ePZWb5I260ZDnqhOaQ=; b=1fPPgN/x3u4JJsswXg64idTvGGsYlp3X31fty/FLZ+a1hRmRLlseXlxImL0dMNs2m0 Ry5pdn/kBgmT/l6Aym9TWUn8FCoCgGEivYHc1f6CMkd5pgxbffUqb3af81+FvCxYVA4l YB8P/XLm9pP5WyO3OXIyoCQiIXPzkPP+zXBznzhXpK6gu08MqBQUYvegQr17+TQPVKiZ 6wWfzA68ERANjXtERmxh8jt1FG1t+U0wYY0M4apGDOTQyB+ZI0IzlagAN5zw5/KMrzni WBpRfdrkhBDQLRlvNjbTJ0DKOkSzW1lqa0+3/POoR+tQOEQozRnFX2Sqv3xwoC28d7jl R0oQ== X-Gm-Message-State: AOAM530geySCj0DwIaz+Rmzy2FtSAB6s+Ou9OVU9D8ezlU5Nz4t2xOo3 Iy5ZbOds32WbTXs5mBtWsVksLtJ77iMxLQ== X-Google-Smtp-Source: ABdhPJyW4Dsesi96PK/47D4fBgvd7I/dUBpj5KpEAsRVxVLnTwKwogQ6vZfqtRbHAiqbYZdDtsV+Tw== X-Received: by 2002:a05:600c:3792:b0:39c:6667:202 with SMTP id o18-20020a05600c379200b0039c66670202mr2254531wmr.104.1654765566707; Thu, 09 Jun 2022 02:06:06 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 23/55] target/arm: Move arm_{ldl,ldq}_ptw to ptw.c Date: Thu, 9 Jun 2022 10:05:05 +0100 Message-Id: <20220609090537.1971756-24-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654771411031100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Move the ptw load functions, plus 3 common subroutines: S1_ptw_translate, ptw_attrs_are_device, and regime_translation_big_endian. This also allows get_phys_addr_lpae to become static again. Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-17-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 13 ---- target/arm/helper.c | 141 -------------------------------------- target/arm/ptw.c | 160 ++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 154 insertions(+), 160 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index 31744df6646..28b8cb9fb89 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -13,11 +13,6 @@ =20 extern const uint8_t pamax_map[7]; =20 -uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, - ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi); -uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, - ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi); - bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx); bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn); @@ -40,13 +35,5 @@ int get_S2prot(CPUARMState *env, int s2ap, int xn, bool = s1_is_el0); int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, int ap, int ns, int xn, int pxn); =20 -bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - bool s1_is_el0, - hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, - target_ulong *page_size_ptr, - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) - __attribute__((nonnull)); - #endif /* !CONFIG_USER_ONLY */ #endif /* TARGET_ARM_PTW_H */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 7de815fe986..398bcd62ab9 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10475,12 +10475,6 @@ bool regime_translation_disabled(CPUARMState *env,= ARMMMUIdx mmu_idx) return (regime_sctlr(env, mmu_idx) & SCTLR_M) =3D=3D 0; } =20 -static inline bool regime_translation_big_endian(CPUARMState *env, - ARMMMUIdx mmu_idx) -{ - return (regime_sctlr(env, mmu_idx) & SCTLR_EE) !=3D 0; -} - /* Return the TTBR associated with this translation regime */ uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn) { @@ -10773,141 +10767,6 @@ int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_id= x, bool is_aa64, return prot_rw | PAGE_EXEC; } =20 -static bool ptw_attrs_are_device(CPUARMState *env, ARMCacheAttrs cacheattr= s) -{ - /* - * For an S1 page table walk, the stage 1 attributes are always - * some form of "this is Normal memory". The combined S1+S2 - * attributes are therefore only Device if stage 2 specifies Device. - * With HCR_EL2.FWB =3D=3D 0 this is when descriptor bits [5:4] are 0b= 00, - * ie when cacheattrs.attrs bits [3:2] are 0b00. - * With HCR_EL2.FWB =3D=3D 1 this is when descriptor bit [4] is 0, ie - * when cacheattrs.attrs bit [2] is 0. - */ - assert(cacheattrs.is_s2_format); - if (arm_hcr_el2_eff(env) & HCR_FWB) { - return (cacheattrs.attrs & 0x4) =3D=3D 0; - } else { - return (cacheattrs.attrs & 0xc) =3D=3D 0; - } -} - -/* Translate a S1 pagetable walk through S2 if needed. */ -static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, - hwaddr addr, bool *is_secure, - ARMMMUFaultInfo *fi) -{ - if (arm_mmu_idx_is_stage1_of_2(mmu_idx) && - !regime_translation_disabled(env, ARMMMUIdx_Stage2)) { - target_ulong s2size; - hwaddr s2pa; - int s2prot; - int ret; - ARMMMUIdx s2_mmu_idx =3D *is_secure ? ARMMMUIdx_Stage2_S - : ARMMMUIdx_Stage2; - ARMCacheAttrs cacheattrs =3D {}; - MemTxAttrs txattrs =3D {}; - - ret =3D get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, s2_mmu_idx, f= alse, - &s2pa, &txattrs, &s2prot, &s2size, fi, - &cacheattrs); - if (ret) { - assert(fi->type !=3D ARMFault_None); - fi->s2addr =3D addr; - fi->stage2 =3D true; - fi->s1ptw =3D true; - fi->s1ns =3D !*is_secure; - return ~0; - } - if ((arm_hcr_el2_eff(env) & HCR_PTW) && - ptw_attrs_are_device(env, cacheattrs)) { - /* - * PTW set and S1 walk touched S2 Device memory: - * generate Permission fault. - */ - fi->type =3D ARMFault_Permission; - fi->s2addr =3D addr; - fi->stage2 =3D true; - fi->s1ptw =3D true; - fi->s1ns =3D !*is_secure; - return ~0; - } - - if (arm_is_secure_below_el3(env)) { - /* Check if page table walk is to secure or non-secure PA spac= e. */ - if (*is_secure) { - *is_secure =3D !(env->cp15.vstcr_el2.raw_tcr & VSTCR_SW); - } else { - *is_secure =3D !(env->cp15.vtcr_el2.raw_tcr & VTCR_NSW); - } - } else { - assert(!*is_secure); - } - - addr =3D s2pa; - } - return addr; -} - -/* All loads done in the course of a page table walk go through here. */ -uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, - ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) -{ - ARMCPU *cpu =3D ARM_CPU(cs); - CPUARMState *env =3D &cpu->env; - MemTxAttrs attrs =3D {}; - MemTxResult result =3D MEMTX_OK; - AddressSpace *as; - uint32_t data; - - addr =3D S1_ptw_translate(env, mmu_idx, addr, &is_secure, fi); - attrs.secure =3D is_secure; - as =3D arm_addressspace(cs, attrs); - if (fi->s1ptw) { - return 0; - } - if (regime_translation_big_endian(env, mmu_idx)) { - data =3D address_space_ldl_be(as, addr, attrs, &result); - } else { - data =3D address_space_ldl_le(as, addr, attrs, &result); - } - if (result =3D=3D MEMTX_OK) { - return data; - } - fi->type =3D ARMFault_SyncExternalOnWalk; - fi->ea =3D arm_extabort_type(result); - return 0; -} - -uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, - ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) -{ - ARMCPU *cpu =3D ARM_CPU(cs); - CPUARMState *env =3D &cpu->env; - MemTxAttrs attrs =3D {}; - MemTxResult result =3D MEMTX_OK; - AddressSpace *as; - uint64_t data; - - addr =3D S1_ptw_translate(env, mmu_idx, addr, &is_secure, fi); - attrs.secure =3D is_secure; - as =3D arm_addressspace(cs, attrs); - if (fi->s1ptw) { - return 0; - } - if (regime_translation_big_endian(env, mmu_idx)) { - data =3D address_space_ldq_be(as, addr, attrs, &result); - } else { - data =3D address_space_ldq_le(as, addr, attrs, &result); - } - if (result =3D=3D MEMTX_OK) { - return data; - } - fi->type =3D ARMFault_SyncExternalOnWalk; - fi->ea =3D arm_extabort_type(result); - return 0; -} - /* * check_s2_mmu_setup * @cpu: ARMCPU diff --git a/target/arm/ptw.c b/target/arm/ptw.c index cbccf91b132..e4b860d2aee 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -15,6 +15,154 @@ #include "ptw.h" =20 =20 +static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, + MMUAccessType access_type, ARMMMUIdx mmu_id= x, + bool s1_is_el0, hwaddr *phys_ptr, + MemTxAttrs *txattrs, int *prot, + target_ulong *page_size_ptr, + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheat= trs) + __attribute__((nonnull)); + +static bool regime_translation_big_endian(CPUARMState *env, ARMMMUIdx mmu_= idx) +{ + return (regime_sctlr(env, mmu_idx) & SCTLR_EE) !=3D 0; +} + +static bool ptw_attrs_are_device(CPUARMState *env, ARMCacheAttrs cacheattr= s) +{ + /* + * For an S1 page table walk, the stage 1 attributes are always + * some form of "this is Normal memory". The combined S1+S2 + * attributes are therefore only Device if stage 2 specifies Device. + * With HCR_EL2.FWB =3D=3D 0 this is when descriptor bits [5:4] are 0b= 00, + * ie when cacheattrs.attrs bits [3:2] are 0b00. + * With HCR_EL2.FWB =3D=3D 1 this is when descriptor bit [4] is 0, ie + * when cacheattrs.attrs bit [2] is 0. + */ + assert(cacheattrs.is_s2_format); + if (arm_hcr_el2_eff(env) & HCR_FWB) { + return (cacheattrs.attrs & 0x4) =3D=3D 0; + } else { + return (cacheattrs.attrs & 0xc) =3D=3D 0; + } +} + +/* Translate a S1 pagetable walk through S2 if needed. */ +static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, + hwaddr addr, bool *is_secure, + ARMMMUFaultInfo *fi) +{ + if (arm_mmu_idx_is_stage1_of_2(mmu_idx) && + !regime_translation_disabled(env, ARMMMUIdx_Stage2)) { + target_ulong s2size; + hwaddr s2pa; + int s2prot; + int ret; + ARMMMUIdx s2_mmu_idx =3D *is_secure ? ARMMMUIdx_Stage2_S + : ARMMMUIdx_Stage2; + ARMCacheAttrs cacheattrs =3D {}; + MemTxAttrs txattrs =3D {}; + + ret =3D get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, s2_mmu_idx, f= alse, + &s2pa, &txattrs, &s2prot, &s2size, fi, + &cacheattrs); + if (ret) { + assert(fi->type !=3D ARMFault_None); + fi->s2addr =3D addr; + fi->stage2 =3D true; + fi->s1ptw =3D true; + fi->s1ns =3D !*is_secure; + return ~0; + } + if ((arm_hcr_el2_eff(env) & HCR_PTW) && + ptw_attrs_are_device(env, cacheattrs)) { + /* + * PTW set and S1 walk touched S2 Device memory: + * generate Permission fault. + */ + fi->type =3D ARMFault_Permission; + fi->s2addr =3D addr; + fi->stage2 =3D true; + fi->s1ptw =3D true; + fi->s1ns =3D !*is_secure; + return ~0; + } + + if (arm_is_secure_below_el3(env)) { + /* Check if page table walk is to secure or non-secure PA spac= e. */ + if (*is_secure) { + *is_secure =3D !(env->cp15.vstcr_el2.raw_tcr & VSTCR_SW); + } else { + *is_secure =3D !(env->cp15.vtcr_el2.raw_tcr & VTCR_NSW); + } + } else { + assert(!*is_secure); + } + + addr =3D s2pa; + } + return addr; +} + +/* All loads done in the course of a page table walk go through here. */ +static uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, + ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) +{ + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + MemTxAttrs attrs =3D {}; + MemTxResult result =3D MEMTX_OK; + AddressSpace *as; + uint32_t data; + + addr =3D S1_ptw_translate(env, mmu_idx, addr, &is_secure, fi); + attrs.secure =3D is_secure; + as =3D arm_addressspace(cs, attrs); + if (fi->s1ptw) { + return 0; + } + if (regime_translation_big_endian(env, mmu_idx)) { + data =3D address_space_ldl_be(as, addr, attrs, &result); + } else { + data =3D address_space_ldl_le(as, addr, attrs, &result); + } + if (result =3D=3D MEMTX_OK) { + return data; + } + fi->type =3D ARMFault_SyncExternalOnWalk; + fi->ea =3D arm_extabort_type(result); + return 0; +} + +static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, + ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) +{ + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + MemTxAttrs attrs =3D {}; + MemTxResult result =3D MEMTX_OK; + AddressSpace *as; + uint64_t data; + + addr =3D S1_ptw_translate(env, mmu_idx, addr, &is_secure, fi); + attrs.secure =3D is_secure; + as =3D arm_addressspace(cs, attrs); + if (fi->s1ptw) { + return 0; + } + if (regime_translation_big_endian(env, mmu_idx)) { + data =3D address_space_ldq_be(as, addr, attrs, &result); + } else { + data =3D address_space_ldq_le(as, addr, attrs, &result); + } + if (result =3D=3D MEMTX_OK) { + return data; + } + fi->type =3D ARMFault_SyncExternalOnWalk; + fi->ea =3D arm_extabort_type(result); + return 0; +} + static bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, uint32_t *table, uint32_t address) { @@ -338,12 +486,12 @@ do_fault: * @fi: set to fault info if the translation fails * @cacheattrs: (if non-NULL) set to the cacheability/shareability attribu= tes */ -bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - bool s1_is_el0, - hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, - target_ulong *page_size_ptr, - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) +static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, + MMUAccessType access_type, ARMMMUIdx mmu_id= x, + bool s1_is_el0, hwaddr *phys_ptr, + MemTxAttrs *txattrs, int *prot, + target_ulong *page_size_ptr, + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheat= trs) { ARMCPU *cpu =3D env_archcpu(env); CPUState *cs =3D CPU(cpu); --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654773257; cv=none; d=zohomail.com; s=zohoarc; b=Nye08ydG8YnPXcXp0wvq//IL0dEV8MaHEYQOzW+rI9xIMh/e8R2BdB5fM4bvofJyoYcVmH0CLUMloDgmJrrRgjG/uenEGcWbJ0hCR0Cu1RRbZyrrDqAeyabHBud7gikKZc6Fp+MwQXQ5dh0BfjGpUm5mll023QaJInUWT+gRxi4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654773257; 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=LQAbBz4sWCtAO2yu2KsDdB0OcUgNeqq9QInZEXr67f8=; b=PCNgBjNR0cGspKx9AKNDy/EaQp3wVQ1ruGFjOHTY0eFwDcE6+6d9hNWbTLWPxXPUN6UOsoAUnN2rRQFff5uoX3WZU+1CU0cl8mKHuZB+1GY+O2ELQ7gOf4CjSvqUWtxQsVJNlfCMLo/0qq5bwLaIxxVFqWF1MAZZHrPLfNYjxEU= 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 1654773257746947.2452099754582; Thu, 9 Jun 2022 04:14:17 -0700 (PDT) Received: from localhost ([::1]:38360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzG7E-0004Fx-Oq for importer@patchew.org; Thu, 09 Jun 2022 07:14:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7Q-0001ZE-JP for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:22 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:51890) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7H-000638-G6 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:19 -0400 Received: by mail-wm1-x331.google.com with SMTP id z17so7275188wmi.1 for ; Thu, 09 Jun 2022 02:06:08 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=LQAbBz4sWCtAO2yu2KsDdB0OcUgNeqq9QInZEXr67f8=; b=uv2vHh+riZszdtFm3LFhhQ7v4NIhkOmxQbzVRPNGbcRLEMthArUO/YkdBK9RmAGGLx O5o7zGdZMSlq9CDf+t1porKCQqSAk1rtPs5BYKolvCoUIlXBLoiG2BoTqRc7XcN91NNu lkH5cgO0x5oTEHdgg/dNNF2Yu0XtBKW3gzdHTvqQWq13JPdqK6CHxhKH19EYGuRPUqB5 554cntq1TYAas6rBJ5Xv8WFSfBcFekr2rGAHT3PRubRq39KkM+JU38M2BzRFvX+Lwvep n/cBHbDPqjjop3CfwVsRoXiQOdaqPBPSSbRQzkdd6JpYSst5UZ52bWx/Hu3itj7kkJfi xomQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LQAbBz4sWCtAO2yu2KsDdB0OcUgNeqq9QInZEXr67f8=; b=Iw06qqy5GHMXeSEmmqmk4CuqP4O5mnN+5lbWQy9pT5mqR4E+iXpdlmkwmLinCFxTKO 4A7NPyaR4o/1CswYxpDUkw8ZgtpFe4coERV13+sWuGpdSGSAY8OjRAa84n9qP1HBlRNa VOWrKwU3qQWme2MxOb0qNOAKwWiOd40rNcNQIHuJcNYOIcmm4EYWDmPMsMdYF7Hl2WYK 7WQvZTXBWIy2lH5vjyUMILnNOjRqjLsQJrUnTkabE1elONmZhAJMrCBXJVkyHBnaMVl4 qJCtbFOw1XXz5b8LGmAK7/jTlYnZVMKpaTB8z1f60bRP045zJQAdhLfefIdREPrtHEhx 1uHw== X-Gm-Message-State: AOAM531QYqYzvRjzPvQRYO3vGzsqC4+mMnGEscMO/CW52BspRs6vbMUd Ef8B0q583+ljJBkyomDOt7xMYEQjJRKnuw== X-Google-Smtp-Source: ABdhPJz2bR733zgoNP4W82EJu5U2kXu5XO4Lo7N323F3uSBGPxmP5DMy5zDDvuXawshQBdqDJlbxmQ== X-Received: by 2002:a05:600c:2244:b0:39c:4060:1ec9 with SMTP id a4-20020a05600c224400b0039c40601ec9mr2186915wmm.147.1654765567686; Thu, 09 Jun 2022 02:06:07 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 24/55] target/arm: Move {arm_s1_, }regime_using_lpae_format to tlb_helper.c Date: Thu, 9 Jun 2022 10:05:06 +0100 Message-Id: <20220609090537.1971756-25-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654773258672100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson These functions are used for both page table walking and for deciding what format in which to deliver exception results. Since ptw.c is only present for system mode, put the functions into tlb_helper.c. Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-18-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/helper.c | 24 ------------------------ target/arm/tlb_helper.c | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 398bcd62ab9..d2b196ff3e5 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10515,30 +10515,6 @@ ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) } #endif /* !CONFIG_USER_ONLY */ =20 -/* Return true if the translation regime is using LPAE format page tables = */ -bool regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx) -{ - int el =3D regime_el(env, mmu_idx); - if (el =3D=3D 2 || arm_el_is_aa64(env, el)) { - return true; - } - if (arm_feature(env, ARM_FEATURE_LPAE) - && (regime_tcr(env, mmu_idx)->raw_tcr & TTBCR_EAE)) { - return true; - } - return false; -} - -/* Returns true if the stage 1 translation regime is using LPAE format page - * tables. Used when raising alignment exceptions, whose FSR changes depen= ding - * on whether the long or short descriptor format is in use. */ -bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx) -{ - mmu_idx =3D stage_1_mmu_idx(mmu_idx); - - return regime_using_lpae_format(env, mmu_idx); -} - #ifndef CONFIG_USER_ONLY bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) { diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c index 6421e16202e..7d8a86b3c45 100644 --- a/target/arm/tlb_helper.c +++ b/target/arm/tlb_helper.c @@ -11,6 +11,32 @@ #include "exec/exec-all.h" #include "exec/helper-proto.h" =20 + +/* Return true if the translation regime is using LPAE format page tables = */ +bool regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx) +{ + int el =3D regime_el(env, mmu_idx); + if (el =3D=3D 2 || arm_el_is_aa64(env, el)) { + return true; + } + if (arm_feature(env, ARM_FEATURE_LPAE) + && (regime_tcr(env, mmu_idx)->raw_tcr & TTBCR_EAE)) { + return true; + } + return false; +} + +/* + * Returns true if the stage 1 translation regime is using LPAE format page + * tables. Used when raising alignment exceptions, whose FSR changes depen= ding + * on whether the long or short descriptor format is in use. + */ +bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx) +{ + mmu_idx =3D stage_1_mmu_idx(mmu_idx); + return regime_using_lpae_format(env, mmu_idx); +} + static inline uint32_t merge_syn_data_abort(uint32_t template_syn, unsigned int target_el, bool same_el, bool ea, --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654769089; cv=none; d=zohomail.com; s=zohoarc; b=aebt8E73RuZQIuQ/+8vIL0iRRyucf1TNS6CXoqc8UpGtthNStvo/0WbH5FRcNcHsUU0yfhG86Mio7QDWzNtK7W9FQAIVIBw+T+JlEOHQyF0TsrW4Kpy+E40WGrq/RA5BujWPKrHBYSZP/9LDuAoW5U3oNqIR0I2ZKFW2l0JuJ18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654769089; 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=vIokLa9eFuxFiVW77KIrOZU1hdMYpdkzIffZFBXlcuc=; b=nDHeuZH/2wyL74WIkwzDltPn42Sg+GMKxiEv67CD1acbzLYFWtxyBYSQchgLeFBvb/px62h+qxZUyWmu+5eJToHEgvCmbYailQ4Up6YlRkarp994+/ivx18twmgsBBfTXNp1TZN9Xs07hQY0DoRzVyJE/9t3lQlsBnflNGiDxUM= 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 1654769089315777.617304403438; Thu, 9 Jun 2022 03:04:49 -0700 (PDT) Received: from localhost ([::1]:52960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzF1z-0001Mk-Kk for importer@patchew.org; Thu, 09 Jun 2022 06:04:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7K-0001Yp-Gw for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:18 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:43563) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7H-00063C-GG for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:14 -0400 Received: by mail-wr1-x433.google.com with SMTP id d14so22478436wra.10 for ; Thu, 09 Jun 2022 02:06:09 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=vIokLa9eFuxFiVW77KIrOZU1hdMYpdkzIffZFBXlcuc=; b=CQqjOu4DBavLPFvIx3KuaWUMdGxL+Q8upq+K2k83UjjqO8avt4fANTtmgyGvENzIlq bG0OrlgLufrp6AgPdkr3t7qpHgZT3zuQ0D439n6RukPJIZ5SNUbNuii8qTdWPz4QrjOc AVyfC+7kAnk1V2x0ArAjV/RvAQPp5LZDf7QDUl5OU0xmxWSu8YuI5eQ7vQPoLJSchP90 6T7Y0mBlOzlufl6Zmeo9GhOjGs7ZMvTSMn38YuuxleiRWjt4KOzE7Jq5mHjsB9mtMCQl VCtBi165GQz4C2P5vrROmlxyzPwcVyWR7OCnoRXhzMeWWd9DlAvr8x0e35IlhqfvVckp W2jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vIokLa9eFuxFiVW77KIrOZU1hdMYpdkzIffZFBXlcuc=; b=AMvyxtzxW2876YLWuIHObXdEjBtc7hwn5QzNckJIttp7OlY0vPPPSOUzvjS1ZmL3fI s85nNvdOv/7KiupUK4A+D9vzi4lN0l3ifLGERxUEOPhka3EppeHq0I5HoCU2Lh1GW998 XB/dcHK+epaHZuy+LVnepQxp8kfeQqEuEa6E8389O/BAFY5abinnaRn5kLpFFeteEkTY FwXBENKQZOQurpgAMFgaqR8eHw+cfW2f0TjueKloLnkdfC+c9vMGU4M7ATFgvL90fr4c z52WShNCUwqnNe8Abm2gO7WwegFdYLEt5p0q8cHdBqMNOz1kbDGTThZzXV/j4kMZKRkA zM8w== X-Gm-Message-State: AOAM533veghIVQEDxBJFw+6d+RlP5E2dd31Zhcb9iHQSCF+TC65jmsnR lFAmSQsCKE5WxSazzfX4yt9ryLBLVpCshQ== X-Google-Smtp-Source: ABdhPJwakeZ5a6QIKYbtHHG3gWrEtnC0HdHtrsge8p1M/SvAnweUdMCMnUkYwCd8N2hiXnwv/Pu7oA== X-Received: by 2002:a05:6000:1acc:b0:20f:f12a:a535 with SMTP id i12-20020a0560001acc00b0020ff12aa535mr39078137wry.375.1654765568513; Thu, 09 Jun 2022 02:06:08 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 25/55] target/arm: Move arm_pamax, pamax_map into ptw.c Date: Thu, 9 Jun 2022 10:05:07 +0100 Message-Id: <20220609090537.1971756-26-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654769090272100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-19-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 2 -- target/arm/helper.c | 25 ------------------------- target/arm/ptw.c | 25 +++++++++++++++++++++++++ 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index 28b8cb9fb89..fba650d01ca 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -11,8 +11,6 @@ =20 #ifndef CONFIG_USER_ONLY =20 -extern const uint8_t pamax_map[7]; - bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx); bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn); diff --git a/target/arm/helper.c b/target/arm/helper.c index d2b196ff3e5..563e34ecded 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10814,31 +10814,6 @@ bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64,= int level, } #endif /* !CONFIG_USER_ONLY */ =20 -/* This mapping is common between ID_AA64MMFR0.PARANGE and TCR_ELx.{I}PS. = */ -const uint8_t pamax_map[] =3D { - [0] =3D 32, - [1] =3D 36, - [2] =3D 40, - [3] =3D 42, - [4] =3D 44, - [5] =3D 48, - [6] =3D 52, -}; - -/* The cpu-specific constant value of PAMax; also used by hw/arm/virt. */ -unsigned int arm_pamax(ARMCPU *cpu) -{ - unsigned int parange =3D - FIELD_EX64(cpu->isar.id_aa64mmfr0, ID_AA64MMFR0, PARANGE); - - /* - * id_aa64mmfr0 is a read-only register so values outside of the - * supported mappings can be considered an implementation error. - */ - assert(parange < ARRAY_SIZE(pamax_map)); - return pamax_map[parange]; -} - int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx) { if (regime_has_2_ranges(mmu_idx)) { diff --git a/target/arm/ptw.c b/target/arm/ptw.c index e4b860d2aee..d754273fa16 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -23,6 +23,31 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_= t address, ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheat= trs) __attribute__((nonnull)); =20 +/* This mapping is common between ID_AA64MMFR0.PARANGE and TCR_ELx.{I}PS. = */ +static const uint8_t pamax_map[] =3D { + [0] =3D 32, + [1] =3D 36, + [2] =3D 40, + [3] =3D 42, + [4] =3D 44, + [5] =3D 48, + [6] =3D 52, +}; + +/* The cpu-specific constant value of PAMax; also used by hw/arm/virt. */ +unsigned int arm_pamax(ARMCPU *cpu) +{ + unsigned int parange =3D + FIELD_EX64(cpu->isar.id_aa64mmfr0, ID_AA64MMFR0, PARANGE); + + /* + * id_aa64mmfr0 is a read-only register so values outside of the + * supported mappings can be considered an implementation error. + */ + assert(parange < ARRAY_SIZE(pamax_map)); + return pamax_map[parange]; +} + static bool regime_translation_big_endian(CPUARMState *env, ARMMMUIdx mmu_= idx) { return (regime_sctlr(env, mmu_idx) & SCTLR_EE) !=3D 0; --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654768697; cv=none; d=zohomail.com; s=zohoarc; b=QnqFiexoMoGmWThgR7bVsesM+f55Rzhmz2Jr4OVVTJjJZDTOIOET2ZH5l80NpeVc0RpDq6bRWCy6Yj7ldy+0nQ7nHa13CQiCEegnpQ2UoA5iDAL0/FN/dDs8QVWtMbaNhakWerZajS8SFm+BIotYtgTyZO6AzXtG0kkEjvNBdNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654768697; 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=NZ83DvVjSP5f3cqPypoQ1LPQjwV9cfTRg8x9u5U5b3g=; b=KRYZaQpO7v0asV/iQ6YJUc2zwp8Lp91i1PB3Ku5teaGAVbXe3zdmYsZctRunzTotoE930C8sKFztL5PdZ9R3kAcLjXJBukIku8q5EYeDE5KwzJIX/gMvz8uTMI7TBYc7KrZgjUbxdWimYlxVhv1dBC1m8mUi7LWMKy3GVt1YW7A= 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 165476869770978.68389924636892; Thu, 9 Jun 2022 02:58:17 -0700 (PDT) Received: from localhost ([::1]:44480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzEvf-0003Mn-PK for importer@patchew.org; Thu, 09 Jun 2022 05:58:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7W-0001ci-Pq for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:28 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:38492) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7G-0005vV-Hm for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:26 -0400 Received: by mail-wr1-x430.google.com with SMTP id v14so5217169wra.5 for ; Thu, 09 Jun 2022 02:06:09 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=NZ83DvVjSP5f3cqPypoQ1LPQjwV9cfTRg8x9u5U5b3g=; b=fZa6bg6qSNkmXf57PyJdhOmHbZVgPgo9omqBX1ryW+WwjPjDi4aIn8AU9k9NFiBpFq pErvXrBSbSSRMWExtYBG7c/5veva9BgeP08Rx68+TU2s4nM1kalUNhbdngddleEhOyIG TGqzqznfGO3valMdZqn9/7iliaI7XKI7zy0NCstvLf8z1xzuGNb0odFnTWw+OHvJUyXA EPAnhhbLr9iA+pvmiwtjqkf9DKAFKjeyOAFS6/2u+2rjOPdbGonG0uj26mLhVIMZ7U6k Vfiy4du8asrK6tvvGjmKGX1RiurywbKrFMzgFZgtxWLzkOLdhYffqUG0nrFT0gIFjIrR f8BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NZ83DvVjSP5f3cqPypoQ1LPQjwV9cfTRg8x9u5U5b3g=; b=eQGHIi5n9DHXdZRi23F8NbcLS3/HUvXak0HYYRUhkl+IMsPVNgqDfm/t+BmlvFOgSj XvnwRcP4X1LvErqp75XBMmjapOnou1UkQJfskeV7VbZC88Dx8hWmlUl3mwUAypRqMCDy YhQEHbHwElIrxHaggcXWtKAHKmD+mG4NtlruKUhkt39z28sxMh0WtsrffQp+jow6xDVI DVBW7hei/wM2aXS5k4Zig1rUGZTR29tcVVUDvpChN9vppozgHHIX7tijoDwjjbq9pjj5 IH2/J7B6YgxqVcTRo7FENkPiFAFR5hyGwzdcdnGzNBz+dutdeIHlX4lmri/PeTwJHZhh fosw== X-Gm-Message-State: AOAM532ccOxflbNYf3+fIC/1KaWf2cNzVCcrGuBFNMQuHp9HeOx6vAYg scsXXZrA33U0hCCpdcdrcpMBKQk77VYflA== X-Google-Smtp-Source: ABdhPJzA6aTbg78rtSfrLEj+jEO1ssvtGqyGKiAxkDKXBywbHKfBOLaq1FUVOR2lk7TXV8pFm/f7xA== X-Received: by 2002:a5d:67c2:0:b0:215:7a0f:71f9 with SMTP id n2-20020a5d67c2000000b002157a0f71f9mr30973731wrw.486.1654765569593; Thu, 09 Jun 2022 02:06:09 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 26/55] target/arm: Move get_S1prot, get_S2prot to ptw.c Date: Thu, 9 Jun 2022 10:05:08 +0100 Message-Id: <20220609090537.1971756-27-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::430; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x430.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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654768699811100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-20-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 3 -- target/arm/helper.c | 128 -------------------------------------------- target/arm/ptw.c | 128 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+), 131 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index fba650d01ca..93147e0b065 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -29,9 +29,6 @@ ARMVAParameters aa32_va_parameters(CPUARMState *env, uint= 32_t va, ARMMMUIdx mmu_idx); bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, int inputsize, int stride, int outputsize); -int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0); -int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, - int ap, int ns, int xn, int pxn); =20 #endif /* !CONFIG_USER_ONLY */ #endif /* TARGET_ARM_PTW_H */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 563e34ecded..148eb28ba8c 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10615,134 +10615,6 @@ int simple_ap_to_rw_prot_is_user(int ap, bool is_= user) } } =20 -/* Translate S2 section/page access permissions to protection flags - * - * @env: CPUARMState - * @s2ap: The 2-bit stage2 access permissions (S2AP) - * @xn: XN (execute-never) bits - * @s1_is_el0: true if this is S2 of an S1+2 walk for EL0 - */ -int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0) -{ - int prot =3D 0; - - if (s2ap & 1) { - prot |=3D PAGE_READ; - } - if (s2ap & 2) { - prot |=3D PAGE_WRITE; - } - - if (cpu_isar_feature(any_tts2uxn, env_archcpu(env))) { - switch (xn) { - case 0: - prot |=3D PAGE_EXEC; - break; - case 1: - if (s1_is_el0) { - prot |=3D PAGE_EXEC; - } - break; - case 2: - break; - case 3: - if (!s1_is_el0) { - prot |=3D PAGE_EXEC; - } - break; - default: - g_assert_not_reached(); - } - } else { - if (!extract32(xn, 1, 1)) { - if (arm_el_is_aa64(env, 2) || prot & PAGE_READ) { - prot |=3D PAGE_EXEC; - } - } - } - return prot; -} - -/* Translate section/page access permissions to protection flags - * - * @env: CPUARMState - * @mmu_idx: MMU index indicating required translation regime - * @is_aa64: TRUE if AArch64 - * @ap: The 2-bit simple AP (AP[2:1]) - * @ns: NS (non-secure) bit - * @xn: XN (execute-never) bit - * @pxn: PXN (privileged execute-never) bit - */ -int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, - int ap, int ns, int xn, int pxn) -{ - bool is_user =3D regime_is_user(env, mmu_idx); - int prot_rw, user_rw; - bool have_wxn; - int wxn =3D 0; - - assert(mmu_idx !=3D ARMMMUIdx_Stage2); - assert(mmu_idx !=3D ARMMMUIdx_Stage2_S); - - user_rw =3D simple_ap_to_rw_prot_is_user(ap, true); - if (is_user) { - prot_rw =3D user_rw; - } else { - if (user_rw && regime_is_pan(env, mmu_idx)) { - /* PAN forbids data accesses but doesn't affect insn fetch */ - prot_rw =3D 0; - } else { - prot_rw =3D simple_ap_to_rw_prot_is_user(ap, false); - } - } - - if (ns && arm_is_secure(env) && (env->cp15.scr_el3 & SCR_SIF)) { - return prot_rw; - } - - /* TODO have_wxn should be replaced with - * ARM_FEATURE_V8 || (ARM_FEATURE_V7 && ARM_FEATURE_EL2) - * when ARM_FEATURE_EL2 starts getting set. For now we assume all LPAE - * compatible processors have EL2, which is required for [U]WXN. - */ - have_wxn =3D arm_feature(env, ARM_FEATURE_LPAE); - - if (have_wxn) { - wxn =3D regime_sctlr(env, mmu_idx) & SCTLR_WXN; - } - - if (is_aa64) { - if (regime_has_2_ranges(mmu_idx) && !is_user) { - xn =3D pxn || (user_rw & PAGE_WRITE); - } - } else if (arm_feature(env, ARM_FEATURE_V7)) { - switch (regime_el(env, mmu_idx)) { - case 1: - case 3: - if (is_user) { - xn =3D xn || !(user_rw & PAGE_READ); - } else { - int uwxn =3D 0; - if (have_wxn) { - uwxn =3D regime_sctlr(env, mmu_idx) & SCTLR_UWXN; - } - xn =3D xn || !(prot_rw & PAGE_READ) || pxn || - (uwxn && (user_rw & PAGE_WRITE)); - } - break; - case 2: - break; - } - } else { - xn =3D wxn =3D 0; - } - - if (xn || (wxn && (prot_rw & PAGE_WRITE))) { - return prot_rw; - } - return prot_rw | PAGE_EXEC; -} - /* * check_s2_mmu_setup * @cpu: ARMCPU diff --git a/target/arm/ptw.c b/target/arm/ptw.c index d754273fa16..af9ad420288 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -487,6 +487,134 @@ do_fault: return true; } =20 +/* + * Translate S2 section/page access permissions to protection flags + * @env: CPUARMState + * @s2ap: The 2-bit stage2 access permissions (S2AP) + * @xn: XN (execute-never) bits + * @s1_is_el0: true if this is S2 of an S1+2 walk for EL0 + */ +static int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0) +{ + int prot =3D 0; + + if (s2ap & 1) { + prot |=3D PAGE_READ; + } + if (s2ap & 2) { + prot |=3D PAGE_WRITE; + } + + if (cpu_isar_feature(any_tts2uxn, env_archcpu(env))) { + switch (xn) { + case 0: + prot |=3D PAGE_EXEC; + break; + case 1: + if (s1_is_el0) { + prot |=3D PAGE_EXEC; + } + break; + case 2: + break; + case 3: + if (!s1_is_el0) { + prot |=3D PAGE_EXEC; + } + break; + default: + g_assert_not_reached(); + } + } else { + if (!extract32(xn, 1, 1)) { + if (arm_el_is_aa64(env, 2) || prot & PAGE_READ) { + prot |=3D PAGE_EXEC; + } + } + } + return prot; +} + +/* + * Translate section/page access permissions to protection flags + * @env: CPUARMState + * @mmu_idx: MMU index indicating required translation regime + * @is_aa64: TRUE if AArch64 + * @ap: The 2-bit simple AP (AP[2:1]) + * @ns: NS (non-secure) bit + * @xn: XN (execute-never) bit + * @pxn: PXN (privileged execute-never) bit + */ +static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, + int ap, int ns, int xn, int pxn) +{ + bool is_user =3D regime_is_user(env, mmu_idx); + int prot_rw, user_rw; + bool have_wxn; + int wxn =3D 0; + + assert(mmu_idx !=3D ARMMMUIdx_Stage2); + assert(mmu_idx !=3D ARMMMUIdx_Stage2_S); + + user_rw =3D simple_ap_to_rw_prot_is_user(ap, true); + if (is_user) { + prot_rw =3D user_rw; + } else { + if (user_rw && regime_is_pan(env, mmu_idx)) { + /* PAN forbids data accesses but doesn't affect insn fetch */ + prot_rw =3D 0; + } else { + prot_rw =3D simple_ap_to_rw_prot_is_user(ap, false); + } + } + + if (ns && arm_is_secure(env) && (env->cp15.scr_el3 & SCR_SIF)) { + return prot_rw; + } + + /* TODO have_wxn should be replaced with + * ARM_FEATURE_V8 || (ARM_FEATURE_V7 && ARM_FEATURE_EL2) + * when ARM_FEATURE_EL2 starts getting set. For now we assume all LPAE + * compatible processors have EL2, which is required for [U]WXN. + */ + have_wxn =3D arm_feature(env, ARM_FEATURE_LPAE); + + if (have_wxn) { + wxn =3D regime_sctlr(env, mmu_idx) & SCTLR_WXN; + } + + if (is_aa64) { + if (regime_has_2_ranges(mmu_idx) && !is_user) { + xn =3D pxn || (user_rw & PAGE_WRITE); + } + } else if (arm_feature(env, ARM_FEATURE_V7)) { + switch (regime_el(env, mmu_idx)) { + case 1: + case 3: + if (is_user) { + xn =3D xn || !(user_rw & PAGE_READ); + } else { + int uwxn =3D 0; + if (have_wxn) { + uwxn =3D regime_sctlr(env, mmu_idx) & SCTLR_UWXN; + } + xn =3D xn || !(prot_rw & PAGE_READ) || pxn || + (uwxn && (user_rw & PAGE_WRITE)); + } + break; + case 2: + break; + } + } else { + xn =3D wxn =3D 0; + } + + if (xn || (wxn && (prot_rw & PAGE_WRITE))) { + return prot_rw; + } + return prot_rw | PAGE_EXEC; +} + /** * get_phys_addr_lpae: perform one stage of page table walk, LPAE format * --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654769602; cv=none; d=zohomail.com; s=zohoarc; b=YJDF6WKztT7X/TL+VfDpugXyB781qQYwnElUMEuaRF6zYgo37TOnA5zsQkgJTTiFQ+pBVVm21gPPFDa2vW5icX05xgpDte4ZpsZbnQ33zpXAdu3KXdReA7sJLHNOzdH3hy3q7wGNoNgSEnu4aETOF3VxdgKkaRmDuKp0QSK54u4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654769602; 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=7iWAmr8aLaBxhjnqmS0IabAjJ74tn9UJA1n63C3136o=; b=Hs59tJgtj0Z1XDrbhLnzaliMcxy38aJImlEZ+7mWUR0bLd6FlF6s5CgL5l6u8HAzQYAaMJ0BGmAUqRrFgI0hRpWBVf7/mPzyGWkpcwMmyQlibWzsAD+Fgfjx25OugnR4/P+K/IXmh5UnUy/gXsGKS5L9RTJj/6RRJI0jMuLIv6s= 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 1654769602017514.0698264810256; Thu, 9 Jun 2022 03:13:22 -0700 (PDT) Received: from localhost ([::1]:33072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFAG-0007wq-HR for importer@patchew.org; Thu, 09 Jun 2022 06:13:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7L-0001Ys-U6 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:18 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:46819) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7H-0005xd-GH for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:15 -0400 Received: by mail-wr1-x435.google.com with SMTP id u8so27137707wrm.13 for ; Thu, 09 Jun 2022 02:06:10 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=7iWAmr8aLaBxhjnqmS0IabAjJ74tn9UJA1n63C3136o=; b=HNL4ROPLJvjh4JaPHTWCeUuweTRQ81y7PyFIBHd8wx4uAjAR7e8JuBTNbKpZ5Y4sM1 B/4dZpBRuvmT8LhC8EsqHjb/ebNsHqM3pvSfiswEk0PaQHHt9vYFIhumMcRglNlkFwCS 80rzdEVa0xIG1NacQAeV2TK+8IWK0trkcpEt7QwYFxBrauGgeY2L9I5fxcaDGnuL7OwV STS0II2jv8amtgt6r48vq9Y0AGK3NPpRGCUVDWESqJToqwQckfKKT4L8hOefQmQHU5w8 lYR9AFPAT/2FbqkqTOPj6hydajpOWmBsNgj4y3609MxIQOn7HNg3X0gXIa49CCx/fsBa m7hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7iWAmr8aLaBxhjnqmS0IabAjJ74tn9UJA1n63C3136o=; b=Pd8yJRLdVAcReDENDMQzyyC0is3nJERN49fAi1Z330x1xJEu68npVkpJuZ4A0CHlt7 +fLf+5CJBOoNxnS408bOd/qPDCaG4c0/Tq8Uqpp1cRu4pMqhZeq5zV5SnJ7nyIsPOIqz +KjJkupABarHsSjXJeMsOPJTLzep5iWq4QPu8WI5cj9AJg3w/Ft/3f4FsTqMcG5glr/+ 1pErzJajFtI9nA/82/3ueR+6w7WsTxbciTkP/2gDYakKjnyWhotI4BM51r9GVI6GaxCa W3/9MOeTFyza4Q9Vbo/DviLJeum2rBLeMyTF3Zvjb4zirfTbjEYuWXKBYLlyskPZTqff bu+A== X-Gm-Message-State: AOAM533CKrpbzijRKLfq209oKLvAuUu6wEKeelbyiT1mTqFD6mqbPTnl zOO0FiwOVCQgwWd5nvqWvJ/ZBg3Q9cNEUw== X-Google-Smtp-Source: ABdhPJzytP9NINA+npM9t6rvut5dZAyplPIogvkB02BqfaUraSwItPFyUWZGZYntU7IXd9pweGQHHw== X-Received: by 2002:a5d:620b:0:b0:210:11d9:770 with SMTP id y11-20020a5d620b000000b0021011d90770mr37270326wru.11.1654765570493; Thu, 09 Jun 2022 02:06:10 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 27/55] target/arm: Move check_s2_mmu_setup to ptw.c Date: Thu, 9 Jun 2022 10:05:09 +0100 Message-Id: <20220609090537.1971756-28-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654769603456100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-21-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 2 -- target/arm/helper.c | 70 --------------------------------------------- target/arm/ptw.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 72 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index 93147e0b065..a71161b01bd 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -27,8 +27,6 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx,= int ap) =20 ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, ARMMMUIdx mmu_idx); -bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, - int inputsize, int stride, int outputsize); =20 #endif /* !CONFIG_USER_ONLY */ #endif /* TARGET_ARM_PTW_H */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 148eb28ba8c..2526f4c6c4a 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10614,76 +10614,6 @@ int simple_ap_to_rw_prot_is_user(int ap, bool is_u= ser) g_assert_not_reached(); } } - -/* - * check_s2_mmu_setup - * @cpu: ARMCPU - * @is_aa64: True if the translation regime is in AArch64 state - * @startlevel: Suggested starting level - * @inputsize: Bitsize of IPAs - * @stride: Page-table stride (See the ARM ARM) - * - * Returns true if the suggested S2 translation parameters are OK and - * false otherwise. - */ -bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, - int inputsize, int stride, int outputsize) -{ - const int grainsize =3D stride + 3; - int startsizecheck; - - /* - * Negative levels are usually not allowed... - * Except for FEAT_LPA2, 4k page table, 52-bit address space, which - * begins with level -1. Note that previous feature tests will have - * eliminated this combination if it is not enabled. - */ - if (level < (inputsize =3D=3D 52 && stride =3D=3D 9 ? -1 : 0)) { - return false; - } - - startsizecheck =3D inputsize - ((3 - level) * stride + grainsize); - if (startsizecheck < 1 || startsizecheck > stride + 4) { - return false; - } - - if (is_aa64) { - switch (stride) { - case 13: /* 64KB Pages. */ - if (level =3D=3D 0 || (level =3D=3D 1 && outputsize <=3D 42)) { - return false; - } - break; - case 11: /* 16KB Pages. */ - if (level =3D=3D 0 || (level =3D=3D 1 && outputsize <=3D 40)) { - return false; - } - break; - case 9: /* 4KB Pages. */ - if (level =3D=3D 0 && outputsize <=3D 42) { - return false; - } - break; - default: - g_assert_not_reached(); - } - - /* Inputsize checks. */ - if (inputsize > outputsize && - (arm_el_is_aa64(&cpu->env, 1) || inputsize > 40)) { - /* This is CONSTRAINED UNPREDICTABLE and we choose to fault. = */ - return false; - } - } else { - /* AArch32 only supports 4KB pages. Assert on that. */ - assert(stride =3D=3D 9); - - if (level =3D=3D 0) { - return false; - } - } - return true; -} #endif /* !CONFIG_USER_ONLY */ =20 int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index af9ad420288..525272e99af 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -615,6 +615,76 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_= idx, bool is_aa64, return prot_rw | PAGE_EXEC; } =20 +/* + * check_s2_mmu_setup + * @cpu: ARMCPU + * @is_aa64: True if the translation regime is in AArch64 state + * @startlevel: Suggested starting level + * @inputsize: Bitsize of IPAs + * @stride: Page-table stride (See the ARM ARM) + * + * Returns true if the suggested S2 translation parameters are OK and + * false otherwise. + */ +static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, + int inputsize, int stride, int outputsize) +{ + const int grainsize =3D stride + 3; + int startsizecheck; + + /* + * Negative levels are usually not allowed... + * Except for FEAT_LPA2, 4k page table, 52-bit address space, which + * begins with level -1. Note that previous feature tests will have + * eliminated this combination if it is not enabled. + */ + if (level < (inputsize =3D=3D 52 && stride =3D=3D 9 ? -1 : 0)) { + return false; + } + + startsizecheck =3D inputsize - ((3 - level) * stride + grainsize); + if (startsizecheck < 1 || startsizecheck > stride + 4) { + return false; + } + + if (is_aa64) { + switch (stride) { + case 13: /* 64KB Pages. */ + if (level =3D=3D 0 || (level =3D=3D 1 && outputsize <=3D 42)) { + return false; + } + break; + case 11: /* 16KB Pages. */ + if (level =3D=3D 0 || (level =3D=3D 1 && outputsize <=3D 40)) { + return false; + } + break; + case 9: /* 4KB Pages. */ + if (level =3D=3D 0 && outputsize <=3D 42) { + return false; + } + break; + default: + g_assert_not_reached(); + } + + /* Inputsize checks. */ + if (inputsize > outputsize && + (arm_el_is_aa64(&cpu->env, 1) || inputsize > 40)) { + /* This is CONSTRAINED UNPREDICTABLE and we choose to fault. = */ + return false; + } + } else { + /* AArch32 only supports 4KB pages. Assert on that. */ + assert(stride =3D=3D 9); + + if (level =3D=3D 0) { + return false; + } + } + return true; +} + /** * get_phys_addr_lpae: perform one stage of page table walk, LPAE format * --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654766963; cv=none; d=zohomail.com; s=zohoarc; b=kra350As4C0wX0q/Baju3RRFbM6z3CZNWKVz4YLYv5KQ13U/VPUEiBU57uzMUy4EwjuM3z9aMoJR9N9YpBonIkkMvJdE7zrjBpQKfoBqiZpHwrWOemoeJkUDUzH8kEj05kErdSjmDFx35YxJJqfjPAqSqUIUqe3saXZ7P67PUWQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654766963; 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=NDy5L1j1NFeCwxkRreoifiteCmt9uSlmxDgPX55fTNU=; b=E3eX6KARv1h1PezeSle6hzEtuCeyT9YLBP/Evw9BK13sPoH/2FN49G3/KKbUJojes99E80p8rDg7LGsA4X1a2LjHPSUrrcddV2Oshnm57WXk1MVFPPnoO1bG0cA7V8rVTb/kCaFowQNEvdMqeQJ6qiYwm/RGH07/LLTheshHIaQ= 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 1654766963610316.02292601499346; Thu, 9 Jun 2022 02:29:23 -0700 (PDT) Received: from localhost ([::1]:45976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzETi-0000cg-Bx for importer@patchew.org; Thu, 09 Jun 2022 05:29:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7O-0001Z0-C6 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:21 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:33709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7J-00063a-3z for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:16 -0400 Received: by mail-wr1-x433.google.com with SMTP id h5so31518410wrb.0 for ; Thu, 09 Jun 2022 02:06:12 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=NDy5L1j1NFeCwxkRreoifiteCmt9uSlmxDgPX55fTNU=; b=rn1tLAMCWtRlYx+ukNHwDCZj515mfgswJ40a7U18/L+lO0lftUle6LtLJeyoL/RR0U RD6fk/Zm9bLDbnBO0SJrf4oNqdRMTWGVuqPjxxWUDrXcf18+rGC76tauOmVJ9qoxL/z+ NJozbTPGz3tExs0djCv+dhNvWukoUPtLIaYGqaG3g85gqbV8ITy3roqwoKTO/axTWtM4 1v3+j1zlAo0EZbXcgWmtPpG3mZ1fAwvb94GZj3fdFF/Pw66G0yQWV6rX8NxIsCCMBGXc x7KzeEnGwSJR0cCmw1TDKcrZd2Wyv/Sz79GkKx6DFIhAjX/CLJ18Taz4eXwCG+2KfLVF mwVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NDy5L1j1NFeCwxkRreoifiteCmt9uSlmxDgPX55fTNU=; b=WhLQMpp7OIQHBXsMowJqVTSIO7QcY5dx+I+GuW+lwEEnIeTXHcnqab4J5AP4GaI932 7S2iXKOlbBn59uyFs40KAqWZAU2MjIRDY7hd0Lb1eN9iZYxJGFU5EA+Dkh5hxWR3meoj R6EhNqaAF2atUNBJmpCJKuVBzyPKczlvM520bqKWkWVcNu0fj+mJ44ZfwcHgfybkM7i3 oaQxm/+zW5gAK9qH8lEQ+Ov/q3e16Ya+bAAbtjK/Hol5NuarvSS1kwybzCS1IpSI4BGL YC9XCiB7KZj2DtxtYkwqULB1sjAi8wpj+5/TPpogKVK57OBVngj9v1FcYh4LFaBob2r1 SodQ== X-Gm-Message-State: AOAM532dr2dVZwx7VrKHUczcnH8slD8ALASykhDSD/wiSom4VY6K/yku qkLPUThqEqUDCl1Fjbv+LkYMKlee3jUhhg== X-Google-Smtp-Source: ABdhPJw2cm5vmwzhLab6HGqMUR3tpPm+LGIbL3V9Psip9Bd2IgmrtJSU+GjPiQllWwe/KcgDKdLTBw== X-Received: by 2002:adf:eccd:0:b0:212:fbbc:79de with SMTP id s13-20020adfeccd000000b00212fbbc79demr35774935wro.520.1654765571489; Thu, 09 Jun 2022 02:06:11 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 28/55] target/arm: Move aa32_va_parameters to ptw.c Date: Thu, 9 Jun 2022 10:05:10 +0100 Message-Id: <20220609090537.1971756-29-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654766965652100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-22-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 3 --- target/arm/helper.c | 64 --------------------------------------------- target/arm/ptw.c | 64 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 67 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index a71161b01bd..9314fb4d23c 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -25,8 +25,5 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx,= int ap) return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); } =20 -ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, - ARMMMUIdx mmu_idx); - #endif /* !CONFIG_USER_ONLY */ #endif /* TARGET_ARM_PTW_H */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 2526f4c6c4a..f61f1da61e4 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10771,70 +10771,6 @@ ARMVAParameters aa64_va_parameters(CPUARMState *en= v, uint64_t va, } =20 #ifndef CONFIG_USER_ONLY -ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, - ARMMMUIdx mmu_idx) -{ - uint64_t tcr =3D regime_tcr(env, mmu_idx)->raw_tcr; - uint32_t el =3D regime_el(env, mmu_idx); - int select, tsz; - bool epd, hpd; - - assert(mmu_idx !=3D ARMMMUIdx_Stage2_S); - - if (mmu_idx =3D=3D ARMMMUIdx_Stage2) { - /* VTCR */ - bool sext =3D extract32(tcr, 4, 1); - bool sign =3D extract32(tcr, 3, 1); - - /* - * If the sign-extend bit is not the same as t0sz[3], the result - * is unpredictable. Flag this as a guest error. - */ - if (sign !=3D sext) { - qemu_log_mask(LOG_GUEST_ERROR, - "AArch32: VTCR.S / VTCR.T0SZ[3] mismatch\n"); - } - tsz =3D sextract32(tcr, 0, 4) + 8; - select =3D 0; - hpd =3D false; - epd =3D false; - } else if (el =3D=3D 2) { - /* HTCR */ - tsz =3D extract32(tcr, 0, 3); - select =3D 0; - hpd =3D extract64(tcr, 24, 1); - epd =3D false; - } else { - int t0sz =3D extract32(tcr, 0, 3); - int t1sz =3D extract32(tcr, 16, 3); - - if (t1sz =3D=3D 0) { - select =3D va > (0xffffffffu >> t0sz); - } else { - /* Note that we will detect errors later. */ - select =3D va >=3D ~(0xffffffffu >> t1sz); - } - if (!select) { - tsz =3D t0sz; - epd =3D extract32(tcr, 7, 1); - hpd =3D extract64(tcr, 41, 1); - } else { - tsz =3D t1sz; - epd =3D extract32(tcr, 23, 1); - hpd =3D extract64(tcr, 42, 1); - } - /* For aarch32, hpd0 is not enabled without t2e as well. */ - hpd &=3D extract32(tcr, 6, 1); - } - - return (ARMVAParameters) { - .tsz =3D tsz, - .select =3D select, - .epd =3D epd, - .hpd =3D hpd, - }; -} - hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, MemTxAttrs *attrs) { diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 525272e99af..427813ea563 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -615,6 +615,70 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_= idx, bool is_aa64, return prot_rw | PAGE_EXEC; } =20 +static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, + ARMMMUIdx mmu_idx) +{ + uint64_t tcr =3D regime_tcr(env, mmu_idx)->raw_tcr; + uint32_t el =3D regime_el(env, mmu_idx); + int select, tsz; + bool epd, hpd; + + assert(mmu_idx !=3D ARMMMUIdx_Stage2_S); + + if (mmu_idx =3D=3D ARMMMUIdx_Stage2) { + /* VTCR */ + bool sext =3D extract32(tcr, 4, 1); + bool sign =3D extract32(tcr, 3, 1); + + /* + * If the sign-extend bit is not the same as t0sz[3], the result + * is unpredictable. Flag this as a guest error. + */ + if (sign !=3D sext) { + qemu_log_mask(LOG_GUEST_ERROR, + "AArch32: VTCR.S / VTCR.T0SZ[3] mismatch\n"); + } + tsz =3D sextract32(tcr, 0, 4) + 8; + select =3D 0; + hpd =3D false; + epd =3D false; + } else if (el =3D=3D 2) { + /* HTCR */ + tsz =3D extract32(tcr, 0, 3); + select =3D 0; + hpd =3D extract64(tcr, 24, 1); + epd =3D false; + } else { + int t0sz =3D extract32(tcr, 0, 3); + int t1sz =3D extract32(tcr, 16, 3); + + if (t1sz =3D=3D 0) { + select =3D va > (0xffffffffu >> t0sz); + } else { + /* Note that we will detect errors later. */ + select =3D va >=3D ~(0xffffffffu >> t1sz); + } + if (!select) { + tsz =3D t0sz; + epd =3D extract32(tcr, 7, 1); + hpd =3D extract64(tcr, 41, 1); + } else { + tsz =3D t1sz; + epd =3D extract32(tcr, 23, 1); + hpd =3D extract64(tcr, 42, 1); + } + /* For aarch32, hpd0 is not enabled without t2e as well. */ + hpd &=3D extract32(tcr, 6, 1); + } + + return (ARMVAParameters) { + .tsz =3D tsz, + .select =3D select, + .epd =3D epd, + .hpd =3D hpd, + }; +} + /* * check_s2_mmu_setup * @cpu: ARMCPU --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654768823; cv=none; d=zohomail.com; s=zohoarc; b=Kqa14IwQ6Pmbmky24Padjz3+A0U6npvtY/ki0OdX0FP1Q4sgGHAy5Kvs8kAqxY+oht1KsM98ZYk9eZp4KP3AcC312GLrYwbWtMtFv/t9Cd59zI/aMhzlQXBzpLV4rW/KEIm/KYIJxKrPqd4VjRWjKIQSKaKkCpwgSBiqMtghM/A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654768823; 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=rd6uuNfniFNZ5ZxqrHQJZxW1BzKlfPz7FzEjKvWSCtE=; b=EOJxoeAG/+JVDTqk8+jG/RaRgSlTS8/wVqqu1fNoFz6INuel7ynVP919Nc4UwaxsazoTP0v7O6bQPAQg4JX/AR3z4kXaub2RXjAodHkrtuPdVcGNtX2etiYGOgy66lEsLxK0CIxQin8WcNJ2oyubPMeJJy7SO0mMn3loIpuwLlk= 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 165476882357315.997164239694598; Thu, 9 Jun 2022 03:00:23 -0700 (PDT) Received: from localhost ([::1]:47166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzExi-0005Eo-0D for importer@patchew.org; Thu, 09 Jun 2022 06:00:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7O-0001Yz-Ba for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:21 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:36483) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7J-00063j-W3 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:17 -0400 Received: by mail-wr1-x42c.google.com with SMTP id o8so3625877wro.3 for ; Thu, 09 Jun 2022 02:06:13 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=rd6uuNfniFNZ5ZxqrHQJZxW1BzKlfPz7FzEjKvWSCtE=; b=Ll+e0oo1jaPvSjSMft05R2FgQe3K2SnfuIImWHyZwiGxoMJItgjYQBROhhOjGG2nqn AYV20Mecjp7DyZRGA+/isTvkovKsTKB2zGYEQMqiN6H67gesoqkMHpUDC+Pw/OkwkapN ZfXMWvvMbTBc0MQ4PQUT12AwQeE4Z1nyfrRbKX84CTq1saP8XfQk51qY7pqFCbwPI/ir Tj2YQHTzfMDzDZqAl2COkOBq+YfvQDjlQuYWaT8cQ2SFu1P1VIkCdTx38I0Fim5bTpvX KOgeyetWNZ+I74gpv53TzEBFr873f70mRJvnVfpajNdlR1k6jrz4U6+43ds11rudXd+9 Ji9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rd6uuNfniFNZ5ZxqrHQJZxW1BzKlfPz7FzEjKvWSCtE=; b=UjQR4uSY0ruf7oMwEV6UyvqmyqDtCkkXVh6lvDrHevG02iuzVQu1u05kRvR5DuBnOX AJaPJfCWQAUW/poTa1k+CRh2BRQ/lxdo33eGKioDcUVUvVS3QtzDlynDCvlCiLSxZlwR RdX17nrIgVmJE6hgTm080WtxC4F1A8iyWZEM2cBEULV6//IVMY2uGQzC3mPJZyBeyDsQ FYwrkPVywU4sd6nV9caTC8AtFLuh2wrV6lVcbYzuYWWwBet7vcrfFioFTCm9LM3xDlvz 9Qkq6qUrlJSQRKzHNp238xCMhNG3BkuwnTmUMA8d/lYPOnEJwVcQm4kXOwmXtDTC+TaZ Pywg== X-Gm-Message-State: AOAM531CEgXAnhSJl3ArALCPrP4jYh4Lelb3G2OQ4PXleX2YuJv3RScy JkG4XHUq3ssku2XXMlxEF8vvyvzAgZ7cNw== X-Google-Smtp-Source: ABdhPJzMlQehlTKvbt5PFwGDtm/1/IckpECetxalOVR92XObXKeYVPiDa7sywLnNB/Bh00sFP4gzVw== X-Received: by 2002:adf:f90f:0:b0:20e:5fd4:5d06 with SMTP id b15-20020adff90f000000b0020e5fd45d06mr37551453wrr.371.1654765572394; Thu, 09 Jun 2022 02:06:12 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 29/55] target/arm: Move ap_to_tw_prot etc to ptw.c Date: Thu, 9 Jun 2022 10:05:11 +0100 Message-Id: <20220609090537.1971756-30-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654768825193100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-23-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 10 ------ target/arm/helper.c | 77 ------------------------------------------ target/arm/ptw.c | 81 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 87 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index 9314fb4d23c..85ad5767944 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -15,15 +15,5 @@ bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx); bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn); =20 -int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, - int ap, int domain_prot); -int simple_ap_to_rw_prot_is_user(int ap, bool is_user); - -static inline int -simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) -{ - return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); -} - #endif /* !CONFIG_USER_ONLY */ #endif /* TARGET_ARM_PTW_H */ diff --git a/target/arm/helper.c b/target/arm/helper.c index f61f1da61e4..e894afcb491 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10537,83 +10537,6 @@ bool regime_is_user(CPUARMState *env, ARMMMUIdx mm= u_idx) g_assert_not_reached(); } } - -/* Translate section/page access permissions to page - * R/W protection flags - * - * @env: CPUARMState - * @mmu_idx: MMU index indicating required translation regime - * @ap: The 3-bit access permissions (AP[2:0]) - * @domain_prot: The 2-bit domain access permissions - */ -int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap, int domain_= prot) -{ - bool is_user =3D regime_is_user(env, mmu_idx); - - if (domain_prot =3D=3D 3) { - return PAGE_READ | PAGE_WRITE; - } - - switch (ap) { - case 0: - if (arm_feature(env, ARM_FEATURE_V7)) { - return 0; - } - switch (regime_sctlr(env, mmu_idx) & (SCTLR_S | SCTLR_R)) { - case SCTLR_S: - return is_user ? 0 : PAGE_READ; - case SCTLR_R: - return PAGE_READ; - default: - return 0; - } - case 1: - return is_user ? 0 : PAGE_READ | PAGE_WRITE; - case 2: - if (is_user) { - return PAGE_READ; - } else { - return PAGE_READ | PAGE_WRITE; - } - case 3: - return PAGE_READ | PAGE_WRITE; - case 4: /* Reserved. */ - return 0; - case 5: - return is_user ? 0 : PAGE_READ; - case 6: - return PAGE_READ; - case 7: - if (!arm_feature(env, ARM_FEATURE_V6K)) { - return 0; - } - return PAGE_READ; - default: - g_assert_not_reached(); - } -} - -/* Translate section/page access permissions to page - * R/W protection flags. - * - * @ap: The 2-bit simple AP (AP[2:1]) - * @is_user: TRUE if accessing from PL0 - */ -int simple_ap_to_rw_prot_is_user(int ap, bool is_user) -{ - switch (ap) { - case 0: - return is_user ? 0 : PAGE_READ | PAGE_WRITE; - case 1: - return PAGE_READ | PAGE_WRITE; - case 2: - return is_user ? 0 : PAGE_READ; - case 3: - return PAGE_READ; - default: - g_assert_not_reached(); - } -} #endif /* !CONFIG_USER_ONLY */ =20 int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 427813ea563..9ab77c39980 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -211,6 +211,87 @@ static bool get_level1_table_address(CPUARMState *env,= ARMMMUIdx mmu_idx, return true; } =20 +/* + * Translate section/page access permissions to page R/W protection flags + * @env: CPUARMState + * @mmu_idx: MMU index indicating required translation regime + * @ap: The 3-bit access permissions (AP[2:0]) + * @domain_prot: The 2-bit domain access permissions + */ +static int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, + int ap, int domain_prot) +{ + bool is_user =3D regime_is_user(env, mmu_idx); + + if (domain_prot =3D=3D 3) { + return PAGE_READ | PAGE_WRITE; + } + + switch (ap) { + case 0: + if (arm_feature(env, ARM_FEATURE_V7)) { + return 0; + } + switch (regime_sctlr(env, mmu_idx) & (SCTLR_S | SCTLR_R)) { + case SCTLR_S: + return is_user ? 0 : PAGE_READ; + case SCTLR_R: + return PAGE_READ; + default: + return 0; + } + case 1: + return is_user ? 0 : PAGE_READ | PAGE_WRITE; + case 2: + if (is_user) { + return PAGE_READ; + } else { + return PAGE_READ | PAGE_WRITE; + } + case 3: + return PAGE_READ | PAGE_WRITE; + case 4: /* Reserved. */ + return 0; + case 5: + return is_user ? 0 : PAGE_READ; + case 6: + return PAGE_READ; + case 7: + if (!arm_feature(env, ARM_FEATURE_V6K)) { + return 0; + } + return PAGE_READ; + default: + g_assert_not_reached(); + } +} + +/* + * Translate section/page access permissions to page R/W protection flags. + * @ap: The 2-bit simple AP (AP[2:1]) + * @is_user: TRUE if accessing from PL0 + */ +static int simple_ap_to_rw_prot_is_user(int ap, bool is_user) +{ + switch (ap) { + case 0: + return is_user ? 0 : PAGE_READ | PAGE_WRITE; + case 1: + return PAGE_READ | PAGE_WRITE; + case 2: + return is_user ? 0 : PAGE_READ; + case 3: + return PAGE_READ; + default: + g_assert_not_reached(); + } +} + +static int simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int a= p) +{ + return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); +} + static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot, --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654772791; cv=none; d=zohomail.com; s=zohoarc; b=jvfk783FnlG8pLccZVx85drxOep8mwFO7dOVrMZJ7oUM920EabIgjvkYhm2fcQ4/l/h5rw5st6Z0sP83lItzSvLrL2OQ5K+euyVFSSaBOqI603Ttd0qskb6J+t21WWrEnooI/HoD0APvA264fqEwajXLay4DIl3klVuSujH3T80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654772791; 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=OuhXk6TQyBrgWjcan+zAuS1lnzgYNbegbZMrB1RwcE0=; b=TULNjwjv9s5eYJtXgri7ZCfUc+d+u/yG+/9At7Y7CYJPV8VpeNTezY71G8l9M2S0WwvdXBwYli0CuuMRylG/X2kRTnUT/bkcXV9n1uMtF9FAvyis2znhNU9R2sDwEvWJeaDnPBfUnftHcvolTvjFeCopOUamAuw7eMUacPZwPA4= 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 1654772791700849.8195367614751; Thu, 9 Jun 2022 04:06:31 -0700 (PDT) Received: from localhost ([::1]:58384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFzh-0005tC-Tc for importer@patchew.org; Thu, 09 Jun 2022 07:06:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7O-0001Z1-DS for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:21 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:33706) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7K-000640-NK for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:18 -0400 Received: by mail-wr1-x42f.google.com with SMTP id h5so31518518wrb.0 for ; Thu, 09 Jun 2022 02:06:14 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=OuhXk6TQyBrgWjcan+zAuS1lnzgYNbegbZMrB1RwcE0=; b=w2vhU9JBzTbWDw98pfYdxQSWlbErFUebQSWz9iiLuQ3NDfXmJ49hhN63seyjgdEjsx G84r55Pe5sUQ+b2TkRu9/m/vAtu0XfCr7EmORUKufRu31WNLLgvE8gpdNbqARb+lqSEw nit7AaiVRoF2HHqFSczbRSY/qjg4GxbraHgdiJKC7kS868dC/Fi4Xnm6SF4xF0vLBr67 XpIqYMFb738A7814FHw+AnGB5EdCnD2D4BHfDJ9NeRiaF7JgOq1iyBYQFzO0c6auk6aJ FX3TfsCy0nzJHlrRldqgu0uEYHBA/LZFuAE/kRpWhcCYrPKvJ+elU7Gg7m58TFF2fyB5 dnPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OuhXk6TQyBrgWjcan+zAuS1lnzgYNbegbZMrB1RwcE0=; b=bHypYM4ad4WPLQqr0pOYT5kPTFA9WKifYxAIBCBDcHy3IDWUpBX3KDltOcKwUU6L8F js31KwFfbGJ3X9O47+YOUdSE4DmBQImCiF/opjHpXikOHW2JmrANJiqdcNNyauz5fNqi XKU6jGFSNdUgW0XSfwRFP8lzpsdZ+zCcsppPTR3dIJsauXOKTFuTlYlwFhjeWLnkGWFc 7S+0Lb9nNTCPXfpNC3vEIzuXu6hcSAwPf3D7EHJrRBdtnfM1dLrghNnSdNXJer6xWccO WpXi+9egpfUfjGks6jRy2aIutzxwSrw0StQpsISWLFaX5HXNcjVR9R4qxsjqZp5P+Qeb klKg== X-Gm-Message-State: AOAM533wkTds1aMaKZOof50rduSXHl7j6xNHB8ohkuuQlsRA83p+GlXJ WMrb9+4RcK4BML1RJWTXjbmwLDp012QEJA== X-Google-Smtp-Source: ABdhPJyhEOuS04JQ1/4eyPC8SK0KAxeaGRIRUagQgeDsxrGZQAz9ez3sIiwbDO5x/Hh0vkeiu9yZ0w== X-Received: by 2002:a05:6000:1888:b0:218:3fab:c510 with SMTP id a8-20020a056000188800b002183fabc510mr19870503wri.473.1654765573417; Thu, 09 Jun 2022 02:06:13 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 30/55] target/arm: Move regime_is_user to ptw.c Date: Thu, 9 Jun 2022 10:05:12 +0100 Message-Id: <20220609090537.1971756-31-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654772792552100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-24-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 1 - target/arm/helper.c | 24 ------------------------ target/arm/ptw.c | 22 ++++++++++++++++++++++ 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index 85ad5767944..3d3061a4351 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -11,7 +11,6 @@ =20 #ifndef CONFIG_USER_ONLY =20 -bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx); bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn); =20 diff --git a/target/arm/helper.c b/target/arm/helper.c index e894afcb491..8deb0fa94c1 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10515,30 +10515,6 @@ ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) } #endif /* !CONFIG_USER_ONLY */ =20 -#ifndef CONFIG_USER_ONLY -bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) -{ - switch (mmu_idx) { - case ARMMMUIdx_SE10_0: - case ARMMMUIdx_E20_0: - case ARMMMUIdx_SE20_0: - case ARMMMUIdx_Stage1_E0: - case ARMMMUIdx_Stage1_SE0: - case ARMMMUIdx_MUser: - case ARMMMUIdx_MSUser: - case ARMMMUIdx_MUserNegPri: - case ARMMMUIdx_MSUserNegPri: - return true; - default: - return false; - case ARMMMUIdx_E10_0: - case ARMMMUIdx_E10_1: - case ARMMMUIdx_E10_1_PAN: - g_assert_not_reached(); - } -} -#endif /* !CONFIG_USER_ONLY */ - int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx) { if (regime_has_2_ranges(mmu_idx)) { diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 9ab77c39980..8db4b5edf1a 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -53,6 +53,28 @@ static bool regime_translation_big_endian(CPUARMState *e= nv, ARMMMUIdx mmu_idx) return (regime_sctlr(env, mmu_idx) & SCTLR_EE) !=3D 0; } =20 +static bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) +{ + switch (mmu_idx) { + case ARMMMUIdx_SE10_0: + case ARMMMUIdx_E20_0: + case ARMMMUIdx_SE20_0: + case ARMMMUIdx_Stage1_E0: + case ARMMMUIdx_Stage1_SE0: + case ARMMMUIdx_MUser: + case ARMMMUIdx_MSUser: + case ARMMMUIdx_MUserNegPri: + case ARMMMUIdx_MSUserNegPri: + return true; + default: + return false; + case ARMMMUIdx_E10_0: + case ARMMMUIdx_E10_1: + case ARMMMUIdx_E10_1_PAN: + g_assert_not_reached(); + } +} + static bool ptw_attrs_are_device(CPUARMState *env, ARMCacheAttrs cacheattr= s) { /* --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654771720; cv=none; d=zohomail.com; s=zohoarc; b=JyAT3dwAwKnQ0D2QcVJg8el7OxTxEbFH30kocWFoC7K0KKV8S6NrZrFyiy0I2RU8XFzHXUZ8kdPqrIJX/fMNwgUI9+QOsyOo0PVgbENSagpCToNQATchVlcHZrBxItumCHvIOejM0WMKShFkRA/B3jSdWyk3H83T8RziNFYfXV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654771720; 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=vssipGCOqEJQNoMsGfFwc+dxYekNW1L8kP+aFic/gt8=; b=duhgmt6ygFL+1WWQQRteCL+HD3BFWob3OnEoJGouDiOPXGN4cunlv04FU/AfXiQgMseHSW63iWsTvqoXawiGm0VMkqhzRFNUe/a40tvqW8s1CwcGW271YG9pGnZMNWXXhv9fWSgQJBJgto4bROEvbuvT8RdbX/qPkkur7FkGeBs= 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 1654771720670880.2157978847291; Thu, 9 Jun 2022 03:48:40 -0700 (PDT) Received: from localhost ([::1]:40874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFiR-0000ef-Bv for importer@patchew.org; Thu, 09 Jun 2022 06:48:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7O-0001Z2-Gg for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:21 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:46807) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7L-0005v7-GR for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:18 -0400 Received: by mail-wr1-x429.google.com with SMTP id u8so27137454wrm.13 for ; Thu, 09 Jun 2022 02:06:15 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=vssipGCOqEJQNoMsGfFwc+dxYekNW1L8kP+aFic/gt8=; b=NCooA6v8ACoFTIlVaviEsHeZ6x5CwA1abm6IcfTfPLbyUY/rehr6+Mky2geKX2bbTL Sw3hrEvPORH4NQLaBFL1iDIFNZFuBonXypsLlu4mx0EFTfQ7tTQsoC7pIhKf10dHUnCa B1cKJYA9+BFPewG6hJc6/y6qIMS7yk7b8i3ZPKKuDDJQm2y/fs+ZvoGkyQp21d8BtFFU swyH8niWKdIw9pw5KtmQWB4ID3RCfNXijL8qA7QCO5X77GAijPjw8MFHVrglHkVgrstn R1dXFAOcPNuR/BWlTg1KqtuNsBE4llG0rxWaVMh4aTK+SQCWE0t3wfD+F7sInfQdmzrv xVsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vssipGCOqEJQNoMsGfFwc+dxYekNW1L8kP+aFic/gt8=; b=1OCg6LVlVBHiH/0Vi7uM77hg8C/gReU0thHvtfxVYG78pK0QNEGvbqEabDPJXatiUP Jr3dbtUdRLPq5kJV4B8WWC8rBICBW0zpQnD6D9SJOLz4A/oHYM6VoLOlt2KZC+LtjYFR SjYmmZ61Rp21b6EivS9acq34AnZcyJZyUHiMVlQPHeKYE37QJ7EPrl6t9F9fKKv4l0sO RL+ogFRqWFNLV2SJA/n9L7O44LjGeD2UEhkCCJNZCZv69f1CDADb0sNWYyPK9/A0zHDW 5mcxpvMcGR40XM32BZ2zbr0WvqWT23lbUrn1wbPSq/itGa/cHGi1pRQIOza2PT3E3wFb sgcw== X-Gm-Message-State: AOAM533Mzd75FwrMpbU1s58Q5k/Gg8/oPOCQqf7lwWfxG8BclTTKkZpR RA7mg1d4ouTFTyJYHnQSwZDsMp2vBJkJMw== X-Google-Smtp-Source: ABdhPJwCTFtEHZT1Yn1GvjSHBHtkGOzz6GE5+6YxO6sllOUU0zR3BEfZ5iBFh8Zion6TSsJhPCNnhQ== X-Received: by 2002:a5d:58ed:0:b0:217:dd5:7508 with SMTP id f13-20020a5d58ed000000b002170dd57508mr24330176wrd.606.1654765574388; Thu, 09 Jun 2022 02:06:14 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 31/55] target/arm: Move regime_ttbr to ptw.c Date: Thu, 9 Jun 2022 10:05:13 +0100 Message-Id: <20220609090537.1971756-32-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654771721148100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-25-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 1 - target/arm/helper.c | 16 ---------------- target/arm/ptw.c | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index 3d3061a4351..ed152ddaf4e 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -12,7 +12,6 @@ #ifndef CONFIG_USER_ONLY =20 bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); -uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn); =20 #endif /* !CONFIG_USER_ONLY */ #endif /* TARGET_ARM_PTW_H */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 8deb0fa94c1..fdda87e87e2 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10475,22 +10475,6 @@ bool regime_translation_disabled(CPUARMState *env,= ARMMMUIdx mmu_idx) return (regime_sctlr(env, mmu_idx) & SCTLR_M) =3D=3D 0; } =20 -/* Return the TTBR associated with this translation regime */ -uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn) -{ - if (mmu_idx =3D=3D ARMMMUIdx_Stage2) { - return env->cp15.vttbr_el2; - } - if (mmu_idx =3D=3D ARMMMUIdx_Stage2_S) { - return env->cp15.vsttbr_el2; - } - if (ttbrn =3D=3D 0) { - return env->cp15.ttbr0_el[regime_el(env, mmu_idx)]; - } else { - return env->cp15.ttbr1_el[regime_el(env, mmu_idx)]; - } -} - /* Convert a possible stage1+2 MMU index into the appropriate * stage 1 MMU index */ diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 8db4b5edf1a..dc559e6bdfd 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -75,6 +75,22 @@ static bool regime_is_user(CPUARMState *env, ARMMMUIdx m= mu_idx) } } =20 +/* Return the TTBR associated with this translation regime */ +static uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn) +{ + if (mmu_idx =3D=3D ARMMMUIdx_Stage2) { + return env->cp15.vttbr_el2; + } + if (mmu_idx =3D=3D ARMMMUIdx_Stage2_S) { + return env->cp15.vsttbr_el2; + } + if (ttbrn =3D=3D 0) { + return env->cp15.ttbr0_el[regime_el(env, mmu_idx)]; + } else { + return env->cp15.ttbr1_el[regime_el(env, mmu_idx)]; + } +} + static bool ptw_attrs_are_device(CPUARMState *env, ARMCacheAttrs cacheattr= s) { /* --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654772287; cv=none; d=zohomail.com; s=zohoarc; b=OdAGChhBoNF66trynUJY1aGCcKEj990fxJYPTGHBgaYl+RHrVHSM00DH0R6629uA0TpfbY2DCisX4Ir5NpaSAfVlLFhAKLzn2r/EzM4A0QADqkaz46cqLUDMzTBOMjv/fOu6oPvwsL3QmsD7Z3Ywyr27aAIHEq3aMFOtfVWHvTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654772287; 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=NqYWQ8l2y3CQlswUgWQkihqe1Lkdxi0y72T5OHE/ZAg=; b=JCgGDgaTxM3P/z1PDaccvKAHCBXOdxCoeUOM9/5GdDcCwo3wfjO5MXIRQRiKGUOl7rqPT9uLwde2HEnYR7JEtZvpzG9V94LxIpcPlMUm3TbbrUdzkMVSjVxw7Dq1TWl1Xymj+OrnCyUydpWmpbUbhJFvlirAMCBpxlhoNW8fnN4= 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 1654772287575542.248691377787; Thu, 9 Jun 2022 03:58:07 -0700 (PDT) Received: from localhost ([::1]:49814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFra-00085d-EL for importer@patchew.org; Thu, 09 Jun 2022 06:58:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7O-0001Z3-Ud for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:21 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:44816) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7M-00060e-Ft for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:18 -0400 Received: by mail-wr1-x433.google.com with SMTP id q15so23422931wrc.11 for ; Thu, 09 Jun 2022 02:06:16 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=NqYWQ8l2y3CQlswUgWQkihqe1Lkdxi0y72T5OHE/ZAg=; b=lXZ8SzMQuaSIkxttaPcqja1ngEg2kC4C4jnTj25wsXSNAyadt/KJSoB8uTk+71trNh lyMsKokwPfTfS3ET35LbQQIYysiZ+P8um5eZq1cx+ZIJpWtEmo59afB3p81u/ZI9CrtL EThDxu/nzSljgic5GS0+q3D1WeqkdmTvxD/QT8D5VVPI7hAhd8WRBbvGeUgxZsZHAwwf vEZLLUDedkJl1OQAcWMhNJtkthYFoJX7x0qYiJT5KZYhDDgNf3eO8G9YocbQmmCrZSfy H6qp/FFLFnrFmnPxlGvhLSTf9ZbEaBORMz61X1ia5QXZ3abZbnTfp6B19aMrTE8Q0jKi vQAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NqYWQ8l2y3CQlswUgWQkihqe1Lkdxi0y72T5OHE/ZAg=; b=7XWrZwiwGrVCrNXXpQXXVXdqm8/aLvGRKRmqCySWEYpVzX6fCm+axU9eEPCf33y1N7 A3vkTeBEpnYTcgShi4LY1tTEHHBC84LDdsmn7oVKng1Z899ddVB/rSw5dedgefIRi6P3 Flr++gWdweOI4za6mKUBwU4E9ELPQQkLhERBH9DtX7zIo2gkKTLcFJapLkMApwjtG1P2 cAChrgFH0Cn0Sv4kDr2aD4jFj5SzhbeIno74itlxPJiHP71zW1iJJSVbSxzA50pa+8jo Ho3wTWAnDORmgkxuI9+JtsEY9lmV2tBlGCXolm3SicPNkeP2M0srGWlz8+5q+8sIejBY qBZA== X-Gm-Message-State: AOAM532HghF4oujbjge+9nMBjg7hSZuQ0WIJ0WaB4vxQHhpInMk8xCFl BO7C74kShzV36IR9JrrXMBsyjtx3PyuDyA== X-Google-Smtp-Source: ABdhPJzCdX1k7VfeeJ4eZItrHgTdOrxSjkoGP2Aydcls6+JuFh0SXNuBJ8Xs8pN8FsQfH+BkKai/9g== X-Received: by 2002:a5d:5383:0:b0:211:8d24:8285 with SMTP id d3-20020a5d5383000000b002118d248285mr37600105wrv.681.1654765575792; Thu, 09 Jun 2022 02:06:15 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 32/55] target/arm: Move regime_translation_disabled to ptw.c Date: Thu, 9 Jun 2022 10:05:14 +0100 Message-Id: <20220609090537.1971756-33-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654772288911100003 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-26-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 17 ---------------- target/arm/helper.c | 47 --------------------------------------------- target/arm/ptw.c | 47 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 46 insertions(+), 65 deletions(-) delete mode 100644 target/arm/ptw.h diff --git a/target/arm/ptw.h b/target/arm/ptw.h deleted file mode 100644 index ed152ddaf4e..00000000000 --- a/target/arm/ptw.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * ARM page table walking. - * - * This code is licensed under the GNU GPL v2 or later. - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#ifndef TARGET_ARM_PTW_H -#define TARGET_ARM_PTW_H - -#ifndef CONFIG_USER_ONLY - -bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx); - -#endif /* !CONFIG_USER_ONLY */ -#endif /* TARGET_ARM_PTW_H */ diff --git a/target/arm/helper.c b/target/arm/helper.c index fdda87e87e2..69b1c060c1f 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -36,7 +36,6 @@ #include "semihosting/common-semi.h" #endif #include "cpregs.h" -#include "ptw.h" =20 #define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */ =20 @@ -10429,52 +10428,6 @@ uint64_t arm_sctlr(CPUARMState *env, int el) } =20 #ifndef CONFIG_USER_ONLY - -/* Return true if the specified stage of address translation is disabled */ -bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx) -{ - uint64_t hcr_el2; - - if (arm_feature(env, ARM_FEATURE_M)) { - switch (env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)] & - (R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK= )) { - case R_V7M_MPU_CTRL_ENABLE_MASK: - /* Enabled, but not for HardFault and NMI */ - return mmu_idx & ARM_MMU_IDX_M_NEGPRI; - case R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK: - /* Enabled for all cases */ - return false; - case 0: - default: - /* HFNMIENA set and ENABLE clear is UNPREDICTABLE, but - * we warned about that in armv7m_nvic.c when the guest set it. - */ - return true; - } - } - - hcr_el2 =3D arm_hcr_el2_eff(env); - - if (mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_Stage2= _S) { - /* HCR.DC means HCR.VM behaves as 1 */ - return (hcr_el2 & (HCR_DC | HCR_VM)) =3D=3D 0; - } - - if (hcr_el2 & HCR_TGE) { - /* TGE means that NS EL0/1 act as if SCTLR_EL1.M is zero */ - if (!regime_is_secure(env, mmu_idx) && regime_el(env, mmu_idx) =3D= =3D 1) { - return true; - } - } - - if ((hcr_el2 & HCR_DC) && arm_mmu_idx_is_stage1_of_2(mmu_idx)) { - /* HCR.DC means SCTLR_EL1.M behaves as 0 */ - return true; - } - - return (regime_sctlr(env, mmu_idx) & SCTLR_M) =3D=3D 0; -} - /* Convert a possible stage1+2 MMU index into the appropriate * stage 1 MMU index */ diff --git a/target/arm/ptw.c b/target/arm/ptw.c index dc559e6bdfd..ec60afd9bff 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -12,7 +12,6 @@ #include "cpu.h" #include "internals.h" #include "idau.h" -#include "ptw.h" =20 =20 static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, @@ -91,6 +90,52 @@ static uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx = 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) +{ + uint64_t hcr_el2; + + if (arm_feature(env, ARM_FEATURE_M)) { + switch (env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)] & + (R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK= )) { + case R_V7M_MPU_CTRL_ENABLE_MASK: + /* Enabled, but not for HardFault and NMI */ + return mmu_idx & ARM_MMU_IDX_M_NEGPRI; + case R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK: + /* Enabled for all cases */ + return false; + case 0: + default: + /* + * HFNMIENA set and ENABLE clear is UNPREDICTABLE, but + * we warned about that in armv7m_nvic.c when the guest set it. + */ + return true; + } + } + + hcr_el2 =3D arm_hcr_el2_eff(env); + + if (mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_Stage2= _S) { + /* HCR.DC means HCR.VM behaves as 1 */ + return (hcr_el2 & (HCR_DC | HCR_VM)) =3D=3D 0; + } + + if (hcr_el2 & HCR_TGE) { + /* TGE means that NS EL0/1 act as if SCTLR_EL1.M is zero */ + if (!regime_is_secure(env, mmu_idx) && regime_el(env, mmu_idx) =3D= =3D 1) { + return true; + } + } + + if ((hcr_el2 & HCR_DC) && arm_mmu_idx_is_stage1_of_2(mmu_idx)) { + /* HCR.DC means SCTLR_EL1.M behaves as 0 */ + return true; + } + + return (regime_sctlr(env, mmu_idx) & SCTLR_M) =3D=3D 0; +} + static bool ptw_attrs_are_device(CPUARMState *env, ARMCacheAttrs cacheattr= s) { /* --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654769364; cv=none; d=zohomail.com; s=zohoarc; b=mj/luwfEMVLNrd6LT3tP9YVirqZWp3moUZuK3pRN+XWenwK4ZzXMwoGDJjfJay1kRSfk0ZdH1B53RjeScYFuQn0mTvUSwPQA1ILsv7wg3nRSh6bXidO2Oehs/sFX+IxEzlfXtObiI07UmQXmMnsSTYOyGrg6wdHkVJXCQZnqdmw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654769364; 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=JfidimcrBCl7Udx4o3Zs0c4uqkOTceip308AFLIscT0=; b=hXw+wxy3TNTXiFgY4vHLDt5eft1qZriLZKJ7IUhbQDISQa7Vm+8yWbVH6TmOc1zn66gT47BryulhRuUc6EpT02VmDXl26yqpoG1a+5J7Pfd7GOC/ORb4axs/eLxuZD38iPRrQDNGsHAZE6E5KwW/ok4Dc7HwGBnL4eLok7sDUxU= 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 1654769364478736.5837923511054; Thu, 9 Jun 2022 03:09:24 -0700 (PDT) Received: from localhost ([::1]:55902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzF6Q-0003sd-Vt for importer@patchew.org; Thu, 09 Jun 2022 06:09:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39714) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7Q-0001ZD-Fe for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:22 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:46819) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7O-0005xd-3T for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:19 -0400 Received: by mail-wr1-x435.google.com with SMTP id u8so27137707wrm.13 for ; Thu, 09 Jun 2022 02:06:17 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=JfidimcrBCl7Udx4o3Zs0c4uqkOTceip308AFLIscT0=; b=iORuARJVwwG7cRteZ+Qo+xAm0B1S0qTOkFSIP6hNa+Q/+4XQD1BqHnlgTY6I1Hqn5V NvFBRrtYowDAoCPbjMFu83+vb/URbr42RhRLADK7OuFcMEGrpraphyUonXtKkuW/vOO+ TueQaJJ/ZUtzCgHeNFofW0s7bacFbhfJjulrVRMM2yr34E9dVkvAhISr5CKe7pWPkyiJ spyIgYgh0TSGs+6MWLcSqXQk8KyRNCFUqnoUupUfsmTWG/qajhCGMdCJt+YBGZLb4ORe YUE1sJcLIvC8oL/ou/RfwpmACDszrX3g+sAuq2Tkm972tYWebBCGv52k7r1dDTj716bL 4fGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JfidimcrBCl7Udx4o3Zs0c4uqkOTceip308AFLIscT0=; b=bIf14kmcdpLXwpbqRMnjLMNOFymLt18QJ86AtxqUtmefys/u4L6nM4sV+RbIbDxgwH IK4mycYjBwht8Bjr0d9pS8EZ5UjK8zivDXvrFfSyP+Y0meCxVwiJ/dDgijomWQ95Dif4 K/88Kdnb+RZQ9E1zJMV6oPKh5JsqFxKSMSNmzOnPf/9P7WQmY+jFV833f+yZ7uBqRLRe ED2yS/Nuhv5e9grX8Hguu0WAEZdLvd14p+bIrIbVD4eogSbfNhy0yKP3qSTt92sReYEp ZDnGhIDjoSMIleECNP53ptLIyOKBahmwhAiRTu/zARrKAIi+YTU/G7r5eP0geSe1x5Nz CenQ== X-Gm-Message-State: AOAM533kTccI2d9uUzlmfjy5EHB6RJMmAxPaT+HIE5LJTLPnJo2cgWk7 jvwMvZUl2kAvG2elO+5DYhIPUbkNVurKaA== X-Google-Smtp-Source: ABdhPJxAPsi2WdTm2vuR2Y/R5HoxJTQVzLgHXwzFy62yU4Q72BrmOkUX+MnHjsZ1khtuMPAqJtCnlA== X-Received: by 2002:a5d:6dd1:0:b0:210:7a1:cda0 with SMTP id d17-20020a5d6dd1000000b0021007a1cda0mr37329039wrz.570.1654765576678; Thu, 09 Jun 2022 02:06:16 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 33/55] target/arm: Move arm_cpu_get_phys_page_attrs_debug to ptw.c Date: Thu, 9 Jun 2022 10:05:15 +0100 Message-Id: <20220609090537.1971756-34-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654769366071100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-27-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/helper.c | 26 -------------------------- target/arm/ptw.c | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 69b1c060c1f..fe1e426f883 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10606,32 +10606,6 @@ ARMVAParameters aa64_va_parameters(CPUARMState *en= v, uint64_t va, }; } =20 -#ifndef CONFIG_USER_ONLY -hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, - MemTxAttrs *attrs) -{ - ARMCPU *cpu =3D ARM_CPU(cs); - CPUARMState *env =3D &cpu->env; - hwaddr phys_addr; - target_ulong page_size; - int prot; - bool ret; - ARMMMUFaultInfo fi =3D {}; - ARMMMUIdx mmu_idx =3D arm_mmu_idx(env); - ARMCacheAttrs cacheattrs =3D {}; - - *attrs =3D (MemTxAttrs) {}; - - ret =3D get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &phys_addr, - attrs, &prot, &page_size, &fi, &cacheattrs); - - if (ret) { - return -1; - } - return phys_addr; -} -#endif - /* Note that signed overflow is undefined in C. The following routines are careful to use unsigned types where modulo arithmetic is required. Failure to do so _will_ break on newer gcc. */ diff --git a/target/arm/ptw.c b/target/arm/ptw.c index ec60afd9bff..e9f6870d0a6 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2491,3 +2491,27 @@ bool get_phys_addr(CPUARMState *env, target_ulong ad= dress, phys_ptr, prot, page_size, fi); } } + +hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, + MemTxAttrs *attrs) +{ + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + hwaddr phys_addr; + target_ulong page_size; + int prot; + bool ret; + ARMMMUFaultInfo fi =3D {}; + ARMMMUIdx mmu_idx =3D arm_mmu_idx(env); + ARMCacheAttrs cacheattrs =3D {}; + + *attrs =3D (MemTxAttrs) {}; + + ret =3D get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &phys_addr, + attrs, &prot, &page_size, &fi, &cacheattrs); + + if (ret) { + return -1; + } + return phys_addr; +} --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654773825; cv=none; d=zohomail.com; s=zohoarc; b=Ty3C7Ro4J1UuGiQ8uvsQ54+ZqVV6HSL+pvt0r5Cln1FZvyl7HZAof1gng+R/dZztiNbcSxwZI5oIsYWc6R1b1V6y3gPYfzeTQjCGZtY5917s0IFQQvs10LjkUeXIwtoimHWEN04nwRzV1api0JBVjusLVR4z/FNq/H7GAlvrr9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654773825; 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=Hig8Fai2F1wZbBshuF8R/7YaHSV9c3nGNPXI/ypkLI4=; b=UTyo5G4+XTHXBJlK65w/+h+sUKzqbymbKVGdb4OO2pbLFOgni/iwM6eIVWU03Otho5aApXLb4x0vop/MwUzwqXcFU4EqErUPTvETIpewBCLWYrP9wBUauLpJdqbnWqqykx8/APIwALAO7l0iv4gpmLSHAvCvg45bqEkxxJEGSbI= 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 1654773825983566.674217133357; Thu, 9 Jun 2022 04:23:45 -0700 (PDT) Received: from localhost ([::1]:47034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzGGO-0002f7-Du for importer@patchew.org; Thu, 09 Jun 2022 07:23:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7R-0001ZF-2K for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:22 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:44820) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7P-00064p-0N for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:20 -0400 Received: by mail-wr1-x432.google.com with SMTP id q15so23424549wrc.11 for ; Thu, 09 Jun 2022 02:06:18 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Hig8Fai2F1wZbBshuF8R/7YaHSV9c3nGNPXI/ypkLI4=; b=m/4E20ulIBpiVB/IMa2AT0nnlThFQOBHtqCJzjlmJp3oFcJcu+Xpy0FTdeWW4zK9ch MNfuszWLqvuUhK5IseecTJff0wmPFASjE1IRsO2ZrCgBs3E0xzXE6gmjrbATr6Mb1dwZ QYRC3a/r2it+xiQq3um2PL0locyGFSGhxdFfJc/kCiPfxMZALgRo94qDtrRQLntdEi1l CzjGR3jUaO58muauouuXb5mZFNpZH+pl+JGL+2papdYTW5nVR17jJMVvsnE21laW2VpE 2cNW27sSBMP3HMIukzTCCpFRto5WRcn7wVu163HBjAknMWwkjyH9CQsaCSWu40vwAHKx eOlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hig8Fai2F1wZbBshuF8R/7YaHSV9c3nGNPXI/ypkLI4=; b=RUCVNJbDhcMlnMtQvR4ky3yU/4VJ+k52H9hd0SHHGTn3iH87KEoVRwJelRlx1UWafh cKvWDeEmf1P8Ki8+HEonLyO8+VpfXebooxAXg5hfC1Lky5ETHguAgyutxvhrUDFGcjBS banWHdoTftO8zyGgAYBxGDbEFWviASovHJgYgyPGdy3N0df2mh3S3DLP/sFUfWQrG8fx j1OMSP7t7zeULpgz1a6OrwgrGcxrr3ZMdWCpjotlkbxv96TQCXxwDM3ZuN8G5HVyaW0C Rys4kQXMYYWP9W8WOedqehO1mC+GJvC2mcQX+rhwNUzvlPYFaidRMYZKnaHUGBxk0FOV /xBQ== X-Gm-Message-State: AOAM532/T5dd5E2AxQ4FdFGtWdUNTmWElHMe4YCGqqJDs59Bd2zTCqr+ 0qSxk6NAXvvvt1dLPQI2+SzWxPp+UvRR6Q== X-Google-Smtp-Source: ABdhPJw6taCiKgsTflyHHzTZD2bD5n60nC8L1iEFRyRYMLxJLwTSLu81gjHWoHLJSCPyI+/dClUrRg== X-Received: by 2002:a5d:4290:0:b0:213:badd:abc5 with SMTP id k16-20020a5d4290000000b00213baddabc5mr32116536wrq.54.1654765577735; Thu, 09 Jun 2022 02:06:17 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 34/55] target/arm: Move stage_1_mmu_idx, arm_stage1_mmu_idx to ptw.c Date: Thu, 9 Jun 2022 10:05:16 +0100 Message-Id: <20220609090537.1971756-35-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654773827008100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-28-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/helper.c | 32 -------------------------------- target/arm/ptw.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index fe1e426f883..37cf9fa6aba 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10427,31 +10427,6 @@ uint64_t arm_sctlr(CPUARMState *env, int el) return env->cp15.sctlr_el[el]; } =20 -#ifndef CONFIG_USER_ONLY -/* Convert a possible stage1+2 MMU index into the appropriate - * stage 1 MMU index - */ -ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) -{ - switch (mmu_idx) { - case ARMMMUIdx_SE10_0: - return ARMMMUIdx_Stage1_SE0; - case ARMMMUIdx_SE10_1: - return ARMMMUIdx_Stage1_SE1; - case ARMMMUIdx_SE10_1_PAN: - return ARMMMUIdx_Stage1_SE1_PAN; - case ARMMMUIdx_E10_0: - return ARMMMUIdx_Stage1_E0; - case ARMMMUIdx_E10_1: - return ARMMMUIdx_Stage1_E1; - case ARMMMUIdx_E10_1_PAN: - return ARMMMUIdx_Stage1_E1_PAN; - default: - return mmu_idx; - } -} -#endif /* !CONFIG_USER_ONLY */ - int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx) { if (regime_has_2_ranges(mmu_idx)) { @@ -11081,13 +11056,6 @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env) return arm_mmu_idx_el(env, arm_current_el(env)); } =20 -#ifndef CONFIG_USER_ONLY -ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) -{ - return stage_1_mmu_idx(arm_mmu_idx(env)); -} -#endif - static CPUARMTBFlags rebuild_hflags_common(CPUARMState *env, int fp_el, ARMMMUIdx mmu_idx, CPUARMTBFlags flags) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index e9f6870d0a6..49e9a1d108e 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -47,6 +47,34 @@ unsigned int arm_pamax(ARMCPU *cpu) return pamax_map[parange]; } =20 +/* + * Convert a possible stage1+2 MMU index into the appropriate stage 1 MMU = index + */ +ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) +{ + switch (mmu_idx) { + case ARMMMUIdx_SE10_0: + return ARMMMUIdx_Stage1_SE0; + case ARMMMUIdx_SE10_1: + return ARMMMUIdx_Stage1_SE1; + case ARMMMUIdx_SE10_1_PAN: + return ARMMMUIdx_Stage1_SE1_PAN; + case ARMMMUIdx_E10_0: + return ARMMMUIdx_Stage1_E0; + case ARMMMUIdx_E10_1: + return ARMMMUIdx_Stage1_E1; + case ARMMMUIdx_E10_1_PAN: + return ARMMMUIdx_Stage1_E1_PAN; + default: + return mmu_idx; + } +} + +ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) +{ + return stage_1_mmu_idx(arm_mmu_idx(env)); +} + static bool regime_translation_big_endian(CPUARMState *env, ARMMMUIdx mmu_= idx) { return (regime_sctlr(env, mmu_idx) & SCTLR_EE) !=3D 0; --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654770164; cv=none; d=zohomail.com; s=zohoarc; b=MV9s1kOHxEtRSt9ri8gs+hBdZNrC1CKJDUOLO1aVpbNbE2HLnxBQ958Sc0F4PG/sGpif9yD2z5VcckWYb+U3YtI9zrZ7Asz0/GEQP4Go4agvrzOU4wF3qZsuDRjfiBIXwXrULvMktsfyqn8aIL2sE3KmGSGsNUlCFQS8p67Pvww= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654770164; 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=vtklS/jBlWBBb7I5PQy1NemEL8fX7OtzLyw/Jsz+ozc=; b=eplkrp714/XQQr2ccdWisdzzlIYfgI1j1T5J2YDEo+TXcl6IOKoa0pU2JonbHt5hGxt0YBpJkuKg18uFL0yGLVpOk8N5IM+6/FmU+dzJYgiB1RtMUo0mVTE2i+4U924oFKMA34TUSJZ7MnsQJ83xjWi7WuUKgv2ThbUTO7zfhb0= 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 1654770164557169.9830631107402; Thu, 9 Jun 2022 03:22:44 -0700 (PDT) Received: from localhost ([::1]:41580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFJL-0005oa-AI for importer@patchew.org; Thu, 09 Jun 2022 06:22:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7R-0001ZG-BK for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:22 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:36485) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7P-00062j-Aa for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:21 -0400 Received: by mail-wr1-x431.google.com with SMTP id o8so3625311wro.3 for ; Thu, 09 Jun 2022 02:06:18 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=vtklS/jBlWBBb7I5PQy1NemEL8fX7OtzLyw/Jsz+ozc=; b=zOs2w1fq0As+FV5dDTJAxBjv5Jv8AqWDwM0JCrfvo4voWsKiQE9oT281dhoO4Ysevn Gxp3sQ55J70+EQtksSnBfRBnIFdK8ZBqLANhaW60fHcy7DQwX3NdXAmPvRpdfVagnv+K 56UINMHkNh7o+Er0DXHfzcOmhoNoWlkxZ84uhqK/nL6qlj4EqroHl995vuZhF+y1ANgf wi75YBYK6JU2RI38JwYGNxrjeXr0WWJmj9QgV8FyBFXdfs6cv8meyJvNdff4EXk/b37F D2yxhpzyOKWnjOhTIh+AmkGR26UREbIr1X0ik/Kk5EjjclHALfqCTxf6KE5d51vm/rde d6ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vtklS/jBlWBBb7I5PQy1NemEL8fX7OtzLyw/Jsz+ozc=; b=kAj0uBSrldl7pxqI7ryxpoaX05brkEGNvsUqCRW0gUo4tVkiRt2fbstbFOnfb+QUZ1 jnCXIF4kqrglxfxAUfWm8FCFV1m97KMJzWQ826aMf5Tvxx/VtZKX6mW0P/+iMbhX3eRD eS8fQGYOYgu2NWf69n8eLIH9gy6yP7h9i5Lhx3KLi7G2TKrXZpEiNoyA5y732V8R4mpO Y6G+bjLKCQZ+SAeIJ0MOWoa4tsRY+FcXNmvwAdcxmKPDjnMO1wBp5O7CNK9qpN3VddaW thnyV4Za7lxMpktkxxOQSo6jHMa2FoVz0or9fE4H8A19ibdaSTpwT8sI5AQO48LoF4PT YpIg== X-Gm-Message-State: AOAM5323y/Xrvg05hxiLhHcvakrj3JNS2FEkxjykJH2IqD3O0y6tbcaE ZefoU2qweNbVZ9awFr+9BTOV3YfDlIamVQ== X-Google-Smtp-Source: ABdhPJywPfgSq4Es/es1yup3rgJ8DtgqMQM5rABYc94tQNp+MMutvNszzaIZqvXbjIVZ65D4KanDaA== X-Received: by 2002:a5d:5222:0:b0:213:b7f7:58fe with SMTP id i2-20020a5d5222000000b00213b7f758femr31628350wra.620.1654765578602; Thu, 09 Jun 2022 02:06:18 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 35/55] target/arm: Pass CPUARMState to arm_ld[lq]_ptw Date: Thu, 9 Jun 2022 10:05:17 +0100 Message-Id: <20220609090537.1971756-36-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::431; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x431.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654770166647100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson The use of ARM_CPU to recover env from cs calls object_class_dynamic_cast, which shows up on the profile. This is pointless, because all callers already have env, and the reverse operation, env_cpu, is only pointer arithmetic. Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-29-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 49e9a1d108e..4d97a248084 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -241,11 +241,10 @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMM= MUIdx mmu_idx, } =20 /* All loads done in the course of a page table walk go through here. */ -static uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure, +static uint32_t arm_ldl_ptw(CPUARMState *env, hwaddr addr, bool is_secure, ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) { - ARMCPU *cpu =3D ARM_CPU(cs); - CPUARMState *env =3D &cpu->env; + CPUState *cs =3D env_cpu(env); MemTxAttrs attrs =3D {}; MemTxResult result =3D MEMTX_OK; AddressSpace *as; @@ -270,11 +269,10 @@ static uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr= , bool is_secure, return 0; } =20 -static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, +static uint64_t arm_ldq_ptw(CPUARMState *env, hwaddr addr, bool is_secure, ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) { - ARMCPU *cpu =3D ARM_CPU(cs); - CPUARMState *env =3D &cpu->env; + CPUState *cs =3D env_cpu(env); MemTxAttrs attrs =3D {}; MemTxResult result =3D MEMTX_OK; AddressSpace *as; @@ -409,7 +407,6 @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t= address, target_ulong *page_size, ARMMMUFaultInfo *fi) { - CPUState *cs =3D env_cpu(env); int level =3D 1; uint32_t table; uint32_t desc; @@ -427,7 +424,7 @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t= address, fi->type =3D ARMFault_Translation; goto do_fault; } - desc =3D arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), + desc =3D arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx), mmu_idx, fi); if (fi->type !=3D ARMFault_None) { goto do_fault; @@ -466,7 +463,7 @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t= address, /* Fine pagetable. */ table =3D (desc & 0xfffff000) | ((address >> 8) & 0xffc); } - desc =3D arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), + desc =3D arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx), mmu_idx, fi); if (fi->type !=3D ARMFault_None) { goto do_fault; @@ -531,7 +528,6 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t= address, hwaddr *phys_ptr, MemTxAttrs *attrs, int *pro= t, target_ulong *page_size, ARMMMUFaultInfo *fi) { - CPUState *cs =3D env_cpu(env); ARMCPU *cpu =3D env_archcpu(env); int level =3D 1; uint32_t table; @@ -553,7 +549,7 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t= address, fi->type =3D ARMFault_Translation; goto do_fault; } - desc =3D arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), + desc =3D arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx), mmu_idx, fi); if (fi->type !=3D ARMFault_None) { goto do_fault; @@ -607,7 +603,7 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t= address, ns =3D extract32(desc, 3, 1); /* Lookup l2 entry. */ table =3D (desc & 0xfffffc00) | ((address >> 10) & 0x3fc); - desc =3D arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), + desc =3D arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx), mmu_idx, fi); if (fi->type !=3D ARMFault_None) { goto do_fault; @@ -973,7 +969,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64= _t address, ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheat= trs) { ARMCPU *cpu =3D env_archcpu(env); - CPUState *cs =3D CPU(cpu); /* Read an LPAE long-descriptor translation table. */ ARMFaultType fault_type =3D ARMFault_Translation; uint32_t level; @@ -1196,7 +1191,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint= 64_t address, descaddr |=3D (address >> (stride * (4 - level))) & indexmask; descaddr &=3D ~7ULL; nstable =3D extract32(tableattrs, 4, 1); - descriptor =3D arm_ldq_ptw(cs, descaddr, !nstable, mmu_idx, fi); + descriptor =3D arm_ldq_ptw(env, descaddr, !nstable, mmu_idx, fi); if (fi->type !=3D ARMFault_None) { goto do_fault; } --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654767575; cv=none; d=zohomail.com; s=zohoarc; b=DxIYtY+5q+AcVhh/UnlqDJJXFDbavH3ryeDNLuDvu3a1IIDyV+em0ZAsf2FlAUKEVTqMA3jRxLjjhA3yyuCl7RRmairOeYAxom0m747IIAGUODqYQpWJV+g94fqghZcxOckciy43i5AEIwdHrp65bcYI9PEjkuDBRNnQ0twYRvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654767575; 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=EuesFPP2ejmD1fMqQKFfEmxikNEPVrFLtiBcjEpaFDk=; b=k8MOTbGVO/65EV5PfXyw/AdYylp4qmIpP+PKM3k5TNoVPa3SHBvJQUZ9fdMrqCO75RdClXJjGwA9nvTICcktAJTztU24Sxxei6OmITw2iKeTnUckeZJCgK5gZRbFTqotNPcJQLs/bposnqMT2wzyVJCedxhaxsJFQENuQUVS2rg= 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 1654767575231346.4424375414278; Thu, 9 Jun 2022 02:39:35 -0700 (PDT) Received: from localhost ([::1]:54666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzEdZ-00074l-Vv for importer@patchew.org; Thu, 09 Jun 2022 05:39:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39744) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7S-0001ZL-7c for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:22 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:40587) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7Q-0005wl-AN for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:21 -0400 Received: by mail-wr1-x436.google.com with SMTP id k16so31477811wrg.7 for ; Thu, 09 Jun 2022 02:06:19 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=EuesFPP2ejmD1fMqQKFfEmxikNEPVrFLtiBcjEpaFDk=; b=eMZ6cqXEA7rm1G6az+CJ/89YVforU6AL/xrTqOn7qWmJwniNPn+CQlofDzxNN2gipE AG5aFAwfIqcriNAg+rQc9Ms/vDGMcLiSj5h4wqmenczjxf7MDRBrFmmX6CeO9qXRdddJ okDY+Mn+cNLS6wjXhgz7yZsOHoOvllT7Eb2MOeXHrCP6JIPLkaKgOnQoVFsAjt0HGzo/ zaeTJgtF5XfjUXRzTcm1V4pAV+RiHXVd6QEvjlGEBL02zBmQnk5wJJouZf4+CPpNfni0 Po+tOu/MKA14C/zcl0rJAEXvIuip4uyEWykSrE06CQCeiaKJg6Ma2dlV2FAuJIfegcL4 fusw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EuesFPP2ejmD1fMqQKFfEmxikNEPVrFLtiBcjEpaFDk=; b=Vn0TD4K6+Y8Obbvt7p1p6p0XMHmbZGubdHvzhFnTTEJBXrzGTvIoBVEFHcZAUOWp0V 96ZdlKSpW7MHWr4Pojj/5bJRwso6pZaZug/vANME8qYSfZ31xnOKiJL0aYnS683IcNDx ASZvVhs1/i6P4zVLhOHrs5pouGEp+A9VReAxztNVHtPTn439DjtccoSaCNfVsRjwVwR1 DBrSICvHW7YbYGHu0Ah8hwHIgb07NO5LNXn51iGHliMPVbSeKkEXBfDvSpx+IEolTl02 V+fWsc3r0lUSIkUDIt8GLTiy5X1meRWEP8YivNPbwFxwnGLozclb3waUP2NOueXJo7Ch WiBA== X-Gm-Message-State: AOAM530ruAZXMbj/VO5pnnOa0mH6u/C3DUsYY3ywViDkYjSA/4tPUC34 YHH6Pq4nQCyiwEJlnLl7+bseoBoVUdTiaw== X-Google-Smtp-Source: ABdhPJx04aIAuDrm1FMf0ABenZFJQ0+NNaMrPTfT+Uqy4WoKlASDESEUUodFtqcr8b04tn2qlajHNg== X-Received: by 2002:a05:6000:1547:b0:218:568a:bd2e with SMTP id 7-20020a056000154700b00218568abd2emr10444077wry.716.1654765579600; Thu, 09 Jun 2022 02:06:19 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 36/55] target/arm: Rename TBFLAG_A64 ZCR_LEN to VL Date: Thu, 9 Jun 2022 10:05:18 +0100 Message-Id: <20220609090537.1971756-37-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::436; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x436.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654767577238100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson With SME, the vector length does not only come from ZCR_ELx. Comment that this is either NVL or SVL, like the pseudocode. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-2-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu.h | 3 ++- target/arm/translate-a64.h | 2 +- target/arm/translate.h | 2 +- target/arm/helper.c | 2 +- target/arm/translate-a64.c | 2 +- target/arm/translate-sve.c | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 0ee1705a4fa..e791ffdd6b6 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3241,7 +3241,8 @@ FIELD(TBFLAG_M32, MVE_NO_PRED, 5, 1) /* No= t cached. */ */ FIELD(TBFLAG_A64, TBII, 0, 2) FIELD(TBFLAG_A64, SVEEXC_EL, 2, 2) -FIELD(TBFLAG_A64, ZCR_LEN, 4, 4) +/* The current vector length, either NVL or SVL. */ +FIELD(TBFLAG_A64, VL, 4, 4) FIELD(TBFLAG_A64, PAUTH_ACTIVE, 8, 1) FIELD(TBFLAG_A64, BT, 9, 1) FIELD(TBFLAG_A64, BTYPE, 10, 2) /* Not cached. */ diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h index f2e8ee0ee1f..dbc917ee65b 100644 --- a/target/arm/translate-a64.h +++ b/target/arm/translate-a64.h @@ -104,7 +104,7 @@ static inline TCGv_ptr vec_full_reg_ptr(DisasContext *s= , int regno) /* Return the byte size of the "whole" vector register, VL / 8. */ static inline int vec_full_reg_size(DisasContext *s) { - return s->sve_len; + return s->vl; } =20 bool disas_sve(DisasContext *, uint32_t); diff --git a/target/arm/translate.h b/target/arm/translate.h index 9f0bb270c5b..f473a21ed48 100644 --- a/target/arm/translate.h +++ b/target/arm/translate.h @@ -42,7 +42,7 @@ typedef struct DisasContext { bool ns; /* Use non-secure CPREG bank on access */ int fp_excp_el; /* FP exception EL or 0 if enabled */ int sve_excp_el; /* SVE exception EL or 0 if enabled */ - int sve_len; /* SVE vector length in bytes */ + int vl; /* current vector length in bytes */ /* Flag indicating that exceptions from secure mode are routed to EL3.= */ bool secure_routed_to_el3; bool vfp_enabled; /* FP enabled via FPSCR.EN */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 37cf9fa6aba..c228deca755 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11181,7 +11181,7 @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState= *env, int el, int fp_el, zcr_len =3D sve_zcr_len_for_el(env, el); } DP_TBFLAG_A64(flags, SVEEXC_EL, sve_el); - DP_TBFLAG_A64(flags, ZCR_LEN, zcr_len); + DP_TBFLAG_A64(flags, VL, zcr_len); } =20 sctlr =3D regime_sctlr(env, stage1); diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 935e1929bb9..d438fb89e73 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -14608,7 +14608,7 @@ static void aarch64_tr_init_disas_context(DisasCont= extBase *dcbase, dc->align_mem =3D EX_TBFLAG_ANY(tb_flags, ALIGN_MEM); dc->pstate_il =3D EX_TBFLAG_ANY(tb_flags, PSTATE__IL); dc->sve_excp_el =3D EX_TBFLAG_A64(tb_flags, SVEEXC_EL); - dc->sve_len =3D (EX_TBFLAG_A64(tb_flags, ZCR_LEN) + 1) * 16; + dc->vl =3D (EX_TBFLAG_A64(tb_flags, VL) + 1) * 16; dc->pauth_active =3D EX_TBFLAG_A64(tb_flags, PAUTH_ACTIVE); dc->bt =3D EX_TBFLAG_A64(tb_flags, BT); dc->btype =3D EX_TBFLAG_A64(tb_flags, BTYPE); diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c index 836511d7191..67761bf2cc5 100644 --- a/target/arm/translate-sve.c +++ b/target/arm/translate-sve.c @@ -111,7 +111,7 @@ static inline int pred_full_reg_offset(DisasContext *s,= int regno) /* Return the byte size of the whole predicate register, VL / 64. */ static inline int pred_full_reg_size(DisasContext *s) { - return s->sve_len >> 3; + return s->vl >> 3; } =20 /* Round up the size of a register to a size allowed by --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654774625; cv=none; d=zohomail.com; s=zohoarc; b=GZ+XRdLt9xLXr0KNFn0Hh6DNYumvJD0BJTN0WQQFC5M+uSZYr+gdoiQIvCmDqoh0uuBS70SWRqGLbcGidmhes2cJNL3xS7QXagemnQbnFosFxm1hnEvNR9JX4TDHVSVjP+HobwHhydk16eyf4jII27Xy3TfE91rFOKZStov+IEE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654774625; 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=aIxMiFOj5OlkrMNI1jLiszeJAUOpuEVyCOWF9sP0Y2w=; b=OhsDJI5xOwHhiDnpttqXojeYFWBjaTOVxJ8fJ1WOyXv4sHypnZGnwOtHZjU+tw0Mxb5GnQH+jzb3eWZ/tihIBb2M6YtSwlvUKqW7SxmFAzsrutN4wwCCr4eemK4c+PfBoKhID5v2+2/I6VjLGVLDvsAkmNmOeCiXTRMueghCnk8= 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 1654774625667337.8951957379162; Thu, 9 Jun 2022 04:37:05 -0700 (PDT) Received: from localhost ([::1]:55718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzGTH-0002WR-Cr for importer@patchew.org; Thu, 09 Jun 2022 07:37:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7U-0001by-MH for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:24 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:36483) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7S-00063j-WC for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:24 -0400 Received: by mail-wr1-x42c.google.com with SMTP id o8so3625877wro.3 for ; Thu, 09 Jun 2022 02:06:20 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=aIxMiFOj5OlkrMNI1jLiszeJAUOpuEVyCOWF9sP0Y2w=; b=ZC2m5FbCfDchAohCh+UlgwvHp2J/t873YzrMo6IFMAN9+gJvfhwOkbmJ2P0QABjLmY nJOWXN3pusATWYgARANTam9uSrR6CgjXHEf1cRsLX1V2nw2QJgC0yqEVhHXVhVB7UDBN AQ2Zi1Ovk55YuyXHvS7xSav3xNhdu7vDjQGeoB8Um4SAlD2iLvyDrwc7yIuPmcuTxA0A WCc8QjFcUNz/78CVEl9ly1FKvseMuP2teBu6akkxWA7vasDNP9on8bFv0ZTZO2qQjjVr a7RjAmgCZe+E9PDvwSx4vM2JpzKLrelM4oR4mHYWHpl9h1YzsvtxD2b/uKrDc8pLkyCi d+TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aIxMiFOj5OlkrMNI1jLiszeJAUOpuEVyCOWF9sP0Y2w=; b=yuiFcMp9+lnCRhTcJkvtmRouAGLdWvlQPkdsOmNvagGO8q5xK8CkTYp1J+1GHCYSpc FLLdNrtJpmPSP51BITY5QiBSz3mxiRk16TcYYy8yPjqGtRjJtK9zPBQ68+9nLf937Qj9 M4bjW7RuUECdGASkOwcn/wKimgiqcG02OCUK/SnPsIMyccL8I6QiCZ+CX8Ue2VxdzM5+ pu3u+sU4yPnG4lRwF/5rKpmMHK6EEbOXt+8Exb+UUImXJWAWzEOJr5A4EvKvuz5nhMXK l/Mi3IEDBs9CCKtH2mRXkA0Lh0+nFTm9ehYUXCEPrecwyGJYofiQYSiH2clcCqC2cdPG ja0w== X-Gm-Message-State: AOAM532zRD+XeiXPYBUcGiJfM85PlRh7VAYfLLDqUIfec2x8GsBMhsD9 uj7poBVoKb0y8QDLY7EsU4O8TkKrXY6jgw== X-Google-Smtp-Source: ABdhPJx21/fkSsDQUwFjcrjDGYqxWZ2x32SPamIkAE6zS51/GOnDeWVR3l89BqFcBz3exc2T9m6olQ== X-Received: by 2002:a05:6000:1888:b0:218:3fab:c510 with SMTP id a8-20020a056000188800b002183fabc510mr19871078wri.473.1654765580495; Thu, 09 Jun 2022 02:06:20 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 37/55] linux-user/aarch64: Introduce sve_vq Date: Thu, 9 Jun 2022 10:05:19 +0100 Message-Id: <20220609090537.1971756-38-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654774626506100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Add an interface function to extract the digested vector length rather than the raw zcr_el[1] value. This fixes an incorrect return from do_prctl_set_vl where we didn't take into account the set of vector lengths supported by the cpu. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-3-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- linux-user/aarch64/target_prctl.h | 20 +++++++++++++------- target/arm/cpu.h | 11 +++++++++++ linux-user/aarch64/signal.c | 4 ++-- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/linux-user/aarch64/target_prctl.h b/linux-user/aarch64/target_= prctl.h index 3f5a5d3933a..1d440ffbea4 100644 --- a/linux-user/aarch64/target_prctl.h +++ b/linux-user/aarch64/target_prctl.h @@ -10,7 +10,7 @@ static abi_long do_prctl_get_vl(CPUArchState *env) { ARMCPU *cpu =3D env_archcpu(env); if (cpu_isar_feature(aa64_sve, cpu)) { - return ((cpu->env.vfp.zcr_el[1] & 0xf) + 1) * 16; + return sve_vq(env) * 16; } return -TARGET_EINVAL; } @@ -25,18 +25,24 @@ static abi_long do_prctl_set_vl(CPUArchState *env, abi_= long arg2) */ if (cpu_isar_feature(aa64_sve, env_archcpu(env)) && arg2 >=3D 0 && arg2 <=3D 512 * 16 && !(arg2 & 15)) { - ARMCPU *cpu =3D env_archcpu(env); uint32_t vq, old_vq; =20 - old_vq =3D (env->vfp.zcr_el[1] & 0xf) + 1; - vq =3D MAX(arg2 / 16, 1); - vq =3D MIN(vq, cpu->sve_max_vq); + old_vq =3D sve_vq(env); =20 + /* + * Bound the value of arg2, so that we know that it fits into + * the 4-bit field in ZCR_EL1. Rely on the hflags rebuild to + * sort out the length supported by the cpu. + */ + vq =3D MAX(arg2 / 16, 1); + vq =3D MIN(vq, ARM_MAX_VQ); + env->vfp.zcr_el[1] =3D vq - 1; + arm_rebuild_hflags(env); + + vq =3D sve_vq(env); if (vq < old_vq) { aarch64_sve_narrow_vq(env, vq); } - env->vfp.zcr_el[1] =3D vq - 1; - arm_rebuild_hflags(env); return vq * 16; } return -TARGET_EINVAL; diff --git a/target/arm/cpu.h b/target/arm/cpu.h index e791ffdd6b6..f5af88b686d 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3286,6 +3286,17 @@ static inline int cpu_mmu_index(CPUARMState *env, bo= ol ifetch) return EX_TBFLAG_ANY(env->hflags, MMUIDX); } =20 +/** + * sve_vq + * @env: the cpu context + * + * Return the VL cached within env->hflags, in units of quadwords. + */ +static inline int sve_vq(CPUARMState *env) +{ + return EX_TBFLAG_A64(env->hflags, VL) + 1; +} + static inline bool bswap_code(bool sctlr_b) { #ifdef CONFIG_USER_ONLY diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c index 7de4c96eb9d..7da0e36c6d4 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -315,7 +315,7 @@ static int target_restore_sigframe(CPUARMState *env, =20 case TARGET_SVE_MAGIC: if (cpu_isar_feature(aa64_sve, env_archcpu(env))) { - vq =3D (env->vfp.zcr_el[1] & 0xf) + 1; + vq =3D sve_vq(env); sve_size =3D QEMU_ALIGN_UP(TARGET_SVE_SIG_CONTEXT_SIZE(vq)= , 16); if (!sve && size =3D=3D sve_size) { sve =3D (struct target_sve_context *)ctx; @@ -434,7 +434,7 @@ static void target_setup_frame(int usig, struct target_= sigaction *ka, =20 /* SVE state needs saving only if it exists. */ if (cpu_isar_feature(aa64_sve, env_archcpu(env))) { - vq =3D (env->vfp.zcr_el[1] & 0xf) + 1; + vq =3D sve_vq(env); sve_size =3D QEMU_ALIGN_UP(TARGET_SVE_SIG_CONTEXT_SIZE(vq), 16); sve_ofs =3D alloc_sigframe_space(sve_size, &layout); } --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654769952; cv=none; d=zohomail.com; s=zohoarc; b=deLP77Hc78spZjg5uDFh6czg8aesCfgInD05NkPyH8vDHvFmxXsp3naS1pWmDW8LPoRzUgMHxIy4IbUErtor+lp4petdcQi4sQ1COwmNIlhuSWm9Z/szUCZ5qQrQj4BJQpF7di/IzlYFsSv3XM7jFKIXGlxpOVr9eX7Nw25Ds1E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654769952; 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=kIvAW33Xnjg8FxQHlUQZrjhFZhed2xMGpf7iSMt46Cs=; b=WySQhArOhjgjDZI0eAHgN8lMPPdUiIPQC3UGpWM0ukpb0Xoz40TQ2BEJrhPxUYOQ79RtBBbzEB+aKzlvr0jkaRcv76VO9p4UebvhdxTBXeqORQvsrfSXiqgk/5so3yGP4jcYQli3RtKvEtxeviUhIn9WteavOnnnKjhkKTuBnZ4= 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 1654769952661757.0686867919588; Thu, 9 Jun 2022 03:19:12 -0700 (PDT) Received: from localhost ([::1]:38862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFFv-0003ar-3z for importer@patchew.org; Thu, 09 Jun 2022 06:19:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39848) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7V-0001cT-U4 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:26 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:40585) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7T-00066W-Dy for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:25 -0400 Received: by mail-wr1-x42d.google.com with SMTP id k16so31480008wrg.7 for ; Thu, 09 Jun 2022 02:06:22 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=kIvAW33Xnjg8FxQHlUQZrjhFZhed2xMGpf7iSMt46Cs=; b=Tfv6rHlgIQ/2qLYdA8pWVP7TGSU4nNZVGiLLKJSm9BEFY4fTJg2KLdNJ0bYdriMPt9 Lg6DO5vuD7SmOw83Pg+urgl7Z6bVayOkOIk8wt0LxFYG6mwXNj2Z69OTtkxF8r0boihL qeysuxJShUZq2lKLkbHTL8qMnSGv7qL+tgvUZPjVezdE1GyGT5PFk7Cwv4tNNG8VWsW5 HTwEM/+VlbYRoZbGTpZYWr40b9gW57czGf02C7Aecezd5euPvhGHDPDJEBQqjCmXDVPz Qgl9MixPO0rhrCvRcY0+bfE22EfNFpJKrFsAWAGx5gXrTVZ/7rqWdVS0mt2YZsdq2iVr YjyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kIvAW33Xnjg8FxQHlUQZrjhFZhed2xMGpf7iSMt46Cs=; b=VL0/XBE0VkT7k1wdb8GSgNCFyqT82/JIrkOh4mJm1euDJyw9pylAmN1NSQpiJ232EK l1M5trT11ladn5eF9v6ZrR1Ffvd8WS6wO26fbvbj530I41vvyajf1gnpbjfbjExOIvGH RC7/jNt44aL/okNMTir0dsCTkPdQcTuQGxKl0t/tubIyV1hkmIA3fI1Axkm8G0dPeCJj f62NjcCqGgSkehcgigKhmlUknJgxJvIh2P5cH7H9b1THHnTQn7U9j+FZnPXFwztOCNBP zhQ5dk8vJmR4ycxfDUjDfEJMN2BnvKOxyZZSkhCCz+KKjnhJJt20jxZnyN4BPMo4wOE9 jpig== X-Gm-Message-State: AOAM533ocCqU7tpvdSZfy+C1ZnRITn/XJF7Vz6up/yiEN1rA3mTHHIMF 5lDWg+4wOt+KL4Hb3tdlU4CFfG+6PxZXSw== X-Google-Smtp-Source: ABdhPJx3CIh2KjQEjjFunJFfwehGEGpKoWzpLyQoOu62Yr5k2gQPiwvbbKTaouPKARoDU4Twq8AB4Q== X-Received: by 2002:a5d:6945:0:b0:211:7de7:7247 with SMTP id r5-20020a5d6945000000b002117de77247mr37017126wrw.169.1654765581358; Thu, 09 Jun 2022 02:06:21 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 38/55] target/arm: Remove route_to_el2 check from sve_exception_el Date: Thu, 9 Jun 2022 10:05:20 +0100 Message-Id: <20220609090537.1971756-39-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654769954729100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson We handle this routing in raise_exception. Promoting the value early means that we can't directly compare FPEXC_EL and SVEEXC_EL. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-4-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index c228deca755..1bd77af7e50 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6149,8 +6149,7 @@ int sve_exception_el(CPUARMState *env, int el) /* fall through */ case 0: case 2: - /* route_to_el2 */ - return hcr_el2 & HCR_TGE ? 2 : 1; + return 1; } =20 /* Check CPACR.FPEN. */ --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654768342; cv=none; d=zohomail.com; s=zohoarc; b=YwuSPSQ7RTwOwtN4Jd+VOKRfTsogmuuw/4BPG9ZHI71fde27VHXY0hrIrHkvwmX8jBlPmfQwyTgJU/9fehyUVDRhaWRPs0u/XXM39UzrEwedYI+f5U+bqEikedpIqEeT7rRDNkvunbUeVT2Ux4eeMEHzbzQhfbykPjq3YE78gHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654768342; 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=biefxwiMWkFplUNyCYS3rTOiD6++qV4YkTvNGi9PTWE=; b=EQI5NOsqV5wueXVVWAmaycEbdQYDrXTfUSiPgw9rU3Y1w7JxnfaZgoETRHQ8GBB/88QAVEwpbfSJO7g+t53Xga72t5sBL+gqWfVwWsebFUZ9XE+eSIenGOatorjCGviuXCUUwmxnihPlg46ivQNibtIaejoI1Wb4Tb36D6/rUCc= 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 1654768342606654.902438742862; Thu, 9 Jun 2022 02:52:22 -0700 (PDT) Received: from localhost ([::1]:35260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzEpw-0005JO-Vz for importer@patchew.org; Thu, 09 Jun 2022 05:52:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7V-0001cB-S1 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:26 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:43557) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7T-00062u-40 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:24 -0400 Received: by mail-wr1-x42e.google.com with SMTP id d14so22478158wra.10 for ; Thu, 09 Jun 2022 02:06:22 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=biefxwiMWkFplUNyCYS3rTOiD6++qV4YkTvNGi9PTWE=; b=CImkj7CcSzsMXUFeUgr4OgjlVtoTEaUrxxXD1UxdxuMTBDPNY7KSZC9J2nQWZBpt2k AyCywy2PkhKYOMmNXD4p+bbpHrTAiMbc0Uus7iSejXEQKXJh86oLwi3owSaQcKM/ZViW abc8KSlz7HB/POQDmTkRlEYGZ33reKuv6bhKHWSgS3WOFoFP7dyEKc9ff/V9xmh1X8D0 r3fonp6SyqK10HTOuhTNTritWpI02Rl6ihch2CEQ15YaRjrjIoFWC0wQAkaKpdVeghOF aw6dkMN6m9oLNE/I8Tyku9Szvsgg+jAmORHnOYDkpz0yRQXe159Xl8rp13yxCF+fnN5r CXcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=biefxwiMWkFplUNyCYS3rTOiD6++qV4YkTvNGi9PTWE=; b=qRSejLiOANJZNK/BxElUlyufP9EvXeSojt26AFDoZlsQ5XEQB9hh/Z0kFK52czHKZ8 MbJZ32J17zotJg5yND+9GQxRsWH4qtzAMgfin2WylOENKjYgC1BjXDDMXpT1ub3fjTq2 dfivAbPXcNDosSl//xTBTt0DPlMvIejz6MtaWpzBU1O6B1weh5B1yMro3FfTWiKjPQ12 ELiGdUC0Er0G+7DvGlmLUlN0sD0ik0/flPp3/9o47npwr5RWMFd5Extl5HaUB8fXUG7Y 907S93EX7dWhp/o4qIT5Y+vQD9gOHSOuYBv3XtxJ+ayZ3F4gvxVrPKrKxdKs4OANOXAj /HUw== X-Gm-Message-State: AOAM532twcXasMADxcQPrMO2mH3vQXxKNHacxrKSzTsoCUZoYeGKTCrG Li4eINAxyV1qNQNjd9w8NQpnYZSI1irlJg== X-Google-Smtp-Source: ABdhPJzHbC1ruV0FObJphmwh3QEAiJmtcR/l1A3fxtESRWeu9RJp5mi9pJFbNVIkwqMYb+917mk6VA== X-Received: by 2002:a05:6000:152:b0:216:160:2e60 with SMTP id r18-20020a056000015200b0021601602e60mr27315852wrx.663.1654765582316; Thu, 09 Jun 2022 02:06:22 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 39/55] target/arm: Remove fp checks from sve_exception_el Date: Thu, 9 Jun 2022 10:05:21 +0100 Message-Id: <20220609090537.1971756-40-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654768343657100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Instead of checking these bits in fp_exception_el and also in sve_exception_el, document that we must compare the results. The only place where we have not already checked that FP EL is zero is in rebuild_hflags_a64. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-5-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.c | 58 +++++++++++++++------------------------------ 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 1bd77af7e50..4f4044c688d 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6129,11 +6129,15 @@ static const ARMCPRegInfo minimal_ras_reginfo[] =3D= { .access =3D PL2_RW, .fieldoffset =3D offsetof(CPUARMState, cp15.vses= r_el2) }, }; =20 -/* Return the exception level to which exceptions should be taken - * via SVEAccessTrap. If an exception should be routed through - * AArch64.AdvSIMDFPAccessTrap, return 0; fp_exception_el should - * take care of raising that exception. - * C.f. the ARM pseudocode function CheckSVEEnabled. +/* + * Return the exception level to which exceptions should be taken + * via SVEAccessTrap. This excludes the check for whether the exception + * should be routed through AArch64.AdvSIMDFPAccessTrap. That can easily + * be found by testing 0 < fp_exception_el < sve_exception_el. + * + * C.f. the ARM pseudocode function CheckSVEEnabled. Note that the + * pseudocode does *not* separate out the FP trap checks, but has them + * all in one function. */ int sve_exception_el(CPUARMState *env, int el) { @@ -6151,18 +6155,6 @@ int sve_exception_el(CPUARMState *env, int el) case 2: return 1; } - - /* Check CPACR.FPEN. */ - switch (FIELD_EX64(env->cp15.cpacr_el1, CPACR_EL1, FPEN)) { - case 1: - if (el !=3D 0) { - break; - } - /* fall through */ - case 0: - case 2: - return 0; - } } =20 /* @@ -6180,24 +6172,10 @@ int sve_exception_el(CPUARMState *env, int el) case 2: return 2; } - - switch (FIELD_EX32(env->cp15.cptr_el[2], CPTR_EL2, FPEN)) { - case 1: - if (el =3D=3D 2 || !(hcr_el2 & HCR_TGE)) { - break; - } - /* fall through */ - case 0: - case 2: - return 0; - } } else if (arm_is_el2_enabled(env)) { if (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, TZ)) { return 2; } - if (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, TFP)) { - return 0; - } } } =20 @@ -11168,19 +11146,21 @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMSta= te *env, int el, int fp_el, =20 if (cpu_isar_feature(aa64_sve, env_archcpu(env))) { int sve_el =3D sve_exception_el(env, el); - uint32_t zcr_len; =20 /* - * If SVE is disabled, but FP is enabled, - * then the effective len is 0. + * If either FP or SVE are disabled, translator does not need len. + * If SVE EL > FP EL, FP exception has precedence, and translator + * does not need SVE EL. Save potential re-translations by forcing + * the unneeded data to zero. */ - if (sve_el !=3D 0 && fp_el =3D=3D 0) { - zcr_len =3D 0; - } else { - zcr_len =3D sve_zcr_len_for_el(env, el); + if (fp_el !=3D 0) { + if (sve_el > fp_el) { + sve_el =3D 0; + } + } else if (sve_el =3D=3D 0) { + DP_TBFLAG_A64(flags, VL, sve_zcr_len_for_el(env, el)); } DP_TBFLAG_A64(flags, SVEEXC_EL, sve_el); - DP_TBFLAG_A64(flags, VL, zcr_len); } =20 sctlr =3D regime_sctlr(env, stage1); --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654772308; cv=none; d=zohomail.com; s=zohoarc; b=LFu6HPTNHKd9YodPwOKkQ6gItdE2VwxRIDNHznvbFEeNV88jMUw7WnyAPtZpsP6/C5OT1FlDXF/TILoiVR7FEPIDv2IYThEAd7NHLaQli86AGXuALTwEntzWqbhX4tyvLhIVQXyGaW4d2E0C2EmN4bIdgJiMxoNMeKcTYwj8qg4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654772308; 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=OrRqWRQp9nOhwyO9OA3TSRIbMZMtkcOgDSH8VMFZG2E=; b=MRp+mlCwYFktdpPx3dyyC3ak4kEvSVMqckFkke7qv5CPdSa7BGOzYt6DD3INagwC795p3HhOkFZuSIITb12gL3oX+g57/vup1lVlHD7oVfcF1pxF52snJV4LjSwNQS4l54t1qNHlvwxARUafXlYP/UeFcfa+ltSK+5Cjt/kCo2s= 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 1654772308629115.4920935442002; Thu, 9 Jun 2022 03:58:28 -0700 (PDT) Received: from localhost ([::1]:50852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFrv-0000M6-3C for importer@patchew.org; Thu, 09 Jun 2022 06:58:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7j-0001oY-Qd for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:40 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:51890) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7U-000638-17 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:39 -0400 Received: by mail-wm1-x331.google.com with SMTP id z17so7275188wmi.1 for ; Thu, 09 Jun 2022 02:06:23 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=OrRqWRQp9nOhwyO9OA3TSRIbMZMtkcOgDSH8VMFZG2E=; b=SxV8Gfp4Wp7VVIZr1yL5BVHOPT6Ya4UDxFBBrDHQugd19quJmIS0Vpk4f5+KRahsix gW2p/+C2ywCZzUVbx2+K07xciYAujlijQwd30zlw4jDZkkmqDq1yrfvRvddB1g2YB8uz L9NKIxGZ1pyz54Y9J3RSOVVDhy73KUu+QI+bLikJ7bx1d9BQPTNBIuWVwnQVEgSXJxYM 64IdaARQw0MPXKkz9+f7yoTm1oZekOxq0st5KIP39QM+CHXeP9uqtEr4AB3NRbQGwuZ5 c08vT8h4x0DpWdmJsHhS/Bc+CSOK0fjFKz5Ru7dOP8pbwt9amTK+L6yS4pSNYr/nSW1t 2xLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OrRqWRQp9nOhwyO9OA3TSRIbMZMtkcOgDSH8VMFZG2E=; b=nlF981IbsNvQ+UCxwF688XjqQuqoDq96lzw0EvlVpCYEfc29djuWDSIFm/YfJkPYQX hl0TWj/i7mG0iV/HGzrdQe4LWqZbDhnHpfVUp/RqdO6r00gDAJv9b4jtX85I7wWV6mEv 0RGgfvKWJMvt4R5FegGn2I+AfVMe8BDiATEb0W2FBgr5znwzQS+n8n5xLHEZ2BI1K0rb FSwhN2UyCIAY0ncAkuGVRyOs9+IQEkV13EN7v2+3gJC+/2tt2IOjVsr/Q5TVNJmn11o5 LmzcC8pwlXATWz5+PXTCFGw1adbxdzrImTLFW+hDKy2ryiInltN74up4n7o2ZV0Uwv3b AaMg== X-Gm-Message-State: AOAM532GY1JrEhBs3aVPWUTY/s9YzSkXFZq9QNpo8/KDuQ+tjIWFWhpP N1kbQIgMHUST2APNYfxPUMo1Gifu5Ilwjw== X-Google-Smtp-Source: ABdhPJwBlrpQkFdcSqO4Y9kyjrZDqA8FxG9KL6L3pQuKxKScmEQH/bHrbYQP161+lOfhX7mr/j4yRg== X-Received: by 2002:a05:600c:3845:b0:39c:6ea9:ed34 with SMTP id s5-20020a05600c384500b0039c6ea9ed34mr1403163wmr.175.1654765583187; Thu, 09 Jun 2022 02:06:23 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 40/55] target/arm: Add el_is_in_host Date: Thu, 9 Jun 2022 10:05:22 +0100 Message-Id: <20220609090537.1971756-41-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654772309027100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson This (newish) ARM pseudocode function is easier to work with than open-coded tests for HCR_E2H etc. Use of the function will be staged into the code base in parts. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-6-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/internals.h | 2 ++ target/arm/helper.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/target/arm/internals.h b/target/arm/internals.h index 1d83146d565..ceaddcbfd6e 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1347,6 +1347,8 @@ static inline void define_cortex_a72_a57_a53_cp_regin= fo(ARMCPU *cpu) { } void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu); #endif =20 +bool el_is_in_host(CPUARMState *env, int el); + void aa32_max_features(ARMCPU *cpu); =20 #endif diff --git a/target/arm/helper.c b/target/arm/helper.c index 4f4044c688d..322508170e3 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5282,6 +5282,34 @@ uint64_t arm_hcr_el2_eff(CPUARMState *env) return ret; } =20 +/* + * Corresponds to ARM pseudocode function ELIsInHost(). + */ +bool el_is_in_host(CPUARMState *env, int el) +{ + uint64_t mask; + + /* + * Since we only care about E2H and TGE, we can skip arm_hcr_el2_eff(). + * Perform the simplest bit tests first, and validate EL2 afterward. + */ + if (el & 1) { + return false; /* EL1 or EL3 */ + } + + /* + * Note that hcr_write() checks isar_feature_aa64_vh(), + * aka HaveVirtHostExt(), in allowing HCR_E2H to be set. + */ + mask =3D el ? HCR_E2H : HCR_E2H | HCR_TGE; + if ((env->cp15.hcr_el2 & mask) !=3D mask) { + return false; + } + + /* TGE and/or E2H set: double check those bits are currently legal. */ + return arm_is_el2_enabled(env) && arm_el_is_aa64(env, 2); +} + static void hcrx_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654775226; cv=none; d=zohomail.com; s=zohoarc; b=fW4lFXLHjEnyq16lx13+Oqx5qFE3riiTOshmHzzzNbQlJuK3YgTJQX5J181pM5JBQbuw/caN+f7XvvxXuEPMF2JSZWsUOnzfo4ZU0eXQWX5piQE8Z2OU8qEMssT5EaU5GVVZR6IomQijDKmXmvjHnAor5L+pnuHEM/iDnOAUpns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654775226; 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=lq+u7f2f7YE5vmdKlLixcNnaKlj2/xU4nnWKz5bhpYE=; b=MrZDtjwTCietpYyAgmqZD1Pr6ybXS3o2kcCU3wHlU+kTTMLohHJIDrobaW2LaIouFaOTsGFpm6QsdJ4EPRVO0y34rk7BGH8SLthaaxigo6YlsydNcHJ1cP47bsN8oyvrPJZ1tuzvI1LtVWLUdIKWUAIyLlWgNLbU761JVLkgR7o= 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 1654775226561860.2612468605802; Thu, 9 Jun 2022 04:47:06 -0700 (PDT) Received: from localhost ([::1]:36128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzGcy-0000Na-WF for importer@patchew.org; Thu, 09 Jun 2022 07:47:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7W-0001cl-Q9 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:28 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:53919) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7V-00067I-Ao for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:26 -0400 Received: by mail-wm1-x331.google.com with SMTP id z9so5330339wmf.3 for ; Thu, 09 Jun 2022 02:06:24 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=lq+u7f2f7YE5vmdKlLixcNnaKlj2/xU4nnWKz5bhpYE=; b=MUrD7RXva30XHSMxqFTV9lc8x1KlHVijSZRf+PibyhYch/MRfG/ERrlbrAMa5K7Lbi Zh0hCq8gpwkTmWCCAEoIwIa/YBKI+MJsBSdTRikbaHwPDzOHrSci16Y27NIGCezsFy17 1lDwisM/ONvYtEi0W+U6a4Y2FxskNC1W5x5DaHm1u1AFO3WSeqjYNxIjWoWulRmdwoXc U7axr4SlRTm0QDriWRDmArFhMgsXjN5hCxhyIatTPpERVJo68ecmxRtH373ThXDxLM/+ xS6UMNisK67Tsm07sZkl+t5muA0hOT2q8Y9L9oRDBEcCsr1ngmMVPZbIj6k4D0+2RSB+ BgVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lq+u7f2f7YE5vmdKlLixcNnaKlj2/xU4nnWKz5bhpYE=; b=1Gneaqf0TGKtLDPRQIEPtsTrtedTTu6DjzUILgmn8QsQix8vg/kgNqnnMFJQ29H9/W 1vjD54e2jovsTiKfbLcuQzP2chLBFIqmL56VAzMiPqLyjQI86bqGW/s6wM29H7zmRkru +cU4KNpnS6CXOYY92dTI8I2XrwCuqU3bqvrVryR04RGLYbiurPOrdTNW5DrxidhiuvDW QsVoiy5JxFZzrd2Jlc/6Btd8SvqeHjvQcKILHhR6dGM46BLy5l4XBg5iHx6NPrRtnjd/ JNCLVAtgGTVNpiI8HhPywjbyv7tLyT8ZWPaBQPnf+/LzJEccRhGsQ9ZkMBK1KVFZCSL7 AWVQ== X-Gm-Message-State: AOAM530gua54tczfeA2qlyqeoH9hSSzm7uPt5EN+Ru2IqpP1IUjcRY43 TO5/5dZm1KcAbgrYVpO+JfvH1iGY82n3aQ== X-Google-Smtp-Source: ABdhPJxQ17r9VyzK3KbQyjLZWjSci/tpSPqH0J+HQXEcG3gDFo+qef0lJRGFgwkiR1CGoz6NRwCsNQ== X-Received: by 2002:a05:600c:a42:b0:393:d831:bf05 with SMTP id c2-20020a05600c0a4200b00393d831bf05mr2190206wmq.187.1654765583991; Thu, 09 Jun 2022 02:06:23 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 41/55] target/arm: Use el_is_in_host for sve_zcr_len_for_el Date: Thu, 9 Jun 2022 10:05:23 +0100 Message-Id: <20220609090537.1971756-42-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654775228013100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson The ARM pseudocode function NVL uses this predicate now, and I think it's a bit clearer. Simplify the pseudocode condition by noting that IsInHost is always false for EL1. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-7-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 322508170e3..6b17c0f507f 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6238,8 +6238,7 @@ uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) ARMCPU *cpu =3D env_archcpu(env); uint32_t zcr_len =3D cpu->sve_max_vq - 1; =20 - if (el <=3D 1 && - (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) !=3D (HCR_E2H | HCR_T= GE)) { + if (el <=3D 1 && !el_is_in_host(env, el)) { zcr_len =3D MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[1]); } if (el <=3D 2 && arm_feature(env, ARM_FEATURE_EL2)) { --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654775743; cv=none; d=zohomail.com; s=zohoarc; b=EIrkronL14FEokUYjqMOWP2KxeEuigyj8u4WBh9ETTQZLO1/OG7NjInUU5UayfiZgYue9n5TYk0xErbMTQFvpMPN9Jfpk9G+mWAZKVrWmudFlOwT/Ci3+Z0uDoVylEwp6+SZheGXBkfzmIffWWyg97M0mAq2pAbBHrWIVPWnEa4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654775743; 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=tECKDbH/4mwcOqBc4mXupaexcp4butR2eX7BFSU01YQ=; b=e4oXdlQ8iwg4jKXWTc65xhDBzwQg/OGMMH4F0HfK43XPgN+tN/T2GahlMD9wX/nfvVhan6lBfkSCAA6sLotyFsYt6HlLNjNFzBvZ07AEqrJGYsxwDZNVthYrr+3T9fRotmbx0gBG2IdkgIvcC8CL24fzfqqf/ExWeeVWoeRb/nw= 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 16547757429821011.9421578425313; Thu, 9 Jun 2022 04:55:42 -0700 (PDT) Received: from localhost ([::1]:44772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzGlJ-0006rq-56 for importer@patchew.org; Thu, 09 Jun 2022 07:55:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7X-0001d7-TT for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:28 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:34251) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7W-00067c-98 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:27 -0400 Received: by mail-wm1-x332.google.com with SMTP id p6-20020a05600c1d8600b0039c630b8d96so432920wms.1 for ; Thu, 09 Jun 2022 02:06:25 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=tECKDbH/4mwcOqBc4mXupaexcp4butR2eX7BFSU01YQ=; b=mTxweZhmwelgUUrFdCBV+SagYHBM8i4WTuasMM088/5EVcGSTkyBfhyKnikeGxOG5e UcWljrSt/086LLSCVRM6WmJqGzO+VrGvDqTC5AfSDiKQrET5aqtk7JtOpHqpfp/jXI0h FHzhhdHk1wuNx5UCr7zHFTvTs+QzB6+yc6QMNnfj/D6Aulu017huSaBKRI6VDyaGKMoq gTZRu3mnWse40o5ZkEOA8yYJAl4cwPwl6xRqcvWbr+G5HSWjYcPyWwtA73rNeTkCVaMY /WiErQbLBNgGmWNYrTuCnSgdhB5UJ+vNStObQlJqGV+fwtYUF+0whTc/KeIiFKupUl3e Gmzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tECKDbH/4mwcOqBc4mXupaexcp4butR2eX7BFSU01YQ=; b=scDD3HchEvW4aKE444YvGKq8YebopU2fa980I7DfnfgKGakIntp0VhOeTKd9iyuMPS rLMQRzTHH7sGcTp5nymdZ6XA0Ck6uQApRcqRLoxvBEA4en0LbS1gp4qS7SQmjLNc705S asOK6vhzwqojS60SNJSt0LdI5u9c62gTNxfg24615GEj/X/q6R3z5Xno0OWuPTvOpbO8 C0HyqKaXxnCT7acgbBGimpqrgxkYWxVGZGiV5z5pJr7/M1EpDhy666a+tRRbJQPRSPUO LZtbsCgRRhoyJGmkFrDL1J3zMQ/7EIyEKEBpxwr/22QKg2OKYFJ1zFhoTj8aBPXYD76v yDFQ== X-Gm-Message-State: AOAM532CmSvuNnd+znAxiCRlNbqTyb2TsCb1NBSZIyK5nzgEN7f9R5rh 8moV+EGpbfpjYx7lwLYA6dFJGoPvD7JZTg== X-Google-Smtp-Source: ABdhPJz1RA7TOHTMcX7TfvwriU+nWrbuVs4gZ+8r1No7+FP9hKjqkhrRLqWUlistYpcEKtGYEOr5wA== X-Received: by 2002:a7b:c31a:0:b0:39c:4783:385e with SMTP id k26-20020a7bc31a000000b0039c4783385emr2248879wmj.185.1654765584789; Thu, 09 Jun 2022 02:06:24 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 42/55] target/arm: Use el_is_in_host for sve_exception_el Date: Thu, 9 Jun 2022 10:05:24 +0100 Message-Id: <20220609090537.1971756-43-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654775744376100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson The ARM pseudocode function CheckNormalSVEEnabled uses this predicate now, and I think it's a bit clearer. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-8-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 6b17c0f507f..40b60b1eea2 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6170,9 +6170,7 @@ static const ARMCPRegInfo minimal_ras_reginfo[] =3D { int sve_exception_el(CPUARMState *env, int el) { #ifndef CONFIG_USER_ONLY - uint64_t hcr_el2 =3D arm_hcr_el2_eff(env); - - if (el <=3D 1 && (hcr_el2 & (HCR_E2H | HCR_TGE)) !=3D (HCR_E2H | HCR_T= GE)) { + if (el <=3D 1 && !el_is_in_host(env, el)) { switch (FIELD_EX64(env->cp15.cpacr_el1, CPACR_EL1, ZEN)) { case 1: if (el !=3D 0) { @@ -6189,6 +6187,7 @@ int sve_exception_el(CPUARMState *env, int el) * CPTR_EL2 changes format with HCR_EL2.E2H (regardless of TGE). */ if (el <=3D 2) { + uint64_t hcr_el2 =3D arm_hcr_el2_eff(env); if (hcr_el2 & HCR_E2H) { switch (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, ZEN)) { case 1: --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654771074; cv=none; d=zohomail.com; s=zohoarc; b=dNqYsjDS/XKlHXc1O8ED74nLqjPAKM9P5V7gORU4XofDAn79ISoAnRJEMyocxQyngIgat8ME8ni7IB7UBXvgBy9nJW1QwTvVRufureklK0zDMjDgkoFLg58OY//cO8I+tsEpyiBQ7yyunogN67kU5ONuRbjS8vNzym6axqH7BSg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654771074; 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=mf8AdCDhGe88lxvbihB81XSJ6frI4E36LSXViphWNvA=; b=dnzSp7faGXY/vFRZe+V8pTi/jdtisInUgHjljX6S08WgMi3dtOuSCADy673n/eLHYVMJC1MwA3at24ihRwywHS9EBmsma8nNG53WrIxJt1y0bCAn9HgzsgAfJWSY8jMU5on1bSWM1mrtwjqMxn+sHTXdADtfKf3NpKokldV6Vpg= 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 1654771074101743.0709156076205; Thu, 9 Jun 2022 03:37:54 -0700 (PDT) Received: from localhost ([::1]:50288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFY1-0004LO-1P for importer@patchew.org; Thu, 09 Jun 2022 06:37:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7Y-0001d9-4O for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:28 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:36485) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7W-00062j-Lu for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:27 -0400 Received: by mail-wr1-x431.google.com with SMTP id o8so3625311wro.3 for ; Thu, 09 Jun 2022 02:06:26 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=mf8AdCDhGe88lxvbihB81XSJ6frI4E36LSXViphWNvA=; b=fhkawx0VuNJ92c0NYT4sqHx/3AXzhkL7Hbw0A1MglNgQ8isWqSEmJhaINdD6x7rub5 mOj+N9+CgBavt8uNwB9c8hvRJhosjKKpx59/M8HPwCmWFlpnSMEveEH+Gkm4YznUOTVl gDmJ9YLUcsGjeTnW/Dx420CvYgOKuozhI1nFzhsHRmhJyWJDj4JKfcAnmksAJN4pGvk+ e7E6DqGd5y3Y9BOzszfcduHFTes1YOI3PsGWBAdPoSNziupslK00tC2RCd01Nnr7t95N 9s1wiAmNY+epPeUyQOGr5TxYnkrL+319uGtTnfz8u5+QdGDriy0XhyF31zkCgeUI6coz dEwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mf8AdCDhGe88lxvbihB81XSJ6frI4E36LSXViphWNvA=; b=HTpt/jVwCtUhQuKdQ+mpKa8QLTwhMCzbjjWMZ4K/TNuotydz7cOsr5bJlqnilE4dfz 0O3KwfNViTB3ztEWmnRguq37fp1HwihtSUf4x9klf+ga1Bx+cxDMpuc3rzoic0eLb8dt 4R6H50cv2lo3IjlzpCFfBVz/l6QrxB+Aej6cn0eZAU03ArsFZ3Nx03s8XAdc4bjKSxOX LUg+3W4dyA0OjCEpextdxyscTLcwznRzbtG/XTIGc/bcKOWyos1IVpdVmm0MbLOSwG4K yaNXDdJQ2W/t0ZbqgRytY3Nb4kBIOIXv26Lhg01Gd7amG9+Z/HN1XwR5JVSihe0v2k2o haSw== X-Gm-Message-State: AOAM5313zIwUxqb6g5yxg4S6kif9rQu9q8zM7lEDijooRwh+kkkkns19 J8SpkckTnSdbQGDaRWN/LZYKZ9cs5vhV6A== X-Google-Smtp-Source: ABdhPJxwx8+jezwyFCFrMbGIWNavaWtdRE7WKR4UxnujdsVZd8k36O8fWjAFngC4X/gHs+EI+vzdPg== X-Received: by 2002:a5d:4344:0:b0:20c:cad4:9e9b with SMTP id u4-20020a5d4344000000b0020ccad49e9bmr36843473wrr.187.1654765585953; Thu, 09 Jun 2022 02:06:25 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 43/55] target/arm: Hoist arm_is_el2_enabled check in sve_exception_el Date: Thu, 9 Jun 2022 10:05:25 +0100 Message-Id: <20220609090537.1971756-44-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::431; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x431.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654771074943100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson This check is buried within arm_hcr_el2_eff(), but since we have to have the explicit check for CPTR_EL2.TZ, we might as well just check it once at the beginning of the block. Once this is done, we can test HCR_EL2.{E2H,TGE} directly, rather than going through arm_hcr_el2_eff(). Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-9-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 40b60b1eea2..61e8026d0e3 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6183,15 +6183,12 @@ int sve_exception_el(CPUARMState *env, int el) } } =20 - /* - * CPTR_EL2 changes format with HCR_EL2.E2H (regardless of TGE). - */ - if (el <=3D 2) { - uint64_t hcr_el2 =3D arm_hcr_el2_eff(env); - if (hcr_el2 & HCR_E2H) { + if (el <=3D 2 && arm_is_el2_enabled(env)) { + /* CPTR_EL2 changes format with HCR_EL2.E2H (regardless of TGE). */ + if (env->cp15.hcr_el2 & HCR_E2H) { switch (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, ZEN)) { case 1: - if (el !=3D 0 || !(hcr_el2 & HCR_TGE)) { + if (el !=3D 0 || !(env->cp15.hcr_el2 & HCR_TGE)) { break; } /* fall through */ @@ -6199,7 +6196,7 @@ int sve_exception_el(CPUARMState *env, int el) case 2: return 2; } - } else if (arm_is_el2_enabled(env)) { + } else { if (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, TZ)) { return 2; } --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654769197; cv=none; d=zohomail.com; s=zohoarc; b=Y/gWz5rQLN8TUijhVs/pMNWu5SHBnSBuRi5bUlLHprvcmyx4DU5yIN4JCaJzOxOk3J/EWii0b5ySDXkhlZpxTl1ywom1sfLkI4kz0daBi6F00/N7XtnfDM3RX2kamhmE6oJfaZ7q4yJlA2cFqVwqHz0wr4oMZjiszcm8iuVR7zg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654769197; 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=1m/UJxXLmktUI528IS17AqpDYaE8Ds5euhmbpvoO2wI=; b=Uv9mCz2CIYVP/yhqs0ANwGsbWSwk/Gs1LXT6jLBCc9kXSdKiz0a8+tApy0aZ7lDpLR9e8QLmRZK3cMlabpWoO8F178n020zdxC9pOBjvoCdCD8ajsBsLgF0sG5EV2aDt31EOCxE3jGpSQZYxPDNd+IewC8lm9q4JgIom8IrqtZk= 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 1654769196985813.5315538500482; Thu, 9 Jun 2022 03:06:36 -0700 (PDT) Received: from localhost ([::1]:53844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzF3j-0002It-Fr for importer@patchew.org; Thu, 09 Jun 2022 06:06:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7Z-0001e8-IM for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:29 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:55140) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7Y-000687-4S for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:29 -0400 Received: by mail-wm1-x329.google.com with SMTP id n185so12106857wmn.4 for ; Thu, 09 Jun 2022 02:06:27 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=1m/UJxXLmktUI528IS17AqpDYaE8Ds5euhmbpvoO2wI=; b=xQFAqMwdkDeVs1JZLigxCqno2jD16chXRNKDQigIDXF6X461NKYq5Z3DGy25jEnNKt y0t4LtaR0+VtOLKAMfdT0QPfDou1vzp4opggtlMi0Pe0o4BUTmdlR5eYd1ojm4m+6zs+ DCGbilr2gd6Izkawl4sMdM29qU4XNsk8QMcsOXoAPc4NG3ZzYeSsE/T5Rxs/5dOUMe1k Pz9OYnZPwfeyQuTf+f7QWLZ013YcQBjqrkxrcAh+ORTh+vefQhY36CRwu0n43oQZyn9+ H1QgW4NYqjKeX4i5Hcez4LKTqpMn8pvVeDU8ZwvWEv3ib+0O50H3Ouq0KnUwcTzGExeu UqvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1m/UJxXLmktUI528IS17AqpDYaE8Ds5euhmbpvoO2wI=; b=Skq3+rg9Y4KK9UTG/7hyFzZZYlEvBW/J/fFw5bYVa+HTy0ZvOLzIzXBcB0EWs/jDaE qvJcFY9IEoBwmy82AlYNeFswRzDW/FNCAAEhk+t8cVYFUSlAlLENf8jlbKl4ZCZ5PWDg 1hRIo6DusI/PKE9ClOZS51tM2T7iwZi11Xhg4jg7ukSKkvXI874+eQfjAslnfWVS71+e cQQw+t/f6kfanjl4Gj+FJZ77dtFujJR46KHvVmjYsvxZ1bwnO/kaBDL7g+Iif8UgqfK1 W+vG9sDFEwzGjJM1g+VlvXqjQ7+7W5J5CjNOL6kKMP6ZiXv8wfuZ2PwRYCNmo3aNLw+V zZOA== X-Gm-Message-State: AOAM532K/scpHb2RTS7fX/fRstYlP93XfRD5l3+PjxW/kOjszAOzf/3e lRHRDNZ46GodP2hkdHP2zi/VRfnTv9QtXA== X-Google-Smtp-Source: ABdhPJxKuqJxjTlfIOsU6xbI3MoroA9ijYHpM5iXuRU4UscpNb8fi81fD/PkDkEI1s3WHW3JLRpAYw== X-Received: by 2002:a1c:19c4:0:b0:397:88a6:6 with SMTP id 187-20020a1c19c4000000b0039788a60006mr2265383wmz.138.1654765586789; Thu, 09 Jun 2022 02:06:26 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 44/55] target/arm: Do not use aarch64_sve_zcr_get_valid_len in reset Date: Thu, 9 Jun 2022 10:05:26 +0100 Message-Id: <20220609090537.1971756-45-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654769199284100003 Content-Type: text/plain; charset="utf-8" From: Richard Henderson We don't need to constrain the value set in zcr_el[1], because it will be done by sve_zcr_len_for_el. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-10-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index d2bd74c2ed4..06219441674 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -208,8 +208,7 @@ static void arm_cpu_reset(DeviceState *dev) CPACR_EL1, ZEN, 3); /* with reasonable vector length */ if (cpu_isar_feature(aa64_sve, cpu)) { - env->vfp.zcr_el[1] =3D - aarch64_sve_zcr_get_valid_len(cpu, cpu->sve_default_vq - 1= ); + env->vfp.zcr_el[1] =3D cpu->sve_default_vq - 1; } /* * Enable 48-bit address space (TODO: take reserved_va into accoun= t). --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654769656; cv=none; d=zohomail.com; s=zohoarc; b=eWpo1lcI6UErKdSodAU9CaqN9JLm4xxBQfxxnCAkrBG49dzZjgOWLpc5AYfzU5jQN+LjFpUPrmG+IelDBv+rkJYTdVEO6z0RlZmeCnpKjq6DhcbH/5wjIn4eiYCThW/CkjOED9SmWpbNX9yBNFUhrbaIEGblfJMV232/wSLw0A0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654769656; 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=PRXhDDaF6nWlyfN7Oj+HymEa8eenhGrZqsYAZ8IODjs=; b=a1aCCNEBfPgr0+EIJygQSmCvjozTvfyyhbL0rAsXl/T0V0fe1ZIbGfJPunVoH4Re9NXeqIwtGzLqRz7yoxErEwCCCmqMZIJe5B6PdSxN5oIO1ZCITwrUS8lDVQkobaKiO64ZUrd/e+r2zZweN3WpS5r0HBfpVLY1oga/AZIB/Ls= 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 1654769656402693.8209218827741; Thu, 9 Jun 2022 03:14:16 -0700 (PDT) Received: from localhost ([::1]:33826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFB8-0008Rd-VO for importer@patchew.org; Thu, 09 Jun 2022 06:14:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39928) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7a-0001fC-OE for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:31 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:44678) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7Z-00068P-4T for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:30 -0400 Received: by mail-wm1-x334.google.com with SMTP id m32-20020a05600c3b2000b0039756bb41f2so12273407wms.3 for ; Thu, 09 Jun 2022 02:06:28 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=PRXhDDaF6nWlyfN7Oj+HymEa8eenhGrZqsYAZ8IODjs=; b=fffEUXh/hJhdqrF8+T1jEgSi9J+q5yChQeC/OqTRpmM4N8M+grQe6+yIRPW70ArkSK IwEK336e8n8lRdpWpByvEnqZtY6N982J0rfuF0nmJiQ3OxRN2wwsa4B0X0pEGzBeJ8rr P/jy62ELv96VdWew9N8HeT9zy/RtHx6I8Z93DAa31xigxUts1CpAyCLeJcUk0nLbMKp2 yvnVWxEryN534kZDNgz4tHkZE6UTBT21fOM5QfLWeyiQOndzbXW757doMbiPLO79J+eK sbmHYv51GWjoaUs7JMOBo2GkADQuJlh2HzaCNGVA/mVOYGwWRy29ug9ZsfyZHyUi0orE 5/0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PRXhDDaF6nWlyfN7Oj+HymEa8eenhGrZqsYAZ8IODjs=; b=m/Gjxvi0Zl18af9NTiyBipL/haC/NN2q83j+VP1M/9hhmHREFZtriYQXPH47ussaXT 7Q0evKiI6VOG+ytRkTMu9Ssv1euVOydLizCqzaB4+VPgzZR8GpsdJfVpGM9Xexk4z13t tSLaf3QEnu+BZiVI6P2Vsk7nbuq/5PXIFLCLdNB2lq2XVDoZZitPlVIhO+LWJfjXY9ZQ vLZXmJkfKB5YmSoz9YEkGOD1uQ46p+3uTpx5d/w0vJvY3W2ZdsI0gKyLW5TuAEdN9+VY F4wqJMIJ+MgjnrSc4SgO8ulXL4Jwh1L/pgQ+QHR+d6Mf52NBzL0bopQzy/ZRIo+XdDxQ cOSA== X-Gm-Message-State: AOAM5328pEs5wIYPZcCzhPFw3hWI6ivJi13Fhj9uBUokEETUenE7j4br fqp3H8FVmy2hF+fG+mT6vhIh+hPwvjt/ng== X-Google-Smtp-Source: ABdhPJxbCqo1zXudXQ4p1HZNo+SegygV99HBriVtzoyf8cb9RibpYpoHAA0+lOV2XSCSr8dXWni4xA== X-Received: by 2002:a7b:ce8c:0:b0:39c:5bf4:abc0 with SMTP id q12-20020a7bce8c000000b0039c5bf4abc0mr2225808wmj.135.1654765587745; Thu, 09 Jun 2022 02:06:27 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 45/55] target/arm: Merge aarch64_sve_zcr_get_valid_len into caller Date: Thu, 9 Jun 2022 10:05:27 +0100 Message-Id: <20220609090537.1971756-46-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654769658117100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson This function is used only once, and will need modification for Streaming SVE mode. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-11-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/internals.h | 11 ----------- target/arm/helper.c | 30 +++++++++++------------------- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index ceaddcbfd6e..79eb4637538 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -189,17 +189,6 @@ void arm_translate_init(void); void arm_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb); #endif /* CONFIG_TCG */ =20 -/** - * aarch64_sve_zcr_get_valid_len: - * @cpu: cpu context - * @start_len: maximum len to consider - * - * Return the maximum supported sve vector length <=3D @start_len. - * Note that both @start_len and the return value are in units - * of ZCR_ELx.LEN, so the vector bit length is (x + 1) * 128. - */ -uint32_t aarch64_sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len); - enum arm_fprounding { FPROUNDING_TIEEVEN, FPROUNDING_POSINF, diff --git a/target/arm/helper.c b/target/arm/helper.c index 61e8026d0e3..de159c644cd 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6212,39 +6212,31 @@ int sve_exception_el(CPUARMState *env, int el) return 0; } =20 -uint32_t aarch64_sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) -{ - uint32_t end_len; - - start_len =3D MIN(start_len, ARM_MAX_VQ - 1); - end_len =3D start_len; - - if (!test_bit(start_len, cpu->sve_vq_map)) { - end_len =3D find_last_bit(cpu->sve_vq_map, start_len); - assert(end_len < start_len); - } - return end_len; -} - /* * Given that SVE is enabled, return the vector length for EL. */ uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) { ARMCPU *cpu =3D env_archcpu(env); - uint32_t zcr_len =3D cpu->sve_max_vq - 1; + uint32_t len =3D cpu->sve_max_vq - 1; + uint32_t end_len; =20 if (el <=3D 1 && !el_is_in_host(env, el)) { - zcr_len =3D MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[1]); + len =3D MIN(len, 0xf & (uint32_t)env->vfp.zcr_el[1]); } if (el <=3D 2 && arm_feature(env, ARM_FEATURE_EL2)) { - zcr_len =3D MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[2]); + len =3D MIN(len, 0xf & (uint32_t)env->vfp.zcr_el[2]); } if (arm_feature(env, ARM_FEATURE_EL3)) { - zcr_len =3D MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[3]); + len =3D MIN(len, 0xf & (uint32_t)env->vfp.zcr_el[3]); } =20 - return aarch64_sve_zcr_get_valid_len(cpu, zcr_len); + end_len =3D len; + if (!test_bit(len, cpu->sve_vq_map)) { + end_len =3D find_last_bit(cpu->sve_vq_map, len); + assert(end_len < len); + } + return end_len; } =20 static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654770936; cv=none; d=zohomail.com; s=zohoarc; b=GuIR6szY8VpYD1zK4ElNr7X2ySzlCj2egrDLcVFAn8G2kz1C3pfqtnX+bfthdmE+eYdkMOvsD8Be+TR9o3h0AAa4CmeMFIR2a47gp1shyD0CoqNDNggXWfoxIlBeLPgTu3twAMDEHRh7g2c4vNdxFNEg2bf4lmYuDUjWkM0J2Sc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654770936; 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=RzISLAIsm/HQUCbU5drdl/7AuVQMoSI54OKREy/L1no=; b=iZmu4p6wsnoA6BGoxkHl3IH7IZh07MprStYWum+v6duv+IKl09xsY7nWfbNXat0p16T0rM+ntBJKf3x2XxZxvxvP5TxjKmKveiibA6TH2MPFDOXMta3kmsZ4QUglGtcqV4Bwi5URgXe2VBDlVD7q/9+kvv+/z8eX9BS6cBEhM+k= 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 1654770936722903.3112850298763; Thu, 9 Jun 2022 03:35:36 -0700 (PDT) Received: from localhost ([::1]:47586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFVn-0002Kj-9p for importer@patchew.org; Thu, 09 Jun 2022 06:35:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7d-0001hH-UD for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:34 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:51017) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7a-00068f-K9 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:32 -0400 Received: by mail-wm1-x32c.google.com with SMTP id e5so5272909wma.0 for ; Thu, 09 Jun 2022 02:06:30 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=RzISLAIsm/HQUCbU5drdl/7AuVQMoSI54OKREy/L1no=; b=pdT8R7UOBjH98ntFTJOA7FaJDD6BEFL5G79O1tegmwEz6IqpA2E4Oiiry7DFGrsTwA QH8dPxU6xbWjiG6+HZUsTqUr7xGMjng9pUbU+VHramWqxsD+S6rsLBOTkVNGiVLCPNCJ kg/Us/yjM7z5zBNyVLk+9fmqllesCGQdCKytrFeh5rMFZhAHi4fevbAE+ygjAOlXmarU xE2wI+lfTnUcVZ2rkJRE6kuP3QvAPPBhGC6tJpKWLOd6Jv1Af/gJVFjHt5sNMPfY80tr ma8kyagHy6kAh9mprQ0k4oWW3JQyJtx0FVZQ2Y57hCgjreB7CRpTr8fmYD0i/6k7A0Qm TIQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RzISLAIsm/HQUCbU5drdl/7AuVQMoSI54OKREy/L1no=; b=W13HTntDtOrrFRpKWGX/NOm9eGA5oWrRkclJ3ScCu6DM+RWBrQB8lUj3OYorodrsEC Jr6ADiEgBklqzd38ZYze/jTlJlLGSqdNAmUPKixRUZIP4tzvk8AX2DdRAQHgQGteUvLM Dg+J4HD9iUPtrnpz3M9dm1VTqsz6Wkd2pGkt7hOFtwWuW9MMdqLeOTME0Tnnb24DtEHt Clg2du58sjc4Dm9BJAjeMPGoOiFiE6Wa86hZnFUNwi84wZoBbnmQKsqfVrIA9qzyKH80 /VWHBZ+OmPkKh+nGMRP0MfZcmpWDuqpRuu3h4t3cx/+JSV3Z9auqXlKOdiduUT/rdGud +5Uw== X-Gm-Message-State: AOAM532LKONF2qITHCZZHlJOExbR1frzRjBCo0bgVzCu8HEZLxbayeez qLvfO7XlsBT5aBsZNkYa1rVlB3//NnZMgg== X-Google-Smtp-Source: ABdhPJw8QsGio6qUDKOo4+AJhiyeSnmwgfCYuGan/TwutpvXFoQ1umKDLPDvrTb5b3XazkqugS0pZA== X-Received: by 2002:a1c:4682:0:b0:39c:4459:6a84 with SMTP id t124-20020a1c4682000000b0039c44596a84mr2213102wma.167.1654765589048; Thu, 09 Jun 2022 02:06:29 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 46/55] target/arm: Use uint32_t instead of bitmap for sve vq's Date: Thu, 9 Jun 2022 10:05:28 +0100 Message-Id: <20220609090537.1971756-47-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654770938221100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson The bitmap need only hold 15 bits; bitmap is over-complicated. We can simplify operations quite a bit with plain logical ops. The introduction of SVE_VQ_POW2_MAP eliminates the need for looping in order to search for powers of two. Simply perform the logical ops and use count leading or trailing zeros as required to find the result. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-12-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu.h | 6 +-- target/arm/internals.h | 5 ++ target/arm/kvm_arm.h | 7 ++- target/arm/cpu64.c | 117 ++++++++++++++++++++--------------------- target/arm/helper.c | 9 +--- target/arm/kvm64.c | 36 +++---------- 6 files changed, 75 insertions(+), 105 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index f5af88b686d..73f24a57603 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1041,9 +1041,9 @@ struct ArchCPU { * Bits set in sve_vq_supported represent valid vector lengths for * the CPU type. */ - DECLARE_BITMAP(sve_vq_map, ARM_MAX_VQ); - DECLARE_BITMAP(sve_vq_init, ARM_MAX_VQ); - DECLARE_BITMAP(sve_vq_supported, ARM_MAX_VQ); + uint32_t sve_vq_map; + uint32_t sve_vq_init; + uint32_t sve_vq_supported; =20 /* Generic timer counter frequency, in Hz */ uint64_t gt_cntfrq_hz; diff --git a/target/arm/internals.h b/target/arm/internals.h index 79eb4637538..a1bae4588ae 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1340,4 +1340,9 @@ bool el_is_in_host(CPUARMState *env, int el); =20 void aa32_max_features(ARMCPU *cpu); =20 +/* Powers of 2 for sve_vq_map et al. */ +#define SVE_VQ_POW2_MAP \ + ((1 << (1 - 1)) | (1 << (2 - 1)) | \ + (1 << (4 - 1)) | (1 << (8 - 1)) | (1 << (16 - 1))) + #endif diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index b7f78b52154..99017b635ce 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -239,13 +239,12 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures= *ahcf); /** * kvm_arm_sve_get_vls: * @cs: CPUState - * @map: bitmap to fill in * * Get all the SVE vector lengths supported by the KVM host, setting * the bits corresponding to their length in quadwords minus one - * (vq - 1) in @map up to ARM_MAX_VQ. + * (vq - 1) up to ARM_MAX_VQ. Return the resulting map. */ -void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map); +uint32_t kvm_arm_sve_get_vls(CPUState *cs); =20 /** * kvm_arm_set_cpu_features_from_host: @@ -439,7 +438,7 @@ static inline void kvm_arm_steal_time_finalize(ARMCPU *= cpu, Error **errp) g_assert_not_reached(); } =20 -static inline void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) +static inline uint32_t kvm_arm_sve_get_vls(CPUState *cs) { g_assert_not_reached(); } diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index cce68dd82a2..15665c962b2 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -355,8 +355,11 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) * any of the above. Finally, if SVE is not disabled, then at least o= ne * vector length must be enabled. */ - DECLARE_BITMAP(tmp, ARM_MAX_VQ); - uint32_t vq, max_vq =3D 0; + uint32_t vq_map =3D cpu->sve_vq_map; + uint32_t vq_init =3D cpu->sve_vq_init; + uint32_t vq_supported; + uint32_t vq_mask =3D 0; + uint32_t tmp, vq, max_vq =3D 0; =20 /* * CPU models specify a set of supported vector lengths which are @@ -364,10 +367,16 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) * in the supported bitmap results in an error. When KVM is enabled we * fetch the supported bitmap from the host. */ - if (kvm_enabled() && kvm_arm_sve_supported()) { - kvm_arm_sve_get_vls(CPU(cpu), cpu->sve_vq_supported); - } else if (kvm_enabled()) { - assert(!cpu_isar_feature(aa64_sve, cpu)); + if (kvm_enabled()) { + if (kvm_arm_sve_supported()) { + cpu->sve_vq_supported =3D kvm_arm_sve_get_vls(CPU(cpu)); + vq_supported =3D cpu->sve_vq_supported; + } else { + assert(!cpu_isar_feature(aa64_sve, cpu)); + vq_supported =3D 0; + } + } else { + vq_supported =3D cpu->sve_vq_supported; } =20 /* @@ -375,8 +384,9 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) * From the properties, sve_vq_map implies sve_vq_init. * Check first for any sve enabled. */ - if (!bitmap_empty(cpu->sve_vq_map, ARM_MAX_VQ)) { - max_vq =3D find_last_bit(cpu->sve_vq_map, ARM_MAX_VQ) + 1; + if (vq_map !=3D 0) { + max_vq =3D 32 - clz32(vq_map); + vq_mask =3D MAKE_64BIT_MASK(0, max_vq); =20 if (cpu->sve_max_vq && max_vq > cpu->sve_max_vq) { error_setg(errp, "cannot enable sve%d", max_vq * 128); @@ -392,15 +402,10 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) * For KVM we have to automatically enable all supported uniti= alized * lengths, even when the smaller lengths are not all powers-o= f-two. */ - bitmap_andnot(tmp, cpu->sve_vq_supported, cpu->sve_vq_init, ma= x_vq); - bitmap_or(cpu->sve_vq_map, cpu->sve_vq_map, tmp, max_vq); + vq_map |=3D vq_supported & ~vq_init & vq_mask; } else { /* Propagate enabled bits down through required powers-of-two.= */ - for (vq =3D pow2floor(max_vq); vq >=3D 1; vq >>=3D 1) { - if (!test_bit(vq - 1, cpu->sve_vq_init)) { - set_bit(vq - 1, cpu->sve_vq_map); - } - } + vq_map |=3D SVE_VQ_POW2_MAP & ~vq_init & vq_mask; } } else if (cpu->sve_max_vq =3D=3D 0) { /* @@ -413,25 +418,18 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) =20 if (kvm_enabled()) { /* Disabling a supported length disables all larger lengths. */ - for (vq =3D 1; vq <=3D ARM_MAX_VQ; ++vq) { - if (test_bit(vq - 1, cpu->sve_vq_init) && - test_bit(vq - 1, cpu->sve_vq_supported)) { - break; - } - } + tmp =3D vq_init & vq_supported; } else { /* Disabling a power-of-two disables all larger lengths. */ - for (vq =3D 1; vq <=3D ARM_MAX_VQ; vq <<=3D 1) { - if (test_bit(vq - 1, cpu->sve_vq_init)) { - break; - } - } + tmp =3D vq_init & SVE_VQ_POW2_MAP; } + vq =3D ctz32(tmp) + 1; =20 max_vq =3D vq <=3D ARM_MAX_VQ ? vq - 1 : ARM_MAX_VQ; - bitmap_andnot(cpu->sve_vq_map, cpu->sve_vq_supported, - cpu->sve_vq_init, max_vq); - if (max_vq =3D=3D 0 || bitmap_empty(cpu->sve_vq_map, max_vq)) { + vq_mask =3D MAKE_64BIT_MASK(0, max_vq); + vq_map =3D vq_supported & ~vq_init & vq_mask; + + if (max_vq =3D=3D 0 || vq_map =3D=3D 0) { error_setg(errp, "cannot disable sve%d", vq * 128); error_append_hint(errp, "Disabling sve%d results in all " "vector lengths being disabled.\n", @@ -441,7 +439,8 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) return; } =20 - max_vq =3D find_last_bit(cpu->sve_vq_map, max_vq) + 1; + max_vq =3D 32 - clz32(vq_map); + vq_mask =3D MAKE_64BIT_MASK(0, max_vq); } =20 /* @@ -451,9 +450,9 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) */ if (cpu->sve_max_vq !=3D 0) { max_vq =3D cpu->sve_max_vq; + vq_mask =3D MAKE_64BIT_MASK(0, max_vq); =20 - if (!test_bit(max_vq - 1, cpu->sve_vq_map) && - test_bit(max_vq - 1, cpu->sve_vq_init)) { + if (vq_init & ~vq_map & (1 << (max_vq - 1))) { error_setg(errp, "cannot disable sve%d", max_vq * 128); error_append_hint(errp, "The maximum vector length must be " "enabled, sve-max-vq=3D%d (%d bits)\n", @@ -462,8 +461,7 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) } =20 /* Set all bits not explicitly set within sve-max-vq. */ - bitmap_complement(tmp, cpu->sve_vq_init, max_vq); - bitmap_or(cpu->sve_vq_map, cpu->sve_vq_map, tmp, max_vq); + vq_map |=3D ~vq_init & vq_mask; } =20 /* @@ -472,13 +470,14 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) * are clear, just in case anybody looks. */ assert(max_vq !=3D 0); - bitmap_clear(cpu->sve_vq_map, max_vq, ARM_MAX_VQ - max_vq); + assert(vq_mask !=3D 0); + vq_map &=3D vq_mask; =20 /* Ensure the set of lengths matches what is supported. */ - bitmap_xor(tmp, cpu->sve_vq_map, cpu->sve_vq_supported, max_vq); - if (!bitmap_empty(tmp, max_vq)) { - vq =3D find_last_bit(tmp, max_vq) + 1; - if (test_bit(vq - 1, cpu->sve_vq_map)) { + tmp =3D vq_map ^ (vq_supported & vq_mask); + if (tmp) { + vq =3D 32 - clz32(tmp); + if (vq_map & (1 << (vq - 1))) { if (cpu->sve_max_vq) { error_setg(errp, "cannot set sve-max-vq=3D%d", cpu->sve_ma= x_vq); error_append_hint(errp, "This CPU does not support " @@ -502,15 +501,15 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) return; } else { /* Ensure all required powers-of-two are enabled. */ - for (vq =3D pow2floor(max_vq); vq >=3D 1; vq >>=3D 1) { - if (!test_bit(vq - 1, cpu->sve_vq_map)) { - error_setg(errp, "cannot disable sve%d", vq * 128); - error_append_hint(errp, "sve%d is required as it " - "is a power-of-two length smalle= r " - "than the maximum, sve%d\n", - vq * 128, max_vq * 128); - return; - } + tmp =3D SVE_VQ_POW2_MAP & vq_mask & ~vq_map; + if (tmp) { + vq =3D 32 - clz32(tmp); + error_setg(errp, "cannot disable sve%d", vq * 128); + error_append_hint(errp, "sve%d is required as it " + "is a power-of-two length smaller " + "than the maximum, sve%d\n", + vq * 128, max_vq * 128); + return; } } } @@ -530,6 +529,7 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) =20 /* From now on sve_max_vq is the actual maximum supported length. */ cpu->sve_max_vq =3D max_vq; + cpu->sve_vq_map =3D vq_map; } =20 static void cpu_max_get_sve_max_vq(Object *obj, Visitor *v, const char *na= me, @@ -590,7 +590,7 @@ static void cpu_arm_get_sve_vq(Object *obj, Visitor *v,= const char *name, if (!cpu_isar_feature(aa64_sve, cpu)) { value =3D false; } else { - value =3D test_bit(vq - 1, cpu->sve_vq_map); + value =3D extract32(cpu->sve_vq_map, vq - 1, 1); } visit_type_bool(v, name, &value, errp); } @@ -612,12 +612,8 @@ static void cpu_arm_set_sve_vq(Object *obj, Visitor *v= , const char *name, return; } =20 - if (value) { - set_bit(vq - 1, cpu->sve_vq_map); - } else { - clear_bit(vq - 1, cpu->sve_vq_map); - } - set_bit(vq - 1, cpu->sve_vq_init); + cpu->sve_vq_map =3D deposit32(cpu->sve_vq_map, vq - 1, 1, value); + cpu->sve_vq_init |=3D 1 << (vq - 1); } =20 static bool cpu_arm_get_sve(Object *obj, Error **errp) @@ -979,7 +975,7 @@ static void aarch64_max_initfn(Object *obj) cpu->dcz_blocksize =3D 7; /* 512 bytes */ #endif =20 - bitmap_fill(cpu->sve_vq_supported, ARM_MAX_VQ); + cpu->sve_vq_supported =3D MAKE_64BIT_MASK(0, ARM_MAX_VQ); =20 aarch64_add_pauth_properties(obj); aarch64_add_sve_properties(obj); @@ -1026,12 +1022,11 @@ static void aarch64_a64fx_initfn(Object *obj) cpu->gic_vprebits =3D 5; cpu->gic_pribits =3D 5; =20 - /* Suppport of A64FX's vector length are 128,256 and 512bit only */ + /* The A64FX supports only 128, 256 and 512 bit vector lengths */ aarch64_add_sve_properties(obj); - bitmap_zero(cpu->sve_vq_supported, ARM_MAX_VQ); - set_bit(0, cpu->sve_vq_supported); /* 128bit */ - set_bit(1, cpu->sve_vq_supported); /* 256bit */ - set_bit(3, cpu->sve_vq_supported); /* 512bit */ + cpu->sve_vq_supported =3D (1 << 0) /* 128bit */ + | (1 << 1) /* 256bit */ + | (1 << 3); /* 512bit */ =20 cpu->isar.reset_pmcr_el0 =3D 0x46014040; =20 diff --git a/target/arm/helper.c b/target/arm/helper.c index de159c644cd..90aac6bc12d 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6219,7 +6219,6 @@ uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) { ARMCPU *cpu =3D env_archcpu(env); uint32_t len =3D cpu->sve_max_vq - 1; - uint32_t end_len; =20 if (el <=3D 1 && !el_is_in_host(env, el)) { len =3D MIN(len, 0xf & (uint32_t)env->vfp.zcr_el[1]); @@ -6231,12 +6230,8 @@ uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) len =3D MIN(len, 0xf & (uint32_t)env->vfp.zcr_el[3]); } =20 - end_len =3D len; - if (!test_bit(len, cpu->sve_vq_map)) { - end_len =3D find_last_bit(cpu->sve_vq_map, len); - assert(end_len < len); - } - return end_len; + len =3D 31 - clz32(cpu->sve_vq_map & MAKE_64BIT_MASK(0, len + 1)); + return len; } =20 static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index 363032da903..b3f635fc952 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -760,15 +760,13 @@ bool kvm_arm_steal_time_supported(void) =20 QEMU_BUILD_BUG_ON(KVM_ARM64_SVE_VQ_MIN !=3D 1); =20 -void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) +uint32_t kvm_arm_sve_get_vls(CPUState *cs) { /* Only call this function if kvm_arm_sve_supported() returns true. */ static uint64_t vls[KVM_ARM64_SVE_VLS_WORDS]; static bool probed; uint32_t vq =3D 0; - int i, j; - - bitmap_zero(map, ARM_MAX_VQ); + int i; =20 /* * KVM ensures all host CPUs support the same set of vector lengths. @@ -809,46 +807,24 @@ void kvm_arm_sve_get_vls(CPUState *cs, unsigned long = *map) if (vq > ARM_MAX_VQ) { warn_report("KVM supports vector lengths larger than " "QEMU can enable"); + vls[0] &=3D MAKE_64BIT_MASK(0, ARM_MAX_VQ); } } =20 - for (i =3D 0; i < KVM_ARM64_SVE_VLS_WORDS; ++i) { - if (!vls[i]) { - continue; - } - for (j =3D 1; j <=3D 64; ++j) { - vq =3D j + i * 64; - if (vq > ARM_MAX_VQ) { - return; - } - if (vls[i] & (1UL << (j - 1))) { - set_bit(vq - 1, map); - } - } - } + return vls[0]; } =20 static int kvm_arm_sve_set_vls(CPUState *cs) { - uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] =3D {0}; + ARMCPU *cpu =3D ARM_CPU(cs); + uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] =3D { cpu->sve_vq_map }; struct kvm_one_reg reg =3D { .id =3D KVM_REG_ARM64_SVE_VLS, .addr =3D (uint64_t)&vls[0], }; - ARMCPU *cpu =3D ARM_CPU(cs); - uint32_t vq; - int i, j; =20 assert(cpu->sve_max_vq <=3D KVM_ARM64_SVE_VQ_MAX); =20 - for (vq =3D 1; vq <=3D cpu->sve_max_vq; ++vq) { - if (test_bit(vq - 1, cpu->sve_vq_map)) { - i =3D (vq - 1) / 64; - j =3D (vq - 1) % 64; - vls[i] |=3D 1UL << j; - } - } - return kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); } =20 --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654771320; cv=none; d=zohomail.com; s=zohoarc; b=Xft8Sk5XjIZsvW2l8xBQzTVtLFgOEOGUrrlaTDHSWZ+PCJYwomSSHk6Ekq5IDR+MH8zxaWg3InmY3iNb6ZLIPm3EyQAH+4UnCrqexWFycWZDsORq7VDs6zxIl1qmqWKRT76L4vgCKYgbJQIKyEfKlQF1OKPUzZUwgsjmHcSZjYg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654771320; 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=ln4NarpB9GXHE3SSoQy0ZUBfyqzyJv95N2jOXflbDEs=; b=G967WcSQZjInduhA+XP+w0sldKrAZo9eE75FMA2yFNXP7gefI7joELNdOeSgUfEjC7Nt93LNkJ+L/qsh8oBIlLEDqSTOaUnBlqz6XROzI3oU5pxnwCvdIl+h76QNnGMSb2PUJCGzabtzEaGd+UdBSEk5I//045DEhIuyorxIZ84= 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 1654771320252798.2267064653212; Thu, 9 Jun 2022 03:42:00 -0700 (PDT) Received: from localhost ([::1]:56428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFby-0000A6-NT for importer@patchew.org; Thu, 09 Jun 2022 06:41:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7d-0001gU-SN for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:34 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:47100) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7b-00061B-0P for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:32 -0400 Received: by mail-wm1-x32e.google.com with SMTP id r123-20020a1c2b81000000b0039c1439c33cso12264463wmr.5 for ; Thu, 09 Jun 2022 02:06:30 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ln4NarpB9GXHE3SSoQy0ZUBfyqzyJv95N2jOXflbDEs=; b=EWhynYWPJGb3hPXk6/XiW86PShAFbDRSonRdil7h/KJulzf3n5xajMNv53PEghwhkt dRdoIRJ3sguC+yM90+usvvuEVq5U+DTx2ocWe1d40gye0vruVZjEcQ0R9Z1jfaKo/ib5 KWokqu8v4tm0mjmz9ag+9xtqn3zXncCU68EuqDX4RfmseW5QXeh76HswJCQSB/PQCWXQ VjmGThLOM27jEaYTs6fHqXxUPgkjMp1e559531OqscmuHMdtc2qts5JIaydoogrTKLUY 4e31FtyZzgw3swherBq0jjOVJzDp8LzUs1ntwlmiUYesaXihwM88PZhG89NE00Y5wdRI lPnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ln4NarpB9GXHE3SSoQy0ZUBfyqzyJv95N2jOXflbDEs=; b=Zeb3ERLV9o2CH3wPOry2sn5UXTv+WSJhWjTiC0ivXe2DPr5ERUpxdQhjW8eq/nxmu3 IGU+ZdoSLFXAchdp/LCiTiuBfZlor/0h9l2Ia5c2dnQvVnl+uhyT6TVIMDx+gCzu8/+n Rxxzl2SBojWxxp9o9u8yI9olYXOETMRCq44RAx/ID0O+reoy+wQKUScbjkQXPC4bBQSQ h9FHRKwLhpbeuBcjBu0ufUxrjvZMwKBx3ptHyhm0mRX+9226Cq8Eros95I/MPoBAXIAG Ob5+Trs2vK46WoBvMS+iQATOmW8sPHjBIvRoRUz/m1W2/fyQoUHJncUuBVkjEMl7J6XR FDkw== X-Gm-Message-State: AOAM531HZcXhUim1h/8BV7MqUPkg4LfT3XAKz0YmN1Eq3eZd8HUhCtcj K1Ms4lvuvp2KYapw1YHFZxJm/f0jZOQYBg== X-Google-Smtp-Source: ABdhPJzJcGK9QZuiBfEMECR5cG7J7BCVTEjZ4zrOWeuTNRu8GXA01ZhMThN8v/6uU/Y2UyKw/CBU0g== X-Received: by 2002:a05:600c:4fd2:b0:39b:893e:ff79 with SMTP id o18-20020a05600c4fd200b0039b893eff79mr2295531wmq.73.1654765590191; Thu, 09 Jun 2022 02:06:30 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 47/55] target/arm: Rename sve_zcr_len_for_el to sve_vqm1_for_el Date: Thu, 9 Jun 2022 10:05:29 +0100 Message-Id: <20220609090537.1971756-48-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654771321608100003 Content-Type: text/plain; charset="utf-8" From: Richard Henderson This will be used for both Normal and Streaming SVE, and the value does not necessarily come from ZCR_ELx. While we're at it, emphasize the units in which the value is returned. Patch produced by git grep -l sve_zcr_len_for_el | \ xargs -n1 sed -i 's/sve_zcr_len_for_el/sve_vqm1_for_el/g' and then adding a function comment. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-13-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu.h | 11 ++++++++++- target/arm/arch_dump.c | 2 +- target/arm/cpu.c | 2 +- target/arm/gdbstub64.c | 2 +- target/arm/helper.c | 12 ++++++------ 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 73f24a57603..e45b5cb7fe1 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1132,7 +1132,16 @@ void aarch64_sync_64_to_32(CPUARMState *env); =20 int fp_exception_el(CPUARMState *env, int cur_el); int sve_exception_el(CPUARMState *env, int cur_el); -uint32_t sve_zcr_len_for_el(CPUARMState *env, int el); + +/** + * sve_vqm1_for_el: + * @env: CPUARMState + * @el: exception level + * + * Compute the current SVE vector length for @el, in units of + * Quadwords Minus 1 -- the same scale used for ZCR_ELx.LEN. + */ +uint32_t sve_vqm1_for_el(CPUARMState *env, int el); =20 static inline bool is_a64(CPUARMState *env) { diff --git a/target/arm/arch_dump.c b/target/arm/arch_dump.c index 01848453109..b1f040e69f2 100644 --- a/target/arm/arch_dump.c +++ b/target/arm/arch_dump.c @@ -166,7 +166,7 @@ static off_t sve_fpcr_offset(uint32_t vq) =20 static uint32_t sve_current_vq(CPUARMState *env) { - return sve_zcr_len_for_el(env, arm_current_el(env)) + 1; + return sve_vqm1_for_el(env, arm_current_el(env)) + 1; } =20 static size_t sve_size_vq(uint32_t vq) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 06219441674..1b5d5357880 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -925,7 +925,7 @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *= f, int flags) vfp_get_fpcr(env), vfp_get_fpsr(env)); =20 if (cpu_isar_feature(aa64_sve, cpu) && sve_exception_el(env, el) =3D= =3D 0) { - int j, zcr_len =3D sve_zcr_len_for_el(env, el); + int j, zcr_len =3D sve_vqm1_for_el(env, el); =20 for (i =3D 0; i <=3D FFR_PRED_NUM; i++) { bool eol; diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 596878666d7..07a6746944d 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -152,7 +152,7 @@ int arm_gdb_get_svereg(CPUARMState *env, GByteArray *bu= f, int reg) * We report in Vector Granules (VG) which is 64bit in a Z reg * while the ZCR works in Vector Quads (VQ) which is 128bit chunks. */ - int vq =3D sve_zcr_len_for_el(env, arm_current_el(env)) + 1; + int vq =3D sve_vqm1_for_el(env, arm_current_el(env)) + 1; return gdb_get_reg64(buf, vq * 2); } default: diff --git a/target/arm/helper.c b/target/arm/helper.c index 90aac6bc12d..400f7cd1dba 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6215,7 +6215,7 @@ int sve_exception_el(CPUARMState *env, int el) /* * Given that SVE is enabled, return the vector length for EL. */ -uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) +uint32_t sve_vqm1_for_el(CPUARMState *env, int el) { ARMCPU *cpu =3D env_archcpu(env); uint32_t len =3D cpu->sve_max_vq - 1; @@ -6238,7 +6238,7 @@ static void zcr_write(CPUARMState *env, const ARMCPRe= gInfo *ri, uint64_t value) { int cur_el =3D arm_current_el(env); - int old_len =3D sve_zcr_len_for_el(env, cur_el); + int old_len =3D sve_vqm1_for_el(env, cur_el); int new_len; =20 /* Bits other than [3:0] are RAZ/WI. */ @@ -6249,7 +6249,7 @@ static void zcr_write(CPUARMState *env, const ARMCPRe= gInfo *ri, * Because we arrived here, we know both FP and SVE are enabled; * otherwise we would have trapped access to the ZCR_ELn register. */ - new_len =3D sve_zcr_len_for_el(env, cur_el); + new_len =3D sve_vqm1_for_el(env, cur_el); if (new_len < old_len) { aarch64_sve_narrow_vq(env, new_len + 1); } @@ -11168,7 +11168,7 @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState= *env, int el, int fp_el, sve_el =3D 0; } } else if (sve_el =3D=3D 0) { - DP_TBFLAG_A64(flags, VL, sve_zcr_len_for_el(env, el)); + DP_TBFLAG_A64(flags, VL, sve_vqm1_for_el(env, el)); } DP_TBFLAG_A64(flags, SVEEXC_EL, sve_el); } @@ -11534,10 +11534,10 @@ void aarch64_sve_change_el(CPUARMState *env, int = old_el, */ old_a64 =3D old_el ? arm_el_is_aa64(env, old_el) : el0_a64; old_len =3D (old_a64 && !sve_exception_el(env, old_el) - ? sve_zcr_len_for_el(env, old_el) : 0); + ? sve_vqm1_for_el(env, old_el) : 0); new_a64 =3D new_el ? arm_el_is_aa64(env, new_el) : el0_a64; new_len =3D (new_a64 && !sve_exception_el(env, new_el) - ? sve_zcr_len_for_el(env, new_el) : 0); + ? sve_vqm1_for_el(env, new_el) : 0); =20 /* When changing vector length, clear inaccessible state. */ if (new_len < old_len) { --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654770198; cv=none; d=zohomail.com; s=zohoarc; b=dcBt2xSv3c/SY05p6BKy0D01se26PZefxNxRI5aPOGZMBSSh0c5Qt5t9FSPTd6/fw51Tq77uLBklKYhtBJ2RwzYv+0rVXOQsclTCwVVOz5uc+H9LEYaI86NspgLG+9LoRzq9MkEXt1cvqE5O0oze5lYDLuUOeOlnYHy6zUzeReE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654770198; 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=Y6NKzjmohrdzTWz249bQwDudC0VH9aW6QTVdwHDMnIc=; b=XrhXKeTpssAob7Y53VvV0h3O3sbw/Nk2ENnYc+iG4ONGsi6qv0wCvXjfxua7Wb3xn3fTXx3q1T/MARfwOpnc1NOEnqPugohb2m09DEL2KAFiOFZ9uJvUwgFAuf3Wsw1JsWPDAmvUNr2n6P8AYF2u8XywwQ+Pjc8h0B9YTD8PQKc= 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 1654770198268129.09654025864143; Thu, 9 Jun 2022 03:23:18 -0700 (PDT) Received: from localhost ([::1]:42376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFJs-0006Sx-Kd for importer@patchew.org; Thu, 09 Jun 2022 06:23:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7e-0001jh-W7 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:35 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:43563) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7c-00063C-2Z for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:34 -0400 Received: by mail-wr1-x433.google.com with SMTP id d14so22478436wra.10 for ; Thu, 09 Jun 2022 02:06:31 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Y6NKzjmohrdzTWz249bQwDudC0VH9aW6QTVdwHDMnIc=; b=R0faIh7xeFaIzB1VOYAgdfpPLOHHAYna+UOAAyvxW/w11AmltFCmelBXLEUA+IrHBj 4F+NiBeU9u4HxJ9X3owYxm1Srfc5DpSH+nbjlDUg1OyDzDTEoYefWgq6b4Lbx9WR+f1u hTLInLscWUUJku+wN7O1x3yeOwkMRO8QResv2grWibNziF7gzUf4f0+ZVQIehLPuXE1j 3+Sy7tTuJ67og+JTJvAFqx0Cu+/PGhyEReAh65BleCMYJ9wp9CocD5MygDMk2qip0WbV B4QKq1jaBEQdK/oHh0IE9gkPh38xAHssTwCr3omOEhILEBmaBYZS5qzSoPp8gQoQDQwG Mi1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y6NKzjmohrdzTWz249bQwDudC0VH9aW6QTVdwHDMnIc=; b=Tw0no7GwgvaB0raIsMj/HzxjbAPk/W4DGEcYSkBqHkyTSAFqIzjMU3V+mTdJI6ubDH vtyfukLmnGoVrureoNP3TOB5wpu+433u0tBJ50/yYLkuW/JGv+pHIGjmK/nHVElb8Z2s M4Z2/HvJ26AJMwZL5bfk2zuue9hOOyoyBYRSNm7an7tbzO91odO++ImljwoL5omhbiTg 8Qd4r+zb6GO7De3fQ4vWfVN7qT+qYyxYq21pSdonhnNdBXtnKyUvhL9aVJstgCzADpA6 /MRV6Mt0pdjCTYLYUt9IFmnu3fMtFiXbMvw90Mi5/1Ks+IP4l/gBHcVcJSDRnCPZcvTS twmA== X-Gm-Message-State: AOAM530Bc/mzsRECd3TGjuAhW1QlJxbDhZJsRZDnOQozAs56Yuc2Gstg K/vg+Bs3Au48hYzuHsRDD12V3FB08nxfyQ== X-Google-Smtp-Source: ABdhPJw0qXnoznEbtK2ZBayPEzof/Sp6kjpQ6M4Nl1nIUgOSrTw8cgZzEWLqbqXQay6pCqo4Dt2vWQ== X-Received: by 2002:adf:b644:0:b0:210:1fde:a513 with SMTP id i4-20020adfb644000000b002101fdea513mr39475679wre.604.1654765591286; Thu, 09 Jun 2022 02:06:31 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 48/55] target/arm: Split out load/store primitives to sve_ldst_internal.h Date: Thu, 9 Jun 2022 10:05:30 +0100 Message-Id: <20220609090537.1971756-49-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654770199003100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Begin creation of sve_ldst_internal.h by moving the primitives that access host and tlb memory. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-14-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/sve_ldst_internal.h | 127 +++++++++++++++++++++++++++++++++ target/arm/sve_helper.c | 107 +-------------------------- 2 files changed, 128 insertions(+), 106 deletions(-) create mode 100644 target/arm/sve_ldst_internal.h diff --git a/target/arm/sve_ldst_internal.h b/target/arm/sve_ldst_internal.h new file mode 100644 index 00000000000..ef9117e84c1 --- /dev/null +++ b/target/arm/sve_ldst_internal.h @@ -0,0 +1,127 @@ +/* + * ARM SVE Load/Store Helpers + * + * Copyright (c) 2018-2022 Linaro + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef TARGET_ARM_SVE_LDST_INTERNAL_H +#define TARGET_ARM_SVE_LDST_INTERNAL_H + +#include "exec/cpu_ldst.h" + +/* + * Load one element into @vd + @reg_off from @host. + * The controlling predicate is known to be true. + */ +typedef void sve_ldst1_host_fn(void *vd, intptr_t reg_off, void *host); + +/* + * Load one element into @vd + @reg_off from (@env, @vaddr, @ra). + * The controlling predicate is known to be true. + */ +typedef void sve_ldst1_tlb_fn(CPUARMState *env, void *vd, intptr_t reg_off, + target_ulong vaddr, uintptr_t retaddr); + +/* + * Generate the above primitives. + */ + +#define DO_LD_HOST(NAME, H, TYPEE, TYPEM, HOST) = \ +static inline void sve_##NAME##_host(void *vd, intptr_t reg_off, void *hos= t) \ +{ TYPEM val =3D HOST(host); *(TYPEE *)(vd + H(reg_off)) =3D val; } + +#define DO_ST_HOST(NAME, H, TYPEE, TYPEM, HOST) = \ +static inline void sve_##NAME##_host(void *vd, intptr_t reg_off, void *hos= t) \ +{ TYPEM val =3D *(TYPEE *)(vd + H(reg_off)); HOST(host, val); } + +#define DO_LD_TLB(NAME, H, TYPEE, TYPEM, TLB) = \ +static inline void sve_##NAME##_tlb(CPUARMState *env, void *vd, = \ + intptr_t reg_off, target_ulong addr, uintptr_t ra)= \ +{ = \ + TYPEM val =3D TLB(env, useronly_clean_ptr(addr), ra); = \ + *(TYPEE *)(vd + H(reg_off)) =3D val; = \ +} + +#define DO_ST_TLB(NAME, H, TYPEE, TYPEM, TLB) = \ +static inline void sve_##NAME##_tlb(CPUARMState *env, void *vd, = \ + intptr_t reg_off, target_ulong addr, uintptr_t ra)= \ +{ = \ + TYPEM val =3D *(TYPEE *)(vd + H(reg_off)); = \ + TLB(env, useronly_clean_ptr(addr), val, ra); = \ +} + +#define DO_LD_PRIM_1(NAME, H, TE, TM) \ + DO_LD_HOST(NAME, H, TE, TM, ldub_p) \ + DO_LD_TLB(NAME, H, TE, TM, cpu_ldub_data_ra) + +DO_LD_PRIM_1(ld1bb, H1, uint8_t, uint8_t) +DO_LD_PRIM_1(ld1bhu, H1_2, uint16_t, uint8_t) +DO_LD_PRIM_1(ld1bhs, H1_2, uint16_t, int8_t) +DO_LD_PRIM_1(ld1bsu, H1_4, uint32_t, uint8_t) +DO_LD_PRIM_1(ld1bss, H1_4, uint32_t, int8_t) +DO_LD_PRIM_1(ld1bdu, H1_8, uint64_t, uint8_t) +DO_LD_PRIM_1(ld1bds, H1_8, uint64_t, int8_t) + +#define DO_ST_PRIM_1(NAME, H, TE, TM) \ + DO_ST_HOST(st1##NAME, H, TE, TM, stb_p) \ + DO_ST_TLB(st1##NAME, H, TE, TM, cpu_stb_data_ra) + +DO_ST_PRIM_1(bb, H1, uint8_t, uint8_t) +DO_ST_PRIM_1(bh, H1_2, uint16_t, uint8_t) +DO_ST_PRIM_1(bs, H1_4, uint32_t, uint8_t) +DO_ST_PRIM_1(bd, H1_8, uint64_t, uint8_t) + +#define DO_LD_PRIM_2(NAME, H, TE, TM, LD) \ + DO_LD_HOST(ld1##NAME##_be, H, TE, TM, LD##_be_p) \ + DO_LD_HOST(ld1##NAME##_le, H, TE, TM, LD##_le_p) \ + DO_LD_TLB(ld1##NAME##_be, H, TE, TM, cpu_##LD##_be_data_ra) \ + DO_LD_TLB(ld1##NAME##_le, H, TE, TM, cpu_##LD##_le_data_ra) + +#define DO_ST_PRIM_2(NAME, H, TE, TM, ST) \ + DO_ST_HOST(st1##NAME##_be, H, TE, TM, ST##_be_p) \ + DO_ST_HOST(st1##NAME##_le, H, TE, TM, ST##_le_p) \ + DO_ST_TLB(st1##NAME##_be, H, TE, TM, cpu_##ST##_be_data_ra) \ + DO_ST_TLB(st1##NAME##_le, H, TE, TM, cpu_##ST##_le_data_ra) + +DO_LD_PRIM_2(hh, H1_2, uint16_t, uint16_t, lduw) +DO_LD_PRIM_2(hsu, H1_4, uint32_t, uint16_t, lduw) +DO_LD_PRIM_2(hss, H1_4, uint32_t, int16_t, lduw) +DO_LD_PRIM_2(hdu, H1_8, uint64_t, uint16_t, lduw) +DO_LD_PRIM_2(hds, H1_8, uint64_t, int16_t, lduw) + +DO_ST_PRIM_2(hh, H1_2, uint16_t, uint16_t, stw) +DO_ST_PRIM_2(hs, H1_4, uint32_t, uint16_t, stw) +DO_ST_PRIM_2(hd, H1_8, uint64_t, uint16_t, stw) + +DO_LD_PRIM_2(ss, H1_4, uint32_t, uint32_t, ldl) +DO_LD_PRIM_2(sdu, H1_8, uint64_t, uint32_t, ldl) +DO_LD_PRIM_2(sds, H1_8, uint64_t, int32_t, ldl) + +DO_ST_PRIM_2(ss, H1_4, uint32_t, uint32_t, stl) +DO_ST_PRIM_2(sd, H1_8, uint64_t, uint32_t, stl) + +DO_LD_PRIM_2(dd, H1_8, uint64_t, uint64_t, ldq) +DO_ST_PRIM_2(dd, H1_8, uint64_t, uint64_t, stq) + +#undef DO_LD_TLB +#undef DO_ST_TLB +#undef DO_LD_HOST +#undef DO_LD_PRIM_1 +#undef DO_ST_PRIM_1 +#undef DO_LD_PRIM_2 +#undef DO_ST_PRIM_2 + +#endif /* TARGET_ARM_SVE_LDST_INTERNAL_H */ diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c index 3bdcd4ce9d0..0c6dde00aa6 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -21,12 +21,12 @@ #include "cpu.h" #include "internals.h" #include "exec/exec-all.h" -#include "exec/cpu_ldst.h" #include "exec/helper-proto.h" #include "tcg/tcg-gvec-desc.h" #include "fpu/softfloat.h" #include "tcg/tcg.h" #include "vec_internal.h" +#include "sve_ldst_internal.h" =20 =20 /* Return a value for NZCV as per the ARM PredTest pseudofunction. @@ -5301,111 +5301,6 @@ void HELPER(sve_fcmla_zpzzz_d)(void *vd, void *vn, = void *vm, void *va, * Load contiguous data, protected by a governing predicate. */ =20 -/* - * Load one element into @vd + @reg_off from @host. - * The controlling predicate is known to be true. - */ -typedef void sve_ldst1_host_fn(void *vd, intptr_t reg_off, void *host); - -/* - * Load one element into @vd + @reg_off from (@env, @vaddr, @ra). - * The controlling predicate is known to be true. - */ -typedef void sve_ldst1_tlb_fn(CPUARMState *env, void *vd, intptr_t reg_off, - target_ulong vaddr, uintptr_t retaddr); - -/* - * Generate the above primitives. - */ - -#define DO_LD_HOST(NAME, H, TYPEE, TYPEM, HOST) \ -static void sve_##NAME##_host(void *vd, intptr_t reg_off, void *host) \ -{ \ - TYPEM val =3D HOST(host); \ - *(TYPEE *)(vd + H(reg_off)) =3D val; \ -} - -#define DO_ST_HOST(NAME, H, TYPEE, TYPEM, HOST) \ -static void sve_##NAME##_host(void *vd, intptr_t reg_off, void *host) \ -{ HOST(host, (TYPEM)*(TYPEE *)(vd + H(reg_off))); } - -#define DO_LD_TLB(NAME, H, TYPEE, TYPEM, TLB) \ -static void sve_##NAME##_tlb(CPUARMState *env, void *vd, intptr_t reg_off,= \ - target_ulong addr, uintptr_t ra) = \ -{ = \ - *(TYPEE *)(vd + H(reg_off)) =3D = \ - (TYPEM)TLB(env, useronly_clean_ptr(addr), ra); = \ -} - -#define DO_ST_TLB(NAME, H, TYPEE, TYPEM, TLB) \ -static void sve_##NAME##_tlb(CPUARMState *env, void *vd, intptr_t reg_off,= \ - target_ulong addr, uintptr_t ra) = \ -{ = \ - TLB(env, useronly_clean_ptr(addr), = \ - (TYPEM)*(TYPEE *)(vd + H(reg_off)), ra); = \ -} - -#define DO_LD_PRIM_1(NAME, H, TE, TM) \ - DO_LD_HOST(NAME, H, TE, TM, ldub_p) \ - DO_LD_TLB(NAME, H, TE, TM, cpu_ldub_data_ra) - -DO_LD_PRIM_1(ld1bb, H1, uint8_t, uint8_t) -DO_LD_PRIM_1(ld1bhu, H1_2, uint16_t, uint8_t) -DO_LD_PRIM_1(ld1bhs, H1_2, uint16_t, int8_t) -DO_LD_PRIM_1(ld1bsu, H1_4, uint32_t, uint8_t) -DO_LD_PRIM_1(ld1bss, H1_4, uint32_t, int8_t) -DO_LD_PRIM_1(ld1bdu, H1_8, uint64_t, uint8_t) -DO_LD_PRIM_1(ld1bds, H1_8, uint64_t, int8_t) - -#define DO_ST_PRIM_1(NAME, H, TE, TM) \ - DO_ST_HOST(st1##NAME, H, TE, TM, stb_p) \ - DO_ST_TLB(st1##NAME, H, TE, TM, cpu_stb_data_ra) - -DO_ST_PRIM_1(bb, H1, uint8_t, uint8_t) -DO_ST_PRIM_1(bh, H1_2, uint16_t, uint8_t) -DO_ST_PRIM_1(bs, H1_4, uint32_t, uint8_t) -DO_ST_PRIM_1(bd, H1_8, uint64_t, uint8_t) - -#define DO_LD_PRIM_2(NAME, H, TE, TM, LD) \ - DO_LD_HOST(ld1##NAME##_be, H, TE, TM, LD##_be_p) \ - DO_LD_HOST(ld1##NAME##_le, H, TE, TM, LD##_le_p) \ - DO_LD_TLB(ld1##NAME##_be, H, TE, TM, cpu_##LD##_be_data_ra) \ - DO_LD_TLB(ld1##NAME##_le, H, TE, TM, cpu_##LD##_le_data_ra) - -#define DO_ST_PRIM_2(NAME, H, TE, TM, ST) \ - DO_ST_HOST(st1##NAME##_be, H, TE, TM, ST##_be_p) \ - DO_ST_HOST(st1##NAME##_le, H, TE, TM, ST##_le_p) \ - DO_ST_TLB(st1##NAME##_be, H, TE, TM, cpu_##ST##_be_data_ra) \ - DO_ST_TLB(st1##NAME##_le, H, TE, TM, cpu_##ST##_le_data_ra) - -DO_LD_PRIM_2(hh, H1_2, uint16_t, uint16_t, lduw) -DO_LD_PRIM_2(hsu, H1_4, uint32_t, uint16_t, lduw) -DO_LD_PRIM_2(hss, H1_4, uint32_t, int16_t, lduw) -DO_LD_PRIM_2(hdu, H1_8, uint64_t, uint16_t, lduw) -DO_LD_PRIM_2(hds, H1_8, uint64_t, int16_t, lduw) - -DO_ST_PRIM_2(hh, H1_2, uint16_t, uint16_t, stw) -DO_ST_PRIM_2(hs, H1_4, uint32_t, uint16_t, stw) -DO_ST_PRIM_2(hd, H1_8, uint64_t, uint16_t, stw) - -DO_LD_PRIM_2(ss, H1_4, uint32_t, uint32_t, ldl) -DO_LD_PRIM_2(sdu, H1_8, uint64_t, uint32_t, ldl) -DO_LD_PRIM_2(sds, H1_8, uint64_t, int32_t, ldl) - -DO_ST_PRIM_2(ss, H1_4, uint32_t, uint32_t, stl) -DO_ST_PRIM_2(sd, H1_8, uint64_t, uint32_t, stl) - -DO_LD_PRIM_2(dd, H1_8, uint64_t, uint64_t, ldq) -DO_ST_PRIM_2(dd, H1_8, uint64_t, uint64_t, stq) - -#undef DO_LD_TLB -#undef DO_ST_TLB -#undef DO_LD_HOST -#undef DO_LD_PRIM_1 -#undef DO_ST_PRIM_1 -#undef DO_LD_PRIM_2 -#undef DO_ST_PRIM_2 - /* * Skip through a sequence of inactive elements in the guarding predicate = @vg, * beginning at @reg_off bounded by @reg_max. Return the offset of the ac= tive --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654771585; cv=none; d=zohomail.com; s=zohoarc; b=KpWnmAgCfD5mahJ31HovRK8wZVmDyeM2V0uUoaiR2PNjyvLCkriGYsc3BkclMvCggAPCJxzQXrA/XyM4YGUVWGVWsaxP7ETkIdYHAXzRkb2jyCR2swoVFHD8Nb/S4TILxEHCLI0qYI1pKuFm7s0AIz5bdy+/1b0Ilq4VB/TXFmU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654771585; 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=F9/bTgmopMaBQ0OD2oJr6RwZaHaOzv4367oHJLRZpW4=; b=MU+a7iizbJtMnqYcydRyXV2zqWYMH+OLMBGY7KKh+/4UCUM6bhDPrjs06pxZ/GtaZm18a43LGM3C9VmkQbRGU8YQtPVkz4rWfelueBghH4iesovlTRn7V6opeZOaO1HodY133pRbyh30nmdiVVrlyuf+DYe9vs+WcNpkG/yImJo= 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 1654771585027626.043714498479; Thu, 9 Jun 2022 03:46:25 -0700 (PDT) Received: from localhost ([::1]:36708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFgF-00064Z-Pd for importer@patchew.org; Thu, 09 Jun 2022 06:46:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40024) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7i-0001lt-E0 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:38 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:53919) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7d-00067I-9J for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:37 -0400 Received: by mail-wm1-x331.google.com with SMTP id z9so5330339wmf.3 for ; Thu, 09 Jun 2022 02:06:32 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=F9/bTgmopMaBQ0OD2oJr6RwZaHaOzv4367oHJLRZpW4=; b=OJEvjqJyKIiIBkJceysPIhW243YMUSKb6cTvXTQeY+PLTvgSfIboX35HdPDqA9KKFn GMYBGIW8O0Kg8r/0pRN/EXOubKbX+A6XBBkaXn2ZNYbzbcKIFj8TGWL2VzycdHIEH8rF oq5XkxqxlqUySs3deCbiQgRQc8H+oggTjaeDk8lxqyMIgF4c0oNa8ypttrxoMJtbj/K/ 7rcPvlouKGdPhM3943JNs5uD10SS522tvtY8G984X05S4Ng/u3boe/nRKOK1Msdp01N1 LCziZQBiA/nr1I1z54ZqC3DyMaOjJptTHZQyq/m/fEQKXdBEXwwR7dyyELx4iqLd20It 0oMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F9/bTgmopMaBQ0OD2oJr6RwZaHaOzv4367oHJLRZpW4=; b=c+tnp+hVgFK0gLCMrRdkgkKxUMa5IigJSXOtlSWo5pgQDYzMBQMQXc9ICbBAoKyIjK ZV7bdWmtte9MTbAvLigLZ7Wl5kUOO/bV2yBzh2MvsLh3bUTPMakKllmXk1PLYmog/yYo zEAquOrSbVL7HX7ZZ85cJ00xi5mrc1Jisj1vRNPQVX2AmbI8GNNm0N5xBtBuNPbSbM37 sVJH/cRDzIGFPUcwmDQlP1SkMJ3d93ymVyyQ43rzCZXtX9Hr/59WzbcM6ba5dnNAVvIl 4SPm1WGoGsFXWiGmHuLB5l2+wxqVU6FQ2LtlUI+BcCpVQJY5Bmt7jYEp1xP3v15/Jtb1 wu+Q== X-Gm-Message-State: AOAM532GmZTfIcq/ptgbWYStzbUxM3pP/OFidb6FB6CNpxa2tUdO3nNi J2dJaA6TBZoo5oIdloRAcUCGzv5WBgxicQ== X-Google-Smtp-Source: ABdhPJyz3x3eV4DbRep4XvGR6Ck0kFBiokbPZiwL/r9QE5U1vM6Kgm0MPtMBvWuzI1wXT+zMArVHWQ== X-Received: by 2002:a05:600c:2e14:b0:39c:58c4:c6ed with SMTP id o20-20020a05600c2e1400b0039c58c4c6edmr2308116wmf.156.1654765592275; Thu, 09 Jun 2022 02:06:32 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 49/55] target/arm: Export sve contiguous ldst support functions Date: Thu, 9 Jun 2022 10:05:31 +0100 Message-Id: <20220609090537.1971756-50-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654771585870100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Export all of the support functions for performing bulk fault analysis on a set of elements at contiguous addresses controlled by a predicate. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-15-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/sve_ldst_internal.h | 94 ++++++++++++++++++++++++++++++++++ target/arm/sve_helper.c | 87 ++++++------------------------- 2 files changed, 111 insertions(+), 70 deletions(-) diff --git a/target/arm/sve_ldst_internal.h b/target/arm/sve_ldst_internal.h index ef9117e84c1..b5c473fc48b 100644 --- a/target/arm/sve_ldst_internal.h +++ b/target/arm/sve_ldst_internal.h @@ -124,4 +124,98 @@ DO_ST_PRIM_2(dd, H1_8, uint64_t, uint64_t, stq) #undef DO_LD_PRIM_2 #undef DO_ST_PRIM_2 =20 +/* + * Resolve the guest virtual address to info->host and info->flags. + * If @nofault, return false if the page is invalid, otherwise + * exit via page fault exception. + */ + +typedef struct { + void *host; + int flags; + MemTxAttrs attrs; +} SVEHostPage; + +bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env, + target_ulong addr, int mem_off, MMUAccessType access_t= ype, + int mmu_idx, uintptr_t retaddr); + +/* + * Analyse contiguous data, protected by a governing predicate. + */ + +typedef enum { + FAULT_NO, + FAULT_FIRST, + FAULT_ALL, +} SVEContFault; + +typedef struct { + /* + * First and last element wholly contained within the two pages. + * mem_off_first[0] and reg_off_first[0] are always set >=3D 0. + * reg_off_last[0] may be < 0 if the first element crosses pages. + * All of mem_off_first[1], reg_off_first[1] and reg_off_last[1] + * are set >=3D 0 only if there are complete elements on a second page. + * + * The reg_off_* offsets are relative to the internal vector register. + * The mem_off_first offset is relative to the memory address; the + * two offsets are different when a load operation extends, a store + * operation truncates, or for multi-register operations. + */ + int16_t mem_off_first[2]; + int16_t reg_off_first[2]; + int16_t reg_off_last[2]; + + /* + * One element that is misaligned and spans both pages, + * or -1 if there is no such active element. + */ + int16_t mem_off_split; + int16_t reg_off_split; + + /* + * The byte offset at which the entire operation crosses a page bounda= ry. + * Set >=3D 0 if and only if the entire operation spans two pages. + */ + int16_t page_split; + + /* TLB data for the two pages. */ + SVEHostPage page[2]; +} SVEContLdSt; + +/* + * Find first active element on each page, and a loose bound for the + * final element on each page. Identify any single element that spans + * the page boundary. Return true if there are any active elements. + */ +bool sve_cont_ldst_elements(SVEContLdSt *info, target_ulong addr, uint64_t= *vg, + intptr_t reg_max, int esz, int msize); + +/* + * Resolve the guest virtual addresses to info->page[]. + * Control the generation of page faults with @fault. Return false if + * there is no work to do, which can only happen with @fault =3D=3D FAULT_= NO. + */ +bool sve_cont_ldst_pages(SVEContLdSt *info, SVEContFault fault, + CPUARMState *env, target_ulong addr, + MMUAccessType access_type, uintptr_t retaddr); + +#ifdef CONFIG_USER_ONLY +static inline void +sve_cont_ldst_watchpoints(SVEContLdSt *info, CPUARMState *env, uint64_t *v= g, + target_ulong addr, int esize, int msize, + int wp_access, uintptr_t retaddr) +{ } +#else +void sve_cont_ldst_watchpoints(SVEContLdSt *info, CPUARMState *env, + uint64_t *vg, target_ulong addr, + int esize, int msize, int wp_access, + uintptr_t retaddr); +#endif + +void sve_cont_ldst_mte_check(SVEContLdSt *info, CPUARMState *env, uint64_t= *vg, + target_ulong addr, int esize, int msize, + uint32_t mtedesc, uintptr_t ra); + #endif /* TARGET_ARM_SVE_LDST_INTERNAL_H */ diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c index 0c6dde00aa6..8cd371e3e37 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -5341,16 +5341,9 @@ static intptr_t find_next_active(uint64_t *vg, intpt= r_t reg_off, * exit via page fault exception. */ =20 -typedef struct { - void *host; - int flags; - MemTxAttrs attrs; -} SVEHostPage; - -static bool sve_probe_page(SVEHostPage *info, bool nofault, - CPUARMState *env, target_ulong addr, - int mem_off, MMUAccessType access_type, - int mmu_idx, uintptr_t retaddr) +bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env, + target_ulong addr, int mem_off, MMUAccessType access_t= ype, + int mmu_idx, uintptr_t retaddr) { int flags; =20 @@ -5406,59 +5399,13 @@ static bool sve_probe_page(SVEHostPage *info, bool = nofault, return true; } =20 - -/* - * Analyse contiguous data, protected by a governing predicate. - */ - -typedef enum { - FAULT_NO, - FAULT_FIRST, - FAULT_ALL, -} SVEContFault; - -typedef struct { - /* - * First and last element wholly contained within the two pages. - * mem_off_first[0] and reg_off_first[0] are always set >=3D 0. - * reg_off_last[0] may be < 0 if the first element crosses pages. - * All of mem_off_first[1], reg_off_first[1] and reg_off_last[1] - * are set >=3D 0 only if there are complete elements on a second page. - * - * The reg_off_* offsets are relative to the internal vector register. - * The mem_off_first offset is relative to the memory address; the - * two offsets are different when a load operation extends, a store - * operation truncates, or for multi-register operations. - */ - int16_t mem_off_first[2]; - int16_t reg_off_first[2]; - int16_t reg_off_last[2]; - - /* - * One element that is misaligned and spans both pages, - * or -1 if there is no such active element. - */ - int16_t mem_off_split; - int16_t reg_off_split; - - /* - * The byte offset at which the entire operation crosses a page bounda= ry. - * Set >=3D 0 if and only if the entire operation spans two pages. - */ - int16_t page_split; - - /* TLB data for the two pages. */ - SVEHostPage page[2]; -} SVEContLdSt; - /* * Find first active element on each page, and a loose bound for the * final element on each page. Identify any single element that spans * the page boundary. Return true if there are any active elements. */ -static bool sve_cont_ldst_elements(SVEContLdSt *info, target_ulong addr, - uint64_t *vg, intptr_t reg_max, - int esz, int msize) +bool sve_cont_ldst_elements(SVEContLdSt *info, target_ulong addr, uint64_t= *vg, + intptr_t reg_max, int esz, int msize) { const int esize =3D 1 << esz; const uint64_t pg_mask =3D pred_esz_masks[esz]; @@ -5548,9 +5495,9 @@ static bool sve_cont_ldst_elements(SVEContLdSt *info,= target_ulong addr, * Control the generation of page faults with @fault. Return false if * there is no work to do, which can only happen with @fault =3D=3D FAULT_= NO. */ -static bool sve_cont_ldst_pages(SVEContLdSt *info, SVEContFault fault, - CPUARMState *env, target_ulong addr, - MMUAccessType access_type, uintptr_t retad= dr) +bool sve_cont_ldst_pages(SVEContLdSt *info, SVEContFault fault, + CPUARMState *env, target_ulong addr, + MMUAccessType access_type, uintptr_t retaddr) { int mmu_idx =3D cpu_mmu_index(env, false); int mem_off =3D info->mem_off_first[0]; @@ -5606,12 +5553,12 @@ static bool sve_cont_ldst_pages(SVEContLdSt *info, = SVEContFault fault, return have_work; } =20 -static void sve_cont_ldst_watchpoints(SVEContLdSt *info, CPUARMState *env, - uint64_t *vg, target_ulong addr, - int esize, int msize, int wp_access, - uintptr_t retaddr) -{ #ifndef CONFIG_USER_ONLY +void sve_cont_ldst_watchpoints(SVEContLdSt *info, CPUARMState *env, + uint64_t *vg, target_ulong addr, + int esize, int msize, int wp_access, + uintptr_t retaddr) +{ intptr_t mem_off, reg_off, reg_last; int flags0 =3D info->page[0].flags; int flags1 =3D info->page[1].flags; @@ -5667,12 +5614,12 @@ static void sve_cont_ldst_watchpoints(SVEContLdSt *= info, CPUARMState *env, } while (reg_off & 63); } while (reg_off <=3D reg_last); } -#endif } +#endif =20 -static void sve_cont_ldst_mte_check(SVEContLdSt *info, CPUARMState *env, - uint64_t *vg, target_ulong addr, int e= size, - int msize, uint32_t mtedesc, uintptr_t= ra) +void sve_cont_ldst_mte_check(SVEContLdSt *info, CPUARMState *env, + uint64_t *vg, target_ulong addr, int esize, + int msize, uint32_t mtedesc, uintptr_t ra) { intptr_t mem_off, reg_off, reg_last; =20 --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654771105; cv=none; d=zohomail.com; s=zohoarc; b=NkqeTKeNk1oiUzqiYyaTUbr/kIfzhDMK5QIp64FLQ190TqxRq96jScGCtH49VIV427KcvNCeLs0JTUuoVccb1WnRX9OP6v6LfAcS77nDmys5hSWS0masBbpaivFBYW5WJPE/mdHhOVwP8DNTLKTamOxOrtwbYeX6Zn7h8yAILfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654771105; 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=A14QxFs16bLONsVCSDgKLzSud5B5D6SZ03whQ20bd3w=; b=f+srPT+0h/A+bAh+G6sK7/BkEjN5XjLS3m7zIHqO4FfPPUTjPNOyA8gTgLA7zDpKuOvzt3E0ApNdx3l/+chUCu30bpY48auDPSyO/BpNwKni4H0NLyJdfrMnhCM7y2CbIltUborV51zD0IehILEFq9hdIF6nBydC5KLosJuTvWc= 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 1654771105302167.21419801039656; Thu, 9 Jun 2022 03:38:25 -0700 (PDT) Received: from localhost ([::1]:50974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFYV-0004pQ-RS for importer@patchew.org; Thu, 09 Jun 2022 06:38:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7f-0001k9-Jm for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:35 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:43557) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7d-00062u-O4 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:35 -0400 Received: by mail-wr1-x42e.google.com with SMTP id d14so22478158wra.10 for ; Thu, 09 Jun 2022 02:06:33 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=A14QxFs16bLONsVCSDgKLzSud5B5D6SZ03whQ20bd3w=; b=CggcEqGcQmo4V+zqyGuGh0OrHns6C2kvXM732Ca0W6lPCoxIM0XF/QQTx7orla1dlS iCoI3LkbK2LHZ0m5gV8v7aNMmxnw//aJPYJwS7dc9f8KvDYNGWl87EFFQWNrbYL4NEk3 wOCHGZCWYAKB460pdWCn2tqhrz9096rmLXlnld4yDryeW3+fiH1TdaS205ubXCPd4Y0Z Li9exE0QUcRS8VnhJYCgz6hZUJtapy/c5UkH7+iT5rDzTAcfs3DQ/XG8wV/H+HyE3LxK B8VvPMV2ut3xKAYncRBmWpnUXIKNa8DGV5oRswrhwzOn4toKTsHtKPhLu+1Ak4NaCJMD JWRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A14QxFs16bLONsVCSDgKLzSud5B5D6SZ03whQ20bd3w=; b=rAKucWDceyQ9uWls2Fdv+ng9pciwjYgmj1uXYA+Rjy38qJLqI4KrOQiK576jA9OX8O 9P3M3p/neetcPUYzcU9hukL3/FxNpLH1dix9I0sTV3ZBIjkcMBTEfkiJwp0tB6w1wWzQ netDeqK+YgMd3ihIcx+jBjQbQ5XDdIlpR1//tq2iPfeCZ7cwHnwPPXospzT/btZCYHo/ 6vAYqGLwd+EXhVRj7s1N5WeRzIwYfd4LGX202U/RWaX77QzDyhLi7vWhMVFw8pW9ODfc 7L6XzOIZEVCre71pyhe6JhbvrTjKskHnkAVwrLtm6Gk1eCrW9i/mY8OZikVhOSPFSwO9 7G5Q== X-Gm-Message-State: AOAM533gXK/ogNfgMMHnJHn16K8xA9Zc4bCoGNnjvnnQp+WtuGGQ8VoX hb5Ol0Fyza4/NnUri4A3JCQMbzyeKhBMuA== X-Google-Smtp-Source: ABdhPJyDYxr57yHj56c8tb/KvvKQvKCR16vHsUUzT6bekffpeBxp1u38mWphBarfSf7L3z5swcDbfg== X-Received: by 2002:a05:6000:168c:b0:218:4523:c975 with SMTP id y12-20020a056000168c00b002184523c975mr17911740wrd.23.1654765593007; Thu, 09 Jun 2022 02:06:33 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 50/55] target/arm: Move expand_pred_b to vec_internal.h Date: Thu, 9 Jun 2022 10:05:32 +0100 Message-Id: <20220609090537.1971756-51-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654771107177100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Put the inline function near the array declaration. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-16-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/vec_internal.h | 8 +++++++- target/arm/sve_helper.c | 9 --------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/target/arm/vec_internal.h b/target/arm/vec_internal.h index 1d63402042f..d1a1ea4a668 100644 --- a/target/arm/vec_internal.h +++ b/target/arm/vec_internal.h @@ -50,8 +50,14 @@ #define H8(x) (x) #define H1_8(x) (x) =20 -/* Data for expanding active predicate bits to bytes, for byte elements. */ +/* + * Expand active predicate bits to bytes, for byte elements. + */ extern const uint64_t expand_pred_b_data[256]; +static inline uint64_t expand_pred_b(uint8_t byte) +{ + return expand_pred_b_data[byte]; +} =20 static inline void clear_tail(void *vd, uintptr_t opr_sz, uintptr_t max_sz) { diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c index 8cd371e3e37..e865c125273 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -103,15 +103,6 @@ uint32_t HELPER(sve_predtest)(void *vd, void *vg, uint= 32_t words) return flags; } =20 -/* - * Expand active predicate bits to bytes, for byte elements. - * (The data table itself is in vec_helper.c as MVE also needs it.) - */ -static inline uint64_t expand_pred_b(uint8_t byte) -{ - return expand_pred_b_data[byte]; -} - /* Similarly for half-word elements. * for (i =3D 0; i < 256; ++i) { * unsigned long m =3D 0; --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654773273; cv=none; d=zohomail.com; s=zohoarc; b=GTxNJocMaeiJe4fJSsImYYVbFEgNtfhobhXonlqjTWYXge6V/nnbMAqOpkeI++joIkIQdnGBcCpRQge/hBFxHb2FZxzcVEgeLLWZa4fcMv8YBWK/tOKYo2V9WD/KVBaPSgljMEGyW6l1Wp9EI+Xoc9LHFVgPxBfG3JWz+Avh4CM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654773273; 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=cex5x9L9Gl/d10/8cuiaJvgz9NAjknIKjSgIAlTWGEg=; b=cM0dFJR8yW5ONPtYfiFWjD9wNtSJtaVl/INuNMm9ws3q2LsLo7qoL5jg1rJHGiNtKyoZLLAujKJTkC6NidAQtgwQK+qhPL+nG8yBmFlpObxAPngJXootUin6AsEGuxFEx54O0xy1vYePwQVk47iwk0nWziBMs2WxnEceWgD/rhc= 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 1654773273280375.25210799188255; Thu, 9 Jun 2022 04:14:33 -0700 (PDT) Received: from localhost ([::1]:39608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzG7U-0005N9-4Y for importer@patchew.org; Thu, 09 Jun 2022 07:14:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7r-0001sd-4j for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:48 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:42899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7e-00060y-O5 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:46 -0400 Received: by mail-wr1-x432.google.com with SMTP id s1so8358409wra.9 for ; Thu, 09 Jun 2022 02:06:34 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=cex5x9L9Gl/d10/8cuiaJvgz9NAjknIKjSgIAlTWGEg=; b=UO2hkPROv7vuihUX1utcuWVxNMFTDbgBcFfusZtlQkk/9VhAHIEPABTXoV/A5CdH/D xNSeL/bjHkW+0kDIXRX//0+CLnXbOUuB2k+E6XPdtgdr5yvVUlrshc9QSsZ2/pFhn+DU GlXdGda5k3fB3/hMbhImuDEcy0Ms3m+dKl+xxKABfbrdOgQQhlpJ0YVyI4herbssA5SW fkaJUmAdR5gQcLYKjb4DCshJAapMuVKAsX+UljFmxD6phzkNV5WVAGFg6G/ZUsja7uD/ w5qWP2gmUCsGD/H14t6ZuO3+ilobOvLwpiRZJCeNvtN6P1tIOz/xxfdLIxBVCSXXDean C6QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cex5x9L9Gl/d10/8cuiaJvgz9NAjknIKjSgIAlTWGEg=; b=GFOM9rLypc2/QpYdnYgPq7GaC/vMpd1xXezbyOEOFCnDUAnHVTxK0sRoCt+fRIJ79L XzlOiYuZ4AzRN/23qrbO+LwrN0Wlfza7Saun7PEV2fpR7fWyO5F5SL0V1/4DMQMtx5tG 7fvjQWar7DjbI1xigE789KZqX91NZio+FsymP4DaNeo2jyM4NrBMpqR17vm6nl58rGzt 0OYXMBRkSQO1vYe3qmwOl1iRx3klNW63dP37FUoZxnnuaY3aD/WTj5xmlv+eTDTKqD3b /FQZMW/3+aiB1h9vGNYISak+zZMFy1EwXuMfPGdMg+HWYMF7uxWkSJRqXbK6Rjy6h9dT N1HA== X-Gm-Message-State: AOAM532cg53Y0Uv6tQNvZIGXTo+fL+mmc9IgdQ4ovchzyT+Lf3jdNYLg l2k1fl8gFIdYXvrjn/p2AxLEDdjAmyForQ== X-Google-Smtp-Source: ABdhPJzE1wj6FzplAvBiqXD8n3X5c1cXwuh8cu53+lX98E6iA8ESpOkPEC0YwOnrk7Aae8mDCBtd1Q== X-Received: by 2002:a5d:5222:0:b0:213:b7f7:58fe with SMTP id i2-20020a5d5222000000b00213b7f758femr31629529wra.620.1654765593905; Thu, 09 Jun 2022 02:06:33 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 51/55] target/arm: Use expand_pred_b in mve_helper.c Date: Thu, 9 Jun 2022 10:05:33 +0100 Message-Id: <20220609090537.1971756-52-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654773274447100003 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Use the function instead of the array directly. Because the function performs its own masking, via the uint8_t parameter, we need to do nothing extra within the users: the bits above the first 2 (_uh) or 4 (_uw) will be discarded by assignment to the local bmask variables, and of course _uq uses the entire uint64_t result. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-17-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/mve_helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c index 846962bf4c5..403b345ea3b 100644 --- a/target/arm/mve_helper.c +++ b/target/arm/mve_helper.c @@ -726,7 +726,7 @@ static void mergemask_sb(int8_t *d, int8_t r, uint16_t = mask) =20 static void mergemask_uh(uint16_t *d, uint16_t r, uint16_t mask) { - uint16_t bmask =3D expand_pred_b_data[mask & 3]; + uint16_t bmask =3D expand_pred_b(mask); *d =3D (*d & ~bmask) | (r & bmask); } =20 @@ -737,7 +737,7 @@ static void mergemask_sh(int16_t *d, int16_t r, uint16_= t mask) =20 static void mergemask_uw(uint32_t *d, uint32_t r, uint16_t mask) { - uint32_t bmask =3D expand_pred_b_data[mask & 0xf]; + uint32_t bmask =3D expand_pred_b(mask); *d =3D (*d & ~bmask) | (r & bmask); } =20 @@ -748,7 +748,7 @@ static void mergemask_sw(int32_t *d, int32_t r, uint16_= t mask) =20 static void mergemask_uq(uint64_t *d, uint64_t r, uint16_t mask) { - uint64_t bmask =3D expand_pred_b_data[mask & 0xff]; + uint64_t bmask =3D expand_pred_b(mask); *d =3D (*d & ~bmask) | (r & bmask); } =20 --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654771463; cv=none; d=zohomail.com; s=zohoarc; b=liGsgZuEFVuQ08tFhVsqyXItoRBt+txiSEc1WiGMWwsZZJTY10+Nr951G91hr1nOSomhPSNAZd/XysMizD0QELcf0WISVF3jLpyd7tqfE7tVTKealrDyUF7B6VrR4mX691+BBeKOJpHrrlW3l2rZwgflCNpizcSCMobN6yHyP5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654771463; 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=4FBoJtD8BnTfjL+tOQoIkqKssw+9QYDFG8qS913t+NY=; b=SiJyav7NWmlu+wwXz8Xnb3He5UlZ02e+J6GU2P4KgO45IqTsEJbF3IuzuMDSlRIsKMezvPcX2SfPM4HH9OnF8+g4BEXsmkZckFqClc6kZEEICG/Lzaeo3vftI4TIe9Nu6k7k5jiWToepv5GAv9uQPzGLArUmE2poyvsFTP1Ndek= 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 1654771463516531.4835688959616; Thu, 9 Jun 2022 03:44:23 -0700 (PDT) Received: from localhost ([::1]:33576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFeH-0003rU-Sj for importer@patchew.org; Thu, 09 Jun 2022 06:44:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7i-0001n7-Rz for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:39 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:37403) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7h-0006Ag-7h for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:38 -0400 Received: by mail-wr1-x431.google.com with SMTP id m26so20034092wrb.4 for ; Thu, 09 Jun 2022 02:06:35 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=4FBoJtD8BnTfjL+tOQoIkqKssw+9QYDFG8qS913t+NY=; b=xKIotShL64D8PEfdIrqMlXsxd5HmVnVtykYliXYfUptdaBS5C2G+PJcnwQT3o4HdnA TOLKDotN64G8hWxzR+6zCYOcMDzDZF4hSqgDO3F3+yAP4KmWfmDlsuJ4/I9uoJEKV3hs OfvhY+1ntTTHd8J0WB0ewXowOnBtNL2XupBc0MZtGesLUZIjTvbR6f/fq8WT6n0cA1Wx U72jhl/nv6eZbrzooxp4SMpIX7A3ICIjUahCTDlycPJEqoBLeA7Fc9diAJ3OunYPaWtJ IAmDIZdK/JGvyLqX2cp6QqbGSj5kg05DW8I9YguJodcnt4wXRJVNfaNAhAJtJ6U0jluJ jcMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4FBoJtD8BnTfjL+tOQoIkqKssw+9QYDFG8qS913t+NY=; b=Zq9KgKP6VC3eR7Y2PyrgtQHSwcrNiCQU80685YqYvq46dk1Kjmdc/AaOGZTn1K6C8u rupHY5lzMWlUR4+sNGh2dI1pjTsnYCdUQnNJc2UUa949s+BAFQ5wysOtwXGOpOG1p7K4 PIaOoAewVCynaD6rKse/PwLVl9D3/k56rfrMQVeWiW7WautTeAEGjpP3Alnz6ufEp2u/ PH+Nw5onCu97RUWA9fXVyjZrviAhOSeJV3uZrg3uQhOuj1ae0RqiOaSi8FdrWL8fOQiM SGAkeg1rcRSNw4W4bWUinst5MziVMmkeEOPrINHow0ywm3b/4ys7vXakD2TrDrzv/d0N sY4A== X-Gm-Message-State: AOAM5316xU6gvErNZ9AWE/5NeTn6aqi+0/xR7jZLFs9kd0ZJibsKkCMm FkcSVZ4gg3vL92FNVnI4K8PaDwEWvlNoZQ== X-Google-Smtp-Source: ABdhPJwJ+hM+N1lNCI15EPNwgGwzJJ8VBN6lmIa9lfZ06W4B+awsA/NLbRRPTnIiyxKOEUpCD5QFwA== X-Received: by 2002:adf:c64c:0:b0:20f:e8f0:be4c with SMTP id u12-20020adfc64c000000b0020fe8f0be4cmr37253756wrg.614.1654765594780; Thu, 09 Jun 2022 02:06:34 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 52/55] target/arm: Move expand_pred_h to vec_internal.h Date: Thu, 9 Jun 2022 10:05:34 +0100 Message-Id: <20220609090537.1971756-53-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::431; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x431.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654771464983100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Move the data to vec_helper.c and the inline to vec_internal.h. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-18-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/vec_internal.h | 7 +++++++ target/arm/sve_helper.c | 29 ----------------------------- target/arm/vec_helper.c | 26 ++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/target/arm/vec_internal.h b/target/arm/vec_internal.h index d1a1ea4a668..1d527fadac1 100644 --- a/target/arm/vec_internal.h +++ b/target/arm/vec_internal.h @@ -59,6 +59,13 @@ static inline uint64_t expand_pred_b(uint8_t byte) return expand_pred_b_data[byte]; } =20 +/* Similarly for half-word elements. */ +extern const uint64_t expand_pred_h_data[0x55 + 1]; +static inline uint64_t expand_pred_h(uint8_t byte) +{ + return expand_pred_h_data[byte & 0x55]; +} + static inline void clear_tail(void *vd, uintptr_t opr_sz, uintptr_t max_sz) { uint64_t *d =3D vd + opr_sz; diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c index e865c125273..1654c0bbf9e 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -103,35 +103,6 @@ uint32_t HELPER(sve_predtest)(void *vd, void *vg, uint= 32_t words) return flags; } =20 -/* Similarly for half-word elements. - * for (i =3D 0; i < 256; ++i) { - * unsigned long m =3D 0; - * if (i & 0xaa) { - * continue; - * } - * for (j =3D 0; j < 8; j +=3D 2) { - * if ((i >> j) & 1) { - * m |=3D 0xfffful << (j << 3); - * } - * } - * printf("[0x%x] =3D 0x%016lx,\n", i, m); - * } - */ -static inline uint64_t expand_pred_h(uint8_t byte) -{ - static const uint64_t word[] =3D { - [0x01] =3D 0x000000000000ffff, [0x04] =3D 0x00000000ffff0000, - [0x05] =3D 0x00000000ffffffff, [0x10] =3D 0x0000ffff00000000, - [0x11] =3D 0x0000ffff0000ffff, [0x14] =3D 0x0000ffffffff0000, - [0x15] =3D 0x0000ffffffffffff, [0x40] =3D 0xffff000000000000, - [0x41] =3D 0xffff00000000ffff, [0x44] =3D 0xffff0000ffff0000, - [0x45] =3D 0xffff0000ffffffff, [0x50] =3D 0xffffffff00000000, - [0x51] =3D 0xffffffff0000ffff, [0x54] =3D 0xffffffffffff0000, - [0x55] =3D 0xffffffffffffffff, - }; - return word[byte & 0x55]; -} - /* Similarly for single word elements. */ static inline uint64_t expand_pred_s(uint8_t byte) { diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c index 17fb1583622..26c373e522f 100644 --- a/target/arm/vec_helper.c +++ b/target/arm/vec_helper.c @@ -127,6 +127,32 @@ const uint64_t expand_pred_b_data[256] =3D { 0xffffffffffffffff, }; =20 +/* + * Similarly for half-word elements. + * for (i =3D 0; i < 256; ++i) { + * unsigned long m =3D 0; + * if (i & 0xaa) { + * continue; + * } + * for (j =3D 0; j < 8; j +=3D 2) { + * if ((i >> j) & 1) { + * m |=3D 0xfffful << (j << 3); + * } + * } + * printf("[0x%x] =3D 0x%016lx,\n", i, m); + * } + */ +const uint64_t expand_pred_h_data[0x55 + 1] =3D { + [0x01] =3D 0x000000000000ffff, [0x04] =3D 0x00000000ffff0000, + [0x05] =3D 0x00000000ffffffff, [0x10] =3D 0x0000ffff00000000, + [0x11] =3D 0x0000ffff0000ffff, [0x14] =3D 0x0000ffffffff0000, + [0x15] =3D 0x0000ffffffffffff, [0x40] =3D 0xffff000000000000, + [0x41] =3D 0xffff00000000ffff, [0x44] =3D 0xffff0000ffff0000, + [0x45] =3D 0xffff0000ffffffff, [0x50] =3D 0xffffffff00000000, + [0x51] =3D 0xffffffff0000ffff, [0x54] =3D 0xffffffffffff0000, + [0x55] =3D 0xffffffffffffffff, +}; + /* Signed saturating rounding doubling multiply-accumulate high half, 8-bi= t */ int8_t do_sqrdmlah_b(int8_t src1, int8_t src2, int8_t src3, bool neg, bool round) --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654771764; cv=none; d=zohomail.com; s=zohoarc; b=WyTS4zcfjspPDSfh01XqqWgVAiDCsgneDYqO5ZiawMxxjseATyAS1mC4mPuZoiqbwx4m6pdnFn+tlySAMBTo51ikIlEZldAVwbX1+LSE4tswzjbAYjZj0hqNxZeGSV6VSry4Pl5b4T3AlfuyiF2M2R68ffWdXawnCLr4W+z0tUQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654771764; 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=O7gtIRaRwJ71mlo9jIWS+jCv56ddk4eH5DIeQnFasaQ=; b=NncG/EBT5W05/5+120IzLudpjEhYe2moOBfYe+MlcncrUWQ6vpvuwWxiGinDCkYh9Mprza0VBB8H8sRQypopBzk6ArUQaHu+1GlvFuHBW6L56okWur44KPTyqnSi2lbkR+ImEs+lQinDMrV8qpS1iRsLWA4hvgR9eypk1OdiXEw= 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 1654771764169489.9107558885843; Thu, 9 Jun 2022 03:49:24 -0700 (PDT) Received: from localhost ([::1]:41976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzFj8-0001RW-NC for importer@patchew.org; Thu, 09 Jun 2022 06:49:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40068) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7j-0001oG-D9 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:39 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:37679) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7h-0006Aw-U3 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:39 -0400 Received: by mail-wm1-x32c.google.com with SMTP id o37-20020a05600c512500b0039c4ba4c64dso6599170wms.2 for ; Thu, 09 Jun 2022 02:06:37 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=O7gtIRaRwJ71mlo9jIWS+jCv56ddk4eH5DIeQnFasaQ=; b=KzIbGgrv+MHSOzOSIpha96OMEANSnHNIm24FO600IBYEUbg0anhsRIar2ylD9x1A7s 6M7cENNhORciRZZxn46A/ievk+fjUzkvKbaqmRNa6raQF93ZQUDvvHApiJkcNgmcQ6q5 itqJjiYv3vmTl3Pw5c1+hKtYWxIEPUzT/9EBkIFLrCiBegFbxMi4K//RUmABfsv2gkxJ pfN9BTFn3sSwRkw+e5pkPpJB2wKvCHZjb+82NjfjTLYUzJhKbhm+BVqFbxC8AtgRccnA J3LC+c7E/fwsjTgimgEac0pf2T6vMDB4AN2J0PTwooGWd3SmGbrF9gUWhmYOsCVHXLEu yGnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O7gtIRaRwJ71mlo9jIWS+jCv56ddk4eH5DIeQnFasaQ=; b=TQ0a0mys14iihJ5Avf5Y6QG4eA3HjIsfIfYhJPzHLJKthAxgN3/KnfGhPCPNbvxnih 5URLIVU1DqssPqGxLmzLODh4eA8jMokFl+a5w5A7aM7rYVV3oPwnyCWHHFrUQgRdXy2p Tnwca94tb6TdDqEtdzqos4uDeXgvt1/jUAudWCdV/jM0rOQtJFHkdHBJRNLXRmtw7U/N DUd2orQLqs0Ejag4iPMFbPpVY/0d00lOzbvFuJZjsDefrA6OcWm9hR3phlckhPPVetNE 7CMHf2zTeEMj2WUHxcVTE9/zPhxHmbLHMb9PKvVe01ngRKh7yiBtVJUkE5V9FmOXeijZ Wddw== X-Gm-Message-State: AOAM533AwYkRoLOgkjzXoi8ZEXQJnpKAYUJdddN1q5nT81HJ4flMqtXG JFW66IZLFSiRSOymwyjjq1ser2myFS5Mxg== X-Google-Smtp-Source: ABdhPJy7mwQMnDUEHcZd23Frp5+wD8g4i2RaHrhFaP56IVp/Qlfj9W2tDiReZLc/E+VxxNejGWvWYA== X-Received: by 2002:a05:600c:3503:b0:39c:65e0:c070 with SMTP id h3-20020a05600c350300b0039c65e0c070mr2227755wmq.161.1654765595611; Thu, 09 Jun 2022 02:06:35 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 53/55] target/arm: Export bfdotadd from vec_helper.c Date: Thu, 9 Jun 2022 10:05:35 +0100 Message-Id: <20220609090537.1971756-54-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654771766660100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson We will need this over in sme_helper.c. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-19-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/vec_internal.h | 13 +++++++++++++ target/arm/vec_helper.c | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/target/arm/vec_internal.h b/target/arm/vec_internal.h index 1d527fadac1..1f4ed80ff76 100644 --- a/target/arm/vec_internal.h +++ b/target/arm/vec_internal.h @@ -230,4 +230,17 @@ uint64_t pmull_h(uint64_t op1, uint64_t op2); */ uint64_t pmull_w(uint64_t op1, uint64_t op2); =20 +/** + * bfdotadd: + * @sum: addend + * @e1, @e2: multiplicand vectors + * + * BFloat16 2-way dot product of @e1 & @e2, accumulating with @sum. + * The @e1 and @e2 operands correspond to the 32-bit source vector + * slots and contain two Bfloat16 values each. + * + * Corresponds to the ARM pseudocode function BFDotAdd. + */ +float32 bfdotadd(float32 sum, uint32_t e1, uint32_t e2); + #endif /* TARGET_ARM_VEC_INTERNAL_H */ diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c index 26c373e522f..9a9c034e36f 100644 --- a/target/arm/vec_helper.c +++ b/target/arm/vec_helper.c @@ -2557,7 +2557,7 @@ DO_MMLA_B(gvec_usmmla_b, do_usmmla_b) * BFloat16 Dot Product */ =20 -static float32 bfdotadd(float32 sum, uint32_t e1, uint32_t e2) +float32 bfdotadd(float32 sum, uint32_t e1, uint32_t e2) { /* FPCR is ignored for BFDOT and BFMMLA. */ float_status bf_status =3D { --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654772835; cv=none; d=zohomail.com; s=zohoarc; b=UQ2JpwR4mKK+eqSDRaTb18ttohPOClpvEj47+dqhdXsdMtQ3kDg8cCaRnD+SoqyDIhA4MqB/WLA49KtllT8xZ4+qDRK7tsx/xqrwf7jk5gyOGg2RZ33Kn86nGIJMDfo46FfVwn7Kx0MsAkDu7lmvNTW4EUhRx3p09qLz9ByN9L4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654772835; 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=ZDzwoFqQkyUODGOZytKyrO2zzhN95wbOXNg0vdTc5XQ=; b=V6zWWr9m1kOBHOW5dNEa6cKFh7XpLV74FEd4lAenct3EOqEK7744jkzbErzzBj4NowmTRW7GdIhnshmjPaVtvuqty30Tdutwy5xrxREwfjTZhdgYX278zI4zZeKoE8c84nUNQhgCN4qLu8fXMhheRS7v720Cw1KZ8LzU8VaQx3o= 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 1654772835185356.81840797662005; Thu, 9 Jun 2022 04:07:15 -0700 (PDT) Received: from localhost ([::1]:59350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzG0Q-0006mH-4e for importer@patchew.org; Thu, 09 Jun 2022 07:07:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7o-0001rX-50 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:44 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:53920) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7i-0006BK-O3 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:43 -0400 Received: by mail-wm1-x331.google.com with SMTP id z9so5330625wmf.3 for ; Thu, 09 Jun 2022 02:06:37 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ZDzwoFqQkyUODGOZytKyrO2zzhN95wbOXNg0vdTc5XQ=; b=MObO/wfYFRd9V8SBfrCe3zeKzYWbPisVcnsfpRig3h/RGW2oxZ5pibjqvHuZEw5POB L7/KfM2jso5mszakTB80q3fPOPbyb8ZNuWiJ1mT63JqkAvIsZMp7/oJcq5VhMQVSupuj SVpGUs2WmKlrzSeodFPYvbFrjgKgEP6YIEhtDDutU05xRdzApX+boWSoDcSWbn2f8I+w bugYye20JucZiKZqfUrdK4NPxAnCWguYbAINx77iYjpx/r9ck+F9BUVkpGh2SxxSUx2B 27DQf3ObZ1TxkeBIvzwQHXaw7cixqriVOsEK7wi/OuJ0EfPX/v+n0uyGbyOfuMn9RmQO pQUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZDzwoFqQkyUODGOZytKyrO2zzhN95wbOXNg0vdTc5XQ=; b=k89JxNRW/le4Jhe5f+Q5oXqceypxD5YJEW08XssPsIX0piLi7kDbDvpTthLUSHtIoW TIyegCx8oADD0TOjY/o8zPnd2nXDAwk9vwX0A3jUjOtoceFd+GKAk7/HTtwEc15fLUA6 vdtiFyVPriJgmbeHwlpR2E1ZHeh1YjuM//cD/VHfeUW9Zcu2ZFxu+4O1z41e//k41vqb 6Bib1F4Ia9gIG5RJFJWNBcE8lTfq+k+bwqyGXCCeBjtoL05pCYBX+qcUivSHy5Ju9nVP viRifefHwEVW1PaNnFQ4biIEtZIEo86BhcYlbKknYItALS67v/Iez4f1PXQ8hxMYJVF+ m+7Q== X-Gm-Message-State: AOAM530aVCtAQsLJYSGYV7w0y83F4AG0EFI4cX2yLQQXwd/qWeGRB6pO +D5agPbUtlqFd6WIpMQdxt91iknH+PDsrA== X-Google-Smtp-Source: ABdhPJy2nU75B6bitV2nDgfouvimkdJLozQsFceW8B92tpuv8AKk9pVQJsLNIhH8Ffp+Q5EajWXsPQ== X-Received: by 2002:a05:600c:1ca5:b0:39b:a66b:7805 with SMTP id k37-20020a05600c1ca500b0039ba66b7805mr2143187wms.87.1654765596499; Thu, 09 Jun 2022 02:06:36 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 54/55] target/arm: Add isar_feature_aa64_sme Date: Thu, 9 Jun 2022 10:05:36 +0100 Message-Id: <20220609090537.1971756-55-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654772836684100003 Content-Type: text/plain; charset="utf-8" From: Richard Henderson This will be used for implementing FEAT_SME. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-20-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index e45b5cb7fe1..2e6153c5409 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -4048,6 +4048,11 @@ static inline bool isar_feature_aa64_mte(const ARMIS= ARegisters *id) return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, MTE) >=3D 2; } =20 +static inline bool isar_feature_aa64_sme(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SME) !=3D 0; +} + static inline bool isar_feature_aa64_pmu_8_1(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) >=3D 4 && --=20 2.25.1 From nobody Thu Jun 13 22:28:29 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=1654776204; cv=none; d=zohomail.com; s=zohoarc; b=e6YjsFE2WkXsR91bzscHzrBffUyjDj2DyU5T+fv3rBGRi3yXckWB/el/9+ZtE0wAu1de4oCl+/tljyp1kUF8gKnak3usuJiIdX6qioaa5IneAVOMSW7pcj9pcut2L+RIp4NuCEzh/LfERvQA9jpt6oLRfmXoO4ia0A89UBZH/+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654776204; 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=AJUvIhNABE7+bpF4sZrKJZdKNVK1oDZ/5Hrds64VDKo=; b=NebYOJa4lKxvawXXqHqN+douEk8K0wsnOTrXnxv9yB8qlLRxtYvh1P5JF9phxGZ5YP9uVvcBGEr67jo67/BXshXnnPPh+8NVSUXDeb8sQh4vMPwxPbrikLZAj5QzyE6mOfQuXUOPnCEWOuEhGhrDO9vL1edjuFwXLAZ6zwMDc5A= 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 1654776204422566.8472868998564; Thu, 9 Jun 2022 05:03:24 -0700 (PDT) Received: from localhost ([::1]:53400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzGsl-0004sh-AZ for importer@patchew.org; Thu, 09 Jun 2022 08:03:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7k-0001oz-A9 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:40 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:33709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7i-00063a-9r for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:40 -0400 Received: by mail-wr1-x433.google.com with SMTP id h5so31518410wrb.0 for ; Thu, 09 Jun 2022 02:06:37 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=AJUvIhNABE7+bpF4sZrKJZdKNVK1oDZ/5Hrds64VDKo=; b=yCJDWWLBX8grHJ4kdbYX8pcy0jMpbW6pyqvqAWJedSJ+mPEfUKYOEH1kqqbSNGVx4T xwxRPLIvaRUibpw9yCDXsHI/pB6kqmsqsvVosbZcF0WnG6vIdfeoLuKs4qxL9Np0VVC9 IRcYo2C1b3keoWXeTMdLPcTX4acK3xdxO6lzy1Avubv7vLUfxve+DMC0lNjEqNEmucYU LXXJRZpVnUi9t9vFnoS480ZM0iyua1Fzx7aInfz3sVpe90n6bvvuGC+EkMry04G4g2V+ mBFv+IfaRRsivsiFlrgARm4PhEzPJGMDResMrgeNStsMCZIz6RbGeMRs1OPMRPjD1k/h 6+yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AJUvIhNABE7+bpF4sZrKJZdKNVK1oDZ/5Hrds64VDKo=; b=ErzC7E2acdr1kCcFD6MkpZdWIqs2ETLDHTbbW19oIp4HuI9IJSsKbe/9fa+YKPYd4H LPxw4e874y/jLJqh/j630ZUMN9ORV/R5WwwBcEWFJCCrGrVh0njAt/q6nQJLp+tTI8ed uyf4pCs2SJPgSOHBQ6wPuSuTsFK6ELFIyrpR34iA7b+Oo1mkj3v2plyu2so4R0mXLcMa jUbCYXKB/7R/qZFYB4mT5zfbotPvSOxofnST8t0WgzH+CsR2jmT9llHLNIrtNzFK6rDF ZiJILsWLxQ+0FMudoYoOZ3IcNB1weKSS8DgXuZ82YYg5+rI6g2VYWfuvL28DBWMz5ykF Wr4g== X-Gm-Message-State: AOAM532CQk/GTTC0cA4OSgecFXaQ+PtVKEpCPA8Tz0UCqveVs0B3dKH/ jeir+FYuiO8+jKW4/yFHWABbTgejxR1cUg== X-Google-Smtp-Source: ABdhPJwv47Q4cTbzMP0aU9Bh09xprI2YfnL5honM1/klNspZrmZXAdssd6mPbC3XNoFcjq2dUi4SxQ== X-Received: by 2002:adf:eccd:0:b0:212:fbbc:79de with SMTP id s13-20020adfeccd000000b00212fbbc79demr35777097wro.520.1654765597488; Thu, 09 Jun 2022 02:06:37 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 55/55] target/arm: Add ID_AA64SMFR0_EL1 Date: Thu, 9 Jun 2022 10:05:37 +0100 Message-Id: <20220609090537.1971756-56-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654776206329100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson This register is allocated from the existing block of id registers, so it is already RES0 for cpus that do not implement SME. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-21-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu.h | 25 +++++++++++++++++++++++++ target/arm/helper.c | 4 ++-- target/arm/kvm64.c | 11 +++++++---- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 2e6153c5409..78dbcb5592c 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -966,6 +966,7 @@ struct ArchCPU { uint64_t id_aa64dfr0; uint64_t id_aa64dfr1; uint64_t id_aa64zfr0; + uint64_t id_aa64smfr0; uint64_t reset_pmcr_el0; } isar; uint64_t midr; @@ -2190,6 +2191,15 @@ FIELD(ID_AA64ZFR0, I8MM, 44, 4) FIELD(ID_AA64ZFR0, F32MM, 52, 4) FIELD(ID_AA64ZFR0, F64MM, 56, 4) =20 +FIELD(ID_AA64SMFR0, F32F32, 32, 1) +FIELD(ID_AA64SMFR0, B16F32, 34, 1) +FIELD(ID_AA64SMFR0, F16F32, 35, 1) +FIELD(ID_AA64SMFR0, I8I32, 36, 4) +FIELD(ID_AA64SMFR0, F64F64, 48, 1) +FIELD(ID_AA64SMFR0, I16I64, 52, 4) +FIELD(ID_AA64SMFR0, SMEVER, 56, 4) +FIELD(ID_AA64SMFR0, FA64, 63, 1) + FIELD(ID_DFR0, COPDBG, 0, 4) FIELD(ID_DFR0, COPSDBG, 4, 4) FIELD(ID_DFR0, MMAPDBG, 8, 4) @@ -4195,6 +4205,21 @@ static inline bool isar_feature_aa64_sve_f64mm(const= ARMISARegisters *id) return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, F64MM) !=3D 0; } =20 +static inline bool isar_feature_aa64_sme_f64f64(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64smfr0, ID_AA64SMFR0, F64F64); +} + +static inline bool isar_feature_aa64_sme_i16i64(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64smfr0, ID_AA64SMFR0, I16I64) =3D=3D 0xf; +} + +static inline bool isar_feature_aa64_sme_fa64(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64smfr0, ID_AA64SMFR0, FA64); +} + /* * Feature tests for "does this exist in either 32-bit or 64-bit?" */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 400f7cd1dba..ac9942d750d 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -7722,11 +7722,11 @@ void register_cp_regs_for_features(ARMCPU *cpu) .access =3D PL1_R, .type =3D ARM_CP_CONST, .accessfn =3D access_aa64_tid3, .resetvalue =3D cpu->isar.id_aa64zfr0 }, - { .name =3D "ID_AA64PFR5_EL1_RESERVED", .state =3D ARM_CP_STAT= E_AA64, + { .name =3D "ID_AA64SMFR0_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 0, .crm =3D 4, .opc2 =3D = 5, .access =3D PL1_R, .type =3D ARM_CP_CONST, .accessfn =3D access_aa64_tid3, - .resetvalue =3D 0 }, + .resetvalue =3D cpu->isar.id_aa64smfr0 }, { .name =3D "ID_AA64PFR6_EL1_RESERVED", .state =3D ARM_CP_STAT= E_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 0, .crm =3D 4, .opc2 =3D = 6, .access =3D PL1_R, .type =3D ARM_CP_CONST, diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index b3f635fc952..ff8f65da22f 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -574,6 +574,8 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *= ahcf) } else { err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64pfr1, ARM64_SYS_REG(3, 0, 0, 4, 1)); + err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64smfr0, + ARM64_SYS_REG(3, 0, 0, 4, 5)); err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64dfr0, ARM64_SYS_REG(3, 0, 0, 5, 0)); err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64dfr1, @@ -682,10 +684,11 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures= *ahcf) ahcf->isar.id_aa64pfr0 =3D t; =20 /* - * Before v5.1, KVM did not support SVE and did not expose - * ID_AA64ZFR0_EL1 even as RAZ. After v5.1, KVM still does - * not expose the register to "user" requests like this - * unless the host supports SVE. + * There is a range of kernels between kernel commit 73433762fcae + * and f81cb2c3ad41 which have a bug where the kernel doesn't expo= se + * SYS_ID_AA64ZFR0_EL1 via the ONE_REG API unless the VM has enabl= ed + * SVE support, so we only read it here, rather than together with= all + * the other ID registers earlier. */ err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64zfr0, ARM64_SYS_REG(3, 0, 0, 4, 4)); --=20 2.25.1