From: "Jan Beulich" Subject: [PATCH RFC 1/8] x86: allow early use of fixmaps Date: Tue, 11 Sep 2012 11:13:09 +0100 Message-ID: <504F2AD5020000780009A7F1@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartDCEDCEA5.0__=" Return-path: 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 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. --=__PartDCEDCEA5.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline As a prerequisite for adding an EHCI debug port based console implementation, set up the page tables needed for (a sub-portion of) the fixmaps together with other boot time page table construction. Signed-off-by: Jan Beulich --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -3,6 +3,7 @@ #include #include #include +#include #include #include =20 @@ -136,6 +137,9 @@ __start: add $8,%edx add $(1< #include #include +#define __ASSEMBLY__ /* avoid pulling in ACPI stuff (conflicts with EFI) = */ +#include +#undef __ASSEMBLY__ #include #include #include @@ -1123,14 +1126,19 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SY slot &=3D L2_PAGETABLE_ENTRIES - 1; l2_bootmap[slot] =3D l2e_from_paddr(addr, __PAGE_HYPERVISOR|_PAGE_= PSE); } + /* Initialise L2 fixmap page directory entry. */ + l2_fixmap[l2_table_offset(FIXADDR_TOP - 1)] =3D + l2e_from_paddr((UINTN)l1_fixmap, __PAGE_HYPERVISOR); /* Initialise L3 identity-map page directory entries. */ for ( i =3D 0; i < ARRAY_SIZE(l2_identmap) / L2_PAGETABLE_ENTRIES; = ++i ) l3_identmap[i] =3D l3e_from_paddr((UINTN)(l2_identmap + i * L2_PAGETABLE_ENTRIES),= __PAGE_HYPERVISOR); - /* Initialise L3 xen-map page directory entry. */ + /* Initialise L3 xen-map and fixmap page directory entries. */ l3_xenmap[l3_table_offset(XEN_VIRT_START)] =3D l3e_from_paddr((UINTN)l2_xenmap, __PAGE_HYPERVISOR); + l3_xenmap[l3_table_offset(FIXADDR_TOP - 1)] =3D + l3e_from_paddr((UINTN)l2_fixmap, __PAGE_HYPERVISOR); /* Initialise L3 boot-map page directory entries. */ l3_bootmap[l3_table_offset(xen_phys_start)] =3D l3e_from_paddr((UINTN)l2_bootmap, __PAGE_HYPERVISOR); --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -130,6 +130,10 @@ l1_pgentry_t __attribute__ ((__section__ (".bss.page_aligned"))) l1_identmap[L1_PAGETABLE_ENTRIES]; =20 +/* Mapping of the fixmap space needed early. */ +l1_pgentry_t __attribute__ ((__section__ (".bss.page_aligned"))) + l1_fixmap[L1_PAGETABLE_ENTRIES]; + #define MEM_LOG(_f, _a...) gdprintk(XENLOG_WARNING , _f "\n" , ## _a) =20 /* --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -65,6 +65,10 @@ l3_pgentry_t __attribute__ ((__section__ l2_pgentry_t __attribute__ ((__section__ (".bss.page_aligned"))) l2_xenmap[L2_PAGETABLE_ENTRIES]; =20 +/* Enough page directories to map the early fixmap space. */ +l2_pgentry_t __attribute__ ((__section__ (".bss.page_aligned"))) + l2_fixmap[L2_PAGETABLE_ENTRIES]; + /* Enough page directories to map into the bottom 1GB. */ l3_pgentry_t __attribute__ ((__section__ (".bss.page_aligned"))) l3_bootmap[L3_PAGETABLE_ENTRIES]; --- a/xen/include/asm-x86/config.h +++ b/xen/include/asm-x86/config.h @@ -315,7 +315,7 @@ extern unsigned char boot_edid_info[128] #define MACHPHYS_MBYTES 16 /* 1 MB needed per 1 GB memory */ #define FRAMETABLE_MBYTES (MACHPHYS_MBYTES * 6) =20 -#define IOREMAP_VIRT_END 0UL +#define IOREMAP_VIRT_END _AC(0,UL) #define IOREMAP_VIRT_START (IOREMAP_VIRT_END - (IOREMAP_MBYTES<<20)) #define DIRECTMAP_VIRT_END IOREMAP_VIRT_START #define DIRECTMAP_VIRT_START (DIRECTMAP_VIRT_END - (DIRECTMAP_MBYTES<<20= )) --- a/xen/include/asm-x86/fixmap.h +++ b/xen/include/asm-x86/fixmap.h @@ -13,12 +13,17 @@ #define _ASM_FIXMAP_H =20 #include +#include + +#define FIXADDR_TOP (IOREMAP_VIRT_END - PAGE_SIZE) + +#ifndef __ASSEMBLY__ + #include #include #include #include #include -#include #include #include #include @@ -66,7 +71,6 @@ enum fixed_addresses { __end_of_fixed_addresses }; =20 -#define FIXADDR_TOP (IOREMAP_VIRT_END - PAGE_SIZE) #define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) =20 @@ -90,4 +94,6 @@ static inline unsigned long virt_to_fix( return __virt_to_fix(vaddr); } =20 +#endif /* __ASSEMBLY__ */ + #endif --- a/xen/include/asm-x86/page.h +++ b/xen/include/asm-x86/page.h @@ -306,13 +306,15 @@ extern l2_pgentry_t idle_pg_table_l2[ extern l2_pgentry_t *compat_idle_pg_table_l2; extern unsigned int m2p_compat_vstart; extern l2_pgentry_t l2_xenmap[L2_PAGETABLE_ENTRIES], + l2_fixmap[L2_PAGETABLE_ENTRIES], l2_bootmap[L2_PAGETABLE_ENTRIES]; extern l3_pgentry_t l3_xenmap[L3_PAGETABLE_ENTRIES], l3_identmap[L3_PAGETABLE_ENTRIES], l3_bootmap[L3_PAGETABLE_ENTRIES]; #endif extern l2_pgentry_t l2_identmap[4*L2_PAGETABLE_ENTRIES]; -extern l1_pgentry_t l1_identmap[L1_PAGETABLE_ENTRIES]; +extern l1_pgentry_t l1_identmap[L1_PAGETABLE_ENTRIES], + l1_fixmap[L1_PAGETABLE_ENTRIES]; void paging_init(void); void setup_idle_pagetable(void); #endif /* !defined(__ASSEMBLY__) */ --- /dev/null +++ a/xen/include/xen/const.h @@ -0,0 +1,24 @@ +/* const.h: Macros for dealing with constants. */ + +#ifndef __XEN_CONST_H__ +#define __XEN_CONST_H__ + +/* Some constant macros are used in both assembler and + * C code. Therefore we cannot annotate them always with + * 'UL' and other type specifiers unilaterally. We + * use the following macros to deal with this. + * + * Similarly, _AT() will cast an expression with a type in C, but + * leave it unchanged in asm. + */ + +#ifdef __ASSEMBLY__ +#define _AC(X,Y) X +#define _AT(T,X) X +#else +#define __AC(X,Y) (X##Y) +#define _AC(X,Y) __AC(X,Y) +#define _AT(T,X) ((T)(X)) +#endif + +#endif /* __XEN_CONST_H__ */ --=__PartDCEDCEA5.0__= Content-Type: text/plain; name="x86-early-fixmap.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-early-fixmap.patch" x86: allow early use of fixmaps=0A=0AAs a prerequisite for adding an EHCI = debug port based console=0Aimplementation, set up the page tables needed = for (a sub-portion of)=0Athe fixmaps together with other boot time page = table construction.=0A=0ASigned-off-by: Jan Beulich =0A= =0A--- a/xen/arch/x86/boot/head.S=0A+++ b/xen/arch/x86/boot/head.S=0A@@ = -3,6 +3,7 @@=0A #include =0A #include =0A = #include =0A+#include =0A #include = =0A #include =0A =0A@@ -136,6 +137,9 @@ __start:=0A add = $8,%edx=0A add $(1<=0A #include =0A #include = =0A+#define __ASSEMBLY__ /* avoid pulling in ACPI stuff (conflicts with = EFI) */=0A+#include =0A+#undef __ASSEMBLY__=0A #include = =0A #include =0A #include =0A@@ = -1123,14 +1126,19 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SY=0A = slot &=3D L2_PAGETABLE_ENTRIES - 1;=0A l2_bootmap[slot] =3D = l2e_from_paddr(addr, __PAGE_HYPERVISOR|_PAGE_PSE);=0A }=0A+ /* = Initialise L2 fixmap page directory entry. */=0A+ l2_fixmap[l2_table_off= set(FIXADDR_TOP - 1)] =3D=0A+ l2e_from_paddr((UINTN)l1_fixmap, = __PAGE_HYPERVISOR);=0A /* Initialise L3 identity-map page directory = entries. */=0A for ( i =3D 0; i < ARRAY_SIZE(l2_identmap) / L2_PAGETABL= E_ENTRIES; ++i )=0A l3_identmap[i] =3D l3e_from_paddr((UINTN)(l2_id= entmap +=0A i * L2_PAGETABL= E_ENTRIES),=0A __PAGE_HYPERVISOR);= =0A- /* Initialise L3 xen-map page directory entry. */=0A+ /* = Initialise L3 xen-map and fixmap page directory entries. */=0A = l3_xenmap[l3_table_offset(XEN_VIRT_START)] =3D=0A l3e_from_paddr((U= INTN)l2_xenmap, __PAGE_HYPERVISOR);=0A+ l3_xenmap[l3_table_offset(FIXADD= R_TOP - 1)] =3D=0A+ l3e_from_paddr((UINTN)l2_fixmap, __PAGE_HYPERVIS= OR);=0A /* Initialise L3 boot-map page directory entries. */=0A = l3_bootmap[l3_table_offset(xen_phys_start)] =3D=0A l3e_from_paddr((= UINTN)l2_bootmap, __PAGE_HYPERVISOR);=0A--- a/xen/arch/x86/mm.c=0A+++ = b/xen/arch/x86/mm.c=0A@@ -130,6 +130,10 @@=0A l1_pgentry_t __attribute__ = ((__section__ (".bss.page_aligned")))=0A l1_identmap[L1_PAGETABLE_ENTRI= ES];=0A =0A+/* Mapping of the fixmap space needed early. */=0A+l1_pgentry_t= __attribute__ ((__section__ (".bss.page_aligned")))=0A+ l1_fixmap[L1_PA= GETABLE_ENTRIES];=0A+=0A #define MEM_LOG(_f, _a...) gdprintk(XENLOG_WARNING= , _f "\n" , ## _a)=0A =0A /*=0A--- a/xen/arch/x86/x86_64/mm.c=0A+++ = b/xen/arch/x86/x86_64/mm.c=0A@@ -65,6 +65,10 @@ l3_pgentry_t __attribute__ = ((__section__=0A l2_pgentry_t __attribute__ ((__section__ (".bss.page_align= ed")))=0A l2_xenmap[L2_PAGETABLE_ENTRIES];=0A =0A+/* Enough page = directories to map the early fixmap space. */=0A+l2_pgentry_t __attribute__= ((__section__ (".bss.page_aligned")))=0A+ l2_fixmap[L2_PAGETABLE_ENTRIE= S];=0A+=0A /* Enough page directories to map into the bottom 1GB. */=0A = l3_pgentry_t __attribute__ ((__section__ (".bss.page_aligned")))=0A = l3_bootmap[L3_PAGETABLE_ENTRIES];=0A--- a/xen/include/asm-x86/config.h=0A++= + b/xen/include/asm-x86/config.h=0A@@ -315,7 +315,7 @@ extern unsigned = char boot_edid_info[128]=0A #define MACHPHYS_MBYTES 16 /* 1 MB = needed per 1 GB memory */=0A #define FRAMETABLE_MBYTES (MACHPHYS_MBYT= ES * 6)=0A =0A-#define IOREMAP_VIRT_END 0UL=0A+#define IOREMAP_VIRT_END = _AC(0,UL)=0A #define IOREMAP_VIRT_START (IOREMAP_VIRT_END - (IOREMAP_MBYTES= <<20))=0A #define DIRECTMAP_VIRT_END IOREMAP_VIRT_START=0A #define = DIRECTMAP_VIRT_START (DIRECTMAP_VIRT_END - (DIRECTMAP_MBYTES<<20))=0A---= a/xen/include/asm-x86/fixmap.h=0A+++ b/xen/include/asm-x86/fixmap.h=0A@@ = -13,12 +13,17 @@=0A #define _ASM_FIXMAP_H=0A =0A #include =0A= +#include =0A+=0A+#define FIXADDR_TOP (IOREMAP_VIRT_END - = PAGE_SIZE)=0A+=0A+#ifndef __ASSEMBLY__=0A+=0A #include =0A = #include =0A #include =0A #include =0A #include =0A-#include =0A #include =0A #include =0A #include =0A@@ -66,7 +71,6 = @@ enum fixed_addresses {=0A __end_of_fixed_addresses=0A };=0A = =0A-#define FIXADDR_TOP (IOREMAP_VIRT_END - PAGE_SIZE)=0A #define = FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)=0A #define = FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)=0A =0A@@ -90,4 +94,6 @@ static = inline unsigned long virt_to_fix(=0A return __virt_to_fix(vaddr);=0A = }=0A =0A+#endif /* __ASSEMBLY__ */=0A+=0A #endif=0A--- a/xen/include/asm-x8= 6/page.h=0A+++ b/xen/include/asm-x86/page.h=0A@@ -306,13 +306,15 @@ extern = l2_pgentry_t idle_pg_table_l2[=0A extern l2_pgentry_t *compat_idle_pg_ta= ble_l2;=0A extern unsigned int m2p_compat_vstart;=0A extern l2_pgentry_t = l2_xenmap[L2_PAGETABLE_ENTRIES],=0A+ l2_fixmap[L2_PAGETABLE_ENTRIES],=0A= l2_bootmap[L2_PAGETABLE_ENTRIES];=0A extern l3_pgentry_t l3_xenmap[L3_= PAGETABLE_ENTRIES],=0A l3_identmap[L3_PAGETABLE_ENTRIES],=0A = l3_bootmap[L3_PAGETABLE_ENTRIES];=0A #endif=0A extern l2_pgentry_t = l2_identmap[4*L2_PAGETABLE_ENTRIES];=0A-extern l1_pgentry_t l1_identmap[L1_= PAGETABLE_ENTRIES];=0A+extern l1_pgentry_t l1_identmap[L1_PAGETABLE_ENTRIES= ],=0A+ l1_fixmap[L1_PAGETABLE_ENTRIES];=0A void paging_init(void);=0A = void setup_idle_pagetable(void);=0A #endif /* !defined(__ASSEMBLY__) = */=0A--- /dev/null=0A+++ a/xen/include/xen/const.h=0A@@ -0,0 +1,24 = @@=0A+/* const.h: Macros for dealing with constants. */=0A+=0A+#ifndef = __XEN_CONST_H__=0A+#define __XEN_CONST_H__=0A+=0A+/* Some constant macros = are used in both assembler and=0A+ * C code. Therefore we cannot annotate = them always with=0A+ * 'UL' and other type specifiers unilaterally. = We=0A+ * use the following macros to deal with this.=0A+ *=0A+ * Similarly,= _AT() will cast an expression with a type in C, but=0A+ * leave it = unchanged in asm.=0A+ */=0A+=0A+#ifdef __ASSEMBLY__=0A+#define _AC(X,Y) = X=0A+#define _AT(T,X) X=0A+#else=0A+#define __AC(X,Y) (X##Y)=0A+#define = _AC(X,Y) __AC(X,Y)=0A+#define _AT(T,X) ((T)(X))=0A+#endif=0A+=0A+#= endif /* __XEN_CONST_H__ */=0A --=__PartDCEDCEA5.0__= 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 --=__PartDCEDCEA5.0__=--