Skip to contentSkip to conversation

x86: do away with the boot time low-memory 1:1 mapping

PATCH New Jan Beulich 1 participant 1 message Nov 9, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 x86: do away with the boot time low-memory 1:1 mapping

By doing so, we're no longer restricted to be able to place all boot loader modules into the low 1Gb/4Gb (32-/64-bit) of memory, nor is there a dependency anymore on where the boot loader places the modules.

We're also no longer restricted to copy the modules into a place below 4Gb, nor to put them all together into a single piece of memory.

Further it allows even the 32-bit Dom0 kernel to be loaded anywhere in physical memory (except if it doesn't support PAE-above-4G).

xen/arch/x86/boot/head.S +10 -2
@@ -110,12 +110,15 @@ __start:
         /* Initialise L2 identity-map and xen page table entries (16MB). */
         mov     $sym_phys(l2_identmap),%edi
         mov     $sym_phys(l2_xenmap),%esi
+        mov     $sym_phys(l2_bootmap),%edx
         mov     $0x1e3,%eax                  /* PRESENT+RW+A+D+2MB+GLOBAL */
         mov     $8,%ecx
 1:      mov     %eax,(%edi)
         add     $8,%edi
         mov     %eax,(%esi)
         add     $8,%esi
+        mov     %eax,(%edx)
+        add     $8,%edx
         add     $(1<<L2_PAGETABLE_SHIFT),%eax
         loop    1b
         /* Initialise L3 identity-map page directory entries. */
@@ -129,9 +132,13 @@ __start:
         /* Initialise L3 xen-map page directory entry. */
         mov     $(sym_phys(l2_xenmap)+7),%eax
         mov     %eax,sym_phys(l3_xenmap) + l3_table_offset(XEN_VIRT_START)*8
-        /* Hook identity-map and xen-map L3 tables into PML4. */
+        /* Initialise L3 boot-map page directory entry. */
+        mov     $(sym_phys(l2_bootmap)+7),%eax
+        mov     %eax,sym_phys(l3_bootmap) + 0*8
+        /* Hook identity-map, xen-map, and boot-map L3 tables into PML4. */
+        mov     $(sym_phys(l3_bootmap)+7),%eax
+        mov     %eax,sym_phys(idle_pg_table) + 0*8
         mov     $(sym_phys(l3_identmap)+7),%eax
-        mov     %eax,sym_phys(idle_pg_table) + (  0*8) /* PML4[  0]: 1:1 map */
         mov     %eax,sym_phys(idle_pg_table) + l4_table_offset(DIRECTMAP_VIRT_START)*8
         mov     $(sym_phys(l3_xenmap)+7),%eax
         mov     %eax,sym_phys(idle_pg_table) + l4_table_offset(XEN_VIRT_START)*8
@@ -176,6 +183,7 @@ __start:
 #if defined(__x86_64__)
         mov     %edi,sym_phys(l2_identmap)
         mov     %edi,sym_phys(l2_xenmap)
+        mov     %edi,sym_phys(l2_bootmap)
 #else
         mov     %edi,sym_phys(idle_pg_table_l2)
         mov     %edi,sym_phys(idle_pg_table_l2) + (__PAGE_OFFSET>>18)
xen/arch/x86/boot/Makefile +1 -1
@@ -4,6 +4,6 @@ head.o: reloc.S
 
 BOOT_TRAMPOLINE := $(shell sed -n 's,^\#define[[:space:]]\{1\,\}BOOT_TRAMPOLINE[[:space:]]\{1\,\},,p' $(BASEDIR)/include/asm-x86/config.h)
 %.S: %.c
-	RELOC=$(BOOT_TRAMPOLINE) XEN_BITSPERLONG=$(patsubst x86_%,%,$(TARGET_SUBARCH)) $(MAKE) -f build32.mk $@
+	RELOC=$(BOOT_TRAMPOLINE) $(MAKE) -f build32.mk $@
 
 reloc.S: $(BASEDIR)/include/asm-x86/config.h
xen/arch/x86/boot/build32.mk +1 -1
@@ -19,6 +19,6 @@ CFLAGS += -Werror -fno-builtin -msoft-fl
 	$(LD) $(LDFLAGS_DIRECT) -N -Ttext $(RELOC) -o $@ $<
 
 %.o: %.c
-	$(CC) $(CFLAGS) -DXEN_BITSPERLONG=$(XEN_BITSPERLONG) -c $< -o $@
+	$(CC) $(CFLAGS) -c $< -o $@
 
 reloc.o: $(BASEDIR)/include/asm-x86/config.h
xen/arch/x86/boot/reloc.c +0 -24
@@ -68,7 +68,6 @@ multiboot_info_t *reloc(multiboot_info_t
     {
         module_t *mods = reloc_mbi_struct(
             (module_t *)mbi->mods_addr, mbi->mods_count * sizeof(module_t));
-        u32 max_addr = 0;
 
         mbi->mods_addr = (u32)mods;
 
@@ -76,29 +75,6 @@ multiboot_info_t *reloc(multiboot_info_t
         {
             if ( mods[i].string )
                 mods[i].string = (u32)reloc_mbi_string((char *)mods[i].string);
-            if ( mods[i].mod_end > max_addr )
-                max_addr = mods[i].mod_end;
-        }
-
-        /*
-         * 32-bit Xen only maps bottom 1GB of memory at boot time. Relocate 
-         * modules which extend beyond this (GRUB2 in particular likes to 
-         * place modules as high as possible below 4GB).
-         */
-#define BOOTMAP_END (1ul<<30) /* 1GB */
-        if ( (XEN_BITSPERLONG == 32) && (max_addr > BOOTMAP_END) )
-        {
-            char *mod_alloc = (char *)BOOTMAP_END;
-            for ( i = 0; i < mbi->mods_count; i++ )
-                mod_alloc -= mods[i].mod_end - mods[i].mod_start;
-            for ( i = 0; i < mbi->mods_count; i++ )
-            {
-                u32 mod_len = mods[i].mod_end - mods[i].mod_start;
-                mods[i].mod_start = (u32)memcpy(
-                    mod_alloc, (char *)mods[i].mod_start, mod_len);
-                mods[i].mod_end = mods[i].mod_start + mod_len;
-                mod_alloc += mod_len;
-            }
         }
     }
 
xen/arch/x86/domain_build.c +71 -35

200 lines not on this page · raw message

xen/arch/x86/setup.c +268 -102

521 lines not on this page · raw message

xen/arch/x86/x86_64/mm.c +6 -0
@@ -65,6 +65,12 @@ l3_pgentry_t __attribute__ ((__section__
 l2_pgentry_t __attribute__ ((__section__ (".bss.page_aligned")))
     l2_xenmap[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];
+l2_pgentry_t __attribute__ ((__section__ (".bss.page_aligned")))
+    l2_bootmap[L2_PAGETABLE_ENTRIES];
+
 int __mfn_valid(unsigned long mfn)
 {
     return likely(mfn < max_page) &&
xen/include/asm-x86/domain.h +0 -10
@@ -466,16 +466,6 @@ void domain_cpuid(struct domain *d,
                   unsigned int  *ecx,
                   unsigned int  *edx);
 
-int construct_dom0(
-    struct domain *d,
-    unsigned long image_base,
-    unsigned long image_start, unsigned long image_len,
-    unsigned long initrd_start, unsigned long initrd_len,
-    char *cmdline);
-
-extern unsigned long initial_images_nrpages(void);
-extern void discard_initial_images(void);
-
 #endif /* __ASM_DOMAIN_H__ */
 
 /*
xen/include/asm-x86/hvm/svm/amd-iommu-proto.h +0 -1
@@ -30,7 +30,6 @@
         &amd_iommu_head, list)
 
 #define DMA_32BIT_MASK  0x00000000ffffffffULL
-#define PAGE_ALIGN(addr)    (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
 
 extern int amd_iommu_debug;
 extern int amd_iommu_perdev_intremap;
xen/include/asm-x86/page.h +2 -0
@@ -302,6 +302,7 @@ extern l2_pgentry_t   idle_pg_table_l2[
 extern l2_pgentry_t  *compat_idle_pg_table_l2;
 extern unsigned int   m2p_compat_vstart;
 #endif
+extern l2_pgentry_t l2_identmap[4*L2_PAGETABLE_ENTRIES];
 void paging_init(void);
 void setup_idle_pagetable(void);
 #endif /* !defined(__ASSEMBLY__) */
@@ -397,6 +398,7 @@ static inline uint32_t cacheattr_to_pte_
 
 #define PFN_DOWN(x)   ((x) >> PAGE_SHIFT)
 #define PFN_UP(x)     (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
+#define PAGE_ALIGN(x) (((x) + PAGE_SIZE - 1) & PAGE_MASK)
 
 #endif /* __X86_PAGE_H__ */
 
xen/include/asm-x86/setup.h +12 -0
@@ -1,6 +1,8 @@
 #ifndef __X86_SETUP_H_
 #define __X86_SETUP_H_
 
+#include <xen/multiboot.h>
+
 extern int early_boot;
 extern unsigned long xenheap_initial_phys_start;
 
@@ -25,4 +27,14 @@ void init_IRQ(void);
 void vesa_init(void);
 void vesa_mtrr_init(void);
 
+int construct_dom0(
+    struct domain *d,
+    const module_t *kernel, unsigned long kernel_headroom,
+    const module_t *initrd,
+    void *(*bootstrap_map)(const module_t *),
+    char *cmdline);
+
+unsigned long initial_images_nrpages(void);
+void discard_initial_images(void);
+
 #endif
xen/include/xsm/xsm.h +4 -3
@@ -432,14 +432,15 @@ static inline long __do_xsm_op (XEN_GUES
 
 #ifdef XSM_ENABLE
 extern int xsm_init(unsigned int *initrdidx, const multiboot_info_t *mbi,
-                                          unsigned long initial_images_start);
+                    void *(*bootstrap_map)(const module_t *));
 extern int xsm_policy_init(unsigned int *initrdidx, const multiboot_info_t *mbi,
-                                           unsigned long initial_images_start);
+                           void *(*bootstrap_map)(const module_t *));
 extern int register_xsm(struct xsm_operations *ops);
 extern int unregister_xsm(struct xsm_operations *ops);
 #else
 static inline int xsm_init (unsigned int *initrdidx,
-                const multiboot_info_t *mbi, unsigned long initial_images_start)
+                            const multiboot_info_t *mbi,
+                            void *(*bootstrap_map)(const module_t *))
 {
     return 0;
 }
xen/xsm/xsm_core.c +5 -2
@@ -47,7 +47,7 @@ static void __init do_xsm_initcalls(void
 }
 
 int __init xsm_init(unsigned int *initrdidx, const multiboot_info_t *mbi,
-                    unsigned long initial_images_start)
+                    void *(*bootstrap_map)(const module_t *))
 {
     int ret = 0;
 
@@ -55,9 +55,10 @@ int __init xsm_init(unsigned int *initrd
 
     if ( XSM_MAGIC )
     {
-        ret = xsm_policy_init(initrdidx, mbi, initial_images_start);
+        ret = xsm_policy_init(initrdidx, mbi, bootstrap_map);
         if ( ret )
         {
+            bootstrap_map(NULL);
             printk("%s: Error initializing policy.\n", __FUNCTION__);
             return -EINVAL;
         }
@@ -65,6 +66,7 @@ int __init xsm_init(unsigned int *initrd
 
     if ( verify(&dummy_xsm_ops) )
     {
+        bootstrap_map(NULL);
         printk("%s could not verify "
                "dummy_xsm_ops structure.\n", __FUNCTION__);
         return -EIO;
@@ -72,6 +74,7 @@ int __init xsm_init(unsigned int *initrd
 
     xsm_ops = &dummy_xsm_ops;
     do_xsm_initcalls();
+    bootstrap_map(NULL);
 
     return 0;
 }
xen/xsm/xsm_policy.c +7 -12
@@ -22,11 +22,11 @@
 #include <xsm/xsm.h>
 #include <xen/multiboot.h>
 
-char *policy_buffer = NULL;
-u32 policy_size = 0;
+char *__initdata policy_buffer = NULL;
+u32 __initdata policy_size = 0;
 
 int xsm_policy_init(unsigned int *initrdidx, const multiboot_info_t *mbi,
-                           unsigned long initial_images_start)
+                    void *(*bootstrap_map)(const module_t *))
 {
     int i;
     module_t *mod = (module_t *)__va(mbi->mods_addr);
@@ -40,15 +40,8 @@ int xsm_policy_init(unsigned int *initrd
      */
     for ( i = mbi->mods_count-1; i >= 1; i-- )
     {
-        start = initial_images_start + (mod[i].mod_start-mod[0].mod_start);
-#if defined(__i386__)
-        _policy_start = (u32 *)start;
-#elif defined(__x86_64__)
-        _policy_start = maddr_to_virt(start);
-#else
-        _policy_start = NULL;
-#endif
-        _policy_len   = mod[i].mod_end - mod[i].mod_start;
+        _policy_start = bootstrap_map(mod + i);
+        _policy_len   = mod[i].mod_end;
 
         if ( (xsm_magic_t)(*_policy_start) == XSM_MAGIC )
         {
@@ -63,6 +56,8 @@ int xsm_policy_init(unsigned int *initrd
             break;
 
         }
+
+        bootstrap_map(NULL);
     }
 
     return rc;

By doing so, we're no longer restricted to be able to place all boot loader modules into the low 1Gb/4Gb (32-/64-bit) of memory, nor is there a dependency anymore on where the boot loader places the modules.

We're also no longer restricted to copy the modules into a place below 4Gb, nor to put them all together into a single piece of memory.

Further it allows even the 32-bit Dom0 kernel to be loaded anywhere in physical memory (except if it doesn't support PAE-above-4G).

xen/arch/x86/boot/head.S +10 -2
@@ -110,12 +110,15 @@ __start:
         /* Initialise L2 identity-map and xen page table entries (16MB). */
         mov     $sym_phys(l2_identmap),%edi
         mov     $sym_phys(l2_xenmap),%esi
+        mov     $sym_phys(l2_bootmap),%edx
         mov     $0x1e3,%eax                  /* PRESENT+RW+A+D+2MB+GLOBAL */
         mov     $8,%ecx
 1:      mov     %eax,(%edi)
         add     $8,%edi
         mov     %eax,(%esi)
         add     $8,%esi
+        mov     %eax,(%edx)
+        add     $8,%edx
         add     $(1<<L2_PAGETABLE_SHIFT),%eax
         loop    1b
         /* Initialise L3 identity-map page directory entries. */
@@ -129,9 +132,13 @@ __start:
         /* Initialise L3 xen-map page directory entry. */
         mov     $(sym_phys(l2_xenmap)+7),%eax
         mov     %eax,sym_phys(l3_xenmap) + l3_table_offset(XEN_VIRT_START)*8
-        /* Hook identity-map and xen-map L3 tables into PML4. */
+        /* Initialise L3 boot-map page directory entry. */
+        mov     $(sym_phys(l2_bootmap)+7),%eax
+        mov     %eax,sym_phys(l3_bootmap) + 0*8
+        /* Hook identity-map, xen-map, and boot-map L3 tables into PML4. */
+        mov     $(sym_phys(l3_bootmap)+7),%eax
+        mov     %eax,sym_phys(idle_pg_table) + 0*8
         mov     $(sym_phys(l3_identmap)+7),%eax
-        mov     %eax,sym_phys(idle_pg_table) + (  0*8) /* PML4[  0]: 1:1 map */
         mov     %eax,sym_phys(idle_pg_table) + l4_table_offset(DIRECTMAP_VIRT_START)*8
         mov     $(sym_phys(l3_xenmap)+7),%eax
         mov     %eax,sym_phys(idle_pg_table) + l4_table_offset(XEN_VIRT_START)*8
@@ -176,6 +183,7 @@ __start:
 #if defined(__x86_64__)
         mov     %edi,sym_phys(l2_identmap)
         mov     %edi,sym_phys(l2_xenmap)
+        mov     %edi,sym_phys(l2_bootmap)
 #else
         mov     %edi,sym_phys(idle_pg_table_l2)
         mov     %edi,sym_phys(idle_pg_table_l2) + (__PAGE_OFFSET>>18)
xen/arch/x86/boot/Makefile +1 -1
@@ -4,6 +4,6 @@ head.o: reloc.S
 
 BOOT_TRAMPOLINE := $(shell sed -n 's,^\#define[[:space:]]\{1\,\}BOOT_TRAMPOLINE[[:space:]]\{1\,\},,p' $(BASEDIR)/include/asm-x86/config.h)
 %.S: %.c
-	RELOC=$(BOOT_TRAMPOLINE) XEN_BITSPERLONG=$(patsubst x86_%,%,$(TARGET_SUBARCH)) $(MAKE) -f build32.mk $@
+	RELOC=$(BOOT_TRAMPOLINE) $(MAKE) -f build32.mk $@
 
 reloc.S: $(BASEDIR)/include/asm-x86/config.h
xen/arch/x86/boot/build32.mk +1 -1
@@ -19,6 +19,6 @@ CFLAGS += -Werror -fno-builtin -msoft-fl
 	$(LD) $(LDFLAGS_DIRECT) -N -Ttext $(RELOC) -o $@ $<
 
 %.o: %.c
-	$(CC) $(CFLAGS) -DXEN_BITSPERLONG=$(XEN_BITSPERLONG) -c $< -o $@
+	$(CC) $(CFLAGS) -c $< -o $@
 
 reloc.o: $(BASEDIR)/include/asm-x86/config.h
xen/arch/x86/boot/reloc.c +0 -24
@@ -68,7 +68,6 @@ multiboot_info_t *reloc(multiboot_info_t
     {
         module_t *mods = reloc_mbi_struct(
             (module_t *)mbi->mods_addr, mbi->mods_count * sizeof(module_t));
-        u32 max_addr = 0;
 
         mbi->mods_addr = (u32)mods;
 
@@ -76,29 +75,6 @@ multiboot_info_t *reloc(multiboot_info_t
         {
             if ( mods[i].string )
                 mods[i].string = (u32)reloc_mbi_string((char *)mods[i].string);
-            if ( mods[i].mod_end > max_addr )
-                max_addr = mods[i].mod_end;
-        }
-
-        /*
-         * 32-bit Xen only maps bottom 1GB of memory at boot time. Relocate 
-         * modules which extend beyond this (GRUB2 in particular likes to 
-         * place modules as high as possible below 4GB).
-         */
-#define BOOTMAP_END (1ul<<30) /* 1GB */
-        if ( (XEN_BITSPERLONG == 32) && (max_addr > BOOTMAP_END) )
-        {
-            char *mod_alloc = (char *)BOOTMAP_END;
-            for ( i = 0; i < mbi->mods_count; i++ )
-                mod_alloc -= mods[i].mod_end - mods[i].mod_start;
-            for ( i = 0; i < mbi->mods_count; i++ )
-            {
-                u32 mod_len = mods[i].mod_end - mods[i].mod_start;
-                mods[i].mod_start = (u32)memcpy(
-                    mod_alloc, (char *)mods[i].mod_start, mod_len);
-                mods[i].mod_end = mods[i].mod_start + mod_len;
-                mod_alloc += mod_len;
-            }
         }
     }
 
xen/arch/x86/domain_build.c +71 -35

200 lines not on this page · raw message

xen/arch/x86/setup.c +268 -102

521 lines not on this page · raw message

xen/arch/x86/x86_64/mm.c +6 -0
@@ -65,6 +65,12 @@ l3_pgentry_t __attribute__ ((__section__
 l2_pgentry_t __attribute__ ((__section__ (".bss.page_aligned")))
     l2_xenmap[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];
+l2_pgentry_t __attribute__ ((__section__ (".bss.page_aligned")))
+    l2_bootmap[L2_PAGETABLE_ENTRIES];
+
 int __mfn_valid(unsigned long mfn)
 {
     return likely(mfn < max_page) &&
xen/include/asm-x86/domain.h +0 -10
@@ -466,16 +466,6 @@ void domain_cpuid(struct domain *d,
                   unsigned int  *ecx,
                   unsigned int  *edx);
 
-int construct_dom0(
-    struct domain *d,
-    unsigned long image_base,
-    unsigned long image_start, unsigned long image_len,
-    unsigned long initrd_start, unsigned long initrd_len,
-    char *cmdline);
-
-extern unsigned long initial_images_nrpages(void);
-extern void discard_initial_images(void);
-
 #endif /* __ASM_DOMAIN_H__ */
 
 /*
xen/include/asm-x86/hvm/svm/amd-iommu-proto.h +0 -1
@@ -30,7 +30,6 @@
         &amd_iommu_head, list)
 
 #define DMA_32BIT_MASK  0x00000000ffffffffULL
-#define PAGE_ALIGN(addr)    (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
 
 extern int amd_iommu_debug;
 extern int amd_iommu_perdev_intremap;
xen/include/asm-x86/page.h +2 -0
@@ -302,6 +302,7 @@ extern l2_pgentry_t   idle_pg_table_l2[
 extern l2_pgentry_t  *compat_idle_pg_table_l2;
 extern unsigned int   m2p_compat_vstart;
 #endif
+extern l2_pgentry_t l2_identmap[4*L2_PAGETABLE_ENTRIES];
 void paging_init(void);
 void setup_idle_pagetable(void);
 #endif /* !defined(__ASSEMBLY__) */
@@ -397,6 +398,7 @@ static inline uint32_t cacheattr_to_pte_
 
 #define PFN_DOWN(x)   ((x) >> PAGE_SHIFT)
 #define PFN_UP(x)     (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
+#define PAGE_ALIGN(x) (((x) + PAGE_SIZE - 1) & PAGE_MASK)
 
 #endif /* __X86_PAGE_H__ */
 
xen/include/asm-x86/setup.h +12 -0
@@ -1,6 +1,8 @@
 #ifndef __X86_SETUP_H_
 #define __X86_SETUP_H_
 
+#include <xen/multiboot.h>
+
 extern int early_boot;
 extern unsigned long xenheap_initial_phys_start;
 
@@ -25,4 +27,14 @@ void init_IRQ(void);
 void vesa_init(void);
 void vesa_mtrr_init(void);
 
+int construct_dom0(
+    struct domain *d,
+    const module_t *kernel, unsigned long kernel_headroom,
+    const module_t *initrd,
+    void *(*bootstrap_map)(const module_t *),
+    char *cmdline);
+
+unsigned long initial_images_nrpages(void);
+void discard_initial_images(void);
+
 #endif
xen/include/xsm/xsm.h +4 -3
@@ -432,14 +432,15 @@ static inline long __do_xsm_op (XEN_GUES
 
 #ifdef XSM_ENABLE
 extern int xsm_init(unsigned int *initrdidx, const multiboot_info_t *mbi,
-                                          unsigned long initial_images_start);
+                    void *(*bootstrap_map)(const module_t *));
 extern int xsm_policy_init(unsigned int *initrdidx, const multiboot_info_t *mbi,
-                                           unsigned long initial_images_start);
+                           void *(*bootstrap_map)(const module_t *));
 extern int register_xsm(struct xsm_operations *ops);
 extern int unregister_xsm(struct xsm_operations *ops);
 #else
 static inline int xsm_init (unsigned int *initrdidx,
-                const multiboot_info_t *mbi, unsigned long initial_images_start)
+                            const multiboot_info_t *mbi,
+                            void *(*bootstrap_map)(const module_t *))
 {
     return 0;
 }
xen/xsm/xsm_core.c +5 -2
@@ -47,7 +47,7 @@ static void __init do_xsm_initcalls(void
 }
 
 int __init xsm_init(unsigned int *initrdidx, const multiboot_info_t *mbi,
-                    unsigned long initial_images_start)
+                    void *(*bootstrap_map)(const module_t *))
 {
     int ret = 0;
 
@@ -55,9 +55,10 @@ int __init xsm_init(unsigned int *initrd
 
     if ( XSM_MAGIC )
     {
-        ret = xsm_policy_init(initrdidx, mbi, initial_images_start);
+        ret = xsm_policy_init(initrdidx, mbi, bootstrap_map);
         if ( ret )
         {
+            bootstrap_map(NULL);
             printk("%s: Error initializing policy.\n", __FUNCTION__);
             return -EINVAL;
         }
@@ -65,6 +66,7 @@ int __init xsm_init(unsigned int *initrd
 
     if ( verify(&dummy_xsm_ops) )
     {
+        bootstrap_map(NULL);
         printk("%s could not verify "
                "dummy_xsm_ops structure.\n", __FUNCTION__);
         return -EIO;
@@ -72,6 +74,7 @@ int __init xsm_init(unsigned int *initrd
 
     xsm_ops = &dummy_xsm_ops;
     do_xsm_initcalls();
+    bootstrap_map(NULL);
 
     return 0;
 }
xen/xsm/xsm_policy.c +7 -12
@@ -22,11 +22,11 @@
 #include <xsm/xsm.h>
 #include <xen/multiboot.h>
 
-char *policy_buffer = NULL;
-u32 policy_size = 0;
+char *__initdata policy_buffer = NULL;
+u32 __initdata policy_size = 0;
 
 int xsm_policy_init(unsigned int *initrdidx, const multiboot_info_t *mbi,
-                           unsigned long initial_images_start)
+                    void *(*bootstrap_map)(const module_t *))
 {
     int i;
     module_t *mod = (module_t *)__va(mbi->mods_addr);
@@ -40,15 +40,8 @@ int xsm_policy_init(unsigned int *initrd
      */
     for ( i = mbi->mods_count-1; i >= 1; i-- )
     {
-        start = initial_images_start + (mod[i].mod_start-mod[0].mod_start);
-#if defined(__i386__)
-        _policy_start = (u32 *)start;
-#elif defined(__x86_64__)
-        _policy_start = maddr_to_virt(start);
-#else
-        _policy_start = NULL;
-#endif
-        _policy_len   = mod[i].mod_end - mod[i].mod_start;
+        _policy_start = bootstrap_map(mod + i);
+        _policy_len   = mod[i].mod_end;
 
         if ( (xsm_magic_t)(*_policy_start) == XSM_MAGIC )
         {
@@ -63,6 +56,8 @@ int xsm_policy_init(unsigned int *initrd
             break;
 
         }
+
+        bootstrap_map(NULL);
     }
 
     return rc;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel