The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=313a68ea20b48629f655cf38987f4a6ff822f1ab
commit 313a68ea20b48629f655cf38987f4a6ff822f1ab Author: David Woodhouse <d...@amazon.co.uk> AuthorDate: 2025-08-11 10:44:05 +0000 Commit: Colin Percival <cperc...@freebsd.org> CommitDate: 2025-08-13 20:31:15 +0000 bhyve: Add CPUID_BHYVE_FEATURES leaf This allows the hypervisor to advertise features to the guest. The first such feature is CPUID_BHYVE_EXT_DEST_ID which advertises that 15 bits of target APIC ID are available in MSI (and I/O APIC) interrupts, as documented in http://david.woodhou.se/ExtDestId.pdf This defines the guest ABI. The actual implementation will come in a subsequent commit. Reviewed by: kib Pull Request: https://github.com/freebsd/freebsd-src/pull/1797 Signed-off-by: David Woodhouse <d...@amazon.co.uk> --- sys/amd64/vmm/x86.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/sys/amd64/vmm/x86.c b/sys/amd64/vmm/x86.c index 366f1da9f850..9c2fdac11a81 100644 --- a/sys/amd64/vmm/x86.c +++ b/sys/amd64/vmm/x86.c @@ -48,7 +48,12 @@ SYSCTL_DECL(_hw_vmm); static SYSCTL_NODE(_hw_vmm, OID_AUTO, topology, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, NULL); -#define CPUID_VM_HIGH 0x40000000 +#define CPUID_VM_SIGNATURE 0x40000000 +#define CPUID_BHYVE_FEATURES 0x40000001 +#define CPUID_VM_HIGH CPUID_BHYVE_FEATURES + +/* Features advertised in CPUID_BHYVE_FEATURES %eax */ +#define CPUID_BHYVE_FEAT_EXT_DEST_ID (1UL << 0) /* MSI Extended Dest ID */ static const char bhyve_id[12] = "bhyve bhyve "; @@ -100,7 +105,7 @@ x86_emulate_cpuid(struct vcpu *vcpu, uint64_t *rax, uint64_t *rbx, if (cpu_exthigh != 0 && func >= 0x80000000) { if (func > cpu_exthigh) func = cpu_exthigh; - } else if (func >= 0x40000000) { + } else if (func >= CPUID_VM_SIGNATURE) { if (func > CPUID_VM_HIGH) func = CPUID_VM_HIGH; } else if (func > cpu_high) { @@ -601,13 +606,20 @@ x86_emulate_cpuid(struct vcpu *vcpu, uint64_t *rax, uint64_t *rbx, regs[3] = 0; break; - case 0x40000000: + case CPUID_VM_SIGNATURE: regs[0] = CPUID_VM_HIGH; bcopy(bhyve_id, ®s[1], 4); bcopy(bhyve_id + 4, ®s[2], 4); bcopy(bhyve_id + 8, ®s[3], 4); break; + case CPUID_BHYVE_FEATURES: + regs[0] = 0; /* No features to advertise yet */ + regs[1] = 0; + regs[2] = 0; + regs[3] = 0; + break; + default: default_leaf: /*