WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 2/5] x86: move ucode_cpu_info into per-CPU space

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 2/5] x86: move ucode_cpu_info into per-CPU space
From: "Jan Beulich" <JBeulich@xxxxxxxxxx>
Date: Fri, 10 Jul 2009 15:42:50 +0100
Delivery-date: Fri, 10 Jul 2009 07:43:45 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

--- 2009-06-10.orig/xen/arch/x86/microcode.c    2009-01-26 09:39:13.000000000 
+0100
+++ 2009-06-10/xen/arch/x86/microcode.c 2009-07-06 11:13:32.000000000 +0200
@@ -40,7 +40,7 @@ const struct microcode_ops *microcode_op
 
 static DEFINE_SPINLOCK(microcode_mutex);
 
-struct ucode_cpu_info ucode_cpu_info[NR_CPUS];
+DEFINE_PER_CPU(struct ucode_cpu_info, ucode_cpu_info);
 
 struct microcode_info {
     unsigned int cpu;
@@ -51,7 +51,7 @@ struct microcode_info {
 
 static void __microcode_fini_cpu(int cpu)
 {
-    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
+    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
 
     xfree(uci->mc.mc_valid);
     memset(uci, 0, sizeof(*uci));
@@ -67,7 +67,7 @@ static void microcode_fini_cpu(int cpu)
 int microcode_resume_cpu(int cpu)
 {
     int err = 0;
-    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
+    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
     struct cpu_signature nsig;
 
     gdprintk(XENLOG_INFO, "microcode: CPU%d resumed\n", cpu);
@@ -101,7 +101,7 @@ static int microcode_update_cpu(const vo
 {
     int err;
     unsigned int cpu = smp_processor_id();
-    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
+    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
 
     spin_lock(&microcode_mutex);
 
--- 2009-06-10.orig/xen/arch/x86/microcode_amd.c        2009-01-26 
09:39:13.000000000 +0100
+++ 2009-06-10/xen/arch/x86/microcode_amd.c     2009-07-03 17:48:34.000000000 
+0200
@@ -68,7 +68,7 @@ static int collect_cpu_info(int cpu, str
 
 static int microcode_fits(void *mc, int cpu)
 {
-    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
+    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
     struct microcode_header_amd *mc_header = mc;
     unsigned int current_cpu_id;
     unsigned int equiv_cpu_id = 0x0;
@@ -125,7 +125,7 @@ out:
 static int apply_microcode(int cpu)
 {
     unsigned long flags;
-    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
+    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
     uint32_t rev, dummy;
     struct microcode_amd *mc_amd = uci->mc.mc_amd;
 
@@ -253,7 +253,7 @@ static int cpu_request_microcode(int cpu
     unsigned long offset = 0;
     int error = 0;
     int ret;
-    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
+    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
     void *mc;
 
     /* We should bind the task to the CPU */
--- 2009-06-10.orig/xen/arch/x86/microcode_intel.c      2009-01-26 
09:39:13.000000000 +0100
+++ 2009-06-10/xen/arch/x86/microcode_intel.c   2009-07-03 17:49:01.000000000 
+0200
@@ -99,7 +99,7 @@ static int collect_cpu_info(int cpu_num,
 static inline int microcode_update_match(
     int cpu_num, struct microcode_header_intel *mc_header, int sig, int pf)
 {
-    struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
+    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu_num);
 
     return (sigmatch(sig, uci->cpu_sig.sig, pf, uci->cpu_sig.pf) &&
             (mc_header->rev > uci->cpu_sig.rev));
@@ -201,7 +201,7 @@ static int microcode_sanity_check(void *
  */
 static int get_matching_microcode(void *mc, int cpu)
 {
-    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
+    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
     struct microcode_header_intel *mc_header = mc;
     struct extended_sigtable *ext_header;
     unsigned long total_size = get_totalsize(mc_header);
@@ -251,7 +251,7 @@ static int apply_microcode(int cpu)
     unsigned long flags;
     unsigned int val[2];
     int cpu_num = raw_smp_processor_id();
-    struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
+    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu_num);
 
     /* We should bind the task to the CPU */
     BUG_ON(cpu_num != cpu);
@@ -362,7 +362,7 @@ static int cpu_request_microcode(int cpu
 
 static int microcode_resume_match(int cpu, struct cpu_signature *nsig)
 {
-    struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
+    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
 
     return (sigmatch(nsig->sig, uci->cpu_sig.sig, nsig->pf, uci->cpu_sig.pf) &&
             (uci->cpu_sig.rev > nsig->rev));
--- 2009-06-10.orig/xen/include/asm-x86/microcode.h     2009-01-26 
09:39:13.000000000 +0100
+++ 2009-06-10/xen/include/asm-x86/microcode.h  2009-07-03 17:46:52.000000000 
+0200
@@ -1,6 +1,8 @@
 #ifndef ASM_X86__MICROCODE_H
 #define ASM_X86__MICROCODE_H
 
+#include <xen/percpu.h>
+
 struct cpu_signature;
 struct ucode_cpu_info;
 
@@ -88,7 +90,7 @@ struct ucode_cpu_info {
     } mc;
 };
 
-extern struct ucode_cpu_info ucode_cpu_info[];
+DECLARE_PER_CPU(struct ucode_cpu_info, ucode_cpu_info);
 extern const struct microcode_ops *microcode_ops;
 
 #endif /* ASM_X86__MICROCODE_H */



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 2/5] x86: move ucode_cpu_info into per-CPU space, Jan Beulich <=