Skip to contentSkip to conversation

x86-64: don't allow wrmsr to MSR_FAM10H_MMIO_CONF_BASE when Xen itself is using it

PATCH In review Jan Beulich 2 participants 3 messages Jan 7, 2011 – Jan 10, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86-64: don't allow wrmsr to MSR_FAM10H_MMIO_CONF_BASE when Xen itself is using it

xen/arch/x86/traps.c +12 -1
@@ -1695,6 +1695,10 @@ static int is_cpufreq_controller(struct 
             (d->domain_id == 0));
 }
 
+#ifdef CONFIG_X86_64
+#include "x86_64/mmconfig.h"
+#endif
+
 static int emulate_privileged_op(struct cpu_user_regs *regs)
 {
     struct vcpu *v = current;
@@ -2289,7 +2293,14 @@ static int emulate_privileged_op(struct 
                 goto fail;
             if ( !IS_PRIV(v->domain) )
                 break;
-            if ( (rdmsr_safe(MSR_FAM10H_MMIO_CONF_BASE, val) != 0) ||
+            if ( (rdmsr_safe(MSR_FAM10H_MMIO_CONF_BASE, val) != 0) )
+                goto fail;
+            if (
+#ifdef CONFIG_X86_64
+                 (pci_probe & PCI_PROBE_MMCONF) &&
+                 (pci_probe & PCI_CHECK_ENABLE_AMD_MMCONF) ?
+                 val != msr_content :
+#endif
                  ((val ^ msr_content) &
                   ~( FAM10H_MMIO_CONF_ENABLE |
                     (FAM10H_MMIO_CONF_BUSRANGE_MASK <<
xen/arch/x86/traps.c +12 -1
@@ -1695,6 +1695,10 @@ static int is_cpufreq_controller(struct 
             (d->domain_id == 0));
 }
 
+#ifdef CONFIG_X86_64
+#include "x86_64/mmconfig.h"
+#endif
+
 static int emulate_privileged_op(struct cpu_user_regs *regs)
 {
     struct vcpu *v = current;
@@ -2289,7 +2293,14 @@ static int emulate_privileged_op(struct 
                 goto fail;
             if ( !IS_PRIV(v->domain) )
                 break;
-            if ( (rdmsr_safe(MSR_FAM10H_MMIO_CONF_BASE, val) != 0) ||
+            if ( (rdmsr_safe(MSR_FAM10H_MMIO_CONF_BASE, val) != 0) )
+                goto fail;
+            if (
+#ifdef CONFIG_X86_64
+                 (pci_probe & PCI_PROBE_MMCONF) &&
+                 (pci_probe & PCI_CHECK_ENABLE_AMD_MMCONF) ?
+                 val != msr_content :
+#endif
                  ((val ^ msr_content) &
                   ~( FAM10H_MMIO_CONF_ENABLE |
                     (FAM10H_MMIO_CONF_BUSRANGE_MASK <<

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

#1 lore raw

Applied, thanks. Is similar needed in 4.0-testing? It doesn't trivially backport since 4.0-testing does not have other of your patches which also serves to make variable pci_probe non-static.

-- Keir

Quoted 38 lines · Jan Beulich
xen/arch/x86/traps.c +12 -1
@@ -1695,6 +1695,10 @@ static int is_cpufreq_controller(struct
             (d->domain_id == 0));
 }
 
+#ifdef CONFIG_X86_64
+#include "x86_64/mmconfig.h"
+#endif
+
 static int emulate_privileged_op(struct cpu_user_regs *regs)
 {
     struct vcpu *v = current;
@@ -2289,7 +2293,14 @@ static int emulate_privileged_op(struct
                 goto fail;
             if ( !IS_PRIV(v->domain) )
                 break;
-            if ( (rdmsr_safe(MSR_FAM10H_MMIO_CONF_BASE, val) != 0) ||
+            if ( (rdmsr_safe(MSR_FAM10H_MMIO_CONF_BASE, val) != 0) )
+                goto fail;
+            if (
+#ifdef CONFIG_X86_64
+                 (pci_probe & PCI_PROBE_MMCONF) &&
+                 (pci_probe & PCI_CHECK_ENABLE_AMD_MMCONF) ?
+                 val != msr_content :
+#endif
                  ((val ^ msr_content) &
                   ~( FAM10H_MMIO_CONF_ENABLE |
                     (FAM10H_MMIO_CONF_BUSRANGE_MASK <<

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

#2 lore raw
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Keir Fraser

Applied, thanks. Is similar needed in 4.0-testing? It doesn't trivially backport since 4.0-testing does not have other of your patches which also serves to make variable pci_probe non-static.

We don't have full support for PCI_CHECK_ENABLE_AMD_MMCONF in 4.0 anyway, so this not clear whether there would be much benefit from the change here.

However, as you mention it and I now think about it from a slightly different perspective - perhaps having the (pci_probe & PCI_CHECK_ENABLE_AMD_MMCONF) check in here isn't correct at all - we really only should check whether we're using mmconf. From that angle, having this in 4.0 would certainly be desirable, as otherwise the mmconf window could move under our feet.

Yet again when mmconf is enabled (FAM10H_MMIO_CONF_ENABL set) no version of Linux wouldn't move the window either, so the change would only be a theoretical safe guard.

Hence altogether probably not worth the effort for 4.0, the more that the whole thing still isn't complete, as the E820 interaction hasn't seen a decision so far (neither on the Linux side).

Jan

Quoted 40 lines · Jan Beulich
Quoted 39 lines
xen/arch/x86/traps.c +12 -1
@@ -1695,6 +1695,10 @@ static int is_cpufreq_controller(struct
             (d->domain_id == 0));
 }
 
+#ifdef CONFIG_X86_64
+#include "x86_64/mmconfig.h"
+#endif
+
 static int emulate_privileged_op(struct cpu_user_regs *regs)
 {
     struct vcpu *v = current;
@@ -2289,7 +2293,14 @@ static int emulate_privileged_op(struct
                 goto fail;
             if ( !IS_PRIV(v->domain) )
                 break;
-            if ( (rdmsr_safe(MSR_FAM10H_MMIO_CONF_BASE, val) != 0) ||
+            if ( (rdmsr_safe(MSR_FAM10H_MMIO_CONF_BASE, val) != 0) )
+                goto fail;
+            if (
+#ifdef CONFIG_X86_64
+                 (pci_probe & PCI_PROBE_MMCONF) &&
+                 (pci_probe & PCI_CHECK_ENABLE_AMD_MMCONF) ?
+                 val != msr_content :
+#endif
                  ((val ^ msr_content) &
                   ~( FAM10H_MMIO_CONF_ENABLE |
                     (FAM10H_MMIO_CONF_BUSRANGE_MASK <<

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