git: e4b8828947b1 - stable/13 - Hyper-V: vPCI: limit 64 cpus for msi/msix interrupt handling

From: Wei Hu <whu_at_FreeBSD.org>
Date: Tue, 12 Mar 2024 05:14:25 UTC
The branch stable/13 has been updated by whu:

URL: https://cgit.FreeBSD.org/src/commit/?id=e4b8828947b1135fba411f58cac123c85bb24093

commit e4b8828947b1135fba411f58cac123c85bb24093
Author:     Wei Hu <whu@FreeBSD.org>
AuthorDate: 2024-03-11 10:15:09 +0000
Commit:     Wei Hu <whu@FreeBSD.org>
CommitDate: 2024-03-12 05:04:59 +0000

    Hyper-V: vPCI: limit 64 cpus for msi/msix interrupt handling
    
    On older Hyper-V vPCI protocol version 1.1, only the first 64 cpus
    are able to handle msi/msix. This is true on FreeBSD 13.x and earlier
    releases. If MSI IRQ is assigned to cpu id greater than 63, it would
    lead to missing interrupts. Add check in set_interrupt_apic_ids() to
    only add first 64 cpus into the interrupt cpu set.
    
    Reported by:    NetApp
    Tested by:      NetApp
    Reviewed by:    kib
    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D44297
---
 sys/x86/x86/mp_x86.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c
index 1f4caf07f979..56cf7e426076 100644
--- a/sys/x86/x86/mp_x86.c
+++ b/sys/x86/x86/mp_x86.c
@@ -1184,6 +1184,13 @@ set_interrupt_apic_ids(void)
 		    !hyperthreading_intr_allowed)
 			continue;
 
+		/*
+		 * Currently Hyper-V only supports intr on first
+		 * 64 cpus.
+		 */
+		if (vm_guest == VM_GUEST_HV && i > 63)
+			continue;
+
 		intr_add_cpu(i);
 	}
 }