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

[mini-os master] e820: use special type for software reserved memory



commit e7451994adab312cd80d840606c3a04be31e1f1a
Author:     Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Tue Jul 15 15:29:27 2025 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Jul 16 15:04:23 2025 +0200

    e820: use special type for software reserved memory
    
    For memory areas used to map foreign domain memory Mini-OS is using
    the type E820_RESERVED in the memory map today. This is causing
    problems with kexec, as the new kernel should not see those areas in
    the memory map. Unfortunately the sequence of actions for calculating
    the size of the memory map and the removal of those reserved areas
    can't easily be adjusted to do the removal first, so another way must
    be used to avoid passing those reserved areas to the new kernel.
    
    Instead of using the type E820_RESERVED, which might be used for other
    pages as well, just use a new type. Areas with that new type can
    easily be filtered out when building the memory map for the new
    kernel.
    
    Introduce the type E820_TYPE_SOFT_RESERVED with the same value as the
    Linux kernel is using for the same purpose.
    
    Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
    Reviewed-by: Jason Andryuk <jason.andryuk@xxxxxxx>
---
 arch/x86/kexec.c | 4 +++-
 e820.c           | 8 ++++----
 include/e820.h   | 2 ++
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kexec.c b/arch/x86/kexec.c
index 29f8aa8..b33fbfc 100644
--- a/arch/x86/kexec.c
+++ b/arch/x86/kexec.c
@@ -240,14 +240,16 @@ int kexec_get_entry(const char *cmdline)
 
     mmap = next;
     info->memmap_paddr = kexec_param_pa + (unsigned long)next - 
kexec_param_mem;
-    info->memmap_entries = e820_entries;
     for ( i = 0; i < e820_entries; i++ )
     {
+        if ( e820_map[i].type == E820_TYPE_SOFT_RESERVED )
+            continue;
         mmap->addr = e820_map[i].addr;
         mmap->size = e820_map[i].size;
         mmap->type = e820_map[i].type;
         mmap++;
     }
+    info->memmap_entries = mmap - (struct hvm_memmap_table_entry *)next;
     next = mmap;
 
     info->cmdline_paddr = kexec_param_pa + (unsigned long)next - 
kexec_param_mem;
diff --git a/e820.c b/e820.c
index 44cfac0..1ffeaf0 100644
--- a/e820.c
+++ b/e820.c
@@ -367,8 +367,8 @@ unsigned long e820_get_reserved_pfns(int pages)
     for ( i = 0; i < e820_entries && e820_map[i].addr < last + needed; i++ )
         last = round_pgup(e820_map[i].addr + e820_map[i].size);
 
-    if ( i == 0 || e820_map[i - 1].type != E820_RESERVED )
-        e820_insert_entry_at(i, last, needed, E820_RESERVED);
+    if ( i == 0 || e820_map[i - 1].type != E820_TYPE_SOFT_RESERVED )
+        e820_insert_entry_at(i, last, needed, E820_TYPE_SOFT_RESERVED);
     else
         e820_map[i - 1].size += needed;
 
@@ -385,7 +385,7 @@ void e820_put_reserved_pfns(unsigned long start_pfn, int 
pages)
           i < e820_entries && addr >= e820_map[i].addr + e820_map[i].size;
           i++ );
 
-    BUG_ON(i == e820_entries || e820_map[i].type != E820_RESERVED ||
+    BUG_ON(i == e820_entries || e820_map[i].type != E820_TYPE_SOFT_RESERVED ||
            addr + size > e820_map[i].addr + e820_map[i].size);
 
     if ( addr == e820_map[i].addr )
@@ -405,7 +405,7 @@ void e820_put_reserved_pfns(unsigned long start_pfn, int 
pages)
 
     e820_insert_entry_at(i + 1, addr + size,
                          e820_map[i].addr + e820_map[i].size - addr - size,
-                         E820_RESERVED);
+                         E820_TYPE_SOFT_RESERVED);
     e820_map[i].size = addr - e820_map[i].addr;
 }
 #endif
diff --git a/include/e820.h b/include/e820.h
index ffa15aa..ad5657f 100644
--- a/include/e820.h
+++ b/include/e820.h
@@ -39,6 +39,8 @@
 #define E820_DISABLED     6
 #define E820_PMEM         7
 #define E820_TYPES        8
+/* Memory reserved for Mini-OS internal purpose. */
+#define E820_TYPE_SOFT_RESERVED   0xefffffff
 
 struct __packed e820entry {
     uint64_t addr;
--
generated by git-patchbot for /home/xen/git/mini-os.git#master



 


Rackspace

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