]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
plat/kvm/x86: Coalesce the memory region descriptor list
authorSergiu Moga <sergiu.moga@protonmail.com>
Thu, 6 Apr 2023 13:14:03 +0000 (16:14 +0300)
committerUnikraft <monkey@unikraft.io>
Fri, 11 Aug 2023 10:18:44 +0000 (10:18 +0000)
Ensure that there are no overlapping memory regions in the memory
region descriptor list by coalescing them after finishing the
insertion phase of the memory regions reported through the multiboot
protocol.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #848

plat/kvm/x86/lxboot.c
plat/kvm/x86/multiboot.c

index 03b35f4ef4380d9d20333e2a1681a1551a9edc11..130136fd55ef3d1d15989d5b039d7bf1e43a78a3 100644 (file)
@@ -121,10 +121,6 @@ lxboot_init_mem(struct ukplat_bootinfo *bi, struct lxboot_params *bp)
                        mrd.type = UKPLAT_MEMRT_FREE;
                        mrd.flags = UKPLAT_MEMRF_READ | UKPLAT_MEMRF_WRITE;
 
-                       rc = ukplat_memregion_list_insert_split_phys(
-                               &bi->mrds, &mrd, __PAGE_SIZE);
-                       if (unlikely(rc < 0))
-                               lxboot_crash(rc, "Unable to add ram mapping");
                } else {
                        mrd.type = UKPLAT_MEMRT_RESERVED;
                        mrd.flags = UKPLAT_MEMRF_READ | UKPLAT_MEMRF_MAP;
@@ -132,10 +128,12 @@ lxboot_init_mem(struct ukplat_bootinfo *bi, struct lxboot_params *bp)
                        /* We assume that reserved regions cannot
                         * overlap with loaded modules.
                         */
-                       rc = ukplat_memregion_list_insert(&bi->mrds, &mrd);
-                       if (unlikely(rc < 0))
-                               lxboot_crash(rc, "Unable to add ram mapping");
                }
+
+               rc = ukplat_memregion_list_insert(&bi->mrds, &mrd);
+               if (unlikely(rc < 0))
+                       lxboot_crash(rc, "Unable to add ram mapping");
+
        }
 }
 
@@ -153,6 +151,7 @@ void lxboot_entry(struct lcpu *lcpu, struct lxboot_params *bp)
        lxboot_init_cmdline(bi, bp);
        lxboot_init_initrd(bi, bp);
        lxboot_init_mem(bi, bp);
+       ukplat_memregion_list_coalesce(&bi->mrds);
 
        memcpy(bi->bootprotocol, "lxboot", sizeof("lxboot"));
 
index f11cf9117aacde912fe3829f62c50566ba580d6d..2eda0bf64d567879d9847d3d66154bfd5163fa65 100644 (file)
@@ -161,5 +161,7 @@ void multiboot_entry(struct lcpu *lcpu, struct multiboot_info *mi)
                }
        }
 
+       ukplat_memregion_list_coalesce(&bi->mrds);
+
        _ukplat_entry(lcpu, bi);
 }