From nobody Sun Feb 8 05:41:16 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F61537F8C9; Tue, 20 Jan 2026 06:43:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768891440; cv=none; b=oPBFcWcYG6EZ4RN0rHxiVWtfBD/s3qh9hlyf1KPpHnOvHILHe4bSWtBTfd39hMuZDU3AEKOCSdxM99XxX/GM45MPDv/uYMN+UobP+eN1iA3VCeOt4uX1I0xwasOvnKoPyl1B/yGCww7K4VLXQHxPa3WXXB+quqVX/v+9T6DlT+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768891440; c=relaxed/simple; bh=BalUxhQJ1yFzwpzZ+AK8cf6+vgLeWHhnt34Pqi87B4Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PtzpUtwrtVXhPk+6Ep0cKlFtnbvU8JSPiDNfoN4Lf5YZc7JfGQgQBt34RZREeKPEd1pCmO+2zqJ3KDK1OQI1+O1LyBYfmUDJNqRgbZ8VISOoJiDkvPZJC9MMXx3KH/nG1WGKjc0ME6+eGqdAuKlw3tlcuvZmMFuMhvxV2e90ZwQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=bWnfQDL5; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="bWnfQDL5" Received: from mrdev.corp.microsoft.com (192-184-212-33.fiber.dynamic.sonic.net [192.184.212.33]) by linux.microsoft.com (Postfix) with ESMTPSA id C8E3D20B7167; Mon, 19 Jan 2026 22:43:38 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C8E3D20B7167 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1768891419; bh=+gfNKWeY08Vm8PNbCFC1rEYtYrIGwfSMI5VrEew50HM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bWnfQDL5EUpEsU3VzMRuWBTbnZ3bATyez623M6D62i2f141uJAJGhHGyGTh+MdAt1 YP6Tq7BIRfj0D3JdRcLqQw3mfIdiF6PR0FqAQxPP+4n82vypfpQBll8q63FbRw9W+p wxIBkhEnSWn9JFFv8q8IWYkupEoY/QP4lQqvHtzE= From: Mukesh R To: linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-pci@vger.kernel.org, linux-arch@vger.kernel.org Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, longli@microsoft.com, catalin.marinas@arm.com, will@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, joro@8bytes.org, lpieralisi@kernel.org, kwilczynski@kernel.org, mani@kernel.org, robh@kernel.org, bhelgaas@google.com, arnd@arndb.de, nunodasneves@linux.microsoft.com, mhklinux@outlook.com, romank@linux.microsoft.com Subject: [PATCH v0 10/15] PCI: hv: Build device id for a VMBus device Date: Mon, 19 Jan 2026 22:42:25 -0800 Message-ID: <20260120064230.3602565-11-mrathor@linux.microsoft.com> X-Mailer: git-send-email 2.51.2.vfs.0.1 In-Reply-To: <20260120064230.3602565-1-mrathor@linux.microsoft.com> References: <20260120064230.3602565-1-mrathor@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mukesh Rathor On Hyper-V, most hypercalls related to PCI passthru to map/unmap regions, interrupts, etc need a device id as a parameter. This device id refers to that specific device during the lifetime of passthru. An L1VH VM only contains VMBus based devices. A device id for a VMBus device is slightly different in that it uses the hv_pcibus_device info for building it to make sure it matches exactly what the hypervisor expects. This VMBus based device id is needed when attaching devices in an L1VH based guest VM. Before building it, a check is done to make sure the device is a valid VMBus device. Signed-off-by: Mukesh Rathor --- arch/x86/include/asm/mshyperv.h | 2 ++ drivers/pci/controller/pci-hyperv.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyper= v.h index eef4c3a5ba28..0d7fdfb25e76 100644 --- a/arch/x86/include/asm/mshyperv.h +++ b/arch/x86/include/asm/mshyperv.h @@ -188,6 +188,8 @@ bool hv_vcpu_is_preempted(int vcpu); static inline void hv_apic_init(void) {} #endif =20 +u64 hv_pci_vmbus_device_id(struct pci_dev *pdev); + struct irq_domain *hv_create_pci_msi_domain(void); =20 int hv_map_msi_interrupt(struct irq_data *data, diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/p= ci-hyperv.c index 8bc6a38c9b5a..40f0b06bb966 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -579,6 +579,8 @@ static void hv_pci_onchannelcallback(void *context); #define DELIVERY_MODE APIC_DELIVERY_MODE_FIXED #define HV_MSI_CHIP_FLAGS MSI_CHIP_FLAG_SET_ACK =20 +static bool hv_vmbus_pci_device(struct pci_bus *pbus); + static int hv_pci_irqchip_init(void) { return 0; @@ -598,6 +600,26 @@ static unsigned int hv_msi_get_int_vector(struct irq_d= ata *data) =20 #define hv_msi_prepare pci_msi_prepare =20 +u64 hv_pci_vmbus_device_id(struct pci_dev *pdev) +{ + u64 u64val; + struct hv_pcibus_device *hbus; + struct pci_bus *pbus =3D pdev->bus; + + if (!hv_vmbus_pci_device(pbus)) + return 0; + + hbus =3D container_of(pbus->sysdata, struct hv_pcibus_device, sysdata); + u64val =3D (hbus->hdev->dev_instance.b[5] << 24) | + (hbus->hdev->dev_instance.b[4] << 16) | + (hbus->hdev->dev_instance.b[7] << 8) | + (hbus->hdev->dev_instance.b[6] & 0xf8) | + PCI_FUNC(pdev->devfn); + + return u64val; +} +EXPORT_SYMBOL_GPL(hv_pci_vmbus_device_id); + /** * hv_irq_retarget_interrupt() - "Unmask" the IRQ by setting its current * affinity. @@ -1404,6 +1426,13 @@ static struct pci_ops hv_pcifront_ops =3D { .write =3D hv_pcifront_write_config, }; =20 +#ifdef CONFIG_X86 +static bool hv_vmbus_pci_device(struct pci_bus *pbus) +{ + return pbus->ops =3D=3D &hv_pcifront_ops; +} +#endif /* CONFIG_X86 */ + /* * Paravirtual backchannel * --=20 2.51.2.vfs.0.1