Skip to contentSkip to conversation

x86/cpufeatures: Correct LKGS feature flag description

PATCH In review Borislav Petkov 4 participants 10 messages Oct 15, 2025 – Oct 16, 2025 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/cpufeatures: Correct LKGS feature flag description

From: "Borislav Petkov (AMD)" <[email protected]>

Quotation marks in cpufeatures.h comments are special and when the comment begins with a quoted string, that string lands in /proc/cpuinfo, turning it into a user-visible one.

The LKGS comment doesn't begin with a quoted string but just in case drop the quoted "kernel" in there to avoid confusion. And while at it, simply change the description into what the LKGS instruction does for more clarity.

No functional changes.

---
 arch/x86/include/asm/cpufeatures.h       | 2 +-
 tools/arch/x86/include/asm/cpufeatures.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/cpufeatures.h +1 -1
index 80b68f4726e7..4fb5e12dbdbf 100644
@@ -320,7 +320,7 @@
 #define X86_FEATURE_FSRS		(12*32+11) /* Fast short REP STOSB */
 #define X86_FEATURE_FSRC		(12*32+12) /* Fast short REP {CMPSB,SCASB} */
 #define X86_FEATURE_FRED		(12*32+17) /* "fred" Flexible Return and Event Delivery */
-#define X86_FEATURE_LKGS		(12*32+18) /* Load "kernel" (userspace) GS */
+#define X86_FEATURE_LKGS		(12*32+18) /* MSR_KERNEL_GS_BASE = GS.base */
 #define X86_FEATURE_WRMSRNS		(12*32+19) /* Non-serializing WRMSR */
 #define X86_FEATURE_AMX_FP16		(12*32+21) /* AMX fp16 Support */
 #define X86_FEATURE_AVX_IFMA            (12*32+23) /* Support for VPMADD52[H,L]UQ */
tools/arch/x86/include/asm/cpufeatures.h +1 -1
index bd655e100395..d5f091babf96 100644
@@ -320,7 +320,7 @@
 #define X86_FEATURE_FSRS		(12*32+11) /* Fast short REP STOSB */
 #define X86_FEATURE_FSRC		(12*32+12) /* Fast short REP {CMPSB,SCASB} */
 #define X86_FEATURE_FRED		(12*32+17) /* "fred" Flexible Return and Event Delivery */
-#define X86_FEATURE_LKGS		(12*32+18) /* Load "kernel" (userspace) GS */
+#define X86_FEATURE_LKGS		(12*32+18) /* MSR_KERNEL_GS_BASE = GS.base */
 #define X86_FEATURE_WRMSRNS		(12*32+19) /* Non-serializing WRMSR */
 #define X86_FEATURE_AMX_FP16		(12*32+21) /* AMX fp16 Support */
 #define X86_FEATURE_AVX_IFMA            (12*32+23) /* Support for VPMADD52[H,L]UQ */
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Borislav Petkov

From: "Borislav Petkov (AMD)" <[email protected]>

Quotation marks in cpufeatures.h comments are special and when the comment begins with a quoted string, that string lands in /proc/cpuinfo, turning it into a user-visible one.

The LKGS comment doesn't begin with a quoted string but just in case drop the quoted "kernel" in there to avoid confusion. And while at it, simply change the description into what the LKGS instruction does for more clarity.

No functional changes.

---
  arch/x86/include/asm/cpufeatures.h       | 2 +-
  tools/arch/x86/include/asm/cpufeatures.h | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/cpufeatures.h +0 -0
index 80b68f4726e7..4fb5e12dbdbf 100644

arch/x86/include/asm/cpufeatures.h line 323

Quoted 5 lines
arch/x86/include/asm/cpufeatures.h +1 -1
@@ -320,7 +320,7 @@
  #define X86_FEATURE_FSRS		(12*32+11) /* Fast short REP STOSB */
  #define X86_FEATURE_FSRC		(12*32+12) /* Fast short REP {CMPSB,SCASB} */
  #define X86_FEATURE_FRED		(12*32+17) /* "fred" Flexible Return and Event Delivery */
-#define X86_FEATURE_LKGS		(12*32+18) /* Load "kernel" (userspace) GS */
+#define X86_FEATURE_LKGS		(12*32+18) /* MSR_KERNEL_GS_BASE = GS.base */

Yes, the assignment is more clearer to us programmers.

I'm just not sure if "correct" in the shortlog is accurate; it sounds the existing one is wrong. Otherwise,

Quoted 16 lines
arch/x86/include/asm/cpufeatures.h +0 -0
  #define X86_FEATURE_WRMSRNS		(12*32+19) /* Non-serializing WRMSR */
  #define X86_FEATURE_AMX_FP16		(12*32+21) /* AMX fp16 Support */
  #define X86_FEATURE_AVX_IFMA            (12*32+23) /* Support for VPMADD52[H,L]UQ */
tools/arch/x86/include/asm/cpufeatures.h +1 -1
index bd655e100395..d5f091babf96 100644
@@ -320,7 +320,7 @@
  #define X86_FEATURE_FSRS		(12*32+11) /* Fast short REP STOSB */
  #define X86_FEATURE_FSRC		(12*32+12) /* Fast short REP {CMPSB,SCASB} */
  #define X86_FEATURE_FRED		(12*32+17) /* "fred" Flexible Return and Event Delivery */
-#define X86_FEATURE_LKGS		(12*32+18) /* Load "kernel" (userspace) GS */
+#define X86_FEATURE_LKGS		(12*32+18) /* MSR_KERNEL_GS_BASE = GS.base */
  #define X86_FEATURE_WRMSRNS		(12*32+19) /* Non-serializing WRMSR */
  #define X86_FEATURE_AMX_FP16		(12*32+21) /* AMX fp16 Support */
  #define X86_FEATURE_AVX_IFMA            (12*32+23) /* Support for VPMADD52[H,L]UQ */
#2 lore raw
Quoted 43 lines · Xin Li
Quoted 24 lines · Borislav Petkov

From: "Borislav Petkov (AMD)" <[email protected]>

Quotation marks in cpufeatures.h comments are special and when the comment begins with a quoted string, that string lands in /proc/cpuinfo, turning it into a user-visible one.

The LKGS comment doesn't begin with a quoted string but just in case drop the quoted "kernel" in there to avoid confusion. And while at it, simply change the description into what the LKGS instruction does for more clarity.

No functional changes.

---
  arch/x86/include/asm/cpufeatures.h       | 2 +-
  tools/arch/x86/include/asm/cpufeatures.h | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/cpufeatures.h +0 -0
index 80b68f4726e7..4fb5e12dbdbf 100644

arch/x86/include/asm/cpufeatures.h line 323

Quoted 5 lines
arch/x86/include/asm/cpufeatures.h +1 -1
@@ -320,7 +320,7 @@
  #define X86_FEATURE_FSRS		(12*32+11) /* Fast short REP STOSB */
  #define X86_FEATURE_FSRC		(12*32+12) /* Fast short REP {CMPSB,SCASB} */
  #define X86_FEATURE_FRED		(12*32+17) /* "fred" Flexible Return and Event Delivery */
-#define X86_FEATURE_LKGS		(12*32+18) /* Load "kernel" (userspace) GS */
+#define X86_FEATURE_LKGS		(12*32+18) /* MSR_KERNEL_GS_BASE = GS.base */

Yes, the assignment is more clearer to us programmers.

I'm just not sure if "correct" in the shortlog is accurate; it sounds the existing one is wrong. Otherwise,

Quoted 17 lines
Quoted 8 lines
arch/x86/include/asm/cpufeatures.h +0 -0
  #define X86_FEATURE_WRMSRNS		(12*32+19) /* Non-serializing WRMSR */
  #define X86_FEATURE_AMX_FP16		(12*32+21) /* AMX fp16 Support */
  #define X86_FEATURE_AVX_IFMA            (12*32+23) /* Support for VPMADD52[H,L]UQ */
tools/arch/x86/include/asm/cpufeatures.h +0 -0
index bd655e100395..d5f091babf96 100644

tools/arch/x86/include/asm/cpufeatures.h line 326

Quoted 8 lines
tools/arch/x86/include/asm/cpufeatures.h +1 -1
@@ -320,7 +320,7 @@
  #define X86_FEATURE_FSRS		(12*32+11) /* Fast short REP STOSB */
  #define X86_FEATURE_FSRC		(12*32+12) /* Fast short REP {CMPSB,SCASB} */
  #define X86_FEATURE_FRED		(12*32+17) /* "fred" Flexible Return and Event Delivery */
-#define X86_FEATURE_LKGS		(12*32+18) /* Load "kernel" (userspace) GS */
+#define X86_FEATURE_LKGS		(12*32+18) /* MSR_KERNEL_GS_BASE = GS.base */
  #define X86_FEATURE_WRMSRNS		(12*32+19) /* Non-serializing WRMSR */
  #define X86_FEATURE_AMX_FP16		(12*32+21) /* AMX fp16 Support */
  #define X86_FEATURE_AVX_IFMA            (12*32+23) /* Support for VPMADD52[H,L]UQ */

That "assignment" is rather wrong, though; it implies that the two are identical, which they are not; nor does it imply the relationship is fixed (that is provided by FRED, not LKGS). Perhaps just call it "Load user space GS".

#3 lore raw
Quoted 34 lines · H. Peter Anvin
Quoted 33 lines · Xin Li
Quoted 24 lines · Borislav Petkov

From: "Borislav Petkov (AMD)" <[email protected]>

Quotation marks in cpufeatures.h comments are special and when the comment begins with a quoted string, that string lands in /proc/cpuinfo, turning it into a user-visible one.

The LKGS comment doesn't begin with a quoted string but just in case drop the quoted "kernel" in there to avoid confusion. And while at it, simply change the description into what the LKGS instruction does for more clarity.

No functional changes.

---
   arch/x86/include/asm/cpufeatures.h       | 2 +-
   tools/arch/x86/include/asm/cpufeatures.h | 2 +-
   2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/cpufeatures.h +0 -0
index 80b68f4726e7..4fb5e12dbdbf 100644

arch/x86/include/asm/cpufeatures.h line 323

Quoted 5 lines
arch/x86/include/asm/cpufeatures.h +1 -1
@@ -320,7 +320,7 @@
   #define X86_FEATURE_FSRS		(12*32+11) /* Fast short REP STOSB */
   #define X86_FEATURE_FSRC		(12*32+12) /* Fast short REP {CMPSB,SCASB} */
   #define X86_FEATURE_FRED		(12*32+17) /* "fred" Flexible Return and Event Delivery */
-#define X86_FEATURE_LKGS		(12*32+18) /* Load "kernel" (userspace) GS */
+#define X86_FEATURE_LKGS		(12*32+18) /* MSR_KERNEL_GS_BASE = GS.base */

Yes, the assignment is more clearer to us programmers.

Quoted 7 lines
Quoted 5 lines

I'm just not sure if "correct" in the shortlog is accurate; it sounds the existing one is wrong. Otherwise,

That "assignment" is rather wrong, though; it implies that the two are identical, which they are not; nor does it imply the relationship is fixed (that is provided by FRED, not LKGS). Perhaps just call it "Load user space GS".

I see your point, is the following assignment better?

    MSR_KERNEL_GS_BASE = gs_sel->base
#4 lore raw
Quoted 38 lines · Xin Li
Quoted 37 lines · H. Peter Anvin
Quoted 36 lines · Xin Li
Quoted 24 lines · Borislav Petkov

From: "Borislav Petkov (AMD)" <[email protected]>

Quotation marks in cpufeatures.h comments are special and when the comment begins with a quoted string, that string lands in /proc/cpuinfo, turning it into a user-visible one.

The LKGS comment doesn't begin with a quoted string but just in case drop the quoted "kernel" in there to avoid confusion. And while at it, simply change the description into what the LKGS instruction does for more clarity.

No functional changes.

---
   arch/x86/include/asm/cpufeatures.h       | 2 +-
   tools/arch/x86/include/asm/cpufeatures.h | 2 +-
   2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/cpufeatures.h +0 -0
index 80b68f4726e7..4fb5e12dbdbf 100644

arch/x86/include/asm/cpufeatures.h line 323

Quoted 5 lines
arch/x86/include/asm/cpufeatures.h +1 -1
@@ -320,7 +320,7 @@
   #define X86_FEATURE_FSRS		(12*32+11) /* Fast short REP STOSB */
   #define X86_FEATURE_FSRC		(12*32+12) /* Fast short REP {CMPSB,SCASB} */
   #define X86_FEATURE_FRED		(12*32+17) /* "fred" Flexible Return and Event Delivery */
-#define X86_FEATURE_LKGS		(12*32+18) /* Load "kernel" (userspace) GS */
+#define X86_FEATURE_LKGS		(12*32+18) /* MSR_KERNEL_GS_BASE = GS.base */

Yes, the assignment is more clearer to us programmers.

I'm just not sure if "correct" in the shortlog is accurate; it sounds the existing one is wrong. Otherwise,

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

That "assignment" is rather wrong, though; it implies that the two are identical, which they are not; nor does it imply the relationship is fixed (that is provided by FRED, not LKGS). Perhaps just call it "Load user space GS".

I see your point, is the following assignment better?

   MSR_KERNEL_GS_BASE = gs_sel->base

Except that that is also wrong, because that's not all of what the instruction does. "Load user space GS" is really what it does, despite the initiate historical naming.

#5 lore raw
Quoted 42 lines · H. Peter Anvin
Quoted 41 lines · Xin Li
Quoted 40 lines · H. Peter Anvin
Quoted 38 lines · Xin Li
Quoted 24 lines · Borislav Petkov

From: "Borislav Petkov (AMD)" <[email protected]>

Quotation marks in cpufeatures.h comments are special and when the comment begins with a quoted string, that string lands in /proc/cpuinfo, turning it into a user-visible one.

The LKGS comment doesn't begin with a quoted string but just in case drop the quoted "kernel" in there to avoid confusion. And while at it, simply change the description into what the LKGS instruction does for more clarity.

No functional changes.

---
    arch/x86/include/asm/cpufeatures.h       | 2 +-
    tools/arch/x86/include/asm/cpufeatures.h | 2 +-
    2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/cpufeatures.h +0 -0
index 80b68f4726e7..4fb5e12dbdbf 100644

arch/x86/include/asm/cpufeatures.h line 323

Quoted 5 lines
arch/x86/include/asm/cpufeatures.h +1 -1
@@ -320,7 +320,7 @@
    #define X86_FEATURE_FSRS		(12*32+11) /* Fast short REP STOSB */
    #define X86_FEATURE_FSRC		(12*32+12) /* Fast short REP {CMPSB,SCASB} */
    #define X86_FEATURE_FRED		(12*32+17) /* "fred" Flexible Return and Event Delivery */
-#define X86_FEATURE_LKGS		(12*32+18) /* Load "kernel" (userspace) GS */
+#define X86_FEATURE_LKGS		(12*32+18) /* MSR_KERNEL_GS_BASE = GS.base */

Yes, the assignment is more clearer to us programmers.

I'm just not sure if "correct" in the shortlog is accurate; it sounds the existing one is wrong. Otherwise,

Quoted 9 lines
Quoted 6 lines
Quoted 1 line

That "assignment" is rather wrong, though; it implies that the two are identical, which they are not; nor does it imply the relationship is fixed (that is provided by FRED, not LKGS). Perhaps just call it "Load user space GS".

I see your point, is the following assignment better?

    MSR_KERNEL_GS_BASE = gs_sel->base

Except that that is also wrong, because that's not all of what the instruction does. "Load user space GS" is really what it does, despite the initiate historical naming.

Do you mean the load of GS attributes by LKGS is still missing?

#6 lore raw
Quoted 47 lines · Xin Li
Quoted 46 lines · H. Peter Anvin
Quoted 45 lines · Xin Li
Quoted 34 lines · H. Peter Anvin
Quoted 33 lines · Xin Li
Quoted 24 lines · Borislav Petkov

From: "Borislav Petkov (AMD)" <[email protected]>

Quotation marks in cpufeatures.h comments are special and when the comment begins with a quoted string, that string lands in /proc/cpuinfo, turning it into a user-visible one.

The LKGS comment doesn't begin with a quoted string but just in case drop the quoted "kernel" in there to avoid confusion. And while at it, simply change the description into what the LKGS instruction does for more clarity.

No functional changes.

---
    arch/x86/include/asm/cpufeatures.h       | 2 +-
    tools/arch/x86/include/asm/cpufeatures.h | 2 +-
    2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/cpufeatures.h +0 -0
index 80b68f4726e7..4fb5e12dbdbf 100644

arch/x86/include/asm/cpufeatures.h line 323

Quoted 5 lines
arch/x86/include/asm/cpufeatures.h +1 -1
@@ -320,7 +320,7 @@
    #define X86_FEATURE_FSRS		(12*32+11) /* Fast short REP STOSB */
    #define X86_FEATURE_FSRC		(12*32+12) /* Fast short REP {CMPSB,SCASB} */
    #define X86_FEATURE_FRED		(12*32+17) /* "fred" Flexible Return and Event Delivery */
-#define X86_FEATURE_LKGS		(12*32+18) /* Load "kernel" (userspace) GS */
+#define X86_FEATURE_LKGS		(12*32+18) /* MSR_KERNEL_GS_BASE = GS.base */

Yes, the assignment is more clearer to us programmers.

Quoted 7 lines
Quoted 5 lines

I'm just not sure if "correct" in the shortlog is accurate; it sounds the existing one is wrong. Otherwise,

That "assignment" is rather wrong, though; it implies that the two are identical, which they are not; nor does it imply the relationship is fixed (that is provided by FRED, not LKGS). Perhaps just call it "Load user space GS".

I see your point, is the following assignment better?

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
    MSR_KERNEL_GS_BASE = gs_sel->base

Except that that is also wrong, because that's not all of what the instruction does. "Load user space GS" is really what it does, despite the initiate historical naming.

Do you mean the load of GS attributes by LKGS is still missing?

Yes. It's really a modified MOV GS,... instruction that loads the base, limit, selector, and attributes; it just loads the base into a different place.

maintainer
#7 lore raw
Quoted 6 lines · H. Peter Anvin
Quoted 4 lines
Quoted 2 lines

Except that that is also wrong, because that's not all of what the instruction does. "Load user space GS" is really what it does, despite the initiate historical naming.

Do you mean the load of GS attributes by LKGS is still missing?

Yes. It's really a modified MOV GS,... instruction that loads the base, limit, selector, and attributes; it just loads the base into a different place.

Ok, "Load user space GS base" it is. Considering how you can't load any other GS.base due to it GPing for CPL > 0.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#8 lore raw
Quoted 11 lines · Borislav Petkov
Quoted 6 lines · H. Peter Anvin
Quoted 4 lines
Quoted 2 lines

Except that that is also wrong, because that's not all of what the instruction does. "Load user space GS" is really what it does, despite the initiate historical naming.

Do you mean the load of GS attributes by LKGS is still missing?

Yes. It's really a modified MOV GS,... instruction that loads the base, limit, selector, and attributes; it just loads the base into a different place.

Ok, "Load user space GS base" it is. Considering how you can't load any other GS.base due to it GPing for CPL > 0.

No, "load user space GS." It loads everything, not just the base.

maintainer
#9 lore raw
Quoted 1 line · H. Peter Anvin

No, "load user space GS." It loads everything, not just the base.

My aim is to have the comment be maximally helpful:

#define X86_FEATURE_LKGS (12*32+18) /* Like MOV_GS except MSR_KERNEL_GS_BASE = GS.base */

This is the gist of what's in the FRED spec.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette