Skip to content

Commit 353e836

Browse files
kexec: Update to 2.0.26, add framebuffer tracing
Update kexec to 2.0.26. Add tracing to framebuffer initialization. In particular, the driver name is traced if not recognized, and messages about kernel config are shown if the kernel doesn't provide the framebuffer pointer. Signed-off-by: Jonathon Hall <[email protected]>
1 parent a75ecdf commit 353e836

File tree

3 files changed

+163
-93
lines changed

3 files changed

+163
-93
lines changed

modules/kexec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
modules-$(CONFIG_KEXEC) += kexec
22

3-
kexec_version := 2.0.22
3+
kexec_version := 2.0.26
44
kexec_dir := kexec-tools-$(kexec_version)
55
kexec_tar := kexec-tools-$(kexec_version).tar.gz
66
kexec_url := https://kernel.org/pub/linux/utils/kernel/kexec/$(kexec_tar)
7-
kexec_hash := 40623d4321be2865ef9ea2cd6ec998d31dcf93d0f74353cbd3aa06d8821e3e41
7+
kexec_hash := 89bdd941542c64fec16311858df304ed3a3908c1a60874d69df5d9bf1611e062
88

99
kexec_configure := \
1010
CFLAGS="-g -Os -fno-strict-aliasing -Wall -Wstrict-prototypes" \

patches/kexec-2.0.22.patch

Lines changed: 0 additions & 91 deletions
This file was deleted.

patches/kexec-2.0.26.patch

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
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

Comments
 (0)