From nobody Fri Jan 14 14:20:41 2022 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 B70D4195D846; Fri, 14 Jan 2022 14:20:42 +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 4Jb3P61bhwz3Lty; Fri, 14 Jan 2022 14:20:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642170042; 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=ZKitAvBx5xUZx24L8mrOQy/wqHciq6lC7wV2lIYGAG0=; b=hqf5YC9ontvypdasanGgg+Y9VdIQAdTwXv7oS2rSZSEkDbnjXMKZBtwSncCbkjwLjmnC8x 5GRhlhgMZKtE3U9eNh6yNVktY6+lRqxUpYDSD44q9UW13cqHmdyCQyWdraOPy8cOo74RXo nNweClmhw8zQnvmL6CzI5X3aNoZKAAV6uSi+sjOHiv5+n1Nvl84xYeWZy1rFIpmLWzeqrE O7AgrObSL+9F7OnBOqGXoGgzGwJfVTfwE9xpmi/DlKyEJCLPaMQ2Zggw4Rb5G761nBmEs0 F3KFikASSoN4iZVhvqSrobr0Uv23OGmXah2o7j++M521PjyoDxrv6WTCnsgSEQ== 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 6D62515780; Fri, 14 Jan 2022 14:20:41 +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 20EEKfok087989; Fri, 14 Jan 2022 14:20:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20EEKfsr087988; Fri, 14 Jan 2022 14:20:41 GMT (envelope-from git) Date: Fri, 14 Jan 2022 14:20:41 GMT Message-Id: <202201141420.20EEKfsr087988@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Emmanuel Vadot Subject: git: f281bda11a1a - stable/13 - bhyve: use a fixed 32 bit BAR base address 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: manu X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f281bda11a1a01abd911053325407205cffcf808 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642170042; 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=ZKitAvBx5xUZx24L8mrOQy/wqHciq6lC7wV2lIYGAG0=; b=q9mMYvy+DlUx4J6ZhMWpXn94bcXBwoCf9c6KVjy+vWOfGBWUoUqMQ5yc69tCIXSmuImQAz 5stFNO5L3V/xAqD94QzqFDNAWvwoDB3CS+WWeAXAfm6U0oPjcz88E6WKOTUa1jPTxvYXtP flajdk47aKm5uPJpR1P28ldmugHHAPllUgQEhVGtHxmqrWS3WbhNbx+v1NKAVxyKTjkSbB Colau/Ds9riSjoDId5zgPP9ae+7/Z9P4CdwQoicNpaokSqp8oy6fM1WQ/xA8mow0KgwfAC Ea+YjKMQcKOS5jUyi4G8DXhNS8BgE2zlaQWBmc5LwSFkoYSj+q9PgE1CCNlIcQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642170042; a=rsa-sha256; cv=none; b=jt4YM37kkvMXvaO7hsxrze1uohqe4eOMNm5WDLrehYZDV1aqEJznKWmjf8xC2oVV9kZe2a qRzAjvS/24tvnEJa9el0WxEptyHHA1zzU48y/mHsM8gwY8+IJeZoaMNcks1FvJEtJQpCW0 rc4xpHe0RYNAcAs9wCwPxb657BMCTltJEYPdAoXJ650K8+CmE49Uj83SJR21GY6E304ftq IttdkusPOPfpRQnS1SLbttwdn2lPwjms4PWvtJhfr+Ld7Hxfek9hxP9Yi0y/1g+HBmoRld yEsMtdJMjDWJoqaT509t3d28z2WzWHKSAGyfcZj6ZqEGnTrSLJxMqw7YQVIGZQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=f281bda11a1a01abd911053325407205cffcf808 commit f281bda11a1a01abd911053325407205cffcf808 Author: Corvin Köhne AuthorDate: 2021-11-22 15:24:47 +0000 Commit: Emmanuel Vadot CommitDate: 2022-01-14 14:18:03 +0000 bhyve: use a fixed 32 bit BAR base address OVMF always uses 0xC0000000 as base address for 32 bit PCI MMIO space. For that reason, we should use that address too. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D31051 Sponsored by: Beckhoff Automation GmbH & Co. KG (cherry picked from commit 5cf21e48ccf114928da9c6564c7e5dec7d6119c5) bhyve: Fix compile We need err.h Fixes: 5cf21e48ccf11 ("bhyve: use a fixed 32 bit BAR base address") Sponsored by: Bechoff Automation GmbH & Co. KG (cherry picked from commit fc7207c87795da4533dc7f97287638f6da85b3b0) --- usr.sbin/bhyve/pci_emul.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c index cbcd8154b2b1..0b46bcc6200e 100644 --- a/usr.sbin/bhyve/pci_emul.c +++ b/usr.sbin/bhyve/pci_emul.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -43,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -110,6 +112,11 @@ static uint64_t pci_emul_memlim64; #define PCI_EMUL_ECFG_SIZE (MAXBUSES * 1024 * 1024) /* 1MB per bus */ SYSRES_MEM(PCI_EMUL_ECFG_BASE, PCI_EMUL_ECFG_SIZE); +/* + * OVMF always uses 0xC0000000 as base address for 32 bit PCI MMIO. Don't + * change this address without changing it in OVMF. + */ +#define PCI_EMUL_MEMBASE32 0xC0000000 #define PCI_EMUL_MEMLIMIT32 PCI_EMUL_ECFG_BASE #define PCI_EMUL_MEMSIZE64 (32*GB) @@ -1156,8 +1163,11 @@ init_pci(struct vmctx *ctx) int bus, slot, func; int error; + if (vm_get_lowmem_limit(ctx) > PCI_EMUL_MEMBASE32) + errx(EX_OSERR, "Invalid lowmem limit"); + pci_emul_iobase = PCI_EMUL_IOBASE; - pci_emul_membase32 = vm_get_lowmem_limit(ctx); + pci_emul_membase32 = PCI_EMUL_MEMBASE32; pci_emul_membase64 = 4*GB + vm_get_highmem_size(ctx); pci_emul_membase64 = roundup2(pci_emul_membase64, PCI_EMUL_MEMSIZE64); @@ -1262,8 +1272,8 @@ init_pci(struct vmctx *ctx) /* * The guest physical memory map looks like the following: * [0, lowmem) guest system memory - * [lowmem, lowmem_limit) memory hole (may be absent) - * [lowmem_limit, 0xE0000000) PCI hole (32-bit BAR allocation) + * [lowmem, 0xC0000000) memory hole (may be absent) + * [0xC0000000, 0xE0000000) PCI hole (32-bit BAR allocation) * [0xE0000000, 0xF0000000) PCI extended config window * [0xF0000000, 4GB) LAPIC, IOAPIC, HPET, firmware * [4GB, 4GB + highmem)