Re: [PATCH v17 015/116] x86/cpu: Add helper functions to allocate/free TDX private host key id

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

 



On Wed, Nov 15, 2023 at 03:35:11PM +0800,
Chenyi Qiang <chenyi.qiang@xxxxxxxxx> 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@xxxxxxxxx/
> 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@xxxxxxxxxxxxxxx>




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux