]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
plat/kvm/x86: Keep `Multiboot1` memory regions below `1 MiB`
authorSergiu Moga <sergiu.moga@protonmail.com>
Mon, 15 May 2023 06:02:07 +0000 (09:02 +0300)
committerUnikraft <monkey@unikraft.io>
Fri, 11 Aug 2023 10:18:45 +0000 (10:18 +0000)
Keep the `e820` enries below `1 MiB` that we were passed through
`Multiboot1` and rely on the unmappings memory region descriptor to
tell us later what to unmap.

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/multiboot.c

index 2eda0bf64d567879d9847d3d66154bfd5163fa65..fa263f917c2dc2d30bffe72ef6e22114570c83c6 100644 (file)
@@ -50,7 +50,6 @@ void multiboot_entry(struct lcpu *lcpu, struct multiboot_info *mi)
        __sz offset, cmdline_len;
        __paddr_t start, end;
        __u32 i;
-       int rc;
 
        bi = ukplat_bootinfo_get();
        if (unlikely(!bi))
@@ -124,14 +123,9 @@ void multiboot_entry(struct lcpu *lcpu, struct multiboot_info *mi)
                     offset += m->size + sizeof(m->size)) {
                        m = (void *)(__uptr)(mi->mmap_addr + offset);
 
-                       /* Ignore memory below the kernel image for now. This
-                        * is because on x86 there are special regions there
-                        * (e.g., BIOS) which are not represented in the
-                        * region list yet.
-                        */
-                       start = MAX(m->addr, __END);
+                       start = MAX(m->addr, __PAGE_SIZE);
                        end   = m->addr + m->len;
-                       if (end <= start)
+                       if (unlikely(end <= start || end - start < PAGE_SIZE))
                                continue;
 
                        mrd.pbase = start;
@@ -142,12 +136,6 @@ void multiboot_entry(struct lcpu *lcpu, struct multiboot_info *mi)
                                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))
-                                       multiboot_crash("Unable to add region",
-                                                       rc);
                        } else {
                                mrd.type  = UKPLAT_MEMRT_RESERVED;
                                mrd.flags = UKPLAT_MEMRF_READ |
@@ -156,8 +144,9 @@ void multiboot_entry(struct lcpu *lcpu, struct multiboot_info *mi)
                                /* We assume that reserved regions cannot
                                 * overlap with loaded modules.
                                 */
-                               mrd_insert(bi, &mrd);
                        }
+
+                       mrd_insert(bi, &mrd);
                }
        }