Skip to content

Commit 848565d

Browse files
authored
Merge pull request #37 from RinHizakura/pr
Fix regression when bumping Linux to 6.1.88
2 parents 6aebede + 900522a commit 848565d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/arch/x86/vm.c

Lines changed: 9 additions & 1 deletion
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)