Re: [PATCH v9 06/24] virt: sev-guest: Simplify VMPCK and sequence number assignments
From: Nikunj A. Dadhania
Date: Wed Jun 19 2024 - 11:20:46 EST
On 6/19/2024 8:42 PM, Tom Lendacky wrote:
> On 6/19/24 01:06, Nikunj A. Dadhania wrote:
>> On 6/19/2024 2:57 AM, Tom Lendacky wrote:
>>> On 5/30/24 23:30, Nikunj A Dadhania wrote:
>
>>
>> I have separated patch 6 and 7 for better code review and modular changes.
>>
>> The next patch simplifes this further to:
>>
>> static inline u8 *get_vmpck(struct snp_guest_dev *snp_dev)
>> {
>> return snp_dev->secrets->vmpck[snp_dev->vmpck_id];
>> }
>>
>> static bool assign_vmpck(struct snp_guest_dev *dev, unsigned int vmpck_id)
>> {
>> if ((vmpck_id + 1) > VMPCK_MAX_NUM)
>
> Ok, this still has the "+ 1" thing (and it should be >=, right?). How about:
For vmpck_id=3 which is valid, ((3 + 1) >= 4) will exit, which is not correct.
>
> if (!(vmpck_id < VMPCK_MAX_NUM))
> return false;
>
Sure, this is better.
> Just makes it easier to read for me, but if no one else has an issue,
> don't worry about it.
Thanks,
Nikunj