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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221117173455.GC2350331@ls.amr.corp.intel.com>
Date:   Thu, 17 Nov 2022 09:34:55 -0800
From:   Isaku Yamahata <isaku.yamahata@...il.com>
To:     "Huang, Kai" <kai.huang@...el.com>
Cc:     "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "Yamahata, Isaku" <isaku.yamahata@...el.com>,
        "pbonzini@...hat.com" <pbonzini@...hat.com>,
        "Shahar, Sagi" <sagis@...gle.com>,
        "Aktas, Erdem" <erdemaktas@...gle.com>,
        "isaku.yamahata@...il.com" <isaku.yamahata@...il.com>,
        "dmatlack@...gle.com" <dmatlack@...gle.com>,
        "Christopherson,, Sean" <seanjc@...gle.com>
Subject: Re: [PATCH v10 015/108] x86/cpu: Add helper functions to
 allocate/free TDX private host key id

On Tue, Nov 08, 2022 at 09:16:57AM +0000,
"Huang, Kai" <kai.huang@...el.com> wrote:

> On Sat, 2022-10-29 at 23:22 -0700, isaku.yamahata@...el.com wrote:
> > From: Isaku Yamahata <isaku.yamahata@...el.com>
> > 
> > TDX private host key id is assigned to guest TD.  The memory controller
> > encrypts guest TD memory with the assigned TDX private host key id (HIKD).
> 								     ^
> 								     HKID.
> 
> And since you already mentioned in the first sentence, you can put (HKID) part
> there.  And I think you can just use HKID in the rest places to save some typing
> as this is the purpose of using (HKID) I suppose.
> 
> [...]
> 
> >  
> > +/* TDX KeyID pool */
> > +static DEFINE_IDA(tdx_keyid_pool);
> > +
> > +int tdx_keyid_alloc(void)
> > +{
> > +	if (WARN_ON_ONCE(!tdx_keyid_start || !tdx_keyid_num))
> > +		return -EINVAL;
> > +
> > +	/* The first keyID is reserved for the global key. */
> > +	return ida_alloc_range(&tdx_keyid_pool, tdx_keyid_start + 1,
> > +			       tdx_keyid_start + tdx_keyid_num - 1,
> > +			       GFP_KERNEL);
> > +}
> > +EXPORT_SYMBOL_GPL(tdx_keyid_alloc);
> > +
> > +void tdx_keyid_free(int keyid)
> > +{
> > +	/* keyid = 0 is reserved. */
> > +	if (!keyid || keyid <= 0)
> > +		return;
> 
> Double check of keyid == 0.
> 
> I think you can just use:
> 
> 	if (keyid <= tdx_keyid_start)
> 		return;
> 
> And/or add a WARN() as it's a bug if above happens.

Ok. Will fix it with WARN().
-- 
Isaku Yamahata <isaku.yamahata@...il.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ