git: f86ba3eec596 - main - hwpmc: prevent IBS fetch from getting stuck

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Thu, 09 Apr 2026 16:35:30 UTC
The branch main has been updated by mhorne:

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

commit f86ba3eec5961c0217b5458663e0eae5bbad314e
Author:     Ali Mashtizadeh <ali@mashtizadeh.com>
AuthorDate: 2026-04-07 23:33:03 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2026-04-09 16:35:26 +0000

    hwpmc: prevent IBS fetch from getting stuck
    
    Both fetch and op IBS sampling have the same problem where we need to
    rewrite the control MSR to ensure sampling continues at the correct
    rate.  I also like this because it resets the counter reducing the
    chances that we collect a sample inside the NMI handler.
    
    Reported by:    Aalok Agarwal
    Reviewed by:    mhorne
    Sponsored by:   Netflix
    Fixes:  e51ef8ae490f ("hwpmc: Initial support for AMD IBS")
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/2130
---
 sys/dev/hwpmc/hwpmc_ibs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/dev/hwpmc/hwpmc_ibs.c b/sys/dev/hwpmc/hwpmc_ibs.c
index ec1afcb47666..a230288f157e 100644
--- a/sys/dev/hwpmc/hwpmc_ibs.c
+++ b/sys/dev/hwpmc/hwpmc_ibs.c
@@ -342,6 +342,8 @@ pmc_ibs_process_fetch(struct pmc *pm, struct trapframe *tf, uint64_t config)
 	}
 
 	pmc_process_interrupt_mp(PMC_HR, pm, tf, &mpd);
+
+	wrmsr(IBS_FETCH_CTL, pm->pm_md.pm_ibs.ibs_ctl | IBS_FETCH_CTL_ENABLE);
 }
 
 static void