From f86ba3eec5961c0217b5458663e0eae5bbad314e Mon Sep 17 00:00:00 2001 From: Ali Mashtizadeh Date: Tue, 7 Apr 2026 16:33:03 -0700 Subject: [PATCH] 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 ec1afcb4766..a230288f157 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