lkml.org 
[lkml]   [2022]   [Nov]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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@intel.com> wrote:

> On Sat, 2022-10-29 at 23:22 -0700, isaku.yamahata@intel.com wrote:
> > From: Isaku Yamahata <isaku.yamahata@intel.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@gmail.com>

\
 
 \ /
  Last update: 2022-11-17 18:35    [W:0.133 / U:0.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site