Re: [PATCH v2 09/21] x86/virt/tdx: Get information about TDX module and convertible memory

From: Dave Hansen
Date: Mon Mar 28 2022 - 16:30:07 EST


On 3/28/22 13:22, Isaku Yamahata wrote:
>>>> + /*
>>>> + * Also a sane BIOS should never generate invalid CMR(s) between
>>>> + * two valid CMRs. Sanity check this and simply return error in
>>>> + * this case.
>>>> + */
>>>> + for (j = i; j < cmr_num; j++)
>>>> + if (cmr_valid(&cmr_array[j])) {
>>>> + pr_err("Firmware bug: invalid CMR(s) among valid CMRs.\n");
>>>> + return -EFAULT;
>>>> + }
>>> This check doesn't make sense because above i-for loop has break.
>> The break in above i-for loop will hit at the first invalid CMR entry. Yes "j =
>> i" will make double check on this invalid CMR entry, but it should have no
>> problem. Or we can change to "j = i + 1" to skip the first invalid CMR entry.
>>
>> Does this make sense?
> It makes sense. Somehow I missed j = i. I scratch my review.

You can also take it as something you might want to refactor, add
comments, or work on better variable names. If it confused one person,
it will confuse more in the future.