Re: [PATCH] KVM: X86: reset and read st->preempted in atomic way

From: Sean Christopherson
Date: Mon Jun 07 2021 - 20:35:01 EST


Nit: the shortlog is somewhat inaccurate now, maybe just:

KVM: x86: Ensure PV TLB flush tracepoint reflects KVM behavior

or something along those lines. Not sure what the best wording is :-/

On Tue, Jun 01, 2021, Lai Jiangshan wrote:
> From: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx>
>
> In record_steal_time(), st->preempted is read twice, and
> trace_kvm_pv_tlb_flush() might output result inconsistent if
> kvm_vcpu_flush_tlb_guest() see a different st->preempted later.
>
> It is a very trivial problem and hardly has actual harm and can be
> avoided by reseting and reading st->preempted in atomic way via xchg().
>
> Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx>

I saw this quirk too, but couldn't quite bring myself to care enought to test a
patch :-)

Reviewed-by: Sean Christopherson <seanjc@xxxxxxxxxx>