* [PATCH 0/2] genirq and Hyper-V: Clean up handling of add_interrupt_randomness()
@ 2026-04-02 20:23 Michael Kelley
2026-04-02 20:23 ` [PATCH 1/2] genirq/chip: Do add_interrupt_randomness() in handle_percpu_devid_irq() Michael Kelley
2026-04-02 20:24 ` [PATCH 2/2] Drivers: hv: Move add_interrupt_randomness() to hypervisor callback sysvec Michael Kelley
0 siblings, 2 replies; 7+ messages in thread
From: Michael Kelley @ 2026-04-02 20:23 UTC (permalink / raw)
To: kys, haiyangz, wei.liu, decui, longli, tglx, mingo, bp,
dave.hansen, hpa, maz, bigeasy, x86, linux-kernel, linux-hyperv
From: Michael Kelley <mhklinux@outlook.com>
The Hyper-V ISRs are calling add_interrupt_randomness() as a
primary source of entropy in VMs, since the VMs don't have another
good source. The call is currently in the ISRs as a common place to
handle both x86/x64 and arm64. On x86/x64, hypervisor interrupts come
through a custom sysvec entry, and on arm64 they come through an
emulated GICv3. GICv3 uses the generic handler handle_percpu_devid_irq(),
which does not do add_interrupt_randomness(), unlike its counterpart
handle_percpu_irq().
Cleanup this somewhat confusing situation by doing the
add_interrupt_randomness() in handle_percpu_devid_irq(), and remove
it from the Hyper-V ISRs. Then only the Hyper-V custom sysvec path,
which plays the role of a generic interrupt handler, needs to do
add_interrupt_randomness(). As a result of this change, no
device drivers are calling add_interrupt_randomness(), which is
appropriate.
The change is broken into two patches since it spans generic
interrupt handling code and Hyper-V specific code. But the two
patches should be taken together through the same tree. It's
OK to have a bisect window where add_interrupt_randomness() is
done in both places, but taking the Hyper-V patch first could leave
a bisect window where add_interrupt_randomness() is not done in
either place.
Michael Kelley (2):
genirq/chip: Do add_interrupt_randomness() in
handle_percpu_devid_irq()
Drivers: hv: Move add_interrupt_randomness() to hypervisor callback
sysvec
arch/x86/kernel/cpu/mshyperv.c | 2 ++
drivers/hv/mshv_synic.c | 3 ---
drivers/hv/vmbus_drv.c | 3 ---
kernel/irq/chip.c | 3 +++
4 files changed, 5 insertions(+), 6 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 1/2] genirq/chip: Do add_interrupt_randomness() in handle_percpu_devid_irq() 2026-04-02 20:23 [PATCH 0/2] genirq and Hyper-V: Clean up handling of add_interrupt_randomness() Michael Kelley @ 2026-04-02 20:23 ` Michael Kelley 2026-04-02 21:11 ` [tip: irq/core] genirq/chip: Invoke " tip-bot2 for Michael Kelley 2026-04-02 20:24 ` [PATCH 2/2] Drivers: hv: Move add_interrupt_randomness() to hypervisor callback sysvec Michael Kelley 1 sibling, 1 reply; 7+ messages in thread From: Michael Kelley @ 2026-04-02 20:23 UTC (permalink / raw) To: kys, haiyangz, wei.liu, decui, longli, tglx, mingo, bp, dave.hansen, hpa, maz, bigeasy, x86, linux-kernel, linux-hyperv From: Michael Kelley <mhklinux@outlook.com> handle_percpu_devid_irq() is a version of handle_percpu_irq() but with the addition of a pointer to a per-cpu devid. However, handle_percpu_irq() does add_interrupt_randomness(), while handle_percpu_devid_irq() currently does not. Add the missing add_interrupt_randomness(), as it is needed when per-cpu interrupts with devid's are used in VMs for interrupts from the hypervisor. Signed-off-by: Michael Kelley <mhklinux@outlook.com> --- kernel/irq/chip.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 6147a07d0127..6c9b1dc4e7d4 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -14,6 +14,7 @@ #include <linux/interrupt.h> #include <linux/kernel_stat.h> #include <linux/irqdomain.h> +#include <linux/random.h> #include <trace/events/irq.h> @@ -929,6 +930,8 @@ void handle_percpu_devid_irq(struct irq_desc *desc) enabled ? " and unmasked" : "", irq, cpu); } + add_interrupt_randomness(irq); + if (chip->irq_eoi) chip->irq_eoi(&desc->irq_data); } -- 2.25.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [tip: irq/core] genirq/chip: Invoke add_interrupt_randomness() in handle_percpu_devid_irq() 2026-04-02 20:23 ` [PATCH 1/2] genirq/chip: Do add_interrupt_randomness() in handle_percpu_devid_irq() Michael Kelley @ 2026-04-02 21:11 ` tip-bot2 for Michael Kelley 0 siblings, 0 replies; 7+ messages in thread From: tip-bot2 for Michael Kelley @ 2026-04-02 21:11 UTC (permalink / raw) To: linux-tip-commits; +Cc: Michael Kelley, Thomas Gleixner, x86, linux-kernel, maz The following commit has been merged into the irq/core branch of tip: Commit-ID: fd7400cfcbaaa1f3d1b904711d9daf029e996364 Gitweb: https://git.kernel.org/tip/fd7400cfcbaaa1f3d1b904711d9daf029e996364 Author: Michael Kelley <mhklinux@outlook.com> AuthorDate: Thu, 02 Apr 2026 13:23:59 -07:00 Committer: Thomas Gleixner <tglx@kernel.org> CommitterDate: Thu, 02 Apr 2026 23:03:29 +02:00 genirq/chip: Invoke add_interrupt_randomness() in handle_percpu_devid_irq() handle_percpu_devid_irq() is a version of handle_percpu_irq() but with the addition of a pointer to a per-CPU devid. However, handle_percpu_irq() invokes add_interrupt_randomness(), while handle_percpu_devid_irq() currently does not. Add the missing add_interrupt_randomness(), as it is needed when per-CPU interrupts with devid's are used in VMs for interrupts from the hypervisor. Signed-off-by: Michael Kelley <mhklinux@outlook.com> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Link: https://patch.msgid.link/20260402202400.1707-2-mhklkml@zohomail.com --- kernel/irq/chip.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 6147a07..6c9b1dc 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -14,6 +14,7 @@ #include <linux/interrupt.h> #include <linux/kernel_stat.h> #include <linux/irqdomain.h> +#include <linux/random.h> #include <trace/events/irq.h> @@ -929,6 +930,8 @@ void handle_percpu_devid_irq(struct irq_desc *desc) enabled ? " and unmasked" : "", irq, cpu); } + add_interrupt_randomness(irq); + if (chip->irq_eoi) chip->irq_eoi(&desc->irq_data); } ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] Drivers: hv: Move add_interrupt_randomness() to hypervisor callback sysvec 2026-04-02 20:23 [PATCH 0/2] genirq and Hyper-V: Clean up handling of add_interrupt_randomness() Michael Kelley 2026-04-02 20:23 ` [PATCH 1/2] genirq/chip: Do add_interrupt_randomness() in handle_percpu_devid_irq() Michael Kelley @ 2026-04-02 20:24 ` Michael Kelley 2026-04-02 21:07 ` Thomas Gleixner ` (2 more replies) 1 sibling, 3 replies; 7+ messages in thread From: Michael Kelley @ 2026-04-02 20:24 UTC (permalink / raw) To: kys, haiyangz, wei.liu, decui, longli, tglx, mingo, bp, dave.hansen, hpa, maz, bigeasy, x86, linux-kernel, linux-hyperv From: Michael Kelley <mhklinux@outlook.com> The Hyper-V ISRs, for normal guests and when running in the hypervisor root patition, are calling add_interrupt_randomness() as a primary source of entropy. The call is currently in the ISRs as a common place to handle both x86/x64 and arm64. On x86/x64, hypervisor interrupts come through a custom sysvec entry, and do not go through a generic interrupt handler. On arm64, hypervisor interrupts come through an emulated GICv3. GICv3 uses the generic handler handle_percpu_devid_irq(), which does not do add_interrupt_randomness() -- unlike its counterpart handle_percpu_irq(). But handle_percpu_devid_irq() is now updated to do the add_interrupt_randomness(). So add_interrupt_randomness() is now needed only in Hyper-V's x86/x64 custom sysvec path. Move add_interrupt_randomness() from the Hyper-V ISRs into the Hyper-V x86/x64 custom sysvec path, matching the existing STIMER0 sysvec path. With this change, add_interrupt_randomness() is no longer called from any device drivers, which is appropriate. Signed-off-by: Michael Kelley <mhklinux@outlook.com> --- arch/x86/kernel/cpu/mshyperv.c | 2 ++ drivers/hv/mshv_synic.c | 3 --- drivers/hv/vmbus_drv.c | 3 --- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index 9befdc557d9e..a7dfc29d3470 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -161,6 +161,8 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_hyperv_callback) if (vmbus_handler) vmbus_handler(); + add_interrupt_randomness(HYPERVISOR_CALLBACK_VECTOR); + if (ms_hyperv.hints & HV_DEPRECATING_AEOI_RECOMMENDED) apic_eoi(); diff --git a/drivers/hv/mshv_synic.c b/drivers/hv/mshv_synic.c index 43f1bcbbf2d3..e2288a726fec 100644 --- a/drivers/hv/mshv_synic.c +++ b/drivers/hv/mshv_synic.c @@ -12,7 +12,6 @@ #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> @@ -445,8 +444,6 @@ void mshv_isr(void) mb(); if (msg->header.message_flags.msg_pending) hv_set_non_nested_msr(HV_MSR_EOM, 0); - - add_interrupt_randomness(mshv_sint_vector); } else { pr_warn_once("%s: unknown message type 0x%x\n", __func__, msg->header.message_type); diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 1d71c28fadba..3faa74e49a6b 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -32,7 +32,6 @@ #include <linux/ptrace.h> #include <linux/sysfb.h> #include <linux/efi.h> -#include <linux/random.h> #include <linux/kernel.h> #include <linux/syscore_ops.h> #include <linux/dma-map-ops.h> @@ -1356,8 +1355,6 @@ static void __vmbus_isr(void) vmbus_message_sched(hv_cpu, hv_cpu->hyp_synic_message_page); vmbus_message_sched(hv_cpu, hv_cpu->para_synic_message_page); - - add_interrupt_randomness(vmbus_interrupt); } static DEFINE_PER_CPU(bool, vmbus_irq_pending); -- 2.25.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] Drivers: hv: Move add_interrupt_randomness() to hypervisor callback sysvec 2026-04-02 20:24 ` [PATCH 2/2] Drivers: hv: Move add_interrupt_randomness() to hypervisor callback sysvec Michael Kelley @ 2026-04-02 21:07 ` Thomas Gleixner 2026-04-04 6:11 ` Wei Liu 2026-04-04 19:05 ` [tip: irq/core] " tip-bot2 for Michael Kelley 2 siblings, 0 replies; 7+ messages in thread From: Thomas Gleixner @ 2026-04-02 21:07 UTC (permalink / raw) To: mhklinux, kys, haiyangz, wei.liu, decui, longli, mingo, bp, dave.hansen, hpa, maz, bigeasy, x86, linux-kernel, linux-hyperv On Thu, Apr 02 2026 at 13:24, Michael Kelley wrote: > From: Michael Kelley <mhklinux@outlook.com> > > The Hyper-V ISRs, for normal guests and when running in the > hypervisor root patition, are calling add_interrupt_randomness() as a > primary source of entropy. The call is currently in the ISRs as a common > place to handle both x86/x64 and arm64. On x86/x64, hypervisor interrupts > come through a custom sysvec entry, and do not go through a generic > interrupt handler. On arm64, hypervisor interrupts come through an > emulated GICv3. GICv3 uses the generic handler handle_percpu_devid_irq(), > which does not do add_interrupt_randomness() -- unlike its counterpart > handle_percpu_irq(). But handle_percpu_devid_irq() is now updated to do > the add_interrupt_randomness(). So add_interrupt_randomness() is now > needed only in Hyper-V's x86/x64 custom sysvec path. > > Move add_interrupt_randomness() from the Hyper-V ISRs into the Hyper-V > x86/x64 custom sysvec path, matching the existing STIMER0 sysvec path. > With this change, add_interrupt_randomness() is no longer called from any > device drivers, which is appropriate. > > Signed-off-by: Michael Kelley <mhklinux@outlook.com> Acked-by: Thomas Gleixner <tglx@kernel.org> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] Drivers: hv: Move add_interrupt_randomness() to hypervisor callback sysvec 2026-04-02 20:24 ` [PATCH 2/2] Drivers: hv: Move add_interrupt_randomness() to hypervisor callback sysvec Michael Kelley 2026-04-02 21:07 ` Thomas Gleixner @ 2026-04-04 6:11 ` Wei Liu 2026-04-04 19:05 ` [tip: irq/core] " tip-bot2 for Michael Kelley 2 siblings, 0 replies; 7+ messages in thread From: Wei Liu @ 2026-04-04 6:11 UTC (permalink / raw) To: mhklinux Cc: kys, haiyangz, wei.liu, decui, longli, tglx, mingo, bp, dave.hansen, hpa, maz, bigeasy, x86, linux-kernel, linux-hyperv On Thu, Apr 02, 2026 at 01:24:00PM -0700, Michael Kelley wrote: > From: Michael Kelley <mhklinux@outlook.com> > > The Hyper-V ISRs, for normal guests and when running in the > hypervisor root patition, are calling add_interrupt_randomness() as a > primary source of entropy. The call is currently in the ISRs as a common > place to handle both x86/x64 and arm64. On x86/x64, hypervisor interrupts > come through a custom sysvec entry, and do not go through a generic > interrupt handler. On arm64, hypervisor interrupts come through an > emulated GICv3. GICv3 uses the generic handler handle_percpu_devid_irq(), > which does not do add_interrupt_randomness() -- unlike its counterpart > handle_percpu_irq(). But handle_percpu_devid_irq() is now updated to do > the add_interrupt_randomness(). So add_interrupt_randomness() is now > needed only in Hyper-V's x86/x64 custom sysvec path. > > Move add_interrupt_randomness() from the Hyper-V ISRs into the Hyper-V > x86/x64 custom sysvec path, matching the existing STIMER0 sysvec path. > With this change, add_interrupt_randomness() is no longer called from any > device drivers, which is appropriate. > > Signed-off-by: Michael Kelley <mhklinux@outlook.com> Acked-by: Wei Liu <wei.liu@kernel.org> ^ permalink raw reply [flat|nested] 7+ messages in thread
* [tip: irq/core] Drivers: hv: Move add_interrupt_randomness() to hypervisor callback sysvec 2026-04-02 20:24 ` [PATCH 2/2] Drivers: hv: Move add_interrupt_randomness() to hypervisor callback sysvec Michael Kelley 2026-04-02 21:07 ` Thomas Gleixner 2026-04-04 6:11 ` Wei Liu @ 2026-04-04 19:05 ` tip-bot2 for Michael Kelley 2 siblings, 0 replies; 7+ messages in thread From: tip-bot2 for Michael Kelley @ 2026-04-04 19:05 UTC (permalink / raw) To: linux-tip-commits Cc: Michael Kelley, Thomas Gleixner, Wei Liu, x86, linux-kernel, maz The following commit has been merged into the irq/core branch of tip: Commit-ID: e8be82c2d77ec1bb0148406e54b105028a83537e Gitweb: https://git.kernel.org/tip/e8be82c2d77ec1bb0148406e54b105028a83537e Author: Michael Kelley <mhklinux@outlook.com> AuthorDate: Thu, 02 Apr 2026 13:24:00 -07:00 Committer: Thomas Gleixner <tglx@kernel.org> CommitterDate: Sat, 04 Apr 2026 21:01:56 +02:00 Drivers: hv: Move add_interrupt_randomness() to hypervisor callback sysvec The Hyper-V ISRs, for normal guests and when running in the hypervisor root patition, are calling add_interrupt_randomness() as a primary source of entropy. The call is currently in the ISRs as a common place to handle both x86/x64 and arm64. On x86/x64, hypervisor interrupts come through a custom sysvec entry, and do not go through a generic interrupt handler. On arm64, hypervisor interrupts come through an emulated GICv3. GICv3 uses the generic handler handle_percpu_devid_irq(), which does not do add_interrupt_randomness() -- unlike its counterpart handle_percpu_irq(). But handle_percpu_devid_irq() is now updated to do the add_interrupt_randomness(). So add_interrupt_randomness() is now needed only in Hyper-V's x86/x64 custom sysvec path. Move add_interrupt_randomness() from the Hyper-V ISRs into the Hyper-V x86/x64 custom sysvec path, matching the existing STIMER0 sysvec path. With this change, add_interrupt_randomness() is no longer called from any device drivers, which is appropriate. Signed-off-by: Michael Kelley <mhklinux@outlook.com> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Acked-by: Wei Liu <wei.liu@kernel.org> Link: https://patch.msgid.link/20260402202400.1707-3-mhklkml@zohomail.com --- arch/x86/kernel/cpu/mshyperv.c | 2 ++ drivers/hv/mshv_synic.c | 3 --- drivers/hv/vmbus_drv.c | 3 --- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index 9befdc5..a7dfc29 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -161,6 +161,8 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_hyperv_callback) if (vmbus_handler) vmbus_handler(); + add_interrupt_randomness(HYPERVISOR_CALLBACK_VECTOR); + if (ms_hyperv.hints & HV_DEPRECATING_AEOI_RECOMMENDED) apic_eoi(); diff --git a/drivers/hv/mshv_synic.c b/drivers/hv/mshv_synic.c index 43f1bcb..e2288a7 100644 --- a/drivers/hv/mshv_synic.c +++ b/drivers/hv/mshv_synic.c @@ -12,7 +12,6 @@ #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> @@ -445,8 +444,6 @@ void mshv_isr(void) mb(); if (msg->header.message_flags.msg_pending) hv_set_non_nested_msr(HV_MSR_EOM, 0); - - add_interrupt_randomness(mshv_sint_vector); } else { pr_warn_once("%s: unknown message type 0x%x\n", __func__, msg->header.message_type); diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index bc4fc19..e7ac79e 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -32,7 +32,6 @@ #include <linux/ptrace.h> #include <linux/sysfb.h> #include <linux/efi.h> -#include <linux/random.h> #include <linux/kernel.h> #include <linux/syscore_ops.h> #include <linux/dma-map-ops.h> @@ -1361,8 +1360,6 @@ static void __vmbus_isr(void) vmbus_message_sched(hv_cpu, hv_cpu->hyp_synic_message_page); vmbus_message_sched(hv_cpu, hv_cpu->para_synic_message_page); - - add_interrupt_randomness(vmbus_interrupt); } static DEFINE_PER_CPU(bool, vmbus_irq_pending); ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-04-04 19:05 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-04-02 20:23 [PATCH 0/2] genirq and Hyper-V: Clean up handling of add_interrupt_randomness() Michael Kelley 2026-04-02 20:23 ` [PATCH 1/2] genirq/chip: Do add_interrupt_randomness() in handle_percpu_devid_irq() Michael Kelley 2026-04-02 21:11 ` [tip: irq/core] genirq/chip: Invoke " tip-bot2 for Michael Kelley 2026-04-02 20:24 ` [PATCH 2/2] Drivers: hv: Move add_interrupt_randomness() to hypervisor callback sysvec Michael Kelley 2026-04-02 21:07 ` Thomas Gleixner 2026-04-04 6:11 ` Wei Liu 2026-04-04 19:05 ` [tip: irq/core] " tip-bot2 for Michael Kelley
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox