Page MenuHomeFreeBSD

cpuctl, x86: claim IBS NMIs orphaned by control MSR writes
AcceptedPublic

Authored by ojanerif_amd.com on Fri, Oct 16, 11:56 AM.
Tags
None
Referenced Files
F176322202: D60765.diff
Sat, Oct 17, 10:08 PM
Unknown Object (File)
Sat, Oct 17, 12:59 AM
Unknown Object (File)
Sat, Oct 17, 12:07 AM
Unknown Object (File)
Fri, Oct 16, 11:51 PM
Unknown Object (File)
Fri, Oct 16, 10:00 PM
Unknown Object (File)
Fri, Oct 16, 9:00 PM
Unknown Object (File)
Fri, Oct 16, 1:54 PM
Unknown Object (File)
Fri, Oct 16, 1:52 PM
Subscribers

Details

Summary

A cpuctl(4) write that stops or reprograms IBS can clear the valid bit
of a sample whose NMI is already raised. hwpmc then declines the NMI,
no other handler claims it, and with the default machdep.panic_on_nmi
the system panics.

Have nmi_handle_intr() claim, after all handlers declined it, one NMI
per cpuctl write to an IBS control MSR. Claiming last, rather than
from a cpuctl NMI handler, cannot take an NMI away from hwpmc.

cpuctl.ko now needs the new kernel symbols; an MFC has to update both.

Reproduced on an EPYC 9654 by toggling IBS op through /dev/cpuctlN:
about one unclaimed NMI per 2000 toggles.

MFC after: 2 weeks
Sponsored by: AMD
Signed-off-by: Osvaldo Janeri Filho <ojanerif@amd.com>

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

This is not a question to state any objections against the patch, it is a sincere curiosity. Also I hope that you would be not offended for me mentioning Intel while asking it.

Intel has added NMI source reporting, which in theory should allow to identify the source of the NMI. It requires FRED, and as I know Zen 6 supports FRED (am I mistaken)? Does AMD support NMI source reporting, and if yes, could this patch be enhanced to determine the exact cause of NMI? In particular, other cause of NMI would not make IBS NMI 'slipped'?

No offense taken, it is a good question.

Zen 6 does not implement NMI-source reporting, so the patch has to infer the source. It is also needed for the parts without FRED, where this was reproduced.

On other NMIs: the claim is used only after every handler declined the NMI, so an NMI claimed by hwpmc or another handler does not consume it. If the orphaned IBS NMI is merged with one that a handler claims, it is absorbed and the claim stays unused. An unrelated NMI that nobody claims, merged with the IBS NMI or arriving during the write or within 20us after it, would be dropped instead of reaching the unknown NMI path. That needs an otherwise fatal NMI to coincide with a privileged cpuctl write to an IBS MSR, and it is limited to one NMI per write; machdep.ibs_ctl_write_nmis counts the claims.

This revision is now accepted and ready to land.Fri, Oct 16, 1:40 PM