Skip to content

Commit

Permalink
Generate a fake EBDA with kexec, removing the need for a custom xen (#…
Browse files Browse the repository at this point in the history
…227)

This modifies the segment at 0x0 so that it contains enough of a fake
Extended BIOS Data Area at addresses 0x40e and 0x413 that Xen can
correctly locate its trampoline code.

Since custom Xen is no longer required, we can remove the module,
the patches and all of the references to it in the board definition
files.
  • Loading branch information
osresearch committed Feb 28, 2018
1 parent 2facd55 commit f618f09
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 418 deletions.
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ bin_modules-$(CONFIG_FLASHROM) += flashrom
bin_modules-$(CONFIG_CRYPTSETUP) += cryptsetup
bin_modules-$(CONFIG_GPG) += gpg
bin_modules-$(CONFIG_LVM2) += lvm2
bin_modules-$(CONFIG_XEN) += xen
bin_modules-$(CONFIG_DROPBEAR) += dropbear
bin_modules-$(CONFIG_FLASHTOOLS) += flashtools
bin_modules-$(CONFIG_NEWT) += newt
Expand All @@ -339,8 +338,6 @@ $(foreach m, $(modules-y), \
$(call map,initrd_lib_add,$(call libs,$m)) \
)

#$(foreach _, $(call outputs,xen), $(eval $(call initrd_bin,$_)))

# hack to install busybox into the initrd
$(build)/$(BOARD)/heads.cpio: busybox.intermediate
initrd_bins += $(initrd_bin_dir)/busybox
Expand Down
1 change: 0 additions & 1 deletion boards/r630.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ CONFIG_PCIUTILS=y
CONFIG_POPT=y
CONFIG_QRENCODE=y
CONFIG_TPMTOTP=y
#CONFIG_XEN=y
CONFIG_DROPBEAR=y

CONFIG_LINUX_USB=y
Expand Down
1 change: 0 additions & 1 deletion boards/s2600wf.config
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ CONFIG_PCIUTILS=y
#CONFIG_POPT=y
#CONFIG_QRENCODE=y
#CONFIG_TPMTOTP=y
#CONFIG_XEN=y
CONFIG_DROPBEAR=y

CONFIG_LINUX_USB=y
Expand Down
1 change: 0 additions & 1 deletion boards/winterfell.config
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ CONFIG_PCIUTILS=y
CONFIG_POPT=y
#CONFIG_QRENCODE=y
#CONFIG_TPMTOTP=y
CONFIG_XEN=y
CONFIG_DROPBEAR=y
endif

Expand Down
2 changes: 0 additions & 2 deletions boards/x220.config
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ CONFIG_PCIUTILS=y
CONFIG_POPT=y
CONFIG_QRENCODE=y
CONFIG_TPMTOTP=y
CONFIG_XEN=y
CONFIG_XEN_VERSION=4.6
CONFIG_DROPBEAR=y

CONFIG_LINUX_USB=y
Expand Down
2 changes: 0 additions & 2 deletions boards/x230.config
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ CONFIG_PCIUTILS=y
CONFIG_POPT=y
CONFIG_QRENCODE=y
CONFIG_TPMTOTP=y
CONFIG_XEN=y
CONFIG_XEN_VERSION=4.8
CONFIG_DROPBEAR=y

CONFIG_LINUX_USB=y
Expand Down
4 changes: 2 additions & 2 deletions modules/kexec
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
modules-$(CONFIG_KEXEC) += kexec

kexec_version := 2.0.12
kexec_version := 2.0.16
kexec_dir := kexec-tools-$(kexec_version)
kexec_tar := kexec-tools-$(kexec_version).tar.gz
kexec_url := https://kernel.org/pub/linux/utils/kernel/kexec/$(kexec_tar)
kexec_hash := cc7b60dad0da202004048a6179d8a53606943062dd627a2edba45a8ea3a85135
kexec_hash := cf17fc99bf77c9b39f06ee88ac0e86d0349c4a0c3f8214a3cc78eece872f6f3a

kexec_configure := ./configure \
$(CROSS_TOOLS) \
Expand Down
34 changes: 0 additions & 34 deletions modules/xen

This file was deleted.

102 changes: 0 additions & 102 deletions patches/kexec-2.0.12.patch

This file was deleted.

89 changes: 89 additions & 0 deletions patches/kexec-2.0.16.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
diff -u --recursive clean/kexec-tools-2.0.16/Makefile.in kexec-tools-2.0.16/Makefile.in
--- clean/kexec-tools-2.0.16/Makefile.in 2016-12-09 04:42:06.000000000 -0500
+++ kexec-tools-2.0.16/Makefile.in 2018-02-28 05:39:20.461000000 -0500
@@ -158,16 +158,16 @@

# kdump (read a crashdump from memory)
#
-include $(srcdir)/kdump/Makefile
+#include $(srcdir)/kdump/Makefile

# vmcore-dmesg (read dmesg from a vmcore)
#
-include $(srcdir)/vmcore-dmesg/Makefile
+#include $(srcdir)/vmcore-dmesg/Makefile

#
# kexec_test (test program)
#
-include $(srcdir)/kexec_test/Makefile
+#include $(srcdir)/kexec_test/Makefile

SPEC=$(PACKAGE_NAME).spec
GENERATED_SRCS:= $(SPEC)
diff -u --recursive clean/kexec-tools-2.0.16/include/config.h kexec-tools-2.0.16/include/config.h
--- clean/kexec-tools-2.0.16/include/config.h 2017-11-20 04:17:12.000000000 -0500
+++ kexec-tools-2.0.16/include/config.h 2018-02-28 05:39:22.420000000 -0500
@@ -17,7 +17,7 @@
/* #undef HAVE_LIBXENCTRL */

/* Define to 1 if you have the `z' library (-lz). */
-/* #undef HAVE_LIBZ */
+#define HAVE_LIBZ 1

/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
diff -u --recursive clean/kexec-tools-2.0.16/kexec/kexec.c kexec-tools-2.0.16/kexec/kexec.c
--- clean/kexec-tools-2.0.16/kexec/kexec.c 2017-03-02 04:45:46.000000000 -0500
+++ kexec-tools-2.0.16/kexec/kexec.c 2018-02-28 10:40:01.662000000 -0500
@@ -794,6 +794,27 @@
if (sort_segments(&info) < 0) {
return -1;
}
+
+#if 1
+ // force segment 0 to have memsz == bufsz
+ // so that it won't overwrite EBDA
+ if (info.segment[0].mem == 0)
+ {
+ if (kexec_debug)
+ printf("hack ebda into segment 0!\n");
+
+ uint8_t * ebda = calloc(1, info.segment[0].memsz);
+ memcpy(ebda, info.segment[0].buf, info.segment[0].bufsz);
+ info.segment[0].bufsz = info.segment[0].memsz;
+ info.segment[0].buf = ebda;
+
+ // install some default EBDA values that are off scale,
+ // which will force Xen to use the multiboot info
+ *(uint16_t*)(ebda + 0x40e) = 0xFFFF; // segment
+ *(uint16_t*)(ebda + 0x413) = 0xFFFF; // size
+ }
+#endif
+
/* if purgatory is loaded update it */
update_purgatory(&info);
if (entry)
diff -u --recursive clean/kexec-tools-2.0.16/purgatory/Makefile kexec-tools-2.0.16/purgatory/Makefile
--- clean/kexec-tools-2.0.16/purgatory/Makefile 2017-01-31 06:23:48.000000000 -0500
+++ kexec-tools-2.0.16/purgatory/Makefile 2018-02-28 05:39:20.461000000 -0500
@@ -44,7 +44,6 @@
mkdir -p $(@D)
$(COMPILE.c) -o $@ $^

-$(PURGATORY): CC=$(TARGET_CC)
$(PURGATORY): CFLAGS+=$(PURGATORY_EXTRA_CFLAGS) \
$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
-Os -fno-builtin -ffreestanding \
diff -u --recursive clean/kexec-tools-2.0.16/util/Makefile kexec-tools-2.0.16/util/Makefile
--- clean/kexec-tools-2.0.16/util/Makefile 2010-07-29 05:22:16.000000000 -0400
+++ kexec-tools-2.0.16/util/Makefile 2018-02-28 05:39:20.461000000 -0500
@@ -2,7 +2,7 @@

$(BIN_TO_HEX): $(srcdir)/util/bin-to-hex.c
@$(MKDIR) -p $(@D)
- $(LINK.o) $(CFLAGS) -o $@ $^
+ $(BUILD_CC) $(BUILD_CFLAGS) -o $@ $^

$(BIN_TO_HEX): CC=$(BUILD_CC)
$(BIN_TO_HEX): CFLAGS=$(BUILD_CFLAGS)
Loading

0 comments on commit f618f09

Please sign in to comment.