Skip to content

Commit

Permalink
Merge pull request #37 from RinHizakura/pr
Browse files Browse the repository at this point in the history
Fix regression when bumping Linux to 6.1.88
  • Loading branch information
jserv authored Jul 21, 2024
2 parents 6aebede + 900522a commit 848565d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/arch/x86/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <asm/e820.h>
#include <linux/kvm.h>
#include <linux/kvm_para.h>
#include <stddef.h>
#include <string.h>
#include <sys/ioctl.h>

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

/* According to https://www.kernel.org/doc/html/next/x86/boot.html,
* the first step in loading a Linux kernel should be to setup the boot
* parameters (struct boot_params) and initialize it to all zero. Then,
* the setup header at offset 0x01f1 of kernel image on should be loaded
* into struct boot_params. */
memset(boot, 0, sizeof(struct boot_params));
memmove(boot, data, sizeof(struct boot_params));
memmove((void *) ((uintptr_t) boot + offsetof(struct boot_params, hdr)),
(void *) ((uintptr_t) 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;
Expand Down

0 comments on commit 848565d

Please sign in to comment.