Re: [PATCH v7 03/16] virt: sev-guest: Add SNP guest request structure

From: Nikunj A. Dadhania
Date: Fri Jan 26 2024 - 23:06:39 EST


On 1/27/2024 2:46 AM, Tom Lendacky wrote:
> On 12/20/23 09:13, Nikunj A Dadhania wrote:
>> Add a snp_guest_req structure to simplify the function arguments. The
>> structure will be used to call the SNP Guest message request API
>> instead of passing a long list of parameters.
>>
>> Update snp_issue_guest_request() prototype to include the new guest request
>> structure and move the prototype to sev_guest.h.
>>
>> Signed-off-by: Nikunj A Dadhania <nikunj@xxxxxxx>
>> Tested-by: Peter Gonda <pgonda@xxxxxxxxxx>
>> ---
>>   .../x86/include/asm}/sev-guest.h              |  18 +++
>>   arch/x86/include/asm/sev.h                    |   8 --
>>   arch/x86/kernel/sev.c                         |  15 ++-
>>   drivers/virt/coco/sev-guest/sev-guest.c       | 108 +++++++++++-------
>>   4 files changed, 93 insertions(+), 56 deletions(-)
>>   rename {drivers/virt/coco/sev-guest => arch/x86/include/asm}/sev-guest.h (78%)
>>
>> diff --git a/drivers/virt/coco/sev-guest/sev-guest.h b/arch/x86/include/asm/sev-guest.h
>> similarity index 78%
>> rename from drivers/virt/coco/sev-guest/sev-guest.h
>> rename to arch/x86/include/asm/sev-guest.h
>> index ceb798a404d6..27cc15ad6131 100644
>> --- a/drivers/virt/coco/sev-guest/sev-guest.h
>> +++ b/arch/x86/include/asm/sev-guest.h
>> @@ -63,4 +63,22 @@ struct snp_guest_msg {
>>       u8 payload[4000];
>>   } __packed;
>>   +struct snp_guest_req {
>> +    void *req_buf;
>> +    size_t req_sz;
>> +
>> +    void *resp_buf;
>> +    size_t resp_sz;
>> +
>> +    void *data;
>> +    size_t data_npages;
>> +
>> +    u64 exit_code;
>> +    unsigned int vmpck_id;
>> +    u8 msg_version;
>> +    u8 msg_type;
>> +};
>> +
>> +int snp_issue_guest_request(struct snp_guest_req *req, struct snp_req_data *input,
>> +                struct snp_guest_request_ioctl *rio);
>
> This seems odd to have in this file. It's arch/x86/kernel/sev.c that exports the call and so this should probably stay in arch/x86/include/asm/sev.h and put the struct there, too, no?

The prototype is removed in 7/16, I have it here to make sure that compilation does not break with minimal churn.

Regards
Nikunj