From nobody Fri Nov 06 15:57:29 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 4jLkMs1W3dz6ybMK for ; Fri, 06 Nov 2026 15:57:29 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jLkMs0vFFz4grf for ; Fri, 06 Nov 2026 15:57:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793980649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UHpzZzsVRrp2S99YfIQ+mpNtOQc5uMMC/5unvSoKxww=; b=TGpb3dBVzKySZ3XgQA3aBg7KdaaFBWpGLGNkDxzWh11Di9UUVA42qcum3AEDfzmwjR56fy U/mtham+Wv8ZMNdMNLyhSgDaEcZq2BXDtZXmg8WFUPcVbfq8rDp9vRgGtXs4OifQvIVSVi qmOH0RFZEDkQ8itjSPotFE40coo4UEg5q3X4Zx3VUuZb80QVWvaGbE8FDpJmsmaI/3aAs2 S6p9MmF1PuUaDpH4fxR/rCr/buChStihu9nKO491ePFNz2bkdUqBDmIAp2l1evBz4C7a4x sNuOAEFOtmhFTvvPtkrmXoqJJfNDYcqdA67hecBc7XGgxvNNFW6WAx2c9AISvA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793980649; b=uujCnra75+YmDZU3u3BcIcCWsDpmJkdsO8tmIbsBVJPCYYpqWRSCX5oFNl6Nth/3UCdSd2 nvHLSn70SAEbYzYxqHaaYcTwRiLugTAKSocfRsvf7V3p/LhY3cZM/574kHOuHJRkRj7mLt 7n27KvdCTAWHzO1wG3ZaZ/OqQY5X6/c3hLapyLiNYKRb2TtG2UG2dIFhTAJ/9Thgr3ZI2Q 5SJTXhg57PwiMJOMM4QCYRyiHsj1xBE8rsioDiLAsdAfnab4aSK7/11314iG1PYla1C/3c 3/KXzgv1sZi/LEP2f+dd/g0a/NX7gZgkwjTK7YltzAKahIaxCOQF8Qh/iyBX7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793980649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UHpzZzsVRrp2S99YfIQ+mpNtOQc5uMMC/5unvSoKxww=; b=HcWkFJa1wF/I/Cy5CkgNxL52u++WTDzk8A4qrmJozQHyX/85/1A4//4QEr8TZzPiag/KSK OaP3rsszGhekL1uHb19DYbsZteC4bCUJ7o7MqkX/wPLDawiZNPTW68ikOzxlmAffhrIaVJ xBX3YxH23Ibqly5qZqkqxNSbistOVhwk4+eGUfbDQMuhbnQYkluKEq4QjDhOPQJ7WafLQ8 jv/0sFLsEcqvg9LSZ3EOHDQdZza+8jyO+Jqrh/5+XpLSfTUjXelO2YpdlZbZCLELLNOkkc 7xuM+fJTehCsjGEvp6IQb2zalE9tsrqI69zitjBGbU1a8dA1MmojJ4Uy4K45Pg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jLkMs0FRqzkP3 for ; Fri, 06 Nov 2026 15:57:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 346f4 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 06 Nov 2026 15:57:29 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: 0efaebd5ab83 - main - hwpmc: Decline the AMD PerfMonV2 path when GLOBAL_CTL is absent List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository 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: christos X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0efaebd5ab83f5977f7f5a8f76321e77dee1fdb3 Auto-Submitted: auto-generated Date: Fri, 06 Nov 2026 15:57:29 +0000 Message-Id: <6aedf8e9.346f4.11ba2df4@gitrepo.freebsd.org> The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=0efaebd5ab83f5977f7f5a8f76321e77dee1fdb3 commit 0efaebd5ab83f5977f7f5a8f76321e77dee1fdb3 Author: Christos Margiolis AuthorDate: 2026-11-06 08:49:16 +0000 Commit: Christos Margiolis CommitDate: 2026-11-06 15:57:12 +0000 hwpmc: Decline the AMD PerfMonV2 path when GLOBAL_CTL is absent The v2 path writes AMD_PMC_GLOBAL_CTL whenever the PerfMonV2 CPUID bit is set. bhyve passes that bit through from the host but does not emulate the register, so loading hwpmc in a guest on a Family 19h or later host panics the kernel. amd_v2_hwcheck_cpu() already probes EVSEL MSRs, so probe GLOBAL_CTL there too, in order to reject the v2 path and fall back to the generic CPU class. Fixes: 9d3064010590 ("hwpmc_amd: add PerfMonV2 global-control path") Tested by: Osvaldo Janeri Filho MFC after: 1 week Sponsored by: The FreeBSD Foundation Reviewed by: mhorne, afscoelho@gmail.com Differential Revision: https://reviews.freebsd.org/D61133 --- sys/dev/hwpmc/hwpmc_amd.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_amd.c b/sys/dev/hwpmc/hwpmc_amd.c index f466fff4cfb3..e85a3af7cba8 100644 --- a/sys/dev/hwpmc/hwpmc_amd.c +++ b/sys/dev/hwpmc/hwpmc_amd.c @@ -1377,6 +1377,16 @@ amd_v2_hwcheck_cpu(void *arg) int error, i; state = arg; + + /* + * A buggy hypervisor can advertise the PerfMonV2 CPUID bit without + * implementing GLOBAL_CTL. + */ + if (rdmsr_safe(AMD_PMC_GLOBAL_CTL, ®) != 0) { + atomic_set_int(&state->avh_read_error, 1); + return; + } + for (i = 0; i < amd_core_npmcs; i++) { error = rdmsr_safe(amd_pmcdesc[i].pm_evsel, ®); if (error != 0) { @@ -1407,7 +1417,7 @@ amd_hwcheck(void) smp_rendezvous_cpus(all_cpus, smp_no_rendezvous_barrier, amd_v2_hwcheck_cpu, smp_no_rendezvous_barrier, &state); if (state.avh_read_error != 0) { - printf("hwpmc: AMD PerfMonV2 EVSEL read failed on one " + printf("hwpmc: AMD PerfMonV2 MSR read failed on one " "or more CPUs!\n"); return (-1); } @@ -1585,8 +1595,12 @@ pmc_amd_initialize(void) pmcs_per_umc = amd_umc_npmcs / popcntq(regs[2]); } - /* EAX bit 0 holds the PerfMonV2 flag. */ - if (EXTPERFMON_PERFMONV2(regs[0]) && family >= 0x19) + /* + * EAX bit 0 holds the PerfMonV2 flag. PerfMonV2 requires + * PerfCtrExtCore; reject inconsistent CPUID (e.g. bhyve). + */ + if (EXTPERFMON_PERFMONV2(regs[0]) && family >= 0x19 && + (amd_feature2 & AMDID2_PCXC) != 0) amd_perfmon_v2 = true; }