[RFC PATCH 11/16] Documentation/features: Update the membarrier sync core requirements
Mathieu Desnoyers
mathieu.desnoyers at efficios.com
Fri Nov 13 05:18:58 PST 2026
The x86 text says that the return from interrupt uses IRET, which
serializes the core after the IPI. This is not what the code relies
on, and it is not always true:
- Since commit a493d1ca1a03 ("x86/membarrier: Get rid of a dubious
optimization"), the IPI handler issues a core serializing
instruction right away. The interrupted thread can be rescheduled
before the return from interrupt, and another thread of the mm can
then return to user-space through SYSRET.
- With FRED, the kernel returns through ERETS and ERETU. The Intel
SDM does not list them as serializing instructions. It states that
ERETU has the instruction ordering guarantees of SYSRET.
The AMD APM does not describe these two instructions.
Describe what x86 relies on instead: sync_core_before_usermode() and
the writes to CR3.
On arm64 with FEAT_ExS, an exception return is a context
synchronization event only when SCTLR_ELx.EOS is set. The kernel sets
it. Document that the sync core command depends on it.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
.../membarrier-sync-core/arch-support.txt | 35 +++++++++++++------
1 file changed, 24 insertions(+), 11 deletions(-)
diff --git a/Documentation/features/sched/membarrier-sync-core/arch-support.txt b/Documentation/features/sched/membarrier-sync-core/arch-support.txt
index 7425d2b994a3..2782b0d25f43 100644
--- a/Documentation/features/sched/membarrier-sync-core/arch-support.txt
+++ b/Documentation/features/sched/membarrier-sync-core/arch-support.txt
@@ -10,6 +10,10 @@
# Rely on implicit context synchronization as a result of exception return
# when returning from IPI handler, and when returning to user-space.
#
+# On arm64 with FEAT_ExS, an exception return is a context synchronization
+# event only when SCTLR_ELx.EOS is set. The kernel sets it, cf.
+# SCTLR_EL1_EOS in INIT_SCTLR_EL1_MMU_ON. It must stay set.
+#
# * riscv
#
# riscv uses xRET as return from interrupt and to return to user-space.
@@ -28,19 +32,28 @@
#
# * x86
#
-# x86-32 uses IRET as return from interrupt, which takes care of the IPI.
-# However, it uses both IRET and SYSEXIT to go back to user-space. The IRET
-# instruction is core serializing, but not SYSEXIT.
+# x86-32 returns to user-space through either IRET or SYSEXIT. x86-64 returns
+# to user-space through either SYSRETL (compat code), SYSRETQ or IRET, or
+# through ERETU when FRED is enabled. It returns from interrupt through IRET,
+# or through ERETS or ERETU when FRED is enabled.
+#
+# The IRET instruction is core serializing. SYSRET{L,Q}, SYSEXIT, ERETS and
+# ERETU are not. Therefore x86 does not rely on the return instruction:
+#
+# - the IPI handler calls sync_core_before_usermode(), which issues a core
+# serializing instruction right away (cf. ipi_sync_core()). The thread may
+# otherwise be rescheduled before the return from interrupt, and a thread
+# of the same mm may return to user-space through SYSRET,
+#
+# - write_cr3() performed by switch_mm() provides core serialization after
+# changing the current mm,
#
-# x86-64 uses IRET as return from interrupt, which takes care of the IPI.
-# However, it can return to user-space through either SYSRETL (compat code),
-# SYSRETQ, or IRET.
+# - the special case of kthread -> uthread (temporarily keeping current mm
+# into active_mm) issues a sync_core_before_usermode().
#
-# Given that neither SYSRET{L,Q}, nor SYSEXIT, are core serializing, we rely
-# instead on write_cr3() performed by switch_mm() to provide core serialization
-# after changing the current mm, and deal with the special case of kthread ->
-# uthread (temporarily keeping current mm into active_mm) by issuing a
-# sync_core_before_usermode() in that specific case.
+# With page table isolation, sync_core_before_usermode() does nothing: each
+# return to user-space writes to CR3, which is core serializing. Page table
+# isolation and FRED are mutually exclusive.
#
-----------------------
| arch |status|
--
2.47.3
More information about the linux-riscv
mailing list