Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix kexec framebuffer graphics for 5.10 kernel #1378

Merged
Merged
3 changes: 2 additions & 1 deletion config/coreboot-librem_13v2.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ CONFIG_BOARD_PURISM_LIBREM13_V2=y
CONFIG_CPU_MICROCODE_CBFS_EXTERNAL_BINS=y
CONFIG_CPU_UCODE_BINARIES="3rdparty/purism-blobs/mainboard/purism/librem_skl/cpu_microcode_blob.bin"
CONFIG_HAVE_ME_BIN=y
CONFIG_NO_GFX_INIT=y
CONFIG_TPM_MEASURED_BOOT=y
CONFIG_PAYLOAD_LINUX=y
CONFIG_PAYLOAD_FILE="@BOARD_BUILD_DIR@/bzImage"
CONFIG_LINUX_COMMAND_LINE="iommu=pt quiet loglevel=2"
CONFIG_LINUX_COMMAND_LINE="iommu=pt quiet loglevel=2 drm_kms_helper.drm_leak_fbdev_smem=1 i915.enable_fbc=0"
CONFIG_LINUX_INITRD="@BOARD_BUILD_DIR@/initrd.cpio.xz"
3 changes: 2 additions & 1 deletion config/coreboot-librem_13v4.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ CONFIG_BOARD_PURISM_LIBREM13_V4=y
CONFIG_CPU_MICROCODE_CBFS_EXTERNAL_BINS=y
CONFIG_CPU_UCODE_BINARIES="3rdparty/purism-blobs/mainboard/purism/librem_kbl/cpu_microcode_blob.bin"
CONFIG_HAVE_ME_BIN=y
CONFIG_NO_GFX_INIT=y
CONFIG_TPM_MEASURED_BOOT=y
CONFIG_PAYLOAD_LINUX=y
CONFIG_PAYLOAD_FILE="@BOARD_BUILD_DIR@/bzImage"
CONFIG_LINUX_COMMAND_LINE="iommu=pt quiet loglevel=2"
CONFIG_LINUX_COMMAND_LINE="iommu=pt quiet loglevel=2 drm_kms_helper.drm_leak_fbdev_smem=1 i915.enable_fbc=0"
CONFIG_LINUX_INITRD="@BOARD_BUILD_DIR@/initrd.cpio.xz"
3 changes: 2 additions & 1 deletion config/coreboot-librem_14.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ CONFIG_BOARD_PURISM_LIBREM_14=y
CONFIG_CPU_MICROCODE_CBFS_EXTERNAL_BINS=y
CONFIG_CPU_UCODE_BINARIES="3rdparty/purism-blobs/mainboard/purism/librem_cnl/cpu_microcode_blob.bin"
CONFIG_HAVE_ME_BIN=y
CONFIG_NO_GFX_INIT=y
CONFIG_TPM_MEASURED_BOOT=y
CONFIG_PAYLOAD_LINUX=y
CONFIG_PAYLOAD_FILE="@BOARD_BUILD_DIR@/bzImage"
CONFIG_LINUX_INITRD="@BOARD_BUILD_DIR@/initrd.cpio.xz"
CONFIG_LINUX_COMMAND_LINE="intel_iommu=igfx_off quiet loglevel=2"
CONFIG_LINUX_COMMAND_LINE="intel_iommu=igfx_off quiet loglevel=2 drm_kms_helper.drm_leak_fbdev_smem=1 i915.enable_fbc=0"
3 changes: 2 additions & 1 deletion config/coreboot-librem_15v3.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ CONFIG_BOARD_PURISM_LIBREM15_V3=y
CONFIG_CPU_MICROCODE_CBFS_EXTERNAL_BINS=y
CONFIG_CPU_UCODE_BINARIES="3rdparty/purism-blobs/mainboard/purism/librem_skl/cpu_microcode_blob.bin"
CONFIG_HAVE_ME_BIN=y
CONFIG_NO_GFX_INIT=y
CONFIG_TPM_MEASURED_BOOT=y
CONFIG_PAYLOAD_LINUX=y
CONFIG_PAYLOAD_FILE="@BOARD_BUILD_DIR@/bzImage"
CONFIG_LINUX_COMMAND_LINE="iommu=pt quiet loglevel=2"
CONFIG_LINUX_COMMAND_LINE="iommu=pt quiet loglevel=2 drm_kms_helper.drm_leak_fbdev_smem=1 i915.enable_fbc=0"
CONFIG_LINUX_INITRD="@BOARD_BUILD_DIR@/initrd.cpio.xz"
3 changes: 2 additions & 1 deletion config/coreboot-librem_15v4.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ CONFIG_BOARD_PURISM_LIBREM15_V4=y
CONFIG_CPU_MICROCODE_CBFS_EXTERNAL_BINS=y
CONFIG_CPU_UCODE_BINARIES="3rdparty/purism-blobs/mainboard/purism/librem_kbl/cpu_microcode_blob.bin"
CONFIG_HAVE_ME_BIN=y
CONFIG_NO_GFX_INIT=y
CONFIG_TPM_MEASURED_BOOT=y
CONFIG_PAYLOAD_LINUX=y
CONFIG_PAYLOAD_FILE="@BOARD_BUILD_DIR@/bzImage"
CONFIG_LINUX_COMMAND_LINE="iommu=pt quiet loglevel=2 video=eDP-1:1920x1080"
CONFIG_LINUX_COMMAND_LINE="iommu=pt quiet loglevel=2 video=eDP-1:1920x1080 drm_kms_helper.drm_leak_fbdev_smem=1 i915.enable_fbc=0"
CONFIG_LINUX_INITRD="@BOARD_BUILD_DIR@/initrd.cpio.xz"
3 changes: 2 additions & 1 deletion config/coreboot-librem_mini.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ CONFIG_BOARD_PURISM_LIBREM_MINI=y
CONFIG_CPU_MICROCODE_CBFS_EXTERNAL_BINS=y
CONFIG_CPU_UCODE_BINARIES="3rdparty/purism-blobs/mainboard/purism/librem_cnl/cpu_microcode_blob.bin"
CONFIG_HAVE_ME_BIN=y
CONFIG_NO_GFX_INIT=y
CONFIG_PAYLOAD_LINUX=y
CONFIG_PAYLOAD_FILE="@BOARD_BUILD_DIR@/bzImage"
CONFIG_LINUX_INITRD="@BOARD_BUILD_DIR@/initrd.cpio.xz"
CONFIG_LINUX_COMMAND_LINE="intel_iommu=igfx_off quiet loglevel=2"
CONFIG_LINUX_COMMAND_LINE="intel_iommu=igfx_off quiet loglevel=2 drm_kms_helper.drm_leak_fbdev_smem=1 i915.enable_fbc=0"
3 changes: 2 additions & 1 deletion config/coreboot-librem_mini_v2.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ CONFIG_BOARD_PURISM_LIBREM_MINI_V2=y
CONFIG_CPU_MICROCODE_CBFS_EXTERNAL_BINS=y
CONFIG_CPU_UCODE_BINARIES="3rdparty/purism-blobs/mainboard/purism/librem_cnl/cpu_microcode_blob.bin"
CONFIG_HAVE_ME_BIN=y
CONFIG_NO_GFX_INIT=y
CONFIG_PAYLOAD_LINUX=y
CONFIG_PAYLOAD_FILE="@BOARD_BUILD_DIR@/bzImage"
CONFIG_LINUX_INITRD="@BOARD_BUILD_DIR@/initrd.cpio.xz"
CONFIG_LINUX_COMMAND_LINE="intel_iommu=igfx_off quiet loglevel=2"
CONFIG_LINUX_COMMAND_LINE="intel_iommu=igfx_off quiet loglevel=2 drm_kms_helper.drm_leak_fbdev_smem=1 i915.enable_fbc=0"
3 changes: 2 additions & 1 deletion config/coreboot-t440p.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ CONFIG_ME_BIN_PATH="@BLOB_DIR@/t440p/me.bin"
CONFIG_GBE_BIN_PATH="@BLOB_DIR@/t440p/gbe.bin"
CONFIG_HAVE_IFD_BIN=y
CONFIG_BOARD_LENOVO_THINKPAD_T440P=y
CONFIG_LINUX_COMMAND_LINE="intel_iommu=igfx_off"
CONFIG_LINUX_COMMAND_LINE="intel_iommu=igfx_off drm_kms_helper.drm_leak_fbdev_smem=1 i915.enable_fbc=0"
CONFIG_TPM_MEASURED_BOOT=y
CONFIG_HAVE_MRC=y
CONFIG_MRC_FILE="@BLOB_DIR@/haswell/mrc.bin"
CONFIG_HAVE_ME_BIN=y
CONFIG_HAVE_GBE_BIN=y
CONFIG_NO_GFX_INIT=y
CONFIG_PAYLOAD_LINUX=y
CONFIG_PAYLOAD_FILE="@BOARD_BUILD_DIR@/bzImage"
CONFIG_LINUX_INITRD="@BOARD_BUILD_DIR@/initrd.cpio.xz"
1 change: 1 addition & 0 deletions config/linux-librem_common.config
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ CONFIG_I2C_SLAVE=y
# CONFIG_X86_PKG_TEMP_THERMAL is not set
CONFIG_MFD_SYSCON=y
CONFIG_DRM=y
CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM=y
CONFIG_DRM_I915=y
CONFIG_DRM_AST=y
CONFIG_FB_VESA=y
Expand Down
1 change: 1 addition & 0 deletions config/linux-t440p.config
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ CONFIG_I2C_SLAVE=y
# CONFIG_X86_PKG_TEMP_THERMAL is not set
CONFIG_MFD_SYSCON=y
CONFIG_DRM=y
CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM=y
CONFIG_DRM_I915=y
CONFIG_DRM_AST=y
CONFIG_FB_VESA=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.22
kexec_version := 2.0.26
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 := 40623d4321be2865ef9ea2cd6ec998d31dcf93d0f74353cbd3aa06d8821e3e41
kexec_hash := 89bdd941542c64fec16311858df304ed3a3908c1a60874d69df5d9bf1611e062

kexec_configure := \
CFLAGS="-g -Os -fno-strict-aliasing -Wall -Wstrict-prototypes" \
Expand Down
90 changes: 0 additions & 90 deletions patches/kexec-2.0.22.patch

This file was deleted.

161 changes: 161 additions & 0 deletions patches/kexec-2.0.26.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
diff --git a/Makefile.in b/Makefile.in
index 09bbd5c..500ad35 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -167,12 +167,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 14263b0..55291d6 100644
--- a/kexec/arch/i386/x86-linux-setup.c
+++ b/kexec/arch/i386/x86-linux-setup.c
@@ -138,31 +138,76 @@ static int setup_linux_vesafb(struct x86_linux_param_header *real_mode)
if (-1 == fd)
return -1;

- if (-1 == ioctl(fd, FBIOGET_FSCREENINFO, &fix))
+ if (-1 == ioctl(fd, FBIOGET_FSCREENINFO, &fix)) {
+ dbgprintf("%s: FBIOGET_FSCREENINFO failed, can't provide framebuffer\n",
+ __func__);
goto out;
- if (-1 == ioctl(fd, FBIOGET_VSCREENINFO, &var))
+ }
+ if (-1 == ioctl(fd, FBIOGET_VSCREENINFO, &var)) {
+ dbgprintf("%s: FBIOGET_FSCREENINFO failed, can't provide framebuffer\n",
+ __func__);
goto out;
- if (0 == strcmp(fix.id, "VESA VGA")) {
+ }
+ /*
+ * If we can get a framebuffer from the host kernel, provide it to the
+ * target kernel. This does not work for all drivers - we have to be
+ * able to get the framebuffer address, and the framebuffer must be a
+ * plain flat framebuffer. This should work for VESA framebuffers
+ * since that is the only type of framebuffer it creates.
+ *
+ * Since Linux 4.20, getting the framebuffer address requires
+ * CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM and
+ * drm_kms_helper.drm_leak_fbdev_smem=1 on the command line.
+ *
+ * Since Linux 5.8, i915 often uses a compressed framebuffer, this must
+ * be disabled with i915.enable_fbc=0 on the kernel command line.
+ *
+ * This does not work with ast ("astdrmfb") currently as it uses a
+ * shadow buffer internally in the kernel, and there is no way to get
+ * the real framebuffer address.
+ */
+ if (0 == strcmp(fix.id, "VESA VGA")
+ || 0 == strcmp(fix.id, "inteldrmfb")
+ || 0 == strcmp(fix.id, "i915drmfb")) {
/* VIDEO_TYPE_VLFB */
real_mode->orig_video_isVGA = 0x23;
+ dbgprintf("%s: Found driver %s, providing VIDEO_TYPE_VLFB\n",
+ __func__, fix.id);
} else if (0 == strcmp(fix.id, "EFI VGA")) {
/* VIDEO_TYPE_EFI */
real_mode->orig_video_isVGA = 0x70;
+ dbgprintf("%s: Found driver %s, providing VIDEO_TYPE_EFI\n",
+ __func__, fix.id);
} else if (arch_options.reuse_video_type) {
int err;
off_t offset = offsetof(typeof(*real_mode), orig_video_isVGA);

/* blindly try old boot time video type */
err = get_bootparam(&real_mode->orig_video_isVGA, offset, 1);
- if (err)
+ if (err) {
+ dbgprintf("%s: Can't get booted video type, can't provide framebuffer\n",
+ __func__);
goto out;
+ }
+ dbgprintf("%s: Reusing video type %d\n",
+ __func__, real_mode->orig_video_isVGA);
} else {
+ dbgprintf("%s: Unknown driver %s, can't provide framebuffer\n",
+ __func__, fix.id);
real_mode->orig_video_isVGA = 0;
close(fd);
return 0;
}
close(fd);

+ if (!fix.smem_start) {
+ dbgprintf("%s: Kernel did not provide framebuffer address\n",
+ __func__);
+ dbgprintf("%s: Try enabling CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM and "
+ "drm_kms_helper.drm_leak_fbdev_smem\n",
+ __func__);
+ }
+
real_mode->lfb_width = var.xres;
real_mode->lfb_height = var.yres;
real_mode->lfb_depth = var.bits_per_pixel;
diff --git a/kexec/kexec.c b/kexec/kexec.c
index 0e92d96..f7984a8 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -807,6 +807,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 4d2d071..ee5c642 100644
--- a/purgatory/Makefile
+++ b/purgatory/Makefile
@@ -45,7 +45,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)