{"id":2226035,"url":"http://patchwork.ozlabs.org/api/patches/2226035/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pci/patch/20260422023239.1171963-5-mrathor@linux.microsoft.com/","project":{"id":28,"url":"http://patchwork.ozlabs.org/api/projects/28/?format=json","name":"Linux PCI development","link_name":"linux-pci","list_id":"linux-pci.vger.kernel.org","list_email":"linux-pci@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260422023239.1171963-5-mrathor@linux.microsoft.com>","list_archive_url":null,"date":"2026-04-22T02:32:30","name":"[V1,04/13] mshv: Provide a way to get partition id if running in a VMM process","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"dbaa705678d8c52de7ee7a0aebc8fd0b04221633","submitter":{"id":91512,"url":"http://patchwork.ozlabs.org/api/people/91512/?format=json","name":"Mukesh R","email":"mrathor@linux.microsoft.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-pci/patch/20260422023239.1171963-5-mrathor@linux.microsoft.com/mbox/","series":[{"id":500915,"url":"http://patchwork.ozlabs.org/api/series/500915/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pci/list/?series=500915","date":"2026-04-22T02:32:26","name":"PCI passthru on Hyper-V (Part I)","version":1,"mbox":"http://patchwork.ozlabs.org/series/500915/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2226035/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2226035/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-pci+bounces-52899-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=linux.microsoft.com header.i=@linux.microsoft.com\n header.a=rsa-sha256 header.s=default header.b=s+NK51tP;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-pci+bounces-52899-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=linux.microsoft.com\n header.i=@linux.microsoft.com header.b=\"s+NK51tP\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=13.77.154.182","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=linux.microsoft.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=linux.microsoft.com"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0k5h6fcpz1yGs\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 12:42:16 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id DC5CA3050A0B\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 02:34:12 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 81E0C3803E8;\n\tWed, 22 Apr 2026 02:34:00 +0000 (UTC)","from linux.microsoft.com (linux.microsoft.com [13.77.154.182])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 594993815C5;\n\tWed, 22 Apr 2026 02:33:44 +0000 (UTC)","from mrdev.corp.microsoft.com\n (192-184-212-33.fiber.dynamic.sonic.net [192.184.212.33])\n\tby linux.microsoft.com (Postfix) with ESMTPSA id BD44420B6F15;\n\tTue, 21 Apr 2026 19:33:41 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776825236; cv=none;\n b=oO6SYhTO+9nm8Ht2ip/7znJV0sAZfBc1xiYNTXARa6N9rVsIKuw3oCCUVMXAFXr7aSjutVYFbLdpwnOhGCwx0vvcx+l2at/eFp/tgzVq2spz/zH3/L83LAqhO4RoCB/1JiS8hhj1+M7mBDat61QOsL/EoXiXVSsa3jO42H6/Fws=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776825236; c=relaxed/simple;\n\tbh=yqHoN0/B7kB4uVVOu+NW/uh2AcmRAs1ftzDdzQp4n00=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=jlj2j5Gk8H00aEuQMINC/AwZzLTXLZ9mKtuh9DRexe7aCyr4dk0d3eSTDU7TVhMj4z8+JHkNZGUe+xR+nvZuWnBjXCS8+wRORDpjEgwDRmn+rxD6n74ANhM0r9sk8FiQfizueph4wRtaiyr2+VfUa41/VI3BX5xcR1OBuzSkdSA=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=linux.microsoft.com;\n spf=pass smtp.mailfrom=linux.microsoft.com;\n dkim=pass (1024-bit key) header.d=linux.microsoft.com\n header.i=@linux.microsoft.com header.b=s+NK51tP;\n arc=none smtp.client-ip=13.77.154.182","DKIM-Filter":"OpenDKIM Filter v2.11.0 linux.microsoft.com BD44420B6F15","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com;\n\ts=default; t=1776825222;\n\tbh=F42zVdEs44T8GRjrW0mPW72by/e2QFwD5VC6Q2hyg6E=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=s+NK51tPdoLfcxZ6OffDm6U7IvvtWOvDL0BH4ln5pINhW0LUgQc8ibHZoufX7y6gY\n\t voDlcKrXSxemicI9qs5qJ3LSpm7jfovEK6myrTsLivNmMDyziKAsh6BhQj/wGyFFa1\n\t 2DrPOCAnCFSz15t0IL1xYXUKqU0PDWO3dcKCaw6Q=","From":"Mukesh R <mrathor@linux.microsoft.com>","To":"hpa@zytor.com,\n\trobin.murphy@arm.com,\n\trobh@kernel.org,\n\twei.liu@kernel.org,\n\tmrathor@linux.microsoft.com,\n\tmhklinux@outlook.com,\n\tmuislam@microsoft.com,\n\tnamjain@linux.microsoft.com,\n\tmagnuskulke@linux.microsoft.com,\n\tanbelski@linux.microsoft.com,\n\tlinux-kernel@vger.kernel.org,\n\tlinux-hyperv@vger.kernel.org,\n\tiommu@lists.linux.dev,\n\tlinux-pci@vger.kernel.org,\n\tlinux-arch@vger.kernel.org","Cc":"kys@microsoft.com,\n\thaiyangz@microsoft.com,\n\tdecui@microsoft.com,\n\tlongli@microsoft.com,\n\ttglx@kernel.org,\n\tmingo@redhat.com,\n\tbp@alien8.de,\n\tdave.hansen@linux.intel.com,\n\tx86@kernel.org,\n\tjoro@8bytes.org,\n\twill@kernel.org,\n\tlpieralisi@kernel.org,\n\tkwilczynski@kernel.org,\n\tbhelgaas@google.com,\n\tarnd@arndb.de","Subject":"[PATCH V1 04/13] mshv: Provide a way to get partition id if running\n in a VMM process","Date":"Tue, 21 Apr 2026 19:32:30 -0700","Message-ID":"<20260422023239.1171963-5-mrathor@linux.microsoft.com>","X-Mailer":"git-send-email 2.51.2.vfs.0.1","In-Reply-To":"<20260422023239.1171963-1-mrathor@linux.microsoft.com>","References":"<20260422023239.1171963-1-mrathor@linux.microsoft.com>","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit"},"content":"Many PCI passthru related hypercalls require partition id of the target\nguest. Guests are actually managed by MSHV driver and the partition id\nis only maintained there. Add a field in the partition struct in MSHV\ndriver to save the tgid of the VMM process creating the partition,\nand add a function there to retrieve partition id if current process\nis a VMM process.\n\nSigned-off-by: Mukesh R <mrathor@linux.microsoft.com>\n---\n drivers/hv/mshv_root.h         |  1 +\n drivers/hv/mshv_root_main.c    | 22 ++++++++++++++++++++++\n include/asm-generic/mshyperv.h |  5 +++++\n 3 files changed, 28 insertions(+)","diff":"diff --git a/drivers/hv/mshv_root.h b/drivers/hv/mshv_root.h\nindex 1f086dcb7aa1..a85c24dcc701 100644\n--- a/drivers/hv/mshv_root.h\n+++ b/drivers/hv/mshv_root.h\n@@ -138,6 +138,7 @@ struct mshv_partition {\n \n \tstruct mshv_girq_routing_table __rcu *pt_girq_tbl;\n \tu64 isolation_type;\n+\tpid_t pt_vmm_tgid;\n \tbool import_completed;\n \tbool pt_initialized;\n #if IS_ENABLED(CONFIG_DEBUG_FS)\ndiff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c\nindex bd1359eb58dd..02c107458be9 100644\n--- a/drivers/hv/mshv_root_main.c\n+++ b/drivers/hv/mshv_root_main.c\n@@ -1908,6 +1908,27 @@ mshv_partition_release(struct inode *inode, struct file *filp)\n \treturn 0;\n }\n \n+/* Given a process tgid, return partition id if it is a VMM process */\n+u64 mshv_current_partid(void)\n+{\n+\tstruct mshv_partition *pt;\n+\tint i;\n+\tu64 ret_ptid = HV_PARTITION_ID_INVALID;\n+\n+\trcu_read_lock();\n+\n+\thash_for_each_rcu(mshv_root.pt_htable, i, pt, pt_hnode) {\n+\t\tif (pt->pt_vmm_tgid == current->tgid) {\n+\t\t\tret_ptid = pt->pt_id;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\trcu_read_unlock();\n+\treturn ret_ptid;\n+}\n+EXPORT_SYMBOL_GPL(mshv_current_partid);\n+\n static int\n add_partition(struct mshv_partition *partition)\n {\n@@ -2073,6 +2094,7 @@ mshv_ioctl_create_partition(void __user *user_arg, struct device *module_dev)\n \t\tgoto cleanup_irq_srcu;\n \n \tpartition->pt_id = pt_id;\n+\tpartition->pt_vmm_tgid = current->tgid;\n \n \tret = add_partition(partition);\n \tif (ret)\ndiff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h\nindex bf601d67cecb..e8cbc4e3f7ad 100644\n--- a/include/asm-generic/mshyperv.h\n+++ b/include/asm-generic/mshyperv.h\n@@ -350,6 +350,7 @@ int hv_call_add_logical_proc(int node, u32 lp_index, u32 acpi_id);\n int hv_call_notify_all_processors_started(void);\n bool hv_lp_exists(u32 lp_index);\n int hv_call_create_vp(int node, u64 partition_id, u32 vp_index, u32 flags);\n+u64 mshv_current_partid(void);\n \n #else /* CONFIG_MSHV_ROOT */\n static inline bool hv_root_partition(void) { return false; }\n@@ -380,6 +381,10 @@ static inline int hv_call_create_vp(int node, u64 partition_id, u32 vp_index, u3\n {\n \treturn -EOPNOTSUPP;\n }\n+static inline u64 mshv_current_partid(void)\n+{\n+\treturn HV_PARTITION_ID_INVALID;\n+}\n #endif /* CONFIG_MSHV_ROOT */\n \n static inline int hv_deposit_memory(u64 partition_id, u64 status)\n","prefixes":["V1","04/13"]}