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

Re: [PATCH] x86/AMD: make HT range dynamic for Fam17 and up


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Igor Druzhinin <igor.druzhinin@xxxxxxxxxx>
  • Date: Fri, 18 Jun 2021 18:15:08 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vsplhcTyofF7vdbssvmn1EOhC8L9VOs7HZ+acT1iFP4=; b=PSi4NNux1ahWaARg1brEJM/zU0Nlb8BAwEvNBN9QfINOFcvfjI3hpvooqwQSg5TtwqMjzUkEw56EUx+pZ7YcEN2YyUZnz/29oo3GpYSKsCnrDHCJCNtqfew6e0zRo45OT7LZAyJqBgtk3R/HUue6q5fnsEwrgwVhLooQAIh81WvZrncTTrAdM6WTZeHQ71L2JGqdQv15s0j1ZqH57gOQADzd0aJMK+DklZi8Xm3dOLWVeLgPAxIG5kvfGYvahb39ORaWxk6mz/lJrlGMWY/UcEuHw3dnQedOj3xOThetLni9QQNyHP6JJKCxXDGwKR40ifIXuVj2Z74Zg+PT5+rtMA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tfwn6ZJuKxbl0jjdMTnrUO1e0emSX5LbGVpa7YF8GNRfYneXQWXU9Gc7qVPqUSYAlRn6Fjti68BDOcZo+8eBGtG8SWZJ98OHA9CPFXvL3+e7QpTKVTqsOO9Zb9+GRGxVluL7zCBsZ9vyfV1uZUdpAgg51k7mkRctIl3Zt+8W2qIiMb8Gypa8GZhObHJnBNlZ8IjHjIgzu4nSUfkz5ZO26RZ14ZUDJieN4MOi7y5bZ7kcrKxMQV547lKiBhXfQAehXZiDxO1+EhxvM9KoP75aaNWRbZbq9i5Asd6hpArFUK1dG3A5rqqFHqHeKdqgfl3ov97Kbwins2PieEURUPe95g==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Fri, 18 Jun 2021 17:15:24 +0000
  • Ironport-hdrordr: A9a23:FkDc06g6GxTBfq2heOzsUiPlfXBQXzh13DAbv31ZSRFFG/FwyP rAoB1L73PJYWgqNU3I+ergBEGBKUmskaKdkrNhQYtKOzOWx1dATbsSkLcKpgePJ8SQzJ8k6U 4NSdkZNDS0NykBsS+Y2njKLz9D+qj/zEnAv463pB0MPGIaHp2IrT0JbTpzencGNDWubqBJdq Z0iPA3wgZINU5nFfhSURI+Lpn+TpDw5d3bSC9DIyRixBiFjDuu5rK/Ox+E3i0GWzcK5bs562 DKnyHw+63m6piAu17h/l6Wy64TtMrqy9NFCsDJos8JKg/0ggLtQIh6QbWNsB08venqwlc3l9 vnpQsmIq1Imj3sV1DwhSGo9xjr0T4o5XOn40Sfm2HfrcvwQy9/I9ZdhKpCGyGpqXYIjZVZ6u ZmzmiZv51YAVfrhyLm/eXFUBlsiw6dvWciq+gOlHZSOLFuK4O5lbZvuH+9La1wWx4TsOscYa 9T5YDnlbZrmGqhHjXkVjIF+q30YpxbdS32MHTruaSuonJrdT5CvhMlLGF2pAZIyHsHcegy2w 3zCNUiqFh/dL5jUUtDPpZ2fSKWMB2BffueChPfHbzYfJt3c04l/KSHnondotvaI6A18A==
  • Ironport-sdr: 15ps8/VAlFS9sB/F6ODQfuppQyx3q094sFxMEgBwPh6OQ/+X8wl2Ip9Gyofv37DPIAuhajVsZv lymfDs1Jhol9AaP3DahttXvqMH8Uh1Qbf18Y/VA6sU3SzkoJEdDgQHvOygRFNHTeqf/IvSr8Hg M7TP0sAi9rwxk3xkl84RzkT8pIbFUsx868OdulCbODIIPBuaakgkGxwXZwvIh0JyFVexRt7dRQ tEOsxgU2LYTD5cUZB+9inEIywZiZPAWEGoU2c2liAVAI3HksI3BhUhdRr3ObgbjO//WA+qk/Nc nH8=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 18/06/2021 17:00, Jan Beulich wrote:
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.

From "Open-Source Register Reference for AMD Family 17h Processors (PUB)":
https://developer.amd.com/wp-content/resources/56255_3_03.PDF

"The processor defines a reserved memory address region starting at
FFFD_0000_0000h and extending up to FFFF_FFFF_FFFFh."

It's still doesn't say that it's at the top of physical address space
although I understand that's how it's now implemented. The official
document doesn't confirm it will move along with physical address space
extension.

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: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -349,13 +349,17 @@ 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;
+

I understand Andrew has some concerns regarding changing paddr_bits but
some comment explaining what's located at 0x8000001f:ebx[11:6] and why
we're doing this might be useful.

+               paddr_bits = (eax & 0xff) - ((ebx >> 6) & 0x3f);
                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;
--- a/xen/arch/x86/dom0_build.c
+++ b/xen/arch/x86/dom0_build.c
@@ -524,8 +524,11 @@ int __init dom0_setup_permissions(struct
                                           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));

That doesn't really follow what Andrew gave us, namely:

1) On parts with <40 bits, its fully hidden from software
2) Before Fam17h, it was always 12G just below 1T, even if there was more RAM 
above this location
3) On Fam17h and later, it is variable based on SME, and is either just below 
2^48 (no encryption) or 2^43 (encryption)

Do we need (1) to be coded here as well?

Igor


 


Rackspace

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