drivers/tee/tstee/core.c
Source file repositories/reference/linux-study-clean/drivers/tee/tstee/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tee/tstee/core.c- Extension
.c- Size
- 11638 bytes
- Lines
- 481
- 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.
- 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/arm_ffa.hlinux/err.hlinux/errno.hlinux/kernel.hlinux/limits.hlinux/mm.hlinux/module.hlinux/scatterlist.hlinux/slab.hlinux/tee_core.hlinux/types.hlinux/uuid.hlinux/xarray.htstee_private.h
Detected Declarations
function Copyrightfunction arg_list_from_ffa_datafunction tstee_get_versionfunction tstee_openfunction tstee_releasefunction xa_for_eachfunction tstee_open_sessionfunction tstee_close_sessionfunction tstee_invoke_funcfunction tstee_shm_registerfunction tstee_shm_unregisterfunction pool_op_allocfunction pool_op_freefunction pool_op_destroy_poolfunction tstee_check_rpc_compatiblefunction tstee_probefunction tstee_remove
Annotated Snippet
if (shm->size < req_len) {
dev_err(&ffa_dev->dev,
"request doesn't fit into shared memory buffer\n");
rc = -EINVAL;
goto out;
}
handle = shm->sec_world_id;
} else {
handle = FFA_INVALID_MEM_HANDLE;
}
ffa_args[TS_RPC_CTRL_REG] = TS_RPC_CTRL_PACK_IFACE_OPCODE(iface_id,
opcode);
ffa_args[TS_RPC_SERVICE_MEM_HANDLE_LSW] = lower_32_bits(handle);
ffa_args[TS_RPC_SERVICE_MEM_HANDLE_MSW] = upper_32_bits(handle);
ffa_args[TS_RPC_SERVICE_REQ_LEN] = req_len;
ffa_args[TS_RPC_SERVICE_CLIENT_ID] = 0;
arg_list_to_ffa_data(ffa_args, &ffa_data);
rc = ffa_dev->ops->msg_ops->sync_send_receive(ffa_dev, &ffa_data);
if (rc)
goto out;
arg_list_from_ffa_data(&ffa_data, ffa_args);
if (ffa_args[TS_RPC_SERVICE_RPC_STATUS] != TS_RPC_OK) {
dev_err(&ffa_dev->dev, "invoke_func rpc status: %d\n",
ffa_args[TS_RPC_SERVICE_RPC_STATUS]);
rc = -EINVAL;
goto out;
}
arg->ret = ffa_args[TS_RPC_SERVICE_STATUS];
if (shm && shm->size >= ffa_args[TS_RPC_SERVICE_RESP_LEN])
param[0].u.value.a = ffa_args[TS_RPC_SERVICE_RESP_LEN];
out:
if (shm)
tee_shm_put(shm);
return rc;
}
static int tstee_shm_register(struct tee_context *ctx, struct tee_shm *shm,
struct page **pages, size_t num_pages,
unsigned long start __always_unused)
{
struct tstee *tstee = tee_get_drvdata(ctx->teedev);
struct ffa_device *ffa_dev = tstee->ffa_dev;
struct ffa_mem_region_attributes mem_attr = {
.receiver = tstee->ffa_dev->vm_id,
.attrs = FFA_MEM_RW,
.flag = 0,
};
struct ffa_mem_ops_args mem_args = {
.attrs = &mem_attr,
.use_txbuf = true,
.nattrs = 1,
.flags = 0,
};
struct ffa_send_direct_data ffa_data;
struct sg_table sgt;
u32 ffa_args[FFA_DIRECT_REQ_ARG_NUM] = {};
int rc;
rc = sg_alloc_table_from_pages(&sgt, pages, num_pages, 0,
num_pages * PAGE_SIZE, GFP_KERNEL);
if (rc)
return rc;
mem_args.sg = sgt.sgl;
rc = ffa_dev->ops->mem_ops->memory_share(&mem_args);
sg_free_table(&sgt);
if (rc)
return rc;
shm->sec_world_id = mem_args.g_handle;
ffa_args[TS_RPC_CTRL_REG] =
TS_RPC_CTRL_PACK_IFACE_OPCODE(TS_RPC_MGMT_IFACE_ID,
TS_RPC_OP_RETRIEVE_MEM);
ffa_args[TS_RPC_RETRIEVE_MEM_HANDLE_LSW] =
lower_32_bits(shm->sec_world_id);
ffa_args[TS_RPC_RETRIEVE_MEM_HANDLE_MSW] =
upper_32_bits(shm->sec_world_id);
ffa_args[TS_RPC_RETRIEVE_MEM_TAG_LSW] = 0;
ffa_args[TS_RPC_RETRIEVE_MEM_TAG_MSW] = 0;
arg_list_to_ffa_data(ffa_args, &ffa_data);
Annotation
- Immediate include surface: `linux/arm_ffa.h`, `linux/err.h`, `linux/errno.h`, `linux/kernel.h`, `linux/limits.h`, `linux/mm.h`, `linux/module.h`, `linux/scatterlist.h`.
- Detected declarations: `function Copyright`, `function arg_list_from_ffa_data`, `function tstee_get_version`, `function tstee_open`, `function tstee_release`, `function xa_for_each`, `function tstee_open_session`, `function tstee_close_session`, `function tstee_invoke_func`, `function tstee_shm_register`.
- Atlas domain: Driver Families / drivers/tee.
- Implementation status: source implementation candidate.
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.