optee: allow plain TMEM buffers with NULL address
authorVolodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Fri, 19 Jun 2020 22:34:01 +0000 (22:34 +0000)
committerStefano Stabellini <sstabellini@kernel.org>
Wed, 1 Jul 2020 17:15:07 +0000 (10:15 -0700)
commit0dbed3ad3366734fd23ee3fd1f9989c8c96b6052
tree05863ac37b1b34245d376cebf894d3c39e470667
parent5b13eb1d978e9732fe2c9826b60885b687a5c4fc
optee: allow plain TMEM buffers with NULL address

Trusted Applications use a popular approach to determine the required
size of a buffer: the client provides a memory reference with the NULL
pointer to a buffer. This is so called "Null memory reference". TA
updates the reference with the required size and returns it back to the
client. Then the client allocates a buffer of the needed size and
repeats the operation.

This behavior is described in TEE Client API Specification, paragraph
3.2.5. Memory References.

OP-TEE represents this null memory reference as a TMEM parameter with
buf_ptr = 0x0. This is the only case when we should allow a TMEM
buffer without the OPTEE_MSG_ATTR_NONCONTIG flag. This also the
special case for a buffer with OPTEE_MSG_ATTR_NONCONTIG flag.

This could lead to a potential issue, because IPA 0x0 is a valid
address, but OP-TEE will treat it as a special case. So, care should
be taken when construction OP-TEE enabled guest to make sure that such
guest have no memory at IPA 0x0 and none of its memory is mapped at PA
0x0.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
Release-acked-by: Paul Durrant <paul@xen.org>
xen/arch/arm/tee/optee.c