xen/arm: optee: handle shared buffer translation error
authorVolodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Tue, 24 Sep 2019 15:46:45 +0000 (15:46 +0000)
committerJulien Grall <julien.grall@arm.com>
Wed, 25 Sep 2019 15:01:16 +0000 (16:01 +0100)
commitc2c141f0f4248963cedcb972534423cf9092ae52
tree97f3f554d12b23622c9bb76c94ee702dfb41e466
parentbabde47a3feda6dd4ba318e1e57bd2ee9f2c1116
xen/arm: optee: handle shared buffer translation error

There is a case possible, when OP-TEE asks guest to allocate shared
buffer, but Xen for some reason can't translate buffer's addresses. In
this situation we should do two things:

1. Tell guest to free allocated buffer, so there will be no memory
leak for guest.

2. Tell OP-TEE that buffer allocation failed.

To ask guest to free allocated buffer we should perform the same
thing, as OP-TEE does - issue RPC request. This is done by filling
request buffer (luckily we can reuse the same buffer, that OP-TEE used
to issue original request) and then return to guest with special
return code.

Then we need to handle next call from guest in a special way: as RPC
was issued by Xen, not by OP-TEE, it should be handled by Xen.
Basically, this is the mechanism to preempt OP-TEE mediator.

The same mechanism can be used in the future to preempt mediator
during translation large (>512 pages) shared buffers.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Acked-by: Julien Grall <julien.grall@arm.com>
xen/arch/arm/tee/optee.c