[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zhg5cFPL9GgujFKV@google.com>
Date: Thu, 11 Apr 2024 12:26:40 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: Xiong Zhang <xiong.y.zhang@...ux.intel.com>
Cc: pbonzini@...hat.com, peterz@...radead.org, mizhang@...gle.com,
kan.liang@...el.com, zhenyuw@...ux.intel.com, dapeng1.mi@...ux.intel.com,
jmattson@...gle.com, kvm@...r.kernel.org, linux-perf-users@...r.kernel.org,
linux-kernel@...r.kernel.org, zhiyuan.lv@...el.com, eranian@...gle.com,
irogers@...gle.com, samantha.alt@...el.com, like.xu.linux@...il.com,
chao.gao@...el.com
Subject: Re: [RFC PATCH 09/41] perf: core/x86: Forbid PMI handler when guest
own PMU
On Fri, Jan 26, 2024, Xiong Zhang wrote:
> + /*
> + * When PMU is pass-through into guest, this handler should be forbidden from
> + * running, the reasons are:
> + * 1. After perf_guest_switch_to_kvm_pmi_vector() is called, and before cpu
> + * enter into non-root mode, NMI could happen, but x86_pmu_handle_irq()
> + * restore PMU to use NMI vector, which destroy KVM PMI vector setting.
> + * 2. When VM is running, host NMI other than PMI causes VM exit, KVM will
> + * call host NMI handler (vmx_vcpu_enter_exit()) first before KVM save
> + * guest PMU context (kvm_pmu_save_pmu_context()), as x86_pmu_handle_irq()
> + * clear global_status MSR which has guest status now, then this destroy
> + * guest PMU status.
> + * 3. After VM exit, but before KVM save guest PMU context, host NMI other
> + * than PMI could happen, x86_pmu_handle_irq() clear global_status MSR
> + * which has guest status now, then this destroy guest PMU status.
> + */
> + if (perf_is_in_guest_passthrough())
Maybe a name more along the lines of:
if (perf_is_guest_context_loaded())
because that makes it more obvious that the NMI _can't_ belong to the host PMU.
For that matter, I would also rename __perf_force_exclude_guest to
perf_guest_context_loaded (or "active" if that's better). The boolean tracks
the state (guest vs. host context loaded/active), where as forcing perf events
to exclude_guest is an action based on that state.
Powered by blists - more mailing lists