Re: [PATCH v2 3/4] KVM: SVM: move sev_bind_asid to psp
From: Mingwei Zhang
Date: Thu Sep 09 2021 - 17:18:44 EST
> > Most of the address field in the "struct sev_data_*" are physical
> > addressess. The userspace will not be able to populate those fields.
>
> Yeah, that's my biggest hesitation to using struct sev_data_* in the API, it's
> both confusing and gross. But it's also why I think these helpers belong in the
> PSP driver, KVM should not need to know the "on-the-wire" format for communicating
> with the PSP.
>
Did a simple checking for all struct sev_data_* fields defined in psp-sev.h:
The average argument is roughly 4 (103/27), detailed data appended at
last. In addition, I believe the most used commands would be the
following?
#data structure name: number of meaningful fields
sev_data_launch_start: 6
sev_data_activate: 2
sev_data_decommission: 1
sev_data_receive_update_data: 7
sev_data_send_update_vmsa: 7
sev_data_launch_measure: 3
sev_data_launch_finish: 1
sev_data_deactivate: 1
For the above frequently-used command set, the average argument length
is also around 3-4 (28/8) on average, 2.5 as the median.
So, from that perspective, I think we should just remove those
sev_data data structures in KVM, since it is more clear to read each
argument.
In addition, having to construct each sev_data_* structure in KVM code
is also a pain and consumes a lot of irrelevant lines as well.
#data structure name: number of meaningful fields
sev_data_deactivate: 1
sev_data_decommission: 1
sev_data_launch_finish: 1
sev_data_receive_finish: 1
sev_data_send_cancel: 1
sev_data_send_finish: 1
sev_data_activate: 2
sev_data_download_firmware: 2
sev_data_get_id: 2
sev_data_pek_csr: 2
sev_data_init: 3
sev_data_launch_measure: 3
sev_data_launch_update_data: 3
sev_data_launch_update_vmsa: 3
sev_data_attestation_report: 4
sev_data_dbg: 4
sev_data_guest_status: 4
sev_data_pdh_cert_export: 4
sev_data_pek_cert_import: 4
sev_data_launch_start: 6
sev_data_receive_start: 6
sev_data_launch_secret: 7
sev_data_receive_update_data: 7
sev_data_receive_update_vmsa: 7
sev_data_send_update_data: 7
sev_data_send_update_vmsa: 7
sev_data_send_start: 10