On 11/17/25 02:40, Gabriel Brookman wrote:
This feature automatically succeeds tag checks on load instructions when
the appropriate SCTLR_TCSO register for the current exception level is
set. Find information on this feature in the "Tag Checking" section of
the ARM ARM, Memory Tagging Extension chapter.
Signed-off-by: Gabriel Brookman <[email protected]>
---
target/arm/tcg/mte_helper.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c
index bb48fe359b..f9fd6fd408 100644
--- a/target/arm/tcg/mte_helper.c
+++ b/target/arm/tcg/mte_helper.c
@@ -865,8 +865,30 @@ static int mte_probe_int(CPUARMState *env, uint32_t desc,
uint64_t ptr,
return 0;
}
+static bool mte_store_only_active(CPUARMState *env)
+{
+ int el = arm_current_el(env);
+ if (el) {
+ if (SCTLR_TCSO & env->cp15.sctlr_el[el]) {
+ return true;
+ }
+ } else {
+ if ((HCR_E2H & env->cp15.hcr_el2) &&'
You can't test hcr_el2 directly, because SecEL2 might not exist when (Non-secure) EL2
does. However, this can be simplified using arm_sctlr():
uint64_t sctlr = arm_sctlr(env, el);
uint64_t test = el ? SCTLR_TCSO : SCTLR_TCSO0;
return sctlr & test;
That said, we should cache this in TBFLAGS so that we don't generate the mte_check
function call at runtime for reads. See target/arm/tcg/hflags.c, s/MTE_ACTIVE/.
r~