xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] optee: enable OPTEE_SMC_SEC_CAP_MEMREF_NULL capability
@ 2021-05-07  1:39 Volodymyr Babchuk
  2021-05-10 17:36 ` Julien Grall
  0 siblings, 1 reply; 2+ messages in thread
From: Volodymyr Babchuk @ 2021-05-07  1:39 UTC (permalink / raw)
  To: xen-devel, Volodymyr Babchuk, Stefano Stabellini, Julien Grall; +Cc: tee-dev

OP-TEE mediator already have support for NULL memory references. It
was added in patch 0dbed3ad336 ("optee: allow plain TMEM buffers with
NULL address"). But it does not propagate
OPTEE_SMC_SEC_CAP_MEMREF_NULL capability flag to a guest, so well
behaving guest can't use this feature.

Note: linux optee driver honors this capability flag when handling
buffers from userspace clients, but ignores it when working with
internal calls. For instance, __optee_enumerate_devices() function
uses NULL argument to get buffer size hint from OP-TEE. This was the
reason, why "optee: allow plain TMEM buffers with NULL address" was
introduced in the first place.

This patch adds the mentioned capability to list of known
capabilities. From Linux point of view it means that userspace clients
can use this feature, which is confirmed by OP-TEE test suite:

* regression_1025 Test memref NULL and/or 0 bytes size
o regression_1025.1 Invalid NULL buffer memref registration
  regression_1025.1 OK
o regression_1025.2 Input/Output MEMREF Buffer NULL - Size 0 bytes
  regression_1025.2 OK
o regression_1025.3 Input MEMREF Buffer NULL - Size non 0 bytes
  regression_1025.3 OK
o regression_1025.4 Input MEMREF Buffer NULL over PTA invocation
  regression_1025.4 OK
  regression_1025 OK

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
 xen/arch/arm/tee/optee.c            | 3 ++-
 xen/include/asm-arm/tee/optee_smc.h | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c
index 9570dc6771..6b59027964 100644
--- a/xen/arch/arm/tee/optee.c
+++ b/xen/arch/arm/tee/optee.c
@@ -96,7 +96,8 @@
                               OPTEE_SMC_SEC_CAP_UNREGISTERED_SHM | \
-                              OPTEE_SMC_SEC_CAP_DYNAMIC_SHM)
+                              OPTEE_SMC_SEC_CAP_DYNAMIC_SHM | \
+                              OPTEE_SMC_SEC_CAP_MEMREF_NULL)
 enum optee_call_state {
diff --git a/xen/include/asm-arm/tee/optee_smc.h b/xen/include/asm-arm/tee/optee_smc.h
index d568bb2fe1..2f5c702326 100644
--- a/xen/include/asm-arm/tee/optee_smc.h
+++ b/xen/include/asm-arm/tee/optee_smc.h
@@ -244,6 +244,9 @@
 #define OPTEE_SMC_SEC_CAP_DYNAMIC_SHM		(1 << 2)
+/* Secure world supports Shared Memory with a NULL reference */
+#define OPTEE_SMC_SEC_CAP_MEMREF_NULL		(1 << 4)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-10 17:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-07  1:39 [PATCH] optee: enable OPTEE_SMC_SEC_CAP_MEMREF_NULL capability Volodymyr Babchuk
2021-05-10 17:36 ` Julien Grall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).