Skip to content

Commit f26061f

Browse files
committed
KVM: TDX: Don't copy "cmd" back to userspace for KVM_TDX_CAPABILITIES
Don't copy the kvm_tdx_cmd structure back to userspace when handling KVM_TDX_CAPABILITIES, as tdx_get_capabilities() doesn't modify hw_error or any other fields. Opportunistically hoist the call to tdx_get_capabilities() outside of the kvm->lock critical section, as getting the capabilities doesn't touch the VM in any way, e.g. doesn't even take @kvm. Suggested-by: Kai Huang <kai.huang@intel.com> Reviewed-by: Kai Huang <kai.huang@intel.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-26-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 0b76e82 commit f26061f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/x86/kvm/vmx/tdx.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2816,12 +2816,12 @@ int tdx_vm_ioctl(struct kvm *kvm, void __user *argp)
28162816
if (r)
28172817
return r;
28182818

2819+
if (tdx_cmd.id == KVM_TDX_CAPABILITIES)
2820+
return tdx_get_capabilities(&tdx_cmd);
2821+
28192822
guard(mutex)(&kvm->lock);
28202823

28212824
switch (tdx_cmd.id) {
2822-
case KVM_TDX_CAPABILITIES:
2823-
r = tdx_get_capabilities(&tdx_cmd);
2824-
break;
28252825
case KVM_TDX_INIT_VM:
28262826
r = tdx_td_init(kvm, &tdx_cmd);
28272827
break;

0 commit comments

Comments
 (0)