diff --git a/usr.sbin/bhyve/amd64/e820.c b/usr.sbin/bhyve/amd64/e820.c --- a/usr.sbin/bhyve/amd64/e820.c +++ b/usr.sbin/bhyve/amd64/e820.c @@ -223,7 +223,18 @@ * [ 0x2000, 0x4000] RAM <-- element */ TAILQ_INSERT_BEFORE(element, new_element, chain); - element->base = end; + + /* + * If the end of the new entry matches the end of our RAM + * segment, the RAM segement will become empty and we should + * remove it. + */ + if (end != element->end) { + element->base = end; + } else { + TAILQ_REMOVE(&e820_table, element, chain); + free(element); + } } else if (end == element->end) { /* * New element at system memory end boundary. Add new