From nobody Tue Feb 10 15:28:07 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=1639005387; cv=none; d=zohomail.com; s=zohoarc; b=GChaVBEX3VQ6AKEiDQI8H9h23OQC3tDiAakELq6GAM+QUDE7b2owJd7pXlbHQRFe5aCuysSGT5qWc74gx8mDKUWMGTNM/2c8kEo61VE0hHvgXte2UiVtZBr/0ZSxTgt0VckRiKLfBh6w4yAcnjwX0FT2AR3heChAnt6XwxoHmRg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639005387; 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=8Odri40+f/dUoIsb/bgSIF+/bcyc0os3qiW/fNyIHw0=; b=W6lL79OodnosqL2eDp+MXahJHTMe84I06iUIBM/c0T+Yw5UgmGV9Ic/uQjkwKCkGYsxI7iz46LrZeAh+i+U97n0QOKsDpB3AGUHZDkkzD555KiqXFEd4+da4pQqMaY7SPrbpc372vCnKdZ4uVaNi3OqGYObJwpybhLr2SPycpCk= 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 1639005387123890.6206274473341; Wed, 8 Dec 2021 15:16:27 -0800 (PST) Received: from localhost ([::1]:43496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mv6Ak-00048W-4X for importer@patchew.org; Wed, 08 Dec 2021 18:16:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mv66S-00058A-EM for qemu-devel@nongnu.org; Wed, 08 Dec 2021 18:12:00 -0500 Received: from [2607:f8b0:4864:20::42d] (port=42665 helo=mail-pf1-x42d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mv66Q-0004mt-5n for qemu-devel@nongnu.org; Wed, 08 Dec 2021 18:12:00 -0500 Received: by mail-pf1-x42d.google.com with SMTP id u80so3745688pfc.9 for ; Wed, 08 Dec 2021 15:11:57 -0800 (PST) Received: from localhost.localdomain (45-19-222-18.lightspeed.sntcca.sbcglobal.net. [45.19.222.18]) by smtp.gmail.com with ESMTPSA id k15sm3301062pgn.91.2021.12.08.15.11.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 15:11:56 -0800 (PST) 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=8Odri40+f/dUoIsb/bgSIF+/bcyc0os3qiW/fNyIHw0=; b=aGP/X3W0C6PCiBh8YmcA7oZxwYFBL7hHkZKp+cfNv0qAi7nP4jbDHPXInWXSdUl3Sv wbmwJSwk78QrrU9Nn4HHVXOgYGymMI4BxvRkA98qGqh26L7F4ruRVrHNf9Thfy4IlPwm RNv8nDAOHwV4G6bWBbaHENyXWqHMnjT2Cft0s4qC6hQQ/b9HbGjwISvKRtwD2QtnS4v+ e72rKA1JciX5MMYQpjol+k/ju1PDFIpQQOud7zQWOfhZw0ssex88cW3nX9Nd2LoZiFWK 1/ZefKrRLWN6RZt2RYwhSy8yHlkiFFJuNb+zdqgnO7lHJGeX0dGLByWBESWiU7vMdnDd 0KfQ== 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=8Odri40+f/dUoIsb/bgSIF+/bcyc0os3qiW/fNyIHw0=; b=rz/4p9k/2HAUMhSiMJtBWV+ktQMnVmh171+9iXVI+4eA2APIYsiaAe4598SgzkQpZW k9fLCjWQrQ48ZDojFbXawkAi2stnLvG72UcTAqwnxYB5Dpa8byT/LYPmbEtBHCUy13Ud oroT715r/CFdUoKoTwuSLVhxg3z2aUUJiO4/2tE1uiku7XoW5icYs7gDVZymEuyr/KM2 u4ZuHpQmkDnWWlytp7NVUq/w2Udeeb3+dPvDYlY5WUbQ13RqkZljIlIPo81vB8pvqUCa 2ccwWDnOOuBusKW1Y3ukowKt1Tcwea+Wi0OG1DNuKrr6faVv37Cj2c91nLCQEiR7H7V0 A/rA== X-Gm-Message-State: AOAM5316dpq5vDvlVl5QDHjqrIfoopW3krXx1BxhNh1j3I5CfJNi3ZSJ nU//EcFyjvpeiFcqu8BzD2+HdFGJo9C5NA== X-Google-Smtp-Source: ABdhPJx95fcuRxyonZ2v2+foHzPKhUPgGrIanlbXlQHS7pLMhd+gJcc5Mw1x4unDnMQ5kfkIFXsaMA== X-Received: by 2002:a63:6882:: with SMTP id d124mr31976744pgc.234.1639005116664; Wed, 08 Dec 2021 15:11:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 1/6] target/arm: Fault on invalid TCR_ELx.TxSZ Date: Wed, 8 Dec 2021 15:11:49 -0800 Message-Id: <20211208231154.392029-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211208231154.392029-1-richard.henderson@linaro.org> References: <20211208231154.392029-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42d (failed) 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::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1639005388472100001 Content-Type: text/plain; charset="utf-8" Without FEAT_LVA, the behaviour of programming an invalid value is IMPLEMENTATION DEFINED. With FEAT_LVA, programming an invalid minimum value requires a Translation fault. It is most self-consistent to choose to generate the fault always. Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e --- target/arm/helper.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 9b317899a6..575723d62c 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11129,7 +11129,7 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, { uint64_t tcr =3D regime_tcr(env, mmu_idx)->raw_tcr; bool epd, hpd, using16k, using64k; - int select, tsz, tbi, max_tsz; + int select, tsz, tbi; =20 if (!regime_has_2_ranges(mmu_idx)) { select =3D 0; @@ -11165,15 +11165,6 @@ ARMVAParameters aa64_va_parameters(CPUARMState *en= v, uint64_t va, } } =20 - if (cpu_isar_feature(aa64_st, env_archcpu(env))) { - max_tsz =3D 48 - using64k; - } else { - max_tsz =3D 39; - } - - tsz =3D MIN(tsz, max_tsz); - tsz =3D MAX(tsz, 16); /* TODO: ARMv8.2-LVA */ - /* Present TBI as a composite with TBID. */ tbi =3D aa64_va_parameter_tbi(tcr, mmu_idx); if (!data) { @@ -11309,9 +11300,30 @@ static bool get_phys_addr_lpae(CPUARMState *env, u= int64_t address, =20 /* TODO: This code does not support shareability levels. */ if (aarch64) { + int min_tsz =3D 16, max_tsz =3D 39; /* TODO: ARMv8.2-LVA */ + param =3D aa64_va_parameters(env, address, mmu_idx, access_type !=3D MMU_INST_FETCH); level =3D 0; + + if (cpu_isar_feature(aa64_st, env_archcpu(env))) { + max_tsz =3D 48 - param.using64k; + } + + /* + * 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 < min_tsz || param.tsz > max_tsz) { + fault_type =3D ARMFault_Translation; + goto do_fault; + } + addrsize =3D 64 - 8 * param.tbi; inputsize =3D 64 - param.tsz; } else { --=20 2.25.1