From: Sergiu Moga Date: Wed, 16 Aug 2023 15:20:39 +0000 (+0300) Subject: plat/kvm/x86: Ensure that lxboot initrd/cmdl regions are aligned X-Git-Tag: RELEASE-0.14.0~10 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=65ba7213e3732ccdecd1ee7db6f1cbddb131277c;p=unikraft%2Funikraft.git plat/kvm/x86: Ensure that lxboot initrd/cmdl regions are aligned 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 Reviewed-by: Marco Schlumpp Approved-by: Razvan Deaconescu Tested-by: Unikraft CI GitHub-Closes: #1057 --- diff --git a/plat/kvm/x86/lxboot.c b/plat/kvm/x86/lxboot.c index f0c152587..d39579295 100644 --- a/plat/kvm/x86/lxboot.c +++ b/plat/kvm/x86/lxboot.c @@ -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 */