[V4,14/30] x86/microcode/amd: Read revision from hardware in collect_cpu_info_amd()

Message ID 20231002115902.854919221@linutronix.de
State New
Headers
Series x86/microcode: Cleanup and late loading enhancements |

Commit Message

Thomas Gleixner Oct. 2, 2023, 11:59 a.m. UTC
  Prepare to decrapify the core initialization logic which invokes
microcode_ops::apply_microcode() several times just to set
cpu_data::microcode.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
V2: New patch
---
 arch/x86/kernel/cpu/microcode/amd.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Borislav Petkov Oct. 4, 2023, 8:32 a.m. UTC | #1
On Mon, Oct 02, 2023 at 01:59:51PM +0200, Thomas Gleixner wrote:
> Prepare to decrapify the core initialization logic which invokes
> microcode_ops::apply_microcode() several times just to set
> cpu_data::microcode.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
> V2: New patch
> ---
>  arch/x86/kernel/cpu/microcode/amd.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> --- a/arch/x86/kernel/cpu/microcode/amd.c
> +++ b/arch/x86/kernel/cpu/microcode/amd.c
> @@ -634,12 +634,12 @@ void reload_ucode_amd(unsigned int cpu)
>  
>  static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig)
>  {
> -	struct cpuinfo_x86 *c = &cpu_data(cpu);
>  	struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
> +	u32 dummy __always_unused;
>  	struct ucode_patch *p;
>  
>  	csig->sig = cpuid_eax(0x00000001);
> -	csig->rev = c->microcode;
> +	rdmsr(MSR_AMD64_PATCH_LEVEL, csig->rev, dummy);
>  
>  	/*
> * a patch could have been loaded early, set uci->mc so that

Skipping that one as the rev needs to be read on the respective CPU for
mixed silicon steppings on AMD.
  

Patch

--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -634,12 +634,12 @@  void reload_ucode_amd(unsigned int cpu)
 
 static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig)
 {
-	struct cpuinfo_x86 *c = &cpu_data(cpu);
 	struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
+	u32 dummy __always_unused;
 	struct ucode_patch *p;
 
 	csig->sig = cpuid_eax(0x00000001);
-	csig->rev = c->microcode;
+	rdmsr(MSR_AMD64_PATCH_LEVEL, csig->rev, dummy);
 
 	/*
 	 * a patch could have been loaded early, set uci->mc so that