Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1543572 > unrolled thread

[PATCH] x86/microcode: Use native_cpuid() in load_ucode_amd_bsp()

Started byBoris Ostrovsky <boris.ostrovsky@oracle.com>
First post2016-12-16 17:30 +0100
Last post2016-12-16 17:40 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] x86/microcode: Use native_cpuid() in load_ucode_amd_bsp() Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2016-12-16 17:30 +0100
    Re: [PATCH] x86/microcode: Use native_cpuid() in load_ucode_amd_bsp() Borislav Petkov <bp@alien8.de> - 2016-12-16 17:40 +0100

#1543572 — [PATCH] x86/microcode: Use native_cpuid() in load_ucode_amd_bsp()

FromBoris Ostrovsky <boris.ostrovsky@oracle.com>
Date2016-12-16 17:30 +0100
Subject[PATCH] x86/microcode: Use native_cpuid() in load_ucode_amd_bsp()
Message-ID<sP3yq-61M-29@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1543575

FromBorislav Petkov <bp@alien8.de>
Date2016-12-16 17:40 +0100
Message-ID<sP3I5-65D-3@gated-at.bofh.it>
In reply to#1543572
On Fri, Dec 16, 2016 at 11:39:52AM -0500, Boris Ostrovsky wrote:
> 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);
>  }
> -- 

Applied, thanks.

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web