x86/msr: Reduce MSR access interfaces
Subsystems (20)
Juergen Gross
maintainercover x86/msr: Reduce MSR access interfaces
After my first attempt to rework the MSR access functions [1] this is the result of the feedback I got.
I have still followed the idea to:
- Reduce the number of MSR access functions by keeping the ones with 64-bit values only (instead of the dual 32-bit ones).
- Try to have inline functions instead of macros for rdmsr*(), removing the hard to read cases where parameters specified the variables for the results.
One feedback I got was NOT to rename the access functions, which I avoided in my new approach.
The first 8 patches are a complete set for achieving especially the first point above for the *_on_cpu() functions.
Patch 9 is preparing the switch of the CPU-local MSR access functions to have only rdmsr(), rdmsr_safe(), wrmsr() and wrmsr_safe() (all with 64-bit values and as inline functions) in the end. For this purpose the already existing functions/macros are overloaded via macros to accept both variants (64-bit and dual 32-bit values) during the phase switching the different subsystems to the new scheme. This has the advantage to avoid having to either patch all users of the current functions in one patch (like done in the first 8 patches), or having to use intermediate function names with need to be patched at the end another time. The resulting patches would be very hard to review due to their size.
The last 2 patches are examples how switches of subsystems would look like.
Up to now all of that is compile tested only.
[1]: https://lore.kernel.org/lkml/[email protected]/
Juergen Gross (11):
x86/msr: Switch rdmsr_on_cpu() to return a 64-bit quantity x86/msr: Switch all callers of rdmsrq_on_cpu() to use rdmsr_on_cpu() x86/msr: Switch wrmsr_on_cpu() to use a 64-bit quantity x86/msr: Switch all callers of wrmsrq_on_cpu() to use wrmsr_on_cpu() x86/msr: Switch rdmsr_safe_on_cpu() to return a 64-bit quantity x86/msr: Switch all callers of rdmsrq_safe_on_cpu() to use
rdmsr_safe_on_cpu()
x86/msr: Switch wrmsr_safe_on_cpu() to use a 64-bit quantity
x86/msr: Switch all callers of wrmsrq_safe_on_cpu() to use
wrmsr_safe_on_cpu()x86/msr: Add macros for preparing to switch rdmsr/wrmsr interfaces x86/events: Switch core parts to use 64-bit rdmsr/wrmsr() variants x86/cpu/mce: Switch code to use 64-bit rdmsr/wrmsr() variants
arch/x86/events/core.c | 42 ++++---- arch/x86/events/intel/ds.c | 11 +- arch/x86/events/intel/pt.c | 2 +- arch/x86/events/intel/uncore_discovery.c | 2 +- arch/x86/events/intel/uncore_snbep.c | 2 +- arch/x86/events/msr.c | 2 +- arch/x86/events/perf_event.h | 26 ++--- arch/x86/events/probe.c | 2 +- arch/x86/events/rapl.c | 8 +- arch/x86/include/asm/msr.h | 90 +++++++++------- arch/x86/include/asm/paravirt.h | 6 +- arch/x86/kernel/acpi/cppc.c | 8 +- arch/x86/kernel/cpu/intel_epb.c | 8 +- arch/x86/kernel/cpu/mce/amd.c | 101 +++++++++--------- arch/x86/kernel/cpu/mce/core.c | 18 ++-- arch/x86/kernel/cpu/mce/inject.c | 40 +++---- arch/x86/kernel/cpu/mce/intel.c | 32 +++--- 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/msr.c | 8 +- arch/x86/lib/msr-smp.c | 79 ++------------ drivers/cpufreq/acpi-cpufreq.c | 4 +- drivers/cpufreq/amd-pstate-ut.c | 2 +- drivers/cpufreq/amd-pstate.c | 21 ++-- drivers/cpufreq/amd_freq_sensitivity.c | 4 +- drivers/cpufreq/intel_pstate.c | 64 +++++------ drivers/cpufreq/p4-clockmod.c | 32 +++--- drivers/cpufreq/speedstep-centrino.c | 27 ++--- drivers/hwmon/coretemp.c | 44 ++++---- drivers/hwmon/via-cputemp.c | 16 +-- drivers/platform/x86/amd/hfi/hfi.c | 4 +- .../intel/speed_select_if/isst_if_common.c | 13 ++- .../intel/uncore-frequency/uncore-frequency.c | 12 +-- drivers/powercap/intel_rapl_msr.c | 2 +- drivers/thermal/intel/intel_tcc.c | 43 ++++---- drivers/thermal/intel/x86_pkg_temp_thermal.c | 22 ++-- 37 files changed, 387 insertions(+), 438 deletions(-)
Signature · 1 line
2.53.0
Juergen Gross
maintainerRFC PATCH 1/11 x86/msr: Switch rdmsr_on_cpu() to return a 64-bit quantity
In order to prepare retiring rdmsrq_on_cpu() switch rdmsr_on_cpu() to have the same interface as rdmsrq_on_cpu().
Switch all rdmsr_on_cpu() callers to use the new interface.
--- arch/x86/include/asm/msr.h | 8 ++--- arch/x86/kernel/cpu/mce/amd.c | 6 ++-- arch/x86/kernel/cpu/mce/inject.c | 8 ++--- arch/x86/lib/msr-smp.c | 5 ++- drivers/cpufreq/amd_freq_sensitivity.c | 4 +-- drivers/cpufreq/p4-clockmod.c | 32 ++++++++++---------- drivers/cpufreq/speedstep-centrino.c | 27 +++++++++-------- drivers/hwmon/coretemp.c | 12 ++++---- drivers/thermal/intel/x86_pkg_temp_thermal.c | 22 ++++++++------ 9 files changed, 63 insertions(+), 61 deletions(-)
arch/x86/include/asm/msr.h +4 -4
@@ -256,7 +256,7 @@ int msr_set_bit(u32 msr, u8 bit);int msr_clear_bit (u32 msr,u8 bit);#ifdef CONFIG_SMP -int rdmsr_on_cpu (unsigned int cpu,u32 msr_no,u32 *l,u32 *h); +int rdmsr_on_cpu (unsigned int cpu,u32 msr_no,u64 *q);int wrmsr_on_cpu (unsigned int cpu,u32 msr_no,u32 l,u32 h);int rdmsrq_on_cpu (unsigned int cpu,u32 msr_no,u64 *q);int wrmsrq_on_cpu (unsigned int cpu,u32 msr_no,u64 q);
@@ -269,9 +269,9 @@ int wrmsrq_safe_on_cpu(unsigned int cpu, u32 msr_no, u64 q);int rdmsr_safe_regs_on_cpu (unsigned int cpu,u32 regs[8 ]);int wrmsr_safe_regs_on_cpu (unsigned int cpu,u32 regs[8 ]);#else /* CONFIG_SMP */ -static inline int rdmsr_on_cpu (unsigned int cpu,u32 msr_no,u32 *l,u32 *h) +static inline int rdmsr_on_cpu (unsigned int cpu,u32 msr_no,u64 *q) { -rdmsr (msr_no, *l, *h); +rdmsrq (msr_no, *q);return 0 ; }static inline int wrmsr_on_cpu (unsigned int cpu,u32 msr_no,u32 l,u32 h)
@@ -292,7 +292,7 @@ static inline int wrmsrq_on_cpu(unsigned int cpu, u32 msr_no, u64 q)static inline void rdmsr_on_cpus (const struct cpumask *m,u32 msr_no,struct msr __percpu *msrs) { -rdmsr_on_cpu (0 , msr_no,raw_cpu_ptr (&msrs->l),raw_cpu_ptr (&msrs->h)); +rdmsr_on_cpu (0 , msr_no,raw_cpu_ptr (&msrs->q)); }static inline void wrmsr_on_cpus (const struct cpumask *m,u32 msr_no,struct msr __percpu *msrs)
arch/x86/kernel/cpu/mce/amd.c +3 -3
@@ -969,13 +969,13 @@ store_threshold_limit(struct threshold_block *b, const char *buf, size_t size)static ssize_t show_error_count (struct threshold_block *b,char *buf) { -u32 lo, hi; +struct msr val;/* CPU might be offline by now */ -if (rdmsr_on_cpu (b->cpu, b->address, &lo, &hi)) +if (rdmsr_on_cpu (b->cpu, b->address, &val.q))return -ENODEV ; -return sprintf (buf,"%u\n" , ((hi &THRESHOLD_MAX ) - +return sprintf (buf,"%u\n" , ((val.h &THRESHOLD_MAX ) - (THRESHOLD_MAX - b->threshold_limit))); }
arch/x86/kernel/cpu/mce/inject.c +4 -4
@@ -316,18 +316,18 @@ static struct notifier_block inject_nb = {*/ static int toggle_hw_mce_inject (unsigned int cpu,bool enable) { -u32 l, h; +struct msr val;int err; - err =rdmsr_on_cpu (cpu,MSR_K7_HWCR , &l, &h); + err =rdmsr_on_cpu (cpu,MSR_K7_HWCR , &val.q);if (err) {pr_err ("%s: error reading HWCR\n" , __func__);return err; } - enable ? (l |=BIT (18 )) : (l &= ~BIT (18 )); + enable ? (val.l |=BIT (18 )) : (val.l &= ~BIT (18 )); - err =wrmsr_on_cpu (cpu,MSR_K7_HWCR , l, h); + err =wrmsr_on_cpu (cpu,MSR_K7_HWCR , val.l, val.h);if (err)pr_err ("%s: error writing HWCR\n" , __func__);
arch/x86/lib/msr-smp.c +2 -3
@@ -31,7 +31,7 @@ static void __wrmsr_on_cpu(void *info)wrmsr (rv->msr_no, reg->l, reg->h); } -int rdmsr_on_cpu (unsigned int cpu,u32 msr_no,u32 *l,u32 *h) +int rdmsr_on_cpu (unsigned int cpu,u32 msr_no,u64 *q) {int err;struct msr_info rv;
@@ -40,8 +40,7 @@ int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) rv.msr_no = msr_no; err =smp_call_function_single (cpu, __rdmsr_on_cpu, &rv,1 ); - *l = rv.reg.l; - *h = rv.reg.h; + *q = rv.reg.q;return err; }
drivers/cpufreq/amd_freq_sensitivity.c +2 -2
@@ -52,9 +52,9 @@ static unsigned int amd_powersave_bias_target(struct cpufreq_policy *policy,return freq_next;rdmsr_on_cpu (policy->cpu,MSR_AMD64_FREQ_SENSITIVITY_ACTUAL , - &actual.l, &actual.h); + &actual.q);rdmsr_on_cpu (policy->cpu,MSR_AMD64_FREQ_SENSITIVITY_REFERENCE , - &reference.l, &reference.h); + &reference.q); actual.h &=0x00ffffff ; reference.h &=0x00ffffff ;
drivers/cpufreq/p4-clockmod.c +16 -16
@@ -51,24 +51,24 @@ static unsigned int cpufreq_p4_get(unsigned int cpu);static int cpufreq_p4_setdc (unsigned int cpu,unsigned int newstate) { -u32 l, h; +struct msr val;if ((newstate >DC_DISABLE ) || (newstate ==DC_RESV ))return -EINVAL ; -rdmsr_on_cpu (cpu,MSR_IA32_THERM_STATUS , &l, &h); +rdmsr_on_cpu (cpu,MSR_IA32_THERM_STATUS , &val.q); -if (l &0x01 ) +if (val.l &0x01 )pr_debug ("CPU#%d currently thermal throttled\n" , cpu);if (has_N44_O17_errata[cpu] && (newstate ==DC_25PT || newstate ==DC_DFLT )) newstate =DC_38PT ; -rdmsr_on_cpu (cpu,MSR_IA32_THERM_CONTROL , &l, &h); +rdmsr_on_cpu (cpu,MSR_IA32_THERM_CONTROL , &val.q);if (newstate ==DC_DISABLE ) {pr_debug ("CPU#%d disabling modulation\n" , cpu); -wrmsr_on_cpu (cpu,MSR_IA32_THERM_CONTROL , l & ~(1 <<4 ), h); +wrmsr_on_cpu (cpu,MSR_IA32_THERM_CONTROL , val.l & ~(1 <<4 ), val.h); }else {pr_debug ("CPU#%d setting duty cycle to %d%%\n" , cpu, ((125 * newstate) /10 ));
@@ -77,9 +77,9 @@ static int cpufreq_p4_setdc(unsigned int cpu, unsigned int newstate)* bits 3-1 : duty cycle * bit 0 : reserved */ - l = (l & ~14 ); - l = l | (1 <<4 ) | ((newstate &0x7 )<<1 ); -wrmsr_on_cpu (cpu,MSR_IA32_THERM_CONTROL , l, h); + val.l = (val.l & ~14 ); + val.l = val.l | (1 <<4 ) | ((newstate &0x7 )<<1 ); +wrmsr_on_cpu (cpu,MSR_IA32_THERM_CONTROL , val.l, val.h); }return 0 ;
@@ -205,18 +205,18 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)static unsigned int cpufreq_p4_get (unsigned int cpu) { -u32 l, h; +struct msr val; -rdmsr_on_cpu (cpu,MSR_IA32_THERM_CONTROL , &l, &h); +rdmsr_on_cpu (cpu,MSR_IA32_THERM_CONTROL , &val.q); -if (l &0x10 ) { - l = l >>1 ; - l &=0x7 ; +if (val.l &0x10 ) { + val.l = val.l >>1 ; + val.l &=0x7 ; }else - l =DC_DISABLE ; + val.l =DC_DISABLE ; -if (l !=DC_DISABLE ) -return stock_freq * l /8 ; +if (val.l !=DC_DISABLE ) +return stock_freq * val.l /8 ;return stock_freq; }
drivers/cpufreq/speedstep-centrino.c +14 -13
@@ -322,11 +322,11 @@ static unsigned extract_clock(unsigned msr, unsigned int cpu, int failsafe)/* Return the current CPU frequency in kHz */ static unsigned int get_cur_freq (unsigned int cpu) { -unsigned l, h; +struct msr val;unsigned clock_freq; -rdmsr_on_cpu (cpu,MSR_IA32_PERF_STATUS , &l, &h); - clock_freq =extract_clock (l, cpu,0 ); +rdmsr_on_cpu (cpu,MSR_IA32_PERF_STATUS , &val.q); + clock_freq =extract_clock (val.l, cpu,0 );if (unlikely (clock_freq ==0 )) {/*
@@ -335,8 +335,8 @@ static unsigned int get_cur_freq(unsigned int cpu)* P-state transition (like TM2). Get the last freq set * in PERF_CTL. */ -rdmsr_on_cpu (cpu,MSR_IA32_PERF_CTL , &l, &h); - clock_freq =extract_clock (l, cpu,1 ); +rdmsr_on_cpu (cpu,MSR_IA32_PERF_CTL , &val.q); + clock_freq =extract_clock (val.l, cpu,1 ); }return clock_freq; }
@@ -417,7 +417,8 @@ static void centrino_cpu_exit(struct cpufreq_policy *policy)*/ static int centrino_target (struct cpufreq_policy *policy,unsigned int index) { -unsigned int msr, oldmsr =0 , h =0 , cpu = policy->cpu; +unsigned int msr, cpu = policy->cpu; +struct msr oldmsr = { .q =0 };int retval =0 ;unsigned int j, first_cpu;struct cpufreq_frequency_table *op_points;
@@ -459,22 +460,22 @@ static int centrino_target(struct cpufreq_policy *policy, unsigned int index) msr = op_points->driver_data;if (first_cpu) { -rdmsr_on_cpu (good_cpu,MSR_IA32_PERF_CTL , &oldmsr, &h); -if (msr == (oldmsr &0xffff )) { +rdmsr_on_cpu (good_cpu,MSR_IA32_PERF_CTL , &oldmsr.q); +if (msr == (oldmsr.l &0xffff )) {pr_debug ("no change needed - msr was and needs " -"to be %x\n" , oldmsr); +"to be %x\n" , oldmsr.l); retval =0 ; goto out; } first_cpu =0 ;/* all but 16 LSB are reserved, treat them with care */ - oldmsr &= ~0xffff ; + oldmsr.l &= ~0xffff ; msr &=0xffff ; - oldmsr |= msr; + oldmsr.l |= msr; } -wrmsr_on_cpu (good_cpu,MSR_IA32_PERF_CTL , oldmsr, h); +wrmsr_on_cpu (good_cpu,MSR_IA32_PERF_CTL , oldmsr.l, oldmsr.h);if (policy->shared_type ==CPUFREQ_SHARED_TYPE_ANY )break ;
@@ -490,7 +491,7 @@ static int centrino_target(struct cpufreq_policy *policy, unsigned int index)*/ for_each_cpu (j, covered_cpus) -wrmsr_on_cpu (j,MSR_IA32_PERF_CTL , oldmsr, h); +wrmsr_on_cpu (j,MSR_IA32_PERF_CTL , oldmsr.l, oldmsr.h); } retval =0 ;
drivers/hwmon/coretemp.c +6 -6
@@ -356,15 +356,15 @@ static ssize_t show_label(struct device *dev,static ssize_t show_crit_alarm (struct device *dev,struct device_attribute *devattr,char *buf) { -u32 eax, edx; +struct msr val; struct temp_data *tdata = container_of(devattr, struct temp_data, sd_attrs[ATTR_CRIT_ALARM ]);mutex_lock (&tdata->update_lock); -rdmsr_on_cpu (tdata->cpu, tdata->status_reg, &eax, &edx); +rdmsr_on_cpu (tdata->cpu, tdata->status_reg, &val.q);mutex_unlock (&tdata->update_lock); -return sprintf (buf,"%d\n" , (eax >>5 ) &1 ); +return sprintf (buf,"%d\n" , (val.l >>5 ) &1 ); } static ssize_t show_tjmax(struct device *dev,
@@ -398,7 +398,7 @@ static ssize_t show_ttarget(struct device *dev,static ssize_t show_temp (struct device *dev,struct device_attribute *devattr,char *buf) { -u32 eax, edx; +struct msr val; struct temp_data *tdata = container_of(devattr, struct temp_data, sd_attrs[ATTR_TEMP]);int tjmax;
@@ -407,14 +407,14 @@ static ssize_t show_temp(struct device *dev, tjmax =get_tjmax (tdata, dev);/* Check whether the time interval has elapsed */ if (time_after (jiffies, tdata->last_updated +HZ )) { -rdmsr_on_cpu (tdata->cpu, tdata->status_reg, &eax, &edx); +rdmsr_on_cpu (tdata->cpu, tdata->status_reg, &val.q);/* * Ignore the valid bit. In all observed cases the register * value is either low or zero if the valid bit is 0. * Return it instead of reporting an error which doesn't * really help at all. */ - tdata->temp = tjmax - ((eax >>16 ) &0xff ) *1000 ; + tdata->temp = tjmax - ((val.l >>16 ) &0xff ) *1000 ; tdata->last_updated = jiffies; }
drivers/thermal/intel/x86_pkg_temp_thermal.c +12 -10
@@ -125,8 +125,9 @@ sys_set_trip_temp(struct thermal_zone_device *tzd, {struct zone_device *zonedev =thermal_zone_device_priv (tzd);unsigned int trip_index =THERMAL_TRIP_PRIV_TO_INT (trip->priv); -u32 l, h, mask, shift, intr; +u32 mask, shift, intr;int tj_max, val, ret; +struct msr v;if (temp ==THERMAL_TEMP_INVALID ) temp =0 ;
@@ -142,7 +143,7 @@ sys_set_trip_temp(struct thermal_zone_device *tzd,return -EINVAL ; ret =rdmsr_on_cpu (zonedev->cpu,MSR_IA32_PACKAGE_THERM_INTERRUPT , - &l, &h); + &v.q);if (ret <0 )return ret;
@@ -155,20 +156,20 @@ sys_set_trip_temp(struct thermal_zone_device *tzd, shift =THERM_SHIFT_THRESHOLD0 ; intr =THERM_INT_THRESHOLD0_ENABLE ; } - l &= ~mask; + v.l &= ~mask;/* * When users space sets a trip temperature == 0, which is indication * that, it is no longer interested in receiving notifications. */ if (!temp) { - l &= ~intr; + v.l &= ~intr; }else { - l |= val << shift; - l |= intr; + v.l |= val << shift; + v.l |= intr; }return wrmsr_on_cpu (zonedev->cpu,MSR_IA32_PACKAGE_THERM_INTERRUPT , - l, h); + v.l, v.h); }/* Thermal zone callback registry */
@@ -277,7 +278,8 @@ static int pkg_temp_thermal_trips_init(int cpu, int tj_max, struct thermal_trip *trips, int num_trips) {unsigned long thres_reg_value; -u32 mask, shift, eax, edx; +u32 mask, shift; +struct msr val;int ret, i;for (i =0 ; i < num_trips; i++) {
@@ -291,11 +293,11 @@ static int pkg_temp_thermal_trips_init(int cpu, int tj_max, } ret =rdmsr_on_cpu (cpu,MSR_IA32_PACKAGE_THERM_INTERRUPT , - &eax, &edx); + &val.q);if (ret <0 )return ret; - thres_reg_value = (eax & mask) >> shift; + thres_reg_value = (val.l & mask) >> shift; trips[i].temperature = thres_reg_value ? tj_max - thres_reg_value *1000 :THERMAL_TEMP_INVALID ;
Signature · 1 line
2.53.0
Juergen Gross
maintainerRFC PATCH 2/11 x86/msr: Switch all callers of rdmsrq_on_cpu() to use rdmsr_on_cpu()
In reply to Juergen GrossNow that rdmsr_on_cpu() has the same interface as rdmsrq_on_cpu(), the callers of rdmsrq_on_cpu() can be switched to rdmsr_on_cpu() and rdmsrq_on_cpu() can be removed.
At the same time switch the only user of rdmsrl_on_cpu() to rdmsr_on_cpu() and drop rdmsrl_on_cpu(), too.
--- arch/x86/events/intel/uncore_snbep.c | 2 +- arch/x86/include/asm/msr.h | 7 ------ arch/x86/kernel/cpu/intel_epb.c | 4 ++-- arch/x86/kernel/cpu/mce/inject.c | 4 ++-- arch/x86/kernel/cpu/microcode/intel.c | 2 +- arch/x86/lib/msr-smp.c | 15 ------------- drivers/cpufreq/acpi-cpufreq.c | 4 ++-- drivers/cpufreq/amd-pstate.c | 8 +++---- drivers/cpufreq/intel_pstate.c | 22 +++++++++---------- .../intel/uncore-frequency/uncore-frequency.c | 6 ++--- 10 files changed, 26 insertions(+), 48 deletions(-)
arch/x86/events/intel/uncore_snbep.c +1 -1
@@ -3695,7 +3695,7 @@ static int skx_msr_cpu_bus_read(int cpu, u64 *topology) {u64 msr_value; -if (rdmsrq_on_cpu (cpu,SKX_MSR_CPU_BUS_NUMBER , &msr_value) || +if (rdmsr_on_cpu (cpu,SKX_MSR_CPU_BUS_NUMBER , &msr_value) || !(msr_value &SKX_MSR_CPU_BUS_VALID_BIT ))return -ENXIO ;
arch/x86/include/asm/msr.h +0 -7
@@ -258,7 +258,6 @@ int msr_clear_bit(u32 msr, u8 bit);#ifdef CONFIG_SMP int rdmsr_on_cpu (unsigned int cpu,u32 msr_no,u64 *q);int wrmsr_on_cpu (unsigned int cpu,u32 msr_no,u32 l,u32 h); -int rdmsrq_on_cpu (unsigned int cpu,u32 msr_no,u64 *q);int wrmsrq_on_cpu (unsigned int cpu,u32 msr_no,u64 q);void rdmsr_on_cpus (const struct cpumask *mask,u32 msr_no,struct msr __percpu *msrs);void wrmsr_on_cpus (const struct cpumask *mask,u32 msr_no,struct msr __percpu *msrs);
@@ -279,11 +278,6 @@ static inline int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)wrmsr (msr_no, l, h);return 0 ; } -static inline int rdmsrq_on_cpu (unsigned int cpu,u32 msr_no,u64 *q) -{ -rdmsrq (msr_no, *q); -return 0 ; -}static inline int wrmsrq_on_cpu (unsigned int cpu,u32 msr_no,u64 q) {wrmsrq (msr_no, q);
@@ -329,7 +323,6 @@ static inline int wrmsr_safe_regs_on_cpu(unsigned int cpu, u32 regs[8])/* Compatibility wrappers: */ #define rdmsrl (msr, val) rdmsrq(msr, val)#define wrmsrl (msr, val) wrmsrq(msr, val) -#define rdmsrl_on_cpu (cpu, msr, q) rdmsrq_on_cpu(cpu, msr, q)#endif /* __ASSEMBLER__ */ #endif /* _ASM_X86_MSR_H */
arch/x86/kernel/cpu/intel_epb.c +2 -2
@@ -139,7 +139,7 @@ static ssize_t energy_perf_bias_show(struct device *dev,u64 epb;int ret; - ret =rdmsrq_on_cpu (cpu,MSR_IA32_ENERGY_PERF_BIAS , &epb); + ret =rdmsr_on_cpu (cpu,MSR_IA32_ENERGY_PERF_BIAS , &epb);if (ret <0 )return ret;
@@ -161,7 +161,7 @@ static ssize_t energy_perf_bias_store(struct device *dev,else if (kstrtou64 (buf,0 , &val) || val >MAX_EPB )return -EINVAL ; - ret =rdmsrq_on_cpu (cpu,MSR_IA32_ENERGY_PERF_BIAS , &epb); + ret =rdmsr_on_cpu (cpu,MSR_IA32_ENERGY_PERF_BIAS , &epb);if (ret <0 )return ret;
arch/x86/kernel/cpu/mce/inject.c +2 -2
@@ -590,7 +590,7 @@ static int inj_bank_set(void *data, u64 val)u64 cap;/* Get bank count on target CPU so we can handle non-uniform values. */ -rdmsrq_on_cpu (m->extcpu,MSR_IA32_MCG_CAP , &cap); +rdmsr_on_cpu (m->extcpu,MSR_IA32_MCG_CAP , &cap); n_banks = cap &MCG_BANKCNT_MASK ;if (val >= n_banks) {
@@ -614,7 +614,7 @@ static int inj_bank_set(void *data, u64 val)if (cpu_feature_enabled (X86_FEATURE_SMCA )) {u64 ipid; -if (rdmsrq_on_cpu (m->extcpu,MSR_AMD64_SMCA_MCx_IPID (val), &ipid)) { +if (rdmsr_on_cpu (m->extcpu,MSR_AMD64_SMCA_MCx_IPID (val), &ipid)) {pr_err ("Error reading IPID on CPU%d\n" , m->extcpu);return -EINVAL ; }
arch/x86/kernel/cpu/microcode/intel.c +1 -1
@@ -660,7 +660,7 @@ static void stage_microcode(void) pkg_id =topology_logical_package_id (cpu); - err =rdmsrq_on_cpu (cpu,MSR_IA32_MCU_STAGING_MBOX_ADDR , &mmio_pa); + err =rdmsr_on_cpu (cpu,MSR_IA32_MCU_STAGING_MBOX_ADDR , &mmio_pa);if (WARN_ON_ONCE (err))return ;
arch/x86/lib/msr-smp.c +0 -15
@@ -46,21 +46,6 @@ int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u64 *q) }EXPORT_SYMBOL (rdmsr_on_cpu); -int rdmsrq_on_cpu (unsigned int cpu,u32 msr_no,u64 *q) -{ -int err; -struct msr_info rv; - -memset (&rv,0 ,sizeof (rv)); - - rv.msr_no = msr_no; - err =smp_call_function_single (cpu, __rdmsr_on_cpu, &rv,1 ); - *q = rv.reg.q; - -return err; -} -EXPORT_SYMBOL (rdmsrq_on_cpu); -int wrmsr_on_cpu (unsigned int cpu,u32 msr_no,u32 l,u32 h) {int err;
drivers/cpufreq/acpi-cpufreq.c +2 -2
@@ -79,11 +79,11 @@ static bool boost_state(unsigned int cpu)case X86_VENDOR_INTEL :case X86_VENDOR_CENTAUR :case X86_VENDOR_ZHAOXIN : -rdmsrq_on_cpu (cpu,MSR_IA32_MISC_ENABLE , &msr); +rdmsr_on_cpu (cpu,MSR_IA32_MISC_ENABLE , &msr);return !(msr &MSR_IA32_MISC_ENABLE_TURBO_DISABLE );case X86_VENDOR_HYGON :case X86_VENDOR_AMD : -rdmsrq_on_cpu (cpu,MSR_K7_HWCR , &msr); +rdmsr_on_cpu (cpu,MSR_K7_HWCR , &msr);return !(msr &MSR_K7_HWCR_CPB_DIS ); }return false;
drivers/cpufreq/amd-pstate.c +4 -4
@@ -208,7 +208,7 @@ static u8 msr_get_epp(struct amd_cpudata *cpudata)u64 value;int ret; - ret =rdmsrq_on_cpu (cpudata->cpu,MSR_AMD_CPPC_REQ , &value); + ret =rdmsr_on_cpu (cpudata->cpu,MSR_AMD_CPPC_REQ , &value);if (ret <0 ) {pr_debug ("Could not retrieve energy perf value (%d)\n" , ret);return ret;
@@ -382,7 +382,7 @@ static int amd_pstate_init_floor_perf(struct cpufreq_policy *policy)if (!cpu_feature_enabled (X86_FEATURE_CPPC_PERF_PRIO ))return 0 ; - ret =rdmsrq_on_cpu (cpudata->cpu,MSR_AMD_CPPC_REQ2 , &value); + ret =rdmsr_on_cpu (cpudata->cpu,MSR_AMD_CPPC_REQ2 , &value);if (ret) {pr_err ("failed to read CPPC REQ2 value. Error (%d)\n" , ret);return ret;
@@ -480,7 +480,7 @@ static int msr_init_perf(struct amd_cpudata *cpudata)if (ret)return ret; - ret =rdmsrl_on_cpu (cpudata->cpu,MSR_AMD_CPPC_REQ , &cppc_req); + ret =rdmsr_on_cpu (cpudata->cpu,MSR_AMD_CPPC_REQ , &cppc_req);if (ret)return ret;
@@ -881,7 +881,7 @@ static int amd_pstate_init_boost_support(struct amd_cpudata *cpudata) goto exit_err; } - ret =rdmsrq_on_cpu (cpudata->cpu,MSR_K7_HWCR , &boost_val); + ret =rdmsr_on_cpu (cpudata->cpu,MSR_K7_HWCR , &boost_val);if (ret) {pr_err_once ("failed to read initial CPU boost state!\n" ); ret = -EIO ;
drivers/cpufreq/intel_pstate.c +11 -11
@@ -632,8 +632,8 @@ static s16 intel_pstate_get_epp(struct cpudata *cpu_data, u64 hwp_req_data)* MSR_HWP_REQUEST, so need to read and get EPP. */ if (!hwp_req_data) { - epp =rdmsrq_on_cpu (cpu_data->cpu,MSR_HWP_REQUEST , - &hwp_req_data); + epp =rdmsr_on_cpu (cpu_data->cpu,MSR_HWP_REQUEST , + &hwp_req_data);if (epp)return epp; }
@@ -886,7 +886,7 @@ static ssize_t show_base_frequency(struct cpufreq_policy *policy, char *buf)if (ratio <=0 ) {u64 cap; -rdmsrq_on_cpu (policy->cpu,MSR_HWP_CAPABILITIES , &cap); +rdmsr_on_cpu (policy->cpu,MSR_HWP_CAPABILITIES , &cap); ratio =HWP_GUARANTEED_PERF (cap); }
@@ -1187,7 +1187,7 @@ static void __intel_pstate_get_hwp_cap(struct cpudata *cpu) {u64 cap; -rdmsrq_on_cpu (cpu->cpu,MSR_HWP_CAPABILITIES , &cap); +rdmsr_on_cpu (cpu->cpu,MSR_HWP_CAPABILITIES , &cap);WRITE_ONCE (cpu->hwp_cap_cached, cap); cpu->pstate.max_pstate =HWP_GUARANTEED_PERF (cap); cpu->pstate.turbo_pstate =HWP_HIGHEST_PERF (cap);
@@ -1269,7 +1269,7 @@ static void intel_pstate_hwp_set(unsigned int cpu)if (cpu_data->policy ==CPUFREQ_POLICY_PERFORMANCE ) min = max; -rdmsrq_on_cpu (cpu,MSR_HWP_REQUEST , &value); +rdmsr_on_cpu (cpu,MSR_HWP_REQUEST , &value); value &= ~HWP_MIN_PERF (~0L ); value |=HWP_MIN_PERF (min);
@@ -2156,7 +2156,7 @@ static int core_get_min_pstate(int cpu) {u64 value; -rdmsrq_on_cpu (cpu,MSR_PLATFORM_INFO , &value); +rdmsr_on_cpu (cpu,MSR_PLATFORM_INFO , &value);return (value >>40 ) &0xFF ; }
@@ -2164,7 +2164,7 @@ static int core_get_max_pstate_physical(int cpu) {u64 value; -rdmsrq_on_cpu (cpu,MSR_PLATFORM_INFO , &value); +rdmsr_on_cpu (cpu,MSR_PLATFORM_INFO , &value);return (value >>8 ) &0xFF ; }
@@ -2209,7 +2209,7 @@ static int core_get_max_pstate(int cpu)int tdp_ratio;int err; -rdmsrq_on_cpu (cpu,MSR_PLATFORM_INFO , &plat_info); +rdmsr_on_cpu (cpu,MSR_PLATFORM_INFO , &plat_info); max_pstate = (plat_info >>8 ) &0xFF ; tdp_ratio =core_get_tdp_ratio (cpu, plat_info);
@@ -2241,7 +2241,7 @@ static int core_get_turbo_pstate(int cpu)u64 value;int nont, ret; -rdmsrq_on_cpu (cpu,MSR_TURBO_RATIO_LIMIT , &value); +rdmsr_on_cpu (cpu,MSR_TURBO_RATIO_LIMIT , &value); nont =core_get_max_pstate (cpu); ret = (value) &255 ;if (ret <= nont)
@@ -2264,7 +2264,7 @@ static int knl_get_turbo_pstate(int cpu)u64 value;int nont, ret; -rdmsrq_on_cpu (cpu,MSR_TURBO_RATIO_LIMIT , &value); +rdmsr_on_cpu (cpu,MSR_TURBO_RATIO_LIMIT , &value); nont =core_get_max_pstate (cpu); ret = (((value) >>8 ) &0xFF );if (ret <= nont)
@@ -3318,7 +3318,7 @@ static int intel_cpufreq_cpu_init(struct cpufreq_policy *policy)intel_pstate_get_hwp_cap (cpu); -rdmsrq_on_cpu (cpu->cpu,MSR_HWP_REQUEST , &value); +rdmsr_on_cpu (cpu->cpu,MSR_HWP_REQUEST , &value);WRITE_ONCE (cpu->hwp_req_cached, value); cpu->epp_cached =intel_pstate_get_epp (cpu, value);
drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c +3 -3
@@ -52,7 +52,7 @@ static int uncore_read_control_freq(struct uncore_data *data, unsigned int *valuif (data->control_cpu <0 )return -ENXIO ; - ret =rdmsrq_on_cpu (data->control_cpu,MSR_UNCORE_RATIO_LIMIT , &cap); + ret =rdmsr_on_cpu (data->control_cpu,MSR_UNCORE_RATIO_LIMIT , &cap);if (ret)return ret;
@@ -77,7 +77,7 @@ static int uncore_write_control_freq(struct uncore_data *data, unsigned int inpuif (data->control_cpu <0 )return -ENXIO ; - ret =rdmsrq_on_cpu (data->control_cpu,MSR_UNCORE_RATIO_LIMIT , &cap); + ret =rdmsr_on_cpu (data->control_cpu,MSR_UNCORE_RATIO_LIMIT , &cap);if (ret)return ret;
@@ -106,7 +106,7 @@ static int uncore_read_freq(struct uncore_data *data, unsigned int *freq)if (data->control_cpu <0 )return -ENXIO ; - ret =rdmsrq_on_cpu (data->control_cpu,MSR_UNCORE_PERF_STATUS , &ratio); + ret =rdmsr_on_cpu (data->control_cpu,MSR_UNCORE_PERF_STATUS , &ratio);if (ret)return ret;
Signature · 1 line
2.53.0
Juergen Gross
maintainerRFC PATCH 3/11 x86/msr: Switch wrmsr_on_cpu() to use a 64-bit quantity
In reply to Juergen GrossIn order to prepare retiring wrmsrq_on_cpu() switch wrmsr_on_cpu() to have the same interface as wrmsrq_on_cpu().
Switch all wrmsr_on_cpu() callers to use the new interface.
--- arch/x86/events/intel/ds.c | 11 ++++------- arch/x86/include/asm/msr.h | 8 ++++---- arch/x86/kernel/cpu/mce/inject.c | 2 +- arch/x86/lib/msr-smp.c | 5 ++--- drivers/cpufreq/p4-clockmod.c | 4 ++-- drivers/cpufreq/speedstep-centrino.c | 4 ++-- drivers/thermal/intel/x86_pkg_temp_thermal.c | 2 +- 7 files changed, 16 insertions(+), 20 deletions(-)
arch/x86/events/intel/ds.c +4 -7
@@ -780,9 +780,7 @@ void init_debug_store_on_cpu(int cpu)if (!ds)return ; -wrmsr_on_cpu (cpu,MSR_IA32_DS_AREA , - (u32)((u64 )(unsigned long )ds), - (u32)((u64 )(unsigned long )ds >>32 )); +wrmsr_on_cpu (cpu,MSR_IA32_DS_AREA , (u64 )(unsigned long )ds); }void fini_debug_store_on_cpu (int cpu)
@@ -790,7 +788,7 @@ void fini_debug_store_on_cpu(int cpu)if (!per_cpu (cpu_hw_events, cpu).ds)return ; -wrmsr_on_cpu (cpu,MSR_IA32_DS_AREA ,0 ,0 ); +wrmsr_on_cpu (cpu,MSR_IA32_DS_AREA ,0 ); } static DEFINE_PER_CPU(void *, insn_buffer);
@@ -1095,8 +1093,7 @@ void init_arch_pebs_on_cpu(int cpu)* contiguous physical buffer (__alloc_pages_node() with order) */ arch_pebs_base =virt_to_phys (cpuc->pebs_vaddr) |PEBS_BUFFER_SHIFT ; -wrmsr_on_cpu (cpu,MSR_IA32_PEBS_BASE , (u32 )arch_pebs_base, - (u32)(arch_pebs_base >>32 )); +wrmsr_on_cpu (cpu,MSR_IA32_PEBS_BASE , arch_pebs_base); x86_pmu.pebs_active =1 ; }
@@ -1105,7 +1102,7 @@ inline void fini_arch_pebs_on_cpu(int cpu)if (!x86_pmu.arch_pebs)return ; -wrmsr_on_cpu (cpu,MSR_IA32_PEBS_BASE ,0 ,0 ); +wrmsr_on_cpu (cpu,MSR_IA32_PEBS_BASE ,0 ); }/*
arch/x86/include/asm/msr.h +4 -4
@@ -257,7 +257,7 @@ int msr_clear_bit(u32 msr, u8 bit);#ifdef CONFIG_SMP int rdmsr_on_cpu (unsigned int cpu,u32 msr_no,u64 *q); -int wrmsr_on_cpu (unsigned int cpu,u32 msr_no,u32 l,u32 h); +int wrmsr_on_cpu (unsigned int cpu,u32 msr_no,u64 q);int wrmsrq_on_cpu (unsigned int cpu,u32 msr_no,u64 q);void rdmsr_on_cpus (const struct cpumask *mask,u32 msr_no,struct msr __percpu *msrs);void wrmsr_on_cpus (const struct cpumask *mask,u32 msr_no,struct msr __percpu *msrs);
@@ -273,9 +273,9 @@ static inline int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u64 *q)rdmsrq (msr_no, *q);return 0 ; } -static inline int wrmsr_on_cpu (unsigned int cpu,u32 msr_no,u32 l,u32 h) +static inline int wrmsr_on_cpu (unsigned int cpu,u32 msr_no,u64 q) { -wrmsr (msr_no, l, h); +wrmsrq (msr_no, q);return 0 ; }static inline int wrmsrq_on_cpu (unsigned int cpu,u32 msr_no,u64 q)
@@ -291,7 +291,7 @@ static inline void rdmsr_on_cpus(const struct cpumask *m, u32 msr_no,static inline void wrmsr_on_cpus (const struct cpumask *m,u32 msr_no,struct msr __percpu *msrs) { -wrmsr_on_cpu (0 , msr_no,raw_cpu_read (msrs->l),raw_cpu_read (msrs->h)); +wrmsrq_on_cpu (0 , msr_no,raw_cpu_read (msrs->q)); }static inline int rdmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u32 *l,u32 *h)
arch/x86/kernel/cpu/mce/inject.c +1 -1
@@ -327,7 +327,7 @@ static int toggle_hw_mce_inject(unsigned int cpu, bool enable) enable ? (val.l |=BIT (18 )) : (val.l &= ~BIT (18 )); - err =wrmsr_on_cpu (cpu,MSR_K7_HWCR , val.l, val.h); + err =wrmsr_on_cpu (cpu,MSR_K7_HWCR , val.q);if (err)pr_err ("%s: error writing HWCR\n" , __func__);
arch/x86/lib/msr-smp.c +2 -3
@@ -46,7 +46,7 @@ int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u64 *q) }EXPORT_SYMBOL (rdmsr_on_cpu); -int wrmsr_on_cpu (unsigned int cpu,u32 msr_no,u32 l,u32 h) +int wrmsr_on_cpu (unsigned int cpu,u32 msr_no,u64 q) {int err;struct msr_info rv;
@@ -54,8 +54,7 @@ int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)memset (&rv,0 ,sizeof (rv)); rv.msr_no = msr_no; - rv.reg.l = l; - rv.reg.h = h; + rv.reg.q = q; err =smp_call_function_single (cpu, __wrmsr_on_cpu, &rv,1 );return err;
drivers/cpufreq/p4-clockmod.c +2 -2
@@ -68,7 +68,7 @@ static int cpufreq_p4_setdc(unsigned int cpu, unsigned int newstate)rdmsr_on_cpu (cpu,MSR_IA32_THERM_CONTROL , &val.q);if (newstate ==DC_DISABLE ) {pr_debug ("CPU#%d disabling modulation\n" , cpu); -wrmsr_on_cpu (cpu,MSR_IA32_THERM_CONTROL , val.l & ~(1 <<4 ), val.h); +wrmsr_on_cpu (cpu,MSR_IA32_THERM_CONTROL , val.q & ~(1ULL <<4 )); }else {pr_debug ("CPU#%d setting duty cycle to %d%%\n" , cpu, ((125 * newstate) /10 ));
@@ -79,7 +79,7 @@ static int cpufreq_p4_setdc(unsigned int cpu, unsigned int newstate)*/ val.l = (val.l & ~14 ); val.l = val.l | (1 <<4 ) | ((newstate &0x7 )<<1 ); -wrmsr_on_cpu (cpu,MSR_IA32_THERM_CONTROL , val.l, val.h); +wrmsr_on_cpu (cpu,MSR_IA32_THERM_CONTROL , val.q); }return 0 ;
drivers/cpufreq/speedstep-centrino.c +2 -2
@@ -475,7 +475,7 @@ static int centrino_target(struct cpufreq_policy *policy, unsigned int index) oldmsr.l |= msr; } -wrmsr_on_cpu (good_cpu,MSR_IA32_PERF_CTL , oldmsr.l, oldmsr.h); +wrmsr_on_cpu (good_cpu,MSR_IA32_PERF_CTL , oldmsr.q);if (policy->shared_type ==CPUFREQ_SHARED_TYPE_ANY )break ;
@@ -491,7 +491,7 @@ static int centrino_target(struct cpufreq_policy *policy, unsigned int index)*/ for_each_cpu (j, covered_cpus) -wrmsr_on_cpu (j,MSR_IA32_PERF_CTL , oldmsr.l, oldmsr.h); +wrmsr_on_cpu (j,MSR_IA32_PERF_CTL , oldmsr.q); } retval =0 ;
drivers/thermal/intel/x86_pkg_temp_thermal.c +1 -1
@@ -169,7 +169,7 @@ sys_set_trip_temp(struct thermal_zone_device *tzd, }return wrmsr_on_cpu (zonedev->cpu,MSR_IA32_PACKAGE_THERM_INTERRUPT , - v.l, v.h); + v.q); }/* Thermal zone callback registry */
Signature · 1 line
2.53.0
Juergen Gross
maintainerRFC PATCH 4/11 x86/msr: Switch all callers of wrmsrq_on_cpu() to use wrmsr_on_cpu()
In reply to Juergen GrossNow that wrmsr_on_cpu() has the same interface as wrmsrq_on_cpu(), the callers of wrmsrq_on_cpu() can be switched to wrmsr_on_cpu() and wrmsrq_on_cpu() can be removed.
--- arch/x86/include/asm/msr.h | 8 +---- arch/x86/kernel/cpu/intel_epb.c | 4 +-- arch/x86/lib/msr-smp.c | 16 --------- drivers/cpufreq/amd-pstate.c | 8 ++--- drivers/cpufreq/intel_pstate.c | 36 +++++++++---------- drivers/platform/x86/amd/hfi/hfi.c | 4 +-- .../intel/uncore-frequency/uncore-frequency.c | 6 ++-- 7 files changed, 30 insertions(+), 52 deletions(-)
arch/x86/include/asm/msr.h +1 -7
@@ -258,7 +258,6 @@ int msr_clear_bit(u32 msr, u8 bit);#ifdef CONFIG_SMP int rdmsr_on_cpu (unsigned int cpu,u32 msr_no,u64 *q);int wrmsr_on_cpu (unsigned int cpu,u32 msr_no,u64 q); -int wrmsrq_on_cpu (unsigned int cpu,u32 msr_no,u64 q);void rdmsr_on_cpus (const struct cpumask *mask,u32 msr_no,struct msr __percpu *msrs);void wrmsr_on_cpus (const struct cpumask *mask,u32 msr_no,struct msr __percpu *msrs);int rdmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u32 *l,u32 *h);
@@ -278,11 +277,6 @@ static inline int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u64 q)wrmsrq (msr_no, q);return 0 ; } -static inline int wrmsrq_on_cpu (unsigned int cpu,u32 msr_no,u64 q) -{ -wrmsrq (msr_no, q); -return 0 ; -}static inline void rdmsr_on_cpus (const struct cpumask *m,u32 msr_no,struct msr __percpu *msrs) {
@@ -291,7 +285,7 @@ static inline void rdmsr_on_cpus(const struct cpumask *m, u32 msr_no,static inline void wrmsr_on_cpus (const struct cpumask *m,u32 msr_no,struct msr __percpu *msrs) { -wrmsrq_on_cpu (0 , msr_no,raw_cpu_read (msrs->q)); +wrmsr_on_cpu (0 , msr_no,raw_cpu_read (msrs->q)); }static inline int rdmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u32 *l,u32 *h)
arch/x86/kernel/cpu/intel_epb.c +2 -2
@@ -165,8 +165,8 @@ static ssize_t energy_perf_bias_store(struct device *dev,if (ret <0 )return ret; - ret =wrmsrq_on_cpu (cpu,MSR_IA32_ENERGY_PERF_BIAS , - (epb & ~EPB_MASK ) | val); + ret =wrmsr_on_cpu (cpu,MSR_IA32_ENERGY_PERF_BIAS , + (epb & ~EPB_MASK ) | val);if (ret <0 )return ret;
arch/x86/lib/msr-smp.c +0 -16
@@ -61,22 +61,6 @@ int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u64 q) }EXPORT_SYMBOL (wrmsr_on_cpu); -int wrmsrq_on_cpu (unsigned int cpu,u32 msr_no,u64 q) -{ -int err; -struct msr_info rv; - -memset (&rv,0 ,sizeof (rv)); - - rv.msr_no = msr_no; - rv.reg.q = q; - - err =smp_call_function_single (cpu, __wrmsr_on_cpu, &rv,1 ); - -return err; -} -EXPORT_SYMBOL (wrmsrq_on_cpu); -static void __rwmsr_on_cpus (const struct cpumask *mask,u32 msr_no,struct msr __percpu *msrs,void (*msr_func) (void *info))
drivers/cpufreq/amd-pstate.c +4 -4
@@ -271,7 +271,7 @@ static int msr_update_perf(struct cpufreq_policy *policy, u8 min_perf,if (fast_switch) {wrmsrq (MSR_AMD_CPPC_REQ , value); }else { -int ret =wrmsrq_on_cpu (cpudata->cpu,MSR_AMD_CPPC_REQ , value); +int ret =wrmsr_on_cpu (cpudata->cpu,MSR_AMD_CPPC_REQ , value);if (ret)return ret;
@@ -319,7 +319,7 @@ static int msr_set_epp(struct cpufreq_policy *policy, u8 epp)if (value == prev)return 0 ; - ret =wrmsrq_on_cpu (cpudata->cpu,MSR_AMD_CPPC_REQ , value); + ret =wrmsr_on_cpu (cpudata->cpu,MSR_AMD_CPPC_REQ , value);if (ret) {pr_err ("failed to set energy perf value (%d)\n" , ret);return ret;
@@ -357,7 +357,7 @@ static int amd_pstate_set_floor_perf(struct cpufreq_policy *policy, u8 perf) goto out_trace; } - ret =wrmsrq_on_cpu (cpudata->cpu,MSR_AMD_CPPC_REQ2 , value); + ret =wrmsr_on_cpu (cpudata->cpu,MSR_AMD_CPPC_REQ2 , value);if (ret) { changed = false;pr_err ("failed to set CPPC REQ2 value. Error (%d)\n" , ret);
@@ -900,7 +900,7 @@ static int amd_pstate_init_boost_support(struct amd_cpudata *cpudata)static void amd_perf_ctl_reset (unsigned int cpu) { -wrmsrq_on_cpu (cpu,MSR_AMD_PERF_CTL ,0 ); +wrmsr_on_cpu (cpu,MSR_AMD_PERF_CTL ,0 ); }#define CPPC_MAX_PERF U8_MAX
drivers/cpufreq/intel_pstate.c +18 -18
@@ -736,7 +736,7 @@ static int intel_pstate_set_epp(struct cpudata *cpu, u32 epp)* function, so it cannot run in parallel with the update below. */ WRITE_ONCE (cpu->hwp_req_cached, value); - ret =wrmsrq_on_cpu (cpu->cpu,MSR_HWP_REQUEST , value); + ret =wrmsr_on_cpu (cpu->cpu,MSR_HWP_REQUEST , value);if (!ret) cpu->epp_cached = epp;
@@ -1315,7 +1315,7 @@ static void intel_pstate_hwp_set(unsigned int cpu) skip_epp:WRITE_ONCE (cpu_data->hwp_req_cached, value); -wrmsrq_on_cpu (cpu,MSR_HWP_REQUEST , value); +wrmsr_on_cpu (cpu,MSR_HWP_REQUEST , value); }static void intel_pstate_disable_hwp_interrupt (struct cpudata *cpudata);
@@ -1362,7 +1362,7 @@ static void intel_pstate_hwp_offline(struct cpudata *cpu)if (boot_cpu_has (X86_FEATURE_HWP_EPP )) value |=HWP_ENERGY_PERF_PREFERENCE (HWP_EPP_POWERSAVE ); -wrmsrq_on_cpu (cpu->cpu,MSR_HWP_REQUEST , value); +wrmsr_on_cpu (cpu->cpu,MSR_HWP_REQUEST , value);mutex_lock (&hybrid_capacity_lock);
@@ -1411,7 +1411,7 @@ static void intel_pstate_hwp_enable(struct cpudata *cpudata);static void intel_pstate_hwp_reenable (struct cpudata *cpu) {intel_pstate_hwp_enable (cpu); -wrmsrq_on_cpu (cpu->cpu,MSR_HWP_REQUEST ,READ_ONCE (cpu->hwp_req_cached)); +wrmsr_on_cpu (cpu->cpu,MSR_HWP_REQUEST ,READ_ONCE (cpu->hwp_req_cached)); }static int intel_pstate_suspend (struct cpufreq_policy *policy)
@@ -1919,7 +1919,7 @@ static void intel_pstate_notify_work(struct work_struct *work)hybrid_update_capacity (cpudata); } -wrmsrq_on_cpu (cpudata->cpu,MSR_HWP_STATUS ,0 ); +wrmsr_on_cpu (cpudata->cpu,MSR_HWP_STATUS ,0 ); }static DEFINE_RAW_SPINLOCK (hwp_notify_lock);
@@ -1969,8 +1969,8 @@ static void intel_pstate_disable_hwp_interrupt(struct cpudata *cpudata)if (!cpu_feature_enabled (X86_FEATURE_HWP_NOTIFY ))return ; -/* wrmsrq_on_cpu has to be outside spinlock as this can result in IPC */ -wrmsrq_on_cpu (cpudata->cpu,MSR_HWP_INTERRUPT ,0x00 ); +/* wrmsr_on_cpu has to be outside spinlock as this can result in IPC */ +wrmsr_on_cpu (cpudata->cpu,MSR_HWP_INTERRUPT ,0x00 );raw_spin_lock_irq (&hwp_notify_lock); cancel_work =cpumask_test_and_clear_cpu (cpudata->cpu, &hwp_intr_enable_mask);
@@ -1997,9 +1997,9 @@ static void intel_pstate_enable_hwp_interrupt(struct cpudata *cpudata)if (cpu_feature_enabled (X86_FEATURE_HWP_HIGHEST_PERF_CHANGE )) interrupt_mask |=HWP_HIGHEST_PERF_CHANGE_REQ ; -/* wrmsrq_on_cpu has to be outside spinlock as this can result in IPC */ -wrmsrq_on_cpu (cpudata->cpu,MSR_HWP_INTERRUPT , interrupt_mask); -wrmsrq_on_cpu (cpudata->cpu,MSR_HWP_STATUS ,0 ); +/* wrmsr_on_cpu has to be outside spinlock as this can result in IPC */ +wrmsr_on_cpu (cpudata->cpu,MSR_HWP_INTERRUPT , interrupt_mask); +wrmsr_on_cpu (cpudata->cpu,MSR_HWP_STATUS ,0 ); } }
@@ -2038,9 +2038,9 @@ static void intel_pstate_hwp_enable(struct cpudata *cpudata) {/* First disable HWP notification interrupt till we activate again */ if (boot_cpu_has (X86_FEATURE_HWP_NOTIFY )) -wrmsrq_on_cpu (cpudata->cpu,MSR_HWP_INTERRUPT ,0x00 ); +wrmsr_on_cpu (cpudata->cpu,MSR_HWP_INTERRUPT ,0x00 ); -wrmsrq_on_cpu (cpudata->cpu,MSR_PM_ENABLE ,0x1 ); +wrmsr_on_cpu (cpudata->cpu,MSR_PM_ENABLE ,0x1 );intel_pstate_enable_hwp_interrupt (cpudata);
@@ -2306,8 +2306,8 @@ static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate)* the CPU being updated, so force the register update to run on the * right CPU. */ -wrmsrq_on_cpu (cpu->cpu,MSR_IA32_PERF_CTL , - pstate_funcs.get_val (cpu, pstate)); +wrmsr_on_cpu (cpu->cpu,MSR_IA32_PERF_CTL , + pstate_funcs.get_val (cpu, pstate)); }static void intel_pstate_set_min_pstate (struct cpudata *cpu)
@@ -3164,7 +3164,7 @@ static void intel_cpufreq_hwp_update(struct cpudata *cpu, u32 min, u32 max,if (fast_switch)wrmsrq (MSR_HWP_REQUEST , value);else -wrmsrq_on_cpu (cpu->cpu,MSR_HWP_REQUEST , value); +wrmsr_on_cpu (cpu->cpu,MSR_HWP_REQUEST , value); } static void intel_cpufreq_perf_ctl_update(struct cpudata *cpu,
@@ -3174,8 +3174,8 @@ static void intel_cpufreq_perf_ctl_update(struct cpudata *cpu,wrmsrq (MSR_IA32_PERF_CTL , pstate_funcs.get_val (cpu, target_pstate)); else - wrmsrq_on_cpu(cpu->cpu, MSR_IA32_PERF_CTL, - pstate_funcs.get_val(cpu, target_pstate)); + wrmsr_on_cpu(cpu->cpu, MSR_IA32_PERF_CTL, + pstate_funcs.get_val(cpu, target_pstate)); } static int intel_cpufreq_update_pstate(struct cpufreq_policy *policy,
@@ -3385,7 +3385,7 @@ static int intel_cpufreq_suspend(struct cpufreq_policy *policy)* written by it may not be suitable. */ value &= ~HWP_DESIRED_PERF (~0L ); -wrmsrq_on_cpu (cpu->cpu,MSR_HWP_REQUEST , value); +wrmsr_on_cpu (cpu->cpu,MSR_HWP_REQUEST , value);WRITE_ONCE (cpu->hwp_req_cached, value); }
drivers/platform/x86/amd/hfi/hfi.c +2 -2
@@ -260,11 +260,11 @@ static int amd_hfi_set_state(unsigned int cpu, bool state) {int ret; - ret =wrmsrq_on_cpu (cpu,MSR_AMD_WORKLOAD_CLASS_CONFIG , state ?1 :0 ); + ret =wrmsr_on_cpu (cpu,MSR_AMD_WORKLOAD_CLASS_CONFIG , state ?1 :0 );if (ret)return ret; -return wrmsrq_on_cpu (cpu,MSR_AMD_WORKLOAD_HRST ,0x1 ); +return wrmsr_on_cpu (cpu,MSR_AMD_WORKLOAD_HRST ,0x1 ); }/**
drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c +3 -3
@@ -89,7 +89,7 @@ static int uncore_write_control_freq(struct uncore_data *data, unsigned int inpu cap |=FIELD_PREP (UNCORE_MIN_RATIO_MASK , input); } - ret =wrmsrq_on_cpu (data->control_cpu,MSR_UNCORE_RATIO_LIMIT , cap); + ret =wrmsr_on_cpu (data->control_cpu,MSR_UNCORE_RATIO_LIMIT , cap);if (ret)return ret;
@@ -213,8 +213,8 @@ static int uncore_pm_notify(struct notifier_block *nb, unsigned long mode,if (!data || !data->valid || !data->stored_uncore_data)return 0 ; -wrmsrq_on_cpu (data->control_cpu,MSR_UNCORE_RATIO_LIMIT , - data->stored_uncore_data); +wrmsr_on_cpu (data->control_cpu,MSR_UNCORE_RATIO_LIMIT , + data->stored_uncore_data); }break ;default :
Signature · 1 line
2.53.0
Juergen Gross
maintainerRFC PATCH 5/11 x86/msr: Switch rdmsr_safe_on_cpu() to return a 64-bit quantity
In reply to Juergen GrossIn order to prepare retiring rdmsrq_safe_on_cpu() switch rdmsr_safe_on_cpu() to have the same interface as rdmsrq_safe_on_cpu().
Switch all rdmsr_safe_on_cpu() callers to use the new interface.
--- arch/x86/include/asm/msr.h | 7 +++-- arch/x86/kernel/msr.c | 4 +-- arch/x86/lib/msr-smp.c | 9 +++---- drivers/hwmon/coretemp.c | 32 +++++++++++------------ drivers/hwmon/via-cputemp.c | 16 ++++++------ drivers/thermal/intel/intel_tcc.c | 43 ++++++++++++++++--------------- 6 files changed, 54 insertions(+), 57 deletions(-)
arch/x86/include/asm/msr.h +3 -4
@@ -260,7 +260,7 @@ int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u64 *q);int wrmsr_on_cpu (unsigned int cpu,u32 msr_no,u64 q);void rdmsr_on_cpus (const struct cpumask *mask,u32 msr_no,struct msr __percpu *msrs);void wrmsr_on_cpus (const struct cpumask *mask,u32 msr_no,struct msr __percpu *msrs); -int rdmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u32 *l,u32 *h); +int rdmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 *q);int wrmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u32 l,u32 h);int rdmsrq_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 *q);int wrmsrq_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 q);
@@ -287,10 +287,9 @@ static inline void wrmsr_on_cpus(const struct cpumask *m, u32 msr_no, {wrmsr_on_cpu (0 , msr_no,raw_cpu_read (msrs->q)); } -static inline int rdmsr_safe_on_cpu (unsigned int cpu,u32 msr_no, -u32 *l,u32 *h) +static inline int rdmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 *q) { -return rdmsr_safe (msr_no, l, h); +return rdmsrq_safe (msr_no, q); }static inline int wrmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u32 l,u32 h) {
arch/x86/kernel/msr.c +2 -2
@@ -53,7 +53,7 @@ static ssize_t msr_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { u32 __user *tmp = (u32 __user *) buf; -u32 data[2 ]; +u64 data;u32 reg = *ppos;int cpu =iminor (file_inode (file));int err =0 ;
@@ -63,7 +63,7 @@ static ssize_t msr_read(struct file *file, char __user *buf,return -EINVAL ;/* Invalid chunk size */ for (; count; count -=8 ) { - err =rdmsr_safe_on_cpu (cpu, reg, &data[0 ], &data[1 ]); + err =rdmsr_safe_on_cpu (cpu, reg, &data);if (err)break ;if (copy_to_user (tmp, &data,8 )) {
arch/x86/lib/msr-smp.c +3 -6
@@ -131,7 +131,7 @@ static void __wrmsr_safe_on_cpu(void *info) rv->err =wrmsr_safe (rv->msr_no, rv->reg.l, rv->reg.h); } -int rdmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u32 *l,u32 *h) +int rdmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 *q) {struct msr_info_completion rv;call_single_data_t csd;
@@ -148,8 +148,7 @@ int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)wait_for_completion (&rv.done); err = rv.msr.err; } - *l = rv.msr.reg.l; - *h = rv.msr.reg.h; + *q = rv.msr.reg.q;return err; }
@@ -189,11 +188,9 @@ EXPORT_SYMBOL(wrmsrq_safe_on_cpu);int rdmsrq_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 *q) { -u32 low, high;int err; - err =rdmsr_safe_on_cpu (cpu, msr_no, &low, &high); - *q = (u64 )high <<32 | low; + err =rdmsr_safe_on_cpu (cpu, msr_no, q);return err; }
drivers/hwmon/coretemp.c +16 -16
@@ -169,7 +169,7 @@ static int adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)int tjmax_ee =85000 ;int usemsr_ee =1 ;int err; -u32 eax, edx; +u64 val;int i;u16 devfn =PCI_DEVFN (0 ,0 );struct pci_dev *host_bridge =pci_get_domain_bus_and_slot (0 ,0 , devfn);
@@ -220,14 +220,14 @@ static int adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)* http://softwarecommunity.intel.com/Wiki/Mobility/720.htm * For Core2 cores, check MSR 0x17, bit 28 1 = Mobile CPU */ - err =rdmsr_safe_on_cpu (id,0x17 , &eax, &edx); + err =rdmsr_safe_on_cpu (id,0x17 , &val);if (err) {dev_warn (dev,"Unable to access MSR 0x17, assuming desktop" " CPU\n" ); usemsr_ee =0 ; }else if (c->x86_vfm <INTEL_CORE2_PENRYN && - !(eax &0x10000000 )) { + !(val &0x10000000 )) {/* * Trust bit 28 up to Penryn, I could not find any * documentation on that; if you happen to know
@@ -235,8 +235,8 @@ static int adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)*/ usemsr_ee =0 ; }else { -/* Platform ID bits 52:50 (EDX starts at bit 32) */ - platform_id = (edx >>18 ) &0x7 ; +/* Platform ID bits 52:50 */ + platform_id = (val >>50 ) &0x7 ;/* * Mobile Penryn CPU seems to be platform ID 7 or 5
@@ -255,12 +255,12 @@ static int adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev) }if (usemsr_ee) { - err =rdmsr_safe_on_cpu (id,0xee , &eax, &edx); + err =rdmsr_safe_on_cpu (id,0xee , &val);if (err) {dev_warn (dev,"Unable to access MSR 0xEE, for Tjmax, left" " at default\n" ); - }else if (eax &0x40000000 ) { + }else if (val &0x40000000 ) { tjmax = tjmax_ee; } }else if (tjmax ==100000 ) {
@@ -278,7 +278,7 @@ static int get_tjmax(struct temp_data *tdata, struct device *dev) {struct cpuinfo_x86 *c = &cpu_data (tdata->cpu);int err; -u32 eax, edx; +u64 msrval;u32 val;/* use static tjmax once it is set */
@@ -289,11 +289,11 @@ static int get_tjmax(struct temp_data *tdata, struct device *dev)* A new feature of current Intel(R) processors, the * IA32_TEMPERATURE_TARGET contains the TjMax value */ - err =rdmsr_safe_on_cpu (tdata->cpu,MSR_IA32_TEMPERATURE_TARGET , &eax, &edx); + err =rdmsr_safe_on_cpu (tdata->cpu,MSR_IA32_TEMPERATURE_TARGET , &msrval);if (err) {dev_warn_once (dev,"Unable to read TjMax from CPU %u\n" , tdata->cpu); }else { - val = (eax >>16 ) &0xff ; + val = (msrval >>16 ) &0xff ;if (val)return val *1000 ; }
@@ -314,7 +314,7 @@ static int get_tjmax(struct temp_data *tdata, struct device *dev)static int get_ttarget (struct temp_data *tdata,struct device *dev) { -u32 eax, edx; +u64 val;int tjmax, ttarget_offset, ret;/*
@@ -324,14 +324,14 @@ static int get_ttarget(struct temp_data *tdata, struct device *dev)if (tdata->tjmax)return -ENODEV ; - ret =rdmsr_safe_on_cpu (tdata->cpu,MSR_IA32_TEMPERATURE_TARGET , &eax, &edx); + ret =rdmsr_safe_on_cpu (tdata->cpu,MSR_IA32_TEMPERATURE_TARGET , &val);if (ret)return ret; - tjmax = (eax >>16 ) &0xff ; + tjmax = (val >>16 ) &0xff ;/* Read the still undocumented bits 8:15 of IA32_TEMPERATURE_TARGET. */ - ttarget_offset = (eax >>8 ) &0xff ; + ttarget_offset = (val >>8 ) &0xff ;return (tjmax - ttarget_offset) *1000 ; }
@@ -560,7 +560,7 @@ static int create_core_data(struct platform_device *pdev, unsigned int cpu,struct temp_data *tdata;struct platform_data *pdata =platform_get_drvdata (pdev);struct cpuinfo_x86 *c = &cpu_data (cpu); -u32 eax, edx; +u64 val;int err;if (!housekeeping_cpu (cpu,HK_TYPE_MISC ))
@@ -571,7 +571,7 @@ static int create_core_data(struct platform_device *pdev, unsigned int cpu,return -ENOMEM ;/* Test if we can access the status register */ - err =rdmsr_safe_on_cpu (cpu, tdata->status_reg, &eax, &edx); + err =rdmsr_safe_on_cpu (cpu, tdata->status_reg, &val);if (err) goto err;
drivers/hwmon/via-cputemp.c +8 -8
@@ -65,28 +65,28 @@ static ssize_t temp_show(struct device *dev, struct device_attribute *devattr, char *buf) {struct via_cputemp_data *data =dev_get_drvdata (dev); -u32 eax, edx; +u64 val;int err; - err =rdmsr_safe_on_cpu (data->id, data->msr_temp, &eax, &edx); + err =rdmsr_safe_on_cpu (data->id, data->msr_temp, &val);if (err)return -EAGAIN ; -return sprintf (buf,"%lu\n" , ((unsigned long )eax &0xffffff ) *1000 ); +return sprintf (buf,"%lu\n" , ((unsigned long )val &0xffffff ) *1000 ); }static ssize_t cpu0_vid_show (struct device *dev,struct device_attribute *devattr,char *buf) {struct via_cputemp_data *data =dev_get_drvdata (dev); -u32 eax, edx; +u64 val;int err; - err =rdmsr_safe_on_cpu (data->id, data->msr_vid, &eax, &edx); + err =rdmsr_safe_on_cpu (data->id, data->msr_vid, &val);if (err)return -EAGAIN ; -return sprintf (buf,"%d\n" ,vid_from_reg (~edx &0x7f , data->vrm)); +return sprintf (buf,"%d\n" ,vid_from_reg (~(val >>32 ) &0x7f , data->vrm)); } static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, SHOW_TEMP);
@@ -112,7 +112,7 @@ static int via_cputemp_probe(struct platform_device *pdev)struct via_cputemp_data *data;struct cpuinfo_x86 *c = &cpu_data (pdev->id);int err; -u32 eax, edx; +u64 val; data =devm_kzalloc (&pdev->dev,sizeof (struct via_cputemp_data ),GFP_KERNEL );
@@ -143,7 +143,7 @@ static int via_cputemp_probe(struct platform_device *pdev) }/* test if we can access the TEMPERATURE MSR */ - err =rdmsr_safe_on_cpu (data->id, data->msr_temp, &eax, &edx); + err =rdmsr_safe_on_cpu (data->id, data->msr_temp, &val);if (err) {dev_err (&pdev->dev,"Unable to access TEMPERATURE MSR, giving up\n" );
drivers/thermal/intel/intel_tcc.c +22 -21
112 lines not on this page · raw message
Signature · 1 line
2.53.0
Juergen Gross
maintainerRFC PATCH 6/11 x86/msr: Switch all callers of rdmsrq_safe_on_cpu() to use rdmsr_safe_on_cpu()
In reply to Juergen GrossNow that rdmsr_safe_on_cpu() has the same interface as rdmsrq_safe_on_cpu(), the callers of rdmsrq_safe_on_cpu() can be switched to rdmsr_safe_on_cpu() and rdmsrq_safe_on_cpu() can be removed.
--- arch/x86/events/intel/pt.c | 2 +- arch/x86/events/intel/uncore_discovery.c | 2 +- arch/x86/include/asm/msr.h | 5 ----- arch/x86/kernel/acpi/cppc.c | 6 +++--- arch/x86/lib/msr-smp.c | 10 ---------- drivers/cpufreq/amd-pstate-ut.c | 2 +- drivers/cpufreq/amd-pstate.c | 3 +-- drivers/cpufreq/intel_pstate.c | 6 +++--- .../x86/intel/speed_select_if/isst_if_common.c | 4 ++-- drivers/powercap/intel_rapl_msr.c | 2 +- 10 files changed, 13 insertions(+), 29 deletions(-)
arch/x86/events/intel/pt.c +1 -1
@@ -1840,7 +1840,7 @@ static __init int pt_init(void)for_each_online_cpu (cpu) {u64 ctl; - ret =rdmsrq_safe_on_cpu (cpu,MSR_IA32_RTIT_CTL , &ctl); + ret =rdmsr_safe_on_cpu (cpu,MSR_IA32_RTIT_CTL , &ctl);if (!ret && (ctl &RTIT_CTL_TRACEEN )) prior_warn++; }
arch/x86/events/intel/uncore_discovery.c +1 -1
@@ -405,7 +405,7 @@ static bool uncore_discovery_msr(struct uncore_discovery_domain *domain)if (__test_and_set_bit (die, die_mask))continue ; -if (rdmsrq_safe_on_cpu (cpu, domain->discovery_base, &base)) +if (rdmsr_safe_on_cpu (cpu, domain->discovery_base, &base))continue ;if (!base)
arch/x86/include/asm/msr.h +0 -5
@@ -262,7 +262,6 @@ void rdmsr_on_cpus(const struct cpumask *mask, u32 msr_no, struct msr __percpu *void wrmsr_on_cpus (const struct cpumask *mask,u32 msr_no,struct msr __percpu *msrs);int rdmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 *q);int wrmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u32 l,u32 h); -int rdmsrq_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 *q);int wrmsrq_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 q);int rdmsr_safe_regs_on_cpu (unsigned int cpu,u32 regs[8 ]);int wrmsr_safe_regs_on_cpu (unsigned int cpu,u32 regs[8 ]);
@@ -295,10 +294,6 @@ static inline int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) {return wrmsr_safe (msr_no, l, h); } -static inline int rdmsrq_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 *q) -{ -return rdmsrq_safe (msr_no, q); -}static inline int wrmsrq_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 q) {return wrmsrq_safe (msr_no, q);
arch/x86/kernel/acpi/cppc.c +3 -3
@@ -49,7 +49,7 @@ int cpc_read_ffh(int cpunum, struct cpc_reg *reg, u64 *val) {int err; - err =rdmsrq_safe_on_cpu (cpunum, reg->address, val); + err =rdmsr_safe_on_cpu (cpunum, reg->address, val);if (!err) {u64 mask =GENMASK_ULL (reg->bit_offset + reg->bit_width -1 , reg->bit_offset);
@@ -65,7 +65,7 @@ int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val)u64 rd_val;int err; - err =rdmsrq_safe_on_cpu (cpunum, reg->address, &rd_val); + err =rdmsr_safe_on_cpu (cpunum, reg->address, &rd_val);if (!err) {u64 mask =GENMASK_ULL (reg->bit_offset + reg->bit_width -1 , reg->bit_offset);
@@ -147,7 +147,7 @@ int amd_get_highest_perf(unsigned int cpu, u32 *highest_perf)int ret;if (cpu_feature_enabled (X86_FEATURE_CPPC )) { - ret =rdmsrq_safe_on_cpu (cpu,MSR_AMD_CPPC_CAP1 , &val); + ret =rdmsr_safe_on_cpu (cpu,MSR_AMD_CPPC_CAP1 , &val);if (ret) goto out;
arch/x86/lib/msr-smp.c +0 -10
@@ -186,16 +186,6 @@ int wrmsrq_safe_on_cpu(unsigned int cpu, u32 msr_no, u64 q) }EXPORT_SYMBOL (wrmsrq_safe_on_cpu); -int rdmsrq_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 *q) -{ -int err; - - err =rdmsr_safe_on_cpu (cpu, msr_no, q); - -return err; -} -EXPORT_SYMBOL (rdmsrq_safe_on_cpu); -/* * These variants are significantly slower, but allows control over * the entire 32-bit GPR set.
drivers/cpufreq/amd-pstate-ut.c +1 -1
@@ -170,7 +170,7 @@ static int amd_pstate_ut_check_perf(u32 index) lowest_nonlinear_perf = cppc_perf.lowest_nonlinear_perf; lowest_perf = cppc_perf.lowest_perf; }else { - ret =rdmsrq_safe_on_cpu (cpu,MSR_AMD_CPPC_CAP1 , &cap1); + ret =rdmsr_safe_on_cpu (cpu,MSR_AMD_CPPC_CAP1 , &cap1);if (ret) {pr_err ("%s read CPPC_CAP1 ret=%d error!\n" , __func__, ret);return ret;
drivers/cpufreq/amd-pstate.c +1 -2
@@ -471,8 +471,7 @@ static int msr_init_perf(struct amd_cpudata *cpudata)u64 cap1, numerator, cppc_req;u8 min_perf; -int ret =rdmsrq_safe_on_cpu (cpudata->cpu,MSR_AMD_CPPC_CAP1 , - &cap1); +int ret =rdmsr_safe_on_cpu (cpudata->cpu,MSR_AMD_CPPC_CAP1 , &cap1);if (ret)return ret;
drivers/cpufreq/intel_pstate.c +3 -3
@@ -2178,13 +2178,13 @@ static int core_get_tdp_ratio(int cpu, u64 plat_info)int err;/* Get the TDP level (0, 1, 2) to get ratios */ - err =rdmsrq_safe_on_cpu (cpu,MSR_CONFIG_TDP_CONTROL , &tdp_ctrl); + err =rdmsr_safe_on_cpu (cpu,MSR_CONFIG_TDP_CONTROL , &tdp_ctrl);if (err)return err;/* TDP MSR are continuous starting at 0x648 */ tdp_msr =MSR_CONFIG_TDP_NOMINAL + (tdp_ctrl &0x03 ); - err =rdmsrq_safe_on_cpu (cpu, tdp_msr, &tdp_ratio); + err =rdmsr_safe_on_cpu (cpu, tdp_msr, &tdp_ratio);if (err)return err;
@@ -2221,7 +2221,7 @@ static int core_get_max_pstate(int cpu)return tdp_ratio; } - err =rdmsrq_safe_on_cpu (cpu,MSR_TURBO_ACTIVATION_RATIO , &tar); + err =rdmsr_safe_on_cpu (cpu,MSR_TURBO_ACTIVATION_RATIO , &tar);if (!err) {int tar_levels;
drivers/platform/x86/intel/speed_select_if/isst_if_common.c +2 -2
@@ -511,8 +511,8 @@ static long isst_if_msr_cmd_req(u8 *cmd_ptr, int *write_only, int resume) }else {u64 data; - ret =rdmsrq_safe_on_cpu (msr_cmd->logical_cpu, - msr_cmd->msr, &data); + ret =rdmsr_safe_on_cpu (msr_cmd->logical_cpu, + msr_cmd->msr, &data);if (!ret) { msr_cmd->data = data; *write_only =0 ;
drivers/powercap/intel_rapl_msr.c +1 -1
@@ -180,7 +180,7 @@ static int rapl_msr_read_raw(int cpu, struct reg_action *ra, bool pmu_ctx) goto out; } -if (rdmsrq_safe_on_cpu (cpu, ra->reg.msr, &ra->value)) { +if (rdmsr_safe_on_cpu (cpu, ra->reg.msr, &ra->value)) {pr_debug ("failed to read msr 0x%x on cpu %d\n" , ra->reg.msr, cpu);return -EIO ; }
Signature · 1 line
2.53.0
Juergen Gross
maintainerRFC PATCH 7/11 x86/msr: Switch wrmsr_safe_on_cpu() to use a 64-bit quantity
In reply to Juergen GrossIn order to prepare retiring wrmsrq_safe_on_cpu() switch wrmsr_safe_on_cpu() to have the same interface as wrmsrq_safe_on_cpu().
Switch all wrmsr_safe_on_cpu() callers to use the new interface.
--- arch/x86/include/asm/msr.h | 6 +++--- arch/x86/kernel/msr.c | 4 ++-- arch/x86/lib/msr-smp.c | 5 ++--- drivers/thermal/intel/intel_tcc.c | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-)
arch/x86/include/asm/msr.h +3 -3
@@ -261,7 +261,7 @@ int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u64 q);void rdmsr_on_cpus (const struct cpumask *mask,u32 msr_no,struct msr __percpu *msrs);void wrmsr_on_cpus (const struct cpumask *mask,u32 msr_no,struct msr __percpu *msrs);int rdmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 *q); -int wrmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u32 l,u32 h); +int wrmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 q);int wrmsrq_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 q);int rdmsr_safe_regs_on_cpu (unsigned int cpu,u32 regs[8 ]);int wrmsr_safe_regs_on_cpu (unsigned int cpu,u32 regs[8 ]);
@@ -290,9 +290,9 @@ static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u64 *q) {return rdmsrq_safe (msr_no, q); } -static inline int wrmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u32 l,u32 h) +static inline int wrmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 q) { -return wrmsr_safe (msr_no, l, h); +return wrmsrq_safe (msr_no, q); }static inline int wrmsrq_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 q) {
arch/x86/kernel/msr.c +2 -2
@@ -109,7 +109,7 @@ static ssize_t msr_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { const u32 __user *tmp = (const u32 __user *)buf; -u32 data[2 ]; +u64 data;u32 reg = *ppos;int cpu =iminor (file_inode (file));int err =0 ;
@@ -134,7 +134,7 @@ static ssize_t msr_write(struct file *file, const char __user *buf,add_taint (TAINT_CPU_OUT_OF_SPEC ,LOCKDEP_STILL_OK ); - err =wrmsr_safe_on_cpu (cpu, reg, data[0 ], data[1 ]); + err =wrmsr_safe_on_cpu (cpu, reg, data);if (err)break ;
arch/x86/lib/msr-smp.c +2 -3
@@ -154,7 +154,7 @@ int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u64 *q) }EXPORT_SYMBOL (rdmsr_safe_on_cpu); -int wrmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u32 l,u32 h) +int wrmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 q) {int err;struct msr_info rv;
@@ -162,8 +162,7 @@ int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)memset (&rv,0 ,sizeof (rv)); rv.msr_no = msr_no; - rv.reg.l = l; - rv.reg.h = h; + rv.reg.q = q; err =smp_call_function_single (cpu, __wrmsr_safe_on_cpu, &rv,1 );return err ? err : rv.err;
drivers/thermal/intel/intel_tcc.c +1 -1
@@ -261,7 +261,7 @@ int intel_tcc_set_offset(int cpu, int offset)if (cpu <0 )return wrmsr_safe (MSR_IA32_TEMPERATURE_TARGET , val.l, val.h);else -return wrmsr_safe_on_cpu (cpu,MSR_IA32_TEMPERATURE_TARGET , val.l, val.h); +return wrmsr_safe_on_cpu (cpu,MSR_IA32_TEMPERATURE_TARGET , val.q); }EXPORT_SYMBOL_NS_GPL (intel_tcc_set_offset,"INTEL_TCC" );
Signature · 1 line
2.53.0
Juergen Gross
maintainerRFC PATCH 8/11 x86/msr: Switch all callers of wrmsrq_safe_on_cpu() to use wrmsr_safe_on_cpu()
In reply to Juergen GrossNow that wrmsr_safe_on_cpu() has the same interface as wrmsrq_safe_on_cpu(), the callers of wrmsrq_safe_on_cpu() can be switched to wrmsr_safe_on_cpu() and wrmsrq_safe_on_cpu() can be removed.
--- arch/x86/include/asm/msr.h | 5 ----- arch/x86/kernel/acpi/cppc.c | 2 +- arch/x86/lib/msr-smp.c | 16 ---------------- drivers/cpufreq/amd-pstate.c | 2 +- .../x86/intel/speed_select_if/isst_if_common.c | 9 ++++----- 5 files changed, 6 insertions(+), 28 deletions(-)
arch/x86/include/asm/msr.h +0 -5
@@ -262,7 +262,6 @@ void rdmsr_on_cpus(const struct cpumask *mask, u32 msr_no, struct msr __percpu *void wrmsr_on_cpus (const struct cpumask *mask,u32 msr_no,struct msr __percpu *msrs);int rdmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 *q);int wrmsr_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 q); -int wrmsrq_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 q);int rdmsr_safe_regs_on_cpu (unsigned int cpu,u32 regs[8 ]);int wrmsr_safe_regs_on_cpu (unsigned int cpu,u32 regs[8 ]);#else /* CONFIG_SMP */
@@ -294,10 +293,6 @@ static inline int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u64 q) {return wrmsrq_safe (msr_no, q); } -static inline int wrmsrq_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 q) -{ -return wrmsrq_safe (msr_no, q); -}static inline int rdmsr_safe_regs_on_cpu (unsigned int cpu,u32 regs[8 ]) {return rdmsr_safe_regs (regs);
arch/x86/kernel/acpi/cppc.c +1 -1
@@ -74,7 +74,7 @@ int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val) val &= mask; rd_val &= ~mask; rd_val |= val; - err =wrmsrq_safe_on_cpu (cpunum, reg->address, rd_val); + err =wrmsr_safe_on_cpu (cpunum, reg->address, rd_val); }return err; }
arch/x86/lib/msr-smp.c +0 -16
@@ -169,22 +169,6 @@ int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u64 q) }EXPORT_SYMBOL (wrmsr_safe_on_cpu); -int wrmsrq_safe_on_cpu (unsigned int cpu,u32 msr_no,u64 q) -{ -int err; -struct msr_info rv; - -memset (&rv,0 ,sizeof (rv)); - - rv.msr_no = msr_no; - rv.reg.q = q; - - err =smp_call_function_single (cpu, __wrmsr_safe_on_cpu, &rv,1 ); - -return err ? err : rv.err; -} -EXPORT_SYMBOL (wrmsrq_safe_on_cpu); -/* * These variants are significantly slower, but allows control over * the entire 32-bit GPR set.
drivers/cpufreq/amd-pstate.c +1 -1
@@ -450,7 +450,7 @@ static int shmem_set_epp(struct cpufreq_policy *policy, u8 epp)static inline int msr_cppc_enable (struct cpufreq_policy *policy) { -return wrmsrq_safe_on_cpu (policy->cpu,MSR_AMD_CPPC_ENABLE ,1 ); +return wrmsr_safe_on_cpu (policy->cpu,MSR_AMD_CPPC_ENABLE ,1 ); }static int shmem_cppc_enable (struct cpufreq_policy *policy)
drivers/platform/x86/intel/speed_select_if/isst_if_common.c +4 -5
@@ -192,8 +192,8 @@ void isst_resume_common(void)if (cb->registered)isst_mbox_resume_command (cb, sst_cmd); }else { -wrmsrq_safe_on_cpu (sst_cmd->cpu, sst_cmd->cmd, - sst_cmd->data); +wrmsr_safe_on_cpu (sst_cmd->cpu, sst_cmd->cmd, + sst_cmd->data); } } }
@@ -500,9 +500,8 @@ static long isst_if_msr_cmd_req(u8 *cmd_ptr, int *write_only, int resume)if (!capable (CAP_SYS_ADMIN ))return -EPERM ; - ret =wrmsrq_safe_on_cpu (msr_cmd->logical_cpu, - msr_cmd->msr, - msr_cmd->data); + ret =wrmsr_safe_on_cpu (msr_cmd->logical_cpu, + msr_cmd->msr, msr_cmd->data); *write_only =1 ;if (!ret && !resume) ret = isst_store_cmd(0, msr_cmd->msr,
Signature · 1 line
2.53.0
Juergen Gross
maintainerRFC PATCH 9/11 x86/msr: Add macros for preparing to switch rdmsr/wrmsr interfaces
In reply to Juergen GrossIn order to prepare switching the rdmsr(), rdmasr_safe(), wrmsr() and wrmsr_safe() interfaces to 64-bit values instead of 32-bit pairs, add macros to call different implementations depending on the number of passed parameters.
This enables to use the same function/macro names as today while doing the interface switch per component instead of one go.
At the same time switch the rdmsr related interfaces to inline functions, avoiding to change variables passed as a parameter to be changed.
The helper macros will be removed when all users of the current interfaces have been switched to the new ones.
--- arch/x86/include/asm/msr.h | 46 +++++++++++++++++++++++++++++---- arch/x86/include/asm/paravirt.h | 6 ++--- 2 files changed, 44 insertions(+), 8 deletions(-)
arch/x86/include/asm/msr.h +41 -5
@@ -12,6 +12,7 @@#include <uapi/asm/msr.h> #include <asm/shared/msr.h> +#include <linux/args.h> #include <linux/types.h> #include <linux/percpu.h>
@@ -179,14 +180,14 @@ static inline u64 native_read_pmc(int counter)* pointer indirection), this allows gcc to optimize better */ -#define rdmsr (msr, low, high) \ +#define __rdmsr_3 (msr, low, high) \ do { \ u64 __val = native_read_msr((msr)); \ (void)((low) = (u32)__val); \ (void)((high) = (u32)(__val >> 32)); \ } while (0) -static inline void wrmsr (u32 msr,u32 low,u32 high) +static inline void __wrmsr_3 (u32 msr,u32 low,u32 high) {native_write_msr (msr, (u64 )high <<32 | low); }
@@ -206,7 +207,7 @@ static inline int wrmsrq_safe(u32 msr, u64 val) }/* rdmsr with exception handling */ -#define rdmsr_safe (msr, low, high) \ +#define __rdmsr_safe_3 (msr, low, high) \ ({ \ u64 __val; \ int __err = native_read_msr_safe((msr), &__val); \
@@ -243,13 +244,48 @@ static __always_inline void wrmsrns(u32 msr, u64 val) }/* -* Dual u32 version of wrmsrq_safe(): +* Dual u32 versions of wrmsr_safe(): */ -static inline int wrmsr_safe (u32 msr,u32 low,u32 high) +static __always_inline int __wrmsr_safe_3(u32 msr, u32 low, u32 high) {return wrmsrq_safe (msr, (u64 )high <<32 | low); } +/* +* u64 versions of rdmsr/wrmsr[_safe](): +*/ +static __always_inline u64 __rdmsr_1(u32 msr) +{ +u64 val; + +rdmsrq (msr, val); + +return val; +} + +static __always_inline void __wrmsr_2(u32 msr, u64 val) +{ +wrmsrq (msr, val); +} + +static __always_inline int __rdmsr_safe_2(u32 msr, u64 *p) +{ +return rdmsrq_safe (msr, p); +} + +static __always_inline int __wrmsr_safe_2(u32 msr, u64 val) +{ +return wrmsrq_safe (msr, val); +} + +/* +* Macros for selecting u64 or dual u32 versions of rdmsr/wrmsr[_safe](): +*/ +#define rdmsr (...) CONCATENATE(__rdmsr_, COUNT_ARGS(__VA_ARGS__))(__VA_ARGS__) +#define wrmsr (...) CONCATENATE(__wrmsr_, COUNT_ARGS(__VA_ARGS__))(__VA_ARGS__) +#define rdmsr_safe (...) CONCATENATE(__rdmsr_safe_, COUNT_ARGS(__VA_ARGS__))(__VA_ARGS__) +#define wrmsr_safe (...) CONCATENATE(__wrmsr_safe_, COUNT_ARGS(__VA_ARGS__))(__VA_ARGS__) +struct msr __percpu *msrs_alloc (void );void msrs_free (struct msr __percpu *msrs);int msr_set_bit (u32 msr,u8 bit);
arch/x86/include/asm/paravirt.h +3 -3
@@ -150,14 +150,14 @@ static inline int paravirt_write_msr_safe(u32 msr, u64 val)return PVOP_CALL2 (int, pv_ops, cpu.write_msr_safe, msr, val); } -#define rdmsr (msr, val1, val2) \ +#define __rdmsr_3 (msr, val1, val2) \ do { \ u64 _l = paravirt_read_msr(msr); \ val1 = (u32)_l; \ val2 = _l >> 32; \ } while (0) -static __always_inline void wrmsr(u32 msr, u32 low, u32 high) +static __always_inline void __wrmsr_3(u32 msr, u32 low, u32 high) {paravirt_write_msr (msr, (u64 )high <<32 | low); }
@@ -178,7 +178,7 @@ static inline int wrmsrq_safe(u32 msr, u64 val) }/* rdmsr with exception handling */ -#define rdmsr_safe (msr, a, b) \ +#define __rdmsr_safe_3 (msr, a, b) \ ({ \ u64 _l; \ int _err = paravirt_read_msr_safe((msr), &_l); \
Signature · 1 line
2.53.0
Juergen Gross
maintainerRFC PATCH 10/11 x86/events: Switch core parts to use 64-bit rdmsr/wrmsr() variants
In reply to Juergen GrossSwitch the core parts of the x86 events subsystem to use the new 64-bit forms of rdmsr(), rdmasr_safe(), wrmsr() and wrmsr_safe().
--- arch/x86/events/core.c | 42 ++++++++++++++++++------------------ arch/x86/events/msr.c | 2 +- arch/x86/events/perf_event.h | 26 +++++++++++----------- arch/x86/events/probe.c | 2 +- arch/x86/events/rapl.c | 8 +++---- 5 files changed, 40 insertions(+), 40 deletions(-)
arch/x86/events/core.c +21 -21
@@ -279,7 +279,7 @@ bool check_hw_exists(struct pmu *pmu, unsigned long *cntr_mask,*/ for_each_set_bit (i, cntr_mask,X86_PMC_IDX_MAX ) { reg =x86_pmu_config_addr (i); - ret =rdmsrq_safe (reg, &val); + ret =rdmsr_safe (reg, &val);if (ret) goto msr_fail;if (val &ARCH_PERFMON_EVENTSEL_ENABLE ) {
@@ -293,7 +293,7 @@ bool check_hw_exists(struct pmu *pmu, unsigned long *cntr_mask,if (*(u64 *)fixed_cntr_mask) { reg =MSR_ARCH_PERFMON_FIXED_CTR_CTRL ; - ret =rdmsrq_safe (reg, &val); + ret =rdmsr_safe (reg, &val);if (ret) goto msr_fail;for_each_set_bit (i, fixed_cntr_mask,X86_PMC_IDX_MAX ) {
@@ -324,11 +324,11 @@ bool check_hw_exists(struct pmu *pmu, unsigned long *cntr_mask,* (qemu/kvm) that don't trap on the MSR access and always return 0s. */ reg =x86_pmu_event_addr (reg_safe); -if (rdmsrq_safe (reg, &val)) +if (rdmsr_safe (reg, &val)) goto msr_fail; val ^=0xffffUL ; - ret =wrmsrq_safe (reg, val); - ret |=rdmsrq_safe (reg, &val_new); + ret =wrmsr_safe (reg, val); + ret |=rdmsr_safe (reg, &val_new);if (ret || val != val_new) goto msr_fail;
@@ -713,13 +713,13 @@ void x86_pmu_disable_all(void)if (!test_bit (idx, cpuc->active_mask))continue ; -rdmsrq (x86_pmu_config_addr (idx), val); + val =rdmsr (x86_pmu_config_addr (idx));if (!(val &ARCH_PERFMON_EVENTSEL_ENABLE ))continue ; val &= ~ARCH_PERFMON_EVENTSEL_ENABLE ; -wrmsrq (x86_pmu_config_addr (idx), val); +wrmsr (x86_pmu_config_addr (idx), val);if (is_counter_pair (hwc)) -wrmsrq (x86_pmu_config_addr (idx +1 ),0 ); +wrmsr (x86_pmu_config_addr (idx +1 ),0 ); } }
@@ -1446,14 +1446,14 @@ int x86_perf_event_set_period(struct perf_event *event)*/ local64_set (&hwc->prev_count, (u64)-left); -wrmsrq (hwc->event_base, (u64)(-left) & x86_pmu.cntval_mask); +wrmsr (hwc->event_base, (u64)(-left) & x86_pmu.cntval_mask);/* * Sign extend the Merge event counter's upper 16 bits since * we currently declare a 48-bit counter width */ if (is_counter_pair (hwc)) -wrmsrq (x86_pmu_event_addr (idx +1 ),0xffff ); +wrmsr (x86_pmu_event_addr (idx +1 ),0xffff );perf_event_update_userpage (event);
@@ -1575,10 +1575,10 @@ void perf_event_print_debug(void)return ;if (x86_pmu.version >=2 ) { -rdmsrq (MSR_CORE_PERF_GLOBAL_CTRL , ctrl); -rdmsrq (MSR_CORE_PERF_GLOBAL_STATUS , status); -rdmsrq (MSR_CORE_PERF_GLOBAL_OVF_CTRL , overflow); -rdmsrq (MSR_ARCH_PERFMON_FIXED_CTR_CTRL , fixed); + ctrl =rdmsr (MSR_CORE_PERF_GLOBAL_CTRL ); + status =rdmsr (MSR_CORE_PERF_GLOBAL_STATUS ); + overflow =rdmsr (MSR_CORE_PERF_GLOBAL_OVF_CTRL ); + fixed =rdmsr (MSR_ARCH_PERFMON_FIXED_CTR_CTRL );pr_info ("\n" );pr_info ("CPU#%d: ctrl: %016llx\n" , cpu, ctrl);
@@ -1586,19 +1586,19 @@ void perf_event_print_debug(void)pr_info ("CPU#%d: overflow: %016llx\n" , cpu, overflow);pr_info ("CPU#%d: fixed: %016llx\n" , cpu, fixed);if (pebs_constraints) { -rdmsrq (MSR_IA32_PEBS_ENABLE , pebs); + pebs =rdmsr (MSR_IA32_PEBS_ENABLE );pr_info ("CPU#%d: pebs: %016llx\n" , cpu, pebs); }if (x86_pmu.lbr_nr) { -rdmsrq (MSR_IA32_DEBUGCTLMSR , debugctl); + debugctl =rdmsr (MSR_IA32_DEBUGCTLMSR );pr_info ("CPU#%d: debugctl: %016llx\n" , cpu, debugctl); } }pr_info ("CPU#%d: active: %016llx\n" , cpu, *(u64 *)cpuc->active_mask);for_each_set_bit (idx, cntr_mask,X86_PMC_IDX_MAX ) { -rdmsrq (x86_pmu_config_addr (idx), pmc_ctrl); -rdmsrq (x86_pmu_event_addr (idx), pmc_count); + pmc_ctrl =rdmsr (x86_pmu_config_addr (idx)); + pmc_count =rdmsr (x86_pmu_event_addr (idx)); prev_left =per_cpu (pmc_prev_left[idx], cpu);
@@ -1612,7 +1612,7 @@ void perf_event_print_debug(void)for_each_set_bit (idx, fixed_cntr_mask,X86_PMC_IDX_MAX ) {if (fixed_counter_disabled (idx, cpuc->pmu))continue ; -rdmsrq (x86_pmu_fixed_ctr_addr (idx), pmc_count); + pmc_count =rdmsr (x86_pmu_fixed_ctr_addr (idx));pr_info ("CPU#%d: fixed-PMC%d count: %016llx\n" , cpu, idx, pmc_count);
@@ -2560,9 +2560,9 @@ void perf_clear_dirty_counters(void)if (!test_bit (i -INTEL_PMC_IDX_FIXED ,hybrid (cpuc->pmu, fixed_cntr_mask)))continue ; -wrmsrq (x86_pmu_fixed_ctr_addr (i -INTEL_PMC_IDX_FIXED ),0 ); +wrmsr (x86_pmu_fixed_ctr_addr (i -INTEL_PMC_IDX_FIXED ),0 ); }else { -wrmsrq (x86_pmu_event_addr (i),0 ); +wrmsr (x86_pmu_event_addr (i),0 ); } }
arch/x86/events/msr.c +1 -1
@@ -158,7 +158,7 @@ static inline u64 msr_read_counter(struct perf_event *event)u64 now;if (event->hw.event_base) -rdmsrq (event->hw.event_base, now); + now =rdmsr (event->hw.event_base);else now =rdtsc_ordered ();
arch/x86/events/perf_event.h +13 -13
@@ -1271,16 +1271,16 @@ static inline void __x86_pmu_enable_event(struct hw_perf_event *hwc,u64 disable_mask =__this_cpu_read (cpu_hw_events.perf_ctr_virt_mask);if (hwc->extra_reg.reg) -wrmsrq (hwc->extra_reg.reg, hwc->extra_reg.config); +wrmsr (hwc->extra_reg.reg, hwc->extra_reg.config);/* * Add enabled Merge event on next counter * if large increment event being enabled on this counter */ if (is_counter_pair (hwc)) -wrmsrq (x86_pmu_config_addr (hwc->idx +1 ), x86_pmu.perf_ctr_pair_en); +wrmsr (x86_pmu_config_addr (hwc->idx +1 ), x86_pmu.perf_ctr_pair_en); -wrmsrq (hwc->config_base, (hwc->config | enable_mask) & ~disable_mask); +wrmsr (hwc->config_base, (hwc->config | enable_mask) & ~disable_mask); }void x86_pmu_enable_all (int added);
@@ -1296,10 +1296,10 @@ static inline void x86_pmu_disable_event(struct perf_event *event)u64 disable_mask =__this_cpu_read (cpu_hw_events.perf_ctr_virt_mask);struct hw_perf_event *hwc = &event->hw; -wrmsrq (hwc->config_base, hwc->config & ~disable_mask); +wrmsr (hwc->config_base, hwc->config & ~disable_mask);if (is_counter_pair (hwc)) -wrmsrq (x86_pmu_config_addr (hwc->idx +1 ),0 ); +wrmsr (x86_pmu_config_addr (hwc->idx +1 ),0 ); }void x86_pmu_enable_event (struct perf_event *event);
@@ -1473,12 +1473,12 @@ static __always_inline void __amd_pmu_lbr_disable(void) {u64 dbg_ctl, dbg_extn_cfg; -rdmsrq (MSR_AMD_DBG_EXTN_CFG , dbg_extn_cfg); -wrmsrq (MSR_AMD_DBG_EXTN_CFG , dbg_extn_cfg & ~DBG_EXTN_CFG_LBRV2EN ); + dbg_extn_cfg =rdmsr (MSR_AMD_DBG_EXTN_CFG ); +wrmsr (MSR_AMD_DBG_EXTN_CFG , dbg_extn_cfg & ~DBG_EXTN_CFG_LBRV2EN );if (cpu_feature_enabled (X86_FEATURE_AMD_LBR_PMC_FREEZE )) { -rdmsrq (MSR_IA32_DEBUGCTLMSR , dbg_ctl); -wrmsrq (MSR_IA32_DEBUGCTLMSR , dbg_ctl & ~DEBUGCTLMSR_FREEZE_LBRS_ON_PMI ); + dbg_ctl =rdmsr (MSR_IA32_DEBUGCTLMSR ); +wrmsr (MSR_IA32_DEBUGCTLMSR , dbg_ctl & ~DEBUGCTLMSR_FREEZE_LBRS_ON_PMI ); } }
@@ -1619,21 +1619,21 @@ static inline bool intel_pmu_has_bts(struct perf_event *event) static __always_inline void __intel_pmu_pebs_disable_all(void) { -wrmsrq (MSR_IA32_PEBS_ENABLE ,0 ); +wrmsr (MSR_IA32_PEBS_ENABLE ,0 ); } static __always_inline void __intel_pmu_arch_lbr_disable(void) { -wrmsrq (MSR_ARCH_LBR_CTL ,0 ); +wrmsr (MSR_ARCH_LBR_CTL ,0 ); } static __always_inline void __intel_pmu_lbr_disable(void) {u64 debugctl; -rdmsrq (MSR_IA32_DEBUGCTLMSR , debugctl); + debugctl =rdmsr (MSR_IA32_DEBUGCTLMSR ); debugctl &= ~(DEBUGCTLMSR_LBR |DEBUGCTLMSR_FREEZE_LBRS_ON_PMI ); -wrmsrq (MSR_IA32_DEBUGCTLMSR , debugctl); +wrmsr (MSR_IA32_DEBUGCTLMSR , debugctl); }int intel_pmu_save_and_restart (struct perf_event *event);
arch/x86/events/probe.c +1 -1
@@ -45,7 +45,7 @@ perf_msr_probe(struct perf_msr *msr, int cnt, bool zero, void *data)if (msr[bit].test && !msr[bit].test (bit, data))continue ;/* Virt sucks; you cannot tell if a R/O MSR is present :/ */ -if (rdmsrq_safe (msr[bit].msr, &val)) +if (rdmsr_safe (msr[bit].msr, &val))continue ; mask = msr[bit].mask;
arch/x86/events/rapl.c +4 -4
@@ -193,7 +193,7 @@ static inline unsigned int get_rapl_pmu_idx(int cpu, int scope)static inline u64 rapl_read_counter (struct perf_event *event) {u64 raw; -rdmsrq (event->hw.event_base, raw); + raw =rdmsr (event->hw.event_base);return raw; }
@@ -222,7 +222,7 @@ static u64 rapl_event_update(struct perf_event *event) prev_raw_count =local64_read (&hwc->prev_count);do { -rdmsrq (event->hw.event_base, new_raw_count); + new_raw_count =rdmsr (event->hw.event_base); }while (!local64_try_cmpxchg (&hwc->prev_count, &prev_raw_count, new_raw_count));
@@ -611,8 +611,8 @@ static int rapl_check_hw_unit(void)u64 msr_rapl_power_unit_bits;int i; -/* protect rdmsrq() to handle virtualization */ -if (rdmsrq_safe (rapl_model->msr_power_unit, &msr_rapl_power_unit_bits)) +/* protect rdmsr() to handle virtualization */ +if (rdmsr_safe (rapl_model->msr_power_unit, &msr_rapl_power_unit_bits))return -1 ;for (i =0 ; i <NR_RAPL_PKG_DOMAINS ; i++) rapl_pkg_hw_unit[i] = (msr_rapl_power_unit_bits >>8 ) &0x1FULL ;
Signature · 1 line
2.53.0
Juergen Gross
maintainerRFC PATCH 11/11 x86/cpu/mce: Switch code to use 64-bit rdmsr/wrmsr() variants
In reply to Juergen GrossSwitch the x86 MCE code to use the new 64-bit variants of rdmsr(), rdmsr_safe(), wrmsr() and wrmsr_safe().
--- arch/x86/kernel/cpu/mce/amd.c | 95 ++++++++++++++++--------------- arch/x86/kernel/cpu/mce/core.c | 18 +++--- arch/x86/kernel/cpu/mce/inject.c | 28 ++++----- arch/x86/kernel/cpu/mce/intel.c | 32 +++++------ arch/x86/kernel/cpu/mce/p5.c | 16 +++--- arch/x86/kernel/cpu/mce/winchip.c | 10 ++-- 6 files changed, 100 insertions(+), 99 deletions(-)
arch/x86/kernel/cpu/mce/amd.c +48 -47
@@ -280,11 +280,11 @@ static void smca_configure(unsigned int bank, unsigned int cpu)u8 *bank_counts =this_cpu_ptr (smca_bank_counts);const struct smca_hwid *s_hwid;unsigned int i, hwid_mcatype; -u32 high, low; +struct msr val;u32 smca_config =MSR_AMD64_SMCA_MCx_CONFIG (bank);/* Set appropriate bits in MCA_CONFIG */ -if (!rdmsr_safe (smca_config, &low, &high)) { +if (!rdmsr_safe (smca_config, &val.q)) {/* * OS is required to set the MCAX bit to acknowledge that it is * now using the new MSR ranges and new registers under each
@@ -294,7 +294,7 @@ static void smca_configure(unsigned int bank, unsigned int cpu)* * MCA_CONFIG[MCAX] is bit 32 (0 in the high portion of the MSR.) */ - high |=BIT (0 ); + val.h |=BIT (0 );/* * SMCA sets the Deferred Error Interrupt type per bank.
@@ -307,9 +307,9 @@ static void smca_configure(unsigned int bank, unsigned int cpu)* APIC based interrupt. First, check that no interrupt has been * set. */ -if ((low &BIT (5 )) && !((high >>5 ) &0x3 ) && data->dfr_intr_en) { +if ((val.l &BIT (5 )) && !((val.h >>5 ) &0x3 ) && data->dfr_intr_en) {__set_bit (bank, data->dfr_intr_banks); - high |=BIT (5 ); + val.h |=BIT (5 ); }/*
@@ -324,33 +324,33 @@ static void smca_configure(unsigned int bank, unsigned int cpu)* The OS should set this to inform the platform that the OS is ready * to handle the MCA Thresholding interrupt. */ -if ((low &BIT (10 )) && data->thr_intr_en) { +if ((val.l &BIT (10 )) && data->thr_intr_en) {__set_bit (bank, data->thr_intr_banks); - high |=BIT (8 ); + val.h |=BIT (8 ); } -this_cpu_ptr (mce_banks_array)[bank].lsb_in_status = !!(low &BIT (8 )); +this_cpu_ptr (mce_banks_array)[bank].lsb_in_status = !!(val.l &BIT (8 )); -if (low &MCI_CONFIG_PADDRV ) +if (val.l &MCI_CONFIG_PADDRV )this_cpu_ptr (smca_banks)[bank].paddrv =1 ; -wrmsr (smca_config, low, high); +wrmsr (smca_config, val.q); } -if (rdmsr_safe (MSR_AMD64_SMCA_MCx_IPID (bank), &low, &high)) { +if (rdmsr_safe (MSR_AMD64_SMCA_MCx_IPID (bank), &val.q)) {pr_warn ("Failed to read MCA_IPID for bank %d\n" , bank);return ; } - hwid_mcatype =HWID_MCATYPE (high &MCI_IPID_HWID , - (high &MCI_IPID_MCATYPE ) >>16 ); + hwid_mcatype =HWID_MCATYPE (val.h &MCI_IPID_HWID , + (val.h &MCI_IPID_MCATYPE ) >>16 );for (i =0 ; i <ARRAY_SIZE (smca_hwid_mcatypes); i++) { s_hwid = &smca_hwid_mcatypes[i];if (hwid_mcatype == s_hwid->hwid_mcatype) {this_cpu_ptr (smca_banks)[bank].hwid = s_hwid; -this_cpu_ptr (smca_banks)[bank].id = low; +this_cpu_ptr (smca_banks)[bank].id = val.l;this_cpu_ptr (smca_banks)[bank].sysfs_id = bank_counts[s_hwid->bank_type]++;break ; }
@@ -432,50 +432,50 @@ static bool lvt_off_valid(struct threshold_block *b, int apic, u32 lo, u32 hi)static void threshold_restart_block (void *_tr) {struct thresh_restart *tr = _tr; -u32 hi, lo; +struct msr val;/* sysfs write might race against an offline operation */ if (!this_cpu_read (threshold_banks) && !tr->set_lvt_off)return ; -rdmsr (tr->b->address, lo, hi); + val.q =rdmsr (tr->b->address);/* * Reset error count and overflow bit. * This is done during init or after handling an interrupt. */ -if (hi &MASK_OVERFLOW_HI || tr->set_lvt_off) { - hi &= ~(MASK_ERR_COUNT_HI |MASK_OVERFLOW_HI ); - hi |=THRESHOLD_MAX - tr->b->threshold_limit; +if (val.h &MASK_OVERFLOW_HI || tr->set_lvt_off) { + val.h &= ~(MASK_ERR_COUNT_HI |MASK_OVERFLOW_HI ); + val.h |=THRESHOLD_MAX - tr->b->threshold_limit; }else if (tr->old_limit) {/* change limit w/o reset */ -int new_count = (hi &THRESHOLD_MAX ) + +int new_count = (val.h &THRESHOLD_MAX ) + (tr->old_limit - tr->b->threshold_limit); - hi = (hi & ~MASK_ERR_COUNT_HI ) | + val.h = (val.h & ~MASK_ERR_COUNT_HI ) | (new_count &THRESHOLD_MAX ); }/* clear IntType */ - hi &= ~MASK_INT_TYPE_HI ; + val.h &= ~MASK_INT_TYPE_HI ;if (!tr->b->interrupt_capable) goto done;if (tr->set_lvt_off) { -if (lvt_off_valid (tr->b, tr->lvt_off, lo, hi)) { +if (lvt_off_valid (tr->b, tr->lvt_off, val.l, val.h)) {/* set new lvt offset */ - hi &= ~MASK_LVTOFF_HI ; - hi |= tr->lvt_off <<20 ; + val.h &= ~MASK_LVTOFF_HI ; + val.h |= tr->lvt_off <<20 ; } }if (tr->b->interrupt_enable) - hi |=INT_TYPE_APIC ; + val.h |=INT_TYPE_APIC ; done: - hi |=MASK_COUNT_EN_HI ; -wrmsr (tr->b->address, lo, hi); + val.h |=MASK_COUNT_EN_HI ; +wrmsr (tr->b->address, val.q); }static void threshold_restart_bank (unsigned int bank,bool intr_en)
@@ -658,12 +658,12 @@ static void disable_err_thresholding(struct cpuinfo_x86 *c, unsigned int bank)return ; } -rdmsrq (MSR_K7_HWCR , hwcr); + hwcr =rdmsr (MSR_K7_HWCR );/* McStatusWrEn has to be set */ need_toggle = !(hwcr &BIT (18 ));if (need_toggle) -wrmsrq (MSR_K7_HWCR , hwcr |BIT (18 )); +wrmsr (MSR_K7_HWCR , hwcr |BIT (18 ));/* Clear CntP bit safely */ for (i =0 ; i < num_msrs; i++)
@@ -671,7 +671,7 @@ static void disable_err_thresholding(struct cpuinfo_x86 *c, unsigned int bank)/* restore old settings */ if (need_toggle) -wrmsrq (MSR_K7_HWCR , hwcr); +wrmsr (MSR_K7_HWCR , hwcr); }static void amd_apply_cpu_quirks (struct cpuinfo_x86 *c)
@@ -710,7 +710,7 @@ static void smca_enable_interrupt_vectors(void)if (!mce_flags.smca || !mce_flags.succor)return ; -if (rdmsrq_safe (MSR_CU_DEF_ERR , &mca_intr_cfg)) +if (rdmsr_safe (MSR_CU_DEF_ERR , &mca_intr_cfg))return ; offset = (mca_intr_cfg &SMCA_THR_LVT_OFF ) >>12 ;
@@ -726,7 +726,8 @@ static void smca_enable_interrupt_vectors(void)void mce_amd_feature_init (struct cpuinfo_x86 *c) {unsigned int bank, block, cpu =smp_processor_id (); -u32 low =0 , high =0 , address =0 ; +struct msr val = { .q =0 }; +u32 address =0 ;int offset =-1 ;amd_apply_cpu_quirks (c);
@@ -746,21 +747,21 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c)disable_err_thresholding (c, bank);for (block =0 ; block <NR_BLOCKS ; ++block) { - address =get_block_address (address, low, high, bank, block, cpu); + address =get_block_address (address, val.l, val.h, bank, block, cpu);if (!address)break ; -if (rdmsr_safe (address, &low, &high)) +if (rdmsr_safe (address, &val.q))break ; -if (!(high &MASK_VALID_HI )) +if (!(val.h &MASK_VALID_HI ))continue ; -if (!(high &MASK_CNTP_HI ) || - (high &MASK_LOCKED_HI )) +if (!(val.h &MASK_CNTP_HI ) || + (val.h &MASK_LOCKED_HI ))continue ; - offset =prepare_threshold_block (bank, block, address, offset, high); + offset =prepare_threshold_block (bank, block, address, offset, val.h); } } }
@@ -1083,24 +1084,24 @@ static int allocate_threshold_blocks(unsigned int cpu, struct threshold_bank *tb u32 address) {struct threshold_block *b =NULL ; -u32 low, high; +struct msr val;int err;if ((bank >=this_cpu_read (mce_num_banks)) || (block >=NR_BLOCKS ))return 0 ; -if (rdmsr_safe (address, &low, &high)) +if (rdmsr_safe (address, &val.q))return 0 ; -if (!(high &MASK_VALID_HI )) { +if (!(val.h &MASK_VALID_HI )) {if (block) goto recurse;else return 0 ; } -if (!(high &MASK_CNTP_HI ) || - (high &MASK_LOCKED_HI )) +if (!(val.h &MASK_CNTP_HI ) || + (val.h &MASK_LOCKED_HI )) goto recurse; b = kzalloc_obj(struct threshold_block);
@@ -1112,7 +1113,7 @@ static int allocate_threshold_blocks(unsigned int cpu, struct threshold_bank *tb b->cpu = cpu; b->address = address; b->interrupt_enable =0 ; - b->interrupt_capable =lvt_interrupt_supported (bank, high); + b->interrupt_capable =lvt_interrupt_supported (bank, val.h); b->threshold_limit =get_thr_limit ();if (b->interrupt_capable) {
@@ -1124,13 +1125,13 @@ static int allocate_threshold_blocks(unsigned int cpu, struct threshold_bank *tblist_add (&b->miscj, &tb->miscj); -mce_threshold_block_init (b, (high &MASK_LVTOFF_HI ) >>20 ); +mce_threshold_block_init (b, (val.h &MASK_LVTOFF_HI ) >>20 ); err =kobject_init_and_add (&b->kobj, &threshold_ktype, tb->kobj,get_name (cpu, bank, b));if (err) goto out_free; recurse: - address =get_block_address (address, low, high, bank, ++block, cpu); + address =get_block_address (address, val.l, val.h, bank, ++block, cpu);if (!address)return 0 ;
arch/x86/kernel/cpu/mce/core.c +9 -9
@@ -1871,7 +1871,7 @@ static void __mcheck_cpu_cap_init(void)u64 cap;u8 b; -rdmsrq (MSR_IA32_MCG_CAP , cap); + cap =rdmsr (MSR_IA32_MCG_CAP ); b = cap &MCG_BANKCNT_MASK ;
@@ -1890,9 +1890,9 @@ static void __mcheck_cpu_init_generic(void) {u64 cap; -rdmsrq (MSR_IA32_MCG_CAP , cap); + cap =rdmsr (MSR_IA32_MCG_CAP );if (cap &MCG_CTL_P ) -wrmsr (MSR_IA32_MCG_CTL ,0xffffffff ,0xffffffff ); +wrmsr (MSR_IA32_MCG_CTL , ~0ULL ); }static void __mcheck_cpu_init_prepare_banks (void )
@@ -1919,10 +1919,10 @@ static void __mcheck_cpu_init_prepare_banks(void)if (!b->init)continue ; -wrmsrq (mca_msr_reg (i,MCA_CTL ), b->ctl); -wrmsrq (mca_msr_reg (i,MCA_STATUS ),0 ); +wrmsr (mca_msr_reg (i,MCA_CTL ), b->ctl); +wrmsr (mca_msr_reg (i,MCA_STATUS ),0 ); -rdmsrq (mca_msr_reg (i,MCA_CTL ), msrval); + msrval =rdmsr (mca_msr_reg (i,MCA_CTL )); b->init = !!msrval; } }
@@ -2240,7 +2240,7 @@ void mca_bsp_init(struct cpuinfo_x86 *c)if (mce_flags.smca)smca_bsp_init (); -rdmsrq (MSR_IA32_MCG_CAP , cap); + cap =rdmsr (MSR_IA32_MCG_CAP );/* Use accurate RIP reporting if available. */ if ((cap &MCG_EXT_P ) &&MCG_EXT_CNT (cap) >=9 )
@@ -2420,7 +2420,7 @@ static void mce_disable_error_reporting(void)struct mce_bank *b = &mce_banks[i];if (b->init) -wrmsrq (mca_msr_reg (i,MCA_CTL ),0 ); +wrmsr (mca_msr_reg (i,MCA_CTL ),0 ); }return ; }
@@ -2776,7 +2776,7 @@ static void mce_reenable_cpu(void)struct mce_bank *b = &mce_banks[i];if (b->init) -wrmsrq (mca_msr_reg (i,MCA_CTL ), b->ctl); +wrmsr (mca_msr_reg (i,MCA_CTL ), b->ctl); } }
arch/x86/kernel/cpu/mce/inject.c +14 -14
@@ -476,27 +476,27 @@ static void prepare_msrs(void *info)struct mce m = *(struct mce *)info;u8 b = m.bank; -wrmsrq (MSR_IA32_MCG_STATUS , m.mcgstatus); +wrmsr (MSR_IA32_MCG_STATUS , m.mcgstatus);if (boot_cpu_has (X86_FEATURE_SMCA )) {if (m.inject_flags ==DFR_INT_INJ ) { -wrmsrq (MSR_AMD64_SMCA_MCx_DESTAT (b), m.status); -wrmsrq (MSR_AMD64_SMCA_MCx_DEADDR (b), m.addr); +wrmsr (MSR_AMD64_SMCA_MCx_DESTAT (b), m.status); +wrmsr (MSR_AMD64_SMCA_MCx_DEADDR (b), m.addr); }else { -wrmsrq (MSR_AMD64_SMCA_MCx_STATUS (b), m.status); -wrmsrq (MSR_AMD64_SMCA_MCx_ADDR (b), m.addr); +wrmsr (MSR_AMD64_SMCA_MCx_STATUS (b), m.status); +wrmsr (MSR_AMD64_SMCA_MCx_ADDR (b), m.addr); } -wrmsrq (MSR_AMD64_SMCA_MCx_SYND (b), m.synd); +wrmsr (MSR_AMD64_SMCA_MCx_SYND (b), m.synd);if (m.misc) -wrmsrq (MSR_AMD64_SMCA_MCx_MISC (b), m.misc); +wrmsr (MSR_AMD64_SMCA_MCx_MISC (b), m.misc); }else { -wrmsrq (MSR_IA32_MCx_STATUS (b), m.status); -wrmsrq (MSR_IA32_MCx_ADDR (b), m.addr); +wrmsr (MSR_IA32_MCx_STATUS (b), m.status); +wrmsr (MSR_IA32_MCx_ADDR (b), m.addr);if (m.misc) -wrmsrq (MSR_IA32_MCx_MISC (b), m.misc); +wrmsr (MSR_IA32_MCx_MISC (b), m.misc); } }
@@ -742,15 +742,15 @@ static void check_hw_inj_possible(void)u64 status =MCI_STATUS_VAL , ipid;/* Check whether bank is populated */ -rdmsrq (MSR_AMD64_SMCA_MCx_IPID (bank), ipid); + ipid =rdmsr (MSR_AMD64_SMCA_MCx_IPID (bank));if (!ipid)continue ;toggle_hw_mce_inject (cpu, true); -wrmsrq_safe (mca_msr_reg (bank,MCA_STATUS ), status); -rdmsrq_safe (mca_msr_reg (bank,MCA_STATUS ), &status); -wrmsrq_safe (mca_msr_reg (bank,MCA_STATUS ),0 ); +wrmsr_safe (mca_msr_reg (bank,MCA_STATUS ), status); +rdmsr_safe (mca_msr_reg (bank,MCA_STATUS ), &status); +wrmsr_safe (mca_msr_reg (bank,MCA_STATUS ),0 );if (!status) { hw_injection_possible = false;
arch/x86/kernel/cpu/mce/intel.c +16 -16
@@ -94,7 +94,7 @@ static bool cmci_supported(int *banks)if (!boot_cpu_has (X86_FEATURE_APIC ) ||lapic_get_maxlvt () <6 )return false; -rdmsrq (MSR_IA32_MCG_CAP , cap); + cap =rdmsr (MSR_IA32_MCG_CAP ); *banks =min_t (unsigned,MAX_NR_BANKS , cap &MCG_BANKCNT_MASK );return !!(cap &MCG_CMCI_P ); }
@@ -106,7 +106,7 @@ static bool lmce_supported(void)if (mca_cfg.lmce_disabled)return false; -rdmsrq (MSR_IA32_MCG_CAP , tmp); + tmp =rdmsr (MSR_IA32_MCG_CAP );/* * LMCE depends on recovery support in the processor. Hence both
@@ -123,7 +123,7 @@ static bool lmce_supported(void)* WARN if the MSR isn't locked as init_ia32_feat_ctl() unconditionally * locks the MSR in the event that it wasn't already locked by BIOS. */ -rdmsrq (MSR_IA32_FEAT_CTL , tmp); + tmp =rdmsr (MSR_IA32_FEAT_CTL );if (WARN_ON_ONCE (!(tmp &FEAT_CTL_LOCKED )))return false;
@@ -141,9 +141,9 @@ static void cmci_set_threshold(int bank, int thresh)u64 val;raw_spin_lock_irqsave (&cmci_discover_lock, flags); -rdmsrq (MSR_IA32_MCx_CTL2 (bank), val); + val =rdmsr (MSR_IA32_MCx_CTL2 (bank)); val &= ~MCI_CTL2_CMCI_THRESHOLD_MASK ; -wrmsrq (MSR_IA32_MCx_CTL2 (bank), val | thresh); +wrmsr (MSR_IA32_MCx_CTL2 (bank), val | thresh);raw_spin_unlock_irqrestore (&cmci_discover_lock, flags); }
@@ -184,7 +184,7 @@ static bool cmci_skip_bank(int bank, u64 *val)if (test_bit (bank, mce_banks_ce_disabled))return true; -rdmsrq (MSR_IA32_MCx_CTL2 (bank), *val); + *val =rdmsr (MSR_IA32_MCx_CTL2 (bank));/* Already owned by someone else? */ if (*val &MCI_CTL2_CMCI_EN ) {
@@ -232,8 +232,8 @@ static void cmci_claim_bank(int bank, u64 val, int bios_zero_thresh, int *bios_wstruct mca_storm_desc *storm =this_cpu_ptr (&storm_desc); val |=MCI_CTL2_CMCI_EN ; -wrmsrq (MSR_IA32_MCx_CTL2 (bank), val); -rdmsrq (MSR_IA32_MCx_CTL2 (bank), val); +wrmsr (MSR_IA32_MCx_CTL2 (bank), val); + val =rdmsr (MSR_IA32_MCx_CTL2 (bank));/* If the enable bit did not stick, this bank should be polled. */ if (!(val &MCI_CTL2_CMCI_EN )) {
@@ -324,9 +324,9 @@ static void __cmci_disable_bank(int bank)if (!test_bit (bank,this_cpu_ptr (mce_banks_owned)))return ; -rdmsrq (MSR_IA32_MCx_CTL2 (bank), val); + val =rdmsr (MSR_IA32_MCx_CTL2 (bank)); val &= ~MCI_CTL2_CMCI_EN ; -wrmsrq (MSR_IA32_MCx_CTL2 (bank), val); +wrmsr (MSR_IA32_MCx_CTL2 (bank), val);__clear_bit (bank,this_cpu_ptr (mce_banks_owned));if ((val &MCI_CTL2_CMCI_THRESHOLD_MASK ) ==CMCI_STORM_THRESHOLD )
@@ -430,10 +430,10 @@ void intel_init_lmce(void)if (!lmce_supported ())return ; -rdmsrq (MSR_IA32_MCG_EXT_CTL , val); + val =rdmsr (MSR_IA32_MCG_EXT_CTL );if (!(val &MCG_EXT_CTL_LMCE_EN )) -wrmsrq (MSR_IA32_MCG_EXT_CTL , val |MCG_EXT_CTL_LMCE_EN ); +wrmsr (MSR_IA32_MCG_EXT_CTL , val |MCG_EXT_CTL_LMCE_EN ); }void intel_clear_lmce (void )
@@ -443,9 +443,9 @@ void intel_clear_lmce(void)if (!lmce_supported ())return ; -rdmsrq (MSR_IA32_MCG_EXT_CTL , val); + val =rdmsr (MSR_IA32_MCG_EXT_CTL ); val &= ~MCG_EXT_CTL_LMCE_EN ; -wrmsrq (MSR_IA32_MCG_EXT_CTL , val); +wrmsr (MSR_IA32_MCG_EXT_CTL , val); }/*
@@ -460,10 +460,10 @@ static void intel_imc_init(struct cpuinfo_x86 *c)case INTEL_SANDYBRIDGE_X :case INTEL_IVYBRIDGE_X :case INTEL_HASWELL_X : -if (rdmsrq_safe (MSR_ERROR_CONTROL , &error_control)) +if (rdmsr_safe (MSR_ERROR_CONTROL , &error_control))return ; error_control |=2 ; -wrmsrq_safe (MSR_ERROR_CONTROL , error_control); +wrmsr_safe (MSR_ERROR_CONTROL , error_control);break ; } }
arch/x86/kernel/cpu/mce/p5.c +8 -8
@@ -23,16 +23,16 @@ int mce_p5_enabled __read_mostly;/* Machine check handler for Pentium class Intel CPUs: */ noinstr void pentium_machine_check(struct pt_regs *regs) { -u32 loaddr, hi, lotype; +struct msr addr, type;instrumentation_begin (); -rdmsr (MSR_IA32_P5_MC_ADDR , loaddr, hi); -rdmsr (MSR_IA32_P5_MC_TYPE , lotype, hi); + addr.q =rdmsr (MSR_IA32_P5_MC_ADDR ); + type.q =rdmsr (MSR_IA32_P5_MC_TYPE );pr_emerg ("CPU#%d: Machine Check Exception: 0x%8X (type 0x%8X).\n" , -smp_processor_id (), loaddr, lotype); +smp_processor_id (), addr.l, type.l); -if (lotype & (1 <<5 )) { +if (type.l & (1 <<5 )) {pr_emerg ("CPU#%d: Possible thermal failure (CPU on fire ?).\n" ,smp_processor_id ()); }
@@ -44,7 +44,7 @@ noinstr void pentium_machine_check(struct pt_regs *regs)/* Set up machine check reporting for processors with Intel style MCE: */ void intel_p5_mcheck_init (struct cpuinfo_x86 *c) { -u32 l, h; +u64 val;/* Default P5 to off as its often misconnected: */ if (!mce_p5_enabled)
@@ -55,8 +55,8 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)return ;/* Read registers before enabling: */ -rdmsr (MSR_IA32_P5_MC_ADDR , l, h); -rdmsr (MSR_IA32_P5_MC_TYPE , l, h); + val =rdmsr (MSR_IA32_P5_MC_ADDR ); + val =rdmsr (MSR_IA32_P5_MC_TYPE );pr_info ("Intel old style machine check architecture supported.\n" );/* Enable MCE: */
arch/x86/kernel/cpu/mce/winchip.c +5 -5
@@ -28,12 +28,12 @@ noinstr void winchip_machine_check(struct pt_regs *regs)/* Set up machine check reporting on the Winchip C6 series */ void winchip_mcheck_init (struct cpuinfo_x86 *c) { -u32 lo, hi; +struct msr val; -rdmsr (MSR_IDT_FCR1 , lo, hi); - lo |= (1 <<2 );/* Enable EIERRINT (int 18 MCE) */ - lo &= ~(1 <<4 );/* Enable MCE */ -wrmsr (MSR_IDT_FCR1 , lo, hi); + val.q =rdmsr (MSR_IDT_FCR1 ); + val.l |= (1 <<2 );/* Enable EIERRINT (int 18 MCE) */ + val.l &= ~(1 <<4 );/* Enable MCE */ +wrmsr (MSR_IDT_FCR1 , val.q);cr4_set_bits (X86_CR4_MCE );
Signature · 1 line
2.53.0