From 0cc7e6df9f892197131a8e4101f1e9c8242b9fac Mon Sep 17 00:00:00 2001 From: robelin Date: Sat, 20 Jul 2024 14:08:32 +0800 Subject: [PATCH] Fix regression when bumping Linux to 6.1.88 Starting from Linux v6.1.88 commit f31f521, the first bootsec is complete removed and filled with 0xff to reserve for PE header. Since we load the full 512 bytes, those 0xff will break kvm-host. Instead, we only have to take the part of setup header. --- src/arch/x86/vm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/arch/x86/vm.c b/src/arch/x86/vm.c index 3608919..f125fe6 100644 --- a/src/arch/x86/vm.c +++ b/src/arch/x86/vm.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "err.h" #include "vm.h" @@ -131,7 +132,9 @@ int vm_arch_load_image(vm_t *v, void *data, size_t datasz) void *kernel = ((uint8_t *) v->mem) + 0x100000; memset(boot, 0, sizeof(struct boot_params)); - memmove(boot, data, sizeof(struct boot_params)); + memmove((void *)boot + offsetof(struct boot_params, hdr), + data + offsetof(struct boot_params, hdr), + sizeof(struct setup_header)); size_t setup_sectors = boot->hdr.setup_sects; size_t setupsz = (setup_sectors + 1) * 512;