Skip to content

Fix regression when bumping Linux to 6.1.88 #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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