From nobody Mon Sep 28 17:43:35 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 4htpZH6HZGz6cRRZ for ; Mon, 28 Sep 2026 17:43:35 +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 4htpZH5WDxz4mH0 for ; Mon, 28 Sep 2026 17:43:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1790617415; 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=E/09CYQhqQNu3UnS2Y6EnDk7GRsu4n4pCynAR3rUKNw=; b=TDjYxHZ2ecOBcPn7IAhFfqFwTL5Cdd6d3dJNxRcvxtbLsFsXadOBR8nSiHVb5bxsFB5jP4 RmuOw6WnzlHYHKaGYfU8f42RCvOUj5u5cltCfd/3HdfoP1uT6Vlmfqv9XrInezwhlpiqSJ 7hCw3tQEDSrrE4DRUcEcQd1e3YmrWZ3vy47nAoZrsASwoywI+EqdS+7oYrk9jkQ162zcPu VlzUCdnCb3oaJyUtDazzcthqMRyuqZ0Ff1Ua1YGJ366jpt3KRCGpwoB8lmSO68stuThBcr FihYg6gJewN39AR4zClZ2fJHsVuHEuq1ZiZIqFA2yWwWBwCDMTRYbMkmhKH0Qg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1790617415; b=X2biD6fK2sEAwb3cUCw9YW9JwMTxtImSKAgblQRvtTShKk8wjoCyd2OWoUKP+DCVUAiaH4 pwqEor2/vU3B1euxquWzT5+cD14w94rnwIWo1tPLySQdHcNxGej3qeoABsxlVS0Z3Sky4e 5If/CaqaMCUNoWrUoK9yATFBGBrJZdlEyPuYz3HaM77FiYGyfmonk5VdeZSXyJa2/QMKeN fudD02kO0MFiOXqMgHB3lhWjYMsTcbzpx4ElcrJFNaph51gxA8GHjY16wRC30/BprW+Vjd 2AUGr1o7r21bIBdDKfRgQb/a0sdTXcfJMJaKIxsxooP5ksX98glvOfD7k4V1yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1790617415; 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=E/09CYQhqQNu3UnS2Y6EnDk7GRsu4n4pCynAR3rUKNw=; b=LWCNZ85I9PeH1E1+YYqC2C6j1K9cdJd8uV6FFqvcLCz92CjiYqfug5GspyvBY0S5zlTlsn qiCu6cwBuvbO8b3opDrDAdD+i84ANmWAG68T8NoodEr/y6fr1gwxrV3q0qccCPyzMa71G0 55+5IGEIKassMHOGWLSLcu6tDStlnZJwNmRd4iIOyjCmkMekmXY2fP0ctxRF4cb1s+2nq8 OmDPyRd6hVDJMm84UkScckueGNB0SacNZBDSkK9Am4aE5MsbTU+8eyUAEg33VskySuRMiR A099qHKYfXfXohlR6UBH/gPXqQhXJRV6+siHmUUeqkDVXqUXBjRCS1fj/TQxVg== 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 4htpZH4ZDtzf7R for ; Mon, 28 Sep 2026 17:43:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 372da by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 28 Sep 2026 17:43:35 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Andre Silva From: Mitchell Horne Subject: git: 34b00ed041a4 - main - hwpmc: fix IBS fetch and op NMI handling 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: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 34b00ed041a49eecc85b9a91748145ada14d83c5 Auto-Submitted: auto-generated Date: Mon, 28 Sep 2026 17:43:35 +0000 Message-Id: <6abaa747.372da.153426f9@gitrepo.freebsd.org> The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=34b00ed041a49eecc85b9a91748145ada14d83c5 commit 34b00ed041a49eecc85b9a91748145ada14d83c5 Author: Andre Silva AuthorDate: 2026-09-28 17:39:56 +0000 Commit: Mitchell Horne CommitDate: 2026-09-28 17:40:14 +0000 hwpmc: fix IBS fetch and op NMI handling Service each IBS unit with a valid bit set when fetch and op share an NMI. Otherwise, op samples can be lost. Treat the extra NMI that follows as expected (skip it). Reviewed by: mhorne Fixes: e51ef8ae490f ("hwpmc: Initial support for AMD IBS") Differential Revision: https://reviews.freebsd.org/D60004 --- sys/dev/hwpmc/hwpmc_ibs.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_ibs.c b/sys/dev/hwpmc/hwpmc_ibs.c index 17c3495f6a79..9e4af386f8d8 100644 --- a/sys/dev/hwpmc/hwpmc_ibs.c +++ b/sys/dev/hwpmc/hwpmc_ibs.c @@ -97,6 +97,7 @@ SYSCTL_U64(_kern_hwpmc, OID_AUTO, ibs_op_ctl2_extra_mask, CTLFLAG_RDTUN, struct ibs_cpu { int pc_status; + int pc_nmi_credit; /* latched NMIs already serviced */ struct pmc_hw pc_ibspmcs[IBS_NPMCS]; }; static struct ibs_cpu **ibs_pcpu; @@ -702,24 +703,40 @@ pmc_ibs_intr(struct trapframe *tf) pac = ibs_pcpu[cpu]; + /* + * Fetch and op share an NMI. Both valid bits may be set on entry, + * so service each valid source or the skipped unit can stay frozen + * with no NMI pending to re-arm it. + */ config = rdmsr(IBS_FETCH_CTL); if ((config & IBS_FETCH_CTL_VALID) != 0) { pm = pac->pc_ibspmcs[IBS_PMC_FETCH].phw_pmc; - retval = 1; + retval++; pmc_ibs_process_fetch(pm, tf, config); } config = rdmsr(IBS_OP_CTL); - if ((retval == 0) && ((config & IBS_OP_CTL_VALID) != 0)) { + if ((config & IBS_OP_CTL_VALID) != 0) { pm = pac->pc_ibspmcs[IBS_PMC_OP].phw_pmc; - retval = 1; + retval++; pmc_ibs_process_op(pm, tf, config); } + /* + * When both units were serviced, the second unit's NMI may still be + * latched and will arrive with no valid bit set. Claim that one + * NMI so it is not reported as unknown. + */ + if (retval == 0 && pac->pc_nmi_credit != 0) + retval = 1; + pac->pc_nmi_credit = (retval == 2); + if (retval > 1) + retval = 1; + if (retval == 0) { // Lets check for a stray NMI when stopping if (atomic_load_int(&pac->pc_status) == IBS_CPU_STOPPING) {