From nobody Sat Oct 11 08:27:42 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B987B2868AC; Tue, 10 Jun 2025 23:52:09 +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=1749599531; cv=none; b=CBqYI/fY7HUzhAGbbaRqXcKCBv4FeX0kM9unpe4h4JsBbNcsQyfE6RiMKnPgW5OglZv2aq1OgY9irBcZrrQp30e9Z6/QA4UHQVfZezC/kVPP9ZSBYyHvo0q9WLDjrBYbpH4F/qC8us21N7tWLtZlQBUaVMXRp2+c0CSmhWayHRE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749599531; c=relaxed/simple; bh=37HPHA9RfOtlboXAsLA3xyjUIs+4gv/UlcQmD0ikOZI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=CNzJRyLOMbZ7gK8UtkV8KrELO2V58F/WnzPvGgDu/d3NxfjIZWuYQ0Al8r4qitzrkJRi6RqQw7EmJqa8DUjcb0TxyUP6gjZUYty4RM/lMC79wBiDjdmuRUSNNi38oLSg+BeU5RY0wMr3KpGXEa/0Un3VNLUuYQ+cQBfjG3Zomvk= 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=P0+Z0f4B; 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="P0+Z0f4B" Received: by linux.microsoft.com (Postfix, from userid 1032) id 53E3E2078616; Tue, 10 Jun 2025 16:52:09 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 53E3E2078616 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1749599529; bh=puB6cQFE/rhFTMv5Zzq0obpGjYzCvE7tXTvZDEqP3mA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P0+Z0f4BKYWK/KShVT6OLBOzCiYr/h6meeLZkwn4DDq55vb5NYJWA3EY+zs+CFuak hYOn+YkHhCvZkEj3mTZK7nHjaLpFt42zgQ0Zkyg2FDSteIySCpVJz1/H2sc3jCGC7v MkT40l/z1WnTDuczGpq4nhCmhCg7gIaudSF+ljqo= From: Nuno Das Neves To: linux-hyperv@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, mhklinux@outlook.com, decui@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, lpieralisi@kernel.org, kw@linux.com, manivannan.sadhasivam@linaro.org, robh@kernel.org, bhelgaas@google.com, jinankjain@linux.microsoft.com, skinsburskii@linux.microsoft.com, mrathor@linux.microsoft.com, x86@kernel.org, Nuno Das Neves Subject: [PATCH 1/4] PCI: hv: Do not do vmbus initialization on baremetal Date: Tue, 10 Jun 2025 16:52:03 -0700 Message-Id: <1749599526-19963-2-git-send-email-nunodasneves@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1749599526-19963-1-git-send-email-nunodasneves@linux.microsoft.com> References: <1749599526-19963-1-git-send-email-nunodasneves@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mukesh Rathor init_hv_pci_drv() is not relevant for root partition on baremetal as there is no vmbus. On nested (with a Windows L1 root), vmbus is present. Signed-off-by: Mukesh Rathor Signed-off-by: Nuno Das Neves Reviewed-by: Roman Kisel --- drivers/pci/controller/pci-hyperv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/p= ci-hyperv.c index b4f29ee75848..4d25754dfe2f 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -4150,6 +4150,9 @@ static int __init init_hv_pci_drv(void) if (!hv_is_hyperv_initialized()) return -ENODEV; =20 + if (hv_root_partition() && !hv_nested) + return -ENODEV; + ret =3D hv_pci_irqchip_init(); if (ret) return ret; --=20 2.34.1 From nobody Sat Oct 11 08:27:42 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E1B4A2874EA; Tue, 10 Jun 2025 23:52:09 +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=1749599531; cv=none; b=XuulgMe3azuRICadfT5tC0sWkbJIO1t+rz3UjZF95GgYqP7NxnDpypbdpvqyo3xSQyMewZNGJ/EjJgttso95zRchuly6mvvaiGpFmomRnmRi9eFZjxWV32WOmlxliej1CkG30FFCoJ5X9CDmeBegTjnAq/Uu3id5xwNX6oBk+Ow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749599531; c=relaxed/simple; bh=nGXl2PDQRQ/W58aqs8ixmweJeT81nC3/xaedzcip7ZU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=L01T0L9xbzLfyG8YKRVvwPAJC2hfxoz+eiYnY9avWcaH6UefNBpP/HNyZvm4Ffh1UpHHOXTDVbNpobdNLEB0GcuR+31OokEBzsAqAsPh+iQf9IUe1H/+GSsR+0mygsU1AEN9TPpZ7OBNdyklvg017Oak13EaR1K9bRYHEm1Ga9w= 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=auAOTSOH; 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="auAOTSOH" Received: by linux.microsoft.com (Postfix, from userid 1032) id 61C5A2115180; Tue, 10 Jun 2025 16:52:09 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 61C5A2115180 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1749599529; bh=N7hVPdAAjB/xqyWhZ1EbQv9ByTMZgaoTVHsW9l2uYC0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=auAOTSOHG4T6VJOzF8nplNmsgLj+MnowWVh2+4m2n6/JHzQRe8VeIHSDhFgcbXzVn n0m7GouL959m0GQ+FEhQ4NwcR5Rr8MPu3x6UalBb3+BujZ/b/fIs6t+HX0MH1QXHeB 0TpdWOu6HjQqjutygkhILaQ0asqVqixQz5M3V8rQ= From: Nuno Das Neves To: linux-hyperv@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, mhklinux@outlook.com, decui@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, lpieralisi@kernel.org, kw@linux.com, manivannan.sadhasivam@linaro.org, robh@kernel.org, bhelgaas@google.com, jinankjain@linux.microsoft.com, skinsburskii@linux.microsoft.com, mrathor@linux.microsoft.com, x86@kernel.org, Nuno Das Neves Subject: [PATCH 2/4] Drivers: hv: Use nested hypercall for post message and signal event Date: Tue, 10 Jun 2025 16:52:04 -0700 Message-Id: <1749599526-19963-3-git-send-email-nunodasneves@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1749599526-19963-1-git-send-email-nunodasneves@linux.microsoft.com> References: <1749599526-19963-1-git-send-email-nunodasneves@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When running nested, these hypercalls must be sent to the L0 hypervisor or vmbus will fail. Add ARM64 stubs for the nested hypercall helpers to not break compilation (nested is still only supported in x86). Signed-off-by: Nuno Das Neves Reviewed-by: Roman Kisel --- arch/arm64/include/asm/mshyperv.h | 10 ++++++++++ drivers/hv/connection.c | 3 +++ drivers/hv/hv.c | 3 +++ 3 files changed, 16 insertions(+) diff --git a/arch/arm64/include/asm/mshyperv.h b/arch/arm64/include/asm/msh= yperv.h index b721d3134ab6..893d6a2e8dab 100644 --- a/arch/arm64/include/asm/mshyperv.h +++ b/arch/arm64/include/asm/mshyperv.h @@ -53,6 +53,16 @@ static inline u64 hv_get_non_nested_msr(unsigned int reg) return hv_get_msr(reg); } =20 +static inline u64 hv_do_nested_hypercall(u64 control, void *input, void *o= utput) +{ + return U64_MAX; +} + +static inline u64 hv_do_fast_nested_hypercall8(u64 control, u64 input1) +{ + return U64_MAX; +} + /* SMCCC hypercall parameters */ #define HV_SMCCC_FUNC_NUMBER 1 #define HV_FUNC_ID ARM_SMCCC_CALL_VAL( \ diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c index be490c598785..992022bc770c 100644 --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c @@ -518,6 +518,9 @@ void vmbus_set_event(struct vmbus_channel *channel) channel->sig_event, 0); else WARN_ON_ONCE(1); + } else if (hv_nested) { + hv_do_fast_nested_hypercall8(HVCALL_SIGNAL_EVENT, + channel->sig_event); } else { hv_do_fast_hypercall8(HVCALL_SIGNAL_EVENT, channel->sig_event); } diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index 308c8f279df8..99b73e779bf0 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c @@ -84,6 +84,9 @@ int hv_post_message(union hv_connection_id connection_id, sizeof(*aligned_msg)); else status =3D HV_STATUS_INVALID_PARAMETER; + } else if (hv_nested) { + status =3D hv_do_nested_hypercall(HVCALL_POST_MESSAGE, + aligned_msg, NULL); } else { status =3D hv_do_hypercall(HVCALL_POST_MESSAGE, aligned_msg, NULL); --=20 2.34.1 From nobody Sat Oct 11 08:27:42 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0CA5F28A722; Tue, 10 Jun 2025 23:52:09 +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=1749599531; cv=none; b=naIdHfU+Kknyh1AUF+i/07LbyI0cpVzX2EEY41ndN3D27kBYaYrzoxz/gzbBZ9uyqWI0EiskJ2blEuQBq2857IxrwO33h3aiv+pcp2n04fNV6UL5vwvTGZxXqLV6zdjvuhCEgFbKbHD0PnzImlh2lczusLZqAkQsxJ/Uk/lwCuU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749599531; c=relaxed/simple; bh=sXnnRz5wfs+ByvjGLJDGva9pA3vfok7mgIRKbB/IvYU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=dzRo9OL6DTLzgYsWJVw4aOrIjZgC/2YngAiZIQp1NBhFkEbVvCvCG8QDWkn4bpb0q5HjpM4Oq8wjlsbkpbPr6fyW4OA0gS7A2qoTfUZK+6AZGm4r83nn7fWI1UhtfO1l6LzoMWk+7ZOYmnUheHf0zVPM4KCHJi1W2+p8Zn4jUqs= 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=g9SAmhmF; 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="g9SAmhmF" Received: by linux.microsoft.com (Postfix, from userid 1032) id 728772115186; Tue, 10 Jun 2025 16:52:09 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 728772115186 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1749599529; bh=rXbxqdatFz0GsfdGns1ozciabfioI/E/Nkoi8/nxIJU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g9SAmhmFHhM3ZQ09+FxENRwSu11O2tcnVikLE+HVGQ4JGLCVSQGM35dwAYYi96UTJ PX12+2qkKWegodX2JEMAIDCQn3c2iGcyguzb1Ub4d6WXKYgN9ck+FzLYf8BzZNl9bw u7T+TCzpQHBwomT2kdAgufKzn6z/pImmakqi8+wY= From: Nuno Das Neves To: linux-hyperv@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, mhklinux@outlook.com, decui@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, lpieralisi@kernel.org, kw@linux.com, manivannan.sadhasivam@linaro.org, robh@kernel.org, bhelgaas@google.com, jinankjain@linux.microsoft.com, skinsburskii@linux.microsoft.com, mrathor@linux.microsoft.com, x86@kernel.org, Nuno Das Neves Subject: [PATCH 3/4] x86: hyperv: Expose hv_map_msi_interrupt function Date: Tue, 10 Jun 2025 16:52:05 -0700 Message-Id: <1749599526-19963-4-git-send-email-nunodasneves@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1749599526-19963-1-git-send-email-nunodasneves@linux.microsoft.com> References: <1749599526-19963-1-git-send-email-nunodasneves@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stanislav Kinsburskii This patch moves a part of currently internal logic into the hv_map_msi_interrupt function and makes it globally available helper function, which will be used to map PCI interrupts in case of root partition. Signed-off-by: Stanislav Kinsburskii Signed-off-by: Nuno Das Neves Reviewed-by: Roman Kisel --- arch/x86/hyperv/irqdomain.c | 47 ++++++++++++++++++++++++--------- arch/x86/include/asm/mshyperv.h | 2 ++ 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/arch/x86/hyperv/irqdomain.c b/arch/x86/hyperv/irqdomain.c index 31f0d29cbc5e..82f3bafb93d6 100644 --- a/arch/x86/hyperv/irqdomain.c +++ b/arch/x86/hyperv/irqdomain.c @@ -169,13 +169,40 @@ static union hv_device_id hv_build_pci_dev_id(struct = pci_dev *dev) return dev_id; } =20 -static int hv_map_msi_interrupt(struct pci_dev *dev, int cpu, int vector, - struct hv_interrupt_entry *entry) +/** + * hv_map_msi_interrupt() - "Map" the MSI IRQ in the hypervisor. + * @data: Describes the IRQ + * @out_entry: Hypervisor (MSI) interrupt entry (can be NULL) + * + * Map the IRQ in the hypervisor by issuing a MAP_DEVICE_INTERRUPT hyperca= ll. + */ +int hv_map_msi_interrupt(struct irq_data *data, + struct hv_interrupt_entry *out_entry) { - union hv_device_id device_id =3D hv_build_pci_dev_id(dev); + struct msi_desc *msidesc; + struct pci_dev *dev; + union hv_device_id device_id; + struct hv_interrupt_entry dummy; + struct irq_cfg *cfg =3D irqd_cfg(data); + const cpumask_t *affinity; + int cpu; + u64 res; =20 - return hv_map_interrupt(device_id, false, cpu, vector, entry); + msidesc =3D irq_data_get_msi_desc(data); + dev =3D msi_desc_to_pci_dev(msidesc); + device_id =3D hv_build_pci_dev_id(dev); + affinity =3D irq_data_get_effective_affinity_mask(data); + cpu =3D cpumask_first_and(affinity, cpu_online_mask); + + res =3D hv_map_interrupt(device_id, false, cpu, cfg->vector, + out_entry ? out_entry : &dummy); + if (!hv_result_success(res)) + pr_err("%s: failed to map interrupt: %s", + __func__, hv_result_to_string(res)); + + return hv_result_to_errno(res); } +EXPORT_SYMBOL_GPL(hv_map_msi_interrupt); =20 static inline void entry_to_msi_msg(struct hv_interrupt_entry *entry, stru= ct msi_msg *msg) { @@ -190,10 +217,8 @@ static void hv_irq_compose_msi_msg(struct irq_data *da= ta, struct msi_msg *msg) { struct msi_desc *msidesc; struct pci_dev *dev; - struct hv_interrupt_entry out_entry, *stored_entry; + struct hv_interrupt_entry *stored_entry; struct irq_cfg *cfg =3D irqd_cfg(data); - const cpumask_t *affinity; - int cpu; u64 status; =20 msidesc =3D irq_data_get_msi_desc(data); @@ -204,9 +229,6 @@ static void hv_irq_compose_msi_msg(struct irq_data *dat= a, struct msi_msg *msg) return; } =20 - affinity =3D irq_data_get_effective_affinity_mask(data); - cpu =3D cpumask_first_and(affinity, cpu_online_mask); - if (data->chip_data) { /* * This interrupt is already mapped. Let's unmap first. @@ -235,15 +257,14 @@ static void hv_irq_compose_msi_msg(struct irq_data *d= ata, struct msi_msg *msg) return; } =20 - status =3D hv_map_msi_interrupt(dev, cpu, cfg->vector, &out_entry); + status =3D hv_map_msi_interrupt(data, stored_entry); if (status !=3D HV_STATUS_SUCCESS) { kfree(stored_entry); return; } =20 - *stored_entry =3D out_entry; data->chip_data =3D stored_entry; - entry_to_msi_msg(&out_entry, msg); + entry_to_msi_msg(data->chip_data, msg); =20 return; } diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyper= v.h index 5ec92e3e2e37..843121465ddd 100644 --- a/arch/x86/include/asm/mshyperv.h +++ b/arch/x86/include/asm/mshyperv.h @@ -261,6 +261,8 @@ static inline void hv_apic_init(void) {} =20 struct irq_domain *hv_create_pci_msi_domain(void); =20 +int hv_map_msi_interrupt(struct irq_data *data, + struct hv_interrupt_entry *out_entry); int hv_map_ioapic_interrupt(int ioapic_id, bool level, int vcpu, int vecto= r, struct hv_interrupt_entry *entry); int hv_unmap_ioapic_interrupt(int ioapic_id, struct hv_interrupt_entry *en= try); --=20 2.34.1 From nobody Sat Oct 11 08:27:42 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2728228BA88; Tue, 10 Jun 2025 23:52:10 +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=1749599531; cv=none; b=bOyan/twZm1mUBGo1vZu6CZWKy6QCWY16yCfv03jCvTy5HQP15um8b8g1rKXaI4duYVpiwqLlzkIfi36u4N2Gubv3Fc6/4RisyhK36xuDAKejjzWTOOdUkuCXQXrwqhm5afBvqcVHP+/PLmpInvp1SwXD0EUeQtHra/EZEPc4bw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749599531; c=relaxed/simple; bh=wVLWn8Voi27o4oS3F360XZyMfrh+Z5cexYK+WZ766KU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=lrHxMKsLFMyUHcmMmtMHqZQl6Xe6R7gi54KoNCwtAbM0KWXjTZOOKw5IjWqW0xy1V1xU5pFhM0CdgeGrhR52Lm1bcTLou4DupkkpAaXIMTDr2dewIJNPbNTJgs8TY5Uc6wzQ0Rep6d1zRWSXnO78KG/ZXZ8h44aUY03Kg9UG6H8= 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=qMlakPqv; 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="qMlakPqv" Received: by linux.microsoft.com (Postfix, from userid 1032) id 809222115188; Tue, 10 Jun 2025 16:52:09 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 809222115188 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1749599529; bh=2OIurZZU+W8LJhjgQv4K7OiVx/Za0G2uLpi0IQWvRSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qMlakPqvE+vQ1DebGap+Ye6OBZa6NnUYPh3gXIJV7wyy7Wjk7E1Cby06xj9ViXuCJ oWIWOHbtX2mEHM+Kc12WmLboZfDbNWLapRNElVyOCZ2qrYhpvJbUbDfFnqL7VbO365 a4iZJmfff5uYK258r9c3RW8w5crRqmbPT7Af8CBY= From: Nuno Das Neves To: linux-hyperv@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, mhklinux@outlook.com, decui@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, lpieralisi@kernel.org, kw@linux.com, manivannan.sadhasivam@linaro.org, robh@kernel.org, bhelgaas@google.com, jinankjain@linux.microsoft.com, skinsburskii@linux.microsoft.com, mrathor@linux.microsoft.com, x86@kernel.org, Nuno Das Neves Subject: [PATCH 4/4] PCI: hv: Use the correct hypercall for unmasking interrupts on nested Date: Tue, 10 Jun 2025 16:52:06 -0700 Message-Id: <1749599526-19963-5-git-send-email-nunodasneves@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1749599526-19963-1-git-send-email-nunodasneves@linux.microsoft.com> References: <1749599526-19963-1-git-send-email-nunodasneves@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stanislav Kinsburskii Running as nested root on MSHV imposes a different requirement for the pci-hyperv controller. In this setup, the interrupt will first come to the L1 (nested) hypervisor, which will deliver it to the appropriate root CPU. Instead of issuing the RETARGET hypercall, we should issue the MAP_DEVICE_INTERRUPT hypercall to L1 to complete the setup. Rename hv_arch_irq_unmask() to hv_irq_retarget_interrupt(). Co-developed-by: Jinank Jain Signed-off-by: Jinank Jain Signed-off-by: Stanislav Kinsburskii Signed-off-by: Nuno Das Neves Reviewed-by: Roman Kisel --- drivers/pci/controller/pci-hyperv.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/p= ci-hyperv.c index 4d25754dfe2f..0f491c802fb9 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -600,7 +600,7 @@ static unsigned int hv_msi_get_int_vector(struct irq_da= ta *data) #define hv_msi_prepare pci_msi_prepare =20 /** - * hv_arch_irq_unmask() - "Unmask" the IRQ by setting its current + * hv_irq_retarget_interrupt() - "Unmask" the IRQ by setting its current * affinity. * @data: Describes the IRQ * @@ -609,7 +609,7 @@ static unsigned int hv_msi_get_int_vector(struct irq_da= ta *data) * is built out of this PCI bus's instance GUID and the function * number of the device. */ -static void hv_arch_irq_unmask(struct irq_data *data) +static void hv_irq_retarget_interrupt(struct irq_data *data) { struct msi_desc *msi_desc =3D irq_data_get_msi_desc(data); struct hv_retarget_device_interrupt *params; @@ -714,6 +714,20 @@ static void hv_arch_irq_unmask(struct irq_data *data) dev_err(&hbus->hdev->device, "%s() failed: %#llx", __func__, res); } + +static void hv_arch_irq_unmask(struct irq_data *data) +{ + if (hv_nested && hv_root_partition()) + /* + * In case of the nested root partition, the nested hypervisor + * is taking care of interrupt remapping and thus the + * MAP_DEVICE_INTERRUPT hypercall is required instead of + * RETARGET_INTERRUPT. + */ + (void)hv_map_msi_interrupt(data, NULL); + else + hv_irq_retarget_interrupt(data); +} #elif defined(CONFIG_ARM64) /* * SPI vectors to use for vPCI; arch SPIs range is [32, 1019], but leaving= a bit --=20 2.34.1