drivers/tee/amdtee/call.c
Source file repositories/reference/linux-study-clean/drivers/tee/amdtee/call.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tee/amdtee/call.c- Extension
.c- Size
- 10756 bytes
- Lines
- 452
- Domain
- Driver Families
- Bucket
- drivers/tee
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/tee.hlinux/tee_core.hlinux/psp-tee.hlinux/slab.hlinux/psp.hamdtee_if.hamdtee_private.h
Detected Declarations
function tee_params_to_amd_paramsfunction amd_params_to_tee_paramsfunction get_ta_refcountfunction put_ta_refcountfunction handle_unload_tafunction handle_close_sessionfunction handle_unmap_shmemfunction handle_invoke_cmdfunction handle_map_shmemfunction handle_open_sessionfunction handle_load_ta
Annotated Snippet
if (type > TEE_OP_PARAM_TYPE_VALUE_INOUT) {
u32 buf_id = (u32)tee[i].u.memref.shm->sec_world_id;
amd->params[i].mref.buf_id = buf_id;
amd->params[i].mref.offset = tee[i].u.memref.shm_offs;
amd->params[i].mref.size = tee[i].u.memref.size;
pr_debug("%s: bufid[%d] = 0x%x, offset[%d] = 0x%x, size[%d] = 0x%x\n",
__func__,
i, amd->params[i].mref.buf_id,
i, amd->params[i].mref.offset,
i, amd->params[i].mref.size);
} else {
if (tee[i].u.value.c)
pr_warn("%s: Discarding value c", __func__);
amd->params[i].val.a = tee[i].u.value.a;
amd->params[i].val.b = tee[i].u.value.b;
pr_debug("%s: a[%d] = 0x%x, b[%d] = 0x%x\n", __func__,
i, amd->params[i].val.a,
i, amd->params[i].val.b);
}
}
return 0;
}
static int amd_params_to_tee_params(struct tee_param *tee, u32 count,
struct tee_operation *amd)
{
int i;
u32 type;
if (!count)
return 0;
if (!tee || !amd || count > TEE_MAX_PARAMS)
return -EINVAL;
/* Assumes amd->param_types is valid */
for (i = 0; i < count; i++) {
type = TEE_PARAM_TYPE_GET(amd->param_types, i);
pr_debug("%s: type[%d] = 0x%x\n", __func__, i, type);
if (type == TEE_OP_PARAM_TYPE_INVALID ||
type > TEE_OP_PARAM_TYPE_MEMREF_INOUT)
return -EINVAL;
if (type == TEE_OP_PARAM_TYPE_NONE ||
type == TEE_OP_PARAM_TYPE_VALUE_INPUT ||
type == TEE_OP_PARAM_TYPE_MEMREF_INPUT)
continue;
/*
* It is assumed that buf_id remains unchanged for
* both open_session and invoke_cmd call
*/
if (type > TEE_OP_PARAM_TYPE_MEMREF_INPUT) {
tee[i].u.memref.shm_offs = amd->params[i].mref.offset;
tee[i].u.memref.size = amd->params[i].mref.size;
pr_debug("%s: bufid[%d] = 0x%x, offset[%d] = 0x%x, size[%d] = 0x%x\n",
__func__,
i, amd->params[i].mref.buf_id,
i, amd->params[i].mref.offset,
i, amd->params[i].mref.size);
} else {
/* field 'c' not supported by AMD TEE */
tee[i].u.value.a = amd->params[i].val.a;
tee[i].u.value.b = amd->params[i].val.b;
tee[i].u.value.c = 0;
pr_debug("%s: a[%d] = 0x%x, b[%d] = 0x%x\n",
__func__,
i, amd->params[i].val.a,
i, amd->params[i].val.b);
}
}
return 0;
}
static DEFINE_MUTEX(ta_refcount_mutex);
static LIST_HEAD(ta_list);
static u32 get_ta_refcount(u32 ta_handle)
{
struct amdtee_ta_data *ta_data;
u32 count = 0;
/* Caller must hold a mutex */
list_for_each_entry(ta_data, &ta_list, list_node)
if (ta_data->ta_handle == ta_handle)
return ++ta_data->refcount;
Annotation
- Immediate include surface: `linux/device.h`, `linux/tee.h`, `linux/tee_core.h`, `linux/psp-tee.h`, `linux/slab.h`, `linux/psp.h`, `amdtee_if.h`, `amdtee_private.h`.
- Detected declarations: `function tee_params_to_amd_params`, `function amd_params_to_tee_params`, `function get_ta_refcount`, `function put_ta_refcount`, `function handle_unload_ta`, `function handle_close_session`, `function handle_unmap_shmem`, `function handle_invoke_cmd`, `function handle_map_shmem`, `function handle_open_session`.
- Atlas domain: Driver Families / drivers/tee.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.