From nobody Wed Oct 8 00:25:01 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B670D7263F; Thu, 3 Jul 2025 22:44:50 +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=1751582692; cv=none; b=J1x38s7aRDdfhvaWf/vT7QfRAGkioO+BaCHYXF6XjAXWI9Glr8X6sgrwXlPzuOsbLw12TPJCYUU9WiYCWzQc4WKaBa7xBg16XWNfO3Ow4dcHj/SkfQpDiAUjFgBwuju4hJOLQlnIkqkU4JICeegdaH7ST++17blYh6JVYChqfbA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751582692; c=relaxed/simple; bh=WpZytQMrPGzw6xWGqoVz9pIbjS7pWkaHK+uTiyZ+pEc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=njnxZAub2RFOTwgBFEn1U1vf6mvterJl/76MUhMBfds7uh8ivvJVuMEUE1SpuMAm6dt8ZuOY6KOBBlpCklLkxgMT0m5Ijx4FjNrCrUPzUq95ICeJnMzBU55QT9nMccSSuyqrtv3sANYUY0Uv4gZfkmnin5PtK73ubmd2UhZiCU4= 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=UShXlfxH; 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="UShXlfxH" Received: by linux.microsoft.com (Postfix, from userid 1032) id 656EC201657A; Thu, 3 Jul 2025 15:44:50 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 656EC201657A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1751582690; bh=Sr/aIsRtVZTTmdi0MYbRiz/Hji+Rbh1yrHyYblC7Xtg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UShXlfxHkXNG+/p6Ib7AxuHsBUIW7JFqBhlADi7hQCc+vtt/Ur/1j3nh6AhR89UuE XLNznSCEjpeN94Fclp5X/o1R13niEshvr1UqmyP+o5tRzadYLsSWlWJXnFx04wD7Qm JcLMRZviYW3FZAldMYu7zn8/oQnB9ZRNzDB2JyD4= 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, mhklinux@outlook.com, tglx@linutronix.de, bhelgaas@google.com, romank@linux.microsoft.com Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, catalin.marinas@arm.com, will@kernel.org, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, jinankjain@linux.microsoft.com, skinsburskii@linux.microsoft.com, mrathor@linux.microsoft.com, x86@kernel.org, Nuno Das Neves Subject: [PATCH v2 1/6] PCI: hv: Don't load the driver for baremetal root partition Date: Thu, 3 Jul 2025 15:44:32 -0700 Message-Id: <1751582677-30930-2-git-send-email-nunodasneves@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1751582677-30930-1-git-send-email-nunodasneves@linux.microsoft.com> References: <1751582677-30930-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 The root partition only uses VMBus when running nested. When running on baremetal the Hyper-V PCI driver is not needed, so do not initialize it. Signed-off-by: Mukesh Rathor Signed-off-by: Nuno Das Neves Reviewed-by: Roman Kisel Acked-by: Bjorn Helgaas --- 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 Wed Oct 8 00:25:01 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 35C782C159A; Thu, 3 Jul 2025 22:44:52 +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=1751582693; cv=none; b=nAGibLLls/uX+YYciOPB1sf4DeueCtDPoTOGVbQETaT09RgDycMn4A7sOcTrRHtL/s+wUiz5UJ0wWHChU6Hxmaue0Wz+VkBUNBtc1ObBCfP8biyJ4lUSw8ttStmN0NSPi18GHKJQovTJ+d/Eq4W69kZuB9Ox0ejOMWuYVDU0p5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751582693; c=relaxed/simple; bh=Xkcr7RGizw2oQjQ1SwC5idPHGqWiAMXaJ1ege7+PEGQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=pAdFFBbRcwhrzqaU5xqTP/true8b+KjA/zbGEyAXm9/641AaB3TNxuXDDZ1QB3NkmrnbvOKKvVURHGldRajdOxlNhPbJlm5DSPZoXYry+7DElx0bXrVLd2mlZlaTlb/EYzxSgP0EKnNEzs9nVTbqF4SMlucXtf388W3rP9jo+k0= 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=EcAR4NuW; 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="EcAR4NuW" Received: by linux.microsoft.com (Postfix, from userid 1032) id AA101211518E; Thu, 3 Jul 2025 15:44:51 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com AA101211518E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1751582691; bh=ejh03XwHi8XDCLlghgIiwbsg6jskRGIuuAKzLCeBRKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EcAR4NuW3QI7k24XLVV+tA58bvaDDeUsu+DP5/F/nMID4kNfofCnY9JTEX3afeRtb fN+6khLyaXxQOH8SJzOGvfGJIYM44Y5Xa7kWUFGc08ixcQM1WDHvL6cSwUwpBJN+L1 XGTiHzx0djTqDp1u58VqI9EB9xOs265BfVK9Qseg= 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, mhklinux@outlook.com, tglx@linutronix.de, bhelgaas@google.com, romank@linux.microsoft.com Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, catalin.marinas@arm.com, will@kernel.org, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, jinankjain@linux.microsoft.com, skinsburskii@linux.microsoft.com, mrathor@linux.microsoft.com, x86@kernel.org, Nuno Das Neves Subject: [PATCH v2 2/6] Drivers: hv: Use nested hypercall for post message and signal event Date: Thu, 3 Jul 2025 15:44:33 -0700 Message-Id: <1751582677-30930-3-git-send-email-nunodasneves@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1751582677-30930-1-git-send-email-nunodasneves@linux.microsoft.com> References: <1751582677-30930-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. Remove hv_do_nested_hypercall() and hv_do_fast_nested_hypercall8() altogether and open-code these cases, since there are only 2 and all they do is add the nested bit. Signed-off-by: Nuno Das Neves Reviewed-by: Roman Kisel --- arch/x86/include/asm/mshyperv.h | 20 -------------------- drivers/hv/connection.c | 7 +++++-- drivers/hv/hv.c | 6 ++++-- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyper= v.h index 5ec92e3e2e37..e00a8431ef8e 100644 --- a/arch/x86/include/asm/mshyperv.h +++ b/arch/x86/include/asm/mshyperv.h @@ -111,12 +111,6 @@ static inline u64 hv_do_hypercall(u64 control, void *i= nput, void *output) return hv_status; } =20 -/* Hypercall to the L0 hypervisor */ -static inline u64 hv_do_nested_hypercall(u64 control, void *input, void *o= utput) -{ - return hv_do_hypercall(control | HV_HYPERCALL_NESTED, input, output); -} - /* Fast hypercall with 8 bytes of input and no output */ static inline u64 _hv_do_fast_hypercall8(u64 control, u64 input1) { @@ -164,13 +158,6 @@ static inline u64 hv_do_fast_hypercall8(u16 code, u64 = input1) return _hv_do_fast_hypercall8(control, input1); } =20 -static inline u64 hv_do_fast_nested_hypercall8(u16 code, u64 input1) -{ - u64 control =3D (u64)code | HV_HYPERCALL_FAST_BIT | HV_HYPERCALL_NESTED; - - return _hv_do_fast_hypercall8(control, input1); -} - /* Fast hypercall with 16 bytes of input */ static inline u64 _hv_do_fast_hypercall16(u64 control, u64 input1, u64 inp= ut2) { @@ -222,13 +209,6 @@ static inline u64 hv_do_fast_hypercall16(u16 code, u64= input1, u64 input2) return _hv_do_fast_hypercall16(control, input1, input2); } =20 -static inline u64 hv_do_fast_nested_hypercall16(u16 code, u64 input1, u64 = input2) -{ - u64 control =3D (u64)code | HV_HYPERCALL_FAST_BIT | HV_HYPERCALL_NESTED; - - return _hv_do_fast_hypercall16(control, input1, input2); -} - extern struct hv_vp_assist_page **hv_vp_assist_page; =20 static inline struct hv_vp_assist_page *hv_get_vp_assist_page(unsigned int= cpu) diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c index be490c598785..47c93cee1ef6 100644 --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c @@ -518,8 +518,11 @@ void vmbus_set_event(struct vmbus_channel *channel) channel->sig_event, 0); else WARN_ON_ONCE(1); - } else { - hv_do_fast_hypercall8(HVCALL_SIGNAL_EVENT, channel->sig_event); + } else if (hv_nested) { + u64 control =3D HVCALL_SIGNAL_EVENT; + + control |=3D hv_nested ? HV_HYPERCALL_NESTED : 0; + hv_do_fast_hypercall8(control, channel->sig_event); } } EXPORT_SYMBOL_GPL(vmbus_set_event); diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index 308c8f279df8..b14c5f9e0ef2 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c @@ -85,8 +85,10 @@ int hv_post_message(union hv_connection_id connection_id, else status =3D HV_STATUS_INVALID_PARAMETER; } else { - status =3D hv_do_hypercall(HVCALL_POST_MESSAGE, - aligned_msg, NULL); + u64 control =3D HVCALL_POST_MESSAGE; + + control |=3D hv_nested ? HV_HYPERCALL_NESTED : 0; + status =3D hv_do_hypercall(control, aligned_msg, NULL); } =20 local_irq_restore(flags); --=20 2.34.1 From nobody Wed Oct 8 00:25:01 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94F592C15AA; Thu, 3 Jul 2025 22:44:52 +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=1751582693; cv=none; b=D2GQksxQXeWk06nlw0U6HeJpVNlvOsDOMQ/KJRF+AXIVsYt4mBAH3qkRGja1ayiiqk3cCi78VAnwAexsYDc8oMT936v51K4WTPfkHzkHxm7ZzSm+5zj2WuzqFhpYsANT5jAykhgIzvzJtLsiTUjBojOHFNHietyjFKqLdbgg1eE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751582693; c=relaxed/simple; bh=yo0RQYo8djmodDk2+1PRbRm10T8lvoiziD52WnSRHxA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=IRcmBLg63Id3gMzvj8NcJBN7rg4/pfTZmGHBCyJq3iT+1f76+cWlR4mN3aKBHcMi1MHQE0XW/AZB72KEHbdc7v0guNosNqeDleoLvw2ESXGED8KVSfGuC9Mt4Z5HpI4l+xZxT7CEVkKj+ri8vQlacaxswBTkGd0K8Ghn7oMh9UU= 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=fk13oTkk; 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="fk13oTkk" Received: by linux.microsoft.com (Postfix, from userid 1032) id 401B42115189; Thu, 3 Jul 2025 15:44:52 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 401B42115189 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1751582692; bh=3VpgfDJQYn3ffptUBCYFWibfHui5iQWzNjqFNfpXPDU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fk13oTkk6sLk/wXss1sCA9KIc1jX7QUcJ5Kf1vlJ5/S3GMj0FJ73jyjVUk1umEPBK 6f/RJ2kF6G3t5sKo7HgO2MbFN06RVUW+N0QG0oPXm6weBw39VP99+2q33kPEuhuGVX UtuwKPrpaceUxwECyhLW/ECvqtOyBbgOTODjkSoE= 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, mhklinux@outlook.com, tglx@linutronix.de, bhelgaas@google.com, romank@linux.microsoft.com Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, catalin.marinas@arm.com, will@kernel.org, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, jinankjain@linux.microsoft.com, skinsburskii@linux.microsoft.com, mrathor@linux.microsoft.com, x86@kernel.org, Nuno Das Neves Subject: [PATCH v2 3/6] x86/hyperv: Fix usage of cpu_online_mask to get valid cpu Date: Thu, 3 Jul 2025 15:44:34 -0700 Message-Id: <1751582677-30930-4-git-send-email-nunodasneves@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1751582677-30930-1-git-send-email-nunodasneves@linux.microsoft.com> References: <1751582677-30930-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" Accessing cpu_online_mask here is problematic because the cpus read lock is not held in this context. However, cpu_online_mask isn't needed here since the effective affinity mask is guaranteed to be valid in this callback. So, just use cpumask_first() to get the cpu instead of ANDing it with cpus_online_mask unnecessarily. Fixes: e39397d1fd68 ("x86/hyperv: implement an MSI domain for root partitio= n") Reported-by: Michael Kelley Closes: https://lore.kernel.org/linux-hyperv/SN6PR02MB4157639630F8AD2D8FD8F= 52FD475A@SN6PR02MB4157.namprd02.prod.outlook.com/ Suggested-by: Thomas Gleixner Signed-off-by: Nuno Das Neves --- arch/x86/hyperv/irqdomain.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/hyperv/irqdomain.c b/arch/x86/hyperv/irqdomain.c index 31f0d29cbc5e..e28c317ac9e8 100644 --- a/arch/x86/hyperv/irqdomain.c +++ b/arch/x86/hyperv/irqdomain.c @@ -192,7 +192,6 @@ static void hv_irq_compose_msi_msg(struct irq_data *dat= a, struct msi_msg *msg) struct pci_dev *dev; struct hv_interrupt_entry out_entry, *stored_entry; struct irq_cfg *cfg =3D irqd_cfg(data); - const cpumask_t *affinity; int cpu; u64 status; =20 @@ -204,8 +203,7 @@ 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); + cpu =3D cpumask_first(irq_data_get_effective_affinity_mask(data)); =20 if (data->chip_data) { /* --=20 2.34.1 From nobody Wed Oct 8 00:25:01 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 11E052C15B2; Thu, 3 Jul 2025 22:44:52 +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=1751582694; cv=none; b=nZ+pjblkGLmfIed1eXqcSdWu+JDa6Cb0BhG75JcpCEs+P0/CFMz5tmtAABnKskXDkQFEjolccQuIEMnDtAUGF6+urM6Jj528Z/ElgnZR1ZIEnJZ3nlLvbRNNnEl8275jaBqpkoQ8gy4m9XsCI3Oz3MMWivRxqbhOFhERkTCfIPI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751582694; c=relaxed/simple; bh=HKDjMyE40VwaJ+QLHyu8orsTQnBzhgCDwZxdokg/sbk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=B9lgzJvPhiM2yRPI+NKZGnrEyEygBhACiQg/LdhV4vaV4ZuWuFrJf+9GPnLkED1UHb3A7QawxBt9OkjQYw76vhD/fpSNovhD+E2JzrHmeFx4Wz0G9ZkyPSTQAE/wgrCdepHeRJyCcvHQofYIUhJ0VnMVdFeyxZfcg1xFHqoMrwM= 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=cuzDw/Bv; 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="cuzDw/Bv" Received: by linux.microsoft.com (Postfix, from userid 1032) id B0A3B211519B; Thu, 3 Jul 2025 15:44:52 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B0A3B211519B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1751582692; bh=tI8H2wX5v8zGuMwr587IEjCe4lTn+vWzbXe7WRWsg+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cuzDw/BvqYiWhv4ZVvq35a121EEkTzNqbBH9zE+v3pbZSTS2nZ1rddj1qBA9zM8Es 4b+jEBsHQzVleQGzDcWLBJxRPpU4iDFQTag2XdvQRMn/ihcNGQpd78dlGH0YJcLqMi WLMMRL0kQG0tQLLjhccZh8PTlySg+5dZ0/34LQGE= 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, mhklinux@outlook.com, tglx@linutronix.de, bhelgaas@google.com, romank@linux.microsoft.com Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, catalin.marinas@arm.com, will@kernel.org, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, jinankjain@linux.microsoft.com, skinsburskii@linux.microsoft.com, mrathor@linux.microsoft.com, x86@kernel.org, Nuno Das Neves Subject: [PATCH v2 4/6] x86/hyperv: Clean up hv_map/unmap_interrupt() return values Date: Thu, 3 Jul 2025 15:44:35 -0700 Message-Id: <1751582677-30930-5-git-send-email-nunodasneves@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1751582677-30930-1-git-send-email-nunodasneves@linux.microsoft.com> References: <1751582677-30930-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" Fix the return values of these hypercall helpers so they return a negated errno either directly or via hv_result_to_errno(). Update the callers to check for errno instead of using hv_status_success(), and remove redundant error printing. While at it, rearrange some variable declarations to adhere to style guidelines i.e. "reverse fir tree order". Signed-off-by: Nuno Das Neves --- arch/x86/hyperv/irqdomain.c | 32 ++++++++++++++------------------ drivers/iommu/hyperv-iommu.c | 33 ++++++++++++--------------------- 2 files changed, 26 insertions(+), 39 deletions(-) diff --git a/arch/x86/hyperv/irqdomain.c b/arch/x86/hyperv/irqdomain.c index e28c317ac9e8..75b25724b045 100644 --- a/arch/x86/hyperv/irqdomain.c +++ b/arch/x86/hyperv/irqdomain.c @@ -46,7 +46,7 @@ static int hv_map_interrupt(union hv_device_id device_id,= bool level, if (nr_bank < 0) { local_irq_restore(flags); pr_err("%s: unable to generate VP set\n", __func__); - return EINVAL; + return -EINVAL; } intr_desc->target.flags =3D HV_DEVICE_INTERRUPT_TARGET_PROCESSOR_SET; =20 @@ -66,7 +66,7 @@ static int hv_map_interrupt(union hv_device_id device_id,= bool level, if (!hv_result_success(status)) hv_status_err(status, "\n"); =20 - return hv_result(status); + return hv_result_to_errno(status); } =20 static int hv_unmap_interrupt(u64 id, struct hv_interrupt_entry *old_entry) @@ -88,7 +88,10 @@ static int hv_unmap_interrupt(u64 id, struct hv_interrup= t_entry *old_entry) status =3D hv_do_hypercall(HVCALL_UNMAP_DEVICE_INTERRUPT, input, NULL); local_irq_restore(flags); =20 - return hv_result(status); + if (!hv_result_success(status)) + hv_status_err(status, "\n"); + + return hv_result_to_errno(status); } =20 #ifdef CONFIG_PCI_MSI @@ -188,12 +191,11 @@ static inline void entry_to_msi_msg(struct hv_interru= pt_entry *entry, struct msi static int hv_unmap_msi_interrupt(struct pci_dev *dev, struct hv_interrupt= _entry *old_entry); static void hv_irq_compose_msi_msg(struct irq_data *data, struct msi_msg *= msg) { - struct msi_desc *msidesc; - struct pci_dev *dev; struct hv_interrupt_entry out_entry, *stored_entry; struct irq_cfg *cfg =3D irqd_cfg(data); - int cpu; - u64 status; + struct msi_desc *msidesc; + struct pci_dev *dev; + int cpu, ret; =20 msidesc =3D irq_data_get_msi_desc(data); dev =3D msi_desc_to_pci_dev(msidesc); @@ -217,14 +219,12 @@ static void hv_irq_compose_msi_msg(struct irq_data *d= ata, struct msi_msg *msg) stored_entry =3D data->chip_data; data->chip_data =3D NULL; =20 - status =3D hv_unmap_msi_interrupt(dev, stored_entry); + ret =3D hv_unmap_msi_interrupt(dev, stored_entry); =20 kfree(stored_entry); =20 - if (status !=3D HV_STATUS_SUCCESS) { - hv_status_debug(status, "failed to unmap\n"); + if (ret) return; - } } =20 stored_entry =3D kzalloc(sizeof(*stored_entry), GFP_ATOMIC); @@ -233,8 +233,8 @@ static void hv_irq_compose_msi_msg(struct irq_data *dat= a, struct msi_msg *msg) return; } =20 - status =3D hv_map_msi_interrupt(dev, cpu, cfg->vector, &out_entry); - if (status !=3D HV_STATUS_SUCCESS) { + ret =3D hv_map_msi_interrupt(dev, cpu, cfg->vector, &out_entry); + if (ret) { kfree(stored_entry); return; } @@ -255,7 +255,6 @@ static void hv_teardown_msi_irq(struct pci_dev *dev, st= ruct irq_data *irqd) { struct hv_interrupt_entry old_entry; struct msi_msg msg; - u64 status; =20 if (!irqd->chip_data) { pr_debug("%s: no chip data\n!", __func__); @@ -268,10 +267,7 @@ static void hv_teardown_msi_irq(struct pci_dev *dev, s= truct irq_data *irqd) kfree(irqd->chip_data); irqd->chip_data =3D NULL; =20 - status =3D hv_unmap_msi_interrupt(dev, &old_entry); - - if (status !=3D HV_STATUS_SUCCESS) - hv_status_err(status, "\n"); + (void)hv_unmap_msi_interrupt(dev, &old_entry); } =20 static void hv_msi_free_irq(struct irq_domain *domain, diff --git a/drivers/iommu/hyperv-iommu.c b/drivers/iommu/hyperv-iommu.c index 761ab647f372..0961ac805944 100644 --- a/drivers/iommu/hyperv-iommu.c +++ b/drivers/iommu/hyperv-iommu.c @@ -193,15 +193,13 @@ struct hyperv_root_ir_data { static void hyperv_root_ir_compose_msi_msg(struct irq_data *irq_data, struct msi_msg *= msg) { - u64 status; - u32 vector; - struct irq_cfg *cfg; - int ioapic_id; - const struct cpumask *affinity; - int cpu; - struct hv_interrupt_entry entry; struct hyperv_root_ir_data *data =3D irq_data->chip_data; + struct hv_interrupt_entry entry; + const struct cpumask *affinity; struct IO_APIC_route_entry e; + struct irq_cfg *cfg; + int cpu, ioapic_id; + u32 vector; =20 cfg =3D irqd_cfg(irq_data); affinity =3D irq_data_get_effective_affinity_mask(irq_data); @@ -214,23 +212,16 @@ hyperv_root_ir_compose_msi_msg(struct irq_data *irq_d= ata, struct msi_msg *msg) && data->entry.ioapic_rte.as_uint64) { entry =3D data->entry; =20 - status =3D hv_unmap_ioapic_interrupt(ioapic_id, &entry); - - if (status !=3D HV_STATUS_SUCCESS) - hv_status_debug(status, "failed to unmap\n"); + (void)hv_unmap_ioapic_interrupt(ioapic_id, &entry); =20 data->entry.ioapic_rte.as_uint64 =3D 0; data->entry.source =3D 0; /* Invalid source */ } =20 =20 - status =3D hv_map_ioapic_interrupt(ioapic_id, data->is_level, cpu, - vector, &entry); - - if (status !=3D HV_STATUS_SUCCESS) { - hv_status_err(status, "map failed\n"); + if (hv_map_ioapic_interrupt(ioapic_id, data->is_level, cpu, + vector, &entry)) return; - } =20 data->entry =3D entry; =20 @@ -322,10 +313,10 @@ static void hyperv_root_irq_remapping_free(struct irq= _domain *domain, data =3D irq_data->chip_data; e =3D &data->entry; =20 - if (e->source =3D=3D HV_DEVICE_TYPE_IOAPIC - && e->ioapic_rte.as_uint64) - hv_unmap_ioapic_interrupt(data->ioapic_id, - &data->entry); + if (e->source =3D=3D HV_DEVICE_TYPE_IOAPIC && + e->ioapic_rte.as_uint64) + (void)hv_unmap_ioapic_interrupt(data->ioapic_id, + &data->entry); =20 kfree(data); } --=20 2.34.1 From nobody Wed Oct 8 00:25:01 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 888CC2C15BE; Thu, 3 Jul 2025 22:44:53 +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=1751582695; cv=none; b=UtlzrJmp4ibBDDkE6Xsdw5FY6fwm0gBBW24G1zvALBgQ7DmzQfuzgE0MfE77WsoV1iyCaBOKYexAWlU95qRnMCi8L7/L0hFLjosMLpgAexxJXh7j+R/BI0TP+kUbKUsH9QW7Wo8d9Kha3tq1no8OZL5ApOxy7wyG7aZlToFkV1g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751582695; c=relaxed/simple; bh=uiQDxjJ1ZD6oxrb7AM4nf4Mj1uhvKEg0ygFnD1gzArk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=mngutnTuEi7hCPJgmvjGKYXJGrJaqaPosq8G0CsTrC+imdFpwKnlRijHbypLk7UqeMBfa3iRGhoIUXRB5powdguGI4Z2iVWHdGFXG2VASCSiY6ut2TY3/EoabtGDQjNOpeTs2b7YA0AwM8Ge/gRo1E3M36Je4XNDbedzehEEWIo= 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=oDblWI43; 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="oDblWI43" Received: by linux.microsoft.com (Postfix, from userid 1032) id 2C6602115816; Thu, 3 Jul 2025 15:44:53 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2C6602115816 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1751582693; bh=yuiKy6HzLGMzTMoD6eaD/m/nf1gAtFL5nYBYhD5Qphs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oDblWI43lsxH9jUfMZeRB1+emFtnDegfbB6mjKyHcpOhYrcXlgm8Gu7Am5Kmj0HpG 71EJOHAo+qzhsCv8jE4vWyx5qbIbcBNn3Kwbvt+zUEpaFh6H8v9KrfGVnmOWkcG6RR Tqm8oVDvfAIovGG7P/VQMNewAbD17k6t4ZCEBHDA= 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, mhklinux@outlook.com, tglx@linutronix.de, bhelgaas@google.com, romank@linux.microsoft.com Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, catalin.marinas@arm.com, will@kernel.org, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, jinankjain@linux.microsoft.com, skinsburskii@linux.microsoft.com, mrathor@linux.microsoft.com, x86@kernel.org, Nuno Das Neves Subject: [PATCH v2 5/6] x86: hyperv: Expose hv_map_msi_interrupt function Date: Thu, 3 Jul 2025 15:44:36 -0700 Message-Id: <1751582677-30930-6-git-send-email-nunodasneves@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1751582677-30930-1-git-send-email-nunodasneves@linux.microsoft.com> References: <1751582677-30930-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 | 38 +++++++++++++++++++++++---------- arch/x86/include/asm/mshyperv.h | 2 ++ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/arch/x86/hyperv/irqdomain.c b/arch/x86/hyperv/irqdomain.c index 75b25724b045..eca015563420 100644 --- a/arch/x86/hyperv/irqdomain.c +++ b/arch/x86/hyperv/irqdomain.c @@ -172,13 +172,32 @@ 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 irq_cfg *cfg =3D irqd_cfg(data); + struct hv_interrupt_entry dummy; + union hv_device_id device_id; + struct msi_desc *msidesc; + struct pci_dev *dev; + int cpu; =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); + cpu =3D cpumask_first(irq_data_get_effective_affinity_mask(data)); + + return hv_map_interrupt(device_id, false, cpu, cfg->vector, + out_entry ? out_entry : &dummy); } +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) { @@ -191,11 +210,11 @@ static inline void entry_to_msi_msg(struct hv_interru= pt_entry *entry, struct msi static int hv_unmap_msi_interrupt(struct pci_dev *dev, struct hv_interrupt= _entry *old_entry); static void hv_irq_compose_msi_msg(struct irq_data *data, struct msi_msg *= msg) { - struct hv_interrupt_entry out_entry, *stored_entry; + struct hv_interrupt_entry *stored_entry; struct irq_cfg *cfg =3D irqd_cfg(data); struct msi_desc *msidesc; struct pci_dev *dev; - int cpu, ret; + int ret; =20 msidesc =3D irq_data_get_msi_desc(data); dev =3D msi_desc_to_pci_dev(msidesc); @@ -205,8 +224,6 @@ static void hv_irq_compose_msi_msg(struct irq_data *dat= a, struct msi_msg *msg) return; } =20 - cpu =3D cpumask_first(irq_data_get_effective_affinity_mask(data)); - if (data->chip_data) { /* * This interrupt is already mapped. Let's unmap first. @@ -233,15 +250,14 @@ static void hv_irq_compose_msi_msg(struct irq_data *d= ata, struct msi_msg *msg) return; } =20 - ret =3D hv_map_msi_interrupt(dev, cpu, cfg->vector, &out_entry); + ret =3D hv_map_msi_interrupt(data, stored_entry); if (ret) { 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 e00a8431ef8e..42ea9c68f8c8 100644 --- a/arch/x86/include/asm/mshyperv.h +++ b/arch/x86/include/asm/mshyperv.h @@ -241,6 +241,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 Wed Oct 8 00:25:01 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D641A2C3245; Thu, 3 Jul 2025 22:44:53 +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=1751582695; cv=none; b=gBs9sRAb+lZD5p99uKNJWU/cxafPAKC+glospuphznESV+Ook7qxbv/aTR5v6HCaMusTAmsP21lxsHZq3M196yRrKFlZ/wiLUTJSbTNPyHW55LhIaLeO9KGFMngjz7L7c4HB/pF2/iqh2H2M4ssL0OTddXqQkK5iqZF3lqWhUrs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751582695; c=relaxed/simple; bh=20MuRFf6dgkcOzbvX/wpMb7vM1FZ2s/pj2m0m5FFrIg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=GjP5yBOhaGx7wX2nrQTCYkGg7GUZDrDzrpBUWxZtrGpstoNrdN+DmAcZdGKlQuPWlnZ3Ppo510KWTWyAnvyBTYaaZc0fgsjxn910h+XkdWgVH6e35ogzckrZwxQGgbZ6NdE7vFhnWUUUNFuUFw2q0zHs+bEAXMpqUimokPS6v7E= 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=HyWsBdbT; 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="HyWsBdbT" Received: by linux.microsoft.com (Postfix, from userid 1032) id 92A8821151BE; Thu, 3 Jul 2025 15:44:53 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 92A8821151BE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1751582693; bh=32BzIHGNp0akvBK9OGz37WAORZ5C+YK3ijDeUf8UyCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HyWsBdbTfYTmux2z6fic1v81c+SlXy2R+ZaRiPuCKErJfyagh+edfjNDki874GJbA DzX9C/5z3IYgHEXMfOaooa9OQBw4xm9UguLkcWuqNQIiuM02DjLZOlV1VTn2P5lAkY KdA4akRVLO3B4QKaiB2dfZ9etbC+Ue9S1QLiRtT8= 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, mhklinux@outlook.com, tglx@linutronix.de, bhelgaas@google.com, romank@linux.microsoft.com Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, catalin.marinas@arm.com, will@kernel.org, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, jinankjain@linux.microsoft.com, skinsburskii@linux.microsoft.com, mrathor@linux.microsoft.com, x86@kernel.org, Nuno Das Neves Subject: [PATCH v2 6/6] PCI: hv: Use the correct hypercall for unmasking interrupts on nested Date: Thu, 3 Jul 2025 15:44:37 -0700 Message-Id: <1751582677-30930-7-git-send-email-nunodasneves@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1751582677-30930-1-git-send-email-nunodasneves@linux.microsoft.com> References: <1751582677-30930-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, 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 Acked-by: Bjorn Helgaas --- 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..9a8cba39ea6b 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_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