diff mbox series

[v7,4/5] xen/arm: optee: check if OP-TEE is virtualization-aware

Message ID 20190619175333.29938-5-volodymyr_babchuk@epam.com (mailing list archive)
State New, archived
Headers show
Series TEE mediator (and OP-TEE) support in XEN | expand

Commit Message

Volodymyr Babchuk June 19, 2019, 5:54 p.m. UTC
This is workaround for OP-TEE 3.5. This is the first OP-TEE release
which supports virtualization, but there is no way to tell if
OP-TEE was built with that support enabled. We can probe for it
by calling SMC that is available only when OP-TEE is built with
virtualization support.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
---
 xen/arch/arm/tee/optee.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Julien Grall July 7, 2019, 6:32 p.m. UTC | #1
Hi Volodymyr,

On 6/19/19 6:54 PM, Volodymyr Babchuk wrote:
> This is workaround for OP-TEE 3.5. This is the first OP-TEE release
> which supports virtualization, but there is no way to tell if
> OP-TEE was built with that support enabled. We can probe for it
> by calling SMC that is available only when OP-TEE is built with
> virtualization support.
> 
> Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>

Acked-by: Julien Grall <julien.grall@arm.com>

Cheers,

> ---
>   xen/arch/arm/tee/optee.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c
> index 28d34360fc..14381d6b2d 100644
> --- a/xen/arch/arm/tee/optee.c
> +++ b/xen/arch/arm/tee/optee.c
> @@ -172,6 +172,16 @@ static bool optee_probe(void)
>           return false;
>       }
>   
> +    /*
> +     * Workaround: OP-TEE 3.5 have no way to tell if it is build with
> +     * virtualization support. But we can probe for OPTEE_SMC_VM_DESTROYED
> +     * call. It will return OPTEE_SMC_RETURN_UNKNOWN_FUNCTION if
> +     * OP-TEE have no virtualization support enabled.
> +     */
> +    arm_smccc_smc(OPTEE_SMC_VM_DESTROYED, 0, 0, 0, 0, 0, 0, 0, &resp);
> +    if ( resp.a0 == OPTEE_SMC_RETURN_UNKNOWN_FUNCTION )
> +        return false;
> +
>       return true;
>   }
>   
>
diff mbox series

Patch

diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c
index 28d34360fc..14381d6b2d 100644
--- a/xen/arch/arm/tee/optee.c
+++ b/xen/arch/arm/tee/optee.c
@@ -172,6 +172,16 @@  static bool optee_probe(void)
         return false;
     }
 
+    /*
+     * Workaround: OP-TEE 3.5 have no way to tell if it is build with
+     * virtualization support. But we can probe for OPTEE_SMC_VM_DESTROYED
+     * call. It will return OPTEE_SMC_RETURN_UNKNOWN_FUNCTION if
+     * OP-TEE have no virtualization support enabled.
+     */
+    arm_smccc_smc(OPTEE_SMC_VM_DESTROYED, 0, 0, 0, 0, 0, 0, 0, &resp);
+    if ( resp.a0 == OPTEE_SMC_RETURN_UNKNOWN_FUNCTION )
+        return false;
+
     return true;
 }