KVM: SVM: Return -EINVAL instead of -EBUSY on attempt to re-init SEV/SEV-ES
authorSean Christopherson <seanjc@google.com>
Wed, 31 Jan 2024 23:56:09 +0000 (15:56 -0800)
committerSean Christopherson <seanjc@google.com>
Tue, 6 Feb 2024 19:10:12 +0000 (11:10 -0800)
Return -EINVAL instead of -EBUSY if userspace attempts KVM_SEV{,ES}_INIT
on a VM that already has SEV active.  Returning -EBUSY is nonsencial as
it's impossible to deactivate SEV without destroying the VM, i.e. the VM
isn't "busy" in any sane sense of the word, and the odds of any userspace
wanting exactly -EBUSY on a userspace bug are minuscule.

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/r/20240131235609.4161407-5-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/sev.c

index 5f8312edee36b1a2385de032114c63f4209494af..f06f9e51ad9dba5da99896d6983dfed2c3fdd1bb 100644 (file)
@@ -259,9 +259,8 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)
        if (kvm->created_vcpus)
                return -EINVAL;
 
-       ret = -EBUSY;
        if (unlikely(sev->active))
-               return ret;
+               return -EINVAL;
 
        sev->active = true;
        sev->es_active = argp->id == KVM_SEV_ES_INIT;