This patch has the allocator in KVM code, and the keyid ranges exported fromUse this range of HKIDs reserved for guest use with the kernel's IDAThis is basically what Dave was asking for, isn't it?
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.
arch/x86. Per the discussion with Dave we will export the allocator functions
and keep the keyid ranges in arch/x86 code.