lguest: Compile hypervisor.S into the lg module directly
PATCH 1/1 lguest: Compile hypervisor.S into the lg module directly
Because of legacy-induced blindness, I insisted on separately building the hypervisor.S switcher code (which is mapped at 0xFFC0000 in host and guest). However, the lguest64 patches showed the error of my
ways: it has no relocations, so it can be linked into the module like normal then remapped.
The only downside is that we can no longer use sizeof(hypervisor_blob), so we need to allocate our page-array dynamically.
Signed-off-by Rusty Russell <[email protected]>
arch/i386/lguest/Makefile +1 -16
@@ -4,19 +4,4 @@ obj-$(CONFIG_LGUEST_GUEST) += lguest.o l # Host requires the other files, which can be a module. obj-$(CONFIG_LGUEST) += lg.o lg-objs := core.o hypercalls.o page_tables.o interrupts_and_traps.o \ - segments.o io.o lguest_user.o - -# We use top 4MB for hypervisor. */ -HYPE_ADDR := 0xFFC00000 -# The data is only 1k (256 interrupt handler pointers) -HYPE_DATA_SIZE := 1024 -CFLAGS += -DHYPE_ADDR="$(HYPE_ADDR)" -DHYPE_DATA_SIZE="$(HYPE_DATA_SIZE)" - -$(obj)/core.o: $(obj)/hypervisor-blob.c -# This links the hypervisor in the right place and turns it into a C array. -$(obj)/hypervisor-raw: $(obj)/hypervisor.o - @$(LD) -static -Tdata=`printf %#x $$(($(HYPE_ADDR)))` -Ttext=`printf %#x $$(($(HYPE_ADDR)+$(HYPE_DATA_SIZE)))` -o $@ $< && $(OBJCOPY) -O binary $@ -$(obj)/hypervisor-blob.c: $(obj)/hypervisor-raw - @od -tx1 -An -v $< | sed -e 's/^ /0x/' -e 's/$$/,/' -e 's/ /,0x/g' > $@ - -clean-files := hypervisor-blob.c hypervisor-raw + segments.o io.o lguest_user.o hypervisor.o
arch/i386/lguest/core.c +39 -28
139 lines not on this page · raw message
arch/i386/lguest/hypervisor.S +5 -5
@@ -10,11 +10,11 @@ #include "lg.h" .text -ENTRY(_start) /* ld complains unless _start is defined. */ +ENTRY(start_hyper_text) /* %eax points to lguest pages for this CPU. %ebx contains cr3 value. All normal registers can be clobbered! */ -switch_to_guest: +ENTRY(switch_to_guest) /* Save host segments on host stack. */ pushl %es pushl %ds
@@ -148,8 +148,8 @@ handle_nmi: * host. Unfortunately we can't tell them apart except by entry * point, so we need 256 entry points. */ -irq_stubs: .data +.global default_idt_entries default_idt_entries: .text IRQ_STUBS 0 1 return_to_host /* First two traps */
@@ -159,5 +159,5 @@ default_idt_entries: IRQ_STUB 128 return_to_host /* System call (overridden) */ IRQ_STUBS 129 255 deliver_to_host /* Other real interrupts */ -/* Everything after this is used for the lguest_state structs. */ -ALIGN +.text +ENTRY(end_hyper_text)