From: Amirreza Zarrabi via OP-TEE <op-tee@lists.trustedfirmware.org>
To: Jens Wiklander <jens.wiklander@linaro.org>,
Sumit Garg <sumit.garg@kernel.org>,
op-tee@lists.trustedfirmware.org
Subject: dma_heap and protected memory
Date: Fri, 15 May 2026 13:10:50 +1000 [thread overview]
Message-ID: <75d61a22-7c36-434a-a9f2-80533090e072@oss.qualcomm.com> (raw)
Hi Jens,
Recently protected heap support has been added for the TEE subsystem.
This allows dma-heaps to be managed by the TEE subsystem itself.
For standard, non-protected heaps such as the system heap or CMA heap,
I am trying to understand the expected usage model. One possible workaround
appears to be to mmap the dma-buf fd in userspace, then register the
resulting userspace VA with the TEE subsystem to obtain a TEE shared-memory
object, for example:
fd = dma_heap_alloc(...);
va = mmap(fd, ...);
shm_fd = tee_shm_register(va, size);
tee_invoke(shm_fd);
close(shm_fd);
munmap(va, size);
close(fd);
This seems reasonable when the lifetime of the registered shared memory
is limited to a single invocation or callback. However, I am concerned about
cases (multiple exits in qcomtee) where the TEE side needs to retain access
to the memory after the ioctl/invocation returns.
In that case, registering only the userspace VA does not appear
to keep the underlying dma-buf object alive. The TEE core pins the pages,
but it does not hold a dma-buf reference or attachment. If userspace later
closes the dma-buf fd and unmaps the VA, the dma-buf exporter may consider
the buffer released, while the TEE side may still have the memory registered.
Is there a recommended way to use standard heaps, such as the system or
CMA dma-buf heaps, when the sharing lifetime is longer than a single TEE call?
Would it make sense to extend tee_shm_register_fd() so that it can handle
dma-buf fds from regular dma-heaps as well, not only dma-bufs managed by
the TEE subsystem? That would allow the TEE core or backend driver to keep
the dma-buf reference for the lifetime of the TEE shared-memory object.
Best regards,
Amir
reply other threads:[~2026-05-15 3:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=75d61a22-7c36-434a-a9f2-80533090e072@oss.qualcomm.com \
--to=op-tee@lists.trustedfirmware.org \
--cc=amirreza.zarrabi@oss.qualcomm.com \
--cc=jens.wiklander@linaro.org \
--cc=sumit.garg@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.