heads/patches/kexec-2.0.20.patch
alex-nitrokey 83cac9ed14
Fix kexec to work with Debian Installer (fixes )
This patch was reported by @bemoody in issue 

Tested via `BOARD=x230-hotp-verification` on a Thinkpad x230

Signed-off-by: alex-nitrokey <alex@nitrokey.com>
2020-07-30 22:11:05 +02:00

91 lines
2.7 KiB
Diff

diff --git a/Makefile.in b/Makefile.in
index fb01134..bf1973e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -157,12 +157,12 @@ include $(srcdir)/kexec/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 --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c
index 057ee14..43e017a 100644
--- a/kexec/arch/i386/x86-linux-setup.c
+++ b/kexec/arch/i386/x86-linux-setup.c
@@ -137,7 +137,8 @@ static int setup_linux_vesafb(struct x86_linux_param_header *real_mode)
goto out;
if (-1 == ioctl(fd, FBIOGET_VSCREENINFO, &var))
goto out;
- if (0 == strcmp(fix.id, "VESA VGA")) {
+ if (0 == strcmp(fix.id, "VESA VGA")
+ || 0 == strcmp(fix.id, "inteldrmfb")) {
/* VIDEO_TYPE_VLFB */
real_mode->orig_video_isVGA = 0x23;
} else if (0 == strcmp(fix.id, "EFI VGA")) {
diff --git a/kexec/kexec.c b/kexec/kexec.c
index bc6ab3d..b82725b 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -805,6 +805,27 @@ static int my_load(const char *type, int fileind, int argc, char **argv,
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 --git a/purgatory/Makefile b/purgatory/Makefile
index 2dd6c47..2de8f07 100644
--- a/purgatory/Makefile
+++ b/purgatory/Makefile
@@ -44,7 +44,6 @@ purgatory/sha256.o: $(srcdir)/util_lib/sha256.c
mkdir -p $(@D)
$(COMPILE.c) -o $@ $^
-$(PURGATORY): CC=$(TARGET_CC)
$(PURGATORY): CFLAGS=$(PURGATORY_EXTRA_CFLAGS) \
$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
-Os -fno-builtin -ffreestanding \
diff --git a/util/Makefile b/util/Makefile
index 948ee63..833a897 100644
--- a/util/Makefile
+++ b/util/Makefile
@@ -2,7 +2,7 @@ BIN_TO_HEX:= bin/bin-to-hex
$(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)