ia64/xen-unstable

changeset 19072:9f9ba1a7cc92

x86 ucode: add S3 microcode update

When wakeup from S3, use per cpu microcode image to update cpu
microcode.

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jan 22 11:17:48 2009 +0000 (2009-01-22)
parents adc3775bb6d8
children d52921c18c3d
files xen/arch/x86/acpi/power.c xen/arch/x86/microcode.c xen/arch/x86/microcode_amd.c xen/arch/x86/microcode_intel.c xen/arch/x86/smpboot.c xen/include/asm-x86/microcode.h xen/include/asm-x86/processor.h
line diff
     1.1 --- a/xen/arch/x86/acpi/power.c	Thu Jan 22 11:11:39 2009 +0000
     1.2 +++ b/xen/arch/x86/acpi/power.c	Thu Jan 22 11:17:48 2009 +0000
     1.3 @@ -221,6 +221,7 @@ static int enter_state(u32 state)
     1.4  
     1.5   enable_cpu:
     1.6      cpufreq_add_cpu(0);
     1.7 +    microcode_resume_cpu(0);
     1.8      enable_nonboot_cpus();
     1.9      thaw_domains();
    1.10      spin_unlock(&pm_lock);
     2.1 --- a/xen/arch/x86/microcode.c	Thu Jan 22 11:11:39 2009 +0000
     2.2 +++ b/xen/arch/x86/microcode.c	Thu Jan 22 11:17:48 2009 +0000
     2.3 @@ -86,14 +86,15 @@ int microcode_resume_cpu(int cpu)
     2.4          return err;
     2.5      }
     2.6  
     2.7 -    if ( memcmp(&nsig, &uci->cpu_sig, sizeof(nsig)) )
     2.8 +    if ( microcode_ops->microcode_resume_match(cpu, &nsig) )
     2.9 +    {
    2.10 +        return microcode_ops->apply_microcode(cpu);
    2.11 +    }
    2.12 +    else
    2.13      {
    2.14          microcode_fini_cpu(cpu);
    2.15 -        /* Should we look for a new ucode here? */
    2.16          return -EIO;
    2.17      }
    2.18 -
    2.19 -    return microcode_ops->apply_microcode(cpu);
    2.20  }
    2.21  
    2.22  static int microcode_update_cpu(const void *buf, size_t size)
     3.1 --- a/xen/arch/x86/microcode_amd.c	Thu Jan 22 11:11:39 2009 +0000
     3.2 +++ b/xen/arch/x86/microcode_amd.c	Thu Jan 22 11:17:48 2009 +0000
     3.3 @@ -318,7 +318,13 @@ out:
     3.4      return error;
     3.5  }
     3.6  
     3.7 +static int microcode_resume_match(int cpu, struct cpu_signature *nsig)
     3.8 +{
     3.9 +    return 0;
    3.10 +}
    3.11 +
    3.12  static struct microcode_ops microcode_amd_ops = {
    3.13 +    .microcode_resume_match           = microcode_resume_match,
    3.14      .cpu_request_microcode            = cpu_request_microcode,
    3.15      .collect_cpu_info                 = collect_cpu_info,
    3.16      .apply_microcode                  = apply_microcode,
     4.1 --- a/xen/arch/x86/microcode_intel.c	Thu Jan 22 11:11:39 2009 +0000
     4.2 +++ b/xen/arch/x86/microcode_intel.c	Thu Jan 22 11:17:48 2009 +0000
     4.3 @@ -360,7 +360,16 @@ static int cpu_request_microcode(int cpu
     4.4      return error;
     4.5  }
     4.6  
     4.7 +static int microcode_resume_match(int cpu, struct cpu_signature *nsig)
     4.8 +{
     4.9 +    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
    4.10 +
    4.11 +    return (sigmatch(nsig->sig, uci->cpu_sig.sig, nsig->pf, uci->cpu_sig.pf) &&
    4.12 +            (uci->cpu_sig.rev > nsig->rev));
    4.13 +}
    4.14 +
    4.15  static struct microcode_ops microcode_intel_ops = {
    4.16 +    .microcode_resume_match           = microcode_resume_match,
    4.17      .cpu_request_microcode            = cpu_request_microcode,
    4.18      .collect_cpu_info                 = collect_cpu_info,
    4.19      .apply_microcode                  = apply_microcode,
     5.1 --- a/xen/arch/x86/smpboot.c	Thu Jan 22 11:11:39 2009 +0000
     5.2 +++ b/xen/arch/x86/smpboot.c	Thu Jan 22 11:17:48 2009 +0000
     5.3 @@ -525,6 +525,8 @@ void __devinit start_secondary(void *unu
     5.4  	/* We can take interrupts now: we're officially "up". */
     5.5  	local_irq_enable();
     5.6  
     5.7 +	microcode_resume_cpu(cpu);
     5.8 +
     5.9  	wmb();
    5.10  	startup_cpu_idle_loop();
    5.11  }
     6.1 --- a/xen/include/asm-x86/microcode.h	Thu Jan 22 11:11:39 2009 +0000
     6.2 +++ b/xen/include/asm-x86/microcode.h	Thu Jan 22 11:17:48 2009 +0000
     6.3 @@ -5,6 +5,7 @@ struct cpu_signature;
     6.4  struct ucode_cpu_info;
     6.5  
     6.6  struct microcode_ops {
     6.7 +    int (*microcode_resume_match)(int cpu, struct cpu_signature *nsig);
     6.8      int (*cpu_request_microcode)(int cpu, const void *buf, size_t size);
     6.9      int (*collect_cpu_info)(int cpu, struct cpu_signature *csig);
    6.10      int (*apply_microcode)(int cpu);
     7.1 --- a/xen/include/asm-x86/processor.h	Thu Jan 22 11:11:39 2009 +0000
     7.2 +++ b/xen/include/asm-x86/processor.h	Thu Jan 22 11:17:48 2009 +0000
     7.3 @@ -553,6 +553,7 @@ int wrmsr_hypervisor_regs(
     7.4      uint32_t idx, uint32_t eax, uint32_t edx);
     7.5  
     7.6  int microcode_update(XEN_GUEST_HANDLE(const_void), unsigned long len);
     7.7 +int microcode_resume_cpu(int cpu);
     7.8  
     7.9  #endif /* !__ASSEMBLY__ */
    7.10