mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
x86/boot: Force error checking for reserve_e820_ram()
Failing to mark Xen as Reserved in the E820 is catastrophic; RAM regions get
handed to the physical memory allocator for general use. Similarly, failure
to mark the boot modules as reserved is not going to result in a working
system.
Mark reserve_e820_ram() as __must_check, and panic() on failure. To avoid
opencoding the range in every caller, print a general failure message in
reserve_e820_ram().
Reported-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
master commit: b7c0ac4467
master date: 2026-09-24 20:54:37 +0100
This commit is contained in:
1 parent
9f993bafc3
commit
c2a0004aba
3 files changed
+16
-6
No files matched your search
+7
-1
@@ -680,7 +680,13 @@ int __init e820_change_range_type(
|
||||
/* Set E820_RAM area (@s,@e) as RESERVED in specified e820 map. */
|
||||
int __init reserve_e820_ram(struct e820map *map, uint64_t s, uint64_t e)
|
||||
{
|
||||
return e820_change_range_type(map, s, e, E820_RAM, E820_RESERVED);
|
||||
int res = e820_change_range_type(map, s, e, E820_RAM, E820_RESERVED);
|
||||
|
||||
if ( !res )
|
||||
printk("Failed to convert E820 RAM %"PRIx64"-%"PRIx64" to RESERVED\n",
|
||||
s, e);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
unsigned long __init init_e820(const char *str, struct e820map *raw)
|
||||
|
||||
@@ -25,7 +25,8 @@ struct e820map {
|
||||
|
||||
extern int sanitize_e820_map(struct e820entry *biosmap, unsigned int *pnr_map);
|
||||
extern int e820_all_mapped(u64 start, u64 end, unsigned type);
|
||||
extern int reserve_e820_ram(struct e820map *map, uint64_t s, uint64_t e);
|
||||
extern int __must_check reserve_e820_ram(
|
||||
struct e820map *map, uint64_t s, uint64_t e);
|
||||
extern int e820_change_range_type(
|
||||
struct e820map *map, uint64_t s, uint64_t e,
|
||||
uint32_t orig_type, uint32_t new_type);
|
||||
|
||||
@@ -1583,7 +1583,8 @@ void asmlinkage __init noreturn __start_xen(void)
|
||||
{
|
||||
uint64_t s = bi->mods[i].start, l = bi->mods[i].size;
|
||||
|
||||
reserve_e820_ram(&boot_e820, s, s + PAGE_ALIGN(l));
|
||||
if ( !reserve_e820_ram(&boot_e820, s, s + PAGE_ALIGN(l)) )
|
||||
panic("Failed to reserve boot module %u in E820\n", i);
|
||||
}
|
||||
|
||||
if ( !xen_phys_start )
|
||||
@@ -1596,11 +1597,13 @@ void asmlinkage __init noreturn __start_xen(void)
|
||||
/* This needs to remain in sync with remove_xen_ranges(). */
|
||||
if ( efi_boot_mem_unused(&eb_start, &eb_end) )
|
||||
{
|
||||
reserve_e820_ram(&boot_e820, __pa(_stext), __pa(eb_start));
|
||||
reserve_e820_ram(&boot_e820, __pa(eb_end), __pa(__2M_rwdata_end));
|
||||
if ( !reserve_e820_ram(&boot_e820, __pa(_stext), __pa(eb_start)) ||
|
||||
!reserve_e820_ram(&boot_e820, __pa(eb_end), __pa(__2M_rwdata_end)) )
|
||||
panic("Failed to reserve Xen in E820\n");
|
||||
}
|
||||
else
|
||||
reserve_e820_ram(&boot_e820, __pa(_stext), __pa(__2M_rwdata_end));
|
||||
if ( !reserve_e820_ram(&boot_e820, __pa(_stext), __pa(__2M_rwdata_end)) )
|
||||
panic("Failed to reserve Xen in E820\n");
|
||||
|
||||
/* Late kexec reservation (dynamic start address). */
|
||||
kexec_reserve_area();
|
||||
|
||||