[PATCH 00/32] x86/msr: Drop 32-bit MSR interfaces

Juergen Gross posted 32 patches 5 days, 14 hours ago
Only 1 patches received!
There is a newer version of this series
arch/x86/coco/sev/core.c                      |  2 +-
arch/x86/events/amd/brs.c                     |  4 +-
arch/x86/events/amd/core.c                    |  8 +-
arch/x86/events/amd/ibs.c                     | 18 ++--
arch/x86/events/amd/lbr.c                     | 16 +--
arch/x86/events/amd/power.c                   |  8 +-
arch/x86/events/amd/uncore.c                  |  4 +-
arch/x86/events/core.c                        | 20 ++--
arch/x86/events/intel/core.c                  | 14 +--
arch/x86/events/intel/cstate.c                |  5 +-
arch/x86/events/intel/ds.c                    |  2 +-
arch/x86/events/intel/knc.c                   | 10 +-
arch/x86/events/intel/lbr.c                   | 25 ++---
arch/x86/events/intel/p4.c                    |  6 +-
arch/x86/events/intel/p6.c                    |  4 +-
arch/x86/events/intel/pt.c                    | 12 +--
arch/x86/events/intel/uncore.c                |  6 +-
arch/x86/events/intel/uncore_nhmex.c          |  4 +-
arch/x86/events/intel/uncore_snb.c            |  2 +-
arch/x86/events/intel/uncore_snbep.c          |  6 +-
arch/x86/events/msr.c                         |  2 +-
arch/x86/events/perf_event.h                  |  6 +-
arch/x86/events/rapl.c                        |  6 +-
arch/x86/events/zhaoxin/core.c                | 10 +-
arch/x86/hyperv/hv_apic.c                     | 17 ++--
arch/x86/hyperv/hv_init.c                     | 26 ++---
arch/x86/hyperv/hv_spinlock.c                 |  2 +-
arch/x86/include/asm/apic.h                   |  7 +-
arch/x86/include/asm/debugreg.h               |  6 +-
arch/x86/include/asm/fsgsbase.h               |  2 +-
arch/x86/include/asm/kvm_host.h               |  5 +-
arch/x86/include/asm/msr.h                    | 39 +-------
arch/x86/include/asm/paravirt.h               | 26 +----
arch/x86/include/asm/resctrl.h                |  5 +-
arch/x86/kernel/acpi/sleep.c                  | 20 ++--
arch/x86/kernel/apic/apic.c                   | 45 ++++-----
arch/x86/kernel/apic/apic_numachip.c          |  6 +-
arch/x86/kernel/cet.c                         |  2 +-
arch/x86/kernel/cpu/amd.c                     | 42 ++++----
arch/x86/kernel/cpu/aperfmperf.c              |  8 +-
arch/x86/kernel/cpu/bugs.c                    | 12 +--
arch/x86/kernel/cpu/bus_lock.c                |  8 +-
arch/x86/kernel/cpu/centaur.c                 | 35 +++----
arch/x86/kernel/cpu/common.c                  | 22 +++--
arch/x86/kernel/cpu/feat_ctl.c                | 27 +++---
arch/x86/kernel/cpu/hygon.c                   |  9 +-
arch/x86/kernel/cpu/intel.c                   | 12 +--
arch/x86/kernel/cpu/intel_epb.c               |  4 +-
arch/x86/kernel/cpu/mce/amd.c                 | 89 ++++++++---------
arch/x86/kernel/cpu/mce/core.c                | 10 +-
arch/x86/kernel/cpu/mce/inject.c              |  2 +-
arch/x86/kernel/cpu/mce/intel.c               | 18 ++--
arch/x86/kernel/cpu/mce/p5.c                  | 16 +--
arch/x86/kernel/cpu/mce/winchip.c             | 10 +-
arch/x86/kernel/cpu/microcode/intel.c         |  2 +-
arch/x86/kernel/cpu/mshyperv.c                |  6 +-
arch/x86/kernel/cpu/mtrr/amd.c                | 36 ++++---
arch/x86/kernel/cpu/mtrr/centaur.c            | 18 ++--
arch/x86/kernel/cpu/mtrr/cleanup.c            | 18 ++--
arch/x86/kernel/cpu/mtrr/generic.c            | 97 ++++++++++---------
arch/x86/kernel/cpu/mtrr/mtrr.c               |  4 +-
arch/x86/kernel/cpu/resctrl/core.c            |  9 +-
arch/x86/kernel/cpu/resctrl/monitor.c         | 27 +++---
arch/x86/kernel/cpu/resctrl/pseudo_lock.c     | 12 +--
arch/x86/kernel/cpu/resctrl/rdtgroup.c        |  2 +-
arch/x86/kernel/cpu/topology.c                |  2 +-
arch/x86/kernel/cpu/topology_amd.c            |  4 +-
arch/x86/kernel/cpu/transmeta.c               |  9 +-
arch/x86/kernel/cpu/tsx.c                     | 10 +-
arch/x86/kernel/cpu/umwait.c                  |  2 +-
arch/x86/kernel/cpu/zhaoxin.c                 | 12 +--
arch/x86/kernel/fpu/core.c                    |  2 +-
arch/x86/kernel/hpet.c                        |  2 +-
arch/x86/kernel/kvm.c                         |  2 +-
arch/x86/kernel/mmconf-fam10h_64.c            |  6 +-
arch/x86/kernel/process.c                     |  4 +-
arch/x86/kernel/process_64.c                  | 14 +--
arch/x86/kernel/shstk.c                       |  8 +-
arch/x86/kernel/traps.c                       |  4 +-
arch/x86/kernel/tsc.c                         |  8 +-
arch/x86/kernel/tsc_msr.c                     | 15 +--
arch/x86/kernel/tsc_sync.c                    |  6 +-
arch/x86/kvm/svm/pmu.c                        |  4 +-
arch/x86/kvm/svm/svm.c                        |  4 +-
arch/x86/kvm/vmx/nested.c                     |  4 +-
arch/x86/kvm/vmx/pmu_intel.c                  |  8 +-
arch/x86/kvm/vmx/sgx.c                        |  6 +-
arch/x86/kvm/vmx/vmx.c                        | 54 ++++++-----
arch/x86/kvm/x86.c                            | 12 +--
arch/x86/lib/insn-eval.c                      |  6 +-
arch/x86/lib/msr-smp.c                        |  8 +-
arch/x86/mm/pat/memtype.c                     |  2 +-
arch/x86/pci/amd_bus.c                        |  8 +-
arch/x86/pci/mmconfig-shared.c                |  8 +-
arch/x86/platform/olpc/olpc-xo1-rtc.c         |  6 +-
arch/x86/platform/olpc/olpc-xo1-sci.c         | 11 ++-
arch/x86/power/cpu.c                          | 10 +-
arch/x86/realmode/init.c                      |  2 +-
arch/x86/virt/hw.c                            |  8 +-
arch/x86/virt/svm/sev.c                       | 18 ++--
arch/x86/virt/vmx/tdx/tdx.c                   |  8 +-
arch/x86/xen/suspend.c                        |  2 +-
drivers/acpi/processor_perflib.c              | 11 ++-
drivers/acpi/processor_throttling.c           | 14 +--
drivers/ata/pata_cs5535.c                     | 20 ++--
drivers/ata/pata_cs5536.c                     | 17 ++--
drivers/char/agp/nvidia-agp.c                 | 32 +++---
drivers/char/hw_random/via-rng.c              | 29 +++---
drivers/cpufreq/acpi-cpufreq.c                | 24 ++---
drivers/cpufreq/amd-pstate.c                  |  4 +-
drivers/cpufreq/e_powersaver.c                | 52 +++++-----
drivers/cpufreq/intel_pstate.c                | 30 +++---
drivers/cpufreq/longhaul.c                    | 23 ++---
drivers/cpufreq/longrun.c                     | 78 ++++++++-------
drivers/cpufreq/powernow-k6.c                 | 12 +--
drivers/cpufreq/powernow-k7.c                 | 10 +-
drivers/cpufreq/powernow-k8.c                 | 67 ++++++-------
drivers/cpufreq/speedstep-centrino.c          | 16 +--
drivers/cpufreq/speedstep-lib.c               | 63 ++++++------
drivers/edac/amd64_edac.c                     |  6 +-
drivers/edac/ie31200_edac.c                   | 10 +-
drivers/edac/mce_amd.c                        |  8 +-
drivers/gpio/gpio-cs5535.c                    | 10 +-
drivers/hv/mshv_vtl_main.c                    |  2 +-
drivers/hwmon/hwmon-vid.c                     | 11 ++-
drivers/idle/intel_idle.c                     | 26 ++---
drivers/misc/cs5535-mfgpt.c                   | 33 +++----
drivers/mtd/nand/raw/cs553x_nand.c            |  6 +-
drivers/platform/x86/intel/ifs/load.c         | 10 +-
drivers/platform/x86/intel/ifs/runtest.c      |  8 +-
drivers/platform/x86/intel/pmc/cnp.c          |  2 +-
.../intel/speed_select_if/isst_if_mbox_msr.c  |  6 +-
.../intel/speed_select_if/isst_tpmi_core.c    |  2 +-
drivers/platform/x86/intel_ips.c              | 20 ++--
drivers/powercap/intel_rapl_common.c          | 20 ++--
drivers/powercap/intel_rapl_msr.c             |  2 +-
drivers/thermal/intel/intel_hfi.c             |  8 +-
drivers/thermal/intel/intel_tcc.c             | 10 +-
drivers/thermal/intel/therm_throt.c           | 74 +++++++-------
drivers/thermal/intel/x86_pkg_temp_thermal.c  | 32 +++---
drivers/video/fbdev/geode/display_gx.c        |  8 +-
drivers/video/fbdev/geode/gxfb_core.c         |  2 +-
drivers/video/fbdev/geode/lxfb_ops.c          | 50 +++++-----
drivers/video/fbdev/geode/suspend_gx.c        | 24 ++---
drivers/video/fbdev/geode/video_gx.c          |  8 +-
include/linux/cs5535.h                        | 10 +-
146 files changed, 1044 insertions(+), 1128 deletions(-)
[PATCH 00/32] x86/msr: Drop 32-bit MSR interfaces
Posted by Juergen Gross 5 days, 14 hours ago
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.

Note that most patches of this series are independent from each other.
Only the patches removing a specific interface (patches 7, 15, 26 and
30) and the last two patches of the series depend on all previous
patches.

Based on kernel 7.2-rc1, tested with and without parvirtualization
active, compile tested for x86 with 64- and 32-bit allyes and allno
configs.

Juergen Gross (32):
  thermal/intel: Stop using 32-bit MSR interfaces
  powercap: Stop using 32-bit MSR interfaces
  edac: Stop using 32-bit MSR interfaces
  acpi: Stop using 32-bit MSR interfaces
  x86/mtrr: Stop using 32-bit MSR interfaces
  x86/msr: Stop using 32-bit MSR interfaces in lib/msr-smp.c
  x86/msr: Remove wrmsr_safe()
  x86/mce: Stop using 32-bit MSR interfaces
  KVM/x86: Stop using 32-bit MSR interfaces
  x86/hygon: Stop using 32-bit MSR interfaces
  x86/pci: Stop using 32-bit MSR interfaces
  x86/amd: Stop using 32-bit MSR interfaces
  x86/featctl: Stop using 32-bit MSR interfaces
  x86/tsc: Stop using 32-bit MSR interfaces
  x86/msr: Remove rdmsr_safe()
  cpufreq: Stop using 32-bit MSR interfaces
  x86/resctrl: Stop using 32-bit MSR interfaces
  x86/apic: Stop using 32-bit MSR interfaces
  x86/cpu: Stop using 32-bit MSR interfaces
  drivers/ata: Stop using 32-bit MSR interfaces
  agp/nvidia: Stop using 32-bit MSR interfaces
  fbdev/geode: Stop using 32-bit MSR interfaces
  hw_random/via-rng: Stop using 32-bit MSR interfaces
  drivers/gpio: Stop using 32-bit MSR interfaces
  drivers/misc: Stop using 32-bit MSR interfaces
  x86/msr: Remove wrmsr()
  x86/hyperv: Stop using 32-bit MSR interfaces
  x86/olpc: Stop using 32-bit MSR interfaces
  hwmon: Stop using 32-bit MSR interfaces
  x86/msr: Remove rdmsr()
  treewide: convert rdmsrq() from a macro to an inline function
  x86/msr: Simplify some rdmsrq() use cases

 arch/x86/coco/sev/core.c                      |  2 +-
 arch/x86/events/amd/brs.c                     |  4 +-
 arch/x86/events/amd/core.c                    |  8 +-
 arch/x86/events/amd/ibs.c                     | 18 ++--
 arch/x86/events/amd/lbr.c                     | 16 +--
 arch/x86/events/amd/power.c                   |  8 +-
 arch/x86/events/amd/uncore.c                  |  4 +-
 arch/x86/events/core.c                        | 20 ++--
 arch/x86/events/intel/core.c                  | 14 +--
 arch/x86/events/intel/cstate.c                |  5 +-
 arch/x86/events/intel/ds.c                    |  2 +-
 arch/x86/events/intel/knc.c                   | 10 +-
 arch/x86/events/intel/lbr.c                   | 25 ++---
 arch/x86/events/intel/p4.c                    |  6 +-
 arch/x86/events/intel/p6.c                    |  4 +-
 arch/x86/events/intel/pt.c                    | 12 +--
 arch/x86/events/intel/uncore.c                |  6 +-
 arch/x86/events/intel/uncore_nhmex.c          |  4 +-
 arch/x86/events/intel/uncore_snb.c            |  2 +-
 arch/x86/events/intel/uncore_snbep.c          |  6 +-
 arch/x86/events/msr.c                         |  2 +-
 arch/x86/events/perf_event.h                  |  6 +-
 arch/x86/events/rapl.c                        |  6 +-
 arch/x86/events/zhaoxin/core.c                | 10 +-
 arch/x86/hyperv/hv_apic.c                     | 17 ++--
 arch/x86/hyperv/hv_init.c                     | 26 ++---
 arch/x86/hyperv/hv_spinlock.c                 |  2 +-
 arch/x86/include/asm/apic.h                   |  7 +-
 arch/x86/include/asm/debugreg.h               |  6 +-
 arch/x86/include/asm/fsgsbase.h               |  2 +-
 arch/x86/include/asm/kvm_host.h               |  5 +-
 arch/x86/include/asm/msr.h                    | 39 +-------
 arch/x86/include/asm/paravirt.h               | 26 +----
 arch/x86/include/asm/resctrl.h                |  5 +-
 arch/x86/kernel/acpi/sleep.c                  | 20 ++--
 arch/x86/kernel/apic/apic.c                   | 45 ++++-----
 arch/x86/kernel/apic/apic_numachip.c          |  6 +-
 arch/x86/kernel/cet.c                         |  2 +-
 arch/x86/kernel/cpu/amd.c                     | 42 ++++----
 arch/x86/kernel/cpu/aperfmperf.c              |  8 +-
 arch/x86/kernel/cpu/bugs.c                    | 12 +--
 arch/x86/kernel/cpu/bus_lock.c                |  8 +-
 arch/x86/kernel/cpu/centaur.c                 | 35 +++----
 arch/x86/kernel/cpu/common.c                  | 22 +++--
 arch/x86/kernel/cpu/feat_ctl.c                | 27 +++---
 arch/x86/kernel/cpu/hygon.c                   |  9 +-
 arch/x86/kernel/cpu/intel.c                   | 12 +--
 arch/x86/kernel/cpu/intel_epb.c               |  4 +-
 arch/x86/kernel/cpu/mce/amd.c                 | 89 ++++++++---------
 arch/x86/kernel/cpu/mce/core.c                | 10 +-
 arch/x86/kernel/cpu/mce/inject.c              |  2 +-
 arch/x86/kernel/cpu/mce/intel.c               | 18 ++--
 arch/x86/kernel/cpu/mce/p5.c                  | 16 +--
 arch/x86/kernel/cpu/mce/winchip.c             | 10 +-
 arch/x86/kernel/cpu/microcode/intel.c         |  2 +-
 arch/x86/kernel/cpu/mshyperv.c                |  6 +-
 arch/x86/kernel/cpu/mtrr/amd.c                | 36 ++++---
 arch/x86/kernel/cpu/mtrr/centaur.c            | 18 ++--
 arch/x86/kernel/cpu/mtrr/cleanup.c            | 18 ++--
 arch/x86/kernel/cpu/mtrr/generic.c            | 97 ++++++++++---------
 arch/x86/kernel/cpu/mtrr/mtrr.c               |  4 +-
 arch/x86/kernel/cpu/resctrl/core.c            |  9 +-
 arch/x86/kernel/cpu/resctrl/monitor.c         | 27 +++---
 arch/x86/kernel/cpu/resctrl/pseudo_lock.c     | 12 +--
 arch/x86/kernel/cpu/resctrl/rdtgroup.c        |  2 +-
 arch/x86/kernel/cpu/topology.c                |  2 +-
 arch/x86/kernel/cpu/topology_amd.c            |  4 +-
 arch/x86/kernel/cpu/transmeta.c               |  9 +-
 arch/x86/kernel/cpu/tsx.c                     | 10 +-
 arch/x86/kernel/cpu/umwait.c                  |  2 +-
 arch/x86/kernel/cpu/zhaoxin.c                 | 12 +--
 arch/x86/kernel/fpu/core.c                    |  2 +-
 arch/x86/kernel/hpet.c                        |  2 +-
 arch/x86/kernel/kvm.c                         |  2 +-
 arch/x86/kernel/mmconf-fam10h_64.c            |  6 +-
 arch/x86/kernel/process.c                     |  4 +-
 arch/x86/kernel/process_64.c                  | 14 +--
 arch/x86/kernel/shstk.c                       |  8 +-
 arch/x86/kernel/traps.c                       |  4 +-
 arch/x86/kernel/tsc.c                         |  8 +-
 arch/x86/kernel/tsc_msr.c                     | 15 +--
 arch/x86/kernel/tsc_sync.c                    |  6 +-
 arch/x86/kvm/svm/pmu.c                        |  4 +-
 arch/x86/kvm/svm/svm.c                        |  4 +-
 arch/x86/kvm/vmx/nested.c                     |  4 +-
 arch/x86/kvm/vmx/pmu_intel.c                  |  8 +-
 arch/x86/kvm/vmx/sgx.c                        |  6 +-
 arch/x86/kvm/vmx/vmx.c                        | 54 ++++++-----
 arch/x86/kvm/x86.c                            | 12 +--
 arch/x86/lib/insn-eval.c                      |  6 +-
 arch/x86/lib/msr-smp.c                        |  8 +-
 arch/x86/mm/pat/memtype.c                     |  2 +-
 arch/x86/pci/amd_bus.c                        |  8 +-
 arch/x86/pci/mmconfig-shared.c                |  8 +-
 arch/x86/platform/olpc/olpc-xo1-rtc.c         |  6 +-
 arch/x86/platform/olpc/olpc-xo1-sci.c         | 11 ++-
 arch/x86/power/cpu.c                          | 10 +-
 arch/x86/realmode/init.c                      |  2 +-
 arch/x86/virt/hw.c                            |  8 +-
 arch/x86/virt/svm/sev.c                       | 18 ++--
 arch/x86/virt/vmx/tdx/tdx.c                   |  8 +-
 arch/x86/xen/suspend.c                        |  2 +-
 drivers/acpi/processor_perflib.c              | 11 ++-
 drivers/acpi/processor_throttling.c           | 14 +--
 drivers/ata/pata_cs5535.c                     | 20 ++--
 drivers/ata/pata_cs5536.c                     | 17 ++--
 drivers/char/agp/nvidia-agp.c                 | 32 +++---
 drivers/char/hw_random/via-rng.c              | 29 +++---
 drivers/cpufreq/acpi-cpufreq.c                | 24 ++---
 drivers/cpufreq/amd-pstate.c                  |  4 +-
 drivers/cpufreq/e_powersaver.c                | 52 +++++-----
 drivers/cpufreq/intel_pstate.c                | 30 +++---
 drivers/cpufreq/longhaul.c                    | 23 ++---
 drivers/cpufreq/longrun.c                     | 78 ++++++++-------
 drivers/cpufreq/powernow-k6.c                 | 12 +--
 drivers/cpufreq/powernow-k7.c                 | 10 +-
 drivers/cpufreq/powernow-k8.c                 | 67 ++++++-------
 drivers/cpufreq/speedstep-centrino.c          | 16 +--
 drivers/cpufreq/speedstep-lib.c               | 63 ++++++------
 drivers/edac/amd64_edac.c                     |  6 +-
 drivers/edac/ie31200_edac.c                   | 10 +-
 drivers/edac/mce_amd.c                        |  8 +-
 drivers/gpio/gpio-cs5535.c                    | 10 +-
 drivers/hv/mshv_vtl_main.c                    |  2 +-
 drivers/hwmon/hwmon-vid.c                     | 11 ++-
 drivers/idle/intel_idle.c                     | 26 ++---
 drivers/misc/cs5535-mfgpt.c                   | 33 +++----
 drivers/mtd/nand/raw/cs553x_nand.c            |  6 +-
 drivers/platform/x86/intel/ifs/load.c         | 10 +-
 drivers/platform/x86/intel/ifs/runtest.c      |  8 +-
 drivers/platform/x86/intel/pmc/cnp.c          |  2 +-
 .../intel/speed_select_if/isst_if_mbox_msr.c  |  6 +-
 .../intel/speed_select_if/isst_tpmi_core.c    |  2 +-
 drivers/platform/x86/intel_ips.c              | 20 ++--
 drivers/powercap/intel_rapl_common.c          | 20 ++--
 drivers/powercap/intel_rapl_msr.c             |  2 +-
 drivers/thermal/intel/intel_hfi.c             |  8 +-
 drivers/thermal/intel/intel_tcc.c             | 10 +-
 drivers/thermal/intel/therm_throt.c           | 74 +++++++-------
 drivers/thermal/intel/x86_pkg_temp_thermal.c  | 32 +++---
 drivers/video/fbdev/geode/display_gx.c        |  8 +-
 drivers/video/fbdev/geode/gxfb_core.c         |  2 +-
 drivers/video/fbdev/geode/lxfb_ops.c          | 50 +++++-----
 drivers/video/fbdev/geode/suspend_gx.c        | 24 ++---
 drivers/video/fbdev/geode/video_gx.c          |  8 +-
 include/linux/cs5535.h                        | 10 +-
 146 files changed, 1044 insertions(+), 1128 deletions(-)

-- 
2.54.0
Re: [PATCH 00/32] x86/msr: Drop 32-bit MSR interfaces
Posted by Arnd Bergmann 5 days, 13 hours ago
On Mon, Jun 29, 2026, at 08:04, Juergen Gross wrote:
> 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.

Hi Jürgen,

I assume this is fine, but since you don't mention it explicitly here,
please clarify what this means for 32-bit CPUs without the rdmsrq
instruction. Those will continue using the same instructions as before
and just change the calling conventions, right?

> Note that most patches of this series are independent from each other.
> Only the patches removing a specific interface (patches 7, 15, 26 and
> 30) and the last two patches of the series depend on all previous
> patches.

It looks like you are touching most files twice or more here, to
first convert from rdmsr to rdmsrq and then to change the
two-argument rdmsrq() macro to a single-argument inline. If you
introduce the inline version of rdmsrq() first, you should be
able to skip the second step (patch 31) as they could be able
to coexist.

     Arnd
Re: [PATCH 00/32] x86/msr: Drop 32-bit MSR interfaces
Posted by Jürgen Groß 5 days, 13 hours ago
On 29.06.26 08:52, Arnd Bergmann wrote:
> On Mon, Jun 29, 2026, at 08:04, Juergen Gross wrote:
>> 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.
> 
> Hi Jürgen,
> 
> I assume this is fine, but since you don't mention it explicitly here,
> please clarify what this means for 32-bit CPUs without the rdmsrq
> instruction. Those will continue using the same instructions as before
> and just change the calling conventions, right?

Yes. I thought this would be clear from the following:

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

> 
>> Note that most patches of this series are independent from each other.
>> Only the patches removing a specific interface (patches 7, 15, 26 and
>> 30) and the last two patches of the series depend on all previous
>> patches.
> 
> It looks like you are touching most files twice or more here, to
> first convert from rdmsr to rdmsrq and then to change the
> two-argument rdmsrq() macro to a single-argument inline. If you
> introduce the inline version of rdmsrq() first, you should be
> able to skip the second step (patch 31) as they could be able
> to coexist.

I've discussed how to structure the series with Ingo Molnar before [1]. The
current approach was his preference.


Juergen

[1]: https://lore.kernel.org/lkml/f8d02c78-4681-4043-a5fa-921fa790b1b4@suse.com/
Re: [PATCH 00/32] x86/msr: Drop 32-bit MSR interfaces
Posted by Arnd Bergmann 5 days, 12 hours ago
On Mon, Jun 29, 2026, at 09:01, Jürgen Groß wrote:
> On 29.06.26 08:52, Arnd Bergmann wrote:
>> On Mon, Jun 29, 2026, at 08:04, Juergen Gross wrote:
>> 
>> I assume this is fine, but since you don't mention it explicitly here,
>> please clarify what this means for 32-bit CPUs without the rdmsrq
>> instruction. Those will continue using the same instructions as before
>> and just change the calling conventions, right?
>
> Yes. I thought this would be clear from the following:
>
>    - They are based on primitives using 64-bit sized values anyway.

Right, that was my reading of it as well, but it's not entirely
clear when the function name is the same as the mnemonic of an
instruction that only exists on newer CPUs and the later patch
descriptions (e.g. 25/32 that I was Cc's on) have a much shorter
explanation.

>>> Note that most patches of this series are independent from each other.
>>> Only the patches removing a specific interface (patches 7, 15, 26 and
>>> 30) and the last two patches of the series depend on all previous
>>> patches.
>> 
>> It looks like you are touching most files twice or more here, to
>> first convert from rdmsr to rdmsrq and then to change the
>> two-argument rdmsrq() macro to a single-argument inline. If you
>> introduce the inline version of rdmsrq() first, you should be
>> able to skip the second step (patch 31) as they could be able
>> to coexist.
>
> I've discussed how to structure the series with Ingo Molnar before [1]. The
> current approach was his preference.

Ok.

      Arnd
Re: [PATCH 00/32] x86/msr: Drop 32-bit MSR interfaces
Posted by Ingo Molnar 5 days, 8 hours ago
* Arnd Bergmann <arnd@arndb.de> wrote:

> >>> Note that most patches of this series are independent from each other.
> >>> Only the patches removing a specific interface (patches 7, 15, 26 and
> >>> 30) and the last two patches of the series depend on all previous
> >>> patches.
> >> 
> >> It looks like you are touching most files twice or more here, to
> >> first convert from rdmsr to rdmsrq and then to change the
> >> two-argument rdmsrq() macro to a single-argument inline. If you
> >> introduce the inline version of rdmsrq() first, you should be
> >> able to skip the second step (patch 31) as they could be able
> >> to coexist.
> >
> > I've discussed how to structure the series with Ingo Molnar before [1]. The
> > current approach was his preference.
> 
> Ok.

Note that the individual patches are IMO significantly easier to review
through the actual 32-bit => 64-bit variable assignment changes done
in isolation (which sometimes include minor cleanups), while
the Coccinelle semantic patch:

   { a(b,c) => c = a(b) }

which changes both the function signature and the order of terms as
well, is just a single add-on treewide patch.

Thanks,

	Ingo
Re: [PATCH 00/32] x86/msr: Drop 32-bit MSR interfaces
Posted by Sean Christopherson 4 days, 1 hour ago
On Mon, Jun 29, 2026, Ingo Molnar wrote:
> * Arnd Bergmann <arnd@arndb.de> wrote:
> 
> > >>> Note that most patches of this series are independent from each other.
> > >>> Only the patches removing a specific interface (patches 7, 15, 26 and
> > >>> 30) and the last two patches of the series depend on all previous
> > >>> patches.
> > >> 
> > >> It looks like you are touching most files twice or more here, to
> > >> first convert from rdmsr to rdmsrq and then to change the
> > >> two-argument rdmsrq() macro to a single-argument inline. If you
> > >> introduce the inline version of rdmsrq() first, you should be
> > >> able to skip the second step (patch 31) as they could be able
> > >> to coexist.
> > >
> > > I've discussed how to structure the series with Ingo Molnar before [1]. The
> > > current approach was his preference.
> > 
> > Ok.
> 
> Note that the individual patches are IMO significantly easier to review
> through the actual 32-bit => 64-bit variable assignment changes done
> in isolation (which sometimes include minor cleanups), while
> the Coccinelle semantic patch:
> 
>    { a(b,c) => c = a(b) }
> 
> which changes both the function signature and the order of terms as
> well, is just a single add-on treewide patch.

Is the plan for subsystem maintainers to pick up the relevant patches, and then
do the treewide change one release cycle later?
Re: [PATCH 00/32] x86/msr: Drop 32-bit MSR interfaces
Posted by Ingo Molnar 2 days, 10 hours ago
* Sean Christopherson <seanjc@google.com> wrote:

> > Note that the individual patches are IMO significantly easier to review
> > through the actual 32-bit => 64-bit variable assignment changes done
> > in isolation (which sometimes include minor cleanups), while
> > the Coccinelle semantic patch:
> > 
> >    { a(b,c) => c = a(b) }
> > 
> > which changes both the function signature and the order of terms as
> > well, is just a single add-on treewide patch.
> 
> Is the plan for subsystem maintainers to pick up the relevant patches,
> and then do the treewide change one release cycle later?

I'll try to keep the patches in a single tree (tip:x86/msr)
in the hope of not prolonging the pain two cycles - but it's
of course fine for maintainers to pick up the patches too
(most of them are standalone), we'll sort it all out in the end.

Thanks,

	Ingo
Re: [PATCH 00/32] x86/msr: Drop 32-bit MSR interfaces
Posted by Juergen Gross 2 days, 9 hours ago
On 02.07.26 12:07, Ingo Molnar wrote:
> 
> * Sean Christopherson <seanjc@google.com> wrote:
> 
>>> Note that the individual patches are IMO significantly easier to review
>>> through the actual 32-bit => 64-bit variable assignment changes done
>>> in isolation (which sometimes include minor cleanups), while
>>> the Coccinelle semantic patch:
>>>
>>>     { a(b,c) => c = a(b) }
>>>
>>> which changes both the function signature and the order of terms as
>>> well, is just a single add-on treewide patch.
>>
>> Is the plan for subsystem maintainers to pick up the relevant patches,
>> and then do the treewide change one release cycle later?
> 
> I'll try to keep the patches in a single tree (tip:x86/msr)
> in the hope of not prolonging the pain two cycles - but it's
> of course fine for maintainers to pick up the patches too
> (most of them are standalone), we'll sort it all out in the end.

Ingo, would you be fine with me posting patch updates just as replies to the
original patch emails? This would speed things up, as I wouldn't need to wait
for more review input of all the patches before sending out new versions.

As the patches are (mostly) standalone, this should not cause any weird
problems.

The last two patches might need updates, but those can be applied only after
the rest has been accepted anyway.


Juergen
Re: [PATCH 00/32] x86/msr: Drop 32-bit MSR interfaces
Posted by Jürgen Groß 3 days, 11 hours ago
On 30.06.26 20:59, Sean Christopherson wrote:
> On Mon, Jun 29, 2026, Ingo Molnar wrote:
>> * Arnd Bergmann <arnd@arndb.de> wrote:
>>
>>>>>> Note that most patches of this series are independent from each other.
>>>>>> Only the patches removing a specific interface (patches 7, 15, 26 and
>>>>>> 30) and the last two patches of the series depend on all previous
>>>>>> patches.
>>>>>
>>>>> It looks like you are touching most files twice or more here, to
>>>>> first convert from rdmsr to rdmsrq and then to change the
>>>>> two-argument rdmsrq() macro to a single-argument inline. If you
>>>>> introduce the inline version of rdmsrq() first, you should be
>>>>> able to skip the second step (patch 31) as they could be able
>>>>> to coexist.
>>>>
>>>> I've discussed how to structure the series with Ingo Molnar before [1]. The
>>>> current approach was his preference.
>>>
>>> Ok.
>>
>> Note that the individual patches are IMO significantly easier to review
>> through the actual 32-bit => 64-bit variable assignment changes done
>> in isolation (which sometimes include minor cleanups), while
>> the Coccinelle semantic patch:
>>
>>     { a(b,c) => c = a(b) }
>>
>> which changes both the function signature and the order of terms as
>> well, is just a single add-on treewide patch.
> 
> Is the plan for subsystem maintainers to pick up the relevant patches, and then
> do the treewide change one release cycle later?

Yes, please.


Juergen
Re: [PATCH 00/32] x86/msr: Drop 32-bit MSR interfaces
Posted by Jürgen Groß 5 days, 11 hours ago
On 29.06.26 10:06, Arnd Bergmann wrote:
> On Mon, Jun 29, 2026, at 09:01, Jürgen Groß wrote:
>> On 29.06.26 08:52, Arnd Bergmann wrote:
>>> On Mon, Jun 29, 2026, at 08:04, Juergen Gross wrote:
>>>
>>> I assume this is fine, but since you don't mention it explicitly here,
>>> please clarify what this means for 32-bit CPUs without the rdmsrq
>>> instruction. Those will continue using the same instructions as before
>>> and just change the calling conventions, right?
>>
>> Yes. I thought this would be clear from the following:
>>
>>     - They are based on primitives using 64-bit sized values anyway.
> 
> Right, that was my reading of it as well, but it's not entirely
> clear when the function name is the same as the mnemonic of an
> instruction that only exists on newer CPUs and the later patch

There is no RDMSRQ instruction on any x86 CPU. Are you mixing this up with
WRMSRNS/RDMSR using an immediate for addressing the MSR?


Juergen
Re: [PATCH 00/32] x86/msr: Drop 32-bit MSR interfaces
Posted by Arnd Bergmann 5 days, 11 hours ago
On Mon, Jun 29, 2026, at 10:15, Jürgen Groß wrote:
> On 29.06.26 10:06, Arnd Bergmann wrote:
>> On Mon, Jun 29, 2026, at 09:01, Jürgen Groß wrote:
>>> On 29.06.26 08:52, Arnd Bergmann wrote:
>>>> On Mon, Jun 29, 2026, at 08:04, Juergen Gross wrote:
>>>>
>>>> I assume this is fine, but since you don't mention it explicitly here,
>>>> please clarify what this means for 32-bit CPUs without the rdmsrq
>>>> instruction. Those will continue using the same instructions as before
>>>> and just change the calling conventions, right?
>>>
>>> Yes. I thought this would be clear from the following:
>>>
>>>     - They are based on primitives using 64-bit sized values anyway.
>> 
>> Right, that was my reading of it as well, but it's not entirely
>> clear when the function name is the same as the mnemonic of an
>> instruction that only exists on newer CPUs and the later patch
>
> There is no RDMSRQ instruction on any x86 CPU. Are you mixing this up with
> WRMSRNS/RDMSR using an immediate for addressing the MSR?

Yes, I was just confused about the exact definition here and assumed
the single-register output version was actually called rdmsrq.

     Arnd
Re: [PATCH 00/32] x86/msr: Drop 32-bit MSR interfaces
Posted by H. Peter Anvin 4 days ago
On 2026-06-29 01:38, Arnd Bergmann wrote:
>>
>> There is no RDMSRQ instruction on any x86 CPU. Are you mixing this up with
>> WRMSRNS/RDMSR using an immediate for addressing the MSR?
> 
> Yes, I was just confused about the exact definition here and assumed
> the single-register output version was actually called rdmsrq.
> 
So just to be clear:

There are three instructions(*):

	wrmsr		- implicit form only
	wrmsrns		- implicit or immediate
	rdmsr		- implicit or immediate

The implicit form are the same on 32 and 64 bits (and, in fact, 16 bits): they
take a MSR register address in %ecx and the data as two 32-bit words in
%edx:%eax. This interface predates x86-64 by about a decade, and the Linux MSR
interfaces were designed when Linux was 32-bit only, so it made sense at the
time to treat them as two halves, especially since MSRs often are various
kinds of bitfields. It didn't help that gcc at the time was extremely
inefficient in its handling of multiword arithmetic (it is much better now),
so using a u64 would have made for much worse code.

The immediate forms are 64-bit only and use a single arbitrary 64-bit
register; the MSR address is kept in an immediate in the instruction, just
like they are for most other register types. The only thing that is "special"
there is that the possible register address space is very large (2^32)
although in practice a very small fraction of that is (currently) used.

The immediate forms are expected to be faster, and provide for further
performance improvements in future microarchitectures. This is important,
because it provides a fine-grain uniform architecture for supervisor-only
state, instead of having to give a bulk ISA (XSAVES/XRSTORS) that is different
from the fine-grained architecture, and still get good performance. This gives
the kernel very fine level control over the context switch flows, for one thing.

WRMSRNS is a non-serializing form of WRMSR, which is defined as an
architecturally hard-serializing instruction, although some MSRs have been
retconned as non-serializing (and the set is different between vendors.) We
want to switch that over to the model where the kernel explicitly opts in to
nonserialization, but that means using alternatives since not all CPUs have
the WRMSRNS instruction.

Furthermore, we want to use alternatives so we can make use of the
immediate-format instructions when the MSR address is known at compile time,
which it is in *nearly* all cases. If we are smart about it we can also use
this to let the tracing framework be specific about what MSRs to trace, since
some MSRs are frequently accessed, but many are set at startup and then
rarely, if ever, touched.


(*) There are actually two more instructions:

	RDMSRLIST
	WRMSRLIST

... which are bulk versions of RDMSR and WRMSRNS respectively. They can be
useful to save and restore entire groups of MSRs in one shot, such as
performance counter configurations. By architecturally allowing the memory
operations and MSR operations to operate asynchronously, they give some of the
pipeline benefits of the immediate MSR operations without requiring the MSR
set to have been set at compile time or code to be dynamically generated.

However, they expose an entirely different programming model, whereas the
immediate- and -NS instruction choices can be entirely hidden at the C level.
Re: [PATCH 00/32] x86/msr: Drop 32-bit MSR interfaces
Posted by Jan Beulich 5 days, 11 hours ago
On 29.06.2026 10:15, Jürgen Groß wrote:
> On 29.06.26 10:06, Arnd Bergmann wrote:
>> On Mon, Jun 29, 2026, at 09:01, Jürgen Groß wrote:
>>> On 29.06.26 08:52, Arnd Bergmann wrote:
>>>> On Mon, Jun 29, 2026, at 08:04, Juergen Gross wrote:
>>>>
>>>> I assume this is fine, but since you don't mention it explicitly here,
>>>> please clarify what this means for 32-bit CPUs without the rdmsrq
>>>> instruction. Those will continue using the same instructions as before
>>>> and just change the calling conventions, right?
>>>
>>> Yes. I thought this would be clear from the following:
>>>
>>>     - They are based on primitives using 64-bit sized values anyway.
>>
>> Right, that was my reading of it as well, but it's not entirely
>> clear when the function name is the same as the mnemonic of an
>> instruction that only exists on newer CPUs and the later patch
> 
> There is no RDMSRQ instruction on any x86 CPU.

And perhaps wrongly so. On the binutils side I did argue previously that it
is in the spirit of the original AT&T assembler language to permit, but not
require, suffixes matching the size of (uniform) register operands. Even for
insns not allowing for memory operands, simply for overall consistency.

(I took the liberty to at least limit the number of Cc-ed lists some.)

Jan