Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Apr 2023 10:02:31 GMT
From:      =?utf-8?Q?Corvin=20K=C3=B6hne?= <corvink@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: ab64356b1c9d - stable/13 - bhyve: make use of helper to read PCI IDs from bhyve config
Message-ID:  <202304051002.335A2Vit040389@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by corvink:

URL: https://cgit.FreeBSD.org/src/commit/?id=ab64356b1c9d5c30875303c231c772df553d3bb2

commit ab64356b1c9d5c30875303c231c772df553d3bb2
Author:     Corvin Köhne <corvink@FreeBSD.org>
AuthorDate: 2023-02-06 10:13:56 +0000
Commit:     Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2023-04-05 10:00:39 +0000

    bhyve: make use of helper to read PCI IDs from bhyve config
    
    For compatibilty reasons, the old config values are still supported.
    
    Reviewed by:            jhb
    MFC after:              1 week
    Sponsored by:           Beckhoff Automation GmbH & Co. KG
    Differential Revision:  https://reviews.freebsd.org/D38403
    
    (cherry picked from commit b72e06b13ee08b94a3e74ac2473e889aeb7a3d1a)
---
 usr.sbin/bhyve/bhyve_config.5   | 11 +++++++----
 usr.sbin/bhyve/pci_hostbridge.c | 17 +++++++++++++++--
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/usr.sbin/bhyve/bhyve_config.5 b/usr.sbin/bhyve/bhyve_config.5
index 31f848740aa8..9482d1260e05 100644
--- a/usr.sbin/bhyve/bhyve_config.5
+++ b/usr.sbin/bhyve/bhyve_config.5
@@ -412,12 +412,15 @@ to use standard input and output of the
 process.
 .El
 .Ss Host Bridge Settings
-.Bl -column "vendor" "integer" "Default"
+.Bl -column "pcireg.*" "integer" "Default"
 .It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description
+.It Va pcireg.* Ta integer Ta Ta
+Values of PCI register.
+.Bl -column "device" "Default"
+.It Sy Name Ta Sy Default
 .It Va vendor Ta integer Ta 0x1275 Ta
-PCI vendor ID.
-.It Va devid Ta integer Ta 0x1275 Ta
-PCI device ID.
+.It Va device Ta integer Ta 0x1275 Ta
+.El
 .El
 .Ss AHCI Controller Settings
 AHCI controller devices contain zero or more ports each of which
diff --git a/usr.sbin/bhyve/pci_hostbridge.c b/usr.sbin/bhyve/pci_hostbridge.c
index f0878d97a77e..cbc61893961b 100644
--- a/usr.sbin/bhyve/pci_hostbridge.c
+++ b/usr.sbin/bhyve/pci_hostbridge.c
@@ -31,6 +31,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include <err.h>
 #include <stdlib.h>
 
 #include "config.h"
@@ -48,9 +49,13 @@ pci_hostbridge_init(struct pci_devinst *pi, nvlist_t *nvl)
 	value = get_config_value_node(nvl, "vendor");
 	if (value != NULL)
 		vendor = strtol(value, NULL, 0);
+	else
+		vendor = pci_config_read_reg(NULL, nvl, PCIR_VENDOR, 2, vendor);
 	value = get_config_value_node(nvl, "devid");
 	if (value != NULL)
 		device = strtol(value, NULL, 0);
+	else
+		device = pci_config_read_reg(NULL, nvl, PCIR_DEVICE, 2, device);
 
 	/* config space */
 	pci_set_cfgdata16(pi, PCIR_VENDOR, vendor);
@@ -67,8 +72,16 @@ pci_hostbridge_init(struct pci_devinst *pi, nvlist_t *nvl)
 static int
 pci_amd_hostbridge_legacy_config(nvlist_t *nvl, const char *opts __unused)
 {
-	set_config_value_node(nvl, "vendor", "0x1022");	/* AMD */
-	set_config_value_node(nvl, "devid", "0x7432");	/* made up */
+	nvlist_t *pci_regs;
+
+	pci_regs = create_relative_config_node(nvl, "pcireg");
+	if (pci_regs == NULL) {
+		warnx("amd_hostbridge: failed to create pciregs node");
+		return (-1);
+	}
+
+	set_config_value_node(pci_regs, "vendor", "0x1022"); /* AMD */
+	set_config_value_node(pci_regs, "device", "0x7432"); /* made up */
 
 	return (0);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202304051002.335A2Vit040389>