Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: Rename kvm_arch_vcpu_async_ioctl() to kvm_arch_vcpu_unlocked_ioctl()

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>

+19 -19
+2 -2
arch/arm64/kvm/arm.c
··· 1835 1835 return r; 1836 1836 } 1837 1837 1838 - long kvm_arch_vcpu_async_ioctl(struct file *filp, unsigned int ioctl, 1839 - unsigned long arg) 1838 + long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl, 1839 + unsigned long arg) 1840 1840 { 1841 1841 return -ENOIOCTLCMD; 1842 1842 }
+2 -2
arch/loongarch/kvm/vcpu.c
··· 1471 1471 return 0; 1472 1472 } 1473 1473 1474 - long kvm_arch_vcpu_async_ioctl(struct file *filp, 1475 - unsigned int ioctl, unsigned long arg) 1474 + long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl, 1475 + unsigned long arg) 1476 1476 { 1477 1477 void __user *argp = (void __user *)arg; 1478 1478 struct kvm_vcpu *vcpu = filp->private_data;
+2 -2
arch/mips/kvm/mips.c
··· 895 895 return r; 896 896 } 897 897 898 - long kvm_arch_vcpu_async_ioctl(struct file *filp, unsigned int ioctl, 899 - unsigned long arg) 898 + long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl, 899 + unsigned long arg) 900 900 { 901 901 struct kvm_vcpu *vcpu = filp->private_data; 902 902 void __user *argp = (void __user *)arg;
+2 -2
arch/powerpc/kvm/powerpc.c
··· 2028 2028 return -EINVAL; 2029 2029 } 2030 2030 2031 - long kvm_arch_vcpu_async_ioctl(struct file *filp, 2032 - unsigned int ioctl, unsigned long arg) 2031 + long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl, 2032 + unsigned long arg) 2033 2033 { 2034 2034 struct kvm_vcpu *vcpu = filp->private_data; 2035 2035 void __user *argp = (void __user *)arg;
+2 -2
arch/riscv/kvm/vcpu.c
··· 238 238 return VM_FAULT_SIGBUS; 239 239 } 240 240 241 - long kvm_arch_vcpu_async_ioctl(struct file *filp, 242 - unsigned int ioctl, unsigned long arg) 241 + long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl, 242 + unsigned long arg) 243 243 { 244 244 struct kvm_vcpu *vcpu = filp->private_data; 245 245 void __user *argp = (void __user *)arg;
+2 -2
arch/s390/kvm/kvm-s390.c
··· 5730 5730 return r; 5731 5731 } 5732 5732 5733 - long kvm_arch_vcpu_async_ioctl(struct file *filp, 5734 - unsigned int ioctl, unsigned long arg) 5733 + long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl, 5734 + unsigned long arg) 5735 5735 { 5736 5736 struct kvm_vcpu *vcpu = filp->private_data; 5737 5737 void __user *argp = (void __user *)arg;
+2 -2
arch/x86/kvm/x86.c
··· 7240 7240 return 0; 7241 7241 } 7242 7242 7243 - long kvm_arch_vcpu_async_ioctl(struct file *filp, unsigned int ioctl, 7244 - unsigned long arg) 7243 + long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl, 7244 + unsigned long arg) 7245 7245 { 7246 7246 return -ENOIOCTLCMD; 7247 7247 }
+2 -2
include/linux/kvm_host.h
··· 1557 1557 unsigned int ioctl, unsigned long arg); 1558 1558 long kvm_arch_vcpu_ioctl(struct file *filp, 1559 1559 unsigned int ioctl, unsigned long arg); 1560 + long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, 1561 + unsigned int ioctl, unsigned long arg); 1560 1562 vm_fault_t kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf); 1561 1563 1562 1564 int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext); ··· 2439 2437 } 2440 2438 #endif /* CONFIG_HAVE_KVM_NO_POLL */ 2441 2439 2442 - long kvm_arch_vcpu_async_ioctl(struct file *filp, 2443 - unsigned int ioctl, unsigned long arg); 2444 2440 void kvm_arch_guest_memory_reclaimed(struct kvm *kvm); 2445 2441 2446 2442 #ifdef CONFIG_HAVE_KVM_VCPU_RUN_PID_CHANGE
+3 -3
virt/kvm/kvm_main.c
··· 4434 4434 return r; 4435 4435 4436 4436 /* 4437 - * Some architectures have vcpu ioctls that are asynchronous to vcpu 4438 - * execution; mutex_lock() would break them. 4437 + * Let arch code handle select vCPU ioctls without holding vcpu->mutex, 4438 + * e.g. to support ioctls that can run asynchronous to vCPU execution. 4439 4439 */ 4440 - r = kvm_arch_vcpu_async_ioctl(filp, ioctl, arg); 4440 + r = kvm_arch_vcpu_unlocked_ioctl(filp, ioctl, arg); 4441 4441 if (r != -ENOIOCTLCMD) 4442 4442 return r; 4443 4443