[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z78kv-hhU6AWyufz@google.com>
Date: Wed, 26 Feb 2025 06:27:11 -0800
From: Sean Christopherson <seanjc@...gle.com>
To: Joerg Roedel <jroedel@...e.de>
Cc: Michael Roth <michael.roth@....com>, kvm@...r.kernel.org, linux-coco@...ts.linux.dev,
linux-kernel@...r.kernel.org, pbonzini@...hat.com, thomas.lendacky@....com,
ashish.kalra@....com, liam.merwick@...cle.com, pankaj.gupta@....com,
dionnaglaze@...gle.com, huibo.wang@....com
Subject: Re: [PATCH v5 1/1] KVM: Introduce KVM_EXIT_SNP_REQ_CERTS for SNP certificate-fetching
On Mon, Feb 24, 2025, Joerg Roedel wrote:
> Hi Michael,
>
> On Wed, Feb 19, 2025 at 09:15:05AM -0600, Michael Roth wrote:
> > + - If some other error occurred, userspace must set `ret` to ``EIO``.
> > + (This is to reserve special meaning for unused error codes in the
> > + future.)
>
> [...]
>
> > +static int snp_complete_req_certs(struct kvm_vcpu *vcpu)
> > +{
> > + struct vcpu_svm *svm = to_svm(vcpu);
> > + struct vmcb_control_area *control = &svm->vmcb->control;
> > +
> > + if (vcpu->run->snp_req_certs.ret) {
> > + if (vcpu->run->snp_req_certs.ret == ENOSPC) {
> > + vcpu->arch.regs[VCPU_REGS_RBX] = vcpu->run->snp_req_certs.npages;
> > + ghcb_set_sw_exit_info_2(svm->sev_es.ghcb,
> > + SNP_GUEST_ERR(SNP_GUEST_VMM_ERR_INVALID_LEN, 0));
> > + } else if (vcpu->run->snp_req_certs.ret == EAGAIN) {
> > + ghcb_set_sw_exit_info_2(svm->sev_es.ghcb,
> > + SNP_GUEST_ERR(SNP_GUEST_VMM_ERR_BUSY, 0));
> > + } else {
> > + ghcb_set_sw_exit_info_2(svm->sev_es.ghcb,
> > + SNP_GUEST_ERR(SNP_GUEST_VMM_ERR_GENERIC, 0));
> > + }
>
> According to the documentation above, there should be a block checking
> for EIO which injects SNP_GUEST_VMM_ERR_GENERIC and the else block
> should return with EINVAL to user-space, no?
Yeah. It feels a bit ridiculous, but it would be quite unfortunate to go through
the extra effort of decoupling KVM's error handling from the GHCB error code, only
for it to all fall apart due to not enforcing the "return" value.
Powered by blists - more mailing lists