Skip to contentSkip to conversation

x86/pvh: disable all MTRR CPU features on cpuid for dom0

RFT Luis R. Rodriguez 5 participants 5 messages Mar 26, 2015 – Mar 27, 2015

lore
Share & tools
lore
#0 lore raw

From: "Luis R. Rodriguez" <[email protected]>

Commit 586ab6a by Roger disabled the main MTRR CPU feature on the cpuid when on pvh in order to avoid having MTRR code run on the OS on dom0. This missed the fact that not all CPUs use this cpuid to identify MTRR support, this complets that.

This could in theory fix some potential issues where MTRR code was previously enabled, for instance running cat /proc/mtrr on a Linux system where MTRR was actually disabled.

Cc Roger Pau Monné <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>

---

Konrad asked me to submit this. I don't have time to test this though so it goes as RFT. If it clears through the flames of xen testing thunder please consider merging.

 xen/arch/x86/traps.c             | 6 ++++++
 xen/include/asm-x86/cpufeature.h | 3 +++
 2 files changed, 9 insertions(+)
xen/arch/x86/traps.c +6 -0
index ec324b0..23c3bbc 100644
@@ -888,7 +888,13 @@ void pv_cpuid(struct cpu_user_regs *regs)
         __clear_bit(X86_FEATURE_ACC, &d);
         __clear_bit(X86_FEATURE_PBE, &d);
         if ( is_pvh_vcpu(curr) )
+        {
             __clear_bit(X86_FEATURE_MTRR, &d);
+            __clear_bit(X86_FEATURE_K6_MTRR, &d);
+            __clear_bit(X86_FEATURE_CENTAUR_MCR, &d);
+            __clear_bit(X86_FEATURE_CYRIX_ARR, &d);
+        }
+
 
         __clear_bit(X86_FEATURE_DTES64 % 32, &c);
         __clear_bit(X86_FEATURE_MWAIT % 32, &c);
xen/include/asm-x86/cpufeature.h +3 -0
index 7963a3a..2ce5c7c 100644
@@ -61,6 +61,9 @@
 
 /* Other features, Linux-defined mapping, word 3 */
 /* This range is used for feature bits which conflict or are synthesized */
+#define X86_FEATURE_K6_MTRR     (3*32+ 1) /* AMD K6 nonstandard MTRRs */
+#define X86_FEATURE_CYRIX_ARR   (3*32+ 2) /* Cyrix ARRs (= MTRRs) */
+#define X86_FEATURE_CENTAUR_MCR (3*32+ 3) /* Centaur MCRs (= MTRRs) */
 #define X86_FEATURE_CONSTANT_TSC (3*32+ 8) /* TSC ticks at a constant rate */
 #define X86_FEATURE_NONSTOP_TSC	(3*32+ 9) /* TSC does not stop in C states */
 #define X86_FEATURE_ARAT	(3*32+ 10) /* Always running APIC timer */
Signature · 7 lines
2.3.2.209.gd67f9d5.dirty


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

El 27/03/15 a les 0.33, Luis R. Rodriguez ha escrit:

Quoted 10 lines

From: "Luis R. Rodriguez" <[email protected]>

Commit 586ab6a by Roger disabled the main MTRR CPU feature on the cpuid when on pvh in order to avoid having MTRR code run on the OS on dom0. This missed the fact that not all CPUs use this cpuid to identify MTRR support, this complets that.

This could in theory fix some potential issues where MTRR code was previously enabled, for instance running cat /proc/mtrr on a Linux system where MTRR was actually disabled.

AFAICT we will never support PVH on those CPU types, so I'm not sure if it's worth disabling it. AMD K6, Centaur and VIA chips don't have the necessary hardware extensions to allow running PVH guests.

Roger.

#2 lore raw
Quoted 8 lines · Roger Pau Monné

El 27/03/15 a les 0.33, Luis R. Rodriguez ha escrit:

Quoted 7 lines

From: "Luis R. Rodriguez" <[email protected]>

Commit 586ab6a by Roger disabled the main MTRR CPU feature on the cpuid when on pvh in order to avoid having MTRR code run on the OS on dom0. This missed the fact that not all CPUs use this cpuid to identify MTRR support, this complets that.

Quoted 7 lines
Quoted 3 lines

This could in theory fix some potential issues where MTRR code was previously enabled, for instance running cat /proc/mtrr on a Linux system where MTRR was actually disabled.

AFAICT we will never support PVH on those CPU types, so I'm not sure if it's worth disabling it. AMD K6, Centaur and VIA chips don't have the necessary hardware extensions to allow running PVH guests.

Great, should this be annotated?

Luis

#3 lore raw
In reply to Luis R. Rodriguez
Quoted 47 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

Commit 586ab6a by Roger disabled the main MTRR CPU feature on the cpuid when on pvh in order to avoid having MTRR code run on the OS on dom0. This missed the fact that not all CPUs use this cpuid to identify MTRR support, this complets that.

This could in theory fix some potential issues where MTRR code was previously enabled, for instance running cat /proc/mtrr on a Linux system where MTRR was actually disabled.

Cc Roger Pau Monné <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>

---

Konrad asked me to submit this. I don't have time to test this though so it goes as RFT. If it clears through the flames of xen testing thunder please consider merging.

  xen/arch/x86/traps.c             | 6 ++++++
  xen/include/asm-x86/cpufeature.h | 3 +++
  2 files changed, 9 insertions(+)
xen/arch/x86/traps.c +6 -0
index ec324b0..23c3bbc 100644
@@ -888,7 +888,13 @@ void pv_cpuid(struct cpu_user_regs *regs)
          __clear_bit(X86_FEATURE_ACC, &d);
          __clear_bit(X86_FEATURE_PBE, &d);
          if ( is_pvh_vcpu(curr) )
+        {
              __clear_bit(X86_FEATURE_MTRR, &d);
+            __clear_bit(X86_FEATURE_K6_MTRR, &d);
+            __clear_bit(X86_FEATURE_CENTAUR_MCR, &d);
+            __clear_bit(X86_FEATURE_CYRIX_ARR, &d);
+        }
+
 
          __clear_bit(X86_FEATURE_DTES64 % 32, &c);
          __clear_bit(X86_FEATURE_MWAIT % 32, &c);
xen/include/asm-x86/cpufeature.h +0 -0
index 7963a3a..2ce5c7c 100644

xen/include/asm-x86/cpufeature.h line 66

Quoted 6 lines
xen/include/asm-x86/cpufeature.h +3 -0
@@ -61,6 +61,9 @@
 
  /* Other features, Linux-defined mapping, word 3 */
  /* This range is used for feature bits which conflict or are synthesized */
+#define X86_FEATURE_K6_MTRR     (3*32+ 1) /* AMD K6 nonstandard MTRRs */
+#define X86_FEATURE_CYRIX_ARR   (3*32+ 2) /* Cyrix ARRs (= MTRRs) */
+#define X86_FEATURE_CENTAUR_MCR (3*32+ 3) /* Centaur MCRs (= MTRRs) */

You are introducing 3 new defines, so you can clear them out of a word.

Under what circumstances would these bits will ever be set in the first place?

~Andrew

xen/include/asm-x86/cpufeature.h line 69

Quoted 3 lines
xen/include/asm-x86/cpufeature.h +0 -0
  #define X86_FEATURE_CONSTANT_TSC (3*32+ 8) /* TSC ticks at a constant rate */
  #define X86_FEATURE_NONSTOP_TSC	(3*32+ 9) /* TSC does not stop in C states */
  #define X86_FEATURE_ARAT	(3*32+ 10) /* Always running APIC timer */

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

#4 lore raw
Quoted 59 lines
Quoted 1 line
Quoted 1 line · On 27.03.15 at 10:37, <[email protected]> wrote:

Review

Quoted 43 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

Commit 586ab6a by Roger disabled the main MTRR CPU feature on the cpuid when on pvh in order to avoid having MTRR code run on the OS on dom0. This missed the fact that not all CPUs use this cpuid to identify MTRR support, this complets that.

This could in theory fix some potential issues where MTRR code was previously enabled, for instance running cat /proc/mtrr on a Linux system where MTRR was actually disabled.

Cc Roger Pau Monné <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>

---

Konrad asked me to submit this. I don't have time to test this though so it goes as RFT. If it clears through the flames of xen testing thunder please consider merging.

  xen/arch/x86/traps.c             | 6 ++++++
  xen/include/asm-x86/cpufeature.h | 3 +++
  2 files changed, 9 insertions(+)
xen/arch/x86/traps.c +6 -0
index ec324b0..23c3bbc 100644
@@ -888,7 +888,13 @@ void pv_cpuid(struct cpu_user_regs *regs)
          __clear_bit(X86_FEATURE_ACC, &d);
          __clear_bit(X86_FEATURE_PBE, &d);
          if ( is_pvh_vcpu(curr) )
+        {
              __clear_bit(X86_FEATURE_MTRR, &d);
+            __clear_bit(X86_FEATURE_K6_MTRR, &d);
+            __clear_bit(X86_FEATURE_CENTAUR_MCR, &d);
+            __clear_bit(X86_FEATURE_CYRIX_ARR, &d);
+        }
+
 
          __clear_bit(X86_FEATURE_DTES64 % 32, &c);
          __clear_bit(X86_FEATURE_MWAIT % 32, &c);
(quoted diff) +0 -0

b/xen/include/asm-x86/cpufeature.h

xen/include/asm-x86/cpufeature.h line 66

Quoted 10 lines

index 7963a3a..2ce5c7c 100644

xen/include/asm-x86/cpufeature.h +3 -0
@@ -61,6 +61,9 @@
 
  /* Other features, Linux-defined mapping, word 3 */
  /* This range is used for feature bits which conflict or are synthesized */
+#define X86_FEATURE_K6_MTRR     (3*32+ 1) /* AMD K6 nonstandard MTRRs */
+#define X86_FEATURE_CYRIX_ARR   (3*32+ 2) /* Cyrix ARRs (= MTRRs) */
+#define X86_FEATURE_CENTAUR_MCR (3*32+ 3) /* Centaur MCRs (= MTRRs) */

You are introducing 3 new defines, so you can clear them out of a word.

Quoted 2 lines

Under what circumstances would these bits will ever be set in the first place?

And then, if any of them can validly be set on a 64-bit capable CPU, the mechanism to clear them is completely wrong: Did you spot the "synthesized" in the comment above, and that this is index 3? I ask because the change to traps.c clears these flags from word 0, where those bits have completely different meaning.

Jan

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