git: 32f7bddb443a - main - amd64: Don't probe MSR_IRPERF when running under bhyve

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 19 Oct 2026 15:29:31 UTC
The branch main has been updated by markj:

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

commit 32f7bddb443ad7ddc72fa65ab0eb3a3658703cc7
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-10-19 13:59:41 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-10-19 15:29:13 +0000

    amd64: Don't probe MSR_IRPERF when running under bhyve
    
    vmm doesn't implement it, and bhyve simply aborts.  I fixed this in
    commit c83e075d72f6, but it'll still be impossible to boot newer FreeBSD
    guests on older hosts without this workaround.
    
    Reviewed by:    adrian
    Fixes:          2272fac218a8 ("hwpmc: Add support for AMD-only IRPERF in hwpmc PERF class")
    Differential Revision:  https://reviews.freebsd.org/D60730
---
 sys/amd64/amd64/initcpu.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/amd64/amd64/initcpu.c b/sys/amd64/amd64/initcpu.c
index a690e3829e7a..6ca89f2b36d4 100644
--- a/sys/amd64/amd64/initcpu.c
+++ b/sys/amd64/amd64/initcpu.c
@@ -375,11 +375,15 @@ initializecpu(void)
 	 * returns inaccurate values. That case is handled entirely by the
 	 * family/model check above.
 	 *
+	 * Released versions of vmm erroneously advertise IRPERF support, so
+	 * ignore it when running under bhyve.
+	 *
 	 * This runs on every core (BSP and each AP) via initializecpu();
 	 * pmc_amd_initialize() later assumes IRPERF's enabled/disabled state
 	 * is consistent across all cores.
 	 */
 	if ((amd_extended_feature_extensions & AMDFEID_IRPERF) &&
+	    vm_guest != VM_GUEST_BHYVE &&
 	    ((CPUID_TO_FAMILY(cpu_id) > 0x17) ||
 	    (CPUID_TO_FAMILY(cpu_id) == 0x17 && CPUID_TO_MODEL(cpu_id) >= 0x30))) {
 		wrmsr(MSR_HWCR, rdmsr(MSR_HWCR) | HWCR_IRPERFEN);