From: "Jan Beulich" Subject: [PATCH 3/4] x86: provide build time option to support up to 123Tb of memory Date: Wed, 28 Jan 2015 08:11:41 +0000 Message-ID: <54C8A7CD020000780005A2D6@mail.emea.novell.com> References: <54C8A524020000780005A27E@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartC0F551AD.1__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YGNiy-0003LU-JA for xen-devel@lists.xenproject.org; Wed, 28 Jan 2015 08:11:44 +0000 In-Reply-To: <54C8A524020000780005A27E@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Andrew Cooper , Keir Fraser , Tim Deegan List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartC0F551AD.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline As this requires growing struct page_info from 32 to 48 bytes as well as shrinking the always accessible direct mapped memory range from 5Tb to 3.5Tb, this isn't being introduced as a general or default enabled feature. For now setting "bigmem=3Dy" implies "shadow-paging=3Dn", as the shadow paging code otherwise fails to build (see http://lists.xenproject.org/archives/html/xen-devel/2015-01/msg03165.html).= A side effect of the change to x86's mm.h is that asm/mm.h may no longer be included directly. Hence in the few places where this was done, xen/mm.h is being substituted (indirectly in the hvm/mtrr.h case). Signed-off-by: Jan Beulich --- a/xen/arch/x86/Rules.mk +++ b/xen/arch/x86/Rules.mk @@ -32,7 +32,8 @@ x86 :=3D y x86_32 :=3D n x86_64 :=3D y =20 -shadow-paging ?=3D y +bigmem ?=3D n +shadow-paging ?=3D $(if $(filter y,$(bigmem)),n,y) =20 CFLAGS +=3D -mno-red-zone -mno-sse -fpic CFLAGS +=3D -fno-asynchronous-unwind-tables @@ -42,3 +43,4 @@ CFLAGS +=3D -DGCC_HAS_VISIBILITY_ATTRIBUTE endif =20 CFLAGS-$(shadow-paging) +=3D -DCONFIG_SHADOW_PAGING +CFLAGS-$(bigmem) +=3D -DCONFIG_BIGMEM --- a/xen/arch/x86/hvm/mtrr.c +++ b/xen/arch/x86/hvm/mtrr.c @@ -18,13 +18,11 @@ */ =20 #include -#include +#include #include #include -#include #include #include -#include #include #include #include --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -386,8 +386,13 @@ static void __init setup_max_pdx(unsigne if ( max_pdx > FRAMETABLE_NR ) max_pdx =3D FRAMETABLE_NR; =20 + if ( max_pdx > MPT_VIRT_SIZE / sizeof(unsigned long) ) + max_pdx =3D MPT_VIRT_SIZE / sizeof(unsigned long); + +#ifdef PAGE_LIST_NULL if ( max_pdx >=3D PAGE_LIST_NULL ) max_pdx =3D PAGE_LIST_NULL - 1; +#endif =20 max_page =3D pdx_to_pfn(max_pdx - 1) + 1; } --- a/xen/include/asm-x86/config.h +++ b/xen/include/asm-x86/config.h @@ -158,6 +158,7 @@ extern unsigned char boot_edid_info[128] * High read-only compatibility machine-to-phys translation table. * 0xffff82d080000000 - 0xffff82d0bfffffff [1GB, 2^30 bytes, PML4:261] * Xen text, static data, bss. +#ifndef CONFIG_BIGMEM * 0xffff82d0c0000000 - 0xffff82dffbffffff [61GB - 64MB, PML4:261] * Reserved for future use. * 0xffff82dffc000000 - 0xffff82dfffffffff [64MB, 2^26 bytes, PML4:261] @@ -166,6 +167,16 @@ extern unsigned char boot_edid_info[128] * Page-frame information array. * 0xffff830000000000 - 0xffff87ffffffffff [5TB, 5*2^40 bytes, PML4:262-2= 71] * 1:1 direct mapping of all physical memory. +#else + * 0xffff82d0c0000000 - 0xffff82ffdfffffff [188.5GB, PML4:261] + * Reserved for future use. + * 0xffff82ffe0000000 - 0xffff82ffffffffff [512MB, 2^29 bytes, PML4:261] + * Super-page information array. + * 0xffff830000000000 - 0xffff847fffffffff [1.5TB, 3*2^39 bytes, = PML4:262-264] + * Page-frame information array. + * 0xffff848000000000 - 0xffff87ffffffffff [3.5TB, 7*2^39 bytes, = PML4:265-271] + * 1:1 direct mapping of all physical memory. +#endif * 0xffff880000000000 - 0xffffffffffffffff [120TB, PML4:272-5= 11] * PV: Guest-defined use. * 0xffff880000000000 - 0xffffff7fffffffff [119.5TB, PML4:272-5= 10] @@ -234,21 +245,35 @@ extern unsigned char boot_edid_info[128] /* Slot 261: xen text, static data and bss (1GB). */ #define XEN_VIRT_START (HIRO_COMPAT_MPT_VIRT_END) #define XEN_VIRT_END (XEN_VIRT_START + GB(1)) -/* Slot 261: superpage information array (64MB). */ + +/* Slot 261: superpage information array (64MB or 512MB). */ #define SPAGETABLE_VIRT_END FRAMETABLE_VIRT_START #define SPAGETABLE_NR (((FRAMETABLE_NR - 1) >> (SUPERPAGE_SHIFT = - \ PAGE_SHIFT)) + = 1) #define SPAGETABLE_SIZE (SPAGETABLE_NR * sizeof(struct spage_info)= ) #define SPAGETABLE_VIRT_START ((SPAGETABLE_VIRT_END - SPAGETABLE_SIZE) = & \ (_AC(-1,UL) << SUPERPAGE_SHIFT)) + +#ifndef CONFIG_BIGMEM /* Slot 261: page-frame information array (128GB). */ -#define FRAMETABLE_VIRT_END DIRECTMAP_VIRT_START #define FRAMETABLE_SIZE GB(128) +#else +/* Slot 262-264: page-frame information array (1.5TB). */ +#define FRAMETABLE_SIZE GB(1536) +#endif +#define FRAMETABLE_VIRT_END DIRECTMAP_VIRT_START #define FRAMETABLE_NR (FRAMETABLE_SIZE / sizeof(*frame_table)) #define FRAMETABLE_VIRT_START (FRAMETABLE_VIRT_END - FRAMETABLE_SIZE) + +#ifndef CONFIG_BIGMEM /* Slot 262-271/510: A direct 1:1 mapping of all of physical memory. */ #define DIRECTMAP_VIRT_START (PML4_ADDR(262)) #define DIRECTMAP_SIZE (PML4_ENTRY_BYTES * (511 - 262)) +#else +/* Slot 265-271/510: A direct 1:1 mapping of all of physical memory. */ +#define DIRECTMAP_VIRT_START (PML4_ADDR(265)) +#define DIRECTMAP_SIZE (PML4_ENTRY_BYTES * (511 - 265)) +#endif #define DIRECTMAP_VIRT_END (DIRECTMAP_VIRT_START + DIRECTMAP_SIZE) =20 #ifndef __ASSEMBLY__ --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -17,6 +17,7 @@ */ #define PFN_ORDER(_pfn) ((_pfn)->v.free.order) =20 +#ifndef CONFIG_BIGMEM /* * This definition is solely for the use in struct page_info (and * struct page_list_head), intended to allow easy adjustment once x86-64 @@ -30,6 +31,9 @@ struct page_list_entry { __pdx_t next, prev; }; +#else +#define __pdx_t unsigned long +#endif =20 struct page_sharing_info; =20 --- a/xen/include/asm-x86/mtrr.h +++ b/xen/include/asm-x86/mtrr.h @@ -1,8 +1,7 @@ #ifndef __ASM_X86_MTRR_H__ #define __ASM_X86_MTRR_H__ =20 -#include -#include +#include =20 /* These are the region types. They match the architectural specification.= */ #define MTRR_TYPE_UNCACHABLE 0 --=__PartC0F551AD.1__= Content-Type: text/plain; name="x86-bigmem.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-bigmem.patch" x86: provide build time option to support up to 123Tb of memory=0A=0AAs = this requires growing struct page_info from 32 to 48 bytes as well=0Aas = shrinking the always accessible direct mapped memory range from 5Tb=0Ato = 3.5Tb, this isn't being introduced as a general or default enabled=0Afeatur= e.=0A=0AFor now setting "bigmem=3Dy" implies "shadow-paging=3Dn", as the = shadow=0Apaging code otherwise fails to build (see=0Ahttp://lists.xenprojec= t.org/archives/html/xen-devel/2015-01/msg03165.html).=0A=0AA side effect = of the change to x86's mm.h is that asm/mm.h may no=0Alonger be included = directly. Hence in the few places where this was done,=0Axen/mm.h is being = substituted (indirectly in the hvm/mtrr.h case).=0A=0ASigned-off-by: Jan = Beulich =0A=0A--- a/xen/arch/x86/Rules.mk=0A+++ = b/xen/arch/x86/Rules.mk=0A@@ -32,7 +32,8 @@ x86 :=3D y=0A x86_32 :=3D n=0A = x86_64 :=3D y=0A =0A-shadow-paging ?=3D y=0A+bigmem ?=3D n=0A+shadow= -paging ?=3D $(if $(filter y,$(bigmem)),n,y)=0A =0A CFLAGS +=3D -mno-red-zo= ne -mno-sse -fpic=0A CFLAGS +=3D -fno-asynchronous-unwind-tables=0A@@ = -42,3 +43,4 @@ CFLAGS +=3D -DGCC_HAS_VISIBILITY_ATTRIBUTE=0A endif=0A =0A = CFLAGS-$(shadow-paging) +=3D -DCONFIG_SHADOW_PAGING=0A+CFLAGS-$(bigmem) = +=3D -DCONFIG_BIGMEM=0A--- a/xen/arch/x86/hvm/mtrr.c=0A+++ b/xen/arch/x= 86/hvm/mtrr.c=0A@@ -18,13 +18,11 @@=0A */=0A =0A #include =0A-#include =0A+#include =0A #include = =0A #include =0A-#include =0A #include = =0A #include =0A-#include =0A = #include =0A #include =0A #include = =0A--- a/xen/arch/x86/setup.c=0A+++ b/xen/arch/x86/set= up.c=0A@@ -386,8 +386,13 @@ static void __init setup_max_pdx(unsigne=0A = if ( max_pdx > FRAMETABLE_NR )=0A max_pdx =3D FRAMETABLE_NR;=0A = =0A+ if ( max_pdx > MPT_VIRT_SIZE / sizeof(unsigned long) )=0A+ = max_pdx =3D MPT_VIRT_SIZE / sizeof(unsigned long);=0A+=0A+#ifdef PAGE_LIST_= NULL=0A if ( max_pdx >=3D PAGE_LIST_NULL )=0A max_pdx =3D = PAGE_LIST_NULL - 1;=0A+#endif=0A =0A max_page =3D pdx_to_pfn(max_pdx - = 1) + 1;=0A }=0A--- a/xen/include/asm-x86/config.h=0A+++ b/xen/include/asm-x= 86/config.h=0A@@ -158,6 +158,7 @@ extern unsigned char boot_edid_info[128]= =0A * High read-only compatibility machine-to-phys translation = table.=0A * 0xffff82d080000000 - 0xffff82d0bfffffff [1GB, 2^30 bytes, = PML4:261]=0A * Xen text, static data, bss.=0A+#ifndef CONFIG_BIGMEM=0A = * 0xffff82d0c0000000 - 0xffff82dffbffffff [61GB - 64MB, = PML4:261]=0A * Reserved for future use.=0A * 0xffff82dffc000000 - = 0xffff82dfffffffff [64MB, 2^26 bytes, PML4:261]=0A@@ -166,6 +167,16 @@ = extern unsigned char boot_edid_info[128]=0A * Page-frame information = array.=0A * 0xffff830000000000 - 0xffff87ffffffffff [5TB, 5*2^40 bytes, = PML4:262-271]=0A * 1:1 direct mapping of all physical memory.=0A+#else= =0A+ * 0xffff82d0c0000000 - 0xffff82ffdfffffff [188.5GB, = PML4:261]=0A+ * Reserved for future use.=0A+ * 0xffff82ffe0000000 - = 0xffff82ffffffffff [512MB, 2^29 bytes, PML4:261]=0A+ * Super-page = information array.=0A+ * 0xffff830000000000 - 0xffff847fffffffff [1.5TB, = 3*2^39 bytes, PML4:262-264]=0A+ * Page-frame information array.=0A+ * = 0xffff848000000000 - 0xffff87ffffffffff [3.5TB, 7*2^39 bytes, PML4:265-271]= =0A+ * 1:1 direct mapping of all physical memory.=0A+#endif=0A * = 0xffff880000000000 - 0xffffffffffffffff [120TB, PML4:272-511]= =0A * PV: Guest-defined use.=0A * 0xffff880000000000 - 0xffffff7fffff= ffff [119.5TB, PML4:272-510]=0A@@ -234,21 +245,35 @@ extern = unsigned char boot_edid_info[128]=0A /* Slot 261: xen text, static data = and bss (1GB). */=0A #define XEN_VIRT_START (HIRO_COMPAT_MPT_VIRT_= END)=0A #define XEN_VIRT_END (XEN_VIRT_START + GB(1))=0A-/* = Slot 261: superpage information array (64MB). */=0A+=0A+/* Slot 261: = superpage information array (64MB or 512MB). */=0A #define SPAGETABLE_VIRT_= END FRAMETABLE_VIRT_START=0A #define SPAGETABLE_NR (((FRAMETA= BLE_NR - 1) >> (SUPERPAGE_SHIFT - \=0A = PAGE_SHIFT)) + 1)=0A #define SPAGETABLE_SIZE = (SPAGETABLE_NR * sizeof(struct spage_info))=0A #define SPAGETABLE_VIRT_STAR= T ((SPAGETABLE_VIRT_END - SPAGETABLE_SIZE) & \=0A = (_AC(-1,UL) << SUPERPAGE_SHIFT))=0A+=0A+#ifndef CONFIG_BIGMEM=0A = /* Slot 261: page-frame information array (128GB). */=0A-#define FRAMETABLE= _VIRT_END DIRECTMAP_VIRT_START=0A #define FRAMETABLE_SIZE = GB(128)=0A+#else=0A+/* Slot 262-264: page-frame information array (1.5TB). = */=0A+#define FRAMETABLE_SIZE GB(1536)=0A+#endif=0A+#define = FRAMETABLE_VIRT_END DIRECTMAP_VIRT_START=0A #define FRAMETABLE_NR = (FRAMETABLE_SIZE / sizeof(*frame_table))=0A #define FRAMETABLE_VIRT_ST= ART (FRAMETABLE_VIRT_END - FRAMETABLE_SIZE)=0A+=0A+#ifndef CONFIG_BIGMEM= =0A /* Slot 262-271/510: A direct 1:1 mapping of all of physical memory. = */=0A #define DIRECTMAP_VIRT_START (PML4_ADDR(262))=0A #define = DIRECTMAP_SIZE (PML4_ENTRY_BYTES * (511 - 262))=0A+#else=0A+/* = Slot 265-271/510: A direct 1:1 mapping of all of physical memory. = */=0A+#define DIRECTMAP_VIRT_START (PML4_ADDR(265))=0A+#define = DIRECTMAP_SIZE (PML4_ENTRY_BYTES * (511 - 265))=0A+#endif=0A = #define DIRECTMAP_VIRT_END (DIRECTMAP_VIRT_START + DIRECTMAP_SIZE)=0A = =0A #ifndef __ASSEMBLY__=0A--- a/xen/include/asm-x86/mm.h=0A+++ b/xen/inclu= de/asm-x86/mm.h=0A@@ -17,6 +17,7 @@=0A */=0A #define PFN_ORDER(_pfn) = ((_pfn)->v.free.order)=0A =0A+#ifndef CONFIG_BIGMEM=0A /*=0A * This = definition is solely for the use in struct page_info (and=0A * struct = page_list_head), intended to allow easy adjustment once x86-64=0A@@ -30,6 = +31,9 @@ struct page_list_entry=0A {=0A __pdx_t next, prev;=0A = };=0A+#else=0A+#define __pdx_t unsigned long=0A+#endif=0A =0A struct = page_sharing_info;=0A =0A--- a/xen/include/asm-x86/mtrr.h=0A+++ b/xen/inclu= de/asm-x86/mtrr.h=0A@@ -1,8 +1,7 @@=0A #ifndef __ASM_X86_MTRR_H__=0A = #define __ASM_X86_MTRR_H__=0A =0A-#include =0A-#include = =0A+#include =0A =0A /* These are the region types. = They match the architectural specification. */=0A #define MTRR_TYPE_UNCACHA= BLE 0=0A --=__PartC0F551AD.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartC0F551AD.1__=--