From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3967DC87FCE for ; Sun, 27 Jul 2025 08:04:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwM0-00068e-QE; Sun, 27 Jul 2025 04:03:33 -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 1ufwLf-0005Ac-Iw for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:13 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwLd-00043G-Ql for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:11 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-235e1d710d8so45887365ad.1 for ; Sun, 27 Jul 2025 01:03:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603388; x=1754208188; darn=nongnu.org; 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=d2EtIwYhWBdunEnHZqFFjPpeIhDqDk+A7MtfcXFRuII=; b=YJkYm+N/uMDX+3rtKutoU5HARhpFkPJ2GCgbjS6bf+8IskxN9sew9wz7GE57iJGf06 gYbzTsxmRWYed027Z+X9xSSXBNruGmg9rr0hj711pYEQvtiYczSno/bD8SD4TDwt7+Lt r6jMOSThsbkCxwrpA8J7fQJvV0Au8Y/b6Tg6k40cxGmoClYF5uSFi0KAbaAEVx3uZXHq AFhqHPi8wt9URFzY7OjjRDE6g7m45iErojmiJF4l0ChWL2teE3MKWFqWBLTQY2r7VU/2 Dd68cAKMfJytbKKs48SRPIjYHdpRlMuxqqLR66PHdPTlYooy1sOOsZmjtC8EVTVR5gjp DOhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603388; x=1754208188; 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=d2EtIwYhWBdunEnHZqFFjPpeIhDqDk+A7MtfcXFRuII=; b=NbDay3QAeRKsyljMrHyfilMZJhHBt2f9IdHSiEsAqePW55t8fUCEvlqnol8cnJoyRG h+ePmv/ibZcnoQkLsrTgo+L/nBp5f3iZImpJ2s4mxOTCLgxLisRpsmIHbMKT1ifQdFD+ K9qXqmAHS4G5nI4oQbXg+6rt+EdLK8w5DZdFUjYEvK4AkD1u/NJMY0wUApMH3zaHgnwI 2a/s+SBydAhguTaF+cgJv0W2sfvJj3ltHE3DBimOETC/iNls8InrpoNafxgvZJRESS3Q oAYXVvI6eWLIMpoyFPwK+2r11oQneaaebwlQhPL9AmBeDb0pUCsWCC4DUGaIxUMNCHun btYA== X-Gm-Message-State: AOJu0YyZ2FyI1Y7zuJ9tJlwC+uePaVuIzAJcda/+d8IBj+aCHp4NsluS zF/LZxSXZ+CRhE+k2QkPqvZ0DeHHfSYMvJ/hOYSnQpSTcmiyD1leSv+m2VhMnfr7CWm+jCbPjm5 FihRB X-Gm-Gg: ASbGncuQWStNOTsyNnpVd7Mm9B1k6BAoAQDgSDD9n1SEWiB7FwV5hZxdW5L4cW60vgU Qz74ykxcO4Fdx5b3T4v5LizUwxhFeaDK/MPEZwDZYPS3TZfUAS7yZH5UlulYoTQ1ysCqUX0fli9 t1Gw2ow29DAZrZvvSvCcJUBhc+c50nR62oX+8crObfHA3TYgIUSK8ir5/xU8pcQ4A5wXe2RYwo2 QHk8tzlsBIG/GH3T0mHEzRHYEeRFBhz1t++h2QVDYTZVZBVImyRTBaCMbRhwyq3/dBBm2Yo0TJQ PPuG2/0l5i++hbr9E6tcA3DUx3fosTIQLFOnlsuk23B5FPonH5RE+PnLMeQG8QrkmD/k1ptFFCX 3qTRS4Gvi/pX/4vxMu8c40IpvbKN/xG/Se9rU2gqJDWafUH7eU5El5p/MwaA165eUfF821pdZ8Y Ni7Qca+Z0U6w== X-Google-Smtp-Source: AGHT+IFju1qSSPpmBJkIphAJ8pz0PGLVnKMnDrfHIHaeuL3Xg8w8myeMSf20CntHltCPh75kPEoXSA== X-Received: by 2002:a17:903:3508:b0:23e:277b:b921 with SMTP id d9443c01a7336-23fb3179e0dmr108943045ad.42.1753603388479; Sun, 27 Jul 2025 01:03:08 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 09/82] target/arm: Implement FEAT_ATS1A Date: Sat, 26 Jul 2025 22:01:41 -1000 Message-ID: <20250727080254.83840-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Implement FEAT_ATS1A and enable for -cpu max. Signed-off-by: Richard Henderson --- target/arm/cpregs.h | 1 + target/arm/cpu-features.h | 5 ++++ target/arm/tcg/cpregs-at.c | 44 +++++++++++++++++++++++++++++++++++ target/arm/tcg/cpu64.c | 1 + docs/system/arm/emulation.rst | 1 + 5 files changed, 52 insertions(+) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index 1d103b577f..2a4826f5c4 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -854,6 +854,7 @@ typedef enum FGTBit { DO_BIT(HFGITR, DVPRCTX), DO_BIT(HFGITR, CPPRCTX), DO_BIT(HFGITR, DCCVAC), + DO_BIT(HFGITR, ATS1E1A), } FGTBit; #undef DO_BIT diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index 9579d93cec..7f2ca51b4c 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -609,6 +609,11 @@ static inline bool isar_feature_aa64_lut(const ARMISARegisters *id) return FIELD_EX64_IDREG(id, ID_AA64ISAR2, LUT); } +static inline bool isar_feature_aa64_ats1a(const ARMISARegisters *id) +{ + return FIELD_EX64_IDREG(id, ID_AA64ISAR2, ATS1A); +} + static inline bool isar_feature_aa64_fp_simd(const ARMISARegisters *id) { /* We always set the AdvSIMD and FP fields identically. */ diff --git a/target/arm/tcg/cpregs-at.c b/target/arm/tcg/cpregs-at.c index bebf168997..0e8f229aa7 100644 --- a/target/arm/tcg/cpregs-at.c +++ b/target/arm/tcg/cpregs-at.c @@ -488,6 +488,47 @@ static const ARMCPRegInfo ats1cp_reginfo[] = { .writefn = ats_write }, }; +static void ats_s1e1a(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) +{ + uint64_t hcr_el2 = arm_hcr_el2_eff(env); + bool regime_e20 = (hcr_el2 & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE); + ARMMMUIdx mmu_idx = regime_e20 ? ARMMMUIdx_E20_2 : ARMMMUIdx_Stage1_E1; + ARMSecuritySpace ss = arm_security_space_below_el3(env); + + env->cp15.par_el[1] = do_ats_write(env, value, 0, mmu_idx, ss); +} + +static void ats_s1e2a(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) +{ + uint64_t hcr_el2 = arm_hcr_el2_eff(env); + ARMMMUIdx mmu_idx = hcr_el2 & HCR_E2H ? ARMMMUIdx_E20_2 : ARMMMUIdx_E2; + ARMSecuritySpace ss = arm_security_space_below_el3(env); + + env->cp15.par_el[1] = do_ats_write(env, value, 0, mmu_idx, ss); +} + +static void ats_s1e3a(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) +{ + env->cp15.par_el[1] = do_ats_write(env, value, 0, ARMMMUIdx_E3, + arm_security_space(env)); +} + +static const ARMCPRegInfo ats1a_reginfo[] = { + { .name = "AT_S1E1A", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 2, + .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, + .fgt = FGT_ATS1E1A, + .accessfn = at_s1e01_access, .writefn = ats_s1e1a }, + { .name = "AT_S1E2A", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 4, .crn = 7, .crm = 9, .opc2 = 2, + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, + .accessfn = at_s1e2_access, .writefn = ats_s1e2a }, + { .name = "AT_S1E3A", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 6, .crn = 7, .crm = 9, .opc2 = 2, + .access = PL3_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, + .writefn = ats_s1e3a }, +}; + void define_at_insn_regs(ARMCPU *cpu) { CPUARMState *env = &cpu->env; @@ -509,4 +550,7 @@ void define_at_insn_regs(ARMCPU *cpu) if (cpu_isar_feature(aa32_ats1e1, cpu)) { define_arm_cp_regs(cpu, ats1cp_reginfo); } + if (cpu_isar_feature(aa64_ats1a, cpu)) { + define_arm_cp_regs(cpu, ats1a_reginfo); + } } diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c index c54aa528c6..22ccc4f697 100644 --- a/target/arm/tcg/cpu64.c +++ b/target/arm/tcg/cpu64.c @@ -1178,6 +1178,7 @@ void aarch64_max_tcg_initfn(Object *obj) t = FIELD_DP64(t, ID_AA64ISAR2, MOPS, 1); /* FEAT_MOPS */ t = FIELD_DP64(t, ID_AA64ISAR2, BC, 1); /* FEAT_HBC */ t = FIELD_DP64(t, ID_AA64ISAR2, WFXT, 2); /* FEAT_WFxT */ + t = FIELD_DP64(t, ID_AA64ISAR2, ATS1A, 1); /* FEAT_ATS1A */ SET_IDREG(isar, ID_AA64ISAR2, t); t = GET_IDREG(isar, ID_AA64PFR0); diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index d207a9f266..1489c262b8 100644 --- a/docs/system/arm/emulation.rst +++ b/docs/system/arm/emulation.rst @@ -23,6 +23,7 @@ the following architecture extensions: - FEAT_AFP (Alternate floating-point behavior) - FEAT_Armv9_Crypto (Armv9 Cryptographic Extension) - FEAT_ASID16 (16 bit ASID) +- FEAT_ATS1A (Address Translation operations that ignore stage 1 permissions) - FEAT_BBM at level 2 (Translation table break-before-make levels) - FEAT_BF16 (AArch64 BFloat16 instructions) - FEAT_BTI (Branch Target Identification) -- 2.43.0