@samitouri / QOSamiQemu / commits / b79a9b6e5b

accel/tcg: Use TLB_FORCE_SLOW not TLB_MMIO for user-only plugins

In 6d03226b422 we set TLB_MMIO to a non-zero value for user-only so that we could return a non-zero value from probe_* functions so that we could force callers like Arm SVE vector moves to use the slow path rather than direct access. All for the sake of exposing these accesses to plugins. Back then, TLB_FORCE_SLOW did not exist, so TLB_MMIO seemed like a reasonable solution. However, user-only doesn't really have MMIO and this has knock-on effects, like forcing Arm SVE first-fault vector loads to stop. Better to use TLB_FORCE_SLOW as a more exact trigger for plugins. Cc: qemu-stable@nongnu.org Fixes: 6d03226b422 ("plugins: force slow path when plugins instrument memory ops") Acked-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-ID: <20260702171057.47998-1-richard.henderson@linaro.org>

Richard Henderson committed Jul 2, 2026 at 10:10 UTC b79a9b6e5b5657534615dd8e574d58305e16841c
2 files changed +6 -5
accel/tcg/user-exec.c
+2 -2
@@ -769,7 +769,7 @@ static int probe_access_internal(CPUArchState *env, vaddr addr,
769 if (page_flags & acc_flag) {
770 if (access_type != MMU_INST_FETCH
771 && cpu_plugin_mem_cbs_enabled(env_cpu(env))) {
772 - return TLB_MMIO;
772 + return TLB_FORCE_SLOW;
773 }
774 return 0; /* success */
775 }
@@ -804,7 +804,7 @@ void *probe_access(CPUArchState *env, vaddr addr, int size,
804
805 g_assert(-(addr | TARGET_PAGE_MASK) >= size);
806 flags = probe_access_internal(env, addr, size, access_type, false, ra);
807 - g_assert((flags & ~TLB_MMIO) == 0);
807 + g_assert((flags & ~TLB_FORCE_SLOW) == 0);
808
809 return size ? g2h_vaddr(env_cpu(env), addr) : NULL;
810 }
include/exec/tlb-flags.h
+4 -3
@@ -27,12 +27,13 @@
27
28 /*
29 * Allow some level of source compatibility with softmmu.
30 - * Invalid is set when the page does not have requested permissions.
31 - * MMIO is set when we want the target helper to use the functional
30 + * INVALID is set when the page does not have requested permissions.
31 + * FORCE_SLOW is set when we want the target helper to use the functional
32 * interface for load/store so that plugins see the access.
33 */
34 #define TLB_INVALID_MASK (1 << 0)
35 -#define TLB_MMIO (1 << 1)
35 +#define TLB_FORCE_SLOW (1 << 1)
36 +#define TLB_MMIO 0
37 #define TLB_WATCHPOINT 0
38
39 #else