debuggers.hg

changeset 19963:ed76e4bbea83

x86: move ucode_cpu_info into per-CPU space

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jul 13 11:31:34 2009 +0100 (2009-07-13)
parents 7406764457a0
children 3952eaeb70b0
files xen/arch/x86/microcode.c xen/arch/x86/microcode_amd.c xen/arch/x86/microcode_intel.c xen/include/asm-x86/microcode.h
line diff
     1.1 --- a/xen/arch/x86/microcode.c	Mon Jul 13 11:31:08 2009 +0100
     1.2 +++ b/xen/arch/x86/microcode.c	Mon Jul 13 11:31:34 2009 +0100
     1.3 @@ -40,7 +40,7 @@ const struct microcode_ops *microcode_op
     1.4  
     1.5  static DEFINE_SPINLOCK(microcode_mutex);
     1.6  
     1.7 -struct ucode_cpu_info ucode_cpu_info[NR_CPUS];
     1.8 +DEFINE_PER_CPU(struct ucode_cpu_info, ucode_cpu_info);
     1.9  
    1.10  struct microcode_info {
    1.11      unsigned int cpu;
    1.12 @@ -51,7 +51,7 @@ struct microcode_info {
    1.13  
    1.14  static void __microcode_fini_cpu(int cpu)
    1.15  {
    1.16 -    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
    1.17 +    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
    1.18  
    1.19      xfree(uci->mc.mc_valid);
    1.20      memset(uci, 0, sizeof(*uci));
    1.21 @@ -67,7 +67,7 @@ static void microcode_fini_cpu(int cpu)
    1.22  int microcode_resume_cpu(int cpu)
    1.23  {
    1.24      int err = 0;
    1.25 -    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
    1.26 +    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
    1.27      struct cpu_signature nsig;
    1.28  
    1.29      gdprintk(XENLOG_INFO, "microcode: CPU%d resumed\n", cpu);
    1.30 @@ -101,7 +101,7 @@ static int microcode_update_cpu(const vo
    1.31  {
    1.32      int err;
    1.33      unsigned int cpu = smp_processor_id();
    1.34 -    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
    1.35 +    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
    1.36  
    1.37      spin_lock(&microcode_mutex);
    1.38  
     2.1 --- a/xen/arch/x86/microcode_amd.c	Mon Jul 13 11:31:08 2009 +0100
     2.2 +++ b/xen/arch/x86/microcode_amd.c	Mon Jul 13 11:31:34 2009 +0100
     2.3 @@ -68,7 +68,7 @@ static int collect_cpu_info(int cpu, str
     2.4  
     2.5  static int microcode_fits(void *mc, int cpu)
     2.6  {
     2.7 -    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
     2.8 +    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
     2.9      struct microcode_header_amd *mc_header = mc;
    2.10      unsigned int current_cpu_id;
    2.11      unsigned int equiv_cpu_id = 0x0;
    2.12 @@ -125,7 +125,7 @@ out:
    2.13  static int apply_microcode(int cpu)
    2.14  {
    2.15      unsigned long flags;
    2.16 -    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
    2.17 +    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
    2.18      uint32_t rev, dummy;
    2.19      struct microcode_amd *mc_amd = uci->mc.mc_amd;
    2.20  
    2.21 @@ -253,7 +253,7 @@ static int cpu_request_microcode(int cpu
    2.22      unsigned long offset = 0;
    2.23      int error = 0;
    2.24      int ret;
    2.25 -    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
    2.26 +    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
    2.27      void *mc;
    2.28  
    2.29      /* We should bind the task to the CPU */
     3.1 --- a/xen/arch/x86/microcode_intel.c	Mon Jul 13 11:31:08 2009 +0100
     3.2 +++ b/xen/arch/x86/microcode_intel.c	Mon Jul 13 11:31:34 2009 +0100
     3.3 @@ -99,7 +99,7 @@ static int collect_cpu_info(int cpu_num,
     3.4  static inline int microcode_update_match(
     3.5      int cpu_num, struct microcode_header_intel *mc_header, int sig, int pf)
     3.6  {
     3.7 -    struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
     3.8 +    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu_num);
     3.9  
    3.10      return (sigmatch(sig, uci->cpu_sig.sig, pf, uci->cpu_sig.pf) &&
    3.11              (mc_header->rev > uci->cpu_sig.rev));
    3.12 @@ -201,7 +201,7 @@ static int microcode_sanity_check(void *
    3.13   */
    3.14  static int get_matching_microcode(void *mc, int cpu)
    3.15  {
    3.16 -    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
    3.17 +    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
    3.18      struct microcode_header_intel *mc_header = mc;
    3.19      struct extended_sigtable *ext_header;
    3.20      unsigned long total_size = get_totalsize(mc_header);
    3.21 @@ -251,7 +251,7 @@ static int apply_microcode(int cpu)
    3.22      unsigned long flags;
    3.23      unsigned int val[2];
    3.24      int cpu_num = raw_smp_processor_id();
    3.25 -    struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
    3.26 +    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu_num);
    3.27  
    3.28      /* We should bind the task to the CPU */
    3.29      BUG_ON(cpu_num != cpu);
    3.30 @@ -362,7 +362,7 @@ static int cpu_request_microcode(int cpu
    3.31  
    3.32  static int microcode_resume_match(int cpu, struct cpu_signature *nsig)
    3.33  {
    3.34 -    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
    3.35 +    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
    3.36  
    3.37      return (sigmatch(nsig->sig, uci->cpu_sig.sig, nsig->pf, uci->cpu_sig.pf) &&
    3.38              (uci->cpu_sig.rev > nsig->rev));
     4.1 --- a/xen/include/asm-x86/microcode.h	Mon Jul 13 11:31:08 2009 +0100
     4.2 +++ b/xen/include/asm-x86/microcode.h	Mon Jul 13 11:31:34 2009 +0100
     4.3 @@ -1,6 +1,8 @@
     4.4  #ifndef ASM_X86__MICROCODE_H
     4.5  #define ASM_X86__MICROCODE_H
     4.6  
     4.7 +#include <xen/percpu.h>
     4.8 +
     4.9  struct cpu_signature;
    4.10  struct ucode_cpu_info;
    4.11  
    4.12 @@ -88,7 +90,7 @@ struct ucode_cpu_info {
    4.13      } mc;
    4.14  };
    4.15  
    4.16 -extern struct ucode_cpu_info ucode_cpu_info[];
    4.17 +DECLARE_PER_CPU(struct ucode_cpu_info, ucode_cpu_info);
    4.18  extern const struct microcode_ops *microcode_ops;
    4.19  
    4.20  #endif /* ASM_X86__MICROCODE_H */