Skip to content

Commit

Permalink
x86, AMD: Correct {rd,wr}msr_amd_safe warnings
Browse files Browse the repository at this point in the history
The idea with those routines is to slowly phase them out and not call
them on anything else besides K8. They even have a check for that which,
when called too early, fails. Let me explain:

It gets the cpuinfo_x86 pointer from the per_cpu array and when this
happens for cpu0, before its boot_cpu_data has been copied back to the
per_cpu array in smp_store_boot_cpu_info(), we get an empty struct and
thus the check fails.

Use boot_cpu_data directly instead.

Signed-off-by: Borislav Petkov <bp@suse.de>
Link: http://lkml.kernel.org/r/1365436666-9837-4-git-send-email-bp@alien8.de
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
  • Loading branch information
Borislav Petkov committed Apr 16, 2013
1 parent 55a36b6 commit 682469a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions arch/x86/kernel/cpu/amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

static inline int rdmsrl_amd_safe(unsigned msr, unsigned long long *p)
{
struct cpuinfo_x86 *c = &cpu_data(smp_processor_id());
u32 gprs[8] = { 0 };
int err;

WARN_ONCE((c->x86 != 0xf), "%s should only be used on K8!\n", __func__);
WARN_ONCE((boot_cpu_data.x86 != 0xf),
"%s should only be used on K8!\n", __func__);

gprs[1] = msr;
gprs[7] = 0x9c5a203a;
Expand All @@ -38,10 +38,10 @@ static inline int rdmsrl_amd_safe(unsigned msr, unsigned long long *p)

static inline int wrmsrl_amd_safe(unsigned msr, unsigned long long val)
{
struct cpuinfo_x86 *c = &cpu_data(smp_processor_id());
u32 gprs[8] = { 0 };

WARN_ONCE((c->x86 != 0xf), "%s should only be used on K8!\n", __func__);
WARN_ONCE((boot_cpu_data.x86 != 0xf),
"%s should only be used on K8!\n", __func__);

gprs[0] = (u32)val;
gprs[1] = msr;
Expand Down

0 comments on commit 682469a

Please sign in to comment.