Skip to contentSkip to conversation

microcode update support for AMD CPUs

PATCH In review Christoph Egger 3 participants 4 messages Sep 12, 2008 – Sep 15, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 microcode update support for AMD CPUs

Hi,

Attached patch adds microcode update support for
AMD CPUs Family10h and Family11h.
It is based on a patch for Linux which is on its way for 2.6.28.

Signature · 12 lines
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy
xen/arch/x86/Makefile +2 -0
diff -r 982e6fce0e47 xen/arch/x86/Makefile
@@ -28,6 +28,8 @@ obj-y += ioport_emulate.o
 obj-y += ioport_emulate.o
 obj-y += irq.o
 obj-y += microcode.o
+obj-y += microcode_amd.o
+obj-y += microcode_intel.o
 obj-y += mm.o
 obj-y += mpparse.o
 obj-y += nmi.o
xen/arch/x86/microcode.c +184 -394

657 lines not on this page · raw message

xen/arch/x86/microcode_amd.c new file +366 -0

366 lines not on this page · raw message

xen/arch/x86/microcode_intel.c new file +425 -0

425 lines not on this page · raw message

xen/include/asm-x86/microcode.h new file +100 -0

100 lines not on this page · raw message

xen/include/asm-x86/msr-index.h +4 -0
diff -r 982e6fce0e47 xen/include/asm-x86/msr-index.h
@@ -211,6 +211,10 @@
 #define FAM10H_MMIO_CONF_BASE_MASK	0xfffffff
 #define FAM10H_MMIO_CONF_BASE_SHIFT	20
 
+/* AMD Microcode MSRs */
+#define MSR_AMD_PATCHLEVEL		0x0000008b
+#define MSR_AMD_PATCHLOADER		0xc0010020
+
 /* K6 MSRs */
 #define MSR_K6_EFER			0xc0000080
 #define MSR_K6_STAR			0xc0000081
xen/include/asm-x86/processor.h +0 -35
diff -r 982e6fce0e47 xen/include/asm-x86/processor.h
@@ -486,41 +486,6 @@ long set_gdt(struct vcpu *d,
 })
 long set_debugreg(struct vcpu *p, int reg, unsigned long value);
 
-struct microcode_header {
-    unsigned int hdrver;
-    unsigned int rev;
-    unsigned int date;
-    unsigned int sig;
-    unsigned int cksum;
-    unsigned int ldrver;
-    unsigned int pf;
-    unsigned int datasize;
-    unsigned int totalsize;
-    unsigned int reserved[3];
-};
-
-struct microcode {
-    struct microcode_header hdr;
-    unsigned int bits[0];
-};
-
-typedef struct microcode microcode_t;
-typedef struct microcode_header microcode_header_t;
-
-/* microcode format is extended from prescott processors */
-struct extended_signature {
-    unsigned int sig;
-    unsigned int pf;
-    unsigned int cksum;
-};
-
-struct extended_sigtable {
-    unsigned int count;
-    unsigned int cksum;
-    unsigned int reserved[3];
-    struct extended_signature sigs[0];
-};
-
 /* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
 static always_inline void rep_nop(void)
 {

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Christoph Egger writes ("[Xen-devel] [PATCH] microcode update support for AMD CPUs"):

xen/arch/x86/microcode_amd.c line 188

Quoted 1 line
xen/arch/x86/microcode_amd.c new file +1 -0
+	edx = (unsigned int)((unsigned long)(addr >> 32));

This is wrong. addr is an unsigned long, ie 32 bits so you are shifting by >= the word size, which is not permitted. Helpfully, many compilers warn about it.

But addr came from this:

	addr = (unsigned long)&uci->mc.mc_amd->hdr.data_code;

surely this cannot be right if you're expecting the address to be longer than 32 bits in some cases ?

Ian.

#2 lore raw
Quoted 4 lines · Ian Jackson

Christoph Egger writes ("[Xen-devel] [PATCH] microcode update support for AMD CPUs"):

Quoted 1 line

+ edx = (unsigned int)((unsigned long)(addr >> 32));

Quoted 8 lines

This is wrong. addr is an unsigned long, ie 32 bits so you are shifting by >= the word size, which is not permitted. Helpfully, many compilers warn about it.

But addr came from this:
addr = (unsigned long)&uci->mc.mc_amd->hdr.data_code; surely this cannot be right if you're expecting the address to be longer than 32 bits in some cases ?

The code's correct when targeting x86_64. It just isn't careful enough for the i386 target. I'll check in a fix, since it's pretty trivial.

-- Keir

#3 lore raw
Quoted 11 lines · On Monday 15 September 2008 16:42:17 Keir Fraser wrote:
Quoted 10 lines · Ian Jackson

Christoph Egger writes ("[Xen-devel] [PATCH] microcode update support for AMD

CPUs"):

Quoted 1 line

+ edx = (unsigned int)((unsigned long)(addr >> 32));

This is wrong. addr is an unsigned long, ie 32 bits so you are shifting by >= the word size, which is not permitted. Helpfully, many compilers warn about it.

Quoted 7 lines
Quoted 4 lines

But addr came from this:
addr = (unsigned long)&uci->mc.mc_amd->hdr.data_code; surely this cannot be right if you're expecting the address to be longer than 32 bits in some cases ?

The code's correct when targeting x86_64. It just isn't careful enough for the i386 target. I'll check in a fix, since it's pretty trivial.

Thanks for fixing this. I should have compile-tested for 32bit at least. gcc actually warns with shifting >= count .

Christoph

Signature · 12 lines
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy