STRUCT TEE_SHM(9)
๐ struct tee_shm โ the shared memory glow-up ๐
okay so this is a page from the Kernel API Manual (section 9, kernel land, very demure very mindful) and it's literally all about struct tee_shm โ the shared memory object. it's giving "the thing that holds your bytes when the normal world and the secure world need to pass notes in class" โจ
๐ธ NAME ๐ธ
struct tee_shm โ shared memory object. that's it. that's the whole name. iconic behavior honestly ๐
๐ฆ SYNOPSIS ๐ฆ
here's the whole struct, bestie, copied exactly, do not touch:
struct tee_shm {
struct tee_context *ctx;
phys_addr_t paddr;
void *kaddr;
size_t size;
unsigned int offset;
struct page **pages;
size_t num_pages;
refcount_t refcount;
u32 flags;
int id;
u64 sec_world_id;
};
look at her. eleven fields, all main character energy ๐
โจ Members โจ
okay so now we go member by member, no skipping, i don't make the rules (i do, actually, and the rule is keep every detail):
ctxโ the context using the object. like, whose vibe is this shm attached to ๐ซถpaddrโ physical address of the shared memory. the real-real address, ngl ๐kaddrโ virtual address of the shared memory. the kernel's own little view of it ๐sizeโ size of shared memory. how much room we're working with, periodt ๐offsetโ offset of buffer in user space. where the good stuff actually starts ๐pagesโ locked pages from userspace. they're pinned down and they're staying put ๐num_pagesโ number of locked pages. gotta count 'em ๐งฎrefcountโ reference counter. classic. keeps track of how many people are holding on ๐flagsโ defined byTEE_SHM_*intee_core.h. go look at the header, i'm not doing your homework for you ๐idโ unique id of a shared memory object on this device, shared with user space. yes, user space gets to see this one, it's a whole collab ๐คsec_world_idโ secure world assigned id of this shared memory object, not used by all drivers. lowkey not every driver bothers with it, so don't assume ๐ฅ
fr fr: sec_world_id is not used by all drivers โ so don't go reading it and acting surprised if it's not what you expected. that's on you bestie ๐ญ
๐ SEE ALSO ๐
the whole friend group, all linked in Kernel file ./include/linux/tee_drv.h:
struct tee_context(9)tee_shm_alloc_kernel_buf(9)tee_shm_register_kernel_buf(9)tee_shm_register_fd(9)tee_shm_free(9)tee_shm_get_va(9)tee_shm_get_pa(9)tee_shm_get_size(9)tee_shm_get_pages(9)tee_shm_get_page_offset(9)tee_client_open_context(9)tee_client_close_context(9)tee_client_get_version(9)tee_client_open_session(9)tee_client_close_session(9)tee_client_system_session(9)tee_client_invoke_func(9)tee_client_cancel_req(9)struct tee_client_device(9)struct tee_client_driver(9)
like, that's the whole squad, go read them all, i'll wait ๐
and that's the page!! shipped from the source at ./include/linux, dated October 2026 โ so yes she's from the future and she's still slaying ๐
k bye, go write some TEE code, i believe in you ๐ง๐
๐ฆ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms