git: 4b1974e9db63 - main - vmm: Emulate CPUID leaf 1Fh for guests
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 19 Aug 2026 10:29:06 UTC
The branch main has been updated by ivy:
URL: https://cgit.FreeBSD.org/src/commit/?id=4b1974e9db63d6510406e4ef3e56c250edd2240a
commit 4b1974e9db63d6510406e4ef3e56c250edd2240a
Author: Jochen Neumeister <joneum@FreeBSD.org>
AuthorDate: 2026-08-19 10:07:03 +0000
Commit: Lexi Winter <ivy@FreeBSD.org>
CommitDate: 2026-08-19 10:28:33 +0000
vmm: Emulate CPUID leaf 1Fh for guests
On an Intel N150 host a guest started with sockets=1, cores=4,
threads=1 reports "1 package(s) x 2 core(s) x 2 hardware threads"
instead of four cores with one thread each, while the host itself
detects its topology correctly.
A FreeBSD guest picks the topology leaf in topo_probe_intel_0xb(),
sys/x86/x86/mp_x86.c, and since 6badb512a94d it prefers leaf 1Fh over
leaf 0Bh whenever cpu_high is 1Fh or higher. bhyve passes leaf 0
through unmodified, so the guest sees the maximum basic leaf of the
host, which is 1Fh or above on Alder Lake and newer, and takes that
path. x86_emulate_cpuid(), sys/amd64/vmm/x86.c, derives the topology
from vm_get_topology() for leaves 1, 4 and 0Bh, but has no case for
1Fh, so the request ends up in default_leaf and the host values are
returned verbatim. The guest therefore enumerates the topology of the
host: with an SMT shift of 1 in the host's leaf 1Fh and four vCPUs this
gives core_id_shift = 1 and pkg_id_shift = 2, which is exactly the
reported 2 cores x 2 threads. Hosts whose maximum basic leaf is below
1Fh are unaffected, as the request is clamped to cpu_high before the
switch statement.
Leaf 1Fh uses the same level encoding as leaf 0Bh for the SMT and the
core level, so handle both leaves in the same case. The module, tile
and die levels are not emulated and terminate the enumeration, exactly
as they already do for leaf 0Bh.
PR: 297475
MFC after: 1 week
Reported by: Richard Straka <fntms@pryse.net>
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D58885
---
sys/amd64/vmm/x86.c | 5 ++++-
sys/amd64/vmm/x86.h | 1 +
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/sys/amd64/vmm/x86.c b/sys/amd64/vmm/x86.c
index 4ac008499999..8d621192693f 100644
--- a/sys/amd64/vmm/x86.c
+++ b/sys/amd64/vmm/x86.c
@@ -493,8 +493,11 @@ x86_emulate_cpuid(struct vcpu *vcpu, uint64_t *rax, uint64_t *rbx,
break;
case CPUID_0000_000B:
+ case CPUID_0000_001F:
/*
- * Intel processor topology enumeration
+ * Intel processor topology enumeration. Leaf 1Fh
+ * is the V2 form of leaf 0Bh and uses the same
+ * encoding for the SMT and core levels.
*/
if (vmm_is_intel()) {
vm_get_topology(vm, &sockets, &cores, &threads,
diff --git a/sys/amd64/vmm/x86.h b/sys/amd64/vmm/x86.h
index 56364f4f5cb4..97e759847abb 100644
--- a/sys/amd64/vmm/x86.h
+++ b/sys/amd64/vmm/x86.h
@@ -42,6 +42,7 @@
#define CPUID_0000_000F (0xF)
#define CPUID_0000_0010 (0x10)
#define CPUID_0000_0015 (0x15)
+#define CPUID_0000_001F (0x1F)
#define CPUID_8000_0000 (0x80000000)
#define CPUID_8000_0001 (0x80000001)
#define CPUID_8000_0002 (0x80000002)