[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231117000205.GA1277973@ls.amr.corp.intel.com>
Date: Thu, 16 Nov 2023 16:02:05 -0800
From: Isaku Yamahata <isaku.yamahata@...ux.intel.com>
To: Chenyi Qiang <chenyi.qiang@...el.com>
Cc: isaku.yamahata@...el.com, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, isaku.yamahata@...il.com,
Paolo Bonzini <pbonzini@...hat.com>, erdemaktas@...gle.com,
Sean Christopherson <seanjc@...gle.com>,
Sagi Shahar <sagis@...gle.com>,
David Matlack <dmatlack@...gle.com>,
Kai Huang <kai.huang@...el.com>,
Zhi Wang <zhi.wang.linux@...il.com>, chen.bo@...el.com,
hang.yuan@...el.com, tina.zhang@...el.com,
isaku.yamahata@...ux.intel.com
Subject: Re: [PATCH v17 015/116] x86/cpu: Add helper functions to
allocate/free TDX private host key id
On Wed, Nov 15, 2023 at 03:35:11PM +0800,
Chenyi Qiang <chenyi.qiang@...el.com> wrote:
> > diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
> > index 38ec6815a42a..c01cbfc81fbb 100644
> > --- a/arch/x86/virt/vmx/tdx/tdx.c
> > +++ b/arch/x86/virt/vmx/tdx/tdx.c
> > @@ -37,7 +37,8 @@
> > #include <asm/tdx.h>
> > #include "tdx.h"
> >
> > -static u32 tdx_global_keyid __ro_after_init;
> > +u32 tdx_global_keyid __ro_after_init;
> > +EXPORT_SYMBOL_GPL(tdx_global_keyid);
> > static u32 tdx_guest_keyid_start __ro_after_init;
> > static u32 tdx_nr_guest_keyids __ro_after_init;
> >
> > @@ -105,6 +106,31 @@ static inline int sc_retry_prerr(sc_func_t func, sc_err_func_t err_func,
> > #define seamcall_prerr_ret(__fn, __args) \
> > sc_retry_prerr(__seamcall_ret, seamcall_err_ret, (__fn), (__args))
> >
> > +/* TDX KeyID pool */
> > +static DEFINE_IDA(tdx_guest_keyid_pool);
> > +
> > +int tdx_guest_keyid_alloc(void)
> > +{
> > + if (WARN_ON_ONCE(!tdx_guest_keyid_start || !tdx_nr_guest_keyids))
> > + return -EINVAL;
> > +
> > + /* The first keyID is reserved for the global key. */
> > + return ida_alloc_range(&tdx_guest_keyid_pool, tdx_guest_keyid_start + 1,
>
> Per
> https://lore.kernel.org/all/121aab11b48b4e6550cfe6d23b4daab744ee2076.1697532085.git.kai.huang@intel.com/
> tdx_guest_keyid_start has already reserved the first keyID for global
> key, I think we don't need to reserve another one here.
Nice catch. Will fix it with the next respin.
--
Isaku Yamahata <isaku.yamahata@...ux.intel.com>
Powered by blists - more mailing lists