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

[xen master] xen/arm: Extend the memory overlap check to include EfiACPIReclaimMemory



commit 3e25767ea50a95b0bd08c5922e33e601228f7485
Author:     Henry Wang <Henry.Wang@xxxxxxx>
AuthorDate: Wed Feb 1 10:15:13 2023 +0800
Commit:     Julien Grall <julien@xxxxxxx>
CommitDate: Sun Apr 16 17:19:06 2023 +0100

    xen/arm: Extend the memory overlap check to include EfiACPIReclaimMemory
    
    Similarly as the static regions and boot modules, memory regions with
    EfiACPIReclaimMemory type (defined in bootinfo.acpi if CONFIG_ACPI is
    enabled) should also not be overlapping with memory regions in
    bootinfo.reserved_mem and bootinfo.modules.
    
    Therefore, this commit reuses the `meminfo_overlap_check()` to further
    extends the check in function `check_reserved_regions_overlap()` so that
    memory regions in bootinfo.acpi are included. If any error occurs in the
    extended `check_reserved_regions_overlap()`, the `meminfo_add_bank()`
    defined in `efi-boot.h` will return early.
    
    Signed-off-by: Henry Wang <Henry.Wang@xxxxxxx>
    Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
---
 xen/arch/arm/efi/efi-boot.h | 10 ++++++++--
 xen/arch/arm/setup.c        |  6 ++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h
index 223db0c4da..bb64925d70 100644
--- a/xen/arch/arm/efi/efi-boot.h
+++ b/xen/arch/arm/efi/efi-boot.h
@@ -161,13 +161,19 @@ static bool __init meminfo_add_bank(struct meminfo *mem,
                                     EFI_MEMORY_DESCRIPTOR *desc)
 {
     struct membank *bank;
+    paddr_t start = desc->PhysicalStart;
+    paddr_t size = desc->NumberOfPages * EFI_PAGE_SIZE;
 
     if ( mem->nr_banks >= NR_MEM_BANKS )
         return false;
+#ifdef CONFIG_ACPI
+    if ( check_reserved_regions_overlap(start, size) )
+        return false;
+#endif
 
     bank = &mem->bank[mem->nr_banks];
-    bank->start = desc->PhysicalStart;
-    bank->size = desc->NumberOfPages * EFI_PAGE_SIZE;
+    bank->start = start;
+    bank->size = size;
 
     mem->nr_banks++;
 
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 1ea42a0386..6f9f4d8c8a 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -350,6 +350,12 @@ bool __init check_reserved_regions_overlap(paddr_t 
region_start,
                                    region_start, region_size) )
         return true;
 
+#ifdef CONFIG_ACPI
+    /* Check if input region is overlapping with ACPI EfiACPIReclaimMemory */
+    if ( meminfo_overlap_check(&bootinfo.acpi, region_start, region_size) )
+        return true;
+#endif
+
     return false;
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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