[tip: x86/asm] x86/asm/fsgsbase: Remove unnecessary "memory" clobbers from FS/GS base (read-) accessors
From: tip-bot2 for Uros Bizjak
Date: Mon Mar 30 2026 - 03:18:34 EST
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: d9576c9cd6a3056435e8e974c36ef576816a6c99
Gitweb: https://git.kernel.org/tip/d9576c9cd6a3056435e8e974c36ef576816a6c99
Author: Uros Bizjak <ubizjak@xxxxxxxxx>
AuthorDate: Mon, 30 Mar 2026 07:57:42 +02:00
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitterDate: Mon, 30 Mar 2026 09:10:15 +02:00
x86/asm/fsgsbase: Remove unnecessary "memory" clobbers from FS/GS base (read-) accessors
The rdfsbase() and rdgsbase() helpers currently include a "memory"
clobber in their inline assembly definitions. However, the RDFSBASE
and RDGSBASE instructions only read the FS/GS base MSRs into a
general-purpose register and do not access memory. The "memory" clobber,
which acts as a compiler barrier and may inhibit optimization,
is therefore unnecessary.
The "memory" clobber was historically used as a scheduling constraint
to prevent the compiler from moving the instructions before preceding
segment register loads. This is not required because both the segment
register loads and the RDFSBASE/RDGSBASE accessors are implemented
with `asm volatile`, which already prevents reordering between them.
No functional change intended.
Signed-off-by: Uros Bizjak <ubizjak@xxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: H. Peter Anvin <hpa@xxxxxxxxx>
Link: https://patch.msgid.link/20260330055823.5793-1-ubizjak@xxxxxxxxx
---
arch/x86/include/asm/fsgsbase.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/fsgsbase.h b/arch/x86/include/asm/fsgsbase.h
index ab2547f..70ff4ef 100644
--- a/arch/x86/include/asm/fsgsbase.h
+++ b/arch/x86/include/asm/fsgsbase.h
@@ -25,7 +25,7 @@ static __always_inline unsigned long rdfsbase(void)
{
unsigned long fsbase;
- asm volatile("rdfsbase %0" : "=r" (fsbase) :: "memory");
+ asm volatile("rdfsbase %0" : "=r" (fsbase));
return fsbase;
}
@@ -34,7 +34,7 @@ static __always_inline unsigned long rdgsbase(void)
{
unsigned long gsbase;
- asm volatile("rdgsbase %0" : "=r" (gsbase) :: "memory");
+ asm volatile("rdgsbase %0" : "=r" (gsbase));
return gsbase;
}