Re: Save a WRMSR GS.base?

From: David Laight

Date: Thu Jun 18 2026 - 06:23:53 EST


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