Skip to content

Commit 7561361

Browse files
committed
Merge tag 'x86-msr-2026-06-14' of gitolite.kernel.org:pub/scm/linux/kernel/git/tip/tip
Pull x86/msr updates from Ingo Molnar: - Large series to reorganize the rdmsr/wrmsr APIs to remove 32-bit variants and convert to 64-bit variants (Juergen Gross) - Fix W=1 warning (HyeongJun An) * tag 'x86-msr-2026-06-14' of gitolite.kernel.org:pub/scm/linux/kernel/git/tip/tip: x86/msr: Remove wrmsrl() x86/msr: Switch wrmsrl() users to wrmsrq() x86/msr: Remove rdmsrl() x86/msr: Switch rdmsrl() users to rdmsrq() x86/msr: Remove wrmsr_safe_on_cpu() x86/msr: Switch wrmsr_safe_on_cpu() users to wrmsrq_safe_on_cpu() x86/msr: Remove rdmsr_safe_on_cpu() x86/msr: Switch rdmsr_safe_on_cpu() users to rdmsrq_safe_on_cpu() x86/msr: Don't use rdmsr_safe_on_cpu() in rdmsrq_safe_on_cpu() x86/msr: Remove wrmsr_on_cpu() x86/msr: Switch wrmsr_on_cpu() users to wrmsrq_on_cpu() x86/msr: Remove rdmsr_on_cpu() x86/msr: Switch rdmsr_on_cpu() users to rdmsrq_on_cpu() x86/msr: Remove rdmsrl_on_cpu() x86/msr: Switch rdmsrl_on_cpu() user to rdmsrq_on_cpu() x86/process: Convert rdmsr() to rdmsrq() in arch_post_acpi_subsys_init() to address W=1 warning
2 parents 2cbf335 + b588407 commit 7561361

23 files changed

Lines changed: 149 additions & 243 deletions

File tree

arch/x86/events/amd/uncore.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ static void amd_uncore_umc_read(struct perf_event *event)
966966
* UMC counters do not have RDPMC assignments. Read counts directly
967967
* from the corresponding PERF_CTR.
968968
*/
969-
rdmsrl(hwc->event_base, new);
969+
rdmsrq(hwc->event_base, new);
970970

971971
/*
972972
* Unlike the other uncore counters, UMC counters saturate and set the
@@ -975,7 +975,7 @@ static void amd_uncore_umc_read(struct perf_event *event)
975975
* that the counter never gets a chance to saturate.
976976
*/
977977
if (new & BIT_ULL(63 - COUNTER_SHIFT)) {
978-
wrmsrl(hwc->event_base, 0);
978+
wrmsrq(hwc->event_base, 0);
979979
local64_set(&hwc->prev_count, 0);
980980
} else {
981981
local64_set(&hwc->prev_count, new);

arch/x86/events/intel/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3417,12 +3417,12 @@ static void intel_pmu_config_acr(int idx, u64 mask, u32 reload)
34173417
}
34183418

34193419
if (cpuc->acr_cfg_b[idx] != mask) {
3420-
wrmsrl(msr_b + msr_offset, mask);
3420+
wrmsrq(msr_b + msr_offset, mask);
34213421
cpuc->acr_cfg_b[idx] = mask;
34223422
}
34233423
/* Only update CFG_C reload when ACR is actively enabled (mask != 0) */
34243424
if (mask && ((cpuc->cfg_c_val[idx] & ARCH_PEBS_RELOAD) != reload)) {
3425-
wrmsrl(msr_c + msr_offset, reload);
3425+
wrmsrq(msr_c + msr_offset, reload);
34263426
cpuc->cfg_c_val[idx] = reload;
34273427
}
34283428
}

arch/x86/events/intel/ds.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -780,17 +780,15 @@ void init_debug_store_on_cpu(int cpu)
780780
if (!ds)
781781
return;
782782

783-
wrmsr_on_cpu(cpu, MSR_IA32_DS_AREA,
784-
(u32)((u64)(unsigned long)ds),
785-
(u32)((u64)(unsigned long)ds >> 32));
783+
wrmsrq_on_cpu(cpu, MSR_IA32_DS_AREA, (u64)(unsigned long)ds);
786784
}
787785

788786
void fini_debug_store_on_cpu(int cpu)
789787
{
790788
if (!per_cpu(cpu_hw_events, cpu).ds)
791789
return;
792790

793-
wrmsr_on_cpu(cpu, MSR_IA32_DS_AREA, 0, 0);
791+
wrmsrq_on_cpu(cpu, MSR_IA32_DS_AREA, 0);
794792
}
795793

796794
static DEFINE_PER_CPU(void *, insn_buffer);
@@ -1095,8 +1093,7 @@ void init_arch_pebs_on_cpu(int cpu)
10951093
* contiguous physical buffer (__alloc_pages_node() with order)
10961094
*/
10971095
arch_pebs_base = virt_to_phys(cpuc->pebs_vaddr) | PEBS_BUFFER_SHIFT;
1098-
wrmsr_on_cpu(cpu, MSR_IA32_PEBS_BASE, (u32)arch_pebs_base,
1099-
(u32)(arch_pebs_base >> 32));
1096+
wrmsrq_on_cpu(cpu, MSR_IA32_PEBS_BASE, arch_pebs_base);
11001097
x86_pmu.pebs_active = 1;
11011098
}
11021099

@@ -1105,7 +1102,7 @@ inline void fini_arch_pebs_on_cpu(int cpu)
11051102
if (!x86_pmu.arch_pebs)
11061103
return;
11071104

1108-
wrmsr_on_cpu(cpu, MSR_IA32_PEBS_BASE, 0, 0);
1105+
wrmsrq_on_cpu(cpu, MSR_IA32_PEBS_BASE, 0);
11091106
}
11101107

11111108
/*

arch/x86/include/asm/msr.h

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -256,29 +256,15 @@ int msr_set_bit(u32 msr, u8 bit);
256256
int msr_clear_bit(u32 msr, u8 bit);
257257

258258
#ifdef CONFIG_SMP
259-
int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
260-
int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
261259
int rdmsrq_on_cpu(unsigned int cpu, u32 msr_no, u64 *q);
262260
int wrmsrq_on_cpu(unsigned int cpu, u32 msr_no, u64 q);
263261
void rdmsr_on_cpus(const struct cpumask *mask, u32 msr_no, struct msr __percpu *msrs);
264262
void wrmsr_on_cpus(const struct cpumask *mask, u32 msr_no, struct msr __percpu *msrs);
265-
int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
266-
int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
267263
int rdmsrq_safe_on_cpu(unsigned int cpu, u32 msr_no, u64 *q);
268264
int wrmsrq_safe_on_cpu(unsigned int cpu, u32 msr_no, u64 q);
269265
int rdmsr_safe_regs_on_cpu(unsigned int cpu, u32 regs[8]);
270266
int wrmsr_safe_regs_on_cpu(unsigned int cpu, u32 regs[8]);
271267
#else /* CONFIG_SMP */
272-
static inline int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
273-
{
274-
rdmsr(msr_no, *l, *h);
275-
return 0;
276-
}
277-
static inline int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
278-
{
279-
wrmsr(msr_no, l, h);
280-
return 0;
281-
}
282268
static inline int rdmsrq_on_cpu(unsigned int cpu, u32 msr_no, u64 *q)
283269
{
284270
rdmsrq(msr_no, *q);
@@ -292,21 +278,12 @@ static inline int wrmsrq_on_cpu(unsigned int cpu, u32 msr_no, u64 q)
292278
static inline void rdmsr_on_cpus(const struct cpumask *m, u32 msr_no,
293279
struct msr __percpu *msrs)
294280
{
295-
rdmsr_on_cpu(0, msr_no, raw_cpu_ptr(&msrs->l), raw_cpu_ptr(&msrs->h));
281+
rdmsrq_on_cpu(0, msr_no, raw_cpu_ptr(&msrs->q));
296282
}
297283
static inline void wrmsr_on_cpus(const struct cpumask *m, u32 msr_no,
298284
struct msr __percpu *msrs)
299285
{
300-
wrmsr_on_cpu(0, msr_no, raw_cpu_read(msrs->l), raw_cpu_read(msrs->h));
301-
}
302-
static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no,
303-
u32 *l, u32 *h)
304-
{
305-
return rdmsr_safe(msr_no, l, h);
306-
}
307-
static inline int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
308-
{
309-
return wrmsr_safe(msr_no, l, h);
286+
wrmsrq_on_cpu(0, msr_no, raw_cpu_read(msrs->q));
310287
}
311288
static inline int rdmsrq_safe_on_cpu(unsigned int cpu, u32 msr_no, u64 *q)
312289
{
@@ -325,11 +302,5 @@ static inline int wrmsr_safe_regs_on_cpu(unsigned int cpu, u32 regs[8])
325302
return wrmsr_safe_regs(regs);
326303
}
327304
#endif /* CONFIG_SMP */
328-
329-
/* Compatibility wrappers: */
330-
#define rdmsrl(msr, val) rdmsrq(msr, val)
331-
#define wrmsrl(msr, val) wrmsrq(msr, val)
332-
#define rdmsrl_on_cpu(cpu, msr, q) rdmsrq_on_cpu(cpu, msr, q)
333-
334305
#endif /* __ASSEMBLER__ */
335306
#endif /* _ASM_X86_MSR_H */

arch/x86/kernel/cpu/mce/amd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -969,13 +969,13 @@ store_threshold_limit(struct threshold_block *b, const char *buf, size_t size)
969969

970970
static ssize_t show_error_count(struct threshold_block *b, char *buf)
971971
{
972-
u32 lo, hi;
972+
struct msr val;
973973

974974
/* CPU might be offline by now */
975-
if (rdmsr_on_cpu(b->cpu, b->address, &lo, &hi))
975+
if (rdmsrq_on_cpu(b->cpu, b->address, &val.q))
976976
return -ENODEV;
977977

978-
return sprintf(buf, "%u\n", ((hi & THRESHOLD_MAX) -
978+
return sprintf(buf, "%u\n", ((val.h & THRESHOLD_MAX) -
979979
(THRESHOLD_MAX - b->threshold_limit)));
980980
}
981981

arch/x86/kernel/cpu/mce/inject.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,18 +316,18 @@ static struct notifier_block inject_nb = {
316316
*/
317317
static int toggle_hw_mce_inject(unsigned int cpu, bool enable)
318318
{
319-
u32 l, h;
319+
struct msr val;
320320
int err;
321321

322-
err = rdmsr_on_cpu(cpu, MSR_K7_HWCR, &l, &h);
322+
err = rdmsrq_on_cpu(cpu, MSR_K7_HWCR, &val.q);
323323
if (err) {
324324
pr_err("%s: error reading HWCR\n", __func__);
325325
return err;
326326
}
327327

328-
enable ? (l |= BIT(18)) : (l &= ~BIT(18));
328+
enable ? (val.l |= BIT(18)) : (val.l &= ~BIT(18));
329329

330-
err = wrmsr_on_cpu(cpu, MSR_K7_HWCR, l, h);
330+
err = wrmsrq_on_cpu(cpu, MSR_K7_HWCR, val.q);
331331
if (err)
332332
pr_err("%s: error writing HWCR\n", __func__);
333333

arch/x86/kernel/cpu/resctrl/monitor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ static int __cntr_id_read(u32 cntr_id, u64 *val)
301301
* is set if the counter data is unavailable.
302302
*/
303303
wrmsr(MSR_IA32_QM_EVTSEL, ABMC_EXTENDED_EVT_ID | ABMC_EVT_ID, cntr_id);
304-
rdmsrl(MSR_IA32_QM_CTR, msr_val);
304+
rdmsrq(MSR_IA32_QM_CTR, msr_val);
305305

306306
if (msr_val & RMID_VAL_ERROR)
307307
return -EIO;
@@ -532,7 +532,7 @@ static void resctrl_abmc_config_one_amd(void *info)
532532
{
533533
union l3_qos_abmc_cfg *abmc_cfg = info;
534534

535-
wrmsrl(MSR_IA32_L3_QOS_ABMC_CFG, abmc_cfg->full);
535+
wrmsrq(MSR_IA32_L3_QOS_ABMC_CFG, abmc_cfg->full);
536536
}
537537

538538
/*

arch/x86/kernel/msr.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static ssize_t msr_read(struct file *file, char __user *buf,
5353
size_t count, loff_t *ppos)
5454
{
5555
u32 __user *tmp = (u32 __user *) buf;
56-
u32 data[2];
56+
u64 data;
5757
u32 reg = *ppos;
5858
int cpu = iminor(file_inode(file));
5959
int err = 0;
@@ -63,7 +63,7 @@ static ssize_t msr_read(struct file *file, char __user *buf,
6363
return -EINVAL; /* Invalid chunk size */
6464

6565
for (; count; count -= 8) {
66-
err = rdmsr_safe_on_cpu(cpu, reg, &data[0], &data[1]);
66+
err = rdmsrq_safe_on_cpu(cpu, reg, &data);
6767
if (err)
6868
break;
6969
if (copy_to_user(tmp, &data, 8)) {
@@ -109,7 +109,7 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
109109
size_t count, loff_t *ppos)
110110
{
111111
const u32 __user *tmp = (const u32 __user *)buf;
112-
u32 data[2];
112+
u64 data;
113113
u32 reg = *ppos;
114114
int cpu = iminor(file_inode(file));
115115
int err = 0;
@@ -134,7 +134,7 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
134134

135135
add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK);
136136

137-
err = wrmsr_safe_on_cpu(cpu, reg, data[0], data[1]);
137+
err = wrmsrq_safe_on_cpu(cpu, reg, data);
138138
if (err)
139139
break;
140140

arch/x86/kernel/process.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ void amd_e400_c1e_apic_setup(void)
969969

970970
void __init arch_post_acpi_subsys_init(void)
971971
{
972-
u32 lo, hi;
972+
u64 val;
973973

974974
if (!boot_cpu_has_bug(X86_BUG_AMD_E400))
975975
return;
@@ -979,8 +979,8 @@ void __init arch_post_acpi_subsys_init(void)
979979
* the machine is affected K8_INTP_C1E_ACTIVE_MASK bits are set in
980980
* MSR_K8_INT_PENDING_MSG.
981981
*/
982-
rdmsr(MSR_K8_INT_PENDING_MSG, lo, hi);
983-
if (!(lo & K8_INTP_C1E_ACTIVE_MASK))
982+
rdmsrq(MSR_K8_INT_PENDING_MSG, val);
983+
if (!(val & K8_INTP_C1E_ACTIVE_MASK))
984984
return;
985985

986986
boot_cpu_set_bug(X86_BUG_AMD_APIC_C1E);

arch/x86/kernel/process_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
708708

709709
/* Reset hw history on AMD CPUs */
710710
if (cpu_feature_enabled(X86_FEATURE_AMD_WORKLOAD_CLASS))
711-
wrmsrl(MSR_AMD_WORKLOAD_HRST, 0x1);
711+
wrmsrq(MSR_AMD_WORKLOAD_HRST, 0x1);
712712

713713
return prev_p;
714714
}

0 commit comments

Comments
 (0)