lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 11 Jan 2023 09:23:24 +0000
From:   "Huang, Kai" <kai.huang@...el.com>
To:     "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "Hansen, Dave" <dave.hansen@...el.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC:     "Luck, Tony" <tony.luck@...el.com>,
        "bagasdotme@...il.com" <bagasdotme@...il.com>,
        "ak@...ux.intel.com" <ak@...ux.intel.com>,
        "Wysocki, Rafael J" <rafael.j.wysocki@...el.com>,
        "kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>,
        "Christopherson,, Sean" <seanjc@...gle.com>,
        "Chatre, Reinette" <reinette.chatre@...el.com>,
        "pbonzini@...hat.com" <pbonzini@...hat.com>,
        "linux-mm@...ck.org" <linux-mm@...ck.org>,
        "Yamahata, Isaku" <isaku.yamahata@...el.com>,
        "tglx@...utronix.de" <tglx@...utronix.de>,
        "peterz@...radead.org" <peterz@...radead.org>,
        "imammedo@...hat.com" <imammedo@...hat.com>,
        "Gao, Chao" <chao.gao@...el.com>,
        "Brown, Len" <len.brown@...el.com>,
        "Shahar, Sagi" <sagis@...gle.com>,
        "sathyanarayanan.kuppuswamy@...ux.intel.com" 
        <sathyanarayanan.kuppuswamy@...ux.intel.com>,
        "Huang, Ying" <ying.huang@...el.com>,
        "Williams, Dan J" <dan.j.williams@...el.com>
Subject: Re: [PATCH v8 08/16] x86/virt/tdx: Add placeholder to construct TDMRs
 to cover all TDX memory regions

On Tue, 2023-01-10 at 11:12 -0800, Hansen, Dave wrote:
> On 1/9/23 18:23, Huang, Kai wrote:
> > 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.
> 
> What's the problem with recalculating it?  It is calculated like this:
> 
> 	tdmr_sz = ALIGN(constant1 + constant2 * variable);
> 
> So, what's the problem?  You're concerned about too many multiplications?

No problem.  I don't have concern about multiplications, but since they can be
avoided, I thought perhaps it's better to avoid.

So I am fine with either way, no problem.

> 
> > 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@intel.com/T/#mb9826e2bcf8bf6399c13cc5f95a948fe4b3a46d9
> > 
> > Please let me know what's your preference?
> 
> I dunno.  My gut says that passing sysinfo around and just deriving the
> sizes values from that with helpers is the best way.  'struct
> tdmr_info_list' isn't a horrible idea in and of itself, but I think it's
> a confusing structure because it's not clear how the pieces fit together
> when half of it is *required* and the other half is just for some kind
> of perceived convenience.
> 

Sure.  No more argument about this.

However, for the sake of not adding more review burden to you, how about keeping
the 'struct tdmr_info_list' as is this time?  Of course I am willing to remove
the 'tdmr_sz' and 'max_tdmrs' from 'struct tdmr_info_list' but only keep 'tdmrs'
and 'nr_consumed_tdmrs' if you are wiling or want to look at what will the new
code look like.

Please let me know?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ