Re: [PATCH v8 08/16] x86/virt/tdx: Add placeholder to construct TDMRs to cover all TDX memory regions

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

 



On Mon, 2023-01-09 at 16:47 -0800, Dave Hansen wrote:
> On 1/9/23 16:40, Huang, Kai wrote:
> > On Fri, 2023-01-06 at 11:24 -0800, Dave Hansen wrote:
> ...
> > > Also, tdmr_sz and max_tdmrs can both be derived from 'sysinfo'.  Do they
> > > really need to be stored here?
> > 
> > It's not mandatory to keep them here.  I did it mainly because I want to avoid
> > passing 'sysinfo' as argument for almost all functions related to constructing
> > TDMRs.
> 
> I don't think it hurts readability that much.  On the contrary, it makes
> it more clear what data is needed for initialization.

Sorry one thing I forgot to mention is if we keep 'tdmr_sz' in 'struct
tdmr_info_list', it only needs to be calculated at once when allocating the
buffer.  Otherwise, we need to calculate it based on sysinfo-
>max_reserved_per_tdmr each time we want to get a TDMR at a given index.

To me putting relevant fields (tdmrs, tdmr_sz, max_tdmrs, nr_consumed_tdmrs)
together makes how the TDMR list is organized more clear.  But please let me
know if you prefer removing 'tdmr_sz' and 'max_tdmrs'.

Btw, if we remove 'tdmr_sz' and 'max_tdmrs', even nr_consumed_tdmrs is not
absolutely necessary here.  It can be a local variable of init_tdx_module() (as
shown in v7), and the 'struct tdmr_info_list' will only have the 'tdmrs' member
(as you commented in v7):

https://lore.kernel.org/linux-mm/cc195eb6499cf021b4ce2e937200571915bfe66f.camel@xxxxxxxxx/T/#mb9826e2bcf8bf6399c13cc5f95a948fe4b3a46d9

Please let me know what's your preference?

> 
> > > If so, I think I'd probably do something
> > > like this with the structure:
> > > 
> > > struct tdmr_info_list {
> > >       struct tdmr_info *tdmrs;
> > >       int nr_consumed_tdmrs; // How many @tdmrs are in use
> > > 
> > >       /* Metadata for freeing this structure: */
> > >       int tdmr_sz;   // Size of one 'tdmr_info' (has a flex array)
> > >       int max_tdmrs; // How many @tdmrs are allocated
> > > };
> > > 
> > > Modulo whataver folks are doing for comments these days.
> > 
> > Looks nice to me.  Will use.  A slight thing is 'tdmr_sz' is also used to get
> > the TDMR at a given index, but not just freeing the structure.
> > 
> > Btw, is C++ style comment "//" OK in kernel code?
> 
> It's OK with me, but I don't think there's much consensus on it.
> Probably best to stick with normal arch/x86 style for now.
> 
> 

Will use normal arch/x86 style for now.  Thanks for the info.





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux