|
| 1 | +diff --git a/Makefile.in b/Makefile.in |
| 2 | +index 09bbd5c..500ad35 100644 |
| 3 | +--- a/Makefile.in |
| 4 | ++++ b/Makefile.in |
| 5 | +@@ -167,12 +167,12 @@ include $(srcdir)/kexec/Makefile |
| 6 | + |
| 7 | + # vmcore-dmesg (read dmesg from a vmcore) |
| 8 | + # |
| 9 | +-include $(srcdir)/vmcore-dmesg/Makefile |
| 10 | ++#include $(srcdir)/vmcore-dmesg/Makefile |
| 11 | + |
| 12 | + # |
| 13 | + # kexec_test (test program) |
| 14 | + # |
| 15 | +-include $(srcdir)/kexec_test/Makefile |
| 16 | ++#include $(srcdir)/kexec_test/Makefile |
| 17 | + |
| 18 | + SPEC=$(PACKAGE_NAME).spec |
| 19 | + GENERATED_SRCS:= $(SPEC) |
| 20 | +diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c |
| 21 | +index 14263b0..55291d6 100644 |
| 22 | +--- a/kexec/arch/i386/x86-linux-setup.c |
| 23 | ++++ b/kexec/arch/i386/x86-linux-setup.c |
| 24 | +@@ -138,31 +138,76 @@ static int setup_linux_vesafb(struct x86_linux_param_header *real_mode) |
| 25 | + if (-1 == fd) |
| 26 | + return -1; |
| 27 | + |
| 28 | +- if (-1 == ioctl(fd, FBIOGET_FSCREENINFO, &fix)) |
| 29 | ++ if (-1 == ioctl(fd, FBIOGET_FSCREENINFO, &fix)) { |
| 30 | ++ dbgprintf("%s: FBIOGET_FSCREENINFO failed, can't provide framebuffer\n", |
| 31 | ++ __func__); |
| 32 | + goto out; |
| 33 | +- if (-1 == ioctl(fd, FBIOGET_VSCREENINFO, &var)) |
| 34 | ++ } |
| 35 | ++ if (-1 == ioctl(fd, FBIOGET_VSCREENINFO, &var)) { |
| 36 | ++ dbgprintf("%s: FBIOGET_FSCREENINFO failed, can't provide framebuffer\n", |
| 37 | ++ __func__); |
| 38 | + goto out; |
| 39 | +- if (0 == strcmp(fix.id, "VESA VGA")) { |
| 40 | ++ } |
| 41 | ++ /* |
| 42 | ++ * If we can get a framebuffer from the host kernel, provide it to the |
| 43 | ++ * target kernel. This does not work for all drivers - we have to be |
| 44 | ++ * able to get the framebuffer address, and the framebuffer must be a |
| 45 | ++ * plain flat framebuffer. This should work for VESA framebuffers |
| 46 | ++ * since that is the only type of framebuffer it creates. |
| 47 | ++ * |
| 48 | ++ * Since Linux 4.20, getting the framebuffer address requires |
| 49 | ++ * CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM and |
| 50 | ++ * drm_kms_helper.drm_leak_fbdev_smem=1 on the command line. |
| 51 | ++ * |
| 52 | ++ * Since Linux 5.8, i915 often uses a compressed framebuffer, this must |
| 53 | ++ * be disabled with i915.enable_fbc=0 on the kernel command line. |
| 54 | ++ * |
| 55 | ++ * This does not work with ast ("astdrmfb") currently as it uses a |
| 56 | ++ * shadow buffer internally in the kernel, and there is no way to get |
| 57 | ++ * the real framebuffer address. |
| 58 | ++ */ |
| 59 | ++ if (0 == strcmp(fix.id, "VESA VGA") |
| 60 | ++ || 0 == strcmp(fix.id, "inteldrmfb") |
| 61 | ++ || 0 == strcmp(fix.id, "i915drmfb")) { |
| 62 | + /* VIDEO_TYPE_VLFB */ |
| 63 | + real_mode->orig_video_isVGA = 0x23; |
| 64 | ++ dbgprintf("%s: Found driver %s, providing VIDEO_TYPE_VLFB\n", |
| 65 | ++ __func__, fix.id); |
| 66 | + } else if (0 == strcmp(fix.id, "EFI VGA")) { |
| 67 | + /* VIDEO_TYPE_EFI */ |
| 68 | + real_mode->orig_video_isVGA = 0x70; |
| 69 | ++ dbgprintf("%s: Found driver %s, providing VIDEO_TYPE_EFI\n", |
| 70 | ++ __func__, fix.id); |
| 71 | + } else if (arch_options.reuse_video_type) { |
| 72 | + int err; |
| 73 | + off_t offset = offsetof(typeof(*real_mode), orig_video_isVGA); |
| 74 | + |
| 75 | + /* blindly try old boot time video type */ |
| 76 | + err = get_bootparam(&real_mode->orig_video_isVGA, offset, 1); |
| 77 | +- if (err) |
| 78 | ++ if (err) { |
| 79 | ++ dbgprintf("%s: Can't get booted video type, can't provide framebuffer\n", |
| 80 | ++ __func__); |
| 81 | + goto out; |
| 82 | ++ } |
| 83 | ++ dbgprintf("%s: Reusing video type %d\n", |
| 84 | ++ __func__, real_mode->orig_video_isVGA); |
| 85 | + } else { |
| 86 | ++ dbgprintf("%s: Unknown driver %s, can't provide framebuffer\n", |
| 87 | ++ __func__, fix.id); |
| 88 | + real_mode->orig_video_isVGA = 0; |
| 89 | + close(fd); |
| 90 | + return 0; |
| 91 | + } |
| 92 | + close(fd); |
| 93 | + |
| 94 | ++ if (!fix.smem_start) { |
| 95 | ++ dbgprintf("%s: Kernel did not provide framebuffer address\n", |
| 96 | ++ __func__); |
| 97 | ++ dbgprintf("%s: Try enabling CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM and " |
| 98 | ++ "drm_kms_helper.drm_leak_fbdev_smem\n", |
| 99 | ++ __func__); |
| 100 | ++ } |
| 101 | ++ |
| 102 | + real_mode->lfb_width = var.xres; |
| 103 | + real_mode->lfb_height = var.yres; |
| 104 | + real_mode->lfb_depth = var.bits_per_pixel; |
| 105 | +diff --git a/kexec/kexec.c b/kexec/kexec.c |
| 106 | +index 0e92d96..f7984a8 100644 |
| 107 | +--- a/kexec/kexec.c |
| 108 | ++++ b/kexec/kexec.c |
| 109 | +@@ -807,6 +807,27 @@ static int my_load(const char *type, int fileind, int argc, char **argv, |
| 110 | + if (sort_segments(&info) < 0) { |
| 111 | + return -1; |
| 112 | + } |
| 113 | ++ |
| 114 | ++#if 1 |
| 115 | ++ // force segment 0 to have memsz == bufsz |
| 116 | ++ // so that it won't overwrite EBDA |
| 117 | ++ if (info.segment[0].mem == 0) |
| 118 | ++ { |
| 119 | ++ if (kexec_debug) |
| 120 | ++ printf("hack ebda into segment 0!\n"); |
| 121 | ++ |
| 122 | ++ uint8_t * ebda = calloc(1, info.segment[0].memsz); |
| 123 | ++ memcpy(ebda, info.segment[0].buf, info.segment[0].bufsz); |
| 124 | ++ info.segment[0].bufsz = info.segment[0].memsz; |
| 125 | ++ info.segment[0].buf = ebda; |
| 126 | ++ |
| 127 | ++ // install some default EBDA values that are off scale, |
| 128 | ++ // which will force Xen to use the multiboot info |
| 129 | ++ *(uint16_t*)(ebda + 0x40e) = 0xFFFF; // segment |
| 130 | ++ *(uint16_t*)(ebda + 0x413) = 0xFFFF; // size |
| 131 | ++ } |
| 132 | ++#endif |
| 133 | ++ |
| 134 | + /* if purgatory is loaded update it */ |
| 135 | + update_purgatory(&info); |
| 136 | + if (entry) |
| 137 | +diff --git a/purgatory/Makefile b/purgatory/Makefile |
| 138 | +index 4d2d071..ee5c642 100644 |
| 139 | +--- a/purgatory/Makefile |
| 140 | ++++ b/purgatory/Makefile |
| 141 | +@@ -45,7 +45,6 @@ purgatory/sha256.o: $(srcdir)/util_lib/sha256.c |
| 142 | + mkdir -p $(@D) |
| 143 | + $(COMPILE.c) -o $@ $^ |
| 144 | + |
| 145 | +-$(PURGATORY): CC=$(TARGET_CC) |
| 146 | + $(PURGATORY): CFLAGS=$(PURGATORY_EXTRA_CFLAGS) \ |
| 147 | + $($(ARCH)_PURGATORY_EXTRA_CFLAGS) \ |
| 148 | + -Os -fno-builtin -ffreestanding \ |
| 149 | +diff --git a/util/Makefile b/util/Makefile |
| 150 | +index 948ee63..833a897 100644 |
| 151 | +--- a/util/Makefile |
| 152 | ++++ b/util/Makefile |
| 153 | +@@ -2,7 +2,7 @@ BIN_TO_HEX:= bin/bin-to-hex |
| 154 | + |
| 155 | + $(BIN_TO_HEX): $(srcdir)/util/bin-to-hex.c |
| 156 | + @$(MKDIR) -p $(@D) |
| 157 | +- $(LINK.o) $(CFLAGS) -o $@ $^ |
| 158 | ++ $(BUILD_CC) $(BUILD_CFLAGS) -o $@ $^ |
| 159 | + |
| 160 | + $(BIN_TO_HEX): CC=$(BUILD_CC) |
| 161 | + $(BIN_TO_HEX): CFLAGS=$(BUILD_CFLAGS) |
0 commit comments