Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c2d08791 authored by Jeremy Fitzhardinge's avatar Jeremy Fitzhardinge
Browse files

xen: clean up "extra" memory handling some more



Make sure that extra_pages is added for all E820_RAM regions beyond
mem_end - completely excluded regions as well as the remains of partially
included regions.

Also makes sure the extra region is not unnecessarily high, and simplifies
the logic to decide which regions should be added.

Signed-off-by: default avatarJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
parent 12334715
Loading
Loading
Loading
Loading
+9 −12
Original line number Diff line number Diff line
@@ -182,24 +182,21 @@ char * __init xen_memory_setup(void)
	for (i = 0; i < memmap.nr_entries; i++) {
		unsigned long long end = map[i].addr + map[i].size;

		if (map[i].type == E820_RAM) {
			if (map[i].addr < mem_end && end > mem_end) {
				/* Truncate region to max_mem. */
				u64 delta = end - mem_end;
		if (map[i].type == E820_RAM && end > mem_end) {
			/* RAM off the end - may be partially included */
			u64 delta = min(map[i].size, end - mem_end);

			map[i].size -= delta;
				extra_pages += PFN_DOWN(delta);
			end -= delta;

				end = mem_end;
			}
			extra_pages += PFN_DOWN(delta);
		}

		if (end > xen_extra_mem_start)
		if (map[i].size > 0 && end > xen_extra_mem_start)
			xen_extra_mem_start = end;

		/* If region is non-RAM or below mem_end, add what remains */
		if ((map[i].type != E820_RAM || map[i].addr < mem_end) &&
		    map[i].size > 0)
		/* Add region if any remains */
		if (map[i].size > 0)
			e820_add_region(map[i].addr, map[i].size, map[i].type);
	}