From nobody Mon Aug 19 13:59:10 2024 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 4WnZ2k6FPXz5T4lF; Mon, 19 Aug 2024 13:59:10 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WnZ2k4Z0bz4nbN; Mon, 19 Aug 2024 13:59:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724075950; 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=nTiPBILVzBCL8ijGuxyIPLCW3SHVzR9U/zgkBkawcwE=; b=L7iqjN0hyUhLcwbmE+R0h7GQEvSF0SZUx51ueaQSqDiLlmzTUjUrzhJUlzfM3vkR/RYpAb 1rVl1/Rtmv3HzXv3J9lnm3zv5kyV9TSLS0Ab/lyik9FEQ20FzK03M8LYhq+cpVsf8vKhll dVC999O2z8+m32bDY+/h3jscTtvonXr9OgIAlZkNYabyoru5DMjxhXf42AcqAXzyMM/pvi 8JChTpH4GEKkf0uyAqp9OGkh4WEtzRrpy2vCtZmCEH5Qu5Sb2zJh1vdYWSooONsNj6bx60 2VQd3XqQcD+hZT6+hltKSPw3m5rmtw8nLEsqn27FijGyJ+8tQFWoDztKCobeDg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724075950; a=rsa-sha256; cv=none; b=Z6kIPbMQay1vjAOBMAUKJfsl0rXUvPxVRmev9ad24IctRljVmp7qZ3tkPc1ib7cXa+jQxn N3bcec8u2uhUb+FrwxY3IVKDGjiwvz/8E614UcSSyaWnwsroZvpOcODWmQO8jcL87wsQcS CMLaKHFL7XYOUJjiT2T0Tjfqoeop8hk3POeMZZ/o55WJKE6eJfYUp5RBhnEymNDDMhii+k uRz9vIwiFpl4dIioBPeUCHWdetRFFCPiGJzS7hrmdW/+Q8FHHg2zhjkxPSSnF52ipLc66c BAu6v+caKh/uKfkiQvZpSLAmIj1L297dp92r+8PnILxfMbP7QYW0WIztBzKwLA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724075950; 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=nTiPBILVzBCL8ijGuxyIPLCW3SHVzR9U/zgkBkawcwE=; b=kSQ5qA8kp7uG3nJ9q0AO9g0BQEbDm+N/4dVrn/X1HHXqBLBNJoedw3DI+HDa/AxFzenVHx gCzjvkCEj7VbJxvK+dKqrxOMMcMaej0RDQrnR0C3V7Ncdig/p39OOJe84nMFUrLhXfICt/ 8rDCzWhesgrkhCc9AaJ6Jvw1HOhkcpxFrgDYoqwhoow4XIUKeHmkWPwWYstLpARpgpAa+/ ngAmNXUFrFI6ciK/FADqdOgg3BN4ZpDjV//cD6eiQaHzg/hEmILAs3XDWvstvY4p7xRPNw g6ZaB4cOgYY41cU04TycMq2bpq481rtPFeqmAF/j7453R49yOY4sn418u22/lA== 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 4WnZ2k49HXzJPq; Mon, 19 Aug 2024 13:59:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 47JDxAdl026032; Mon, 19 Aug 2024 13:59:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47JDxAbK026029; Mon, 19 Aug 2024 13:59:10 GMT (envelope-from git) Date: Mon, 19 Aug 2024 13:59:10 GMT Message-Id: <202408191359.47JDxAbK026029@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: e962b37bf0ff - main - bhyve: Do not enable PCI BAR decoding if a boot ROM is present 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e962b37bf0ffe7f30f5b025b46ea49ba01c71f2f Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e962b37bf0ffe7f30f5b025b46ea49ba01c71f2f commit e962b37bf0ffe7f30f5b025b46ea49ba01c71f2f Author: Mark Johnston AuthorDate: 2024-08-19 13:56:06 +0000 Commit: Mark Johnston CommitDate: 2024-08-19 13:56:06 +0000 bhyve: Do not enable PCI BAR decoding if a boot ROM is present Let the boot ROM handle BAR initialization. This fixes a problem where u-boot's BAR remapping conflicts with some limitations in bhyve. See https://lists.freebsd.org/archives/freebsd-virtualization/2024-April/002103.html for a description of what goes wrong. The old behaviour can be restored by setting the pci.enable_bars configuration variable. Reviewed by: corvink, jhb Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D45049 --- usr.sbin/bhyve/bhyve_config.5 | 3 +++ usr.sbin/bhyve/pci_emul.c | 27 ++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bhyve/bhyve_config.5 b/usr.sbin/bhyve/bhyve_config.5 index ebbb206cca9f..25185e2ef1b4 100644 --- a/usr.sbin/bhyve/bhyve_config.5 +++ b/usr.sbin/bhyve/bhyve_config.5 @@ -157,6 +157,9 @@ Specify the keyboard layout name with the file name in This value only works when loaded with UEFI mode for VNC, and used a VNC client that don't support QEMU Extended Key Event Message (e.g. TightVNC). +.It Va pci.enable_bars Ta bool Ta Ta +Enable and map PCI BARs before executing any guest code. +This setting is false by default when using a boot ROM and true otherwise. .It Va tpm.path Ta string Ta Ta Path to the host TPM device. This is typically /dev/tpm0. diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c index 00e9138d3910..e066d6766f3c 100644 --- a/usr.sbin/bhyve/pci_emul.c +++ b/usr.sbin/bhyve/pci_emul.c @@ -48,6 +48,7 @@ #include "acpi.h" #include "bhyverun.h" +#include "bootrom.h" #include "config.h" #include "debug.h" #ifdef __amd64__ @@ -853,6 +854,14 @@ pci_emul_alloc_bar(struct pci_devinst *pdi, int idx, enum pcibar_type type, TAILQ_INSERT_BEFORE(bar, new_bar, chain); } + /* + * Enable PCI BARs only if we don't have a boot ROM, i.e., bhyveload was + * used to load the initial guest image. Otherwise, we rely on the boot + * ROM to handle this. + */ + if (!get_config_bool_default("pci.enable_bars", !bootrom_boot())) + return (0); + /* * pci_passthru devices synchronize their physical and virtual command * register on init. For that reason, the virtual cmd reg should be @@ -966,8 +975,19 @@ pci_emul_assign_bar(struct pci_devinst *const pdi, const int idx, pci_set_cfgdata32(pdi, PCIR_BAR(idx + 1), bar >> 32); } - if (type != PCIBAR_ROM) { - register_bar(pdi, idx); + switch (type) { + case PCIBAR_IO: + if (porten(pdi)) + register_bar(pdi, idx); + break; + case PCIBAR_MEM32: + case PCIBAR_MEM64: + case PCIBAR_MEMHI64: + if (memen(pdi)) + register_bar(pdi, idx); + break; + default: + break; } return (0); @@ -1140,7 +1160,8 @@ pci_emul_init(struct vmctx *ctx, struct pci_devemu *pde, int bus, int slot, pci_set_cfgdata8(pdi, PCIR_INTLINE, 255); pci_set_cfgdata8(pdi, PCIR_INTPIN, 0); - pci_set_cfgdata8(pdi, PCIR_COMMAND, PCIM_CMD_BUSMASTEREN); + if (!get_config_bool_default("pci.enable_bars", !bootrom_boot())) + pci_set_cfgdata8(pdi, PCIR_COMMAND, PCIM_CMD_BUSMASTEREN); err = (*pde->pe_init)(pdi, fi->fi_config); if (err == 0)