]> xenbits.xensource.com Git - xen.git/commitdiff
x86/AMD: make HT range dynamic for Fam17 and up
authorJan Beulich <jbeulich@suse.com>
Fri, 19 Nov 2021 08:38:09 +0000 (09:38 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 19 Nov 2021 08:38:09 +0000 (09:38 +0100)
At the time of d838ac2539cf ("x86: don't allow Dom0 access to the HT
address range") documentation correctly stated that the range was
completely fixed. For Fam17 and newer, it lives at the top of physical
address space, though.

To correctly determine the top of physical address space, we need to
account for their physical address reduction, hence the calculation of
paddr_bits also gets adjusted.

While for paddr_bits < 40 the HT range is completely hidden, there's no
need to suppress the range insertion in that case: It'll just have no
real meaning.

Reported-by: Igor Druzhinin <igor.druzhinin@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
master commit: d6e38eea2d806c53d976603717aebf6e5de30a1e
master date: 2021-10-19 10:04:13 +0200

xen/arch/x86/cpu/common.c
xen/arch/x86/dom0_build.c

index a684519a20d9aa2f5896dd20ec87fc988ab5db47..743fbb65ab1cb52fa492285855ee739fb990a5c5 100644 (file)
@@ -336,16 +336,23 @@ void __init early_cpu_init(void)
 
        eax = cpuid_eax(0x80000000);
        if ((eax >> 16) == 0x8000 && eax >= 0x80000008) {
+               ebx = eax >= 0x8000001f ? cpuid_ebx(0x8000001f) : 0;
                eax = cpuid_eax(0x80000008);
+
                paddr_bits = eax & 0xff;
                if (paddr_bits > PADDR_BITS)
                        paddr_bits = PADDR_BITS;
+
                vaddr_bits = (eax >> 8) & 0xff;
                if (vaddr_bits > VADDR_BITS)
                        vaddr_bits = VADDR_BITS;
+
                hap_paddr_bits = ((eax >> 16) & 0xff) ?: paddr_bits;
                if (hap_paddr_bits > PADDR_BITS)
                        hap_paddr_bits = PADDR_BITS;
+
+               /* Account for SME's physical address space reduction. */
+               paddr_bits -= (ebx >> 6) & 0x3f;
        }
 
        if (!(c->x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)))
index 0ce29e91a317761802fef01aa79c47b3eabd2e09..d24dd9daf698f69314ce0ba42d53804b869b8b6e 100644 (file)
@@ -521,8 +521,11 @@ int __init dom0_setup_permissions(struct domain *d)
                                          MSI_ADDR_DEST_ID_MASK));
     /* HyperTransport range. */
     if ( boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON) )
-        rc |= iomem_deny_access(d, paddr_to_pfn(0xfdULL << 32),
-                                paddr_to_pfn((1ULL << 40) - 1));
+    {
+        mfn = paddr_to_pfn(1UL <<
+                           (boot_cpu_data.x86 < 0x17 ? 40 : paddr_bits));
+        rc |= iomem_deny_access(d, mfn - paddr_to_pfn(3UL << 32), mfn - 1);
+    }
 
     /* Remove access to E820_UNUSABLE I/O regions above 1MB. */
     for ( i = 0; i < e820.nr_map; i++ )