x86: real mode support
PATCH 1/3 x86: real mode support
Add infrastructure to return back to real mode in order to obtain certain pieces of information from the BIOS.
Along the way it turned out helpful to convert x86-32's boot code to use SYM_PHYS() just like x86-64 has been doing for a while.
Signed-off-by Jan Beulich <[email protected]>
xen/arch/x86/Makefile +2 -0
@@ -78,6 +78,8 @@ xen.lds: $(TARGET_SUBARCH)/xen.lds.S $(H boot/mkelf32: boot/mkelf32.c $(HOSTCC) $(HOSTCFLAGS) -o $@ $< +boot/$(TARGET_SUBARCH).o: boot/realmode.S + .PHONY: clean clean:: rm -f asm-offsets.s xen.lds boot/*.o boot/*~ boot/core boot/mkelf32
xen/arch/x86/boot/realmode.S new file +120 -0
120 lines not on this page · raw message
xen/arch/x86/boot/x86_32.S +25 -18
119 lines not on this page · raw message
xen/arch/x86/boot/x86_64.S +11 -4
@@ -72,6 +72,8 @@ __start: /* Save the Multiboot info structure for later use. */ mov %ebx,SYM_PHYS(multiboot_ptr) + lss SYM_PHYS(.Lstack_start),%esp + /* We begin by interrogating the CPU for the presence of long mode. */ mov $0x80000000,%eax cpuid
@@ -200,7 +202,7 @@ multiboot_ptr: .word 0 nopaging_gdt_descr: .word LAST_RESERVED_GDT_BYTE - .quad gdt_table - FIRST_RESERVED_GDT_BYTE - __PAGE_OFFSET + .quad SYM_PHYS(gdt_table) - FIRST_RESERVED_GDT_BYTE cpuid_ext_features: .long 0
@@ -217,6 +219,9 @@ idt_descr: ENTRY(stack_start) .quad cpu0_stack +.Lstack_start: + .long SYM_PHYS(cpu0_stack) + STACK_SIZE - CPUINFO_sizeof + .word __HYPERVISOR_DS32 high_start: .quad __high_start
@@ -256,14 +261,14 @@ ENTRY(compat_gdt_table) .align PAGE_SIZE, 0 ENTRY(idle_pg_table) ENTRY(idle_pg_table_4) - .quad idle_pg_table_l3 - __PAGE_OFFSET + 7 # PML4[0] + .quad SYM_PHYS(idle_pg_table_l3) + 7 # PML4[0] .fill 261,8,0 - .quad idle_pg_table_l3 - __PAGE_OFFSET + 7 # PML4[262] + .quad SYM_PHYS(idle_pg_table_l3) + 7 # PML4[262] /* Initial PDP -- level-3 page table. */ .align PAGE_SIZE, 0 ENTRY(idle_pg_table_l3) - .quad idle_pg_table_l2 - __PAGE_OFFSET + 7 + .quad SYM_PHYS(idle_pg_table_l2) + 7 /* Initial PDE -- level-2 page table. Maps first 1GB physical memory. */ .align PAGE_SIZE, 0
@@ -283,3 +288,5 @@ ENTRY(idle_pg_table_l2) .section ".bss.stack_aligned","w" ENTRY(cpu0_stack) .fill STACK_SIZE,1,0 + +#include "realmode.S"
xen/arch/x86/x86_32/asm-offsets.c +5 -0
@@ -7,6 +7,7 @@#include <xen/config.h> #include <xen/perfc.h> #include <xen/sched.h> +#include <xen/multiboot.h> #include <asm/fixmap.h> #include <asm/hardirq.h>
@@ -100,6 +101,10 @@ void __dummy__(void)DEFINE (CPUINFO_sizeof,sizeof (struct cpu_info ));BLANK (); +OFFSET (MBI_flags, multiboot_info_t, flags); +OFFSET (MBI_cmdline, multiboot_info_t, cmdline); +BLANK (); + OFFSET(TRAPBOUNCE_error_code, struct trap_bounce, error_code); OFFSET(TRAPBOUNCE_flags, struct trap_bounce, flags); OFFSET(TRAPBOUNCE_cs, struct trap_bounce, cs);
xen/arch/x86/x86_32/xen.lds.S +4 -0
@@ -63,6 +63,10 @@ SECTIONS __initcall_start = .; .initcall.init : { *(.initcall1.init) } :text __initcall_end = .; + . = ALIGN(16); + .real.text : { *(.real.text) } :text + .real.data : { *(.real.data) } :text + __end_realmode = .; . = ALIGN(PAGE_SIZE); __init_end = .;
xen/arch/x86/x86_64/asm-offsets.c +5 -0
@@ -7,6 +7,7 @@#include <xen/config.h> #include <xen/perfc.h> #include <xen/sched.h> +#include <xen/multiboot.h> #ifdef CONFIG_COMPAT #include <compat/xen.h> #endif
@@ -113,6 +114,10 @@ void __dummy__(void)DEFINE (CPUINFO_sizeof,sizeof (struct cpu_info ));BLANK (); +OFFSET (MBI_flags, multiboot_info_t, flags); +OFFSET (MBI_cmdline, multiboot_info_t, cmdline); +BLANK (); + OFFSET(TRAPBOUNCE_error_code, struct trap_bounce, error_code); OFFSET(TRAPBOUNCE_flags, struct trap_bounce, flags); OFFSET(TRAPBOUNCE_cs, struct trap_bounce, cs);
xen/arch/x86/x86_64/xen.lds.S +4 -0
@@ -61,6 +61,10 @@ SECTIONS __initcall_start = .; .initcall.init : { *(.initcall1.init) } :text __initcall_end = .; + . = ALIGN(16); + .real.text : { *(.real.text) } :text + .real.data : { *(.real.data) } :text + __end_realmode = .; . = ALIGN(PAGE_SIZE); __init_end = .;