static struct tdx_sys_info tdx_sysinfo __ro_after_init;
static bool tdx_module_initialized __ro_after_init;
-static atomic_t nr_configured_hkid;
-
typedef void (*sc_err_func_t)(u64 fn, u64 err, struct tdx_module_args *args);
static inline void seamcall_err(u64 fn, u64 err, struct tdx_module_args *args)
int i;
/* No TD is running. Allow any cpu to be offline. */
- if (!atomic_read(&nr_configured_hkid))
+ if (ida_is_empty(&tdx_guest_keyid_pool))
goto done;
/*
int tdx_guest_keyid_alloc(void)
{
- int ret;
-
- ret = ida_alloc_range(&tdx_guest_keyid_pool, tdx_guest_keyid_start,
- tdx_guest_keyid_start + tdx_nr_guest_keyids - 1,
- GFP_KERNEL);
- if (ret >= 0)
- atomic_inc(&nr_configured_hkid);
-
- return ret;
+ return ida_alloc_range(&tdx_guest_keyid_pool, tdx_guest_keyid_start,
+ tdx_guest_keyid_start + tdx_nr_guest_keyids - 1,
+ GFP_KERNEL);
}
EXPORT_SYMBOL_FOR_KVM(tdx_guest_keyid_alloc);
void tdx_guest_keyid_free(unsigned int keyid)
{
ida_free(&tdx_guest_keyid_pool, keyid);
- atomic_dec(&nr_configured_hkid);
}
EXPORT_SYMBOL_FOR_KVM(tdx_guest_keyid_free);