From nobody Tue Nov 12 07:55:45 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Xndy93f8kz5bfCW; Tue, 12 Nov 2024 07:55:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xndy92DrCz4f5K; Tue, 12 Nov 2024 07:55:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731398145; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kWvaYERNUvzC6RCW2uYC7LeTfrM3jG72Tsr0DSj88Vg=; b=fIh/GZVdbAbdh9KHY+JipPkCUrdkW69JuSDeZzKWDPxRNXPU1gk0aCgiilnBBd4Dxu3aIR g4eRB+Gkvsqf4SNkVEePPGJtYNnj2mUSfuZ2UJLmjE9TXS/iErqYhv0J2EkjOryIG4NcPC X3cC666IFZIJrVm0PTAhVJas5xQZWaWManapU76335pC5VpGWHBmenyCAOeKmZrgdcS0c2 hfZ+5R+ji4V1zaGqcqVBwpZwtiMiZmR22BlMzEFMq1jn/gAtiVg8OjfIJ63PUeEO53yrqn szub6xC6TzN2OM8sGJdAjh9HK8pNW+P93F72HXZS+jF7vFpwFdFTjjcqgwTNCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731398145; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kWvaYERNUvzC6RCW2uYC7LeTfrM3jG72Tsr0DSj88Vg=; b=cuRXmPLYvIxZBieDseZB0PelsUbGyFpJZ4jXfvUNjyB4Z+bExR6B+KW+vaLHFOa99ke/2X pCyhbJjrgdE9TMA8EINT5H6M1DnD3I9U7MW6IAtCzuY/Dw7ajPYkM+Hl4VSz4wGnbjNPbx kG1J7dEYdqPUXZ2eCCBMoKHiDwqZSKQ6xbJh6cC8J0ATeOnW89u6pogzj9rqI/kJa9WpSJ KC/D7TJRuWz0s+qT9fODTyTC5MGjO/o7Wd+bDo2ecsMswfz4op1KRA+1W5+7xW7OWjGbGc Jq2pJfC049ayFTlmsq4X2S1d+ZOb6qfRmjYN2nVbJreMxk1xwZAd41pTpRbdsw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731398145; a=rsa-sha256; cv=none; b=gbwiGeK+fJsR+8SUObuOtck6RPIhX1Mdv7u7YVy0wyPu5Jpnxh7bzyxU+GF8yV4mdny6CV q2YcAtJi6SVqRmKbDVcpWA9tFYqlmvaSX0DfGqdfJRwrK4ye4/vesd+5oznTHPvNoZJ8TD j3/A7/L1GvJCDPxLG5PCgfwOVZ7wguTWupEHvVT2535pfgCnBIfv79NTOl8PgbQAX3ps0p CQDJRZthIcQNxfrJBi+F37tOTaWXM7S4RCtkUMSvd8lrc0LG+2CQ3Ey/ELgJ6KtRhnCWRd ZfI6py3M9SQbQ5Kr3mYRpICpxD/6yF9nXfhPlE30Yl4/wK939e0LIM+OQkTXWg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Xndy91pL0z11wC; Tue, 12 Nov 2024 07:55:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4AC7tjd4077204; Tue, 12 Nov 2024 07:55:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AC7tj7P077201; Tue, 12 Nov 2024 07:55:45 GMT (envelope-from git) Date: Tue, 12 Nov 2024 07:55:45 GMT Message-Id: <202411120755.4AC7tj7P077201@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Corvin =?utf-8?Q?K=C3=B6hne?= Subject: git: 660e7182dbee - stable/14 - bhyve: merge adjacent E820 entries List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: corvink X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 660e7182dbeedea9083eb788dfcdfd17cc9ac6b6 Auto-Submitted: auto-generated The branch stable/14 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=660e7182dbeedea9083eb788dfcdfd17cc9ac6b6 commit 660e7182dbeedea9083eb788dfcdfd17cc9ac6b6 Author: Corvin Köhne AuthorDate: 2023-12-19 14:01:45 +0000 Commit: Corvin Köhne CommitDate: 2024-11-12 07:54:22 +0000 bhyve: merge adjacent E820 entries EDKII can allocate adjacent E820 entries only if they are at a page boundary. For some unknown and probably strange reasons, Intel puts it's OpRegion at an offset of 0x18 bytes. If the VBT lays directly behind the OpRegion, we're going to try allocating two adjacent E820 sharing the same page. This causes EDKII to do not properly allocate those entries. A Linux guest then isn't able to map the VBT and those fails to find it. Reviewed by: markj MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D45336 (cherry picked from commit 08139140c5f96fd9deb7a8de7a534bccf9a1d0c8) --- usr.sbin/bhyve/amd64/e820.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/usr.sbin/bhyve/amd64/e820.c b/usr.sbin/bhyve/amd64/e820.c index 148cae72ca6e..2fad22865ba6 100644 --- a/usr.sbin/bhyve/amd64/e820.c +++ b/usr.sbin/bhyve/amd64/e820.c @@ -156,6 +156,7 @@ e820_add_entry(const uint64_t base, const uint64_t end, { struct e820_element *new_element; struct e820_element *element; + struct e820_element *sib_element; struct e820_element *ram_element; assert(end >= base); @@ -273,6 +274,33 @@ e820_add_entry(const uint64_t base, const uint64_t end, element->base = end; } + /* + * If the previous element has the same type and ends at our base + * boundary, we can merge both entries. + */ + sib_element = TAILQ_PREV(new_element, e820_table, chain); + if (sib_element != NULL && + sib_element->type == new_element->type && + sib_element->end == new_element->base) { + new_element->base = sib_element->base; + TAILQ_REMOVE(&e820_table, sib_element, chain); + free(sib_element); + } + + /* + * If the next element has the same type and starts at our end + * boundary, we can merge both entries. + */ + sib_element = TAILQ_NEXT(new_element, chain); + if (sib_element != NULL && + sib_element->type == new_element->type && + sib_element->base == new_element->end) { + /* Merge new element into subsequent one. */ + new_element->end = sib_element->end; + TAILQ_REMOVE(&e820_table, sib_element, chain); + free(sib_element); + } + return (0); }