Skip to contentSkip to conversation

xen: Fake out the Bus Unit Config MSR on revF AMD CPUs

PATCH In review George Dunlap 3 participants 4 messages Mar 7, 2012 – Mar 8, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: Fake out the Bus Unit Config MSR on revF AMD CPUs

Win2k8 x64 reads this MSR on revF chips, where it wasn't publically available; it uses a magic constant in %rdi as a password, which we don't have in rdmsr_safe(). Since we'll ignore the later writes, just use a plausible value here (the reset value from rev10h chips) if the real CPU didn't provide one.

xen/arch/x86/hvm/svm/svm.c +12 -0
@@ -1516,6 +1516,18 @@ static int svm_msr_read_intercept(unsign
         if ( rdmsr_safe(msr, *msr_content) == 0 )
             break;
 
+        if ( msr == MSR_F10_BU_CFG )
+        {
+            /* Win2k8 x64 reads this MSR on revF chips, where it
+             * wasn't publically available; it uses a magic constant
+             * in %rdi as a password, which we don't have in
+             * rdmsr_safe().  Since we'll ignore the later writes,
+             * just use a plausible value here (the reset value from
+             * rev10h chips) if the real CPU didn't provide one. */
+            *msr_content = 0x0000000010200020ull;
+            break;
+        }
+
         goto gpf;
     }
 
xen/include/asm-x86/msr-index.h +3 -0
@@ -211,6 +211,9 @@
 #define MSR_F10_MC4_MISC2		0xc0000409
 #define MSR_F10_MC4_MISC3		0xc000040A
 
+/* AMD Family10h MMU control MSRs */
+#define MSR_F10_BU_CFG                  0xc0011023
+
 /* Other AMD Fam10h MSRs */
 #define MSR_FAM10H_MMIO_CONF_BASE	0xc0010058
 #define FAM10H_MMIO_CONF_ENABLE         (1<<0)
#1 lore raw
Quoted 13 lines
Quoted 1 line
Quoted 1 line · George Dunlap

Win2k8 x64 reads this MSR on revF chips, where it wasn't publically available; it uses a magic constant in %rdi as a password, which we don't have in rdmsr_safe(). Since we'll ignore the later writes, just use a plausible value here (the reset value from rev10h chips) if the real CPU didn't provide one.

xen/arch/x86/hvm/svm/svm.c static int svm_msr_read_intercept(unsign · line 1519

Quoted 4 lines
xen/arch/x86/hvm/svm/svm.c +1 -0
@@ -1516,6 +1516,18 @@ static int svm_msr_read_intercept(unsign
         if ( rdmsr_safe(msr, *msr_content) == 0 )
             break;
 
+        if ( msr == MSR_F10_BU_CFG )

As you're aiming at revF only, shouldn't you check at least the CPU family here? With the MSR being model specific, you otherwise risk to return (bogus) data for something completely different on future CPU families.

Jan

Quoted 32 lines
xen/arch/x86/hvm/svm/svm.c +11 -0
+        {
+            /* Win2k8 x64 reads this MSR on revF chips, where it
+             * wasn't publically available; it uses a magic constant
+             * in %rdi as a password, which we don't have in
+             * rdmsr_safe().  Since we'll ignore the later writes,
+             * just use a plausible value here (the reset value from
+             * rev10h chips) if the real CPU didn't provide one. */
+            *msr_content = 0x0000000010200020ull;
+            break;
+        }
+
         goto gpf;
     }
 
xen/include/asm-x86/msr-index.h +3 -0
@@ -211,6 +211,9 @@
 #define MSR_F10_MC4_MISC2		0xc0000409
 #define MSR_F10_MC4_MISC3		0xc000040A
 
+/* AMD Family10h MMU control MSRs */
+#define MSR_F10_BU_CFG                  0xc0011023
+
 /* Other AMD Fam10h MSRs */
 #define MSR_FAM10H_MMIO_CONF_BASE	0xc0010058
 #define FAM10H_MMIO_CONF_ENABLE         (1<<0)

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

#2 lore raw
Quoted 16 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · George Dunlap

Win2k8 x64 reads this MSR on revF chips, where it wasn't publically available; it uses a magic constant in %rdi as a password, which we don't have in rdmsr_safe(). Since we'll ignore the later writes, just use a plausible value here (the reset value from rev10h chips) if the real CPU didn't provide one.

xen/arch/x86/hvm/svm/svm.c +0 -0
@@ -1516,6 +1516,18 @@ static int svm_msr_read_intercept(unsign
         if ( rdmsr_safe(msr, *msr_content) == 0 )
             break;
 
Quoted 6 lines

xen/arch/x86/hvm/svm/svm.c static int svm_msr_read_intercept(unsign · line 1519

Quoted 1 line
xen/arch/x86/hvm/svm/svm.c +1 -0
+        if ( msr == MSR_F10_BU_CFG )

As you're aiming at revF only, shouldn't you check at least the CPU family here? With the MSR being model specific, you otherwise risk to return (bogus) data for something completely different on future CPU families.

I think that makes sense, but a quick glance through arch/x86/cpu/amd.c doesn't suggest to me the most concise way of making that test... could you give me a suggestion?

Thanks,
-George

#3 lore raw
Quoted 25 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 16 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · George Dunlap

Win2k8 x64 reads this MSR on revF chips, where it wasn't publically available; it uses a magic constant in %rdi as a password, which we don't have in rdmsr_safe(). Since we'll ignore the later writes, just use a plausible value here (the reset value from rev10h chips) if the real CPU didn't provide one.

xen/arch/x86/hvm/svm/svm.c +0 -0
@@ -1516,6 +1516,18 @@ static int svm_msr_read_intercept(unsign
         if ( rdmsr_safe(msr, *msr_content) == 0 )
             break;
 
Quoted 6 lines

xen/arch/x86/hvm/svm/svm.c static int svm_msr_read_intercept(unsign · line 1519

Quoted 1 line
xen/arch/x86/hvm/svm/svm.c +1 -0
+        if ( msr == MSR_F10_BU_CFG )

As you're aiming at revF only, shouldn't you check at least the CPU family here? With the MSR being model specific, you otherwise risk to return (bogus) data for something completely different on future CPU families.

Quoted 3 lines

I think that makes sense, but a quick glance through arch/x86/cpu/amd.c doesn't suggest to me the most concise way of making that test... could you give me a suggestion?

Just check boot_cpu_data.x86 == 0xf - I don't think we (or they) are prepared to handle mixed family systems (mixed model already being questionable in some places).

Jan