Re: [PATCH v7 06/16] virt: sev-guest: Move SNP Guest command mutex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/27/2024 3:41 AM, Tom Lendacky wrote:
> On 12/20/23 09:13, Nikunj A Dadhania wrote:
>> SNP command mutex is used to serialize the shared buffer access, command
>> handling and message sequence number races. Move the SNP guest command
>> mutex out of the sev guest driver and provide accessors to sev-guest
>> driver. Remove multiple lockdep check in sev-guest driver, next patch adds
>> a single lockdep check in snp_send_guest_request().
>>
>> Signed-off-by: Nikunj A Dadhania <nikunj@xxxxxxx>
>> ---
>>   arch/x86/include/asm/sev-guest.h        |  3 +++
>>   arch/x86/kernel/sev.c                   | 21 +++++++++++++++++++++
>>   drivers/virt/coco/sev-guest/sev-guest.c | 23 +++++++----------------
>>   3 files changed, 31 insertions(+), 16 deletions(-)
>>
>> diff --git a/arch/x86/include/asm/sev-guest.h b/arch/x86/include/asm/sev-guest.h
>> index 27cc15ad6131..2f3cceb88396 100644
>> --- a/arch/x86/include/asm/sev-guest.h
>> +++ b/arch/x86/include/asm/sev-guest.h
>> @@ -81,4 +81,7 @@ struct snp_guest_req {
>>     int snp_issue_guest_request(struct snp_guest_req *req, struct snp_req_data *input,
>>                   struct snp_guest_request_ioctl *rio);
>> +void snp_guest_cmd_lock(void);
>> +void snp_guest_cmd_unlock(void);
>> +
>>   #endif /* __VIRT_SEVGUEST_H__ */
>> diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c
>> index 6aa0bdf8a7a0..191193924b22 100644
>> --- a/arch/x86/kernel/sev.c
>> +++ b/arch/x86/kernel/sev.c
>> @@ -941,6 +941,21 @@ static void snp_cleanup_vmsa(struct sev_es_save_area *vmsa)
>>           free_page((unsigned long)vmsa);
>>   }
>>   +/*  SNP Guest command mutex to serialize the shared buffer access and command handling. */
>> +static struct mutex snp_guest_cmd_mutex;
> 
> You should probably use:
> 
> static DEFINE_MUTEX(snp_guest_cmd_mutex);
> 
> That way you can avoid the initialization in snp_init_platform_device().
> 
> With that:
> 
> Reviewed-by: Tom Lendacky <thomas.lendacky@xxxxxxx>

Sure, will change.

Regards
Nikunj





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux