From patchwork Fri Oct 21 17:23:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 617189 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1193501pvb; Fri, 21 Oct 2022 12:21:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM58rmtAFTze/97DANVzPRtjFEzi/J2sNDQq8+A8HYiMtx9CzrykbDTVtcJzdDHrgQJIOKqK X-Received: by 2002:a0c:a909:0:b0:4b3:ffb2:f69e with SMTP id y9-20020a0ca909000000b004b3ffb2f69emr17908617qva.4.1666380116126; Fri, 21 Oct 2022 12:21:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666380116; cv=none; d=google.com; s=arc-20160816; b=UScvH/tTXtw7FdlzwIpjFzfVEWM1T4/1bFg3VkpNX03Ikj+myMO/uNxSjjJyNfuhvw 02VOSFooMLuQxZXG54ussb40HJtPxC/18PtErZGtPEXE01Kj0g4WucB8NcYyxo+9RBY1 OCI8CcTIrDF43ohJnKs6d2INxKNbsGSypbqO884MvDEsjTGuPuu21528lkTqcs/38Kgc EduKH2lISnej+8Hg/ofXfLBmZgx92gq7/FqHnRg9mFQNTHcKc0bRGXo2gU+W2giSWzko iiBumI21YzVyy/7s9XsMfF9dXeza/bCFREvYIzno1YG2qTmp6MwwPEFHbXGclxgNksUy eNAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=cU9RhXgsAuBoWahY8ojheS2Kw+9q/J8NtHNIBVaWFq0=; b=ewDdQAFCqZyz8ih0eBE3VAk+0RFnEPePAsdYkCiCrmJKfbyRqXHJA1aw36hciKVE0x FQDranzjjZ0K28cdvFXsJu8MQNdt2ZrNXniDDTiJhVLwI8QeE5/rBSAVPBRwyAH1KVws FzV5cr8KZDPD1NaiM99Z8awmSaVOaW9P5LIqaRTQGhPq9iRUeVAupBO1d/u3AGSR9RLd oDrGCHPRvFZEpnhseA2l6BoRB7tIoaOHR1ucfiFqMa0Ep0DRWVhuFyk5XQU696vflC2P i0G4H1y03KSLPi2pNfUGJlehx1O85yOKZwS2EUovIg/M+rwqpwoKK5VIeFAh90oWw5xg 1BKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="nCFD/ZFm"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w23-20020a05620a0e9700b006ce7dfdaf38si11745551qkm.551.2022.10.21.12.21.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 12:21:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="nCFD/ZFm"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olxTq-0000Uc-VU; Fri, 21 Oct 2022 15:15:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olvkI-0006H7-LY for qemu-devel@nongnu.org; Fri, 21 Oct 2022 13:23:46 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olvkG-0007lM-Ud for qemu-devel@nongnu.org; Fri, 21 Oct 2022 13:23:46 -0400 Received: by mail-wm1-x335.google.com with SMTP id l16-20020a05600c4f1000b003c6c0d2a445so2486190wmq.4 for ; Fri, 21 Oct 2022 10:23:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=cU9RhXgsAuBoWahY8ojheS2Kw+9q/J8NtHNIBVaWFq0=; b=nCFD/ZFm+nS/CRYI5RlSfjC6CH91D5mrwKN1Tr2c+qB425kVBtYX2msX2i6qC/pLw8 MO6EDa4lUW4cnoHGLTLUckdKJsavSgYYLqwftg7Q/CkXB415It8Wsbxd8fr5u7IFa9e6 AAwmdruiFFRnGtU6klQuWn1x3d5Hp+iBz9DRdlVAPsgypmRuvUZ7L3hLj//ALJricwWD rAAiy4orJdgBgHx4vBnQy7JUVeYkNKJk/QBC99N6FwXTXHVS0D2vWxfoOlcwR3gNx0mW umboNTyjsaA+lb7q4mb2rRI5SIjJpntY1DacXJCWCRuISSmSSR8/bXn+9v2m2qN1HA4D 80Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cU9RhXgsAuBoWahY8ojheS2Kw+9q/J8NtHNIBVaWFq0=; b=gRbRK9K5W2krpFEpPGGfUQkp+3RdSG0ywHEgLg6f4ny2r3CMLSA0O4P1+M+eE2PRi9 pg8iV6TbxVE9MUVKjyyTSnOuOUOrCuXUAjBIAT91Sy8ION+sr0SAyVu/Gs4HVolkljST KwX9ji28TMe1ilN+i/zjFp2Xv+YfUwJRbmZc6L0jwFl3sx1tnUtn7Wn+kCV4+XyHX6A1 zt6vOREQMMpTq9bEEk4gVYaoRtjOnmaciWaDBxxLl/igYbr1ntOuWiYR8zTfv06Cnpbc FoITQH4qTGSeXmvQ7XrOLfs4xgF2dMfp8RauVOIXGHP7Izallb3ajlz4Gc+ZCyG6jNjV VaMQ== X-Gm-Message-State: ACrzQf3O06pBo68ucETshV7p5Cr2d0hdzw2HK0PImcyzIgxjF9Ko0HLH 1s3TRRpUt9tJ0nSw2c+rvt1S9A== X-Received: by 2002:a05:600c:15cc:b0:3c6:6ff5:21b8 with SMTP id v12-20020a05600c15cc00b003c66ff521b8mr13528297wmf.55.1666373023048; Fri, 21 Oct 2022 10:23:43 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id o18-20020adfcf12000000b0022a297950cesm19460927wrj.23.2022.10.21.10.23.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 10:23:42 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id F2C0D1FFB7; Fri, 21 Oct 2022 18:23:41 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , Peter Maydell Subject: [RFC PATCH] target/arm: don't process FCSE translations on physical TLBs Date: Fri, 21 Oct 2022 18:23:38 +0100 Message-Id: <20221021172338.2782240-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org A recent change to the page table walking code missed checking if we are at the processing the physical translation and bombs attempting to derive the current EL. Fix this by introducing a new helper (regime_is_phys) and extending the check around the FCSE processing. Signed-off-by: Alex Bennée Fixes: f3639a64f6 (target/arm: Use softmmu tlbs for page table walking) Cc: Richard Henderson --- target/arm/internals.h | 12 ++++++++++++ target/arm/ptw.c | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index c3c3920ded..0e753203b5 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -673,6 +673,18 @@ static inline bool regime_is_pan(CPUARMState *env, ARMMMUIdx mmu_idx) } } +static inline bool regime_is_phys(ARMMMUIdx mmu_idx) +{ + switch (mmu_idx) { + case ARMMMUIdx_Phys_NS: + case ARMMMUIdx_Phys_S: + return true; + default: + return false; + } +} + + /* Return the exception level which controls this address translation regime */ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) { diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 6c5ed56a10..1456a2f1de 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2557,7 +2557,7 @@ static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw, * 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 != ARMMMUIdx_Stage2 + if (address < 0x02000000 && !(mmu_idx == ARMMMUIdx_Stage2 || regime_is_phys(mmu_idx)) && !arm_feature(env, ARM_FEATURE_V8)) { if (regime_el(env, mmu_idx) == 3) { address += env->cp15.fcseidr_s;