]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: Rename kvm_arch_vcpu_async_ioctl() to kvm_arch_vcpu_unlocked_ioctl()
authorSean Christopherson <seanjc@google.com>
Thu, 30 Oct 2025 20:09:25 +0000 (13:09 -0700)
committerSean Christopherson <seanjc@google.com>
Wed, 5 Nov 2025 19:03:11 +0000 (11:03 -0800)
Rename the "async" ioctl API to "unlocked" so that upcoming usage in x86's
TDX code doesn't result in a massive misnomer.  To avoid having to retry
SEAMCALLs, TDX needs to acquire kvm->lock *and* all vcpu->mutex locks, and
acquiring all of those locks after/inside the current vCPU's mutex is a
non-starter.  However, TDX also needs to acquire the vCPU's mutex and load
the vCPU, i.e. the handling is very much not async to the vCPU.

No functional change intended.

Acked-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Yan Zhao <yan.y.zhao@intel.com>
Tested-by: Yan Zhao <yan.y.zhao@intel.com>
Tested-by: Kai Huang <kai.huang@intel.com>
Link: https://patch.msgid.link/20251030200951.3402865-3-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/arm64/kvm/arm.c
arch/loongarch/kvm/vcpu.c
arch/mips/kvm/mips.c
arch/powerpc/kvm/powerpc.c
arch/riscv/kvm/vcpu.c
arch/s390/kvm/kvm-s390.c
arch/x86/kvm/x86.c
include/linux/kvm_host.h
virt/kvm/kvm_main.c

index ef5bf57f79b702dbd45e54258f6ebf2d276c7cba..cf23f6b07ec72beeabfa0ab4ec2b6820a308ea76 100644 (file)
@@ -1835,8 +1835,8 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
        return r;
 }
 
-long kvm_arch_vcpu_async_ioctl(struct file *filp, unsigned int ioctl,
-                              unsigned long arg)
+long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl,
+                                 unsigned long arg)
 {
        return -ENOIOCTLCMD;
 }
index 30e3b089a59665b4d709dedb31c49512decc2d70..9a5844e85fd316ba4c1e6d13ce5c5f5988fc2f3e 100644 (file)
@@ -1471,8 +1471,8 @@ int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq)
        return 0;
 }
 
-long kvm_arch_vcpu_async_ioctl(struct file *filp,
-                              unsigned int ioctl, unsigned long arg)
+long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl,
+                                 unsigned long arg)
 {
        void __user *argp = (void __user *)arg;
        struct kvm_vcpu *vcpu = filp->private_data;
index a75587018f447f65c5c4416612deaa88afae92af..b0fb92fda4d4235b3d51b5eb94aec25287d4e119 100644 (file)
@@ -895,8 +895,8 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
        return r;
 }
 
-long kvm_arch_vcpu_async_ioctl(struct file *filp, unsigned int ioctl,
-                              unsigned long arg)
+long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl,
+                                 unsigned long arg)
 {
        struct kvm_vcpu *vcpu = filp->private_data;
        void __user *argp = (void __user *)arg;
index 2ba057171ebe0c8f4f1775fc426d2cc559160735..9a89a6d98f97b35d411626f5280895d300f9ec28 100644 (file)
@@ -2028,8 +2028,8 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
        return -EINVAL;
 }
 
-long kvm_arch_vcpu_async_ioctl(struct file *filp,
-                              unsigned int ioctl, unsigned long arg)
+long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl,
+                                 unsigned long arg)
 {
        struct kvm_vcpu *vcpu = filp->private_data;
        void __user *argp = (void __user *)arg;
index bccb919ca6153f82c8bd4ebca5f0ca519fd2fa6c..a4bd6077eecc260f0cafd8e6c5a81efc909273cb 100644 (file)
@@ -238,8 +238,8 @@ vm_fault_t kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
        return VM_FAULT_SIGBUS;
 }
 
-long kvm_arch_vcpu_async_ioctl(struct file *filp,
-                              unsigned int ioctl, unsigned long arg)
+long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl,
+                                 unsigned long arg)
 {
        struct kvm_vcpu *vcpu = filp->private_data;
        void __user *argp = (void __user *)arg;
index 16ba04062854a99ab7d48ac427b690006ea8e7eb..8c4caa5f2fcd8297fc93fc6d21e17a3f95956db1 100644 (file)
@@ -5730,8 +5730,8 @@ static long kvm_s390_vcpu_memsida_op(struct kvm_vcpu *vcpu,
        return r;
 }
 
-long kvm_arch_vcpu_async_ioctl(struct file *filp,
-                              unsigned int ioctl, unsigned long arg)
+long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl,
+                                 unsigned long arg)
 {
        struct kvm_vcpu *vcpu = filp->private_data;
        void __user *argp = (void __user *)arg;
index ca5ba2caf314ffc45fccb1f16af127febacbe390..b85cb213a3369eb0eb77b3f223bde823eb6b21ba 100644 (file)
@@ -7240,8 +7240,8 @@ static int kvm_vm_ioctl_set_clock(struct kvm *kvm, void __user *argp)
        return 0;
 }
 
-long kvm_arch_vcpu_async_ioctl(struct file *filp, unsigned int ioctl,
-                              unsigned long arg)
+long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl,
+                                 unsigned long arg)
 {
        return -ENOIOCTLCMD;
 }
index 7186b2ae4b570aabca5dbc4bb127947568ad95fd..d93f75b05ae2272c1ba8e10dde8c34b38f0e2eb6 100644 (file)
@@ -1557,6 +1557,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
                        unsigned int ioctl, unsigned long arg);
 long kvm_arch_vcpu_ioctl(struct file *filp,
                         unsigned int ioctl, unsigned long arg);
+long kvm_arch_vcpu_unlocked_ioctl(struct file *filp,
+                                 unsigned int ioctl, unsigned long arg);
 vm_fault_t kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf);
 
 int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext);
@@ -2437,8 +2439,6 @@ static inline bool kvm_arch_no_poll(struct kvm_vcpu *vcpu)
 }
 #endif /* CONFIG_HAVE_KVM_NO_POLL */
 
-long kvm_arch_vcpu_async_ioctl(struct file *filp,
-                              unsigned int ioctl, unsigned long arg);
 void kvm_arch_guest_memory_reclaimed(struct kvm *kvm);
 
 #ifdef CONFIG_HAVE_KVM_VCPU_RUN_PID_CHANGE
index b7a0ae2a7b205c014cd9ddac7194ab93aecfad5a..b7db1d5f71a8be12c9f0a796e9cf944c272a8e74 100644 (file)
@@ -4434,10 +4434,10 @@ static long kvm_vcpu_ioctl(struct file *filp,
                return r;
 
        /*
-        * Some architectures have vcpu ioctls that are asynchronous to vcpu
-        * execution; mutex_lock() would break them.
+        * Let arch code handle select vCPU ioctls without holding vcpu->mutex,
+        * e.g. to support ioctls that can run asynchronous to vCPU execution.
         */
-       r = kvm_arch_vcpu_async_ioctl(filp, ioctl, arg);
+       r = kvm_arch_vcpu_unlocked_ioctl(filp, ioctl, arg);
        if (r != -ENOIOCTLCMD)
                return r;