|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2/5] xen/x86: Misc boot/link tweaking
* 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@xxxxxxxxxx>
CC: Jan Beulich <JBeulich@xxxxxxxx>
---
xen/arch/x86/boot/head.S | 26 ++------------------------
xen/arch/x86/boot/x86_64.S | 20 ++++++++++++++++++++
xen/arch/x86/setup.c | 3 ---
xen/arch/x86/xen.lds.S | 5 +++--
4 files changed, 25 insertions(+), 29 deletions(-)
diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index 2d0e56c..cfd59dc 100644
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -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
diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S
index bfbafd2..c8bf9d0 100644
--- a/xen/arch/x86/boot/x86_64.S
+++ b/xen/arch/x86/boot/x86_64.S
@@ -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)
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index d118dec..d3c1817 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -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,
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index 5fc6c9f..6553cff 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -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")
--
1.7.10.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |