News: 0001644452

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

Linux Preparing To Retire Its 32-bit MSR Interfaces

([Linux Kernel] 5 Hours Ago Modern MSR Code Rework)


Currently measuring in at 32 patches, SUSE engineer Juergen Gross has been leading the effort to end the Linux kernel's usage of their 32-bit model specific register (MSR) interfaces so the more modern 64-bit interfaces can be exclusively used. This allows for better code unification and cleaning up the MSR code.

Eliminating usage of the 32-bit MSR interfaces with the likes of rdmsr() and rdmsr_safe() is being done since the 64-bit interfaces like rdmsrq() are superior, all the MSR access macros can then be converted to inline functions, and will allow for more MSR code reorganization/improvements moving forward.

Juergen Gross explained in [1]the patch series :

"For accessing the MSR registers on the local CPU, there are 2 types of interfaces: the "modern" 64-bit ones (rdmsrq() etc.) and the 32-bit ones (rdmsr() etc.) which are using the upper and lower 32-bit halves of the 64-bit wide MSR register values.

The 32-bit interfaces are not optimal for 3 reasons:

- They are based on primitives using 64-bit sized values anyway.

- Modern x86 CPUs have added support for MSR access instructions using an immediate value instead of a register for addressing the MSR, while the value is in a 64-bit register.

- rdmsr() is a macro storing the upper and lower 32-bit halves in variables specified as macro parameters. This is obscuring variable assignment through a macro. Additionally rdmsrq() is mimicking this pattern by being a macro, too, with the target variable specified as a parameter as well.

For those reasons drop the 32-bit interfaces for accessing the x86 MSR registers completely and only use the 64-bit variants.

This allows to switch all "high-level" MSR access macros to inline functions in the end.

This series will be used as the base for further reorganisation of the MSR access functions, especially for completely inlining the MSR access instructions even with paravirtualization being active."

Some of these patches were queued over the past day into [2]tip/tip.git's x86/msr Git branch for avoiding use of the 32-bit MSR interfaces in various areas of the common x86 kernel code. The other patches are expected to land via their respective subsystem branches. With seeing this activity in tip/tip.git, that work should then land for the Linux 7.3 kernel cycle later in the year. If the rest of the patches are queued up in coming weeks in their respective branches, this could lead to the old interfaces being removed from the mainline kernel this year.

As brought up on the mailing list, this removal of the 32-bit MSR interfaces will not affect Linux's x86 32-bit CPU support. SImply the calling conventions will change within the kernel code but older 32-bit CPUs will still continue to function.



[1] https://lore.kernel.org/all/20260629060526.3638272-1-jgross@suse.com/

[2] https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/log/?h=x86/msr



"Of course, in Perl culture, almost nothis is prohibited. My feeling is that the rest of the world already has plenty of perfectly good prohibitions, so why invent more?"

-- Larry Wall (Open Sources, 1999 O'Reilly and Associates)