public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/cpufeatures: Correct LKGS feature flag description
@ 2025-10-15 10:35 Borislav Petkov
  2025-10-15 15:08 ` Xin Li
  0 siblings, 1 reply; 10+ messages in thread
From: Borislav Petkov @ 2025-10-15 10:35 UTC (permalink / raw)
  To: H. Peter Anvin, Xin Li; +Cc: X86 ML, LKML, Borislav Petkov (AMD)

From: "Borislav Petkov (AMD)" <bp@alien8.de>

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.

Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
---
 arch/x86/include/asm/cpufeatures.h       | 2 +-
 tools/arch/x86/include/asm/cpufeatures.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index 80b68f4726e7..4fb5e12dbdbf 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -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 */
diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h
index bd655e100395..d5f091babf96 100644
--- a/tools/arch/x86/include/asm/cpufeatures.h
+++ b/tools/arch/x86/include/asm/cpufeatures.h
@@ -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.51.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/cpufeatures: Correct LKGS feature flag description
  2025-10-15 10:35 [PATCH] x86/cpufeatures: Correct LKGS feature flag description Borislav Petkov
@ 2025-10-15 15:08 ` Xin Li
  2025-10-15 15:18   ` H. Peter Anvin
  0 siblings, 1 reply; 10+ messages in thread
From: Xin Li @ 2025-10-15 15:08 UTC (permalink / raw)
  To: Borislav Petkov, H. Peter Anvin, Xin Li
  Cc: X86 ML, LKML, Borislav Petkov (AMD)

On 10/15/2025 6:35 PM, Borislav Petkov wrote:
> From: "Borislav Petkov (AMD)" <bp@alien8.de>
> 
> 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.
> 
> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
> ---
>   arch/x86/include/asm/cpufeatures.h       | 2 +-
>   tools/arch/x86/include/asm/cpufeatures.h | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
> index 80b68f4726e7..4fb5e12dbdbf 100644
> --- a/arch/x86/include/asm/cpufeatures.h
> +++ b/arch/x86/include/asm/cpufeatures.h
> @@ -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,

Reviewed-by: Xin Li (Intel) <xin@zytor.com>






>   #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 */
> diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h
> index bd655e100395..d5f091babf96 100644
> --- a/tools/arch/x86/include/asm/cpufeatures.h
> +++ b/tools/arch/x86/include/asm/cpufeatures.h
> @@ -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 */


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/cpufeatures: Correct LKGS feature flag description
  2025-10-15 15:08 ` Xin Li
@ 2025-10-15 15:18   ` H. Peter Anvin
  2025-10-15 15:34     ` Xin Li
  0 siblings, 1 reply; 10+ messages in thread
From: H. Peter Anvin @ 2025-10-15 15:18 UTC (permalink / raw)
  To: Xin Li, Borislav Petkov, Xin Li; +Cc: X86 ML, LKML, Borislav Petkov (AMD)

On October 15, 2025 8:08:17 AM PDT, Xin Li <xin@zytor.com> wrote:
>On 10/15/2025 6:35 PM, Borislav Petkov wrote:
>> From: "Borislav Petkov (AMD)" <bp@alien8.de>
>> 
>> 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.
>> 
>> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
>> ---
>>   arch/x86/include/asm/cpufeatures.h       | 2 +-
>>   tools/arch/x86/include/asm/cpufeatures.h | 2 +-
>>   2 files changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
>> index 80b68f4726e7..4fb5e12dbdbf 100644
>> --- a/arch/x86/include/asm/cpufeatures.h
>> +++ b/arch/x86/include/asm/cpufeatures.h
>> @@ -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,
>
>Reviewed-by: Xin Li (Intel) <xin@zytor.com>
>
>
>
>
>
>
>>   #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 */
>> diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h
>> index bd655e100395..d5f091babf96 100644
>> --- a/tools/arch/x86/include/asm/cpufeatures.h
>> +++ b/tools/arch/x86/include/asm/cpufeatures.h
>> @@ -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".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/cpufeatures: Correct LKGS feature flag description
  2025-10-15 15:18   ` H. Peter Anvin
@ 2025-10-15 15:34     ` Xin Li
  2025-10-15 15:36       ` H. Peter Anvin
  0 siblings, 1 reply; 10+ messages in thread
From: Xin Li @ 2025-10-15 15:34 UTC (permalink / raw)
  To: H. Peter Anvin, Borislav Petkov, Xin Li
  Cc: X86 ML, LKML, Borislav Petkov (AMD)

On 10/15/2025 11:18 PM, H. Peter Anvin wrote:
> On October 15, 2025 8:08:17 AM PDT, Xin Li <xin@zytor.com> wrote:
>> On 10/15/2025 6:35 PM, Borislav Petkov wrote:
>>> From: "Borislav Petkov (AMD)" <bp@alien8.de>
>>>
>>> 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.
>>>
>>> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
>>> ---
>>>    arch/x86/include/asm/cpufeatures.h       | 2 +-
>>>    tools/arch/x86/include/asm/cpufeatures.h | 2 +-
>>>    2 files changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
>>> index 80b68f4726e7..4fb5e12dbdbf 100644
>>> --- a/arch/x86/include/asm/cpufeatures.h
>>> +++ b/arch/x86/include/asm/cpufeatures.h
>>> @@ -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,
>>
>> Reviewed-by: Xin Li (Intel) <xin@zytor.com>
>>
> 
> 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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/cpufeatures: Correct LKGS feature flag description
  2025-10-15 15:34     ` Xin Li
@ 2025-10-15 15:36       ` H. Peter Anvin
  2025-10-15 15:41         ` Xin Li
  0 siblings, 1 reply; 10+ messages in thread
From: H. Peter Anvin @ 2025-10-15 15:36 UTC (permalink / raw)
  To: Xin Li, Borislav Petkov, Xin Li; +Cc: X86 ML, LKML, Borislav Petkov (AMD)

On October 15, 2025 8:34:00 AM PDT, Xin Li <xin@zytor.com> wrote:
>On 10/15/2025 11:18 PM, H. Peter Anvin wrote:
>> On October 15, 2025 8:08:17 AM PDT, Xin Li <xin@zytor.com> wrote:
>>> On 10/15/2025 6:35 PM, Borislav Petkov wrote:
>>>> From: "Borislav Petkov (AMD)" <bp@alien8.de>
>>>> 
>>>> 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.
>>>> 
>>>> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
>>>> ---
>>>>    arch/x86/include/asm/cpufeatures.h       | 2 +-
>>>>    tools/arch/x86/include/asm/cpufeatures.h | 2 +-
>>>>    2 files changed, 2 insertions(+), 2 deletions(-)
>>>> 
>>>> diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
>>>> index 80b68f4726e7..4fb5e12dbdbf 100644
>>>> --- a/arch/x86/include/asm/cpufeatures.h
>>>> +++ b/arch/x86/include/asm/cpufeatures.h
>>>> @@ -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,
>>> 
>>> Reviewed-by: Xin Li (Intel) <xin@zytor.com>
>>> 
>> 
>> 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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/cpufeatures: Correct LKGS feature flag description
  2025-10-15 15:36       ` H. Peter Anvin
@ 2025-10-15 15:41         ` Xin Li
  2025-10-15 15:44           ` H. Peter Anvin
  0 siblings, 1 reply; 10+ messages in thread
From: Xin Li @ 2025-10-15 15:41 UTC (permalink / raw)
  To: H. Peter Anvin, Borislav Petkov, Xin Li
  Cc: X86 ML, LKML, Borislav Petkov (AMD)

On 10/15/2025 11:36 PM, H. Peter Anvin wrote:
> On October 15, 2025 8:34:00 AM PDT, Xin Li <xin@zytor.com> wrote:
>> On 10/15/2025 11:18 PM, H. Peter Anvin wrote:
>>> On October 15, 2025 8:08:17 AM PDT, Xin Li <xin@zytor.com> wrote:
>>>> On 10/15/2025 6:35 PM, Borislav Petkov wrote:
>>>>> From: "Borislav Petkov (AMD)" <bp@alien8.de>
>>>>>
>>>>> 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.
>>>>>
>>>>> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
>>>>> ---
>>>>>     arch/x86/include/asm/cpufeatures.h       | 2 +-
>>>>>     tools/arch/x86/include/asm/cpufeatures.h | 2 +-
>>>>>     2 files changed, 2 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
>>>>> index 80b68f4726e7..4fb5e12dbdbf 100644
>>>>> --- a/arch/x86/include/asm/cpufeatures.h
>>>>> +++ b/arch/x86/include/asm/cpufeatures.h
>>>>> @@ -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,
>>>>
>>>> Reviewed-by: Xin Li (Intel) <xin@zytor.com>
>>>>
>>>
>>> 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?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/cpufeatures: Correct LKGS feature flag description
  2025-10-15 15:41         ` Xin Li
@ 2025-10-15 15:44           ` H. Peter Anvin
  2025-10-15 15:49             ` Borislav Petkov
  0 siblings, 1 reply; 10+ messages in thread
From: H. Peter Anvin @ 2025-10-15 15:44 UTC (permalink / raw)
  To: Xin Li, Borislav Petkov, Xin Li; +Cc: X86 ML, LKML, Borislav Petkov (AMD)

On October 15, 2025 8:41:03 AM PDT, Xin Li <xin@zytor.com> wrote:
>On 10/15/2025 11:36 PM, H. Peter Anvin wrote:
>> On October 15, 2025 8:34:00 AM PDT, Xin Li <xin@zytor.com> wrote:
>>> On 10/15/2025 11:18 PM, H. Peter Anvin wrote:
>>>> On October 15, 2025 8:08:17 AM PDT, Xin Li <xin@zytor.com> wrote:
>>>>> On 10/15/2025 6:35 PM, Borislav Petkov wrote:
>>>>>> From: "Borislav Petkov (AMD)" <bp@alien8.de>
>>>>>> 
>>>>>> 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.
>>>>>> 
>>>>>> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
>>>>>> ---
>>>>>>     arch/x86/include/asm/cpufeatures.h       | 2 +-
>>>>>>     tools/arch/x86/include/asm/cpufeatures.h | 2 +-
>>>>>>     2 files changed, 2 insertions(+), 2 deletions(-)
>>>>>> 
>>>>>> diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
>>>>>> index 80b68f4726e7..4fb5e12dbdbf 100644
>>>>>> --- a/arch/x86/include/asm/cpufeatures.h
>>>>>> +++ b/arch/x86/include/asm/cpufeatures.h
>>>>>> @@ -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,
>>>>> 
>>>>> Reviewed-by: Xin Li (Intel) <xin@zytor.com>
>>>>> 
>>>> 
>>>> 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?

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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/cpufeatures: Correct LKGS feature flag description
  2025-10-15 15:44           ` H. Peter Anvin
@ 2025-10-15 15:49             ` Borislav Petkov
  2025-10-16  3:12               ` H. Peter Anvin
  0 siblings, 1 reply; 10+ messages in thread
From: Borislav Petkov @ 2025-10-15 15:49 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Xin Li, Borislav Petkov, Xin Li, X86 ML, LKML

On Wed, Oct 15, 2025 at 08:44:55AM -0700, H. Peter Anvin wrote:
> >> 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.

-- 
Regards/Gruss,
    Boris.

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/cpufeatures: Correct LKGS feature flag description
  2025-10-15 15:49             ` Borislav Petkov
@ 2025-10-16  3:12               ` H. Peter Anvin
  2025-10-16 12:41                 ` Borislav Petkov
  0 siblings, 1 reply; 10+ messages in thread
From: H. Peter Anvin @ 2025-10-16  3:12 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: Xin Li, Borislav Petkov, Xin Li, X86 ML, LKML

On October 15, 2025 8:49:11 AM PDT, Borislav Petkov <bp@alien8.de> wrote:
>On Wed, Oct 15, 2025 at 08:44:55AM -0700, H. Peter Anvin wrote:
>> >> 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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/cpufeatures: Correct LKGS feature flag description
  2025-10-16  3:12               ` H. Peter Anvin
@ 2025-10-16 12:41                 ` Borislav Petkov
  0 siblings, 0 replies; 10+ messages in thread
From: Borislav Petkov @ 2025-10-16 12:41 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Xin Li, Borislav Petkov, Xin Li, X86 ML, LKML

On Wed, Oct 15, 2025 at 08:12:08PM -0700, H. Peter Anvin wrote:
> 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.

-- 
Regards/Gruss,
    Boris.

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-10-16 12:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-15 10:35 [PATCH] x86/cpufeatures: Correct LKGS feature flag description Borislav Petkov
2025-10-15 15:08 ` Xin Li
2025-10-15 15:18   ` H. Peter Anvin
2025-10-15 15:34     ` Xin Li
2025-10-15 15:36       ` H. Peter Anvin
2025-10-15 15:41         ` Xin Li
2025-10-15 15:44           ` H. Peter Anvin
2025-10-15 15:49             ` Borislav Petkov
2025-10-16  3:12               ` H. Peter Anvin
2025-10-16 12:41                 ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox