[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen stable-4.11] x86/AMD: correct certain Fam17 checks



commit fcc4f5db17766b148cb86664867770facd30589a
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Fri Jul 5 10:31:26 2019 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri Jul 5 10:31:26 2019 +0200

    x86/AMD: correct certain Fam17 checks
    
    Commit 3157bb4e13 ("Add MSR support for various feature AMD processor
    families") converted certain checks for Fam11 to include families all
    the way up to Fam17. The commit having no description, it is hard to
    tell whether this was a mechanical dec->hex conversion mistake, or
    indeed intended. In any event the NB_CFG handling needs to be restricted
    to Fam16 and below: Fam17 doesn't really have such an MSR anymore. As
    per observation it's read-zero / write-discard now, so make PV uniformly
    (with the exception of pinned Dom0 vCPU-s) behave so, just like HVM
    already does.
    
    Mirror the NB_CFG behavior to MSR_FAM10H_MMIO_CONF_BASE as well, except
    that here the vendor/model check is kept in place (for now at least).
    
    A non-MMCFG extended config space access mechanism still appears to
    exist, but code to deal with it will need to be written down the road,
    when it can actually be tested.
    
    Reported-by: Pu Wen <puwen@xxxxxxxx>
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    master commit: e0fbf3bf9871b00fa526c4ed893604e7ad6c3090
    master date: 2019-06-18 16:33:53 +0200
---
 xen/arch/x86/hvm/ioreq.c       |  2 +-
 xen/arch/x86/pv/emul-priv-op.c | 18 +++++++++++++-----
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/xen/arch/x86/hvm/ioreq.c b/xen/arch/x86/hvm/ioreq.c
index fd10ee6146..ac05875af1 100644
--- a/xen/arch/x86/hvm/ioreq.c
+++ b/xen/arch/x86/hvm/ioreq.c
@@ -1334,7 +1334,7 @@ struct hvm_ioreq_server *hvm_select_ioreq_server(struct 
domain *d,
              d->arch.cpuid->x86_vendor == X86_VENDOR_AMD &&
              (x86_fam = get_cpu_family(
                  d->arch.cpuid->basic.raw_fms, NULL, NULL)) > 0x10 &&
-             x86_fam <= 0x17 )
+             x86_fam < 0x17 )
         {
             uint64_t msr_val;
 
diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c
index 312c1ee9cf..b7aa6475fd 100644
--- a/xen/arch/x86/pv/emul-priv-op.c
+++ b/xen/arch/x86/pv/emul-priv-op.c
@@ -199,7 +199,7 @@ static bool pci_cfg_ok(struct domain *currd, unsigned int 
start,
     /* AMD extended configuration space access? */
     if ( CF8_ADDR_HI(currd->arch.pci_cf8) &&
          boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
-         boot_cpu_data.x86 >= 0x10 && boot_cpu_data.x86 <= 0x17 )
+         boot_cpu_data.x86 >= 0x10 && boot_cpu_data.x86 < 0x17 )
     {
         uint64_t msr_val;
 
@@ -923,6 +923,17 @@ static int read_msr(unsigned int reg, uint64_t *val,
         }
         goto normal;
 
+    case MSR_FAM10H_MMIO_CONF_BASE:
+        if ( boot_cpu_data.x86_vendor != X86_VENDOR_AMD ||
+             boot_cpu_data.x86 < 0x10 || boot_cpu_data.x86 >= 0x17 )
+            break;
+        /* fall through */
+    case MSR_AMD64_NB_CFG:
+        if ( !is_hardware_domain(currd) || !is_pinned_vcpu(curr) )
+            goto normal;
+        *val = 0;
+        return X86EMUL_OKAY;
+
     case MSR_IA32_MISC_ENABLE:
         rdmsrl(reg, *val);
         *val = guest_misc_enable(*val);
@@ -1048,9 +1059,6 @@ static int write_msr(unsigned int reg, uint64_t val,
         break;
 
     case MSR_AMD64_NB_CFG:
-        if ( boot_cpu_data.x86_vendor != X86_VENDOR_AMD ||
-             boot_cpu_data.x86 < 0x10 || boot_cpu_data.x86 > 0x17 )
-            break;
         if ( !is_hardware_domain(currd) || !is_pinned_vcpu(curr) )
             return X86EMUL_OKAY;
         if ( (rdmsr_safe(MSR_AMD64_NB_CFG, temp) != 0) ||
@@ -1062,7 +1070,7 @@ static int write_msr(unsigned int reg, uint64_t val,
 
     case MSR_FAM10H_MMIO_CONF_BASE:
         if ( boot_cpu_data.x86_vendor != X86_VENDOR_AMD ||
-             boot_cpu_data.x86 < 0x10 || boot_cpu_data.x86 > 0x17 )
+             boot_cpu_data.x86 < 0x10 || boot_cpu_data.x86 >= 0x17 )
             break;
         if ( !is_hardware_domain(currd) || !is_pinned_vcpu(curr) )
             return X86EMUL_OKAY;
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.11

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.