RE: [PATCH Part2 v6 13/49] crypto:ccp: Provide APIs to issue SEV-SNP commands

From: Kalra, Ashish
Date: Mon Oct 03 2022 - 10:38:52 EST


[AMD Official Use Only - General]

Hello Boris,

>> +int snp_guest_decommission(struct sev_data_snp_decommission *data,
>> +int *error) {
>> + return sev_do_cmd(SEV_CMD_SNP_DECOMMISSION, data, error); }
>> +EXPORT_SYMBOL_GPL(snp_guest_decommission);
>> +
>> +int snp_guest_df_flush(int *error)
>> +{
>> + return sev_do_cmd(SEV_CMD_SNP_DF_FLUSH, NULL, error); }
>> +EXPORT_SYMBOL_GPL(snp_guest_df_flush);
>> +
>> +int snp_guest_page_reclaim(struct sev_data_snp_page_reclaim *data,
>> +int *error) {
>> + return sev_do_cmd(SEV_CMD_SNP_PAGE_RECLAIM, data, error); }
>> +EXPORT_SYMBOL_GPL(snp_guest_page_reclaim);
>> +
>> +int snp_guest_dbg_decrypt(struct sev_data_snp_dbg *data, int *error)
>> +{
>> + return sev_do_cmd(SEV_CMD_SNP_DBG_DECRYPT, data, error); }
>> +EXPORT_SYMBOL_GPL(snp_guest_dbg_decrypt);

>So this mindless repetition is getting annoying. I see ~70 SEV commands.
>Adding ~70 functions which parrot all the same call to sev_do_cmd() is just insane.

>I think you should simply export sev_do_cmd() and call it instead.

>Yes, when it turns out that a command and the preparation to issue it before it starts repeating pretty often, you could do a helper. But adding those silly wrappers doesn't bring anything besides confusion and code bloat.

There are actually only 8 functions in total which are simply calling sev_do_cmd(), all other functions calling sev_do_cmd() have a lot of other specific functionality in them.

Those are the earlier - sev_platform_status(), sev_guest_deactivate(), sev_guest_decomission() and sev_guest_df_flush().

And the 4 functions added in this patch - snp_guest_decomission(), snp_guest_df_flush(), snp_guest_page_reclaim(), and snp_guest_dbg_decrypt().

Thanks,
Ashish