aboutsummaryrefslogtreecommitdiff
path: root/emulators/xen-kernel
diff options
context:
space:
mode:
authorRoger Pau Monné <royger@FreeBSD.org>2019-07-03 14:24:46 +0000
committerRoger Pau Monné <royger@FreeBSD.org>2019-07-03 14:24:46 +0000
commit2213382ec79a995f3722aba33580ee276ce1d0a6 (patch)
tree6620ec8fe88c913cceff9192982f5202d50e30b7 /emulators/xen-kernel
parentb603533eedd71ceae1278a37111b65219bba3dd6 (diff)
downloadports-2213382ec79a995f3722aba33580ee276ce1d0a6.tar.gz
ports-2213382ec79a995f3722aba33580ee276ce1d0a6.zip
Notes
Diffstat (limited to 'emulators/xen-kernel')
-rw-r--r--emulators/xen-kernel/Makefile22
-rw-r--r--emulators/xen-kernel/files/0001-x86-linker-add-a-reloc-section-to-ELF-linker-script.patch50
-rw-r--r--emulators/xen-kernel/files/0003-xen-link-handle-.init.rodata.cst-sections-in-the-lin.patch53
-rw-r--r--emulators/xen-kernel/files/0004-x86-check-for-multiboot-1-2-header-presence.patch64
4 files changed, 180 insertions, 9 deletions
diff --git a/emulators/xen-kernel/Makefile b/emulators/xen-kernel/Makefile
index 3ccb7d01e962..dad3ebc5322b 100644
--- a/emulators/xen-kernel/Makefile
+++ b/emulators/xen-kernel/Makefile
@@ -2,7 +2,7 @@
PORTNAME= xen
PORTVERSION= 4.12.0
-PORTREVISION= 2
+PORTREVISION= 3
CATEGORIES= emulators
MASTER_SITES= http://downloads.xenproject.org/release/xen/${PORTVERSION}/
PKGNAMESUFFIX= -kernel
@@ -15,17 +15,11 @@ LICENSE= GPLv2
ONLY_FOR_ARCHS= amd64
USES= cpe gmake python:2.7,build
-# LLD 8 changed the behaviour re the placement of orphaned sections, which
-# produces a non-bootable Xen kernel:
-#
-# https://bugs.llvm.org/show_bug.cgi?id=42327
-#
-# Switch to GNU LD (and NM) until this is resolved.
-USE_BINUTILS= yes
+
# Ports build environment has ARCH=amd64 set which disables Xen automatic arch
# detection, but amd64 is not a valid arch for Xen. Hardcode x86_64 on the
# command line in order to overwrite the one from the environment.
-MAKE_ARGS= clang=y PYTHON=${PYTHON_CMD} ARCH=x86_64 LD=${LD} NM=${NM}
+MAKE_ARGS= clang=y PYTHON=${PYTHON_CMD} ARCH=x86_64
NO_MTREE= yes
STRIP= #
PLIST_FILES= /boot/xen \
@@ -45,6 +39,16 @@ EXTRA_PATCHES+= ${PATCHDIR}/xsa297-4.12-1.patch:-p1 \
${PATCHDIR}/xsa297-4.12-6.patch:-p1 \
${PATCHDIR}/xsa297-4.12-7.patch:-p1
+# LLD 8 changed the behaviour re the placement of orphaned sections, which
+# produces a non-bootable Xen kernel:
+#
+# https://bugs.llvm.org/show_bug.cgi?id=42327
+#
+# Backport the fixes from upstream
+EXTRA_PATCHES+= ${PATCHDIR}/0001-x86-linker-add-a-reloc-section-to-ELF-linker-script.patch:-p1 \
+ ${PATCHDIR}/0003-xen-link-handle-.init.rodata.cst-sections-in-the-lin.patch:-p1 \
+ ${PATCHDIR}/0004-x86-check-for-multiboot-1-2-header-presence.patch:-p1
+
.include <bsd.port.options.mk>
.if ${OPSYS} != FreeBSD
diff --git a/emulators/xen-kernel/files/0001-x86-linker-add-a-reloc-section-to-ELF-linker-script.patch b/emulators/xen-kernel/files/0001-x86-linker-add-a-reloc-section-to-ELF-linker-script.patch
new file mode 100644
index 000000000000..46fa6110d9c6
--- /dev/null
+++ b/emulators/xen-kernel/files/0001-x86-linker-add-a-reloc-section-to-ELF-linker-script.patch
@@ -0,0 +1,50 @@
+From 597c57becbeba21ff9f0c078ba2e32973d09d258 Mon Sep 17 00:00:00 2001
+From: Roger Pau Monne <roger.pau@citrix.com>
+Date: Thu, 27 Jun 2019 11:33:33 +0200
+Subject: [PATCH 1/4] x86/linker: add a reloc section to ELF linker script
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+if the hypervisor has been built with EFI support (ie: multiboot2).
+This allows to position the .reloc section correctly in the output
+binary.
+
+Note that for the ELF output format the .reloc section is moved before
+.bss because the data it contains is read-only, so it belongs with the
+other sections containing read-only data.
+
+Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
+Acked-by: Jan Beulich <jbeulich@suse.com>
+Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
+---
+ xen/arch/x86/xen.lds.S | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
+index 98a99444c2..cee7cf80dd 100644
+--- a/xen/arch/x86/xen.lds.S
++++ b/xen/arch/x86/xen.lds.S
+@@ -175,6 +175,19 @@ SECTIONS
+ } :text
+ #endif
+ #endif
++
++/*
++ * ELF builds are linked to a fixed virtual address, and in principle
++ * shouldn't have a .reloc section. However, due to the way EFI support is
++ * currently implemented, retaining the .reloc section is necessary.
++ */
++#if defined(XEN_BUILD_EFI) && !defined(EFI)
++ . = ALIGN(4);
++ DECL_SECTION(.reloc) {
++ *(.reloc)
++ } :text
++#endif
++
+ _erodata = .;
+
+ . = ALIGN(SECTION_ALIGN);
+--
+2.20.1 (Apple Git-117)
+
diff --git a/emulators/xen-kernel/files/0003-xen-link-handle-.init.rodata.cst-sections-in-the-lin.patch b/emulators/xen-kernel/files/0003-xen-link-handle-.init.rodata.cst-sections-in-the-lin.patch
new file mode 100644
index 000000000000..51dd1e0d92d2
--- /dev/null
+++ b/emulators/xen-kernel/files/0003-xen-link-handle-.init.rodata.cst-sections-in-the-lin.patch
@@ -0,0 +1,53 @@
+From 874fc28b72fbb49f4f304b9acd3d49afd8326042 Mon Sep 17 00:00:00 2001
+From: Roger Pau Monne <roger.pau@citrix.com>
+Date: Thu, 27 Jun 2019 11:33:34 +0200
+Subject: [PATCH 3/4] xen/link: handle .init.rodata.cst* sections in the linker
+ script
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Note that those sections when not prefixed with .init are already
+handled by the more general .rodata.* matching pattern in the .rodata
+output section.
+
+Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
+Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
+[Make .init.rodata consistent with .rodata]
+Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
+---
+ xen/arch/arm/xen.lds.S | 3 +--
+ xen/arch/x86/xen.lds.S | 3 +--
+ 2 files changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
+index e664c4441a..12c107f45d 100644
+--- a/xen/arch/arm/xen.lds.S
++++ b/xen/arch/arm/xen.lds.S
+@@ -154,8 +154,7 @@ SECTIONS
+ . = ALIGN(PAGE_SIZE);
+ .init.data : {
+ *(.init.rodata)
+- *(.init.rodata.rel)
+- *(.init.rodata.str*)
++ *(.init.rodata.*)
+
+ . = ALIGN(POINTER_ALIGN);
+ __setup_start = .;
+diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
+index cee7cf80dd..a73139cd29 100644
+--- a/xen/arch/x86/xen.lds.S
++++ b/xen/arch/x86/xen.lds.S
+@@ -219,8 +219,7 @@ SECTIONS
+ #endif
+
+ *(.init.rodata)
+- *(.init.rodata.rel)
+- *(.init.rodata.str*)
++ *(.init.rodata.*)
+
+ . = ALIGN(POINTER_ALIGN);
+ __setup_start = .;
+--
+2.20.1 (Apple Git-117)
+
diff --git a/emulators/xen-kernel/files/0004-x86-check-for-multiboot-1-2-header-presence.patch b/emulators/xen-kernel/files/0004-x86-check-for-multiboot-1-2-header-presence.patch
new file mode 100644
index 000000000000..7c6e4eaa659c
--- /dev/null
+++ b/emulators/xen-kernel/files/0004-x86-check-for-multiboot-1-2-header-presence.patch
@@ -0,0 +1,64 @@
+From e632d56f0f5787204ef9b640d5f9153dcd4cb3de Mon Sep 17 00:00:00 2001
+From: Roger Pau Monne <roger.pau@citrix.com>
+Date: Thu, 27 Jun 2019 11:33:35 +0200
+Subject: [PATCH 4/4] x86: check for multiboot{1, 2} header presence
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+After building the hypervisor binary. Note that the check is performed
+by searching for the magic header value at the start of the binary.
+
+Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
+Acked-by: Jan Beulich <jbeulich@suse.com>
+Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
+---
+ .gitignore | 1 +
+ xen/arch/x86/Makefile | 10 ++++++++--
+ 2 files changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/.gitignore b/.gitignore
+index a77cbff02c..8a19c8af04 100644
+--- a/.gitignore
++++ b/.gitignore
+@@ -278,6 +278,7 @@ tools/xentrace/xentrace
+ xen/.banner
+ xen/.config
+ xen/.config.old
++xen/.xen.elf32
+ xen/System.map
+ xen/arch/x86/asm-macros.i
+ xen/arch/x86/boot/mkelf32
+diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
+index 8a8d8f060f..5e3840084b 100644
+--- a/xen/arch/x86/Makefile
++++ b/xen/arch/x86/Makefile
+@@ -99,9 +99,15 @@ endif
+ syms-warn-dup-y := --warn-dup
+ syms-warn-dup-$(CONFIG_SUPPRESS_DUPLICATE_SYMBOL_WARNINGS) :=
+
++$(TARGET): TMP = $(@D)/.$(@F).elf32
+ $(TARGET): $(TARGET)-syms $(efi-y) boot/mkelf32
+- ./boot/mkelf32 $(notes_phdrs) $(TARGET)-syms $(TARGET) $(XEN_IMG_OFFSET) \
++ ./boot/mkelf32 $(notes_phdrs) $(TARGET)-syms $(TMP) $(XEN_IMG_OFFSET) \
+ `$(NM) $(TARGET)-syms | sed -ne 's/^\([^ ]*\) . __2M_rwdata_end$$/0x\1/p'`
++ od -t x4 -N 8192 $(TMP) | grep 1badb002 > /dev/null || \
++ { echo "No Multiboot1 header found" >&2; false; }
++ od -t x4 -N 32768 $(TMP) | grep e85250d6 > /dev/null || \
++ { echo "No Multiboot2 header found" >&2; false; }
++ mv $(TMP) $(TARGET)
+
+ ALL_OBJS := $(BASEDIR)/arch/x86/boot/built_in.o $(BASEDIR)/arch/x86/efi/built_in.o $(ALL_OBJS)
+
+@@ -249,7 +255,7 @@ efi/mkreloc: efi/mkreloc.c
+ clean::
+ rm -f asm-offsets.s *.lds boot/*.o boot/*~ boot/core boot/mkelf32
+ rm -f asm-macros.i $(BASEDIR)/include/asm-x86/asm-macros.*
+- rm -f $(BASEDIR)/.xen-syms.[0-9]* boot/.*.d
++ rm -f $(BASEDIR)/.xen-syms.[0-9]* boot/.*.d $(BASEDIR)/.xen.elf32
+ rm -f $(BASEDIR)/.xen.efi.[0-9]* efi/*.efi efi/mkreloc
+ rm -f boot/cmdline.S boot/reloc.S boot/*.lnk boot/*.bin
+ rm -f note.o
+--
+2.20.1 (Apple Git-117)
+