]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
AArch64: Add asymmetric faulting mode for tag violations in mem.tagging tunable
authorTejas Belagod <Tejas.Belagod@arm.com>
Mon, 27 Jun 2022 18:00:50 +0000 (18:00 +0000)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Thu, 30 Jun 2022 13:01:08 +0000 (14:01 +0100)
The new asymmetric mode is available when HWCAP2_MTE3 is set (support is
available), bit2 is set in the tunable (user request per application),
and the system is configured such that the asymmetric mode is preferred over
sync or async (per-cpu system-wide setting).

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
manual/tunables.texi
sysdeps/unix/sysv/linux/aarch64/cpu-features.c

index 2c076019aeaa3e01a3e723f94ce84c1dcf39fffb..83cdcdac6dc70098b0408133d4a6f1987bd84eca 100644 (file)
@@ -602,6 +602,9 @@ Bit 1 enables precise faulting mode for tag violations on systems that
 support deferred tag violation reporting.  This may cause programs
 to run more slowly.
 
+Bit 2 enables either precise or deferred faulting mode for tag violations
+whichever is preferred by the system.
+
 Other bits are currently reserved.
 
 @Theglibc{} startup code will automatically enable memory tagging
index 41dda8d00327e56b6c85a07eb68435de1dda5dae..d14c0f4e1f2905148ac55a4569fd3e12f9a1d7fe 100644 (file)
@@ -108,7 +108,13 @@ init_cpu_features (struct cpu_features *cpu_features)
   TUNABLE_SET (glibc, mem, tagging, cpu_features->mte_state);
 # endif
 
-  if (cpu_features->mte_state & 2)
+  if (cpu_features->mte_state & 4)
+    /* Enable choosing system-preferred faulting mode.  */
+    __prctl (PR_SET_TAGGED_ADDR_CTRL,
+            (PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_SYNC | PR_MTE_TCF_ASYNC
+             | MTE_ALLOWED_TAGS),
+            0, 0, 0);
+  else if (cpu_features->mte_state & 2)
     __prctl (PR_SET_TAGGED_ADDR_CTRL,
             (PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_SYNC | MTE_ALLOWED_TAGS),
             0, 0, 0);