Re: [PATCH v3 01/11] KVM: SVM: Add KVM_SEV SEND_START command

From: Peter Gonda
Date: Thu Nov 14 2019 - 14:27:52 EST


On Tue, Nov 12, 2019 at 2:27 PM Brijesh Singh <brijesh.singh@xxxxxxx> wrote:
>
>
> On 11/12/19 12:35 PM, Peter Gonda wrote:
> > On Wed, Jul 10, 2019 at 1:13 PM Singh, Brijesh <brijesh.singh@xxxxxxx> wrote:
> >> +static int sev_send_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
> >> +{
> >> + struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
> >> + void *amd_cert = NULL, *session_data = NULL;
> >> + void *pdh_cert = NULL, *plat_cert = NULL;
> >> + struct sev_data_send_start *data = NULL;
> >> + struct kvm_sev_send_start params;
> >> + int ret;
> >> +
> >> + if (!sev_guest(kvm))
> >> + return -ENOTTY;
> >> +
> >> + if (copy_from_user(&params, (void __user *)(uintptr_t)argp->data,
> >> + sizeof(struct kvm_sev_send_start)))
> >> + return -EFAULT;
> >> +
> >> + data = kzalloc(sizeof(*data), GFP_KERNEL);
> >> + if (!data)
> >> + return -ENOMEM;
> >> +
> >> + /* userspace wants to query the session length */
> >> + if (!params.session_len)
> >> + goto cmd;
> >> +
> >> + if (!params.pdh_cert_uaddr || !params.pdh_cert_len ||
> >> + !params.session_uaddr)
> >> + return -EINVAL;
> > I think pdh_cert is only required if the guest policy SEV bit is set.
> > Can pdh_cert be optional?
>
>
> We don't cache the policy information in kernel, having said so we can
> try caching it during the LAUNCH_START to optimize this case. I have to
> check with FW folks but I believe all those fields are required. IIRC,
> When I passed NULL then SEND_START failed for me. But I double check it
> and update you on this.


I must have misinterpreted the this line of the spec:
"If GCTX.POLICY.SEV is 1, the PDH, PEK, CEK, ASK, and ARK certificates
are validated."
I thought that since they were not validated they were not needed.