From nobody Thu Apr 9 16:35:29 2026 X-Original-To: dev-commits-src-main@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 4fs5C562Gmz6YBxG for ; Thu, 09 Apr 2026 16:35: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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fs5C553Qvz4HXx for ; Thu, 09 Apr 2026 16:35:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1775752529; 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=rTSxvH3jiisS8woZw0zWwWwJ3fry2mxqOZhmf8hFhg8=; b=MqqzVcNO2tP0x/5ECR6/CeilqOgxfztl1W9pUSaNQnjW4npHPaH76Ud75YNisabnXbjYIb v7bIo/9CtEJhURbcE/27FNPKLtvZ/1F75popZBKlQ9sJHTIElh1ox/gXXz6SVALhGfvf8h 8BQPjFtplNGXfwV9F1WAliUsm2ACg1hbNXxeku1TJSR9qCb2JdQANiqPGVXPUcePhiUij+ oXi5rnAmRr5U0vf5ReqAId0OgA8UQS9+oQJGhckJ8Wy9QeFAPzma//JMrXNie5z5ODR9Vd Q+MVp6sAO/coK2FQv9nh6XHRpbU6PEwnj2BgI+sol7SYfa7ZFb+vHCwFeMPQaA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1775752529; a=rsa-sha256; cv=none; b=OIcLQWbDe2y/dSmeNOx/z/ymNWzeOHO8PmuJRqupIIMfUXRdCKGhK2Nl4/pK9b0uSQIOvm Q69gJCpsUkMaPXP8+bGqxG5TS6CGlw2cpz/MuhcmsLSMH5ce2NDCCWn8itR+AwRdbyIfnx NK+x3x/wj/7K5/ElD0FzO4yST2kohtFYhAxfEXLawuGfi7zkPPqaAMxXp6t7gizABUrOgV /3zskhLs9y0vvseuxIsfJ9/fqmGfs+wwVf2Q7bNjuv3ps4+0XmqAJRjohySCakKv3ZUPAJ heVs9EaVXU6ogpei31yZ+XgLDgtfxa7+OCVVxfqPnznN5cU4zLCqtMckdX/ycA== 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=1775752529; 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=rTSxvH3jiisS8woZw0zWwWwJ3fry2mxqOZhmf8hFhg8=; b=U1pGEMh6CrADcVJTGOFNQmWk/Z2iAOWijc4uTkeR8BoIw6GmUaIMU+Pcw5O7YTnkL2g/CC B8pxZrvN3UxcjhalQRfwvDk4M5K372mWkvUnz5xmtGqWzoUl35hE74t648u4luaR5KELAf 4RRekxJB/YkPvzk0y7nhFTFUJdmVcJ3Q+oslu9y5uO5sRE+ovZ2ujbE3NAltl7kUdPfnh6 Uo3WV58FkcXrzBnS/03Rv3iG0HZwHyQCOK/2LcCDI+qDcgXanKoYjgyXN7MjIejTgfHiej ngn7Z0vOQIyKmHPVziUFLxrNU3p8wVPAPTsHc9o6zVqr40RdcKmRaEMd8mbnVw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fs5C54Cpbz1Kql for ; Thu, 09 Apr 2026 16:35:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 249d1 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 09 Apr 2026 16:35:29 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Ali Mashtizadeh From: Mitchell Horne Subject: git: 7a1aaca06c33 - main - hwpmc: Fix bug when stopping ibs-op List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7a1aaca06c3384f90202dafa60440081d67d00fd Auto-Submitted: auto-generated Date: Thu, 09 Apr 2026 16:35:29 +0000 Message-Id: <69d7d551.249d1.779d8ba0@gitrepo.freebsd.org> The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=7a1aaca06c3384f90202dafa60440081d67d00fd commit 7a1aaca06c3384f90202dafa60440081d67d00fd Author: Ali Mashtizadeh AuthorDate: 2026-04-04 21:30:03 +0000 Commit: Mitchell Horne CommitDate: 2026-04-09 16:35:26 +0000 hwpmc: Fix bug when stopping ibs-op In ibs_stop_pmc I accidently cleared the fetch max count value rather than the op max count value, when stopping the op counter. This mitigates a bug in early pre-zen processors, but breaks using both counters simultaneously. I also found that the max op count mask needs to be extended for recent zen processors. Reported by: Andre Fernando da Silva Reviewed by: mhorne Sponsored by: Netflix Fixes: e51ef8ae490f ("hwpmc: Initial support for AMD IBS") Pull Request: https://github.com/freebsd/freebsd-src/pull/2120 --- sys/dev/hwpmc/hwpmc_ibs.c | 4 ++-- sys/dev/hwpmc/hwpmc_ibs.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_ibs.c b/sys/dev/hwpmc/hwpmc_ibs.c index bfc135f06884..ec1afcb47666 100644 --- a/sys/dev/hwpmc/hwpmc_ibs.c +++ b/sys/dev/hwpmc/hwpmc_ibs.c @@ -270,7 +270,7 @@ ibs_stop_pmc(int cpu __diagused, int ri, struct pmc *pm) * Turn off the ENABLE bit, but unfortunately there are a few quirks * that generate excess NMIs. Workaround #420 in the Revision Guide * for AMD Family 10h Processors 41322 Rev. 3.92 March 2012. requires - * that we clear the count before clearing enable. + * that we clear the max count before clearing enable. * * Even after clearing the counter spurious NMIs are still possible so * we use a per-CPU atomic variable to notify the interrupt handler we @@ -290,7 +290,7 @@ ibs_stop_pmc(int cpu __diagused, int ri, struct pmc *pm) wrmsr(IBS_FETCH_CTL, config); break; case IBS_PMC_OP: - wrmsr(IBS_FETCH_CTL, config & ~IBS_FETCH_CTL_MAXCNTMASK); + wrmsr(IBS_OP_CTL, config & ~IBS_OP_CTL_MAXCNTMASK); DELAY(1); config &= ~IBS_OP_CTL_ENABLE; wrmsr(IBS_OP_CTL, config); diff --git a/sys/dev/hwpmc/hwpmc_ibs.h b/sys/dev/hwpmc/hwpmc_ibs.h index c66d54672543..1616a746ffef 100644 --- a/sys/dev/hwpmc/hwpmc_ibs.h +++ b/sys/dev/hwpmc/hwpmc_ibs.h @@ -112,7 +112,7 @@ #define IBS_OP_CTL_VALID (1ULL << 18) /* Valid */ #define IBS_OP_CTL_ENABLE (1ULL << 17) /* Enable */ #define IBS_OP_CTL_L3MISSONLY (1ULL << 16) /* L3 Miss Filtering */ -#define IBS_OP_CTL_MAXCNTMASK 0x0000FFFFULL +#define IBS_OP_CTL_MAXCNTMASK 0x07F0FFFFULL #define IBS_OP_CTL_LDLAT_TO_CTL(_c) ((((ldlat) >> 7) - 1) << 59) #define IBS_OP_INTERVAL_TO_CTL(_c) ((((_c) >> 4) & 0x0000FFFFULL) | ((_c) & 0x07F00000))