]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
x86: produce a binary that can be booted as PVH
authorWei Liu <wei.liu2@citrix.com>
Fri, 10 Nov 2017 16:19:40 +0000 (16:19 +0000)
committerRoger Pau Monne <roger.pau@citrix.com>
Thu, 11 Jan 2018 17:51:18 +0000 (17:51 +0000)
Produce a binary that can be booted as PVH. It doesn't do much yet.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
v2:
1. Remove shim-y dependency.
2. Remove extraneous blank line.
3. Fix bugs in xen.lds.S.
4. Haven't split code into pvh.S because that will break later
   patches.

.gitignore
xen/arch/x86/Makefile
xen/arch/x86/boot/head.S
xen/arch/x86/xen.lds.S

index d64b03d06c8f92cd78fd0104e746dd67ac060004..8da67daf3102fdc56e67f1b94f4b411b67f58db7 100644 (file)
@@ -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.*
index d5d58a205ec80f9ff89446eab082f8ce73ae3fce..01d1178530af296dc65fa46d6b94ae21e6955a97 100644 (file)
@@ -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
@@ -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
index 9cc35da558537ff2c36f23655020a460b3648915..af25d237368ce37bee26afc09767f6dac6590e01 100644 (file)
@@ -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,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
index 400d8a56c4720dca598d1d8e0060a9531012d005..2023f971e492ae2a1093da43db63dbe265b5da00 100644 (file)
@@ -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
 }
@@ -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
   }