x86: msr: propagate errors from smp_call_function_single()
Propagate error (-ENXIO) from smp_call_function_single(). These errors can happen when a CPU is unplugged while the MSR driver is open. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
parent
f73be6dedf
commit
c6f31932d0
@ -79,8 +79,11 @@ static ssize_t msr_read(struct file *file, char __user *buf,
|
|||||||
|
|
||||||
for (; count; count -= 8) {
|
for (; count; count -= 8) {
|
||||||
err = rdmsr_safe_on_cpu(cpu, reg, &data[0], &data[1]);
|
err = rdmsr_safe_on_cpu(cpu, reg, &data[0], &data[1]);
|
||||||
if (err)
|
if (err) {
|
||||||
return -EIO;
|
if (err == -EFAULT) /* Fix idiotic error code */
|
||||||
|
err = -EIO;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
if (copy_to_user(tmp, &data, 8))
|
if (copy_to_user(tmp, &data, 8))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
tmp += 2;
|
tmp += 2;
|
||||||
@ -105,8 +108,11 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
|
|||||||
if (copy_from_user(&data, tmp, 8))
|
if (copy_from_user(&data, tmp, 8))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
err = wrmsr_safe_on_cpu(cpu, reg, data[0], data[1]);
|
err = wrmsr_safe_on_cpu(cpu, reg, data[0], data[1]);
|
||||||
if (err)
|
if (err) {
|
||||||
return -EIO;
|
if (err == -EFAULT) /* Fix idiotic error code */
|
||||||
|
err = -EIO;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
tmp += 2;
|
tmp += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,10 +30,11 @@ static int _rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h, int safe)
|
|||||||
|
|
||||||
rv.msr_no = msr_no;
|
rv.msr_no = msr_no;
|
||||||
if (safe) {
|
if (safe) {
|
||||||
smp_call_function_single(cpu, __rdmsr_safe_on_cpu, &rv, 1);
|
err = smp_call_function_single(cpu, __rdmsr_safe_on_cpu,
|
||||||
err = rv.err;
|
&rv, 1);
|
||||||
|
err = err ? err : rv.err;
|
||||||
} else {
|
} else {
|
||||||
smp_call_function_single(cpu, __rdmsr_on_cpu, &rv, 1);
|
err = smp_call_function_single(cpu, __rdmsr_on_cpu, &rv, 1);
|
||||||
}
|
}
|
||||||
*l = rv.l;
|
*l = rv.l;
|
||||||
*h = rv.h;
|
*h = rv.h;
|
||||||
@ -64,23 +65,24 @@ static int _wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h, int safe)
|
|||||||
rv.l = l;
|
rv.l = l;
|
||||||
rv.h = h;
|
rv.h = h;
|
||||||
if (safe) {
|
if (safe) {
|
||||||
smp_call_function_single(cpu, __wrmsr_safe_on_cpu, &rv, 1);
|
err = smp_call_function_single(cpu, __wrmsr_safe_on_cpu,
|
||||||
err = rv.err;
|
&rv, 1);
|
||||||
|
err = err ? err : rv.err;
|
||||||
} else {
|
} else {
|
||||||
smp_call_function_single(cpu, __wrmsr_on_cpu, &rv, 1);
|
err = smp_call_function_single(cpu, __wrmsr_on_cpu, &rv, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wrmsr_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)
|
||||||
{
|
{
|
||||||
_wrmsr_on_cpu(cpu, msr_no, l, h, 0);
|
return _wrmsr_on_cpu(cpu, msr_no, l, h, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
|
int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
|
||||||
{
|
{
|
||||||
_rdmsr_on_cpu(cpu, msr_no, l, h, 0);
|
return _rdmsr_on_cpu(cpu, msr_no, l, h, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* These "safe" variants are slower and should be used when the target MSR
|
/* These "safe" variants are slower and should be used when the target MSR
|
||||||
|
@ -192,19 +192,20 @@ do { \
|
|||||||
#define write_rdtscp_aux(val) wrmsr(0xc0000103, (val), 0)
|
#define write_rdtscp_aux(val) wrmsr(0xc0000103, (val), 0)
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
|
int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
|
||||||
void wrmsr_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);
|
||||||
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, u32 *l, u32 *h);
|
||||||
|
|
||||||
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, u32 l, u32 h);
|
||||||
#else /* CONFIG_SMP */
|
#else /* CONFIG_SMP */
|
||||||
static inline void 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, u32 *l, u32 *h)
|
||||||
{
|
{
|
||||||
rdmsr(msr_no, *l, *h);
|
rdmsr(msr_no, *l, *h);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
static inline void 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, u32 l, u32 h)
|
||||||
{
|
{
|
||||||
wrmsr(msr_no, l, h);
|
wrmsr(msr_no, l, h);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no,
|
static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no,
|
||||||
u32 *l, u32 *h)
|
u32 *l, u32 *h)
|
||||||
|
Loading…
Reference in New Issue
Block a user