From nobody Thu Apr 2 00:15:08 2026 Received: from sender4-of-o52.zoho.com (sender4-of-o52.zoho.com [136.143.188.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A9AD3B8BDC; Wed, 25 Feb 2026 12:44:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772023471; cv=pass; b=VszmOy/5UsQrSDAlw8I8kfre2Tv76+LzMaF2Ib8fAuqpf6aiFTSygO+Edl1HHXwqPeJis2XCVNwhU6i4n0UXoWa98yv2notpnSKHYJ2o2V77JIK0eJUkw+BlP+W05yKSpOjAt8s7AFlHtLm7qBNcqJzyPe0xu+IOv09UlQQi8l8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772023471; c=relaxed/simple; bh=CRbIdAoq3DLU5lbymx77lbmed7urdnYOTlWNibtDGYw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tiOxz4RewAYSqZZp7U7uBuitYsvLUd1QksxedEBNeTWJ6gwysT8zIFIYMzUescr2oFgp+R6Nh/aB/CEsHpzoKD/kGofHiEwfTN2VcLxmvKU8TFGlA+xAi5I2WG9lPzZ8goywqgYNE3+bQkYc080nQSNYxOMu9V3pBHkQuFEq5p4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=anirudhrb.com; spf=pass smtp.mailfrom=anirudhrb.com; dkim=pass (1024-bit key) header.d=anirudhrb.com header.i=anirudh@anirudhrb.com header.b=a5D5hFSU; arc=pass smtp.client-ip=136.143.188.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=anirudhrb.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=anirudhrb.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=anirudhrb.com header.i=anirudh@anirudhrb.com header.b="a5D5hFSU" ARC-Seal: i=1; a=rsa-sha256; t=1772023460; cv=none; d=zohomail.com; s=zohoarc; b=NmwJH/nDrIdnWhUzzZtC5CbW0A96dXoeFnQjKWskSQNeq0R35Dncu0N449QLZR1LNiisdzjk9ovzGzieryJm52vqx/USOd7cwukaNqBdh0nGFKwZKURhD0xoQc8kHgUVJHfsBczj0fi3+hYzHB2v0vsUl3GIizbrpGVaf0CAyxw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772023460; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=fG+8vVFhZIped1F/mbSApTwZNbLnzNAsr70jFt/qte4=; b=MArxvPCIjcIdhv8q2IDK3wVUOeKFmNuRWab8wgMIHITZSyPRBvfFT+vGBWCf4D5TDUtseSl9WytmHrT7gP9k3nsu3OyeXFRhh1uu8+NOHa8lPjxlcjeMLyNMGHu9HoDcrcwerNZhr7hZVuN1sgpTnR4+Oc8omsHU58kGwrBk8e8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=anirudhrb.com; spf=pass smtp.mailfrom=anirudh@anirudhrb.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1772023460; s=zoho; d=anirudhrb.com; i=anirudh@anirudhrb.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=fG+8vVFhZIped1F/mbSApTwZNbLnzNAsr70jFt/qte4=; b=a5D5hFSUi3iaADR2oy1Y/za+NjzWApzJbqy/Qqd4Z5tNwDjmcrsmCv1AxTdiuidE 7zYGc7WwkfjGBdYYFrIcA6F6IfIJBIbNYJQS1a1ZnPv30bHWWTYJcf9bxPKR3KWoYpe 3CvvuCu0eXO9u54/4BTCKCrvSEvFljW7jfp1IDqc= Received: by mx.zohomail.com with SMTPS id 1772023458155385.9574680466594; Wed, 25 Feb 2026 04:44:18 -0800 (PST) From: Anirudh Rayabharam To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, longli@microsoft.com, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Cc: anirudh@anirudhrb.com, Michael Kelley Subject: [PATCH v6 1/2] mshv: refactor synic init and cleanup Date: Wed, 25 Feb 2026 12:44:02 +0000 Message-Id: <20260225124403.2187880-2-anirudh@anirudhrb.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260225124403.2187880-1-anirudh@anirudhrb.com> References: <20260225124403.2187880-1-anirudh@anirudhrb.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 X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" From: Anirudh Rayabharam (Microsoft) Rename mshv_synic_init() to mshv_synic_cpu_init() and mshv_synic_cleanup() to mshv_synic_cpu_exit() to better reflect that these functions handle per-cpu synic setup and teardown. Use mshv_synic_init/cleanup() to perform init/cleanup that is not per-cpu. Move all the synic related setup from mshv_parent_partition_init. Move the reboot notifier to mshv_synic.c because it currently only operates on the synic cpuhp state. Move out synic_pages from the global mshv_root since its use is now completely local to mshv_synic.c. This is in preparation for the next patch which will add more stuff to mshv_synic_init(). No functional change. Reviewed-by: Michael Kelley Signed-off-by: Anirudh Rayabharam (Microsoft) --- drivers/hv/mshv_root.h | 5 ++- drivers/hv/mshv_root_main.c | 64 +++++---------------------------- drivers/hv/mshv_synic.c | 71 +++++++++++++++++++++++++++++++++---- 3 files changed, 75 insertions(+), 65 deletions(-) diff --git a/drivers/hv/mshv_root.h b/drivers/hv/mshv_root.h index 04c2a1910a8a..826798f1a8ec 100644 --- a/drivers/hv/mshv_root.h +++ b/drivers/hv/mshv_root.h @@ -190,7 +190,6 @@ struct hv_synic_pages { }; =20 struct mshv_root { - struct hv_synic_pages __percpu *synic_pages; spinlock_t pt_ht_lock; DECLARE_HASHTABLE(pt_htable, MSHV_PARTITIONS_HASH_BITS); struct hv_partition_property_vmm_capabilities vmm_caps; @@ -249,8 +248,8 @@ int mshv_register_doorbell(u64 partition_id, doorbell_c= b_t doorbell_cb, void mshv_unregister_doorbell(u64 partition_id, int doorbell_portid); =20 void mshv_isr(void); -int mshv_synic_init(unsigned int cpu); -int mshv_synic_cleanup(unsigned int cpu); +int mshv_synic_init(struct device *dev); +void mshv_synic_exit(void); =20 static inline bool mshv_partition_encrypted(struct mshv_partition *partiti= on) { diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c index e6509c980763..7fcde33d3e75 100644 --- a/drivers/hv/mshv_root_main.c +++ b/drivers/hv/mshv_root_main.c @@ -2064,7 +2064,6 @@ mshv_dev_release(struct inode *inode, struct file *fi= lp) return 0; } =20 -static int mshv_cpuhp_online; static int mshv_root_sched_online; =20 static const char *scheduler_type_to_string(enum hv_scheduler_type type) @@ -2249,27 +2248,6 @@ root_scheduler_deinit(void) free_percpu(root_scheduler_output); } =20 -static int mshv_reboot_notify(struct notifier_block *nb, - unsigned long code, void *unused) -{ - cpuhp_remove_state(mshv_cpuhp_online); - return 0; -} - -struct notifier_block mshv_reboot_nb =3D { - .notifier_call =3D mshv_reboot_notify, -}; - -static void mshv_root_partition_exit(void) -{ - unregister_reboot_notifier(&mshv_reboot_nb); -} - -static int __init mshv_root_partition_init(struct device *dev) -{ - return register_reboot_notifier(&mshv_reboot_nb); -} - static int __init mshv_init_vmm_caps(struct device *dev) { int ret; @@ -2314,39 +2292,21 @@ static int __init mshv_parent_partition_init(void) MSHV_HV_MAX_VERSION); } =20 - mshv_root.synic_pages =3D alloc_percpu(struct hv_synic_pages); - if (!mshv_root.synic_pages) { - dev_err(dev, "Failed to allocate percpu synic page\n"); - ret =3D -ENOMEM; + ret =3D mshv_synic_init(dev); + if (ret) goto device_deregister; - } - - ret =3D cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mshv_synic", - mshv_synic_init, - mshv_synic_cleanup); - if (ret < 0) { - dev_err(dev, "Failed to setup cpu hotplug state: %i\n", ret); - goto free_synic_pages; - } - - mshv_cpuhp_online =3D ret; =20 ret =3D mshv_init_vmm_caps(dev); if (ret) - goto remove_cpu_state; + goto synic_cleanup; =20 ret =3D mshv_retrieve_scheduler_type(dev); if (ret) - goto remove_cpu_state; - - if (hv_root_partition()) - ret =3D mshv_root_partition_init(dev); - if (ret) - goto remove_cpu_state; + goto synic_cleanup; =20 ret =3D root_scheduler_init(dev); if (ret) - goto exit_partition; + goto synic_cleanup; =20 ret =3D mshv_debugfs_init(); if (ret) @@ -2367,13 +2327,8 @@ static int __init mshv_parent_partition_init(void) mshv_debugfs_exit(); deinit_root_scheduler: root_scheduler_deinit(); -exit_partition: - if (hv_root_partition()) - mshv_root_partition_exit(); -remove_cpu_state: - cpuhp_remove_state(mshv_cpuhp_online); -free_synic_pages: - free_percpu(mshv_root.synic_pages); +synic_cleanup: + mshv_synic_exit(); device_deregister: misc_deregister(&mshv_dev); return ret; @@ -2387,10 +2342,7 @@ static void __exit mshv_parent_partition_exit(void) misc_deregister(&mshv_dev); mshv_irqfd_wq_cleanup(); root_scheduler_deinit(); - if (hv_root_partition()) - mshv_root_partition_exit(); - cpuhp_remove_state(mshv_cpuhp_online); - free_percpu(mshv_root.synic_pages); + mshv_synic_exit(); } =20 module_init(mshv_parent_partition_init); diff --git a/drivers/hv/mshv_synic.c b/drivers/hv/mshv_synic.c index f8b0337cdc82..f716c2a4952f 100644 --- a/drivers/hv/mshv_synic.c +++ b/drivers/hv/mshv_synic.c @@ -12,11 +12,16 @@ #include #include #include +#include +#include #include =20 #include "mshv_eventfd.h" #include "mshv.h" =20 +static int synic_cpuhp_online; +static struct hv_synic_pages __percpu *synic_pages; + static u32 synic_event_ring_get_queued_port(u32 sint_index) { struct hv_synic_event_ring_page **event_ring_page; @@ -26,7 +31,7 @@ static u32 synic_event_ring_get_queued_port(u32 sint_inde= x) u32 message; u8 tail; =20 - spages =3D this_cpu_ptr(mshv_root.synic_pages); + spages =3D this_cpu_ptr(synic_pages); event_ring_page =3D &spages->synic_event_ring_page; synic_eventring_tail =3D (u8 **)this_cpu_ptr(hv_synic_eventring_tail); =20 @@ -393,7 +398,7 @@ mshv_intercept_isr(struct hv_message *msg) =20 void mshv_isr(void) { - struct hv_synic_pages *spages =3D this_cpu_ptr(mshv_root.synic_pages); + struct hv_synic_pages *spages =3D this_cpu_ptr(synic_pages); struct hv_message_page **msg_page =3D &spages->hyp_synic_message_page; struct hv_message *msg; bool handled; @@ -446,7 +451,7 @@ void mshv_isr(void) } } =20 -int mshv_synic_init(unsigned int cpu) +static int mshv_synic_cpu_init(unsigned int cpu) { union hv_synic_simp simp; union hv_synic_siefp siefp; @@ -455,7 +460,7 @@ int mshv_synic_init(unsigned int cpu) union hv_synic_sint sint; #endif union hv_synic_scontrol sctrl; - struct hv_synic_pages *spages =3D this_cpu_ptr(mshv_root.synic_pages); + struct hv_synic_pages *spages =3D this_cpu_ptr(synic_pages); struct hv_message_page **msg_page =3D &spages->hyp_synic_message_page; struct hv_synic_event_flags_page **event_flags_page =3D &spages->synic_event_flags_page; @@ -542,14 +547,14 @@ int mshv_synic_init(unsigned int cpu) return -EFAULT; } =20 -int mshv_synic_cleanup(unsigned int cpu) +static int mshv_synic_cpu_exit(unsigned int cpu) { union hv_synic_sint sint; union hv_synic_simp simp; union hv_synic_siefp siefp; union hv_synic_sirbp sirbp; union hv_synic_scontrol sctrl; - struct hv_synic_pages *spages =3D this_cpu_ptr(mshv_root.synic_pages); + struct hv_synic_pages *spages =3D this_cpu_ptr(synic_pages); struct hv_message_page **msg_page =3D &spages->hyp_synic_message_page; struct hv_synic_event_flags_page **event_flags_page =3D &spages->synic_event_flags_page; @@ -663,3 +668,57 @@ mshv_unregister_doorbell(u64 partition_id, int doorbel= l_portid) =20 mshv_portid_free(doorbell_portid); } + +static int mshv_synic_reboot_notify(struct notifier_block *nb, + unsigned long code, void *unused) +{ + if (!hv_root_partition()) + return 0; + + cpuhp_remove_state(synic_cpuhp_online); + return 0; +} + +static struct notifier_block mshv_synic_reboot_nb =3D { + .notifier_call =3D mshv_synic_reboot_notify, +}; + +int __init mshv_synic_init(struct device *dev) +{ + int ret =3D 0; + + synic_pages =3D alloc_percpu(struct hv_synic_pages); + if (!synic_pages) { + dev_err(dev, "Failed to allocate percpu synic page\n"); + return -ENOMEM; + } + + ret =3D cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mshv_synic", + mshv_synic_cpu_init, + mshv_synic_cpu_exit); + if (ret < 0) { + dev_err(dev, "Failed to setup cpu hotplug state: %i\n", ret); + goto free_synic_pages; + } + + synic_cpuhp_online =3D ret; + + ret =3D register_reboot_notifier(&mshv_synic_reboot_nb); + if (ret) + goto remove_cpuhp_state; + + return 0; + +remove_cpuhp_state: + cpuhp_remove_state(synic_cpuhp_online); +free_synic_pages: + free_percpu(synic_pages); + return ret; +} + +void mshv_synic_exit(void) +{ + unregister_reboot_notifier(&mshv_synic_reboot_nb); + cpuhp_remove_state(synic_cpuhp_online); + free_percpu(synic_pages); +} --=20 2.34.1 From nobody Thu Apr 2 00:15:08 2026 Received: from sender4-of-o52.zoho.com (sender4-of-o52.zoho.com [136.143.188.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00E1A3AE718; Wed, 25 Feb 2026 12:44:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772023479; cv=pass; b=LcXNvhqxoGD3danbk4YM/xrnpXWcg5sT5a05+riTLW8eS0TKzWLnqWh+qHb/Z4rLf7nwMGoaNWlGbeZaH2e2xUmgqmmoSEubfzdxJZcUb7G65wuhlJkv2pAx9VHk5fkxUuDlzrAUI4uHCTx7wT6kPyk0ki02Dx186L7YPd4/4/Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772023479; c=relaxed/simple; bh=RxR/oi0rOYoCMAb2sBCv8X6o3fpeeP+8oQ4uM+kDhHg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YRZ9ApUuhpQ2L4u6H2X9NNmrrl+fxJVyO1RD/KyKfLJoz9a8MHFextBSmhrbo8P4u5gpvFnCyES3zhoZFNR9e0dyRDPzxmy1RURiUPN72N+sFnZAPUNJCJsFf4UqvnaaV2MqY5GjWFwZzIXNZRsuPy2Oo/wKXhv+mDVl0/4cF5Y= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=anirudhrb.com; spf=pass smtp.mailfrom=anirudhrb.com; dkim=pass (1024-bit key) header.d=anirudhrb.com header.i=anirudh@anirudhrb.com header.b=qOgPZIrR; arc=pass smtp.client-ip=136.143.188.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=anirudhrb.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=anirudhrb.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=anirudhrb.com header.i=anirudh@anirudhrb.com header.b="qOgPZIrR" ARC-Seal: i=1; a=rsa-sha256; t=1772023464; cv=none; d=zohomail.com; s=zohoarc; b=lhqnLLgQeWrjxNPsqbmUJpN2bNICBJsuNc1QQqx34DIw6dwH6UX2jzH9wwyqc3Rp1EAuOMK/OWJGxTv/8ccFUvXwq3Yhk7Oo2/Ouee3OtkFukQHJoiEUZiaJibeAsO37sc5VQ15YV8MS88t30uDO2ItnPRkGMJcm53ly/xdUYz0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772023464; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=ymeZAGX/HEhwO2fptLx3iDYagZh6YeFQ6xUqLXHq6Fg=; b=Y0h0QCAmMc+qteMAZ4ZJTel5kH4vxfss8IKFIpW0AUq8Y4EmdbVC3dCRghLKqLqi3CxxnpdCB+tAf3qOvi7v64WlqlWZbOBO2mWD15hIz7UuwO6fdNSQA3fGznC1dNkDaZWw9R1iteUshOgmuM8638ow2kxOa/khc6shikcun2Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=anirudhrb.com; spf=pass smtp.mailfrom=anirudh@anirudhrb.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1772023464; s=zoho; d=anirudhrb.com; i=anirudh@anirudhrb.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=ymeZAGX/HEhwO2fptLx3iDYagZh6YeFQ6xUqLXHq6Fg=; b=qOgPZIrRkMOiRBFYDwzfiuWhqzQqsfI2iS6hibTg/BnqzhRF/fGQuL/cAPWVj6P+ M3sPGmskep62CCe7T9RFTiYSQfVDRok8cFTGgv63tcvYSPK9m5UfM+6T0xo7T4NIPC8 MICifH/U92DDKAg51QkNSWgs7fy8FUBhenS3065o= Received: by mx.zohomail.com with SMTPS id 1772023462929869.887002562424; Wed, 25 Feb 2026 04:44:22 -0800 (PST) From: Anirudh Rayabharam To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, longli@microsoft.com, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Cc: anirudh@anirudhrb.com, Michael Kelley , Stanislav Kinsburskii Subject: [PATCH v6 2/2] mshv: add arm64 support for doorbell & intercept SINTs Date: Wed, 25 Feb 2026 12:44:03 +0000 Message-Id: <20260225124403.2187880-3-anirudh@anirudhrb.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260225124403.2187880-1-anirudh@anirudhrb.com> References: <20260225124403.2187880-1-anirudh@anirudhrb.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 X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" From: Anirudh Rayabharam (Microsoft) On x86, the HYPERVISOR_CALLBACK_VECTOR is used to receive synthetic interrupts (SINTs) from the hypervisor for doorbells and intercepts. There is no such vector reserved for arm64. On arm64, the hypervisor exposes a synthetic register that can be read to find the INTID that should be used for SINTs. This INTID is in the PPI range. To better unify the code paths, introduce mshv_sint_vector_init() that either reads the synthetic register and obtains the INTID (arm64) or just uses HYPERVISOR_CALLBACK_VECTOR as the interrupt vector (x86). Reviewed-by: Michael Kelley Reviewed-by: Stanislav Kinsburskii Signed-off-by: Anirudh Rayabharam (Microsoft) --- drivers/hv/mshv_synic.c | 119 +++++++++++++++++++++++++++++++++--- include/hyperv/hvgdk_mini.h | 2 + 2 files changed, 111 insertions(+), 10 deletions(-) diff --git a/drivers/hv/mshv_synic.c b/drivers/hv/mshv_synic.c index f716c2a4952f..1e48fce5816b 100644 --- a/drivers/hv/mshv_synic.c +++ b/drivers/hv/mshv_synic.c @@ -10,17 +10,21 @@ #include #include #include +#include #include #include #include #include #include +#include =20 #include "mshv_eventfd.h" #include "mshv.h" =20 static int synic_cpuhp_online; static struct hv_synic_pages __percpu *synic_pages; +static int mshv_sint_vector =3D -1; /* hwirq for the SynIC SINTs */ +static int mshv_sint_irq =3D -1; /* Linux IRQ for mshv_sint_vector */ =20 static u32 synic_event_ring_get_queued_port(u32 sint_index) { @@ -442,9 +446,7 @@ void mshv_isr(void) if (msg->header.message_flags.msg_pending) hv_set_non_nested_msr(HV_MSR_EOM, 0); =20 -#ifdef HYPERVISOR_CALLBACK_VECTOR - add_interrupt_randomness(HYPERVISOR_CALLBACK_VECTOR); -#endif + add_interrupt_randomness(mshv_sint_vector); } else { pr_warn_once("%s: unknown message type 0x%x\n", __func__, msg->header.message_type); @@ -456,9 +458,7 @@ static int mshv_synic_cpu_init(unsigned int cpu) union hv_synic_simp simp; union hv_synic_siefp siefp; union hv_synic_sirbp sirbp; -#ifdef HYPERVISOR_CALLBACK_VECTOR union hv_synic_sint sint; -#endif union hv_synic_scontrol sctrl; struct hv_synic_pages *spages =3D this_cpu_ptr(synic_pages); struct hv_message_page **msg_page =3D &spages->hyp_synic_message_page; @@ -501,10 +501,12 @@ static int mshv_synic_cpu_init(unsigned int cpu) =20 hv_set_non_nested_msr(HV_MSR_SIRBP, sirbp.as_uint64); =20 -#ifdef HYPERVISOR_CALLBACK_VECTOR + if (mshv_sint_irq !=3D -1) + enable_percpu_irq(mshv_sint_irq, 0); + /* Enable intercepts */ sint.as_uint64 =3D 0; - sint.vector =3D HYPERVISOR_CALLBACK_VECTOR; + sint.vector =3D mshv_sint_vector; sint.masked =3D false; sint.auto_eoi =3D hv_recommend_using_aeoi(); hv_set_non_nested_msr(HV_MSR_SINT0 + HV_SYNIC_INTERCEPTION_SINT_INDEX, @@ -512,13 +514,12 @@ static int mshv_synic_cpu_init(unsigned int cpu) =20 /* Doorbell SINT */ sint.as_uint64 =3D 0; - sint.vector =3D HYPERVISOR_CALLBACK_VECTOR; + sint.vector =3D mshv_sint_vector; sint.masked =3D false; sint.as_intercept =3D 1; sint.auto_eoi =3D hv_recommend_using_aeoi(); hv_set_non_nested_msr(HV_MSR_SINT0 + HV_SYNIC_DOORBELL_SINT_INDEX, sint.as_uint64); -#endif =20 /* Enable global synic bit */ sctrl.as_uint64 =3D hv_get_non_nested_msr(HV_MSR_SCONTROL); @@ -573,6 +574,9 @@ static int mshv_synic_cpu_exit(unsigned int cpu) hv_set_non_nested_msr(HV_MSR_SINT0 + HV_SYNIC_DOORBELL_SINT_INDEX, sint.as_uint64); =20 + if (mshv_sint_irq !=3D -1) + disable_percpu_irq(mshv_sint_irq); + /* Disable Synic's event ring page */ sirbp.as_uint64 =3D hv_get_non_nested_msr(HV_MSR_SIRBP); sirbp.sirbp_enabled =3D false; @@ -683,14 +687,106 @@ static struct notifier_block mshv_synic_reboot_nb = =3D { .notifier_call =3D mshv_synic_reboot_notify, }; =20 +#ifndef HYPERVISOR_CALLBACK_VECTOR +static DEFINE_PER_CPU(long, mshv_evt); + +static irqreturn_t mshv_percpu_isr(int irq, void *dev_id) +{ + mshv_isr(); + return IRQ_HANDLED; +} + +#ifdef CONFIG_ACPI +static int __init mshv_acpi_setup_sint_irq(void) +{ + return acpi_register_gsi(NULL, mshv_sint_vector, ACPI_EDGE_SENSITIVE, + ACPI_ACTIVE_HIGH); +} + +static void mshv_acpi_cleanup_sint_irq(void) +{ + acpi_unregister_gsi(mshv_sint_vector); +} +#else +static int __init mshv_acpi_setup_sint_irq(void) +{ + return -ENODEV; +} + +static void mshv_acpi_cleanup_sint_irq(void) +{ +} +#endif + +static int __init mshv_sint_vector_setup(void) +{ + int ret; + struct hv_register_assoc reg =3D { + .name =3D HV_ARM64_REGISTER_SINT_RESERVED_INTERRUPT_ID, + }; + union hv_input_vtl input_vtl =3D { 0 }; + + if (acpi_disabled) + return -ENODEV; + + ret =3D hv_call_get_vp_registers(HV_VP_INDEX_SELF, HV_PARTITION_ID_SELF, + 1, input_vtl, ®); + if (ret || !reg.value.reg64) + return -ENODEV; + + mshv_sint_vector =3D reg.value.reg64; + ret =3D mshv_acpi_setup_sint_irq(); + if (ret < 0) { + pr_err("Failed to setup IRQ for MSHV SINT vector %d: %d\n", + mshv_sint_vector, ret); + goto out_fail; + } + + mshv_sint_irq =3D ret; + + ret =3D request_percpu_irq(mshv_sint_irq, mshv_percpu_isr, "MSHV", + &mshv_evt); + if (ret) + goto out_unregister; + + return 0; + +out_unregister: + mshv_acpi_cleanup_sint_irq(); +out_fail: + return ret; +} + +static void mshv_sint_vector_cleanup(void) +{ + free_percpu_irq(mshv_sint_irq, &mshv_evt); + mshv_acpi_cleanup_sint_irq(); +} +#else /* !HYPERVISOR_CALLBACK_VECTOR */ +static int __init mshv_sint_vector_setup(void) +{ + mshv_sint_vector =3D HYPERVISOR_CALLBACK_VECTOR; + return 0; +} + +static void mshv_sint_vector_cleanup(void) +{ +} +#endif /* HYPERVISOR_CALLBACK_VECTOR */ + int __init mshv_synic_init(struct device *dev) { int ret =3D 0; =20 + ret =3D mshv_sint_vector_setup(); + if (ret) + return ret; + synic_pages =3D alloc_percpu(struct hv_synic_pages); if (!synic_pages) { dev_err(dev, "Failed to allocate percpu synic page\n"); - return -ENOMEM; + ret =3D -ENOMEM; + goto sint_vector_cleanup; } =20 ret =3D cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mshv_synic", @@ -713,6 +809,8 @@ int __init mshv_synic_init(struct device *dev) cpuhp_remove_state(synic_cpuhp_online); free_synic_pages: free_percpu(synic_pages); +sint_vector_cleanup: + mshv_sint_vector_cleanup(); return ret; } =20 @@ -721,4 +819,5 @@ void mshv_synic_exit(void) unregister_reboot_notifier(&mshv_synic_reboot_nb); cpuhp_remove_state(synic_cpuhp_online); free_percpu(synic_pages); + mshv_sint_vector_cleanup(); } diff --git a/include/hyperv/hvgdk_mini.h b/include/hyperv/hvgdk_mini.h index 056ef7b6b360..8bb3dd71c5b4 100644 --- a/include/hyperv/hvgdk_mini.h +++ b/include/hyperv/hvgdk_mini.h @@ -1121,6 +1121,8 @@ enum hv_register_name { HV_X64_REGISTER_MSR_MTRR_FIX4KF8000 =3D 0x0008007A, =20 HV_X64_REGISTER_REG_PAGE =3D 0x0009001C, +#elif defined(CONFIG_ARM64) + HV_ARM64_REGISTER_SINT_RESERVED_INTERRUPT_ID =3D 0x00070001, #endif }; =20 --=20 2.34.1