@@ -695,7 +695,18 @@ static bool process_mem_region(struct mem_vector *region,
unsigned long long minimum,
unsigned long long image_size)
{
+ unsigned long long end;
int i;
+
+ /* Cannot access memory region above MAXMEM: skip it. */
+ if (region->start >= MAXMEM)
+ return 0;
+
+ /* Truncate the region if the end is above MAXMEM */
+ end = region->start + region->size;
+ end = min_t(unsigned long long, end, MAXMEM - 1);
+ region->size = end - region->start;
+
/*
* If no immovable memory found, or MEMORY_HOTREMOVE disabled,
* use @region directly.