Re: [PATCH v2] x86/perf: Use RET0 as default for guest_get_msrs to handle "no PMU" case

Sean Christopherson
2021-03-10T18:17:02Z

On Wed, Mar 10, 2021, Peter Zijlstra wrote:
> On Tue, Mar 09, 2021 at 09:10:19AM -0800, Sean Christopherson wrote:
>
> > @@ -2024,9 +2021,6 @@ static int __init init_hw_perf_events(void)
> > if (!x86_pmu.read)
> > x86_pmu.read = _x86_pmu_read;
> >
> > - if (!x86_pmu.guest_get_msrs)
> > - x86_pmu.guest_get_msrs = perf_guest_get_msrs_nop;
>
> I suspect I might've been over eager here and we're now in trouble when
> *_pmu_init() clears x86_pmu.guest_get_msrs (like for instance on AMD).
>
> When that happens we need to restore __static_call_return0, otherwise
> the following static_call_update() will patch in a NOP and RAX will be
> garbage again.
>
> So I've taken the liberty to update the patch as below.

Doh, I managed to forget about that between v1 and v2, too. Thanks much!