All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/microcode: Use native_cpuid() in load_ucode_amd_bsp()
@ 2016-12-16 16:39 Boris Ostrovsky
  2016-12-16 16:37 ` Borislav Petkov
  2016-12-16 16:37 ` Borislav Petkov
  0 siblings, 2 replies; 13+ messages in thread
From: Boris Ostrovsky @ 2016-12-16 16:39 UTC (permalink / raw)
  To: bp; +Cc: x86, linux-kernel, jgross, xen-devel, Boris Ostrovsky

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 CPUID instruction.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
 arch/x86/kernel/cpu/microcode/amd.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 6f353bd..e2d941f 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -297,6 +297,7 @@ void __init load_ucode_amd_bsp(unsigned int family)
 	struct cpio_data cp;
 	const char *path;
 	bool use_pa;
+	u32 eax, ebx, ecx, edx;
 
 	if (IS_ENABLED(CONFIG_X86_32)) {
 		uci	= (struct ucode_cpu_info *)__pa_nodebug(ucode_cpu_info);
@@ -315,7 +316,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 = 0x00000001;
+	ecx = 0;
+	native_cpuid(&eax, &ebx, &ecx, &edx);
+	uci->cpu_sig.sig = eax;
 
 	apply_microcode_early_amd(cp.data, cp.size, true);
 }
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread
* [PATCH] x86/microcode: Use native_cpuid() in load_ucode_amd_bsp()
@ 2016-12-16 16:39 Boris Ostrovsky
  0 siblings, 0 replies; 13+ messages in thread
From: Boris Ostrovsky @ 2016-12-16 16:39 UTC (permalink / raw)
  To: bp; +Cc: jgross, xen-devel, Boris Ostrovsky, x86, linux-kernel

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 CPUID instruction.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
 arch/x86/kernel/cpu/microcode/amd.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 6f353bd..e2d941f 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -297,6 +297,7 @@ void __init load_ucode_amd_bsp(unsigned int family)
 	struct cpio_data cp;
 	const char *path;
 	bool use_pa;
+	u32 eax, ebx, ecx, edx;
 
 	if (IS_ENABLED(CONFIG_X86_32)) {
 		uci	= (struct ucode_cpu_info *)__pa_nodebug(ucode_cpu_info);
@@ -315,7 +316,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 = 0x00000001;
+	ecx = 0;
+	native_cpuid(&eax, &ebx, &ecx, &edx);
+	uci->cpu_sig.sig = eax;
 
 	apply_microcode_early_amd(cp.data, cp.size, true);
 }
-- 
1.7.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 13+ messages in thread
* [PATCH 0/4] x86/microcode: Some 4.10 fixes
@ 2016-12-18 16:44 Borislav Petkov
  2016-12-18 16:44 ` [PATCH 1/4] x86/microcode/AMD: Make find_proper_container() sane again Borislav Petkov
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Borislav Petkov @ 2016-12-18 16:44 UTC (permalink / raw)
  To: X86 ML; +Cc: Boris Ostrovsky, Jürgen Gross, LKML

From: Borislav Petkov <bp@suse.de>

Hi,

here are 4 fixes for tip/urgent which address issues Boris and Jürgen
reported while testing latest upstream on xen.

As a result, let's just not load it at all when running on a hypervisor
and be done with the d*icking around.

Please apply,
thanks.

Boris Ostrovsky (1):
  x86/microcode/AMD: Use native_cpuid() in load_ucode_amd_bsp()

Borislav Petkov (3):
  x86/microcode/AMD: Make find_proper_container() sane again
  x86/microcode/AMD: Sanitize apply_microcode_early_amd()
  x86/microcode/AMD: Do not load when running on a hypervisor

 arch/x86/kernel/cpu/microcode/amd.c  | 56 +++++++++++++++++++++---------------
 arch/x86/kernel/cpu/microcode/core.c | 28 ++++++++++++------
 2 files changed, 52 insertions(+), 32 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-12-19  9:57 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-16 16:39 [PATCH] x86/microcode: Use native_cpuid() in load_ucode_amd_bsp() Boris Ostrovsky
2016-12-16 16:37 ` Borislav Petkov
2016-12-16 16:37 ` Borislav Petkov
2016-12-16 16:39 Boris Ostrovsky
2016-12-18 16:44 [PATCH 0/4] x86/microcode: Some 4.10 fixes Borislav Petkov
2016-12-18 16:44 ` [PATCH 1/4] x86/microcode/AMD: Make find_proper_container() sane again Borislav Petkov
2016-12-19  9:55   ` [tip:x86/urgent] " tip-bot for Borislav Petkov
2016-12-18 16:44 ` [PATCH 2/4] x86/microcode/AMD: Sanitize apply_microcode_early_amd() Borislav Petkov
2016-12-19  9:55   ` [tip:x86/urgent] " tip-bot for Borislav Petkov
2016-12-18 16:44 ` [PATCH 3/4] x86/microcode/AMD: Do not load when running on a hypervisor Borislav Petkov
2016-12-19  9:56   ` [tip:x86/urgent] " tip-bot for Borislav Petkov
2016-12-18 16:44 ` [PATCH 4/4] x86/microcode/AMD: Use native_cpuid() in load_ucode_amd_bsp() Borislav Petkov
2016-12-19  9:56   ` [tip:x86/urgent] " tip-bot for Boris Ostrovsky

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.