Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 158695
b: refs/heads/master
c: 8b956bf
h: refs/heads/master
i:
  158693: 621c15c
  158691: e3aae86
  158687: fa91f25
v: v3
  • Loading branch information
H. Peter Anvin committed Aug 31, 2009
1 parent 99d1b63 commit 78947e0
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0cc0213e73af5963eca259c84876937c20689dbd
refs/heads/master: 8b956bf1f0f2b552ed93cf6cafe823edff298b3b
18 changes: 14 additions & 4 deletions trunk/arch/x86/include/asm/msr.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ notrace static inline int native_write_msr_safe(unsigned int msr,

extern unsigned long long native_read_tsc(void);

extern int native_rdmsr_safe_regs(u32 *regs);
extern int native_wrmsr_safe_regs(u32 *regs);
extern int native_rdmsr_safe_regs(u32 regs[8]);
extern int native_wrmsr_safe_regs(u32 regs[8]);

static __always_inline unsigned long long __native_read_tsc(void)
{
Expand Down Expand Up @@ -196,12 +196,12 @@ static inline int wrmsrl_amd_safe(unsigned msr, unsigned long long val)
return native_wrmsr_safe_regs(gprs);
}

static inline int rdmsr_safe_regs(u32 *regs)
static inline int rdmsr_safe_regs(u32 regs[8])
{
return native_rdmsr_safe_regs(regs);
}

static inline int wrmsr_safe_regs(u32 *regs)
static inline int wrmsr_safe_regs(u32 regs[8])
{
return native_wrmsr_safe_regs(regs);
}
Expand Down Expand Up @@ -245,6 +245,8 @@ 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);
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]);
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)
{
Expand Down Expand Up @@ -275,6 +277,14 @@ 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 rdmsr_safe_regs_on_cpu(unsigned int cpu, u32 regs[8])
{
return rdmsr_safe_regs(regs);
}
static inline int wrmsr_safe_regs_on_cpu(unsigned int cpu, u32 regs[8])
{
return wrmsr_safe_regs(regs);
}
#endif /* CONFIG_SMP */
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
Expand Down
49 changes: 49 additions & 0 deletions trunk/arch/x86/lib/msr.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,52 @@ int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
return err ? err : rv.err;
}
EXPORT_SYMBOL(wrmsr_safe_on_cpu);

/*
* These variants are significantly slower, but allows control over
* the entire 32-bit GPR set.
*/
struct msr_regs_info {
u32 *regs;
int err;
};

static void __rdmsr_safe_regs_on_cpu(void *info)
{
struct msr_regs_info *rv = info;

rv->err = rdmsr_safe_regs(rv->regs);
}

static void __wrmsr_safe_regs_on_cpu(void *info)
{
struct msr_regs_info *rv = info;

rv->err = wrmsr_safe_regs(rv->regs);
}

int rdmsr_safe_regs_on_cpu(unsigned int cpu, u32 *regs)
{
int err;
struct msr_regs_info rv;

rv.regs = regs;
rv.err = -EIO;
err = smp_call_function_single(cpu, __rdmsr_safe_regs_on_cpu, &rv, 1);

return err ? err : rv.err;
}
EXPORT_SYMBOL(rdmsr_safe_regs_on_cpu);

int wrmsr_safe_regs_on_cpu(unsigned int cpu, u32 *regs)
{
int err;
struct msr_regs_info rv;

rv.regs = regs;
rv.err = -EIO;
err = smp_call_function_single(cpu, __wrmsr_safe_regs_on_cpu, &rv, 1);

return err ? err : rv.err;
}
EXPORT_SYMBOL(wrmsr_safe_regs_on_cpu);

0 comments on commit 78947e0

Please sign in to comment.