Message ID | 20240802205003.353672-3-seanjc@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: kvm_set_memory_region() cleanups | expand |
On Fri, Aug 02, 2024 at 01:49:59PM -0700, Sean Christopherson wrote: > Add a proper lockdep assertion in __kvm_set_memory_region() instead of > relying on a function comment. Opportunistically delete the entire > function comment as the API doesn't allocate memory or select a gfn, > and the "mostly for framebuffers" comment hasn't been true for a very long > time. > > Signed-off-by: Sean Christopherson <seanjc@google.com> > --- > virt/kvm/kvm_main.c | 10 ++-------- > 1 file changed, 2 insertions(+), 8 deletions(-) > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 0557d663b69b..f202bdbfca9e 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -1973,14 +1973,6 @@ static bool kvm_check_memslot_overlap(struct kvm_memslots *slots, int id, > return false; > } > > -/* > - * Allocate some memory and give it an address in the guest physical address > - * space. > - * > - * Discontiguous memory is allowed, mostly for framebuffers. > - * > - * Must be called holding kvm->slots_lock for write. > - */ > int __kvm_set_memory_region(struct kvm *kvm, > const struct kvm_userspace_memory_region2 *mem) > { > @@ -1992,6 +1984,8 @@ int __kvm_set_memory_region(struct kvm *kvm, > int as_id, id; > int r; > > + lockdep_assert_held(&kvm->slots_lock); How about adding this lockdep assertion in __x86_set_memory_region() to replace this comment "/* Called with kvm->slots_lock held. */" as well? > + > r = check_memory_region_flags(kvm, mem); > if (r) > return r; > -- > 2.46.0.rc2.264.g509ed76dc8-goog > >
On Mon, Aug 05, 2024, Tao Su wrote: > On Fri, Aug 02, 2024 at 01:49:59PM -0700, Sean Christopherson wrote: > > Add a proper lockdep assertion in __kvm_set_memory_region() instead of > > relying on a function comment. Opportunistically delete the entire > > function comment as the API doesn't allocate memory or select a gfn, > > and the "mostly for framebuffers" comment hasn't been true for a very long > > time. > > > > Signed-off-by: Sean Christopherson <seanjc@google.com> > > --- > > virt/kvm/kvm_main.c | 10 ++-------- > > 1 file changed, 2 insertions(+), 8 deletions(-) > > > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > > index 0557d663b69b..f202bdbfca9e 100644 > > --- a/virt/kvm/kvm_main.c > > +++ b/virt/kvm/kvm_main.c > > @@ -1973,14 +1973,6 @@ static bool kvm_check_memslot_overlap(struct kvm_memslots *slots, int id, > > return false; > > } > > > > -/* > > - * Allocate some memory and give it an address in the guest physical address > > - * space. > > - * > > - * Discontiguous memory is allowed, mostly for framebuffers. > > - * > > - * Must be called holding kvm->slots_lock for write. > > - */ > > int __kvm_set_memory_region(struct kvm *kvm, > > const struct kvm_userspace_memory_region2 *mem) > > { > > @@ -1992,6 +1984,8 @@ int __kvm_set_memory_region(struct kvm *kvm, > > int as_id, id; > > int r; > > > > + lockdep_assert_held(&kvm->slots_lock); > > How about adding this lockdep assertion in __x86_set_memory_region() to replace > this comment "/* Called with kvm->slots_lock held. */" as well? Ya, will do, I didn't see that comment. Thanks!
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 0557d663b69b..f202bdbfca9e 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1973,14 +1973,6 @@ static bool kvm_check_memslot_overlap(struct kvm_memslots *slots, int id, return false; } -/* - * Allocate some memory and give it an address in the guest physical address - * space. - * - * Discontiguous memory is allowed, mostly for framebuffers. - * - * Must be called holding kvm->slots_lock for write. - */ int __kvm_set_memory_region(struct kvm *kvm, const struct kvm_userspace_memory_region2 *mem) { @@ -1992,6 +1984,8 @@ int __kvm_set_memory_region(struct kvm *kvm, int as_id, id; int r; + lockdep_assert_held(&kvm->slots_lock); + r = check_memory_region_flags(kvm, mem); if (r) return r;
Add a proper lockdep assertion in __kvm_set_memory_region() instead of relying on a function comment. Opportunistically delete the entire function comment as the API doesn't allocate memory or select a gfn, and the "mostly for framebuffers" comment hasn't been true for a very long time. Signed-off-by: Sean Christopherson <seanjc@google.com> --- virt/kvm/kvm_main.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)