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.