From nobody Thu Aug 17 13:02:59 2023 X-Original-To: dev-commits-src-branches@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 4RRQCm0Nj4z4qdt1; Thu, 17 Aug 2023 13:03:00 +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 4RRQCl6cnbz4h0V; Thu, 17 Aug 2023 13:02:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692277379; 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=sSpH0zC/SGVq0m6HXHBfb6NXg/wSH4BmDMJf9TUgYc8=; b=cPgklM5rCjtvrEOUzzhr8CTqifPRK1CYlbLjg5LsNEzrpnGCVNK4qLCexSOPdzt5C4p/7l DfvFsTaYwJ4Nj1rPyC2hDmcY5Jp2Z7wLQs+Hlk9Ax6ojovmD6Iq2owrFbhDiWSX6hjrDTZ tEJ+5gCX0eF1BjTc3JXWi++NF5eYe7jR2a6VRswKy0J68JFokavW2CIuLwycOEDkjQ7/g/ /cYJSflWGWFF9D5PLK6KUFEnZ2mp2uDqcZMt2RQogI2bQDoW7EkCiscnGEaXwoITsfhIbk IpMGyg1BOeNUNfvDnGMstRxu+F1bA0ipp/0+FMueqSq8TsvbfptZRR5hgVO1zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692277379; 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=sSpH0zC/SGVq0m6HXHBfb6NXg/wSH4BmDMJf9TUgYc8=; b=FvJzoDwCGXXma8ihlbqmneovpG1Fhz3xPNLAco9c41tG+70voI9B8ZrRaU4yqpfrcq3dO5 e/VuwQuw8uOoXQ7+6LTK5RrZZwpxiEk1DZkgZBHp3YE/Bu7RRfEinzqZ7ML6YK/j5aS6EQ WkACIDTG89uc4cgq+sVhd2PGB58fG8ELGR7LQCuZHMvsR6WWlq/X+YmyVG8I8V8E7wOibv dpSELvFLU/UCO5eNec2Nwh0zOTBDLSYmutS71O8Hf1BQtazUOklkE84fEAg3a5TihWQxwL kxyeymegOn5Y7Oz/+sO+6ZvLCsjJk7DXqFeB4A0jx7jHHzsQSqHF3U+igF/EYg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1692277379; a=rsa-sha256; cv=none; b=JMxtfYtGZ0Lb43lYIFlPAs34scy0okOGRfp6CLO8iR2oPGm0aiApFNr4nkmVCtaYmaegF6 JKHzOSlpqgm+f/Gzr9JlMXvvNFhzy+B9/ft8z9AgLpyoNhT5QhKXk+q1MfkOCNDV0VrBVi q25tsMTKI0+L3CfmWAYj1HwYlHF3H4x6TdhEVt0C9wI+VfqYZSg/zEBERcUFjinh6Bab07 eVAIVMoG78z8F1y1i0t8DwmkrBdEjQYExng9DYYEZYXJyDSgjxfTVii1+5WlRigTmG/AKJ rQP+hCW8lDHtxZDR0DNIZ0d11RdO5HfFsvPtZozVl0iz52JM+7SZAdRiJBvEfA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4RRQCl5dThzZgH; Thu, 17 Aug 2023 13:02:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 37HD2xPD096711; Thu, 17 Aug 2023 13:02:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37HD2xe7096708; Thu, 17 Aug 2023 13:02:59 GMT (envelope-from git) Date: Thu, 17 Aug 2023 13:02:59 GMT Message-Id: <202308171302.37HD2xe7096708@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: 3152cbdd1657 - stable/13 - bhyve: don't panic if e820 finds no available memory List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/13 X-Git-Reftype: branch X-Git-Commit: 3152cbdd16572e0580588b349165c680ce8bc87b Auto-Submitted: auto-generated The branch stable/13 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=3152cbdd16572e0580588b349165c680ce8bc87b commit 3152cbdd16572e0580588b349165c680ce8bc87b Author: Corvin Köhne AuthorDate: 2023-05-09 12:32:33 +0000 Commit: Corvin Köhne CommitDate: 2023-08-17 12:58:04 +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 (cherry picked from commit 99aeb28b2f7e28c516dd6434db63a9bc1c1f3218) --- 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) { /*