From nobody Tue Sep 23 14:28:10 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 4cWMlb0d7dz68jZg; Tue, 23 Sep 2025 14:28:11 +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 4cWMlZ6zvhz3kps; Tue, 23 Sep 2025 14:28:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758637691; 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=9AFqnoD/XJzHzuJbDUWnflanL3ln8w8/aYRdG5Phwko=; b=G9YLKdCKS50IiIyZMmSNP+oAOG4UP+ZzpDaY9k+9pTfbtxGLR4Yrcc/WW3RSUF505IMY7m IQHmQINr1vdRDRAmlide4RiaeI+qvPXSdTYLBsntlLkjsP/3S7wwVotS2o72+Bd50aJDck 8xJKXBcjwu2kalM7p3Pa4+0X/hjhJA6Lgq12tmM2R3Uf5LVuGUl2FgShLNGmOTFyAzOAym B3bGaTglPp4SNrjVsmU3yFCjjL355LitFTiuxWONcNIGPs3jQIwhHKVjHxRosc1N6e0TJi OwCeHvMrU7iGOzIZjuRj5CgsJGI/88PJSZHj91kpWtTeBjj8tw/1tTXyMocfDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758637691; 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=9AFqnoD/XJzHzuJbDUWnflanL3ln8w8/aYRdG5Phwko=; b=yq2s+B3qbXvqW6qfvkIjLdtn33cFn+hdNvp7uVwjf5iBlNZnKUMAP8aeK3qXJERoj/3hii ymF5zMOdHPVB0bgzRaYrYvGinnS19TUUcwzYQV1mCGEvQpgzuxqVOfX0W8RgAJl2LlBz1w IFnO7SXRm/zkECZqUZcqmnWmPdb04wy350yNk5V2UD0ngI/GHBENhHlXyvATh5HQ09cf0P u5IaZzBjwz1KqwipU9sqX3q2lnuVHT9clEhmsDRsbf1w52QC5KBEmOFPamrrHxjzeIFsdw Yol1DogGZzY0F0P+3scrT9cW/mWCWtTY8JjZkRm6A6NwcD3/53g9B+x3sthofQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1758637691; a=rsa-sha256; cv=none; b=Fg+y7LHwK5L0Ph84g0wJzqwzz2zo99MxZhHeQeFfEmpoeFMG6xg540LFkTU22Y3O7eaTyL 214kHQ3WSOV94IM5bVxRIV/eDw6552eYlXDGSCsFq7iEj+6tSQKJ/vTdtkEtuX/JXPZ/Il in1YLY79awumWcey71kjzZHL4jZ0TGS8GdMu1Ms4K2DRDiaLZlGyMLcXFoVL5bCTdg5z4t yNaJw9uc5/DBtIPpqJ11WqUXvyB2XjpGv6BW/MBMAcUCx6a0PfcPrt3ft1ETqZGxMXI3ex icUAxy/xivbC7+w8SLuCC0fEYHyTOo07GH0ZI6hkQ6/vrPETdat5dGrmSbtJfQ== 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 4cWMlZ6ZsFzqNv; Tue, 23 Sep 2025 14:28: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 58NESAB4074394; Tue, 23 Sep 2025 14:28:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58NESAnB074391; Tue, 23 Sep 2025 14:28:10 GMT (envelope-from git) Date: Tue, 23 Sep 2025 14:28:10 GMT Message-Id: <202509231428.58NESAnB074391@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: d0efd64479ed - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: d0efd64479ed55c74bfa55c1ed23c13d732ee27a Auto-Submitted: auto-generated The branch stable/14 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=d0efd64479ed55c74bfa55c1ed23c13d732ee27a commit d0efd64479ed55c74bfa55c1ed23c13d732ee27a Author: Corvin Köhne AuthorDate: 2022-03-17 12:11:14 +0000 Commit: Corvin Köhne CommitDate: 2025-09-23 14:13:34 +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/Makefile | 1 + usr.sbin/bhyve/pci_passthru_quirks.c | 48 ++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/usr.sbin/bhyve/Makefile b/usr.sbin/bhyve/Makefile index f4dae2f09904..edc556ee373f 100644 --- a/usr.sbin/bhyve/Makefile +++ b/usr.sbin/bhyve/Makefile @@ -41,6 +41,7 @@ SRCS= \ pci_hostbridge.c \ pci_nvme.c \ pci_passthru.c \ + pci_passthru_quirks.c \ pci_virtio_9p.c \ pci_virtio_block.c \ pci_virtio_console.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);