[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZBwS0DNOwMf7OVmV@yzhao56-desk.sh.intel.com>
Date: Thu, 23 Mar 2023 16:50:24 +0800
From: Yan Zhao <yan.y.zhao@...el.com>
To: Sean Christopherson <seanjc@...gle.com>, <kvm@...r.kernel.org>,
<intel-gfx@...ts.freedesktop.org>, <linux-kernel@...r.kernel.org>,
"Zhenyu Wang" <zhenyuw@...ux.intel.com>,
Ben Gardon <bgardon@...gle.com>,
"Paolo Bonzini" <pbonzini@...hat.com>,
<intel-gvt-dev@...ts.freedesktop.org>,
"Zhi Wang" <zhi.a.wang@...el.com>
Subject: Re: [PATCH v2 25/27] KVM: x86/mmu: Drop @slot param from
exported/external page-track APIs
On Fri, Mar 17, 2023 at 04:28:56PM +0800, Yan Zhao wrote:
> On Fri, Mar 10, 2023 at 04:22:56PM -0800, Sean Christopherson wrote:
> ...
> > +int kvm_write_track_add_gfn(struct kvm *kvm, gfn_t gfn)
> > +{
> > + struct kvm_memory_slot *slot;
> > + int idx;
> > +
> > + idx = srcu_read_lock(&kvm->srcu);
> > +
> > + slot = gfn_to_memslot(kvm, gfn);
> > + if (!slot) {
> > + srcu_read_unlock(&kvm->srcu, idx);
> > + return -EINVAL;
> > + }
> > +
> Also fail if slot->flags & KVM_MEMSLOT_INVALID is true?
> There should exist a window for external users to see an invalid slot
> when a slot is about to get deleted/moved.
> (It happens before MOVE is rejected in kvm_arch_prepare_memory_region()).
Or using
if (!kvm_is_visible_memslot(slot)) {
srcu_read_unlock(&kvm->srcu, idx);
return -EINVAL;
}
>
> > + write_lock(&kvm->mmu_lock);
> > + __kvm_write_track_add_gfn(kvm, slot, gfn);
> > + write_unlock(&kvm->mmu_lock);
> > +
> > + srcu_read_unlock(&kvm->srcu, idx);
> > +
> > + return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(kvm_write_track_add_gfn);
> > +
> > +/*
> > + * remove the guest page from the tracking pool which stops the interception
> > + * of corresponding access on that page.
> > + *
> > + * @kvm: the guest instance we are interested in.
> > + * @gfn: the guest page.
> > + */
> > +int kvm_write_track_remove_gfn(struct kvm *kvm, gfn_t gfn)
> > +{
> > + struct kvm_memory_slot *slot;
> > + int idx;
> > +
> > + idx = srcu_read_lock(&kvm->srcu);
> > +
> > + slot = gfn_to_memslot(kvm, gfn);
> > + if (!slot) {
> > + srcu_read_unlock(&kvm->srcu, idx);
> > + return -EINVAL;
> > + }
> > +
> Ditto.
>
> > + write_lock(&kvm->mmu_lock);
> > + __kvm_write_track_remove_gfn(kvm, slot, gfn);
> > + write_unlock(&kvm->mmu_lock);
> > +
> > + srcu_read_unlock(&kvm->srcu, idx);
> > +
> > + return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(kvm_write_track_remove_gfn);
>
Powered by blists - more mailing lists