Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6115606A31A for ; Tue, 1 Dec 2026 00:06:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=unpredictable.fr header.i=@unpredictable.fr header.a=rsa-sha256 header.s=sig1 header.b=og38JZRX Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xYBOH-0001Ui-Id; Mon, 30 Nov 2026 19:06:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xYBMS-0000Uf-RQ for qemu-devel@nongnu.org; Mon, 30 Nov 2026 19:04:46 -0500 Received: from ci-2006i-snip6-3.eps.apple.com ([2a01:b747:3005:201::56] helo=outbound.ci.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xYBMQ-0001jc-Ks for qemu-devel@nongnu.org; Mon, 30 Nov 2026 19:04:44 -0500 Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-20-percent-0 (Postfix) with ESMTPS id C0AEB1800334; Tue, 01 Dec 2026 00:04:36 +0000 (UTC) X-ICL-RepId: 01a22eea-e88c-7ad1-9eed-8a8ae7658297 Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1796083479; x=1827619479; bh=LAiKLg1ZNkICPVRoBRSxX3WuOzDs5f0joRjpAcH0jAc=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=og38JZRX8aVQXiUsY3JobawfkodDwpv2dHa1vCAMOVULlZHJHaeBs/Lea2XJUNBb86iBIQoe0oOwVI4sQFBdWGJ5p8ns98cYLKjsiUp+apzyqqQqtkhaoauansFX/vQdokgfJExMhFt1gXdJYZNqrypbvwC+AaSMwK1dON/Up79P8LI6384dsVYef4AIDOOf5mkxJRH2Fta6k6bPRLbBBvhOWQSTZJecxE5pucCGFTe49hY8yr3afobIWAMcMDod3TUfwqm954FFrDASKS9cY36obKqck76Fhpq4FiJMdelFf2MBGNTot5xM6k0s6sEmVyu6QtRoQiWc90cvI7SqeQ== mail-alias-created-date: 1752046281608 Received: from localhost.localdomain (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-20-percent-0 (Postfix) with ESMTPSA id 22FDC1800D6F; Tue, 01 Dec 2026 00:04:33 +0000 (UTC) From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , qemu-arm@nongnu.org, Mohamed Mediouni Subject: [RFC PATCH 03/11] target/arm: translate-a64: query whether the page is an EGP Date: Tue, 1 Dec 2026 01:04:18 +0100 Message-ID: <20261201000426.84449-4-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261201000426.84449-1-mohamed@unpredictable.fr> References: <20261201000426.84449-1-mohamed@unpredictable.fr> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAxMDAwMCBTYWx0ZWRfX7EOORPs4mKtU riKGINtyC4l7NaMpcuUcNZBLjnoTpCAr0U0NC4ntuwr/Uc2iQzcqpevhXd6sZ145rE57oYuzqv4 PfvlJrQuQsQ78fwS/ACajcRCkG7rGuw= X-Authority-Info-Out: v=2.4 cv=BPgmP1QG c=1 sm=1 tr=0 ts=6b0e0f15 cx=c_apl:c_pps:t_out a=2G65uMN5HjSv0sBfM2Yj2w==:117 a=2G65uMN5HjSv0sBfM2Yj2w==:17 a=pUM-KoujP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CfHPP0+i1xA298vIISp6c2TpR8D 0zIguUYukJjjiMnlUNDEvN5ofhUgX82cn2lyQJ7AzYWPE00UhSvDW0rjED4JG1RuNSjUzB vC/fhespCg2Nz8NmhaC5zqKSPv+IvAdmEhw/2nl+iBAcngZGcu9B11Ehm1n/Po3+LF04CQ 1ozzhV7RcPjX5UIrZPvj2rzPOCaXJQLCkJrHmlDksUN12gJkHp8LzMhDAsjINIFvyTA9B/ R33lgHfdJ9rolfxpflFLmx8v41WEHLwTtqkop021mTppqloNOwrwuZe8Qn8VMngl6cfL0F 6XRJvfMs42GFregcICUsEVIxg0OsBrDqTKzkVwEpnH5Yyr5NjcrQkf1NeTLlW+n1Pr93wt vJ6ozRK6NJJ5J0XvcqUxK5oN4ErwzTYbwfLZEWOjs= Received-SPF: pass client-ip=2a01:b747:3005:201::56; envelope-from=mohamed@unpredictable.fr; helo=outbound.ci.icloud.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_PASS=-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: qemu development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Mohamed Mediouni The set of allowed BTYPEs depends on whether code is running on an enhanced guarded page. Signed-off-by: Mohamed Mediouni --- target/arm/tcg/translate-a64.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index b356393661..12e4f366e3 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -29,6 +29,10 @@ #include "qemu/log.h" #include "semihosting/semihost.h" #include "cpregs.h" +#include "accel/tcg/cpu-mmu-index.h" +#include "accel/tcg/probe.h" +#include "exec/tlb-flags.h" + static TCGv_i64 cpu_X[32]; static TCGv_i64 cpu_gcspr[4]; @@ -10983,6 +10987,7 @@ static bool trans_FAIL(DisasContext *s, arg_OK *a) * @insn: The instruction at the branch destination * @bt: SCTLR_ELx.BT * @btype: PSTATE.BTYPE, and is non-zero + * @btie: Whether the instruction is in an enhanced guarded page * * On a guarded page, there are a limited number of insns * that may be present at the branch target: @@ -10994,7 +10999,7 @@ static bool trans_FAIL(DisasContext *s, arg_OK *a) * * Return true if the branch is compatible, false to raise BTITRAP. */ -static bool btype_destination_ok(uint32_t insn, bool bt, int btype) +static bool btype_destination_ok(uint32_t insn, bool bt, int btype, bool btie) { if ((insn & 0xfffff01fu) == 0xd503201fu) { /* HINT space */ @@ -11158,6 +11163,23 @@ static void aarch64_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) dc->insn_start_updated = false; } +/* Disambiguating between EGP and GP, for FEAT_BTIE */ +static bool is_enhanced_guarded_page(CPUARMState *env, vaddr addr, uintptr_t ra) +{ +#ifdef CONFIG_USER_ONLY + return false; +#else + CPUTLBEntryFull *full; + void *host; + int mmu_idx = cpu_mmu_index(env_cpu(env), true); + int flags = probe_access_full(env, addr, 0, MMU_INST_FETCH, mmu_idx, + false, &host, &full, ra); + + assert(!(flags & TLB_INVALID_MASK)); + return full->extra.arm.enhanced_guarded; +#endif +} + static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) { DisasContext *s = container_of(dcbase, DisasContext, base); @@ -11213,6 +11235,12 @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) if (dc_isar_feature(aa64_bti, s)) { int btype = EX_TBFLAG_A64(s->tbflags, BTYPE); + bool btie = false; + + if (dc_isar_feature(aa64_btie, s)) { + btie = is_enhanced_guarded_page(env, pc, 0); + } + tcg_debug_assert(!s->btype_set); if (s->base.num_insns == 1) { /* @@ -11224,7 +11252,7 @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) * We can check all but the guarded page check here; * defer the latter to a helper. */ - if (btype && !btype_destination_ok(insn, s->bt, btype)) { + if (btype && !btype_destination_ok(insn, s->bt, btype, btie)) { gen_helper_guarded_page_check(tcg_env); } } else { -- 2.54.0 (Apple Git-157)