* [PATCH v5 0/2] ARM64 support for doorbell and intercept SINTs
@ 2026-02-23 14:01 Anirudh Rayabharam
2026-02-23 14:01 ` [PATCH v5 1/2] mshv: refactor synic init and cleanup Anirudh Rayabharam
2026-02-23 14:01 ` [PATCH v5 2/2] mshv: add arm64 support for doorbell & intercept SINTs Anirudh Rayabharam
0 siblings, 2 replies; 10+ messages in thread
From: Anirudh Rayabharam @ 2026-02-23 14:01 UTC (permalink / raw)
To: kys, haiyangz, wei.liu, decui, longli, linux-hyperv, linux-kernel; +Cc: anirudh
From: "Anirudh Rayabharam (Microsoft)" <anirudh@anirudhrb.com>
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.
Changes in v5:
- Better align with coding-style.rst guidelines.
Changes in v4:
- Hypervisor now exposes a synthetic register to read the SINT vector
instead of using an ACPI platform device. So make changes to accomodate that.
Changes in v3:
- Moved the hv_root_partition() check into the reboot notifier
to avoid doing it multiple times.
v2: https://lore.kernel.org/linux-hyperv/20260202182706.648192-1-anirudh@anirudhrb.com/
Changes in v2:
Addressed review comments:
- Moved more stuff into mshv_synic.c
- Code simplifications
- Removed unnecessary debug prints
v1: https://lore.kernel.org/linux-hyperv/20260128160437.3342167-1-anirudh@anirudhrb.com/
Anirudh Rayabharam (Microsoft) (2):
mshv: refactor synic init and cleanup
mshv: add arm64 support for doorbell & intercept SINTs
drivers/hv/mshv_root.h | 5 +-
drivers/hv/mshv_root_main.c | 59 ++---------
drivers/hv/mshv_synic.c | 189 +++++++++++++++++++++++++++++++++---
include/hyperv/hvgdk_mini.h | 2 +
4 files changed, 186 insertions(+), 69 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH v5 1/2] mshv: refactor synic init and cleanup 2026-02-23 14:01 [PATCH v5 0/2] ARM64 support for doorbell and intercept SINTs Anirudh Rayabharam @ 2026-02-23 14:01 ` Anirudh Rayabharam 2026-02-23 17:52 ` Michael Kelley 2026-02-23 14:01 ` [PATCH v5 2/2] mshv: add arm64 support for doorbell & intercept SINTs Anirudh Rayabharam 1 sibling, 1 reply; 10+ messages in thread From: Anirudh Rayabharam @ 2026-02-23 14:01 UTC (permalink / raw) To: kys, haiyangz, wei.liu, decui, longli, linux-hyperv, linux-kernel; +Cc: anirudh From: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com> 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. Signed-off-by: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com> --- drivers/hv/mshv_root.h | 5 ++- drivers/hv/mshv_root_main.c | 59 +++++------------------------- drivers/hv/mshv_synic.c | 71 +++++++++++++++++++++++++++++++++---- 3 files changed, 75 insertions(+), 60 deletions(-) diff --git a/drivers/hv/mshv_root.h b/drivers/hv/mshv_root.h index 3c1d88b36741..26e0320c8097 100644 --- a/drivers/hv/mshv_root.h +++ b/drivers/hv/mshv_root.h @@ -183,7 +183,6 @@ struct hv_synic_pages { }; 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; @@ -242,8 +241,8 @@ int mshv_register_doorbell(u64 partition_id, doorbell_cb_t doorbell_cb, void mshv_unregister_doorbell(u64 partition_id, int doorbell_portid); 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_cleanup(void); static inline bool mshv_partition_encrypted(struct mshv_partition *partition) { diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c index 681b58154d5e..7c1666456e78 100644 --- a/drivers/hv/mshv_root_main.c +++ b/drivers/hv/mshv_root_main.c @@ -2035,7 +2035,6 @@ mshv_dev_release(struct inode *inode, struct file *filp) return 0; } -static int mshv_cpuhp_online; static int mshv_root_sched_online; static const char *scheduler_type_to_string(enum hv_scheduler_type type) @@ -2198,40 +2197,14 @@ root_scheduler_deinit(void) free_percpu(root_scheduler_output); } -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 = { - .notifier_call = mshv_reboot_notify, -}; - static void mshv_root_partition_exit(void) { - unregister_reboot_notifier(&mshv_reboot_nb); root_scheduler_deinit(); } static int __init mshv_root_partition_init(struct device *dev) { - int err; - - err = root_scheduler_init(dev); - if (err) - return err; - - err = register_reboot_notifier(&mshv_reboot_nb); - if (err) - goto root_sched_deinit; - - return 0; - -root_sched_deinit: - root_scheduler_deinit(); - return err; + return root_scheduler_init(dev); } static void mshv_init_vmm_caps(struct device *dev) @@ -2276,31 +2249,18 @@ static int __init mshv_parent_partition_init(void) MSHV_HV_MAX_VERSION); } - mshv_root.synic_pages = alloc_percpu(struct hv_synic_pages); - if (!mshv_root.synic_pages) { - dev_err(dev, "Failed to allocate percpu synic page\n"); - ret = -ENOMEM; + ret = mshv_synic_init(dev); + if (ret) goto device_deregister; - } - - ret = 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 = ret; ret = mshv_retrieve_scheduler_type(dev); if (ret) - goto remove_cpu_state; + goto synic_cleanup; if (hv_root_partition()) ret = mshv_root_partition_init(dev); if (ret) - goto remove_cpu_state; + goto synic_cleanup; mshv_init_vmm_caps(dev); @@ -2318,10 +2278,8 @@ static int __init mshv_parent_partition_init(void) 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_cleanup(); device_deregister: misc_deregister(&mshv_dev); return ret; @@ -2335,8 +2293,7 @@ static void __exit mshv_parent_partition_exit(void) mshv_irqfd_wq_cleanup(); if (hv_root_partition()) mshv_root_partition_exit(); - cpuhp_remove_state(mshv_cpuhp_online); - free_percpu(mshv_root.synic_pages); + mshv_synic_cleanup(); } module_init(mshv_parent_partition_init); diff --git a/drivers/hv/mshv_synic.c b/drivers/hv/mshv_synic.c index f8b0337cdc82..074e37c48876 100644 --- a/drivers/hv/mshv_synic.c +++ b/drivers/hv/mshv_synic.c @@ -12,11 +12,16 @@ #include <linux/mm.h> #include <linux/io.h> #include <linux/random.h> +#include <linux/cpuhotplug.h> +#include <linux/reboot.h> #include <asm/mshyperv.h> #include "mshv_eventfd.h" #include "mshv.h" +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_index) u32 message; u8 tail; - spages = this_cpu_ptr(mshv_root.synic_pages); + spages = this_cpu_ptr(synic_pages); event_ring_page = &spages->synic_event_ring_page; synic_eventring_tail = (u8 **)this_cpu_ptr(hv_synic_eventring_tail); @@ -393,7 +398,7 @@ mshv_intercept_isr(struct hv_message *msg) void mshv_isr(void) { - struct hv_synic_pages *spages = this_cpu_ptr(mshv_root.synic_pages); + struct hv_synic_pages *spages = this_cpu_ptr(synic_pages); struct hv_message_page **msg_page = &spages->hyp_synic_message_page; struct hv_message *msg; bool handled; @@ -446,7 +451,7 @@ void mshv_isr(void) } } -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 = this_cpu_ptr(mshv_root.synic_pages); + struct hv_synic_pages *spages = this_cpu_ptr(synic_pages); struct hv_message_page **msg_page = &spages->hyp_synic_message_page; struct hv_synic_event_flags_page **event_flags_page = &spages->synic_event_flags_page; @@ -542,14 +547,14 @@ int mshv_synic_init(unsigned int cpu) return -EFAULT; } -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 = this_cpu_ptr(mshv_root.synic_pages); + struct hv_synic_pages *spages = this_cpu_ptr(synic_pages); struct hv_message_page **msg_page = &spages->hyp_synic_message_page; struct hv_synic_event_flags_page **event_flags_page = &spages->synic_event_flags_page; @@ -663,3 +668,57 @@ mshv_unregister_doorbell(u64 partition_id, int doorbell_portid) 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 = { + .notifier_call = mshv_synic_reboot_notify, +}; + +int __init mshv_synic_init(struct device *dev) +{ + int ret = 0; + + synic_pages = alloc_percpu(struct hv_synic_pages); + if (!synic_pages) { + dev_err(dev, "Failed to allocate percpu synic page\n"); + return -ENOMEM; + } + + ret = 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 = ret; + + ret = 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_cleanup(void) +{ + unregister_reboot_notifier(&mshv_synic_reboot_nb); + cpuhp_remove_state(synic_cpuhp_online); + free_percpu(synic_pages); +} -- 2.34.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH v5 1/2] mshv: refactor synic init and cleanup 2026-02-23 14:01 ` [PATCH v5 1/2] mshv: refactor synic init and cleanup Anirudh Rayabharam @ 2026-02-23 17:52 ` Michael Kelley 0 siblings, 0 replies; 10+ messages in thread From: Michael Kelley @ 2026-02-23 17:52 UTC (permalink / raw) To: Anirudh Rayabharam, kys, haiyangz, wei.liu, decui, longli, linux-hyperv, linux-kernel From: Anirudh Rayabharam <anirudh@anirudhrb.com> Sent: Monday, February 23, 2026 6:02 AM > > 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. > > Signed-off-by: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com> This patch needs to be rebased on the latest linux-next. It doesn't apply cleanly on linux-next20260219 and resolving the conflicts is a bit messy. But other than that, Reviewed-by: Michael Kelley <mhklinux@outlook.com> > --- > drivers/hv/mshv_root.h | 5 ++- > drivers/hv/mshv_root_main.c | 59 +++++------------------------- > drivers/hv/mshv_synic.c | 71 +++++++++++++++++++++++++++++++++---- > 3 files changed, 75 insertions(+), 60 deletions(-) > > diff --git a/drivers/hv/mshv_root.h b/drivers/hv/mshv_root.h > index 3c1d88b36741..26e0320c8097 100644 > --- a/drivers/hv/mshv_root.h > +++ b/drivers/hv/mshv_root.h > @@ -183,7 +183,6 @@ struct hv_synic_pages { > }; > > 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; > @@ -242,8 +241,8 @@ int mshv_register_doorbell(u64 partition_id, doorbell_cb_t > doorbell_cb, > void mshv_unregister_doorbell(u64 partition_id, int doorbell_portid); > > 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_cleanup(void); > > static inline bool mshv_partition_encrypted(struct mshv_partition *partition) > { > diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c > index 681b58154d5e..7c1666456e78 100644 > --- a/drivers/hv/mshv_root_main.c > +++ b/drivers/hv/mshv_root_main.c > @@ -2035,7 +2035,6 @@ mshv_dev_release(struct inode *inode, struct file *filp) > return 0; > } > > -static int mshv_cpuhp_online; > static int mshv_root_sched_online; > > static const char *scheduler_type_to_string(enum hv_scheduler_type type) > @@ -2198,40 +2197,14 @@ root_scheduler_deinit(void) > free_percpu(root_scheduler_output); > } > > -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 = { > - .notifier_call = mshv_reboot_notify, > -}; > - > static void mshv_root_partition_exit(void) > { > - unregister_reboot_notifier(&mshv_reboot_nb); > root_scheduler_deinit(); > } > > static int __init mshv_root_partition_init(struct device *dev) > { > - int err; > - > - err = root_scheduler_init(dev); > - if (err) > - return err; > - > - err = register_reboot_notifier(&mshv_reboot_nb); > - if (err) > - goto root_sched_deinit; > - > - return 0; > - > -root_sched_deinit: > - root_scheduler_deinit(); > - return err; > + return root_scheduler_init(dev); > } > > static void mshv_init_vmm_caps(struct device *dev) > @@ -2276,31 +2249,18 @@ static int __init mshv_parent_partition_init(void) > MSHV_HV_MAX_VERSION); > } > > - mshv_root.synic_pages = alloc_percpu(struct hv_synic_pages); > - if (!mshv_root.synic_pages) { > - dev_err(dev, "Failed to allocate percpu synic page\n"); > - ret = -ENOMEM; > + ret = mshv_synic_init(dev); > + if (ret) > goto device_deregister; > - } > - > - ret = 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 = ret; > > ret = mshv_retrieve_scheduler_type(dev); > if (ret) > - goto remove_cpu_state; > + goto synic_cleanup; > > if (hv_root_partition()) > ret = mshv_root_partition_init(dev); > if (ret) > - goto remove_cpu_state; > + goto synic_cleanup; > > mshv_init_vmm_caps(dev); > > @@ -2318,10 +2278,8 @@ static int __init mshv_parent_partition_init(void) > 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_cleanup(); > device_deregister: > misc_deregister(&mshv_dev); > return ret; > @@ -2335,8 +2293,7 @@ static void __exit mshv_parent_partition_exit(void) > mshv_irqfd_wq_cleanup(); > if (hv_root_partition()) > mshv_root_partition_exit(); > - cpuhp_remove_state(mshv_cpuhp_online); > - free_percpu(mshv_root.synic_pages); > + mshv_synic_cleanup(); > } > > module_init(mshv_parent_partition_init); > diff --git a/drivers/hv/mshv_synic.c b/drivers/hv/mshv_synic.c > index f8b0337cdc82..074e37c48876 100644 > --- a/drivers/hv/mshv_synic.c > +++ b/drivers/hv/mshv_synic.c > @@ -12,11 +12,16 @@ > #include <linux/mm.h> > #include <linux/io.h> > #include <linux/random.h> > +#include <linux/cpuhotplug.h> > +#include <linux/reboot.h> > #include <asm/mshyperv.h> > > #include "mshv_eventfd.h" > #include "mshv.h" > > +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_index) > u32 message; > u8 tail; > > - spages = this_cpu_ptr(mshv_root.synic_pages); > + spages = this_cpu_ptr(synic_pages); > event_ring_page = &spages->synic_event_ring_page; > synic_eventring_tail = (u8 **)this_cpu_ptr(hv_synic_eventring_tail); > > @@ -393,7 +398,7 @@ mshv_intercept_isr(struct hv_message *msg) > > void mshv_isr(void) > { > - struct hv_synic_pages *spages = this_cpu_ptr(mshv_root.synic_pages); > + struct hv_synic_pages *spages = this_cpu_ptr(synic_pages); > struct hv_message_page **msg_page = &spages->hyp_synic_message_page; > struct hv_message *msg; > bool handled; > @@ -446,7 +451,7 @@ void mshv_isr(void) > } > } > > -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 = this_cpu_ptr(mshv_root.synic_pages); > + struct hv_synic_pages *spages = this_cpu_ptr(synic_pages); > struct hv_message_page **msg_page = &spages->hyp_synic_message_page; > struct hv_synic_event_flags_page **event_flags_page = > &spages->synic_event_flags_page; > @@ -542,14 +547,14 @@ int mshv_synic_init(unsigned int cpu) > return -EFAULT; > } > > -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 = this_cpu_ptr(mshv_root.synic_pages); > + struct hv_synic_pages *spages = this_cpu_ptr(synic_pages); > struct hv_message_page **msg_page = &spages->hyp_synic_message_page; > struct hv_synic_event_flags_page **event_flags_page = > &spages->synic_event_flags_page; > @@ -663,3 +668,57 @@ mshv_unregister_doorbell(u64 partition_id, int > doorbell_portid) > > 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 = { > + .notifier_call = mshv_synic_reboot_notify, > +}; > + > +int __init mshv_synic_init(struct device *dev) > +{ > + int ret = 0; > + > + synic_pages = alloc_percpu(struct hv_synic_pages); > + if (!synic_pages) { > + dev_err(dev, "Failed to allocate percpu synic page\n"); > + return -ENOMEM; > + } > + > + ret = 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 = ret; > + > + ret = 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_cleanup(void) > +{ > + unregister_reboot_notifier(&mshv_synic_reboot_nb); > + cpuhp_remove_state(synic_cpuhp_online); > + free_percpu(synic_pages); > +} > -- > 2.34.1 > ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v5 2/2] mshv: add arm64 support for doorbell & intercept SINTs 2026-02-23 14:01 [PATCH v5 0/2] ARM64 support for doorbell and intercept SINTs Anirudh Rayabharam 2026-02-23 14:01 ` [PATCH v5 1/2] mshv: refactor synic init and cleanup Anirudh Rayabharam @ 2026-02-23 14:01 ` Anirudh Rayabharam 2026-02-23 17:53 ` Michael Kelley 2026-02-23 19:39 ` Stanislav Kinsburskii 1 sibling, 2 replies; 10+ messages in thread From: Anirudh Rayabharam @ 2026-02-23 14:01 UTC (permalink / raw) To: kys, haiyangz, wei.liu, decui, longli, linux-hyperv, linux-kernel; +Cc: anirudh From: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com> 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). Signed-off-by: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com> --- drivers/hv/mshv_synic.c | 120 +++++++++++++++++++++++++++++++++--- include/hyperv/hvgdk_mini.h | 2 + 2 files changed, 112 insertions(+), 10 deletions(-) diff --git a/drivers/hv/mshv_synic.c b/drivers/hv/mshv_synic.c index 074e37c48876..75ef2160b3e0 100644 --- a/drivers/hv/mshv_synic.c +++ b/drivers/hv/mshv_synic.c @@ -10,17 +10,22 @@ #include <linux/kernel.h> #include <linux/slab.h> #include <linux/mm.h> +#include <linux/interrupt.h> #include <linux/io.h> #include <linux/random.h> #include <linux/cpuhotplug.h> #include <linux/reboot.h> #include <asm/mshyperv.h> +#include <linux/platform_device.h> +#include <linux/acpi.h> #include "mshv_eventfd.h" #include "mshv.h" static int synic_cpuhp_online; static struct hv_synic_pages __percpu *synic_pages; +static int mshv_sint_vector = -1; /* hwirq for the SynIC SINTs */ +static int mshv_sint_irq = -1; /* Linux IRQ for mshv_sint_vector */ static u32 synic_event_ring_get_queued_port(u32 sint_index) { @@ -442,9 +447,7 @@ void mshv_isr(void) if (msg->header.message_flags.msg_pending) hv_set_non_nested_msr(HV_MSR_EOM, 0); -#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 +459,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 = this_cpu_ptr(synic_pages); struct hv_message_page **msg_page = &spages->hyp_synic_message_page; @@ -501,10 +502,12 @@ static int mshv_synic_cpu_init(unsigned int cpu) hv_set_non_nested_msr(HV_MSR_SIRBP, sirbp.as_uint64); -#ifdef HYPERVISOR_CALLBACK_VECTOR + if (mshv_sint_irq != -1) + enable_percpu_irq(mshv_sint_irq, 0); + /* Enable intercepts */ sint.as_uint64 = 0; - sint.vector = HYPERVISOR_CALLBACK_VECTOR; + sint.vector = mshv_sint_vector; sint.masked = false; sint.auto_eoi = hv_recommend_using_aeoi(); hv_set_non_nested_msr(HV_MSR_SINT0 + HV_SYNIC_INTERCEPTION_SINT_INDEX, @@ -512,13 +515,12 @@ static int mshv_synic_cpu_init(unsigned int cpu) /* Doorbell SINT */ sint.as_uint64 = 0; - sint.vector = HYPERVISOR_CALLBACK_VECTOR; + sint.vector = mshv_sint_vector; sint.masked = false; sint.as_intercept = 1; sint.auto_eoi = hv_recommend_using_aeoi(); hv_set_non_nested_msr(HV_MSR_SINT0 + HV_SYNIC_DOORBELL_SINT_INDEX, sint.as_uint64); -#endif /* Enable global synic bit */ sctrl.as_uint64 = hv_get_non_nested_msr(HV_MSR_SCONTROL); @@ -573,6 +575,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); + if (mshv_sint_irq != -1) + disable_percpu_irq(mshv_sint_irq); + /* Disable Synic's event ring page */ sirbp.as_uint64 = hv_get_non_nested_msr(HV_MSR_SIRBP); sirbp.sirbp_enabled = false; @@ -683,14 +688,106 @@ static struct notifier_block mshv_synic_reboot_nb = { .notifier_call = mshv_synic_reboot_notify, }; +#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_init(void) +{ + int ret; + struct hv_register_assoc reg = { + .name = HV_ARM64_REGISTER_SINT_RESERVED_INTERRUPT_ID, + }; + union hv_input_vtl input_vtl = { 0 }; + + if (acpi_disabled) + return -ENODEV; + + ret = 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 = reg.value.reg64; + ret = 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 = ret; + + ret = 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_init(void) +{ + mshv_sint_vector = 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 = 0; + ret = mshv_sint_vector_init(); + if (ret) + return ret; + synic_pages = alloc_percpu(struct hv_synic_pages); if (!synic_pages) { dev_err(dev, "Failed to allocate percpu synic page\n"); - return -ENOMEM; + ret = -ENOMEM; + goto sint_vector_cleanup; } ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mshv_synic", @@ -713,6 +810,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; } @@ -721,4 +820,5 @@ void mshv_synic_cleanup(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 30fbbde81c5c..7676f78e0766 100644 --- a/include/hyperv/hvgdk_mini.h +++ b/include/hyperv/hvgdk_mini.h @@ -1117,6 +1117,8 @@ enum hv_register_name { HV_X64_REGISTER_MSR_MTRR_FIX4KF8000 = 0x0008007A, HV_X64_REGISTER_REG_PAGE = 0x0009001C, +#elif defined(CONFIG_ARM64) + HV_ARM64_REGISTER_SINT_RESERVED_INTERRUPT_ID = 0x00070001, #endif }; -- 2.34.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH v5 2/2] mshv: add arm64 support for doorbell & intercept SINTs 2026-02-23 14:01 ` [PATCH v5 2/2] mshv: add arm64 support for doorbell & intercept SINTs Anirudh Rayabharam @ 2026-02-23 17:53 ` Michael Kelley 2026-02-25 12:10 ` Anirudh Rayabharam 2026-02-23 19:39 ` Stanislav Kinsburskii 1 sibling, 1 reply; 10+ messages in thread From: Michael Kelley @ 2026-02-23 17:53 UTC (permalink / raw) To: Anirudh Rayabharam, kys, haiyangz, wei.liu, decui, longli, linux-hyperv, linux-kernel From: Anirudh Rayabharam <anirudh@anirudhrb.com> Sent: Monday, February 23, 2026 6:02 AM > > 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). > > Signed-off-by: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com> > --- > drivers/hv/mshv_synic.c | 120 +++++++++++++++++++++++++++++++++--- > include/hyperv/hvgdk_mini.h | 2 + > 2 files changed, 112 insertions(+), 10 deletions(-) > > diff --git a/drivers/hv/mshv_synic.c b/drivers/hv/mshv_synic.c > index 074e37c48876..75ef2160b3e0 100644 > --- a/drivers/hv/mshv_synic.c > +++ b/drivers/hv/mshv_synic.c > @@ -10,17 +10,22 @@ > #include <linux/kernel.h> > #include <linux/slab.h> > #include <linux/mm.h> > +#include <linux/interrupt.h> > #include <linux/io.h> > #include <linux/random.h> > #include <linux/cpuhotplug.h> > #include <linux/reboot.h> > #include <asm/mshyperv.h> > +#include <linux/platform_device.h> I don't think this #include is needed now that you've switched to getting the INTID via a hypercall instead of via an ACPI device. The rest of the changes look good to me. You have a place carved out to put the DT setup of the mshv_sint_irq, and the scope of all the variables and mshv_percpu_isr() is correct so that there won't be any "unused" warnings generated. Nice! Modulo the unnecessary #include, Reviewed-by: Michael Kelley <mhklinux@outlook.com> > +#include <linux/acpi.h> > > #include "mshv_eventfd.h" > #include "mshv.h" > > static int synic_cpuhp_online; > static struct hv_synic_pages __percpu *synic_pages; > +static int mshv_sint_vector = -1; /* hwirq for the SynIC SINTs */ > +static int mshv_sint_irq = -1; /* Linux IRQ for mshv_sint_vector */ > > static u32 synic_event_ring_get_queued_port(u32 sint_index) > { > @@ -442,9 +447,7 @@ void mshv_isr(void) > if (msg->header.message_flags.msg_pending) > hv_set_non_nested_msr(HV_MSR_EOM, 0); > > -#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 +459,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 = this_cpu_ptr(synic_pages); > struct hv_message_page **msg_page = &spages->hyp_synic_message_page; > @@ -501,10 +502,12 @@ static int mshv_synic_cpu_init(unsigned int cpu) > > hv_set_non_nested_msr(HV_MSR_SIRBP, sirbp.as_uint64); > > -#ifdef HYPERVISOR_CALLBACK_VECTOR > + if (mshv_sint_irq != -1) > + enable_percpu_irq(mshv_sint_irq, 0); > + > /* Enable intercepts */ > sint.as_uint64 = 0; > - sint.vector = HYPERVISOR_CALLBACK_VECTOR; > + sint.vector = mshv_sint_vector; > sint.masked = false; > sint.auto_eoi = hv_recommend_using_aeoi(); > hv_set_non_nested_msr(HV_MSR_SINT0 + > HV_SYNIC_INTERCEPTION_SINT_INDEX, > @@ -512,13 +515,12 @@ static int mshv_synic_cpu_init(unsigned int cpu) > > /* Doorbell SINT */ > sint.as_uint64 = 0; > - sint.vector = HYPERVISOR_CALLBACK_VECTOR; > + sint.vector = mshv_sint_vector; > sint.masked = false; > sint.as_intercept = 1; > sint.auto_eoi = hv_recommend_using_aeoi(); > hv_set_non_nested_msr(HV_MSR_SINT0 + HV_SYNIC_DOORBELL_SINT_INDEX, > sint.as_uint64); > -#endif > > /* Enable global synic bit */ > sctrl.as_uint64 = hv_get_non_nested_msr(HV_MSR_SCONTROL); > @@ -573,6 +575,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); > > + if (mshv_sint_irq != -1) > + disable_percpu_irq(mshv_sint_irq); > + > /* Disable Synic's event ring page */ > sirbp.as_uint64 = hv_get_non_nested_msr(HV_MSR_SIRBP); > sirbp.sirbp_enabled = false; > @@ -683,14 +688,106 @@ static struct notifier_block mshv_synic_reboot_nb = { > .notifier_call = mshv_synic_reboot_notify, > }; > > +#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_init(void) > +{ > + int ret; > + struct hv_register_assoc reg = { > + .name = HV_ARM64_REGISTER_SINT_RESERVED_INTERRUPT_ID, > + }; > + union hv_input_vtl input_vtl = { 0 }; > + > + if (acpi_disabled) > + return -ENODEV; > + > + ret = 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 = reg.value.reg64; > + ret = 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 = ret; > + > + ret = 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_init(void) > +{ > + mshv_sint_vector = 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 = 0; > > + ret = mshv_sint_vector_init(); > + if (ret) > + return ret; > + > synic_pages = alloc_percpu(struct hv_synic_pages); > if (!synic_pages) { > dev_err(dev, "Failed to allocate percpu synic page\n"); > - return -ENOMEM; > + ret = -ENOMEM; > + goto sint_vector_cleanup; > } > > ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mshv_synic", > @@ -713,6 +810,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; > } > > @@ -721,4 +820,5 @@ void mshv_synic_cleanup(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 30fbbde81c5c..7676f78e0766 100644 > --- a/include/hyperv/hvgdk_mini.h > +++ b/include/hyperv/hvgdk_mini.h > @@ -1117,6 +1117,8 @@ enum hv_register_name { > HV_X64_REGISTER_MSR_MTRR_FIX4KF8000 = 0x0008007A, > > HV_X64_REGISTER_REG_PAGE = 0x0009001C, > +#elif defined(CONFIG_ARM64) > + HV_ARM64_REGISTER_SINT_RESERVED_INTERRUPT_ID = 0x00070001, > #endif > }; > > -- > 2.34.1 > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v5 2/2] mshv: add arm64 support for doorbell & intercept SINTs 2026-02-23 17:53 ` Michael Kelley @ 2026-02-25 12:10 ` Anirudh Rayabharam 0 siblings, 0 replies; 10+ messages in thread From: Anirudh Rayabharam @ 2026-02-25 12:10 UTC (permalink / raw) To: Michael Kelley Cc: kys, haiyangz, wei.liu, decui, longli, linux-hyperv, linux-kernel On Mon, Feb 23, 2026 at 05:53:03PM +0000, Michael Kelley wrote: > From: Anirudh Rayabharam <anirudh@anirudhrb.com> Sent: Monday, February 23, 2026 6:02 AM > > > > 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). > > > > Signed-off-by: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com> > > --- > > drivers/hv/mshv_synic.c | 120 +++++++++++++++++++++++++++++++++--- > > include/hyperv/hvgdk_mini.h | 2 + > > 2 files changed, 112 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/hv/mshv_synic.c b/drivers/hv/mshv_synic.c > > index 074e37c48876..75ef2160b3e0 100644 > > --- a/drivers/hv/mshv_synic.c > > +++ b/drivers/hv/mshv_synic.c > > @@ -10,17 +10,22 @@ > > #include <linux/kernel.h> > > #include <linux/slab.h> > > #include <linux/mm.h> > > +#include <linux/interrupt.h> > > #include <linux/io.h> > > #include <linux/random.h> > > #include <linux/cpuhotplug.h> > > #include <linux/reboot.h> > > #include <asm/mshyperv.h> > > +#include <linux/platform_device.h> > > I don't think this #include is needed now that you've switched to getting > the INTID via a hypercall instead of via an ACPI device. > > The rest of the changes look good to me. You have a place carved out > to put the DT setup of the mshv_sint_irq, and the scope of all the > variables and mshv_percpu_isr() is correct so that there won't be any > "unused" warnings generated. Nice! > > Modulo the unnecessary #include, > Reviewed-by: Michael Kelley <mhklinux@outlook.com> Thanks! I'll get rid of the unnecessary include in v6 and also pick-up your Reviewed-by. Anirudh. > > > +#include <linux/acpi.h> > > > > #include "mshv_eventfd.h" > > #include "mshv.h" > > > > static int synic_cpuhp_online; > > static struct hv_synic_pages __percpu *synic_pages; > > +static int mshv_sint_vector = -1; /* hwirq for the SynIC SINTs */ > > +static int mshv_sint_irq = -1; /* Linux IRQ for mshv_sint_vector */ > > > > static u32 synic_event_ring_get_queued_port(u32 sint_index) > > { > > @@ -442,9 +447,7 @@ void mshv_isr(void) > > if (msg->header.message_flags.msg_pending) > > hv_set_non_nested_msr(HV_MSR_EOM, 0); > > > > -#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 +459,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 = this_cpu_ptr(synic_pages); > > struct hv_message_page **msg_page = &spages->hyp_synic_message_page; > > @@ -501,10 +502,12 @@ static int mshv_synic_cpu_init(unsigned int cpu) > > > > hv_set_non_nested_msr(HV_MSR_SIRBP, sirbp.as_uint64); > > > > -#ifdef HYPERVISOR_CALLBACK_VECTOR > > + if (mshv_sint_irq != -1) > > + enable_percpu_irq(mshv_sint_irq, 0); > > + > > /* Enable intercepts */ > > sint.as_uint64 = 0; > > - sint.vector = HYPERVISOR_CALLBACK_VECTOR; > > + sint.vector = mshv_sint_vector; > > sint.masked = false; > > sint.auto_eoi = hv_recommend_using_aeoi(); > > hv_set_non_nested_msr(HV_MSR_SINT0 + > > HV_SYNIC_INTERCEPTION_SINT_INDEX, > > @@ -512,13 +515,12 @@ static int mshv_synic_cpu_init(unsigned int cpu) > > > > /* Doorbell SINT */ > > sint.as_uint64 = 0; > > - sint.vector = HYPERVISOR_CALLBACK_VECTOR; > > + sint.vector = mshv_sint_vector; > > sint.masked = false; > > sint.as_intercept = 1; > > sint.auto_eoi = hv_recommend_using_aeoi(); > > hv_set_non_nested_msr(HV_MSR_SINT0 + HV_SYNIC_DOORBELL_SINT_INDEX, > > sint.as_uint64); > > -#endif > > > > /* Enable global synic bit */ > > sctrl.as_uint64 = hv_get_non_nested_msr(HV_MSR_SCONTROL); > > @@ -573,6 +575,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); > > > > + if (mshv_sint_irq != -1) > > + disable_percpu_irq(mshv_sint_irq); > > + > > /* Disable Synic's event ring page */ > > sirbp.as_uint64 = hv_get_non_nested_msr(HV_MSR_SIRBP); > > sirbp.sirbp_enabled = false; > > @@ -683,14 +688,106 @@ static struct notifier_block mshv_synic_reboot_nb = { > > .notifier_call = mshv_synic_reboot_notify, > > }; > > > > +#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_init(void) > > +{ > > + int ret; > > + struct hv_register_assoc reg = { > > + .name = HV_ARM64_REGISTER_SINT_RESERVED_INTERRUPT_ID, > > + }; > > + union hv_input_vtl input_vtl = { 0 }; > > + > > + if (acpi_disabled) > > + return -ENODEV; > > + > > + ret = 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 = reg.value.reg64; > > + ret = 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 = ret; > > + > > + ret = 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_init(void) > > +{ > > + mshv_sint_vector = 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 = 0; > > > > + ret = mshv_sint_vector_init(); > > + if (ret) > > + return ret; > > + > > synic_pages = alloc_percpu(struct hv_synic_pages); > > if (!synic_pages) { > > dev_err(dev, "Failed to allocate percpu synic page\n"); > > - return -ENOMEM; > > + ret = -ENOMEM; > > + goto sint_vector_cleanup; > > } > > > > ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mshv_synic", > > @@ -713,6 +810,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; > > } > > > > @@ -721,4 +820,5 @@ void mshv_synic_cleanup(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 30fbbde81c5c..7676f78e0766 100644 > > --- a/include/hyperv/hvgdk_mini.h > > +++ b/include/hyperv/hvgdk_mini.h > > @@ -1117,6 +1117,8 @@ enum hv_register_name { > > HV_X64_REGISTER_MSR_MTRR_FIX4KF8000 = 0x0008007A, > > > > HV_X64_REGISTER_REG_PAGE = 0x0009001C, > > +#elif defined(CONFIG_ARM64) > > + HV_ARM64_REGISTER_SINT_RESERVED_INTERRUPT_ID = 0x00070001, > > #endif > > }; > > > > -- > > 2.34.1 > > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v5 2/2] mshv: add arm64 support for doorbell & intercept SINTs 2026-02-23 14:01 ` [PATCH v5 2/2] mshv: add arm64 support for doorbell & intercept SINTs Anirudh Rayabharam 2026-02-23 17:53 ` Michael Kelley @ 2026-02-23 19:39 ` Stanislav Kinsburskii 2026-02-23 20:49 ` Michael Kelley 2026-02-25 12:12 ` Anirudh Rayabharam 1 sibling, 2 replies; 10+ messages in thread From: Stanislav Kinsburskii @ 2026-02-23 19:39 UTC (permalink / raw) To: Anirudh Rayabharam Cc: kys, haiyangz, wei.liu, decui, longli, linux-hyperv, linux-kernel On Mon, Feb 23, 2026 at 02:01:59PM +0000, Anirudh Rayabharam wrote: > From: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com> > > 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). > > Signed-off-by: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com> > --- > drivers/hv/mshv_synic.c | 120 +++++++++++++++++++++++++++++++++--- > include/hyperv/hvgdk_mini.h | 2 + > 2 files changed, 112 insertions(+), 10 deletions(-) > > diff --git a/drivers/hv/mshv_synic.c b/drivers/hv/mshv_synic.c > index 074e37c48876..75ef2160b3e0 100644 > --- a/drivers/hv/mshv_synic.c > +++ b/drivers/hv/mshv_synic.c > @@ -10,17 +10,22 @@ > #include <linux/kernel.h> > #include <linux/slab.h> > #include <linux/mm.h> > +#include <linux/interrupt.h> > #include <linux/io.h> > #include <linux/random.h> > #include <linux/cpuhotplug.h> > #include <linux/reboot.h> > #include <asm/mshyperv.h> > +#include <linux/platform_device.h> > +#include <linux/acpi.h> > > #include "mshv_eventfd.h" > #include "mshv.h" > > static int synic_cpuhp_online; > static struct hv_synic_pages __percpu *synic_pages; > +static int mshv_sint_vector = -1; /* hwirq for the SynIC SINTs */ > +static int mshv_sint_irq = -1; /* Linux IRQ for mshv_sint_vector */ > > static u32 synic_event_ring_get_queued_port(u32 sint_index) > { > @@ -442,9 +447,7 @@ void mshv_isr(void) > if (msg->header.message_flags.msg_pending) > hv_set_non_nested_msr(HV_MSR_EOM, 0); > > -#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 +459,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 = this_cpu_ptr(synic_pages); > struct hv_message_page **msg_page = &spages->hyp_synic_message_page; > @@ -501,10 +502,12 @@ static int mshv_synic_cpu_init(unsigned int cpu) > > hv_set_non_nested_msr(HV_MSR_SIRBP, sirbp.as_uint64); > > -#ifdef HYPERVISOR_CALLBACK_VECTOR > + if (mshv_sint_irq != -1) > + enable_percpu_irq(mshv_sint_irq, 0); > + > /* Enable intercepts */ > sint.as_uint64 = 0; > - sint.vector = HYPERVISOR_CALLBACK_VECTOR; > + sint.vector = mshv_sint_vector; > sint.masked = false; > sint.auto_eoi = hv_recommend_using_aeoi(); > hv_set_non_nested_msr(HV_MSR_SINT0 + HV_SYNIC_INTERCEPTION_SINT_INDEX, > @@ -512,13 +515,12 @@ static int mshv_synic_cpu_init(unsigned int cpu) > > /* Doorbell SINT */ > sint.as_uint64 = 0; > - sint.vector = HYPERVISOR_CALLBACK_VECTOR; > + sint.vector = mshv_sint_vector; > sint.masked = false; > sint.as_intercept = 1; > sint.auto_eoi = hv_recommend_using_aeoi(); > hv_set_non_nested_msr(HV_MSR_SINT0 + HV_SYNIC_DOORBELL_SINT_INDEX, > sint.as_uint64); > -#endif > > /* Enable global synic bit */ > sctrl.as_uint64 = hv_get_non_nested_msr(HV_MSR_SCONTROL); > @@ -573,6 +575,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); > > + if (mshv_sint_irq != -1) > + disable_percpu_irq(mshv_sint_irq); > + > /* Disable Synic's event ring page */ > sirbp.as_uint64 = hv_get_non_nested_msr(HV_MSR_SIRBP); > sirbp.sirbp_enabled = false; > @@ -683,14 +688,106 @@ static struct notifier_block mshv_synic_reboot_nb = { > .notifier_call = mshv_synic_reboot_notify, > }; > > +#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_init(void) > +{ > + int ret; > + struct hv_register_assoc reg = { > + .name = HV_ARM64_REGISTER_SINT_RESERVED_INTERRUPT_ID, > + }; > + union hv_input_vtl input_vtl = { 0 }; > + > + if (acpi_disabled) > + return -ENODEV; > + > + ret = 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 = reg.value.reg64; > + ret = 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 = ret; nit: given that mshv_sint_irq can't be zero, the logic can be simplified by using 0 instead of -1. > + > + ret = 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_init(void) nit: `init` is usually paired with `exit` or `fini`, so maybe `cleanup` can be renamed to `exit` as well for better consistency? Reviewed-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com> > +{ > + mshv_sint_vector = 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 = 0; > > + ret = mshv_sint_vector_init(); > + if (ret) > + return ret; > + > synic_pages = alloc_percpu(struct hv_synic_pages); > if (!synic_pages) { > dev_err(dev, "Failed to allocate percpu synic page\n"); > - return -ENOMEM; > + ret = -ENOMEM; > + goto sint_vector_cleanup; > } > > ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mshv_synic", > @@ -713,6 +810,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; > } > > @@ -721,4 +820,5 @@ void mshv_synic_cleanup(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 30fbbde81c5c..7676f78e0766 100644 > --- a/include/hyperv/hvgdk_mini.h > +++ b/include/hyperv/hvgdk_mini.h > @@ -1117,6 +1117,8 @@ enum hv_register_name { > HV_X64_REGISTER_MSR_MTRR_FIX4KF8000 = 0x0008007A, > > HV_X64_REGISTER_REG_PAGE = 0x0009001C, > +#elif defined(CONFIG_ARM64) > + HV_ARM64_REGISTER_SINT_RESERVED_INTERRUPT_ID = 0x00070001, > #endif > }; > > -- > 2.34.1 > ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH v5 2/2] mshv: add arm64 support for doorbell & intercept SINTs 2026-02-23 19:39 ` Stanislav Kinsburskii @ 2026-02-23 20:49 ` Michael Kelley 2026-02-25 12:11 ` Anirudh Rayabharam 2026-02-25 12:12 ` Anirudh Rayabharam 1 sibling, 1 reply; 10+ messages in thread From: Michael Kelley @ 2026-02-23 20:49 UTC (permalink / raw) To: Stanislav Kinsburskii, Anirudh Rayabharam Cc: kys, haiyangz, wei.liu, decui, longli, linux-hyperv, linux-kernel From: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com> Sent: Monday, February 23, 2026 11:40 AM > [snip] > > + > > +static int __init mshv_sint_vector_init(void) > > +{ > > + int ret; > > + struct hv_register_assoc reg = { > > + .name = HV_ARM64_REGISTER_SINT_RESERVED_INTERRUPT_ID, > > + }; > > + union hv_input_vtl input_vtl = { 0 }; > > + > > + if (acpi_disabled) > > + return -ENODEV; > > + > > + ret = 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 = reg.value.reg64; > > + ret = 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 = ret; > > nit: given that mshv_sint_irq can't be zero, the logic can be simplified by > using 0 instead of -1. The test for <= 0 is actually wrong -- it should be just < 0. Zero is a valid Linux IRQ number. For example, here's the output of /proc/interrupts on a Gen1 VM on Hyper-V, where IRQ 0 is used by the legacy timer: root@gen1ubun:~# cat /proc/interrupts CPU0 CPU1 CPU2 CPU3 0: 18 0 0 0 IR-IO-APIC 2-edge timer 1: 0 9 0 0 IR-IO-APIC 1-edge i8042 4: 0 0 0 792 IR-IO-APIC 4-edge ttyS0 6: 6 0 0 0 IR-IO-APIC 6-edge floppy 8: 0 0 0 0 IR-IO-APIC 8-edge rtc0 9: 0 0 0 0 IR-IO-APIC 9-fasteoi acpi But I see other places throughout Linux kernel code that treat IRQ 0 as invalid. So I dunno .... But it's probably better to treat 0 as a valid IRQ number. Michael > > > > > + > > + ret = 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_init(void) > > nit: `init` is usually paired with `exit` or `fini`, so maybe `cleanup` can be > renamed to `exit` as well for better consistency? > > Reviewed-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com> > > > +{ > > + mshv_sint_vector = 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 = 0; > > > > + ret = mshv_sint_vector_init(); > > + if (ret) > > + return ret; > > + > > synic_pages = alloc_percpu(struct hv_synic_pages); > > if (!synic_pages) { > > dev_err(dev, "Failed to allocate percpu synic page\n"); > > - return -ENOMEM; > > + ret = -ENOMEM; > > + goto sint_vector_cleanup; > > } > > > > ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mshv_synic", > > @@ -713,6 +810,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; > > } > > > > @@ -721,4 +820,5 @@ void mshv_synic_cleanup(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 30fbbde81c5c..7676f78e0766 100644 > > --- a/include/hyperv/hvgdk_mini.h > > +++ b/include/hyperv/hvgdk_mini.h > > @@ -1117,6 +1117,8 @@ enum hv_register_name { > > HV_X64_REGISTER_MSR_MTRR_FIX4KF8000 = 0x0008007A, > > > > HV_X64_REGISTER_REG_PAGE = 0x0009001C, > > +#elif defined(CONFIG_ARM64) > > + HV_ARM64_REGISTER_SINT_RESERVED_INTERRUPT_ID = 0x00070001, > > #endif > > }; > > > > -- > > 2.34.1 > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v5 2/2] mshv: add arm64 support for doorbell & intercept SINTs 2026-02-23 20:49 ` Michael Kelley @ 2026-02-25 12:11 ` Anirudh Rayabharam 0 siblings, 0 replies; 10+ messages in thread From: Anirudh Rayabharam @ 2026-02-25 12:11 UTC (permalink / raw) To: Michael Kelley Cc: Stanislav Kinsburskii, kys, haiyangz, wei.liu, decui, longli, linux-hyperv, linux-kernel On Mon, Feb 23, 2026 at 08:49:37PM +0000, Michael Kelley wrote: > From: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com> Sent: Monday, February 23, 2026 11:40 AM > > > > [snip] > > > > + > > > +static int __init mshv_sint_vector_init(void) > > > +{ > > > + int ret; > > > + struct hv_register_assoc reg = { > > > + .name = HV_ARM64_REGISTER_SINT_RESERVED_INTERRUPT_ID, > > > + }; > > > + union hv_input_vtl input_vtl = { 0 }; > > > + > > > + if (acpi_disabled) > > > + return -ENODEV; > > > + > > > + ret = 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 = reg.value.reg64; > > > + ret = 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 = ret; > > > > nit: given that mshv_sint_irq can't be zero, the logic can be simplified by > > using 0 instead of -1. > > The test for <= 0 is actually wrong -- it should be just < 0. Zero is a valid > Linux IRQ number. For example, here's the output of /proc/interrupts on > a Gen1 VM on Hyper-V, where IRQ 0 is used by the legacy timer: > > root@gen1ubun:~# cat /proc/interrupts > CPU0 CPU1 CPU2 CPU3 > 0: 18 0 0 0 IR-IO-APIC 2-edge timer > 1: 0 9 0 0 IR-IO-APIC 1-edge i8042 > 4: 0 0 0 792 IR-IO-APIC 4-edge ttyS0 > 6: 6 0 0 0 IR-IO-APIC 6-edge floppy > 8: 0 0 0 0 IR-IO-APIC 8-edge rtc0 > 9: 0 0 0 0 IR-IO-APIC 9-fasteoi acpi > > But I see other places throughout Linux kernel code that treat IRQ 0 as > invalid. So I dunno .... But it's probably better to treat 0 as a valid IRQ > number. Agreed. I will fix this check in v6. Thanks, Anirudh. > > Michael > > > > > > > > > > + > > > + ret = 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_init(void) > > > > nit: `init` is usually paired with `exit` or `fini`, so maybe `cleanup` can be > > renamed to `exit` as well for better consistency? > > > > Reviewed-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com> > > > > > +{ > > > + mshv_sint_vector = 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 = 0; > > > > > > + ret = mshv_sint_vector_init(); > > > + if (ret) > > > + return ret; > > > + > > > synic_pages = alloc_percpu(struct hv_synic_pages); > > > if (!synic_pages) { > > > dev_err(dev, "Failed to allocate percpu synic page\n"); > > > - return -ENOMEM; > > > + ret = -ENOMEM; > > > + goto sint_vector_cleanup; > > > } > > > > > > ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mshv_synic", > > > @@ -713,6 +810,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; > > > } > > > > > > @@ -721,4 +820,5 @@ void mshv_synic_cleanup(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 30fbbde81c5c..7676f78e0766 100644 > > > --- a/include/hyperv/hvgdk_mini.h > > > +++ b/include/hyperv/hvgdk_mini.h > > > @@ -1117,6 +1117,8 @@ enum hv_register_name { > > > HV_X64_REGISTER_MSR_MTRR_FIX4KF8000 = 0x0008007A, > > > > > > HV_X64_REGISTER_REG_PAGE = 0x0009001C, > > > +#elif defined(CONFIG_ARM64) > > > + HV_ARM64_REGISTER_SINT_RESERVED_INTERRUPT_ID = 0x00070001, > > > #endif > > > }; > > > > > > -- > > > 2.34.1 > > > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v5 2/2] mshv: add arm64 support for doorbell & intercept SINTs 2026-02-23 19:39 ` Stanislav Kinsburskii 2026-02-23 20:49 ` Michael Kelley @ 2026-02-25 12:12 ` Anirudh Rayabharam 1 sibling, 0 replies; 10+ messages in thread From: Anirudh Rayabharam @ 2026-02-25 12:12 UTC (permalink / raw) To: Stanislav Kinsburskii Cc: kys, haiyangz, wei.liu, decui, longli, linux-hyperv, linux-kernel On Mon, Feb 23, 2026 at 11:39:43AM -0800, Stanislav Kinsburskii wrote: > On Mon, Feb 23, 2026 at 02:01:59PM +0000, Anirudh Rayabharam wrote: > > From: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com> > > > > 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). > > > > Signed-off-by: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com> > > --- > > drivers/hv/mshv_synic.c | 120 +++++++++++++++++++++++++++++++++--- > > include/hyperv/hvgdk_mini.h | 2 + > > 2 files changed, 112 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/hv/mshv_synic.c b/drivers/hv/mshv_synic.c > > index 074e37c48876..75ef2160b3e0 100644 > > --- a/drivers/hv/mshv_synic.c > > +++ b/drivers/hv/mshv_synic.c > > @@ -10,17 +10,22 @@ > > #include <linux/kernel.h> > > #include <linux/slab.h> > > #include <linux/mm.h> > > +#include <linux/interrupt.h> > > #include <linux/io.h> > > #include <linux/random.h> > > #include <linux/cpuhotplug.h> > > #include <linux/reboot.h> > > #include <asm/mshyperv.h> > > +#include <linux/platform_device.h> > > +#include <linux/acpi.h> > > > > #include "mshv_eventfd.h" > > #include "mshv.h" > > > > static int synic_cpuhp_online; > > static struct hv_synic_pages __percpu *synic_pages; > > +static int mshv_sint_vector = -1; /* hwirq for the SynIC SINTs */ > > +static int mshv_sint_irq = -1; /* Linux IRQ for mshv_sint_vector */ > > > > static u32 synic_event_ring_get_queued_port(u32 sint_index) > > { > > @@ -442,9 +447,7 @@ void mshv_isr(void) > > if (msg->header.message_flags.msg_pending) > > hv_set_non_nested_msr(HV_MSR_EOM, 0); > > > > -#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 +459,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 = this_cpu_ptr(synic_pages); > > struct hv_message_page **msg_page = &spages->hyp_synic_message_page; > > @@ -501,10 +502,12 @@ static int mshv_synic_cpu_init(unsigned int cpu) > > > > hv_set_non_nested_msr(HV_MSR_SIRBP, sirbp.as_uint64); > > > > -#ifdef HYPERVISOR_CALLBACK_VECTOR > > + if (mshv_sint_irq != -1) > > + enable_percpu_irq(mshv_sint_irq, 0); > > + > > /* Enable intercepts */ > > sint.as_uint64 = 0; > > - sint.vector = HYPERVISOR_CALLBACK_VECTOR; > > + sint.vector = mshv_sint_vector; > > sint.masked = false; > > sint.auto_eoi = hv_recommend_using_aeoi(); > > hv_set_non_nested_msr(HV_MSR_SINT0 + HV_SYNIC_INTERCEPTION_SINT_INDEX, > > @@ -512,13 +515,12 @@ static int mshv_synic_cpu_init(unsigned int cpu) > > > > /* Doorbell SINT */ > > sint.as_uint64 = 0; > > - sint.vector = HYPERVISOR_CALLBACK_VECTOR; > > + sint.vector = mshv_sint_vector; > > sint.masked = false; > > sint.as_intercept = 1; > > sint.auto_eoi = hv_recommend_using_aeoi(); > > hv_set_non_nested_msr(HV_MSR_SINT0 + HV_SYNIC_DOORBELL_SINT_INDEX, > > sint.as_uint64); > > -#endif > > > > /* Enable global synic bit */ > > sctrl.as_uint64 = hv_get_non_nested_msr(HV_MSR_SCONTROL); > > @@ -573,6 +575,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); > > > > + if (mshv_sint_irq != -1) > > + disable_percpu_irq(mshv_sint_irq); > > + > > /* Disable Synic's event ring page */ > > sirbp.as_uint64 = hv_get_non_nested_msr(HV_MSR_SIRBP); > > sirbp.sirbp_enabled = false; > > @@ -683,14 +688,106 @@ static struct notifier_block mshv_synic_reboot_nb = { > > .notifier_call = mshv_synic_reboot_notify, > > }; > > > > +#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_init(void) > > +{ > > + int ret; > > + struct hv_register_assoc reg = { > > + .name = HV_ARM64_REGISTER_SINT_RESERVED_INTERRUPT_ID, > > + }; > > + union hv_input_vtl input_vtl = { 0 }; > > + > > + if (acpi_disabled) > > + return -ENODEV; > > + > > + ret = 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 = reg.value.reg64; > > + ret = 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 = ret; > > nit: given that mshv_sint_irq can't be zero, the logic can be simplified by > using 0 instead of -1. > > > > > + > > + ret = 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_init(void) > > nit: `init` is usually paired with `exit` or `fini`, so maybe `cleanup` can be > renamed to `exit` as well for better consistency? > > Reviewed-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com> Thanks! I'll fix the naming inconsistencies and also pickup your Reviewed-by in v6. Anirudh. > > > +{ > > + mshv_sint_vector = 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 = 0; > > > > + ret = mshv_sint_vector_init(); > > + if (ret) > > + return ret; > > + > > synic_pages = alloc_percpu(struct hv_synic_pages); > > if (!synic_pages) { > > dev_err(dev, "Failed to allocate percpu synic page\n"); > > - return -ENOMEM; > > + ret = -ENOMEM; > > + goto sint_vector_cleanup; > > } > > > > ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mshv_synic", > > @@ -713,6 +810,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; > > } > > > > @@ -721,4 +820,5 @@ void mshv_synic_cleanup(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 30fbbde81c5c..7676f78e0766 100644 > > --- a/include/hyperv/hvgdk_mini.h > > +++ b/include/hyperv/hvgdk_mini.h > > @@ -1117,6 +1117,8 @@ enum hv_register_name { > > HV_X64_REGISTER_MSR_MTRR_FIX4KF8000 = 0x0008007A, > > > > HV_X64_REGISTER_REG_PAGE = 0x0009001C, > > +#elif defined(CONFIG_ARM64) > > + HV_ARM64_REGISTER_SINT_RESERVED_INTERRUPT_ID = 0x00070001, > > #endif > > }; > > > > -- > > 2.34.1 > > ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-02-25 12:13 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-02-23 14:01 [PATCH v5 0/2] ARM64 support for doorbell and intercept SINTs Anirudh Rayabharam 2026-02-23 14:01 ` [PATCH v5 1/2] mshv: refactor synic init and cleanup Anirudh Rayabharam 2026-02-23 17:52 ` Michael Kelley 2026-02-23 14:01 ` [PATCH v5 2/2] mshv: add arm64 support for doorbell & intercept SINTs Anirudh Rayabharam 2026-02-23 17:53 ` Michael Kelley 2026-02-25 12:10 ` Anirudh Rayabharam 2026-02-23 19:39 ` Stanislav Kinsburskii 2026-02-23 20:49 ` Michael Kelley 2026-02-25 12:11 ` Anirudh Rayabharam 2026-02-25 12:12 ` Anirudh Rayabharam
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®