From nobody Tue Sep 23 14:05:04 2025 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 4cWMDw4rhZz68hTT; Tue, 23 Sep 2025 14:05:04 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cWMDw45Plz3fv9; Tue, 23 Sep 2025 14:05:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758636304; 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=UweiGn47pMPwjfENyvvnSXpU4Sr+zEueUSDMWqIs+F0=; b=NjLL+gQnDBICLvUlKOzrthJoeV8Z0Yg5P7zIx49g/z+iRZU4hvnf9HoIbPQPItokx1ipva CoWrcus3x1sOiE64q1dAKfReMtoKulqd2T35OHH4kkYsjpxqHBef1KVArNymsAyqaYwUWC bdZLx0/p54Qhucbw0HM36IrsD2t1DD5B0MeMyMIyMhX7cGyadOC4HowjfuraAx4aHGPn6i kUx88NdRnKDULifXC4PJwN10aHEE2whzkMAqGGhH1A2fG+JHv/SjbaIcmwc6DV1jv2m5dT eiHumjCDpdSQXeO8gWDceja/J///MNgE3FC6oXYXj1z1g2U1jNGVtOkQc62ESQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758636304; 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=UweiGn47pMPwjfENyvvnSXpU4Sr+zEueUSDMWqIs+F0=; b=mdm/+sMqeme/r9B51XUNOxU2VhF6UBUOIZvKPfzkV9N1rf5c1uZgi6cqOqSQVWilqwProH fIyFF3d0VTazG83XSFXN2VxZ12UQQwklA5dRXOzbPjRXoh3Qbdsy35PdxT9zVcCVwWTzto KJpgGF858exe7UrC/LF1B/fNd2Dv4rEkQQn/ZR4JwNC0NgJSPClvR5WoruFGAa5ZzVii8W HY7QjpAO9uvxk1jQe5HDLUfUpfOqsH5U8Y6RPNhYzDnI418G+uzhE87KJcvfiUb9WFQq43 wEqWOndjbJlc6/wSH/ZGX290oyzT87CFdBaRdnZRrdq0NGQUY2Ivkv7jZWRdew== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1758636304; a=rsa-sha256; cv=none; b=Qvpqan1xwMfEYWt+15U2jmicYSaBXorCLtCvKD6yddfEPo2+YAkV3Awg2xm51YzAXriMd1 9hs46TG0bktFgGTFo+XpapVrxT8C/5/UVKWqjt5w975Z4SnOObFirr2Z5YdSQxA2otXyC1 k+NS7TAuwjUcA278Xpr0+c2IpIDENyPcAUaSAnVdycUxPPQ9t2UiKARGaZCK8UhO7xmw8Z Mt2tPNNoTBpbkhCs6rbX2f5ciP/Z6XcKSG512mFK2TFOvLYmUmw+YFj01o1batYY4rJHEv ZqPfbxlUHiKnwmBJ2Bi4ZXzsnTe2kUCo+f53QAaF3b+JXfzJ36VvDiWJMS+Mkg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cWMDw3P4JzpgR; Tue, 23 Sep 2025 14:05:04 +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 58NE54pm036472; Tue, 23 Sep 2025 14:05:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58NE54al036469; Tue, 23 Sep 2025 14:05:04 GMT (envelope-from git) Date: Tue, 23 Sep 2025 14:05:04 GMT Message-Id: <202509231405.58NE54al036469@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Corvin =?utf-8?Q?K=C3=B6hne?= Subject: git: 5a8172dd6389 - stable/15 - bhyve: assign a valid INTPIN to NVIDIA GPUs 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/15 X-Git-Reftype: branch X-Git-Commit: 5a8172dd6389c1e647ae2fdb9c3534cab3933f86 Auto-Submitted: auto-generated The branch stable/15 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=5a8172dd6389c1e647ae2fdb9c3534cab3933f86 commit 5a8172dd6389c1e647ae2fdb9c3534cab3933f86 Author: Corvin Köhne AuthorDate: 2022-03-17 12:11:14 +0000 Commit: Corvin Köhne CommitDate: 2025-09-23 13:52:51 +0000 bhyve: assign a valid INTPIN to NVIDIA GPUs When passing an NVIDIA GPU to a Linux VM, the GPU driver refuses to work and complains about a missing IRQ: [ 77.208984] NVRM: Can't find an IRQ for your NVIDIA card! [ 77.212697] NVRM: Please check your BIOS settings. [ 77.212699] NVRM: [Plug & Play OS] should be set to NO [ 77.212700] NVRM: [Assign IRQ to VGA] should be set to YES [ 77.212702] nvidia: probe of 0000:00:07.0 failed with error -1 By setting a valid INTPIN in the PCI config space those error messages disappear. Additionally, tools like nvidia-smi are able to detect the GPU and the GPU driver seems to work properly. Note that bhyve still doesn't support legacy interrupts. So, the guest shouldn't try to use it even though we're assigning an INTPIN. Reviewed by: jhb Tested by: chuck MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D51892 (cherry picked from commit effcd0ded0ef1c92bef29c1e9bbf517c97bb45b8) --- usr.sbin/bhyve/amd64/Makefile.inc | 1 + usr.sbin/bhyve/pci_passthru_quirks.c | 48 ++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/usr.sbin/bhyve/amd64/Makefile.inc b/usr.sbin/bhyve/amd64/Makefile.inc index 92e53433ff01..50a011ed4bfd 100644 --- a/usr.sbin/bhyve/amd64/Makefile.inc +++ b/usr.sbin/bhyve/amd64/Makefile.inc @@ -13,6 +13,7 @@ SRCS+= \ pci_gvt-d.c \ pci_lpc.c \ pci_passthru.c \ + pci_passthru_quirks.c \ pctestdev.c \ pm.c \ post.c \ diff --git a/usr.sbin/bhyve/pci_passthru_quirks.c b/usr.sbin/bhyve/pci_passthru_quirks.c new file mode 100644 index 000000000000..5ba0e674f311 --- /dev/null +++ b/usr.sbin/bhyve/pci_passthru_quirks.c @@ -0,0 +1,48 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2025 Beckhoff Automation GmbH & Co. KG + * Author: Corvin Köhne + */ + +#include + +#include + +#include "pci_passthru.h" + +#define PCI_VENDOR_NVIDIA 0x10DE + +static int +nvidia_gpu_probe(struct pci_devinst *const pi) +{ + struct passthru_softc *sc; + uint16_t vendor; + uint8_t class; + + sc = pi->pi_arg; + + vendor = pci_host_read_config(passthru_get_sel(sc), PCIR_VENDOR, 0x02); + if (vendor != PCI_VENDOR_NVIDIA) + return (ENXIO); + + class = pci_host_read_config(passthru_get_sel(sc), PCIR_CLASS, 0x01); + if (class != PCIC_DISPLAY) + return (ENXIO); + + return (0); +} + +static int +nvidia_gpu_init(struct pci_devinst *const pi, nvlist_t *const nvl __unused) +{ + pci_set_cfgdata8(pi, PCIR_INTPIN, 1); + + return (0); +} + +static struct passthru_dev nvidia_gpu = { + .probe = nvidia_gpu_probe, + .init = nvidia_gpu_init, +}; +PASSTHRU_DEV_SET(nvidia_gpu);