On Tue, Oct 21, 2025, Rick P Edgecombe wrote:
> On Thu, 2025-10-16 at 17:32 -0700, Sean Christopherson wrote:
> > Use guard() in tdx_vm_ioctl() to tidy up the code a small amount, but more
> > importantly to minimize the diff of a future change, which will use
> > guard-like semantics to acquire and release multiple locks.
> > 
> > No functional change intended.
> 
> There is a tiny functional change. In the default case it no longer re-copies
> the struct back to userspace.

No?  The default case doesn't copy the struct back even before this patch, it
explicitly skips the copy_to_user().

        mutex_lock(&kvm->lock);

        switch (tdx_cmd.id) {
        case KVM_TDX_CAPABILITIES:
                r = tdx_get_capabilities(&tdx_cmd);
                break;
        case KVM_TDX_INIT_VM:
                r = tdx_td_init(kvm, &tdx_cmd);
                break;
        case KVM_TDX_FINALIZE_VM:
                r = tdx_td_finalize(kvm, &tdx_cmd);
                break;
        default:
                r = -EINVAL;
                goto out;  <====================
        }

        if (copy_to_user(argp, &tdx_cmd, sizeof(struct kvm_tdx_cmd)))
                r = -EFAULT;

out:
        mutex_unlock(&kvm->lock);
        return r;

Reply via email to