From nobody Wed Apr 05 10:02:31 2023 X-Original-To: dev-commits-src-all@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 4Ps0YN1WZ0z44BPf; Wed, 5 Apr 2023 10:02:32 +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 4Ps0YN14D2z4Lnf; Wed, 5 Apr 2023 10:02:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680688952; 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=XU2lSggeB8LSjvSl/KePskTa9pSn46hm7lp5BtELJnk=; b=E38+3e+O8zuVVbMc3txY0IRD+C5MBOCbckFC0XhO6ukXZgrWMRpObJ0j2GA/Uz7r0N1Nn/ OQq5EOL41tuabmChF3pIdfWjRMXUNhhnbXMNNe2tmIQ4ZExs+RXJ/gDoZuiqydrUX3ihRD wch3/ssNTr8AGckMxi5FwYz/hrt4kMY7I7ItH2v1mOsbQFnMYjfqZX2UUZdIndIoxRXGxt erd2qPrTEEteq0NlTX8MdzCPkO+/Vt8/EF0hYFxuvtAdVxEU1yrSt5f0UioV4Iv3QQPCXi w/6T5lJXnYNMkp52wx4zM81d3Oz4hZtkY3s3kzjeuxHqaBkB7ZiBc2FT2SRDMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680688952; 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=XU2lSggeB8LSjvSl/KePskTa9pSn46hm7lp5BtELJnk=; b=PwZyp0dg42/U4KM6x17ra7fA6zfXdMGkmuOJEZHqOJVc81N4Vw6ZzckeOvJnn5u0T5LwNE EdKQ1DVPUefdeKTMBVEHwT3ml2TZOWQ84xSR8rQmWpyJOd88rexjLuHpZRtWT1H0fKuSqE bRpqSkRfI1pUrBtpFK5UMlk0eeJ2Sf6NE4nwKypvdVXwh1SpILxD+Vz+Bmqa0EEASux7TA H6Z2qc5ci2Ci76Ec3emcloV0CcUTFEBj9vMEvs6/iGD26IFq1iICvXg4oxW8I9VOAgljrt VcYJcb5a9yQME+RdAuaVB7SKCBXxSOWMCgqw+bci4E2EgUyCG7Niiv7IWtrPag== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1680688952; a=rsa-sha256; cv=none; b=qbQcfkqYvCNz9gssrUcrQHoRwGSGr69l5KGQgzcB2+YOxzHQ6SIMI0PhZYq5vEosDXsUBi Ev+Wck1co89k2gI+/1HFiYS36+CCizTOnkZECwEM79ikfEMMWJ4PBlr663gsOW6VSIrO57 uRJVyU7ArMML5Dqtw4FpJasrZMTdjqGcBVjxCENSFP0C/j0sofqOuIQbTDDPcCeVuWYklJ ShPI98yFFKLa8y6NLH4JgUj95C+OnV7iziBTBDp0+aC2T42w3gF82rKsL2eBFWF7e3DZJg Ti7KWkI6903/K0RImr44me8dsQJHxPSN00IGs/qQY5vr09s/vQzEdjvXxz/dnQ== 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 4Ps0YM75T7zJYQ; Wed, 5 Apr 2023 10:02:31 +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 335A2VlB040390; Wed, 5 Apr 2023 10:02:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 335A2Vit040389; Wed, 5 Apr 2023 10:02:31 GMT (envelope-from git) Date: Wed, 5 Apr 2023 10:02:31 GMT Message-Id: <202304051002.335A2Vit040389@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Corvin=20K=C3=B6hne?= Subject: git: ab64356b1c9d - stable/13 - bhyve: make use of helper to read PCI IDs from bhyve config List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: ab64356b1c9d5c30875303c231c772df553d3bb2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=ab64356b1c9d5c30875303c231c772df553d3bb2 commit ab64356b1c9d5c30875303c231c772df553d3bb2 Author: Corvin Köhne AuthorDate: 2023-02-06 10:13:56 +0000 Commit: Corvin Köhne 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 __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); }