[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH RFC v1 20/74] x86: produce a binary that can be booted as PVH



Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 .gitignore               |  1 +
 xen/arch/x86/Makefile    | 10 +++++++++-
 xen/arch/x86/boot/head.S | 10 ++++++++++
 xen/arch/x86/xen.lds.S   |  9 ++++++++-
 4 files changed, 28 insertions(+), 2 deletions(-)

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 d5d58a205e..b58141efe2 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -75,6 +75,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
@@ -93,7 +95,7 @@ endif
 syms-warn-dup-y := --warn-dup
 syms-warn-dup-$(CONFIG_SUPPRESS_DUPLICATE_SYMBOL_WARNINGS) :=
 
-$(TARGET): $(TARGET)-syms $(efi-y) boot/mkelf32
+$(TARGET): $(TARGET)-syms $(efi-y) boot/mkelf32 $(shim-y)
        ./boot/mkelf32 $(notes_phdrs) $(TARGET)-syms $(TARGET) 
$(XEN_IMG_OFFSET) \
                       `$(NM) $(TARGET)-syms | sed -ne 's/^\([^ ]*\) . 
__2M_rwdata_end$$/0x\1/p'`
 
@@ -144,6 +146,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 \
@@ -224,5 +231,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..6810422435 100644
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -7,6 +7,7 @@
 #include <asm/page.h>
 #include <asm/msr.h>
 #include <asm/cpufeature.h>
+#include <public/elfnote.h>
 
         .text
         .code32
@@ -374,6 +375,15 @@ 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 400d8a56c4..d880b0a61a 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(EFI)) || defined (CONFIG_PVH_GUEST)
   note PT_NOTE ;
 #endif
 }
@@ -128,6 +128,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)
 /*
@@ -279,6 +285,7 @@ SECTIONS
 #ifdef EFI
        *(.comment)
        *(.comment.*)
+       *(.note.Xen)
 #endif
   }
 
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.