Re: [PATCH v5 1/1] KVM: Introduce KVM_EXIT_SNP_REQ_CERTS for SNP certificate-fetching

From: Joerg Roedel
Date: Mon Feb 24 2025 - 11:25:38 EST


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?

Regards,

--
Jörg Rödel
jroedel@xxxxxxx

SUSE Software Solutions Germany GmbH
Frankenstraße 146
90461 Nürnberg
Germany
https://www.suse.com/

Geschäftsführer: Ivo Totev, Andrew McDonald, Werner Knoblich
(HRB 36809, AG Nürnberg)