Re: [PATCH v2 09/21] x86/virt/tdx: Get information about TDX module and convertible memory
From: Kai Huang
Date: Mon Mar 28 2022 - 19:40:47 EST
On Mon, 2022-03-28 at 13:30 -0700, Dave Hansen wrote:
> 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.
Hi Dave,
OK I'll think over whether I can improve. Thanks for advice.
Btw if you have time, could you help to review this series? Or could you take a
look at whether the overall design is OK, for instance, the design limitations
described in the cover letter?
--
Thanks,
-Kai