[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2f21ab3ed17c9b2b2d4996bc04c65672b005d8a5.camel@redhat.com>
Date: Wed, 08 Jun 2022 11:46:56 +0300
From: Maxim Levitsky <mlevitsk@...hat.com>
To: Vitaly Kuznetsov <vkuznets@...hat.com>
Cc: Sean Christopherson <seanjc@...gle.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Michael Kelley <mikelley@...rosoft.com>,
Siddharth Chandrasekaran <sidcha@...zon.de>,
Yuan Yao <yuan.yao@...ux.intel.com>,
linux-hyperv@...r.kernel.org, linux-kernel@...r.kernel.org,
kvm@...r.kernel.org, Paolo Bonzini <pbonzini@...hat.com>
Subject: Re: [PATCH v6 03/38] KVM: x86: hyper-v: Introduce TLB flush fifo
On Wed, 2022-06-08 at 09:47 +0200, Vitaly Kuznetsov wrote:
> Maxim Levitsky <mlevitsk@...hat.com> writes:
>
> > On Mon, 2022-06-06 at 10:36 +0200, Vitaly Kuznetsov wrote:
> > > To allow flushing individual GVAs instead of always flushing the
> > > whole
> > > VPID a per-vCPU structure to pass the requests is needed. Use
> > > standard
> > > 'kfifo' to queue two types of entries: individual GVA (GFN + up to
> > > 4095
> > > following GFNs in the lower 12 bits) and 'flush all'.
> >
> > Honestly I still don't think I understand why we can't just
> > raise KVM_REQ_TLB_FLUSH_GUEST when the guest uses this interface
> > to flush everthing, and then we won't need to touch the ring
> > at all.
>
> The main reason is that we need to know what to flush: L1 or
> L2. E.g. for VMX, KVM_REQ_TLB_FLUSH_GUEST is basically
>
> vpid_sync_context(vmx_get_current_vpid(vcpu));
>
> which means that if the target vCPU transitions from L1 to L2 or vice
> versa before KVM_REQ_TLB_FLUSH_GUEST gets processed we will flush the
> wrong VPID. And actually the writer (the vCPU which processes the TLB
> flush hypercall) is not anyhow synchronized with the reader (the vCPU
> whose TLB needs to be flushed) here so we can't even know if the target
> vCPU is in guest more or not.
>
> With the newly added KVM_REQ_HV_TLB_FLUSH, we always look at the
> corresponding FIFO and process 'flush all' accordingly. In case the vCPU
> switches between modes, we always raise KVM_REQ_HV_TLB_FLUSH request to
> make sure we check. Note: we can't be raising KVM_REQ_TLB_FLUSH_GUEST
> instead as it always means 'full tlb flush' and we certainly don't want
> that.
>
OK, that makes sense! Let it be then.
Best regards,
Maxim Levitsky
Powered by blists - more mailing lists