Skip to content

Commit 900522a

Browse files
author
robelin
committed
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.
1 parent 6aebede commit 900522a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: src/arch/x86/vm.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <asm/e820.h>
77
#include <linux/kvm.h>
88
#include <linux/kvm_para.h>
9+
#include <stddef.h>
910
#include <string.h>
1011
#include <sys/ioctl.h>
1112

@@ -130,8 +131,15 @@ int vm_arch_load_image(vm_t *v, void *data, size_t datasz)
130131
void *cmdline = ((uint8_t *) v->mem) + 0x20000;
131132
void *kernel = ((uint8_t *) v->mem) + 0x100000;
132133

134+
/* According to https://www.kernel.org/doc/html/next/x86/boot.html,
135+
* the first step in loading a Linux kernel should be to setup the boot
136+
* parameters (struct boot_params) and initialize it to all zero. Then,
137+
* the setup header at offset 0x01f1 of kernel image on should be loaded
138+
* into struct boot_params. */
133139
memset(boot, 0, sizeof(struct boot_params));
134-
memmove(boot, data, sizeof(struct boot_params));
140+
memmove((void *) ((uintptr_t) boot + offsetof(struct boot_params, hdr)),
141+
(void *) ((uintptr_t) data + offsetof(struct boot_params, hdr)),
142+
sizeof(struct setup_header));
135143

136144
size_t setup_sectors = boot->hdr.setup_sects;
137145
size_t setupsz = (setup_sectors + 1) * 512;

0 commit comments

Comments
 (0)