From nobody Fri Jan 14 14:20:40 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 84FE8195D953; Fri, 14 Jan 2022 14:20:43 +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 4Jb3P53jY0z3M7Y; 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=1642170043; 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=AL3mqu6Ne++FEKwHMz6gGPzqrimH1ELSDzfpVkn+Zxc=; b=RgJVs62K7hmOcXmG5s3ZH523wK7OJ8AobfAutXfAHAIb7+xeNNCttRUH/Ar638geRLVCI8 OuUPWOA+G2EwYIUPT2FuNrn1iQtMkWABldm6W+eB9zQlp/Af8SI2Bc7VGausVVN79Pafqi JlRlq70CW8dog59Rrytl6EVhNJbPotZL/skESSb8954E1+GDh1mv25AcTYW1QRa/QDPbl7 t5mtWo3CS8+MJzdONxk3xa1DU+Z3qcFu7z5zG2Z8lbfxwVKWVWgWr4WO/isLOasQgPV//t hCfYdKkrhTkvjHNc8jaNVdiXI3IBrTwxNOOU9JTucGC53+xwdIMldjFvO6TXTw== 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 4B2D715370; Fri, 14 Jan 2022 14:20:40 +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 20EEKeIW087965; Fri, 14 Jan 2022 14:20:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20EEKeT9087964; Fri, 14 Jan 2022 14:20:40 GMT (envelope-from git) Date: Fri, 14 Jan 2022 14:20:40 GMT Message-Id: <202201141420.20EEKeT9087964@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: 366b4fc2d569 - stable/13 - bhyve: move 64 bit BAR location to match OVMF assumptions 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: 366b4fc2d569c44432b201335b2405d4a97fb549 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642170043; 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=AL3mqu6Ne++FEKwHMz6gGPzqrimH1ELSDzfpVkn+Zxc=; b=Yk40t+rYbsDTgCCHDfZj8jX+pT6NRApdBhCbDGEUQ645Celt4GAJvqYvhYSIRqS6YTbvmE ypvEz/Llh538+yRtZWOgQ9i2XDsK2+jj3BLow+/XWl2KdOHnMchwi0qAinPVIAyhCwJypb t/ABH6Fpgh9/F2kk81pM8EpwLXIiHDwd0xCQxt+ySeLQigqq8m2SOVMHKkVPte+MIht54+ D1/7NCBrZHne6hL0M2aA5rGFKu950oPe/quiVXLqVWu4z0NtCQmQLTzHQyQWB2vbzivQpc KdLA1VqTgRG9Mmms17PvbOo10dzXfy2KpfcmdET2iU00H0DR0x22tOGS1DygpQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642170043; a=rsa-sha256; cv=none; b=Cyok1+245pgPwJEmLtsg+lV/Eq3Nize0PCeAxtV+bzH46z28p2NFwkr38B+SPvHDQsZ3GJ 7IvGjG+ERkIcmhagRCdLi4g6tpgXiAuAtdsEJFhhcyvBos3LhKTJjCp1NVPXTv1WXH2rl+ AwV9kis7/Bvp0B+sdvw6jZo1xtGBA4ynhog91/h3DZLt3PSalVg3KZa/I5XERFj9PDEuvf iOsY/Qu//TACtu6vzeMlsMpzqlca2vfFGIQCmappEAAB+vTUNCm7DT0kISSNNUXu71lBGk o9xY6cTHaS5BorYwBv7dK5V2LVc7vQKUsQlZAbJFNJuF0sfJf3mtwSm4XdJ05A== 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=366b4fc2d569c44432b201335b2405d4a97fb549 commit 366b4fc2d569c44432b201335b2405d4a97fb549 Author: Corvin Köhne AuthorDate: 2021-11-22 15:22:48 +0000 Commit: Emmanuel Vadot CommitDate: 2022-01-14 14:17:32 +0000 bhyve: move 64 bit BAR location to match OVMF assumptions OVMF will fail, if large 64 bit BARs are used. GCD-Map doesn't cover 64 bit addresses of BARs. OVMF assumes that 64 bit addresses of BARS are located on next 32 GB boundary behind Top of High RAM. This patch moves 64 bit BARs on next 32 GB boundary behind Top of High RAM to match OVMF assumptions. Differential Revision: https://reviews.freebsd.org/D27970 Sponsored by: Beckhoff Automation GmbH & Co. KG (cherry picked from commit 4a4053e1b053e840cf167a629f8d2b8ae76e6da7) --- usr.sbin/bhyve/pci_emul.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c index bd94859c4ea1..cbcd8154b2b1 100644 --- a/usr.sbin/bhyve/pci_emul.c +++ b/usr.sbin/bhyve/pci_emul.c @@ -33,9 +33,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include -#include #include #include @@ -49,8 +46,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include "acpi.h" @@ -73,6 +68,8 @@ __FBSDID("$FreeBSD$"); #define MAXSLOTS (PCI_SLOTMAX + 1) #define MAXFUNCS (PCI_FUNCMAX + 1) +#define GB (1024 * 1024 * 1024UL) + struct funcinfo { nvlist_t *fi_config; struct pci_devemu *fi_pde; @@ -114,6 +111,7 @@ static uint64_t pci_emul_memlim64; SYSRES_MEM(PCI_EMUL_ECFG_BASE, PCI_EMUL_ECFG_SIZE); #define PCI_EMUL_MEMLIMIT32 PCI_EMUL_ECFG_BASE +#define PCI_EMUL_MEMSIZE64 (32*GB) static struct pci_devemu *pci_emul_finddev(const char *name); static void pci_lintr_route(struct pci_devinst *pi); @@ -1155,25 +1153,15 @@ init_pci(struct vmctx *ctx) nvlist_t *nvl; const char *emul; size_t lowmem; - uint64_t cpu_maxphysaddr, pci_emul_memresv64; - u_int regs[4]; - int bus, slot, func, error; + int bus, slot, func; + int error; pci_emul_iobase = PCI_EMUL_IOBASE; pci_emul_membase32 = vm_get_lowmem_limit(ctx); - do_cpuid(0x80000008, regs); - cpu_maxphysaddr = 1ULL << (regs[0] & 0xff); - if (cpu_maxphysaddr > VM_MAXUSER_ADDRESS_LA48) - cpu_maxphysaddr = VM_MAXUSER_ADDRESS_LA48; - pci_emul_memresv64 = cpu_maxphysaddr / 4; - /* - * Max power of 2 that is less then - * cpu_maxphysaddr - pci_emul_memresv64. - */ - pci_emul_membase64 = 1ULL << (flsl(cpu_maxphysaddr - - pci_emul_memresv64) - 1); - pci_emul_memlim64 = cpu_maxphysaddr; + pci_emul_membase64 = 4*GB + vm_get_highmem_size(ctx); + pci_emul_membase64 = roundup2(pci_emul_membase64, PCI_EMUL_MEMSIZE64); + pci_emul_memlim64 = pci_emul_membase64 + PCI_EMUL_MEMSIZE64; for (bus = 0; bus < MAXBUSES; bus++) { snprintf(node_name, sizeof(node_name), "pci.%d", bus);