From nobody Tue Feb 10 13:37:13 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=1665459701; cv=none; d=zohomail.com; s=zohoarc; b=N3CeN8lD9foVNUdVk1WGT1whFy1a3wfOn9+AOIgypQSLhpjAXiqZ0dR0YequiRL3SxtaK4xbWRDvEXRdISrlATAujVN3IMifbASELchxERz99EA/5qTWADiKwwxBH/am+bw2MI3QkLG2rmBJI8iYPO/tZJXPuJFatbq7u+rfeS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665459701; 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=JyqDFzcDDxaZLADzD0GCm51gPMwBsgamq3ZkxmoSGeA=; b=TfBngHCu8slXV3n5YWOWUWk2xZ14HzVavnK9VfsazXk21T0WhcdcMob/IWGScYbLU8G7RoZfIO2CASQX2R3EekPXv41pzo2c9W74eievbVFgJGYTvQTENuuRgTFokSWJoBqqtmN/prjKf+qyMpAH1WvhOgs4OGLCAarSuJzIHuU= 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 1665459701225793.0223963260029; Mon, 10 Oct 2022 20:41:41 -0700 (PDT) Received: from localhost ([::1]:47448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oi69E-0004Wu-8K for importer@patchew.org; Mon, 10 Oct 2022 23:41:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oi5o9-0002hm-2C for qemu-devel@nongnu.org; Mon, 10 Oct 2022 23:19:53 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]:33661) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oi5o7-00038P-Bw for qemu-devel@nongnu.org; Mon, 10 Oct 2022 23:19:52 -0400 Received: by mail-pg1-x52f.google.com with SMTP id f193so11830100pgc.0 for ; Mon, 10 Oct 2022 20:19:50 -0700 (PDT) Received: from stoup.. ([2602:47:d49d:ec01:5aa4:aba1:1c91:a9b7]) by smtp.gmail.com with ESMTPSA id o74-20020a62cd4d000000b0055f209690c0sm7663567pfg.50.2022.10.10.20.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 20:19:48 -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:subject:date :message-id:reply-to; bh=JyqDFzcDDxaZLADzD0GCm51gPMwBsgamq3ZkxmoSGeA=; b=OE0TB5uLs6bj9+ksRf+VC0vrhDph/IcghoHXZ+0fe7Bpa37UwGcpOOOh4g+jr16yYr 1aUqITTHb0ncwSAlbcFHPewMfS0FR3q84+8AQuuuDHZKH0lUUVDIWNNzXCskWwkhOki4 ktt0zvqtgY9AXgwCind0tqnv3fwupMOKAXULW+V/5+v8KlHgTT8tWacUcwZgBwmH50Eu WukUXpkefB62D5K7X01LjU9CKfKve+LB6iiGEVZOxhfFkaLM/W2Nqmb4JloJjyp4DYm7 esfZB16nPRfzZxrJ+A+IQ0hs8KSBXEb/LvFLVUQ2yu5Pbz5eBNBguxk/8yisH0+N/TpB OuIQ== 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 :subject:date:message-id:reply-to; bh=JyqDFzcDDxaZLADzD0GCm51gPMwBsgamq3ZkxmoSGeA=; b=Uu1d6yHRyzEllXgW3dzlXUwDB48mySOb0tj0AsL4w/HLNQsvI9u21XT5/gKFeClNqA 8iIhFQr30fF50rIP0VkUr475hsNqfhyNAv5bPEMpNQxy+0oGBNTp4DVtwWPT+pIdrPal ndrg2ttdUV2xrA1zbQYuFwguYCt2Jqq8kdBQp/eX+UlbN8Mas5R+ohaKUZzjOeXg1jO7 jCUYgW3kiWybcdlOZm9WFeITp5TByFaJ0HEFfAg60KYRJGo+f986tGRRXmPIU93F+soH XGUwYq17NRJMArHUCHGlchma37iqYDqp63Jm8zmWFmJeqLyR7+JJpneVBzurVM5WMTtJ Qijg== X-Gm-Message-State: ACrzQf2VYGRj8kZPbZhVaRGwGmnCbWSeE0oWSWc8qZFhmpA7jpBiAp/B Lp3eCIhn3Fb5FlXHUaPK5vg0YByw0o+4DQ== X-Google-Smtp-Source: AMsMyM7atgxgrTs0hbeIu+E+Iquw60TLnhFPZWCHFiwz/ptDqo8yErbzQsQtD/ZrtzZvnGEA0WWbpw== X-Received: by 2002:a05:6a00:134f:b0:563:7aa8:5cea with SMTP id k15-20020a056a00134f00b005637aa85ceamr6098400pfu.69.1665458389473; Mon, 10 Oct 2022 20:19:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v4 19/24] target/arm: Fix fault reporting in get_phys_addr_lpae Date: Mon, 10 Oct 2022 20:19:06 -0700 Message-Id: <20221011031911.2408754-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221011031911.2408754-1-richard.henderson@linaro.org> References: <20221011031911.2408754-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::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.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=unavailable 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: 1665459701872100001 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. Reviewed-by: Peter Maydell 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 9b767f8236..acbf09cce8 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1065,8 +1065,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, ARMCPU *cpu =3D env_archcpu(env); ARMMMUIdx mmu_idx =3D ptw->in_mmu_idx; bool is_secure =3D ptw->in_secure; - /* Read an LPAE long-descriptor translation table. */ - ARMFaultType fault_type =3D ARMFault_Translation; uint32_t level; ARMVAParameters param; uint64_t ttbr; @@ -1103,8 +1101,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, * 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; @@ -1141,8 +1138,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, 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 @@ -1168,7 +1164,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, * 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) { @@ -1199,8 +1195,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, 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) { @@ -1219,8 +1214,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, 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; } @@ -1242,7 +1236,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, 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 @@ -1296,7 +1290,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, =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; @@ -1314,7 +1308,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, 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 @@ -1371,9 +1365,9 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, * 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 @@ -1390,8 +1384,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, 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 @@ -1436,8 +1430,9 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, 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