Message ID | 20240802205003.353672-2-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:58PM -0700, Sean Christopherson wrote: > Open code kvm_set_memory_region() into its sole caller in preparation for > adding a dedicated API for setting internal memslots. > > Oppurtunistically use the fancy new guard(mutex) to avoid a local 'r' > variable. > > Signed-off-by: Sean Christopherson <seanjc@google.com> > --- > include/linux/kvm_host.h | 2 -- > virt/kvm/kvm_main.c | 15 ++------------- > 2 files changed, 2 insertions(+), 15 deletions(-) > > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > index 689e8be873a7..b341d00aae37 100644 > --- a/include/linux/kvm_host.h > +++ b/include/linux/kvm_host.h > @@ -1179,8 +1179,6 @@ enum kvm_mr_change { > KVM_MR_FLAGS_ONLY, > }; > > -int kvm_set_memory_region(struct kvm *kvm, > - const struct kvm_userspace_memory_region2 *mem); > int __kvm_set_memory_region(struct kvm *kvm, > const struct kvm_userspace_memory_region2 *mem); > void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot); > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index d0788d0a72cc..0557d663b69b 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -2105,25 +2105,14 @@ int __kvm_set_memory_region(struct kvm *kvm, > } > EXPORT_SYMBOL_GPL(__kvm_set_memory_region); > > -int kvm_set_memory_region(struct kvm *kvm, > - const struct kvm_userspace_memory_region2 *mem) > -{ > - int r; > - > - mutex_lock(&kvm->slots_lock); > - r = __kvm_set_memory_region(kvm, mem); > - mutex_unlock(&kvm->slots_lock); > - return r; > -} > -EXPORT_SYMBOL_GPL(kvm_set_memory_region); > - > static int kvm_vm_ioctl_set_memory_region(struct kvm *kvm, > struct kvm_userspace_memory_region2 *mem) > { > if ((u16)mem->slot >= KVM_USER_MEM_SLOTS) > return -EINVAL; > > - return kvm_set_memory_region(kvm, mem); > + guard(mutex)(&kvm->slots_lock); > + return __kvm_set_memory_region(kvm, mem); ^^ Two spaces are introduced here. > } > > #ifndef CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT > -- > 2.46.0.rc2.264.g509ed76dc8-goog > >
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 689e8be873a7..b341d00aae37 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1179,8 +1179,6 @@ enum kvm_mr_change { KVM_MR_FLAGS_ONLY, }; -int kvm_set_memory_region(struct kvm *kvm, - const struct kvm_userspace_memory_region2 *mem); int __kvm_set_memory_region(struct kvm *kvm, const struct kvm_userspace_memory_region2 *mem); void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot); diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index d0788d0a72cc..0557d663b69b 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2105,25 +2105,14 @@ int __kvm_set_memory_region(struct kvm *kvm, } EXPORT_SYMBOL_GPL(__kvm_set_memory_region); -int kvm_set_memory_region(struct kvm *kvm, - const struct kvm_userspace_memory_region2 *mem) -{ - int r; - - mutex_lock(&kvm->slots_lock); - r = __kvm_set_memory_region(kvm, mem); - mutex_unlock(&kvm->slots_lock); - return r; -} -EXPORT_SYMBOL_GPL(kvm_set_memory_region); - static int kvm_vm_ioctl_set_memory_region(struct kvm *kvm, struct kvm_userspace_memory_region2 *mem) { if ((u16)mem->slot >= KVM_USER_MEM_SLOTS) return -EINVAL; - return kvm_set_memory_region(kvm, mem); + guard(mutex)(&kvm->slots_lock); + return __kvm_set_memory_region(kvm, mem); } #ifndef CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT
Open code kvm_set_memory_region() into its sole caller in preparation for adding a dedicated API for setting internal memslots. Oppurtunistically use the fancy new guard(mutex) to avoid a local 'r' variable. Signed-off-by: Sean Christopherson <seanjc@google.com> --- include/linux/kvm_host.h | 2 -- virt/kvm/kvm_main.c | 15 ++------------- 2 files changed, 2 insertions(+), 15 deletions(-)