x86, msr: Unify rdmsr_on_cpus/wrmsr_on_cpus
Since rdmsr_on_cpus and wrmsr_on_cpus are almost identical, unify them into a common __rwmsr_on_cpus helper thus avoiding code duplication. While at it, convert cpumask_t's to const struct cpumask *. Signed-off-by: Borislav Petkov <borislav.petkov@amd.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
Родитель
0cc6d77e55
Коммит
b8a4754147
|
@ -247,8 +247,8 @@ do { \
|
|||
#ifdef CONFIG_SMP
|
||||
int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
|
||||
int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
|
||||
void rdmsr_on_cpus(const cpumask_t *mask, u32 msr_no, struct msr *msrs);
|
||||
void wrmsr_on_cpus(const cpumask_t *mask, u32 msr_no, struct msr *msrs);
|
||||
void rdmsr_on_cpus(const struct cpumask *mask, u32 msr_no, struct msr *msrs);
|
||||
void wrmsr_on_cpus(const struct cpumask *mask, u32 msr_no, struct msr *msrs);
|
||||
int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
|
||||
int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
|
||||
int rdmsr_safe_regs_on_cpu(unsigned int cpu, u32 regs[8]);
|
||||
|
|
|
@ -71,14 +71,9 @@ int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
|
|||
}
|
||||
EXPORT_SYMBOL(wrmsr_on_cpu);
|
||||
|
||||
/* rdmsr on a bunch of CPUs
|
||||
*
|
||||
* @mask: which CPUs
|
||||
* @msr_no: which MSR
|
||||
* @msrs: array of MSR values
|
||||
*
|
||||
*/
|
||||
void rdmsr_on_cpus(const cpumask_t *mask, u32 msr_no, struct msr *msrs)
|
||||
static void __rwmsr_on_cpus(const struct cpumask *mask, u32 msr_no,
|
||||
struct msr *msrs,
|
||||
void (*msr_func) (void *info))
|
||||
{
|
||||
struct msr_info rv;
|
||||
int this_cpu;
|
||||
|
@ -92,11 +87,23 @@ void rdmsr_on_cpus(const cpumask_t *mask, u32 msr_no, struct msr *msrs)
|
|||
this_cpu = get_cpu();
|
||||
|
||||
if (cpumask_test_cpu(this_cpu, mask))
|
||||
__rdmsr_on_cpu(&rv);
|
||||
msr_func(&rv);
|
||||
|
||||
smp_call_function_many(mask, __rdmsr_on_cpu, &rv, 1);
|
||||
smp_call_function_many(mask, msr_func, &rv, 1);
|
||||
put_cpu();
|
||||
}
|
||||
|
||||
/* rdmsr on a bunch of CPUs
|
||||
*
|
||||
* @mask: which CPUs
|
||||
* @msr_no: which MSR
|
||||
* @msrs: array of MSR values
|
||||
*
|
||||
*/
|
||||
void rdmsr_on_cpus(const struct cpumask *mask, u32 msr_no, struct msr *msrs)
|
||||
{
|
||||
__rwmsr_on_cpus(mask, msr_no, msrs, __rdmsr_on_cpu);
|
||||
}
|
||||
EXPORT_SYMBOL(rdmsr_on_cpus);
|
||||
|
||||
/*
|
||||
|
@ -107,24 +114,9 @@ EXPORT_SYMBOL(rdmsr_on_cpus);
|
|||
* @msrs: array of MSR values
|
||||
*
|
||||
*/
|
||||
void wrmsr_on_cpus(const cpumask_t *mask, u32 msr_no, struct msr *msrs)
|
||||
void wrmsr_on_cpus(const struct cpumask *mask, u32 msr_no, struct msr *msrs)
|
||||
{
|
||||
struct msr_info rv;
|
||||
int this_cpu;
|
||||
|
||||
memset(&rv, 0, sizeof(rv));
|
||||
|
||||
rv.off = cpumask_first(mask);
|
||||
rv.msrs = msrs;
|
||||
rv.msr_no = msr_no;
|
||||
|
||||
this_cpu = get_cpu();
|
||||
|
||||
if (cpumask_test_cpu(this_cpu, mask))
|
||||
__wrmsr_on_cpu(&rv);
|
||||
|
||||
smp_call_function_many(mask, __wrmsr_on_cpu, &rv, 1);
|
||||
put_cpu();
|
||||
__rwmsr_on_cpus(mask, msr_no, msrs, __wrmsr_on_cpu);
|
||||
}
|
||||
EXPORT_SYMBOL(wrmsr_on_cpus);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче