From nobody Tue Feb 10 18:55:39 2026 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=1661188783; cv=none; d=zohomail.com; s=zohoarc; b=mI5FsbDx5geQl7MWEL3rMb5O1FTV4rNYm+KpZ+Yrhz+BMPMj7fdO9hg1HIoC1BV2jTOvwFJRkgm1IFOZNtt77hz6vCeSmAC2rzYTXR8lKvKSZ05pY9xtTUyN+zam0KpEcd4k0eWsWdDyrdYmmhhH9iWd4BiWt+ZjHYg9qOLNOVo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661188783; h=Content-Transfer-Encoding:Cc: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=85RaASzLJRUjYB2qlDOH84qmiuMV9YHjafoqZXxUOdU=; b=RQx+XWwehFzWFHLlK9gcttX2cjNzfOlbeNqhGmzmDH5pR2zAfI1UPpo8j5mkQ4br+L/4++U/DLgRYIRDh+/rHzi9jplcjkSrqBTAk0DFrlcPkDIuOw5skuS6N6zVHpnZjiCR+OvRL0PQRa4tpIjkdJ7wdsgVxza8Zzq6Tdp2Hv4= 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 1661188783294596.5359812759353; Mon, 22 Aug 2022 10:19:43 -0700 (PDT) Received: from localhost ([::1]:42850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQB5R-0006SN-7o for importer@patchew.org; Mon, 22 Aug 2022 13:19:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQ9PC-0004v1-Fs for qemu-devel@nongnu.org; Mon, 22 Aug 2022 11:31:58 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:36386) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQ9Ov-0001hw-BS for qemu-devel@nongnu.org; Mon, 22 Aug 2022 11:31:58 -0400 Received: by mail-pf1-x433.google.com with SMTP id w29so5121499pfj.3 for ; Mon, 22 Aug 2022 08:31:39 -0700 (PDT) Received: from stoup.. ([71.212.157.236]) by smtp.gmail.com with ESMTPSA id i6-20020a17090a3d8600b001f262f6f717sm10353835pjc.3.2022.08.22.08.31.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Aug 2022 08:31:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=85RaASzLJRUjYB2qlDOH84qmiuMV9YHjafoqZXxUOdU=; b=MxYK43xoqwGL/CXWmMqzDSBIbQLaX9W2NsN3UHIBRH4DnjD8MuvRi2KrB+V/VsUEqI vBDwA1G+JXUnQgQFWBFBgt0ts1n1pVsq0Wzh517Ilg1aY9TqztBqHs1lCRuYsCT5lJ98 MluMV914+p6At911sebK3aMozAjUV4EXwHeJy47JnxInQ//0BQZKj/DOXwF6F3sT4crv kIySKgyKsWDoYipbtQOsLBca3Qc6n74Af96d5jt3rKQrMY6oAB9JBLjs56XDeWQuAufm tqj1wh1+szapDXdd/weTyCbjN8kXv4pynqPXi252eQDiMQbr6C2/Pw7DmHr+mLwdngTL rIdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=85RaASzLJRUjYB2qlDOH84qmiuMV9YHjafoqZXxUOdU=; b=ZNbhElg7heeP/nrslcH7MCO0V3NrA1rEAH/4s2lMNRweLUMc3LP8SkNH3Z7zLUQAV7 ClbBnauTbNU8MGjKKSKWOH7wwXAxpAHQGTebli/R9mzipNFz+xtN9wupKiEYsTsJCf46 jYtqt7GuHEylkKws45AroP3n2C5QL/PD/uVpdBK0efqdsx3XKI05b+qx2VIW3WszrmES 11ZXUjhVqh512hAyYAE2Gj1OXB6IYFRKjuu+L8bOy5KNEjC3ykk0byCIkaSY0ppfSban NfH1Stkytge2ynqOQx9YA4X5NQspnWjLVMw9dByJ9TQNmNR1uYrKNV0eb6Z1RVx9l1EM q0dQ== X-Gm-Message-State: ACgBeo3QNOaC052CPjSCGlqDVEbU8B8WsnfEGvKhzALRZOx1B0Whs2Z7 48a8gTYAM2Debf+Q3X+5m3ZXd1E8gxTDzQ== X-Google-Smtp-Source: AA6agR7YdU83dgsioDJnOJfdAKvHGrEeyxt3KkG9b6ZmTetxDFnl5fzghzF71Xhwyvdd2601SxDZ0Q== X-Received: by 2002:a63:89c6:0:b0:429:a28d:7b4 with SMTP id v189-20020a6389c6000000b00429a28d07b4mr17261788pgd.42.1661182297019; Mon, 22 Aug 2022 08:31:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v2 63/66] target/arm: Fix fault reporting in get_phys_addr_lpae Date: Mon, 22 Aug 2022 08:27:38 -0700 Message-Id: <20220822152741.1617527-64-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220822152741.1617527-1-richard.henderson@linaro.org> References: <20220822152741.1617527-1-richard.henderson@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=2607:f8b0:4864:20::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-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, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=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: 1661188783828100001 Content-Type: text/plain; charset="utf-8" Always overriding fi->type was incorrect, as we would not properly propagate the fault type from S1_ptw_translate, or arm_ldq_ptw. Simplify things by providing a new label for a translation fault. For other faults, store into fi directly. Signed-off-by: Richard Henderson --- target/arm/ptw.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index d0981d94d1..5f3841b466 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1015,8 +1015,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint= 64_t address, GetPhysAddrResult *result, ARMMMUFaultInfo = *fi) { ARMCPU *cpu =3D env_archcpu(env); - /* Read an LPAE long-descriptor translation table. */ - ARMFaultType fault_type =3D ARMFault_Translation; uint32_t level; ARMVAParameters param; uint64_t ttbr; @@ -1054,8 +1052,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint= 64_t address, * so our choice is to always raise the fault. */ if (param.tsz_oob) { - fault_type =3D ARMFault_Translation; - goto do_fault; + goto do_translation_fault; } =20 addrsize =3D 64 - 8 * param.tbi; @@ -1092,8 +1089,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint= 64_t address, 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; + goto do_translation_fault; } } =20 @@ -1125,7 +1121,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint= 64_t address, * 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; + goto do_translation_fault; } =20 if (mmu_idx !=3D ARMMMUIdx_Stage2 && mmu_idx !=3D ARMMMUIdx_Stage2_S) { @@ -1156,8 +1152,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint= 64_t address, if (param.ds && stride =3D=3D 9 && sl2) { if (sl0 !=3D 0) { level =3D 0; - fault_type =3D ARMFault_Translation; - goto do_fault; + goto do_translation_fault; } startlevel =3D -1; } else if (!aarch64 || stride =3D=3D 9) { @@ -1176,8 +1171,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint= 64_t address, ok =3D check_s2_mmu_setup(cpu, aarch64, startlevel, inputsize, stride, outputsize); if (!ok) { - fault_type =3D ARMFault_Translation; - goto do_fault; + goto do_translation_fault; } level =3D startlevel; } @@ -1199,7 +1193,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint= 64_t address, descaddr |=3D extract64(ttbr, 2, 4) << 48; } else if (descaddr >> outputsize) { level =3D 0; - fault_type =3D ARMFault_AddressSize; + fi->type =3D ARMFault_AddressSize; goto do_fault; } =20 @@ -1249,7 +1243,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint= 64_t address, =20 if (!(descriptor & 1) || (!(descriptor & 2) && (level =3D=3D 3))) { /* Invalid, or the Reserved level 3 encoding */ - goto do_fault; + goto do_translation_fault; } =20 descaddr =3D descriptor & descaddrmask; @@ -1267,7 +1261,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint= 64_t address, descaddr |=3D extract64(descriptor, 12, 4) << 48; } } else if (descaddr >> outputsize) { - fault_type =3D ARMFault_AddressSize; + fi->type =3D ARMFault_AddressSize; goto do_fault; } =20 @@ -1324,9 +1318,9 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint= 64_t address, * 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 */ + fi->type =3D ARMFault_AccessFlag; goto do_fault; } =20 @@ -1343,8 +1337,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint= 64_t address, result->f.prot =3D get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, p= xn); } =20 - fault_type =3D ARMFault_Permission; if (!(result->f.prot & (1 << access_type))) { + fi->type =3D ARMFault_Permission; goto do_fault; } =20 @@ -1389,8 +1383,9 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint= 64_t address, result->f.lg_page_size =3D ctz64(page_size); return false; =20 -do_fault: - fi->type =3D fault_type; + do_translation_fault: + fi->type =3D ARMFault_Translation; + do_fault: 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 || --=20 2.34.1