[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/3] xen/arm: Extend the memory overlap check to include bootmodules



Similarly as the static regions defined in bootinfo.reserved_mem,
the bootmodule regions defined in bootinfo.modules should also not
be overlapping with memory regions in either bootinfo.reserved_mem
or bootinfo.modules.

Therefore, this commit extends the check in function
`check_reserved_regions_overlap()` to include memory regions in
bootinfo.modules, and use `check_reserved_regions_overlap()` in
`add_boot_module()` to return early if any error occurs.

Signed-off-by: Henry Wang <Henry.Wang@xxxxxxx>
---
 xen/arch/arm/setup.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 94d232605e..b43c8e118a 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -282,6 +282,11 @@ static int __init overlap_check(void *bootinfo_type,
         num = bootinfo.reserved_mem.nr_banks;
         type_str = "reserved_mem";
     }
+    else if ( bootinfo_type == &bootinfo.modules )
+    {
+        num = bootinfo.modules.nr_mods;
+        type_str = "bootmodules";
+    }
     else
         panic("Invalid bootinfo type passed to overlap check\n");
 
@@ -292,6 +297,11 @@ static int __init overlap_check(void *bootinfo_type,
             bank_start = bootinfo.reserved_mem.bank[i].start;
             bank_end = bank_start + bootinfo.reserved_mem.bank[i].size;
         }
+        else if ( bootinfo_type == &bootinfo.modules )
+        {
+            bank_start = bootinfo.modules.module[i].start;
+            bank_end = bank_start + bootinfo.modules.module[i].size;
+        }
 
         if ( region_end <= bank_start || region_start >= bank_end )
             continue;
@@ -331,6 +341,10 @@ int __init check_reserved_regions_overlap(paddr_t 
region_start,
     if ( overlap_check(&bootinfo.reserved_mem, region_start, region_end) )
         return -EINVAL;
 
+    /* Check if input region is overlapping with bootmodules */
+    if ( overlap_check(&bootinfo.modules, region_start, region_end) )
+        return -EINVAL;
+
     return 0;
 }
 
@@ -348,6 +362,10 @@ struct bootmodule __init *add_boot_module(bootmodule_kind 
kind,
                boot_module_kind_as_string(kind), start, start + size);
         return NULL;
     }
+
+    if ( check_reserved_regions_overlap(start, size) )
+        return NULL;
+
     for ( i = 0 ; i < mods->nr_mods ; i++ )
     {
         mod = &mods->module[i];
-- 
2.25.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.