mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
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@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
498266eb5f
commit
cb7d7dd277
4 files changed
+25
-29
No files matched your search
@@ -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
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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")
|
||||