]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: SVM: Simplify request+kick logic in SNP AP Creation handling
authorSean Christopherson <seanjc@google.com>
Thu, 27 Feb 2025 01:25:37 +0000 (17:25 -0800)
committerSean Christopherson <seanjc@google.com>
Mon, 3 Mar 2025 15:34:52 +0000 (07:34 -0800)
Drop the local "kick" variable and the unnecessary "fallthrough" logic
from sev_snp_ap_creation(), and simply pivot on the request when deciding
whether or not to immediate force a state update on the target vCPU.

No functional change intended.

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

index 8bc81a5a8159813936c8442986e2bc71b1d977c2..9ec89c9de6fc2111c79ca4334a5186f881524845 100644 (file)
@@ -3944,7 +3944,6 @@ static int sev_snp_ap_creation(struct vcpu_svm *svm)
        struct vcpu_svm *target_svm;
        unsigned int request;
        unsigned int apic_id;
-       bool kick;
        int ret;
 
        request = lower_32_bits(svm->vmcb->control.exit_info_1);
@@ -3962,18 +3961,10 @@ static int sev_snp_ap_creation(struct vcpu_svm *svm)
 
        target_svm = to_svm(target_vcpu);
 
-       /*
-        * The target vCPU is valid, so the vCPU will be kicked unless the
-        * request is for CREATE_ON_INIT.
-        */
-       kick = true;
-
        mutex_lock(&target_svm->sev_es.snp_vmsa_mutex);
 
        switch (request) {
        case SVM_VMGEXIT_AP_CREATE_ON_INIT:
-               kick = false;
-               fallthrough;
        case SVM_VMGEXIT_AP_CREATE:
                if (vcpu->arch.regs[VCPU_REGS_RAX] != sev->vmsa_features) {
                        vcpu_unimpl(vcpu, "vmgexit: mismatched AP sev_features [%#lx] != [%#llx] from guest\n",
@@ -4018,7 +4009,11 @@ static int sev_snp_ap_creation(struct vcpu_svm *svm)
 
        target_svm->sev_es.snp_ap_waiting_for_reset = true;
 
-       if (kick) {
+       /*
+        * Unless Creation is deferred until INIT, signal the vCPU to update
+        * its state.
+        */
+       if (request != SVM_VMGEXIT_AP_CREATE_ON_INIT) {
                kvm_make_request(KVM_REQ_UPDATE_PROTECTED_GUEST_STATE, target_vcpu);
                kvm_vcpu_kick(target_vcpu);
        }