1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-18 02:19:39 +00:00

bhyve: remove empty E820 entries

When reserving a block with the same size of a RAM segement, we can end up with
an empty RAM segmenet. Avoid that by removing this empty segment from the E820
table.

Reviewed by:		jhb, markj (older version)
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D45480
This commit is contained in:
Corvin Köhne 2024-06-04 09:38:02 +02:00
parent 104ee24349
commit f325f81f4a
No known key found for this signature in database
GPG Key ID: D854DA56315E026A

View File

@ -210,7 +210,19 @@ e820_add_entry(const uint64_t base, const uint64_t end,
(base < element->base || end > element->end))
return (ENOMEM);
if (base == element->base) {
if (base == element->base && end == element->end) {
/*
* The new entry replaces an existing one.
*
* Old table:
* [ 0x1000, 0x4000] RAM <-- element
* New table:
* [ 0x1000, 0x4000] Reserved
*/
TAILQ_INSERT_BEFORE(element, new_element, chain);
TAILQ_REMOVE(&e820_table, element, chain);
free(element);
} else if (base == element->base) {
/*
* New element at system memory base boundary. Add new
* element before current and adjust the base of the old