From nobody Wed Aug 26 10:12:42 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hVL7H3qXWz6pplL for ; Wed, 26 Aug 2026 10:12:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hVL7H1lxGz42bK for ; Wed, 26 Aug 2026 10:12:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787739163; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kCywryX4ySPeF9zbZYbbsYpZ3XWdXuPsnsw0neEHtzo=; b=ECbO96A0cOw9128pv82GFpEZt0Zlv8j/zA63FIbwahTxhC/Erxck640+gmwzyAvQqkc+7X OOJhXT5+2oXtWEt5A7YarLR79styeJ9/zBiNn//LtnxPPHehvOp0b0meSx+ivivMoZbNjJ +AyqVjkDsViYaW1pm1Shf4godZqdO7KbCfMdzfXXKFPUOUrKUi7A9RF3sLv9Vhf9c2tftT snBud+zW9M4acp7S9MVsc6IofiFge9mxpynymi9sWUF9990Hsw4k2K2MTCI7UYC3n/gYoL /LBBd5mvLu04A0+6mnY2yWeIuOzhJWv3QJKe/Hg6VSI7GdplwxBfooknD02kCA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1787739163; a=rsa-sha256; cv=none; b=dtzeSYil82vDd4Ky77wHx0oEygqnhGBvB9Tu3YswLQz69ZZ3JwJjWZM/478d6vnYAKj6ar 6WAAXYNLrz4Dutza4X0/+hlpHj+T7BnUCcuQKD92iAdtYMtBfs5gFoVIOLGuF8Qc0Y+xcO L+JO9+57jfUhi6stktalucrVc2ZDBLNpLdZe/SBSTkDv7Xi5slggt+K20g3ZsmWMMsc3+T loEFSfCMD97vGNEeENpfrUeprbekLezaDLwuKKaE/K6bjq6xkg7GHz3hhAiOU9ZPMbNzrK OjDtsRwrFs+PI38cz74kPTBAhsX8r04HeqAQemXv2ACWcirnYACLRc8gnLiAng== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787739163; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kCywryX4ySPeF9zbZYbbsYpZ3XWdXuPsnsw0neEHtzo=; b=nnS9BWNa85QDfceIF0y9s7to5OMW+9zJgYSFAVhuCoHfqbpBUYHeDPjFEnuTIHHWhBxSrp +b9BN1tfDC9rW60xyjHjRSzJ99JmtzOairnRj5IKXhjM1ulsLHubQMISjXSIbJhabkqTCZ EnHWTJ6juHifDGju3vWs+jc1gmQOATTGsl4Rs2YQd8M6bm/MWM+5Oh3DL35QC01gAb8j+p Hb5x4lb6KnIeXzaYzc2jvzFGP8Vn6HnUwRn+9Wp5i8eR3vxmuqLQGxlRvjPgWX9da/loI/ D5rWO/Th0e8aXCqWwDU61/JPv77ythBRd5/wPBGHRFnPgIlvmncMceFPjlVmww== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hVL7H0Pp1zZVV for ; Wed, 26 Aug 2026 10:12:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 385c0 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 26 Aug 2026 10:12:42 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Jochen Neumeister From: Lexi Winter Subject: git: 8a4fcb694526 - stable/15 - vmm: Emulate CPUID leaf 1Fh for guests List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ivy X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 8a4fcb694526fdb64709e0382d92053a9d71e49a Auto-Submitted: auto-generated Date: Wed, 26 Aug 2026 10:12:42 +0000 Message-Id: <6a8ebc1a.385c0.b1bc468@gitrepo.freebsd.org> The branch stable/15 has been updated by ivy: URL: https://cgit.FreeBSD.org/src/commit/?id=8a4fcb694526fdb64709e0382d92053a9d71e49a commit 8a4fcb694526fdb64709e0382d92053a9d71e49a Author: Jochen Neumeister AuthorDate: 2026-08-19 10:07:03 +0000 Commit: Lexi Winter CommitDate: 2026-08-26 09:56:32 +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 Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D58885 (cherry picked from commit 4b1974e9db63d6510406e4ef3e56c250edd2240a) --- 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)