From nobody Mon Jan 03 16:01:38 2022 X-Original-To: dev-commits-src-main@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 4BF16192604C; Mon, 3 Jan 2022 16:01:40 +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 4JSL8f5ySfz4XPM; Mon, 3 Jan 2022 16:01:38 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 44BA73E1; Mon, 3 Jan 2022 16:01:38 +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 203G1cKE039383; Mon, 3 Jan 2022 16:01:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 203G1can039382; Mon, 3 Jan 2022 16:01:38 GMT (envelope-from git) Date: Mon, 3 Jan 2022 16:01:38 GMT Message-Id: <202201031601.203G1can039382@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 7d55d295086e - main - bhyve: add more slop to 64 bit BARs List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7d55d295086e0f568b42c89604fad3e47633b2ed Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641225699; 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=b/j+sndCPas3Z/EZD9D19LjJMtlmnlRsMfo1GqMzSt4=; b=G5mkhzFz0pZSXI1cu/paD5gctGVnBn0bz4g0EpJ0+Mau7ec8cvw8alSf/1vL1BnloB+XXW GbAQ8DTftSETNnxNvUMrLdgyWnIdiDyr09LsMu5ILN9cAiudNivkpg9VG4FbFeuI3zGe6s b2xdl4mhiax98J4zlcPA1gdA0AvqVDF+KB5rseSpODTCITm98Tto1fKQNOWDgUi3RnW1YI QWvkvG0SyxpRUNB+AtiA/1kXFFXXJUXGRwgI3w6JeRPIDxJkSMJUh7GVJabMkYKXHgET6u P98GGVetxHm0hwnbzLRZdYJTqvQqOrwExJChwRJ4XE2UK8hGCDGXBSb6BrVNTQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641225699; a=rsa-sha256; cv=none; b=kXGrvStZv6u91Vuowh9964eHg5ZxjAGMp41sXSGc8+BTlwY1a6ZxZYTxqxGNgDC+kHJFgP dX4aD6OZk3TfHKPEVX1X7pW5+Nhqyk8lVCMYIyZxnpRPwXRDU1kaNJ7J57Sc3S1Rucaabk N2SVEds+0Pn8st1mVX/owK/MTjBiXWmaCLOzEa7w2ZjX5fffILTs+WZpyHLhJAvPaOXw80 0Jx0dE12ok7t0f40CAYPjPC9JLAxvFO/4ce1bh9VyjaSXVsFBETqSpC0FUWfY+Yw4B0M4w Umno7MAjRqqMubgd3RvIP1ApQ0LV20E8qBO6m9pJlMFqtKJrU9SS9KiP/1FUxg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=7d55d295086e0f568b42c89604fad3e47633b2ed commit 7d55d295086e0f568b42c89604fad3e47633b2ed Author: Corvin Köhne AuthorDate: 2022-01-03 13:19:39 +0000 Commit: Emmanuel Vadot CommitDate: 2022-01-03 15:32:55 +0000 bhyve: add more slop to 64 bit BARs Bhyve allocates small 64 bit BARs below 4 GB and generates ACPI tables based on this allocation. If the guest decides to relocate those BARs above 4 GB, it could lead to mismatching ACPI tables. Especially when using OVMF with enabled bus enumeration it could cause issues. OVMF relocates all 64 bit BARs above 4 GB. The guest OS may be unable to recover from this situation and disables some PCI devices because their BARs are located outside of the MMIO space reported by ACPI. Avoid this situation by giving the guest more space for relocating BARs. Let's be paranoid. The available space for BARs below 4 GB is 512 MB large. Use a slop of 512 MB. It'll allow the guest to relocate all BARs below 4 GB to an address above 4 GB. We could run into issues when we exceeding the memlimit above 4 GB. However, this space has a size of 32 GB. Even when using many PCI device with large BARs like framebuffer or when using multiple PCI busses, it's very unlikely that we run out of space due to the large slop. Additionally, this situation will occur on startup and not at runtime which is much better. Reviewed by: markj MFC after: 2 weeks Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D33118 --- usr.sbin/bhyve/pci_emul.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c index 867ea0638d83..82580b7d6931 100644 --- a/usr.sbin/bhyve/pci_emul.c +++ b/usr.sbin/bhyve/pci_emul.c @@ -1218,7 +1218,8 @@ pci_ecfg_base(void) } #define BUSIO_ROUNDUP 32 -#define BUSMEM_ROUNDUP (1024 * 1024) +#define BUSMEM32_ROUNDUP (1024 * 1024) +#define BUSMEM64_ROUNDUP (512 * 1024 * 1024) int init_pci(struct vmctx *ctx) @@ -1320,14 +1321,14 @@ init_pci(struct vmctx *ctx) pci_emul_iobase = roundup2(pci_emul_iobase, BUSIO_ROUNDUP); bi->iolimit = pci_emul_iobase; - pci_emul_membase32 += BUSMEM_ROUNDUP; + pci_emul_membase32 += BUSMEM32_ROUNDUP; pci_emul_membase32 = roundup2(pci_emul_membase32, - BUSMEM_ROUNDUP); + BUSMEM32_ROUNDUP); bi->memlimit32 = pci_emul_membase32; - pci_emul_membase64 += BUSMEM_ROUNDUP; + pci_emul_membase64 += BUSMEM64_ROUNDUP; pci_emul_membase64 = roundup2(pci_emul_membase64, - BUSMEM_ROUNDUP); + BUSMEM64_ROUNDUP); bi->memlimit64 = pci_emul_membase64; }