From abbc1b5dd8aa0ebb52149ecfc8ae74605a383a1a Mon Sep 17 00:00:00 2001 From: Jonathon Hall Date: Tue, 18 Apr 2023 13:17:18 -0400 Subject: [PATCH 1/7] linux: Allow kexec in userspace to get framebuffer address kexec(8) needs to get the framebuffer address in order to set up the new kernel's boot parameters. This is one of the reasons that using a >4.20 kernel in Heads prevents framebuffer graphics from working in the OS kernel. Linux 4.20 started hiding this address from userspace, because userspace is not supposed to need physical memory addresses. A workaround was added to keep leaking the address, apparently for some proprietary userspace OpenGL drivers. This requires both a Kconfig and a kernel parameter. This commit enables the Kconfig on the librem_common config, and the kernel parameter on the librem_15v4 (where I'm testing this). We will need to enable it on other >4.20 configs/boards as well. Signed-off-by: Jonathon Hall --- config/coreboot-librem_15v4.config | 2 +- config/linux-librem_common.config | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/config/coreboot-librem_15v4.config b/config/coreboot-librem_15v4.config index f58758c28..97310604c 100644 --- a/config/coreboot-librem_15v4.config +++ b/config/coreboot-librem_15v4.config @@ -9,5 +9,5 @@ CONFIG_HAVE_ME_BIN=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" CONFIG_LINUX_INITRD="@BOARD_BUILD_DIR@/initrd.cpio.xz" diff --git a/config/linux-librem_common.config b/config/linux-librem_common.config index 00814567d..d00300624 100644 --- a/config/linux-librem_common.config +++ b/config/linux-librem_common.config @@ -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 From 13a3cee0e5f24990a8c6e769d7bd7aac0cd80150 Mon Sep 17 00:00:00 2001 From: Jonathon Hall Date: Tue, 18 Apr 2023 13:29:38 -0400 Subject: [PATCH 2/7] kexec: Add new i915 driver ID The i915 driver's ID changed again, now to i915drmfb. It's unclear why kexec checks this, it seems it could populate the target kernel's framebuffer info as long as it knows enough about the host kernel's framebuffer, which it already checks. Maybe we could improve this, for now just add the new ID again. Signed-off-by: Jonathon Hall --- patches/kexec-2.0.22.patch | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/patches/kexec-2.0.22.patch b/patches/kexec-2.0.22.patch index c16cda1b6..38dd525af 100644 --- a/patches/kexec-2.0.22.patch +++ b/patches/kexec-2.0.22.patch @@ -21,13 +21,14 @@ diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup 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) +@@ -137,7 +137,9 @@ 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")) { ++ || 0 == strcmp(fix.id, "inteldrmfb") ++ || 0 == strcmp(fix.id, "i915drmfb")) { /* VIDEO_TYPE_VLFB */ real_mode->orig_video_isVGA = 0x23; } else if (0 == strcmp(fix.id, "EFI VGA")) { From 2a2279b587d83de9ce085a5cef275238ba78acaa Mon Sep 17 00:00:00 2001 From: Jonathon Hall Date: Tue, 18 Apr 2023 17:00:03 -0400 Subject: [PATCH 3/7] librem_15v4: Disable i915 compressed framebuffer Compressed framebuffer requires the driver to track updates to the framebuffer from the CPU and update the compressed framebuffer. This doesn't work if we kexec into an OS that will use the linear framebuffer, so disable it. (The OS kernel can still use compressed framebuffer if it has i915.) Linux 5.8 enabled compressed framebuffer on more chipsets using i915, which is why this stopped working. memtest86+ and Debian (manually blacklisted i915, comparable to netinst) now boot correctly on Librem 15v4. This will need to be enabled for other boards too. Signed-off-by: Jonathon Hall --- config/coreboot-librem_15v4.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/coreboot-librem_15v4.config b/config/coreboot-librem_15v4.config index 97310604c..3255bc5a5 100644 --- a/config/coreboot-librem_15v4.config +++ b/config/coreboot-librem_15v4.config @@ -9,5 +9,5 @@ CONFIG_HAVE_ME_BIN=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 drm_kms_helper.drm_leak_fbdev_smem=1" +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" From cd4c1a0fdb6417b1724f4bd908c63cce9d62af88 Mon Sep 17 00:00:00 2001 From: Jonathon Hall Date: Wed, 19 Apr 2023 10:32:23 -0400 Subject: [PATCH 4/7] coreboot-librem*: Set framebuffer kernel params for Librems except L1UM Allow leaking the DRM framebuffer pointer to userspace, and disable framebuffer compression, like librem_15v4. Tested booting memtest86+ and Debian netinstaller on Mini v2. Do not enable this for L1UM, it uses Aspeed graphics which still don't work. qemu uses virtio graphics, which also are not working. Signed-off-by: Jonathon Hall --- config/coreboot-librem_13v2.config | 2 +- config/coreboot-librem_13v4.config | 2 +- config/coreboot-librem_14.config | 2 +- config/coreboot-librem_15v3.config | 2 +- config/coreboot-librem_mini.config | 2 +- config/coreboot-librem_mini_v2.config | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/coreboot-librem_13v2.config b/config/coreboot-librem_13v2.config index 53fd46864..dedd8e612 100644 --- a/config/coreboot-librem_13v2.config +++ b/config/coreboot-librem_13v2.config @@ -9,5 +9,5 @@ CONFIG_HAVE_ME_BIN=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" diff --git a/config/coreboot-librem_13v4.config b/config/coreboot-librem_13v4.config index 4988622d7..827474d50 100644 --- a/config/coreboot-librem_13v4.config +++ b/config/coreboot-librem_13v4.config @@ -9,5 +9,5 @@ CONFIG_HAVE_ME_BIN=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" diff --git a/config/coreboot-librem_14.config b/config/coreboot-librem_14.config index c98c0c31a..82c31b2ce 100644 --- a/config/coreboot-librem_14.config +++ b/config/coreboot-librem_14.config @@ -10,4 +10,4 @@ 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" diff --git a/config/coreboot-librem_15v3.config b/config/coreboot-librem_15v3.config index 2c6014cfd..0e2848f11 100644 --- a/config/coreboot-librem_15v3.config +++ b/config/coreboot-librem_15v3.config @@ -9,5 +9,5 @@ CONFIG_HAVE_ME_BIN=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" diff --git a/config/coreboot-librem_mini.config b/config/coreboot-librem_mini.config index 548d0852e..fb1f425a7 100644 --- a/config/coreboot-librem_mini.config +++ b/config/coreboot-librem_mini.config @@ -11,4 +11,4 @@ CONFIG_HAVE_ME_BIN=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" diff --git a/config/coreboot-librem_mini_v2.config b/config/coreboot-librem_mini_v2.config index f48386f81..a6fce2fe4 100644 --- a/config/coreboot-librem_mini_v2.config +++ b/config/coreboot-librem_mini_v2.config @@ -10,4 +10,4 @@ CONFIG_HAVE_ME_BIN=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" From a75ecdfc8d89be7fff1789b2d51158533b4c81a0 Mon Sep 17 00:00:00 2001 From: Jonathon Hall Date: Wed, 19 Apr 2023 10:34:29 -0400 Subject: [PATCH 5/7] t440p: Enable i915 kexec framebuffer fixes Add CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM and related kernel parameters to t440p. This board is already on kernel 5.10 and uses i915 graphics. Signed-off-by: Jonathon Hall --- config/coreboot-t440p.config | 2 +- config/linux-t440p.config | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/config/coreboot-t440p.config b/config/coreboot-t440p.config index 128125a05..a6140b852 100644 --- a/config/coreboot-t440p.config +++ b/config/coreboot-t440p.config @@ -7,7 +7,7 @@ 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" diff --git a/config/linux-t440p.config b/config/linux-t440p.config index 3aa08a2cc..deea2c757 100644 --- a/config/linux-t440p.config +++ b/config/linux-t440p.config @@ -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 From 353e836dc131b89d3fd7c635993e22a014d3e3e5 Mon Sep 17 00:00:00 2001 From: Jonathon Hall Date: Wed, 19 Apr 2023 14:16:38 -0400 Subject: [PATCH 6/7] 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 --- modules/kexec | 4 +- patches/kexec-2.0.22.patch | 91 --------------------- patches/kexec-2.0.26.patch | 161 +++++++++++++++++++++++++++++++++++++ 3 files changed, 163 insertions(+), 93 deletions(-) delete mode 100644 patches/kexec-2.0.22.patch create mode 100644 patches/kexec-2.0.26.patch diff --git a/modules/kexec b/modules/kexec index 52fa0d4a4..515325626 100644 --- a/modules/kexec +++ b/modules/kexec @@ -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" \ diff --git a/patches/kexec-2.0.22.patch b/patches/kexec-2.0.22.patch deleted file mode 100644 index 38dd525af..000000000 --- a/patches/kexec-2.0.22.patch +++ /dev/null @@ -1,91 +0,0 @@ -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,9 @@ 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") -+ || 0 == strcmp(fix.id, "i915drmfb")) { - /* 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) diff --git a/patches/kexec-2.0.26.patch b/patches/kexec-2.0.26.patch new file mode 100644 index 000000000..71c84abaf --- /dev/null +++ b/patches/kexec-2.0.26.patch @@ -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) From 6d0cd94ba8d0cc96dd0e62b907f38071d7c22324 Mon Sep 17 00:00:00 2001 From: Jonathon Hall Date: Thu, 27 Apr 2023 12:50:29 -0400 Subject: [PATCH 7/7] Enable CONFIG_NO_GFX_INIT in coreboot on i915 boards with Linux 5.10 We don't need coreboot to initialize graphics on this boards, this eliminates some unneeded code and the gnat dependency for them. Coreboot was using libgfxinit, but it was initializing in text mode. Heads' kernel will then switch to graphics mode, and we hand that framebuffer from i915 to the target kernel during kexec. Signed-off-by: Jonathon Hall --- config/coreboot-librem_13v2.config | 1 + config/coreboot-librem_13v4.config | 1 + config/coreboot-librem_14.config | 1 + config/coreboot-librem_15v3.config | 1 + config/coreboot-librem_15v4.config | 1 + config/coreboot-librem_mini.config | 1 + config/coreboot-librem_mini_v2.config | 1 + config/coreboot-t440p.config | 1 + 8 files changed, 8 insertions(+) diff --git a/config/coreboot-librem_13v2.config b/config/coreboot-librem_13v2.config index dedd8e612..512cd7049 100644 --- a/config/coreboot-librem_13v2.config +++ b/config/coreboot-librem_13v2.config @@ -6,6 +6,7 @@ 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" diff --git a/config/coreboot-librem_13v4.config b/config/coreboot-librem_13v4.config index 827474d50..ef583ca99 100644 --- a/config/coreboot-librem_13v4.config +++ b/config/coreboot-librem_13v4.config @@ -6,6 +6,7 @@ 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" diff --git a/config/coreboot-librem_14.config b/config/coreboot-librem_14.config index 82c31b2ce..871a9afd6 100644 --- a/config/coreboot-librem_14.config +++ b/config/coreboot-librem_14.config @@ -6,6 +6,7 @@ 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" diff --git a/config/coreboot-librem_15v3.config b/config/coreboot-librem_15v3.config index 0e2848f11..f9e088f6e 100644 --- a/config/coreboot-librem_15v3.config +++ b/config/coreboot-librem_15v3.config @@ -6,6 +6,7 @@ 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" diff --git a/config/coreboot-librem_15v4.config b/config/coreboot-librem_15v4.config index 3255bc5a5..26ab7cfd4 100644 --- a/config/coreboot-librem_15v4.config +++ b/config/coreboot-librem_15v4.config @@ -6,6 +6,7 @@ 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" diff --git a/config/coreboot-librem_mini.config b/config/coreboot-librem_mini.config index fb1f425a7..71b2b7dca 100644 --- a/config/coreboot-librem_mini.config +++ b/config/coreboot-librem_mini.config @@ -8,6 +8,7 @@ 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" diff --git a/config/coreboot-librem_mini_v2.config b/config/coreboot-librem_mini_v2.config index a6fce2fe4..849851694 100644 --- a/config/coreboot-librem_mini_v2.config +++ b/config/coreboot-librem_mini_v2.config @@ -7,6 +7,7 @@ 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" diff --git a/config/coreboot-t440p.config b/config/coreboot-t440p.config index a6140b852..c70c0e6a6 100644 --- a/config/coreboot-t440p.config +++ b/config/coreboot-t440p.config @@ -13,6 +13,7 @@ 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"