Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Michael Kelley and committed by
Thomas Gleixner
e8be82c2 bad28e01

+2 -6
+2
arch/x86/kernel/cpu/mshyperv.c
··· 161 161 if (vmbus_handler) 162 162 vmbus_handler(); 163 163 164 + add_interrupt_randomness(HYPERVISOR_CALLBACK_VECTOR); 165 + 164 166 if (ms_hyperv.hints & HV_DEPRECATING_AEOI_RECOMMENDED) 165 167 apic_eoi(); 166 168
-3
drivers/hv/mshv_synic.c
··· 12 12 #include <linux/mm.h> 13 13 #include <linux/interrupt.h> 14 14 #include <linux/io.h> 15 - #include <linux/random.h> 16 15 #include <linux/cpuhotplug.h> 17 16 #include <linux/reboot.h> 18 17 #include <asm/mshyperv.h> ··· 444 445 mb(); 445 446 if (msg->header.message_flags.msg_pending) 446 447 hv_set_non_nested_msr(HV_MSR_EOM, 0); 447 - 448 - add_interrupt_randomness(mshv_sint_vector); 449 448 } else { 450 449 pr_warn_once("%s: unknown message type 0x%x\n", __func__, 451 450 msg->header.message_type);
-3
drivers/hv/vmbus_drv.c
··· 32 32 #include <linux/ptrace.h> 33 33 #include <linux/sysfb.h> 34 34 #include <linux/efi.h> 35 - #include <linux/random.h> 36 35 #include <linux/kernel.h> 37 36 #include <linux/syscore_ops.h> 38 37 #include <linux/dma-map-ops.h> ··· 1360 1361 1361 1362 vmbus_message_sched(hv_cpu, hv_cpu->hyp_synic_message_page); 1362 1363 vmbus_message_sched(hv_cpu, hv_cpu->para_synic_message_page); 1363 - 1364 - add_interrupt_randomness(vmbus_interrupt); 1365 1364 } 1366 1365 1367 1366 static DEFINE_PER_CPU(bool, vmbus_irq_pending);