[tip:x86/urgent] x86/microcode/AMD: Use native_cpuid() in load_ucode_amd_bsp()

From: tip-bot for Boris Ostrovsky
Date: Mon Dec 19 2016 - 04:57:10 EST


Commit-ID: 2b4c91569a40c4512ea1b413e0c817d179ce9868
Gitweb: http://git.kernel.org/tip/2b4c91569a40c4512ea1b413e0c817d179ce9868
Author: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
AuthorDate: Sun, 18 Dec 2016 17:44:14 +0100
Committer: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
CommitDate: Mon, 19 Dec 2016 10:46:20 +0100

x86/microcode/AMD: Use native_cpuid() in load_ucode_amd_bsp()

When CONFIG_PARAVIRT is selected, cpuid() becomes a call. Since
for 32-bit kernels load_ucode_amd_bsp() is executed before paging
is enabled the call cannot be completed (as kernel virtual addresses
are not reachable yet).

Use native_cpuid() instead which is an asm wrapper for the CPUID
instruction.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
Signed-off-by: Borislav Petkov <bp@xxxxxxx>
Cc: JÃrgen Gross <jgross@xxxxxxxx>
Link: http://lkml.kernel.org/r/1481906392-3847-1-git-send-email-boris.ostrovsky@xxxxxxxxxx
Link: http://lkml.kernel.org/r/20161218164414.9649-5-bp@xxxxxxxxx
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>

---
arch/x86/kernel/cpu/microcode/amd.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index dc80acf..6a31e26 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -301,6 +301,7 @@ static bool get_builtin_microcode(struct cpio_data *cp, unsigned int family)
void __init load_ucode_amd_bsp(unsigned int family)
{
struct ucode_cpu_info *uci;
+ u32 eax, ebx, ecx, edx;
struct cpio_data cp;
const char *path;
bool use_pa;
@@ -322,7 +323,10 @@ void __init load_ucode_amd_bsp(unsigned int family)
return;

/* Get BSP's CPUID.EAX(1), needed in load_microcode_amd() */
- uci->cpu_sig.sig = cpuid_eax(1);
+ eax = 1;
+ ecx = 0;
+ native_cpuid(&eax, &ebx, &ecx, &edx);
+ uci->cpu_sig.sig = eax;

apply_microcode_early_amd(cp.data, cp.size, true, NULL);
}