{"id":2230649,"url":"http://patchwork.ozlabs.org/api/patches/2230649/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pci/patch/20260429231519.2569088-4-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":"<20260429231519.2569088-4-mrathor@linux.microsoft.com>","list_archive_url":null,"date":"2026-04-29T23:15:19","name":"[v0,3/3] mshv: Implement guest irq migration for passthru'd devices","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"726de32d68ea2649f88ead47177656f4f7b31089","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/20260429231519.2569088-4-mrathor@linux.microsoft.com/mbox/","series":[{"id":502164,"url":"http://patchwork.ozlabs.org/api/series/502164/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pci/list/?series=502164","date":"2026-04-29T23:15:16","name":"PCI passthru on Hyper-V (Part II)","version":0,"mbox":"http://patchwork.ozlabs.org/series/502164/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2230649/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2230649/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-pci+bounces-53432-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=GX8Z+WrN;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.105.105.114; helo=tor.lore.kernel.org;\n envelope-from=linux-pci+bounces-53432-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=\"GX8Z+WrN\"","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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])\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 4g5Y8Z5TpCz1yGq\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 09:16:30 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 0EB40302E3D3\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 29 Apr 2026 23:16:01 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id C97803A1E96;\n\tWed, 29 Apr 2026 23:15:45 +0000 (UTC)","from linux.microsoft.com (linux.microsoft.com [13.77.154.182])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 83F6239DBCD;\n\tWed, 29 Apr 2026 23:15:44 +0000 (UTC)","from mrdev.corp.microsoft.com (unknown [13.88.17.9])\n\tby linux.microsoft.com (Postfix) with ESMTPSA id 5087720B716F;\n\tWed, 29 Apr 2026 16:15:44 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777504545; cv=none;\n b=pxLlWLul40qsB4+8aoZl4uqMGm5F/w2R3xnamt1VbVWhU+zCnVWFM5Xl6znzKfxvlAvq5ZLjkUMGbFGYi0DhzWnzBSufFL0QqFtU1hws1Sxv/nIpUsEZVBg4xK3dNHThGnmTC2itbXoCaD9NrjFmGd+vzKmy4584Vz4uzSDKe2I=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777504545; c=relaxed/simple;\n\tbh=IgxUH/+zU92g1+j5BSaxspdGUgX53/MsjEiv8Uo5rBA=;\n\th=From:To:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=sHUaja/5Gjby4vUy4yxdpJrWQzhIij4ezlhBdyVDOgOdFnR/nRTXR3V8LSy3w3w6FEmOBw3Ct1jZqnd9XgZvIvJv9Gnmv2p6id4GMwT9ftBNSGAB8P6Ml+/9Ao69MHp3EhkuDbrOq3Z/9mcDcX+Caf65EFKpRQGNDgFGpgV6HmA=","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=GX8Z+WrN;\n arc=none smtp.client-ip=13.77.154.182","DKIM-Filter":"OpenDKIM Filter v2.11.0 linux.microsoft.com 5087720B716F","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com;\n\ts=default; t=1777504544;\n\tbh=o49tx8/3sSJgdzeUhZ6VLlQM8CX6XRmt7QR4EGSON+Q=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=GX8Z+WrNd9Fk5OD5jqTO60O02pBd7t+vJvn7ACJSDbaW14L9un4ltVMoUslkBB/Cl\n\t 51eZlHaYgb34tYNCbaXlvttVmQvE1QrMbpt5tW35nN99ZivDLf//g7BoFo5nkDaYNe\n\t HyVnXWXEJ/wa/HrK+a/GXfw5C/Qw/q0NP2wHIwJ8=","From":"Mukesh R <mrathor@linux.microsoft.com>","To":"hpa@zytor.com,\n\trobin.murphy@arm.com,\n\trobh@kernel.org,\n\tlinux-hyperv@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org,\n\tiommu@lists.linux.dev,\n\tlinux-pci@vger.kernel.org,\n\tlinux-arch@vger.kernel.org","Subject":"[PATCH v0 3/3] mshv: Implement guest irq migration for passthru'd\n devices","Date":"Wed, 29 Apr 2026 16:15:19 -0700","Message-ID":"<20260429231519.2569088-4-mrathor@linux.microsoft.com>","X-Mailer":"git-send-email 2.51.2.vfs.0.1","In-Reply-To":"<20260429231519.2569088-1-mrathor@linux.microsoft.com>","References":"<20260429231519.2569088-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":"Ask the hypervisor to retarget interrupts to new guest cpu or vector\nupon guest irq migration. This happens in the irqfd update path.\n\nSigned-off-by: Mukesh R <mrathor@linux.microsoft.com>\n---\n drivers/hv/mshv_eventfd.c | 78 ++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 76 insertions(+), 2 deletions(-)","diff":"diff --git a/drivers/hv/mshv_eventfd.c b/drivers/hv/mshv_eventfd.c\nindex 666e28f4a4b5..0d0f1229f500 100644\n--- a/drivers/hv/mshv_eventfd.c\n+++ b/drivers/hv/mshv_eventfd.c\n@@ -192,6 +192,77 @@ static int mshv_map_device_interrupt(u64 ptid, union hv_device_id hv_devid,\n \n }\n \n+/* NOTE: caller does spin_lock_irq on pt_irqfds_lock, hence no disable here */\n+static void mshv_do_guest_irq_retarget(u64 partid, struct mshv_irqfd *irqfd)\n+{\n+\tint rc, var_size;\n+\tu64 status;\n+\tunion hv_device_id hv_devid;\n+\tstruct hv_input_get_vp_set_from_mda *mda_input;\n+\tunion hv_output_get_vp_set_from_mda *mda_output;\n+\tstruct hv_retarget_device_interrupt *remap_inp;\n+\tstruct pci_dev *pdev;\n+\tstruct irq_data *irqdata;\n+\tstruct mshv_lapic_irq *lapic_irq = &irqfd->irqfd_lapic_irq;\n+\tstruct hv_interrupt_entry *inte = NULL;\n+\n+\tif (!irqfd->irqfd_girq_ent.girq_entry_valid ||\n+\t    irqfd->irqfd_bypass_prod == NULL)\n+\t\treturn;\n+\n+\trc = mshv_parse_mshv_irqfd(irqfd, &pdev, &irqdata);\n+\tif (rc)\n+\t\treturn;\n+\n+\tinte = irqdata->chip_data;\n+\tif (inte == NULL)\n+\t\treturn;\n+\n+\thv_devid.as_uint64 = hv_devid_from_pdev(pdev);\n+\n+\n+\tmda_input = *this_cpu_ptr(hyperv_pcpu_input_arg);\n+\tmda_output = *this_cpu_ptr(hyperv_pcpu_output_arg);\n+\n+\trc = hv_vpset_from_hyp_disabled(mda_input, mda_output, lapic_irq,\n+\t\t\t\t\tpartid);\n+\tif (rc)\n+\t\treturn;\n+\n+\tremap_inp = *this_cpu_ptr(hyperv_pcpu_input_arg);\n+\tmemset(remap_inp, 0, sizeof(*remap_inp));\n+\n+\trc = hv_copy_vpset(&remap_inp->int_target.vp_set,\n+\t\t\t   &mda_output->target_vpset);\n+\tif (rc <= 0) {\n+\t\tpr_err(\"Hyper-V: ptid %lld - vpset copy failed (%d)\\n\",\n+\t\t       partid, rc);\n+\t\treturn;\n+\t}\n+\n+\t/*\n+\t * var-sized hcall: var-size starts after vp_mask (thus vp_set.format\n+\t * does not count, but vp_set.valid_bank_mask does).\n+\t */\n+\tvar_size = rc + 1;\n+\n+\tremap_inp->partition_id = partid;\n+\tremap_inp->device_id = hv_devid.as_uint64;\n+\tremap_inp->int_target.vector = lapic_irq->lapic_vector;\n+\tremap_inp->int_target.flags = HV_DEVICE_INTERRUPT_TARGET_PROCESSOR_SET;\n+\n+\tremap_inp->int_entry.source = inte->source;\n+\tremap_inp->int_entry.msi_entry.as_uint64 = inte->msi_entry.as_uint64;\n+\n+\tstatus = hv_do_rep_hypercall(HVCALL_RETARGET_INTERRUPT, 0, var_size,\n+\t\t\t\t     remap_inp, NULL);\n+\n+\tif (!hv_result_success(status))\n+\t\thv_status_err(status, \"pt:%lld vec:%d lapic-id:%lld\\n\",\n+\t\t\t      partid, lapic_irq->lapic_vector,\n+\t\t\t      lapic_irq->lapic_apic_id);\n+}\n+\n static int mshv_unmap_device_interrupt(union hv_device_id hv_devid,\n \t\t\t\t       struct hv_interrupt_entry *irq_entry)\n {\n@@ -728,9 +799,12 @@ static void mshv_irqfd_update(struct mshv_partition *pt,\n \t\t\t      struct mshv_irqfd *irqfd)\n {\n \twrite_seqcount_begin(&irqfd->irqfd_irqe_sc);\n-\tirqfd->irqfd_girq_ent = mshv_ret_girq_entry(pt,\n-\t\t\t\t\t\t    irqfd->irqfd_irqnum);\n+\tirqfd->irqfd_girq_ent = mshv_ret_girq_entry(pt, irqfd->irqfd_irqnum);\n \tmshv_copy_girq_info(&irqfd->irqfd_girq_ent, &irqfd->irqfd_lapic_irq);\n+\n+#if IS_ENABLED(CONFIG_X86_64)\n+\tmshv_do_guest_irq_retarget(pt->pt_id, irqfd);\n+#endif\n \twrite_seqcount_end(&irqfd->irqfd_irqe_sc);\n }\n \n","prefixes":["v0","3/3"]}