]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
plat/kvm/x86: Ensure that lxboot initrd/cmdl regions are aligned
authorSergiu Moga <sergiu@unikraft.io>
Wed, 16 Aug 2023 15:20:39 +0000 (18:20 +0300)
committerUnikraft <monkey@unikraft.io>
Wed, 16 Aug 2023 16:34:35 +0000 (16:34 +0000)
All memory region descriptors must be aligned. Therefore, ensure
that the initrd and command-line related memory regions inserted
when booting through the Linux Boot Protocol are also aligned.

Note: If these two are aligned, all the other memory regions reported
through the boot protocol should be already aligned. Thus, we do not
do this explicit alignment on the free memory regions, as they must
have been already aligned by the previous boot phase. If this is not
the case, then the issue lies in the entity that booted us.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #1057

plat/kvm/x86/lxboot.c

index f0c152587bb0d53b7bb02c9af2e53dd355560acf..d395792955a61eb4ff9ba6ebbbc08bf3a7109697 100644 (file)
@@ -41,7 +41,7 @@ lxboot_init_cmdline(struct ukplat_bootinfo *bi, struct lxboot_params *bp)
 
        mrd.pbase = cmdline_addr;
        mrd.vbase = cmdline_addr;
-       mrd.len   = cmdline_size;
+       mrd.len   = PAGE_ALIGN_UP(cmdline_size);
        mrd.type  = UKPLAT_MEMRT_CMDLINE;
        mrd.flags = UKPLAT_MEMRF_READ | UKPLAT_MEMRF_MAP;
 #ifdef CONFIG_UKPLAT_MEMRNAME
@@ -79,7 +79,7 @@ lxboot_init_initrd(struct ukplat_bootinfo *bi, struct lxboot_params *bp)
        mrd.flags = UKPLAT_MEMRF_MAP | UKPLAT_MEMRF_READ;
        mrd.vbase = initrd_addr;
        mrd.pbase = initrd_addr;
-       mrd.len   = initrd_size;
+       mrd.len   = PAGE_ALIGN_UP(initrd_size);
 #ifdef CONFIG_UKPLAT_MEMRNAME
        memcpy(mrd.name, "initrd", sizeof("initrd"));
 #endif /* CONFIG_UKPLAT_MEMRNAME */