]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/xen.git/commitdiff
x86: misc boot/link tweaking
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 8 Jun 2015 12:15:59 +0000 (14:15 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 8 Jun 2015 12:15:59 +0000 (14:15 +0200)
 * Introduce symbols bounding the multiboot1 header, which helps clarify that
   it is data and not code corruption when viewing the disassembly.
 * Move the __high_start symbol to its implementation, and declare it
   correctly as ENTRY()
 * Move the l1_identmap construction to be with all the other pagetables, and
   within __page_tables_{start,end}.  This won't affect the EFI relocation
   algorithm, as l1_identmap contains no relocations.
 * Move the cpu0_stack alignment check to the linker.  Chances are very good
   that a binary with a misaligned stack won't get as far as the test.
 * Use MB() in linker script.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/boot/head.S
xen/arch/x86/boot/x86_64.S
xen/arch/x86/setup.c
xen/arch/x86/xen.lds.S

index 2d0e56c26f1f71e99b4109e1374aa003b2230ca5..cfd59dcee038bff70393e1925f1807c5c00190d0 100644 (file)
@@ -23,7 +23,7 @@ ENTRY(start)
         jmp     __start
 
         .align 4
-/*** MULTIBOOT HEADER ****/
+multiboot1_header_start:       /*** MULTIBOOT1 HEADER ****/
 #define MULTIBOOT_HEADER_FLAGS (MULTIBOOT_HEADER_MODS_ALIGNED | \
                                 MULTIBOOT_HEADER_WANT_MEMORY)
         /* Magic number indicating a Multiboot header. */
@@ -32,6 +32,7 @@ ENTRY(start)
         .long   MULTIBOOT_HEADER_FLAGS
         /* Checksum: must be the negated sum of the first two fields. */
         .long   -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
+multiboot1_header_end:
 
         .section .init.rodata, "a", @progbits
         .align 4
@@ -212,27 +213,4 @@ ENTRY(trampoline_start)
 #include "trampoline.S"
 GLOBAL(trampoline_end)
 
-        .text
-__high_start:
 #include "x86_64.S"
-
-        .section .data.page_aligned, "aw", @progbits
-        .p2align PAGE_SHIFT
-/*
- * Mapping of first 2 megabytes of memory. This is mapped with 4kB mappings
- * to avoid type conflicts with fixed-range MTRRs covering the lowest megabyte
- * of physical memory. In any case the VGA hole should be mapped with type UC.
- */
-GLOBAL(l1_identmap)
-        pfn = 0
-        .rept L1_PAGETABLE_ENTRIES
-        /* VGA hole (0xa0000-0xc0000) should be mapped UC. */
-        .if pfn >= 0xa0 && pfn < 0xc0
-        .long (pfn << PAGE_SHIFT) | PAGE_HYPERVISOR_NOCACHE | MAP_SMALL_PAGES
-        .else
-        .long (pfn << PAGE_SHIFT) | PAGE_HYPERVISOR | MAP_SMALL_PAGES
-        .endif
-        .long 0
-        pfn = pfn + 1
-        .endr
-        .size l1_identmap, . - l1_identmap
index bfbafd2ee6b044541cec1b02dc725f15ba66b0d0..c8bf9d02c797f84d2b0ee0a5b2af0e21725e6af5 100644 (file)
@@ -1,5 +1,7 @@
+        .text
         .code64
 
+ENTRY(__high_start)
         /* Install relocated data selectors. */
         lgdt    gdt_descr(%rip)
         mov     $(__HYPERVISOR_DS64),%ecx
@@ -80,6 +82,24 @@ GLOBAL(boot_cpu_compat_gdt_table)
         .align PAGE_SIZE, 0
 
 GLOBAL(__page_tables_start)
+/*
+ * Mapping of first 2 megabytes of memory. This is mapped with 4kB mappings
+ * to avoid type conflicts with fixed-range MTRRs covering the lowest megabyte
+ * of physical memory. In any case the VGA hole should be mapped with type UC.
+ */
+GLOBAL(l1_identmap)
+        pfn = 0
+        .rept L1_PAGETABLE_ENTRIES
+        /* VGA hole (0xa0000-0xc0000) should be mapped UC. */
+        .if pfn >= 0xa0 && pfn < 0xc0
+        .long (pfn << PAGE_SHIFT) | PAGE_HYPERVISOR_NOCACHE | MAP_SMALL_PAGES
+        .else
+        .long (pfn << PAGE_SHIFT) | PAGE_HYPERVISOR | MAP_SMALL_PAGES
+        .endif
+        .long 0
+        pfn = pfn + 1
+        .endr
+        .size l1_identmap, . - l1_identmap
 
 /* Mapping of first 16 megabytes of memory. */
 GLOBAL(l2_identmap)
index d118decd7489b93596f205239d8f6a6aa8df320d..d3c18171af03e8965ec65b89aed0c8f2b5dd4e2f 100644 (file)
@@ -674,9 +674,6 @@ void __init noreturn __start_xen(unsigned long mbi_p)
     if ( !(mbi->flags & MBI_MODULES) || (mbi->mods_count == 0) )
         panic("dom0 kernel not specified. Check bootloader configuration.");
 
-    if ( ((unsigned long)cpu0_stack & (STACK_SIZE-1)) != 0 )
-        panic("Misaligned CPU0 stack.");
-
     if ( efi_enabled )
     {
         set_pdx_range(xen_phys_start >> PAGE_SHIFT,
index 5fc6c9faf55e5720e2b7c60aa135580c96a7c7d4..6553cff56f03066037ca7e2b02574df7db70516b 100644 (file)
@@ -38,7 +38,7 @@ SECTIONS
   . = __XEN_VIRT_START;
   __image_base__ = .;
 #endif
-  . = __XEN_VIRT_START + 0x100000;
+  . = __XEN_VIRT_START + MB(1);
   _start = .;
   .text : {
         _stext = .;            /* Text and read-only data */
@@ -187,7 +187,7 @@ SECTIONS
   /* Trick the linker into setting the image size to exactly 16Mb. */
   . = ALIGN(__section_alignment__);
   .pad : {
-    . = ALIGN(0x1000000);
+    . = ALIGN(MB(16));
   } :text
 #else
   efi = .;
@@ -221,3 +221,4 @@ ASSERT(__image_base__ > XEN_VIRT_START ||
        _end <= XEN_VIRT_END - NR_CPUS * PAGE_SIZE,
        "Xen image overlaps stubs area")
 ASSERT(kexec_reloc_size - kexec_reloc <= PAGE_SIZE, "kexec_reloc is too large")
+ASSERT((cpu0_stack & (STACK_SIZE - 1)) == 0, "cpu0_stack misaligned")