Re: [PATCH 07/25] KVM: TDX: Add helper functions to allocate/free TDX private host key id

Paolo Bonzini
2024-09-10T16:42:09Z

On 9/10/24 18:39, Edgecombe, Rick P wrote:
>>> Use this range of HKIDs reserved for guest use with the kernel's IDA
>>> allocator library helper to create a mini TDX HKID allocator that can be
>>> called when setting up a TD. This way it can have an exclusive HKID, as is
>>> required. This allocator will be used in future changes.
>> This is basically what Dave was asking for, isn't it?
> This patch has the allocator in KVM code, and the keyid ranges exported from
> arch/x86. Per the discussion with Dave we will export the allocator functions
> and keep the keyid ranges in arch/x86 code.

Yes, I meant this is the code and it just has to be moved to arch/x86.
The only other function that is needed is a wrapper for ida_is_empty(),
which is used in tdx_offline_cpu():

/* No TD is running. Allow any cpu to be offline. */
if (ida_is_empty(&tdx_guest_keyid_pool))
return 0;

Paolo