Re: Save a WRMSR GS.base?
From: H. Peter Anvin
Date: Thu Jun 18 2026 - 14:19:46 EST
On June 18, 2026 3:22:56 AM PDT, David Laight <david.laight.linux@xxxxxxxxx> wrote:
>On Wed, 17 Jun 2026 18:09:02 -0700
>Borislav Petkov <bp@xxxxxxxxx> wrote:
>
>> Ok,
>>
>> I think I incorporated them all:
>...
>> +Btw, while running in kernel mode, MSR_KERNEL_GS_BASE contains actually the
>> +*user* GS.base. Thus, the naming can be confusing. Unless one thinks of it as
>> +the kernel's access to GS.base as MSRs are accessible only in CPL0.
>
>That last sentence doesn't read right. Maybe:
>
>The naming of MSR_KERNEL_GS_BASE is rather confusing.
>In can only be accessed in kernel mode where it normally contains the
>USER GS.base.
>The only time it contains the KERNEL GS.base is on system call/interrupt entry
>prior to swapgs being executed (and late in the return to user paths).
>
>As an aside I think a 32bit program can detect hardware interrupts.
>If %gs/%fs is loaded from an LDT and then the LDT entry changed (eg
>a different limit) then the new limit will be loaded by the ISR
>return path.
>I seem to remember deciding that it was impossible to actual restore
>the actual register value.
>
> David
Not just 32-bit programs; any program using IDT, simply by loading a nonzero null selector. FRED does close that gap.