]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: SEV: Don't explicitly pass PSC buffer to snp_begin_psc()
authorSean Christopherson <seanjc@google.com>
Fri, 1 May 2026 20:22:33 +0000 (13:22 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 29 May 2026 18:25:28 +0000 (20:25 +0200)
Stop explicitly passing the PSC buffer to snp_begin_psc(): it *must*
be the scratch area.  This will allow fixing a variety of bugs without
further complicating the code.

No functional change intended.

Cc: stable@vger.kernel.org
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-ID: <20260501202250.2115252-9-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm/sev.c

index a3e85348ace9950348ad9d23e59a447455bd82eb..8577451b82b27e8e71abe06c63fd259607648b15 100644 (file)
@@ -3841,7 +3841,7 @@ struct psc_buffer {
        struct psc_entry entries[];
 } __packed;
 
-static int snp_begin_psc(struct vcpu_svm *svm, struct psc_buffer *psc);
+static int snp_begin_psc(struct vcpu_svm *svm);
 
 static void snp_complete_psc(struct vcpu_svm *svm, u64 psc_ret)
 {
@@ -3883,7 +3883,6 @@ static void __snp_complete_one_psc(struct vcpu_svm *svm)
 static int snp_complete_one_psc(struct kvm_vcpu *vcpu)
 {
        struct vcpu_svm *svm = to_svm(vcpu);
-       struct psc_buffer *psc = svm->sev_es.ghcb_sa;
 
        if (vcpu->run->hypercall.ret) {
                snp_complete_psc(svm, VMGEXIT_PSC_ERROR_GENERIC);
@@ -3893,11 +3892,13 @@ static int snp_complete_one_psc(struct kvm_vcpu *vcpu)
        __snp_complete_one_psc(svm);
 
        /* Handle the next range (if any). */
-       return snp_begin_psc(svm, psc);
+       return snp_begin_psc(svm);
 }
 
-static int snp_begin_psc(struct vcpu_svm *svm, struct psc_buffer *psc)
+static int snp_begin_psc(struct vcpu_svm *svm)
 {
+       struct vcpu_sev_es_state *sev_es = &svm->sev_es;
+       struct psc_buffer *psc = sev_es->ghcb_sa;
        struct psc_entry *entries = psc->entries;
        struct kvm_vcpu *vcpu = &svm->vcpu;
        struct psc_hdr *hdr = &psc->hdr;
@@ -4567,7 +4568,7 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu)
                if (ret)
                        break;
 
-               ret = snp_begin_psc(svm, svm->sev_es.ghcb_sa);
+               ret = snp_begin_psc(svm);
                break;
        case SVM_VMGEXIT_AP_CREATION:
                ret = sev_snp_ap_creation(svm);