From: Sean Christopherson <seanjc@google.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Tao Su <tao1.su@linux.intel.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Xiaoyao Li <xiaoyao.li@intel.com>
Subject: [PATCH v2 1/5] KVM: Open code kvm_set_memory_region() into its sole caller (ioctl() API)
Date: Fri, 10 Jan 2025 16:20:18 -0800 [thread overview]
Message-ID: <20250111002022.1230573-2-seanjc@google.com> (raw)
In-Reply-To: <20250111002022.1230573-1-seanjc@google.com>
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.
Cc: Tao Su <tao1.su@linux.intel.com>
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 401439bb21e3..7443de24b1d9 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -1192,8 +1192,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 de2c11dae231..eb3d0a385077 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2058,25 +2058,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
--
2.47.1.613.gc27f4b7a9f-goog
next prev parent reply other threads:[~2025-01-11 0:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-11 0:20 [PATCH v2 0/5] KVM: kvm_set_memory_region() cleanups Sean Christopherson
2025-01-11 0:20 ` Sean Christopherson [this message]
2025-01-11 0:20 ` [PATCH v2 2/5] KVM: Assert slots_lock is held when setting memory regions Sean Christopherson
2025-01-11 0:20 ` [PATCH v2 3/5] KVM: Add a dedicated API for setting KVM-internal memslots Sean Christopherson
2025-01-20 14:44 ` Christoph Schlameuss
2025-01-21 16:05 ` Sean Christopherson
2025-01-21 16:17 ` Claudio Imbrenda
2025-01-21 19:40 ` Christoph Schlameuss
2025-01-11 0:20 ` [PATCH v2 4/5] KVM: x86: Drop double-underscores from __kvm_set_memory_region() Sean Christopherson
2025-01-11 0:20 ` [PATCH v2 5/5] KVM: Disallow all flags for KVM-internal memslots Sean Christopherson
2025-01-13 11:56 ` [PATCH v2 0/5] KVM: kvm_set_memory_region() cleanups Claudio Imbrenda
2025-01-13 17:30 ` Christoph Schlameuss
2025-01-14 2:09 ` Xiaoyao Li
2025-01-15 2:58 ` Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250111002022.1230573-2-seanjc@google.com \
--to=seanjc@google.com \
--cc=borntraeger@de.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=tao1.su@linux.intel.com \
--cc=xiaoyao.li@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox