From nobody Mon Mar 27 08:11:40 2023 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 4PlQWc5PsBz41wky; Mon, 27 Mar 2023 08:11: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 4PlQWc4vyvz483h; Mon, 27 Mar 2023 08:11:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679904700; 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=c9RLwBF0aqNMbqSlHHtBvlweCt88IHEikfd/oKBFQOc=; b=mYpSW9M5rBMeeGUNEtVCvWIDYY1Z6CcwXOTyPdZexitO6WOFpSWVDofxs7azIkXUxVyy8B ZXs0SHUQaDSoq9rhZ5p9jFAUQ7HWrTayRcSrlmMIFa3kqQinJwjW0J3mwvlo9ugPSb2Kat xIaTgVzX8Dx3BeGV4zQwP+jgpjRcHCz+i6qD6L0JRqz8h9mAsT8JM7jEq78sxUTXEmWUnC rSZQnciNzwMid0CysHTm/8V99h4BJGbCgeaslZhOmBWPQ6QGWr1MCXkiizK4Lni/OtalGy VMOmexqbvAx1WICQEBmloPStSWM1dmotDpkfTU4zry/pi0xDJuUi3juRUvYm9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679904700; 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=c9RLwBF0aqNMbqSlHHtBvlweCt88IHEikfd/oKBFQOc=; b=v+0Bu4EeLnKpGnBRvaQlzbHDAoS6l4O5mdLw5ks55GSL+RKmdKWNNVWDAmeW4XjvkQKiyi M6dOMjEueYexte53Bkkw2xlA4/fauxsbOwWvav8ruFiL12bUjhXrgKWwu4K0L6zE+K4err UsxWXJ/sf+O3IawHdz0gsDEwBlrNgn1vTBFmwfae4CQNfk6/EowQhU1Ka96g1ybNLyU8E5 JdjLUak6tlM5t85Heu009ouPlmFXd77hIewYtH636YFHfIAz0TWFsUdFTdBCn2gRoyoedc qtAzHNvyDkBy1l58j4Axtw2Dy4sM71oxi0SbmUecXnfWfdqtyx8FVKymGjEnaQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679904700; a=rsa-sha256; cv=none; b=wvpkeCLtMONOQgfxgUd+T6+C6zbsVyl1HqbqUas5GL6q84Hu839Ee7VwCGiqegL689tSfZ 2qGxDtyxViUb/Fa+pjoexguhdnZoPr+OmZ76D2R7vcgo+RAMDQ0aXfNjo1JOirDJuITIp9 zPtjEn7ZNvTqV67lHR65MZKw83pwF8nWHk3Y81f7E1KSV0RN2TLYHrdkpdEDtBY1kbvT4X tyjx9O2z275lFx6SR07SqDIlVPHHLGRDSJsbscU3ncWbNcP96XfCoMQfdv8AqMMltwSUE0 zhtC5q12uqB+HjZnX36YtcyE1O3ZtHAGCYmSkhTcmnTxiQoyltPLl5NBcfu+pQ== 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 4PlQWc3kTZzF5x; Mon, 27 Mar 2023 08:11: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 32R8Be7S043746; Mon, 27 Mar 2023 08:11:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32R8Be9L043745; Mon, 27 Mar 2023 08:11:40 GMT (envelope-from git) Date: Mon, 27 Mar 2023 08:11:40 GMT Message-Id: <202303270811.32R8Be9L043745@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Corvin=20K=C3=B6hne?= Subject: git: b72e06b13ee0 - main - bhyve: make use of helper to read PCI IDs from bhyve config 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: corvink X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b72e06b13ee08b94a3e74ac2473e889aeb7a3d1a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=b72e06b13ee08b94a3e74ac2473e889aeb7a3d1a commit b72e06b13ee08b94a3e74ac2473e889aeb7a3d1a Author: Corvin Köhne AuthorDate: 2023-02-06 10:13:56 +0000 Commit: Corvin Köhne CommitDate: 2023-03-27 08:10:24 +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 --- 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 32658c11f9e2..ddfcae8c51d3 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 __FBSDID("$FreeBSD$"); +#include #include #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); }