From nobody Fri May 12 07:47:45 2023 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 4QHgpn4nG3z4BgSX; Fri, 12 May 2023 07:47: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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QHgpn47Gjz4P1d; Fri, 12 May 2023 07:47:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683877665; 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=R84oHOHr+dAoQF0WgSQm7hn23bHy73gq6rZ++hr5F0s=; b=Pmncx+zXBEd2ibRxhU9YtGWhpA1X+VgDUf7XzX/ZYvn171UA+C+RYNxDKAYOKdfTexk+9L 9zRTKGVyPBCJ3ZxLynMRd7JhoqHeaERGRxCnLMQiKSoBHw7JsRxvyRv/MPsqtgoLvGb3Vt rXmHLvogvaqMYXPaR7Cs7RdaRDFoL24ARlCaup54eXyjb9kUSKc1WaL003U5FXTTbxH94g 6hyKUdjMbUU847U8XujB5YbTdyhCIXOkWA/7jizaN3toohqopIyjiOTfOUky55Ea3gqE2A sfFXNCwJ2OGuwgjWKc0T4C4CWscPc0cEfyOtr0aNil/G/200jKqFbCZKiGy/Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683877665; 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=R84oHOHr+dAoQF0WgSQm7hn23bHy73gq6rZ++hr5F0s=; b=CgHNRe51s1v210s53bhjoOdJLXtN9PIBjbgyLEhdNOSGrvKwKihS3lgZhBL1tYkhs2gNwE 4LR9YDkglHWsExx4X9DPGqFMRmY+KN755KSMeLqNdNuiO7guR7OYgPO9lHGjAeWNjifVbp QfnHCgjBsVD6sZBouUuX3QGISxjS95+mgXVKj3qaql1YQkoRgoNLjzaJ7+JbgNmMrzolOt SDPx7DTpc+JYWYmzDrsl/8EE5jgQIfg0VF7J0c8fATOTTdO2X2xxqPMGl78tSeFptB8GYO /VR1AGj/TENZfP4RUhrSUHpBosc9z9F6f1cmKbPJmoxku+uW4UVymKHQgk/oTQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683877665; a=rsa-sha256; cv=none; b=xwMND0makYBvqeKX3h9aM6rEmHsNEdBSkueTZ6dv1oaEbkZS/7Jc5LPTHXcHs71w6AZ5My 5Nzgoe9Y4B4xkM/Wff6hzWJwbgTE+pTIFyLLsfgwxMP6Cgj4LUoCUJ3K1ttGFt6YD1pw7o 25+FkA5FshnTLP7vLS5z8QskhJuc1fl0ezvyDC6BBoMVYd7WcnChz4iPTVAQgtm/nO6v/u Xs3IERO7Zi6hKyyx+ZN4WqRmYOdQfKZBlmTPp4MQ4dOzr59y/Z4ftZkPkQWE7iY/eTaq/o Gs0kamEJ8CklxmyGUIrgNomjTD9yhnM187NrfxLqB1apJuvMq3ID58J3JYU+mg== 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 4QHgpn3Bz1zS2C; Fri, 12 May 2023 07:47:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 34C7lj6F073275; Fri, 12 May 2023 07:47:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34C7ljW2073274; Fri, 12 May 2023 07:47:45 GMT (envelope-from git) Date: Fri, 12 May 2023 07:47:45 GMT Message-Id: <202305120747.34C7ljW2073274@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Corvin=20K=C3=B6hne?= Subject: git: 99aeb28b2f7e - main - bhyve: don't panic if e820 finds no available memory 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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/main X-Git-Reftype: branch X-Git-Commit: 99aeb28b2f7e28c516dd6434db63a9bc1c1f3218 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=99aeb28b2f7e28c516dd6434db63a9bc1c1f3218 commit 99aeb28b2f7e28c516dd6434db63a9bc1c1f3218 Author: Corvin Köhne AuthorDate: 2023-05-09 12:32:33 +0000 Commit: Corvin Köhne CommitDate: 2023-05-12 07:29:39 +0000 bhyve: don't panic if e820 finds no available memory The GVT-d emulation tries to allocate some specific memory. It could happen that this address doesn't exist. In that case, GVT-d will fall back to allocate any address. Nevertheless, this only works if the e820 fails with an error instead of exiting on an assertion. Reviewed by: markj MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D40034 --- usr.sbin/bhyve/e820.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/usr.sbin/bhyve/e820.c b/usr.sbin/bhyve/e820.c index 6c43e6eda3a5..99a66645f70f 100644 --- a/usr.sbin/bhyve/e820.c +++ b/usr.sbin/bhyve/e820.c @@ -197,11 +197,17 @@ e820_add_entry(const uint64_t base, const uint64_t end, return (0); } - assert(element != NULL); - /* Non system memory should be allocated inside system memory. */ - assert(element->type == E820_TYPE_MEMORY); - /* New element should fit into existing system memory element. */ - assert(base >= element->base && end <= element->end); + /* + * If some one tries to allocate a specific address, it could happen, that + * this address is not allocatable. Therefore, do some checks. If the + * address is not allocatable, don't panic. The user may have a fallback and + * tries to allocate another address. This is true for the GVT-d emulation + * which tries to reuse the host address of the graphics stolen memory and + * falls back to allocating the highest address below 4 GB. + */ + if (element == NULL || element->type != E820_TYPE_MEMORY || + (base < element->base || end > element->end)) + return (ENOMEM); if (base == element->base) { /*