On 2025-08-18 9:12 a.m., Peter Zijlstra wrote: > On Mon, Aug 18, 2025 at 08:25:34AM -0700, Sean Christopherson wrote: > >>> OK, so *IF* doing the VM-exit during PMI is sound, this is something >>> that needs a comment somewhere. >> >> I'm a bit lost here. Are you essentially asking if it's ok to take a VM-Exit >> while the guest is handling a PMI? If so, that _has_ to work, because there are >> myriad things that can/will trigger a VM-Exit at any point while the guest is >> active. > > Yes, that's what I'm asking. Why is this VM-exit during PMI nonsense not > subject to the same failures that mandates the mid/late PMI ACK. > > And yes, I realize this needs to work. But so far I'm not sure I > understand why that is a safe thing to do. > > Like I wrote, I suspect writing all the PMU MSRs serializes things > sufficiently, but if that is the case, that needs to be explicitly > mentioned. Because that also doesn't explain why we needs mid-ack > instead of late-ack on ADL e-cores for instance. The mid-ack and late-ack only require under some corner cases, e.g., two PMIs are triggered simultaneously with PEBS. Because the ucode of p-core and e-core handle the pending PEBS records and PMIs differently. For p-core, the ACK should be as close to EOM. Otherwise, the pending PMI will trigger a spurious PMI warning. For e-core, the uncode handles the pending PMI well. There is no spurious PMI. However, it impacts the update of the PEBS_DATA_CFG. The PEBS_DATA_CFG is global. If the ACK cannot be done before re-enabling counters, the stale PEBS_DATA_CFG will somehow be written into the next PEBS record of the pending PMI. It triggers the malformed PEBS record. For the upcoming arch PEBS, the data cfg is per-counter. The mid-ack workaround should not be required. > > Could it perhaps be that we don't let the guests do PEBS because DS > doesn't virtualize? And thus we don't have the malformed PEBS record? > Yes, I don't think it can impact the mediated PMU. The legacy PEBS for vPMU is not supported. Since the configuration is per-counter with the arch PEBS, the malformed PEBS record should not be triggered either. Thanks, Kan