aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Percival <cperciva@FreeBSD.org>2026-02-22 04:09:01 +0000
committerColin Percival <cperciva@FreeBSD.org>2026-03-28 05:54:59 +0000
commit7b6be0014a4eb81943491122bae70914b7fd82b6 (patch)
treedd1d6998bbd2525195730a760dc5ea1720417bdf
parent8dd9a0d52175fbc5dafed851fb95a289a94fb6cd (diff)
Hyper-V: Detect Extended Destination ID support
Hyper-V advertises support for the Extended Destination ID standard via bit 2 of the value returned in the EAX register when the hypervisor stack properties are queried via CPUID. This is based on a commit to the Linux kernel, as there does not seem to be any other documentation of this feature. Reviewed by: Souradeep Chakrabarti MFC after: 3 weeks Sponsored by: Amazon Differential Revision: https://reviews.freebsd.org/D55432
-rw-r--r--sys/dev/hyperv/vmbus/x86/hyperv_reg.h6
-rw-r--r--sys/x86/x86/local_apic.c9
2 files changed, 15 insertions, 0 deletions
diff --git a/sys/dev/hyperv/vmbus/x86/hyperv_reg.h b/sys/dev/hyperv/vmbus/x86/hyperv_reg.h
index 0597a1fea953..e7560d00f25e 100644
--- a/sys/dev/hyperv/vmbus/x86/hyperv_reg.h
+++ b/sys/dev/hyperv/vmbus/x86/hyperv_reg.h
@@ -45,4 +45,10 @@
#define CPUID_LEAF_HV_IDENTITY 0x40000002
#define CPUID_LEAF_HV_FEATURES 0x40000003
#define CPUID_LEAF_HV_RECOMMENDS 0x40000004
+
+#define CPUID_LEAF_HV_STACK_INTERFACE 0x40000081
+#define HYPERV_STACK_INTERFACE_EAX_SIG 0x31235356 /* "VS#1" */
+#define CPUID_LEAF_HV_STACK_PROPERTIES 0x40000082
+#define HYPERV_PROPERTIES_EXT_DEST_ID 0x00000004
+
#endif /* !_HYPERV_REG_H_ */
diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c
index 20f095a13574..cd5e4d474080 100644
--- a/sys/x86/x86/local_apic.c
+++ b/sys/x86/x86/local_apic.c
@@ -75,6 +75,7 @@
#include <x86/kvm.h>
#include <contrib/xen/arch-x86/cpuid.h>
#include <x86/bhyve.h>
+#include <dev/hyperv/vmbus/x86/hyperv_reg.h>
#ifdef DDB
#include <sys/interrupt.h>
@@ -2107,6 +2108,14 @@ detect_extended_dest_id(void)
if (regs[0] & XEN_HVM_CPUID_EXT_DEST_ID)
apic_ext_dest_id = 1;
break;
+ case VM_GUEST_HV:
+ cpuid_count(CPUID_LEAF_HV_STACK_INTERFACE, 0, regs);
+ if (regs[0] != HYPERV_STACK_INTERFACE_EAX_SIG)
+ break;
+ cpuid_count(CPUID_LEAF_HV_STACK_PROPERTIES, 0, regs);
+ if (regs[0] & HYPERV_PROPERTIES_EXT_DEST_ID)
+ apic_ext_dest_id = 1;
+ break;
case VM_GUEST_KVM:
kvm_cpuid_get_features(regs);
if (regs[0] & KVM_FEATURE_MSI_EXT_DEST_ID)