From: Wei Liu Date: Fri, 10 Nov 2017 16:19:40 +0000 (+0000) Subject: x86: produce a binary that can be booted as PVH X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~809 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4ab99cb9196a36188b4a486cf1f0f2c4ac55e5ca;p=xen.git x86: produce a binary that can be booted as PVH Produce a binary that can be booted as PVH. It doesn't do much yet. Signed-off-by: Wei Liu Signed-off-by: Andrew Cooper --- diff --git a/.gitignore b/.gitignore index d64b03d06c..8da67daf31 100644 --- a/.gitignore +++ b/.gitignore @@ -323,6 +323,7 @@ xen/xsm/flask/xenpolicy-* tools/flask/policy/policy.conf tools/flask/policy/xenpolicy-* xen/xen +xen/xen-shim xen/xen-syms xen/xen-syms.map xen/xen.* diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index e8c49639d8..def6fb1e97 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -77,6 +77,8 @@ efi-y := $(shell if [ ! -r $(BASEDIR)/include/xen/compile.h -o \ -O $(BASEDIR)/include/xen/compile.h ]; then \ echo '$(TARGET).efi'; fi) +shim-$(CONFIG_PVH_GUEST) := $(TARGET)-shim + ifneq ($(build_id_linker),) notes_phdrs = --notes else @@ -146,6 +148,11 @@ $(TARGET)-syms: prelink.o xen.lds $(BASEDIR)/common/symbols-dummy.o >$(@D)/$(@F).map rm -f $(@D)/.$(@F).[0-9]* +# Use elf32-x86-64 if toolchain support exists, elf32-i386 otherwise. +$(TARGET)-shim: FORMAT = $(firstword $(filter elf32-x86-64,$(shell $(OBJCOPY) --help)) elf32-i386) +$(TARGET)-shim: $(TARGET)-syms + $(OBJCOPY) -O $(FORMAT) $< $@ + note.o: $(TARGET)-syms $(OBJCOPY) -O binary --only-section=.note.gnu.build-id $(BASEDIR)/xen-syms $@.bin $(OBJCOPY) -I binary -O elf64-x86-64 -B i386:x86-64 \ @@ -226,5 +233,6 @@ clean:: rm -f asm-offsets.s *.lds boot/*.o boot/*~ boot/core boot/mkelf32 rm -f $(BASEDIR)/.xen-syms.[0-9]* boot/.*.d rm -f $(BASEDIR)/.xen.efi.[0-9]* efi/*.efi efi/disabled efi/mkreloc + rm -f $(BASEDIR)/xen-shim rm -f boot/cmdline.S boot/reloc.S boot/*.lnk boot/*.bin rm -f note.o diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index 475c678f2c..472255a4b7 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -7,6 +7,7 @@ #include #include #include +#include .text .code32 @@ -374,6 +375,14 @@ cs32_switch: /* Jump to earlier loaded address. */ jmp *%edi +#ifdef CONFIG_PVH_GUEST +ELFNOTE(Xen, XEN_ELFNOTE_PHYS32_ENTRY, .long sym_offs(__pvh_start)) + +__pvh_start: + ud2a + +#endif /* CONFIG_PVH_GUEST */ + __start: cld cli diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index fadcbc0684..79431e45c2 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -34,7 +34,7 @@ OUTPUT_ARCH(i386:x86-64) PHDRS { text PT_LOAD ; -#if defined(BUILD_ID) && !defined(EFI) +#if (defined(BUILD_ID) || defined (CONFIG_PVH_GUEST)) && !defined(EFI) note PT_NOTE ; #endif } @@ -129,6 +129,12 @@ SECTIONS __param_end = .; } :text +#if defined(CONFIG_PVH_GUEST) && !defined(EFI) + DECL_SECTION(.note.Xen) { + *(.note.Xen) + } :note :text +#endif + #if defined(BUILD_ID) #if !defined(EFI) /* @@ -280,6 +286,7 @@ SECTIONS #ifdef EFI *(.comment) *(.comment.*) + *(.note.Xen) #endif }