git: f325f81f4ab9 - main - bhyve: remove empty E820 entries
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 09 Aug 2024 06:16:11 UTC
The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=f325f81f4ab93646debed0c2291c4c7f31470cfb commit f325f81f4ab93646debed0c2291c4c7f31470cfb Author: Corvin Köhne <corvink@FreeBSD.org> AuthorDate: 2024-06-04 07:38:02 +0000 Commit: Corvin Köhne <corvink@FreeBSD.org> CommitDate: 2024-08-09 06:15:06 +0000 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 --- usr.sbin/bhyve/amd64/e820.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bhyve/amd64/e820.c b/usr.sbin/bhyve/amd64/e820.c index 9d95ec8ce688..148cae72ca6e 100644 --- a/usr.sbin/bhyve/amd64/e820.c +++ b/usr.sbin/bhyve/amd64/e820.c @@ -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