[v2,2/3] ARM: OMAP2+: Introduce check for OP-TEE in omap_secure_init()
diff mbox series

Message ID 20191217234745.4434-3-afd@ti.com
State New
Headers show
Series
  • Use ARM SMC Calling Convention when OP-TEE is available
Related show

Commit Message

Andrew F. Davis Dec. 17, 2019, 11:47 p.m. UTC
This check and associated flag can be used to signal the presence
of OP-TEE on the platform. This can be used to determine which
SMC calls to make to perform secure operations.

Signed-off-by: Andrew F. Davis <afd@ti.com>
---
 arch/arm/mach-omap2/omap-secure.c | 14 ++++++++++++++
 arch/arm/mach-omap2/omap-secure.h |  3 +++
 2 files changed, 17 insertions(+)

Comments

Tony Lindgren Dec. 18, 2019, 12:53 a.m. UTC | #1
* Andrew F. Davis <afd@ti.com> [191217 23:48]:
> --- a/arch/arm/mach-omap2/omap-secure.c
> +++ b/arch/arm/mach-omap2/omap-secure.c
> @@ -20,6 +21,18 @@
>  
>  static phys_addr_t omap_secure_memblock_base;
>  
> +bool optee_available;

The above can be static bool optee_available?

> --- a/arch/arm/mach-omap2/omap-secure.h
> +++ b/arch/arm/mach-omap2/omap-secure.h
> @@ -10,6 +10,8 @@
>  #ifndef OMAP_ARCH_OMAP_SECURE_H
>  #define OMAP_ARCH_OMAP_SECURE_H
>  
> +#include <linux/types.h>
> +
>  /* Monitor error code */
>  #define  API_HAL_RET_VALUE_NS2S_CONVERSION_ERROR	0xFFFFFFFE
>  #define  API_HAL_RET_VALUE_SERVICE_UNKNWON		0xFFFFFFFF
> @@ -72,6 +74,7 @@ extern u32 rx51_secure_dispatcher(u32 idx, u32 process, u32 flag, u32 nargs,
>  extern u32 rx51_secure_update_aux_cr(u32 set_bits, u32 clear_bits);
>  extern u32 rx51_secure_rng_call(u32 ptr, u32 count, u32 flag);
>  
> +extern bool optee_available;
>  void omap_secure_init(void);

And then this change should not be needed, right?

Otherwise series looks OK to me, thanks for updating it.

Regards,

Tony
Andrew F. Davis Dec. 18, 2019, 1 a.m. UTC | #2
On 12/17/19 7:53 PM, Tony Lindgren wrote:
> * Andrew F. Davis <afd@ti.com> [191217 23:48]:
>> --- a/arch/arm/mach-omap2/omap-secure.c
>> +++ b/arch/arm/mach-omap2/omap-secure.c
>> @@ -20,6 +21,18 @@
>>  
>>  static phys_addr_t omap_secure_memblock_base;
>>  
>> +bool optee_available;
> 
> The above can be static bool optee_available?
> 
>> --- a/arch/arm/mach-omap2/omap-secure.h
>> +++ b/arch/arm/mach-omap2/omap-secure.h
>> @@ -10,6 +10,8 @@
>>  #ifndef OMAP_ARCH_OMAP_SECURE_H
>>  #define OMAP_ARCH_OMAP_SECURE_H
>>  
>> +#include <linux/types.h>
>> +
>>  /* Monitor error code */
>>  #define  API_HAL_RET_VALUE_NS2S_CONVERSION_ERROR	0xFFFFFFFE
>>  #define  API_HAL_RET_VALUE_SERVICE_UNKNWON		0xFFFFFFFF
>> @@ -72,6 +74,7 @@ extern u32 rx51_secure_dispatcher(u32 idx, u32 process, u32 flag, u32 nargs,
>>  extern u32 rx51_secure_update_aux_cr(u32 set_bits, u32 clear_bits);
>>  extern u32 rx51_secure_rng_call(u32 ptr, u32 count, u32 flag);
>>  
>> +extern bool optee_available;
>>  void omap_secure_init(void);
> 
> And then this change should not be needed, right?
> 


I have a staged change I'm about to post that makes use of this flag
from outside of omap-secure.c, otherwise I would have left it internal
to that file.

I could also have moved the flag in the patch that uses it, but it
seemed like an unnecessary change given I know it will be needed here soon.

Andrew


> Otherwise series looks OK to me, thanks for updating it.
> 
> Regards,
> 
> Tony
>
Tony Lindgren Dec. 30, 2019, 5:36 p.m. UTC | #3
* Andrew F. Davis <afd@ti.com> [191218 01:01]:
> On 12/17/19 7:53 PM, Tony Lindgren wrote:
> > * Andrew F. Davis <afd@ti.com> [191217 23:48]:
> >> --- a/arch/arm/mach-omap2/omap-secure.c
> >> +++ b/arch/arm/mach-omap2/omap-secure.c
> >> @@ -20,6 +21,18 @@
> >>  
> >>  static phys_addr_t omap_secure_memblock_base;
> >>  
> >> +bool optee_available;
> > 
> > The above can be static bool optee_available?
> > 
> >> --- a/arch/arm/mach-omap2/omap-secure.h
> >> +++ b/arch/arm/mach-omap2/omap-secure.h
> >> @@ -10,6 +10,8 @@
> >>  #ifndef OMAP_ARCH_OMAP_SECURE_H
> >>  #define OMAP_ARCH_OMAP_SECURE_H
> >>  
> >> +#include <linux/types.h>
> >> +
> >>  /* Monitor error code */
> >>  #define  API_HAL_RET_VALUE_NS2S_CONVERSION_ERROR	0xFFFFFFFE
> >>  #define  API_HAL_RET_VALUE_SERVICE_UNKNWON		0xFFFFFFFF
> >> @@ -72,6 +74,7 @@ extern u32 rx51_secure_dispatcher(u32 idx, u32 process, u32 flag, u32 nargs,
> >>  extern u32 rx51_secure_update_aux_cr(u32 set_bits, u32 clear_bits);
> >>  extern u32 rx51_secure_rng_call(u32 ptr, u32 count, u32 flag);
> >>  
> >> +extern bool optee_available;
> >>  void omap_secure_init(void);
> > 
> > And then this change should not be needed, right?
> > 
> 
> 
> I have a staged change I'm about to post that makes use of this flag
> from outside of omap-secure.c, otherwise I would have left it internal
> to that file.
> 
> I could also have moved the flag in the patch that uses it, but it
> seemed like an unnecessary change given I know it will be needed here soon.

OK best to post all them together. Or initially just set it static
as otherwise people reading the patches will wonder about it with
no user. And all the automated test systems will start sending out
patches :)

Regards,

Tony
Andrew F. Davis Dec. 30, 2019, 6:40 p.m. UTC | #4
On 12/30/19 12:36 PM, Tony Lindgren wrote:
> * Andrew F. Davis <afd@ti.com> [191218 01:01]:
>> On 12/17/19 7:53 PM, Tony Lindgren wrote:
>>> * Andrew F. Davis <afd@ti.com> [191217 23:48]:
>>>> --- a/arch/arm/mach-omap2/omap-secure.c
>>>> +++ b/arch/arm/mach-omap2/omap-secure.c
>>>> @@ -20,6 +21,18 @@
>>>>  
>>>>  static phys_addr_t omap_secure_memblock_base;
>>>>  
>>>> +bool optee_available;
>>>
>>> The above can be static bool optee_available?
>>>
>>>> --- a/arch/arm/mach-omap2/omap-secure.h
>>>> +++ b/arch/arm/mach-omap2/omap-secure.h
>>>> @@ -10,6 +10,8 @@
>>>>  #ifndef OMAP_ARCH_OMAP_SECURE_H
>>>>  #define OMAP_ARCH_OMAP_SECURE_H
>>>>  
>>>> +#include <linux/types.h>
>>>> +
>>>>  /* Monitor error code */
>>>>  #define  API_HAL_RET_VALUE_NS2S_CONVERSION_ERROR	0xFFFFFFFE
>>>>  #define  API_HAL_RET_VALUE_SERVICE_UNKNWON		0xFFFFFFFF
>>>> @@ -72,6 +74,7 @@ extern u32 rx51_secure_dispatcher(u32 idx, u32 process, u32 flag, u32 nargs,
>>>>  extern u32 rx51_secure_update_aux_cr(u32 set_bits, u32 clear_bits);
>>>>  extern u32 rx51_secure_rng_call(u32 ptr, u32 count, u32 flag);
>>>>  
>>>> +extern bool optee_available;
>>>>  void omap_secure_init(void);
>>>
>>> And then this change should not be needed, right?
>>>
>>
>>
>> I have a staged change I'm about to post that makes use of this flag
>> from outside of omap-secure.c, otherwise I would have left it internal
>> to that file.
>>
>> I could also have moved the flag in the patch that uses it, but it
>> seemed like an unnecessary change given I know it will be needed here soon.
> 
> OK best to post all them together. Or initially just set it static
> as otherwise people reading the patches will wonder about it with
> no user. And all the automated test systems will start sending out
> patches :)
> 


Okay, I'll post everything together, will add the extra patch for AM43xx
HS suspend/resume that uses this to the end of this series.

Thanks,
Andrew


> Regards,
> 
> Tony
>

Patch
diff mbox series

diff --git a/arch/arm/mach-omap2/omap-secure.c b/arch/arm/mach-omap2/omap-secure.c
index e936732cdc4f..39d8070aede6 100644
--- a/arch/arm/mach-omap2/omap-secure.c
+++ b/arch/arm/mach-omap2/omap-secure.c
@@ -12,6 +12,7 @@ 
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/memblock.h>
+#include <linux/of.h>
 
 #include <asm/cacheflush.h>
 #include <asm/memblock.h>
@@ -20,6 +21,18 @@ 
 
 static phys_addr_t omap_secure_memblock_base;
 
+bool optee_available;
+
+static void __init omap_optee_init_check(void)
+{
+	struct device_node *np;
+
+	np = of_find_node_by_path("/firmware/optee");
+	if (np && of_device_is_available(np))
+		optee_available = true;
+	of_node_put(np);
+}
+
 /**
  * omap_sec_dispatcher: Routine to dispatch low power secure
  * service routines
@@ -166,4 +179,5 @@  u32 rx51_secure_rng_call(u32 ptr, u32 count, u32 flag)
 
 void __init omap_secure_init(void)
 {
+	omap_optee_init_check();
 }
diff --git a/arch/arm/mach-omap2/omap-secure.h b/arch/arm/mach-omap2/omap-secure.h
index 9aeeb236a224..78a1c4f04bbe 100644
--- a/arch/arm/mach-omap2/omap-secure.h
+++ b/arch/arm/mach-omap2/omap-secure.h
@@ -10,6 +10,8 @@ 
 #ifndef OMAP_ARCH_OMAP_SECURE_H
 #define OMAP_ARCH_OMAP_SECURE_H
 
+#include <linux/types.h>
+
 /* Monitor error code */
 #define  API_HAL_RET_VALUE_NS2S_CONVERSION_ERROR	0xFFFFFFFE
 #define  API_HAL_RET_VALUE_SERVICE_UNKNWON		0xFFFFFFFF
@@ -72,6 +74,7 @@  extern u32 rx51_secure_dispatcher(u32 idx, u32 process, u32 flag, u32 nargs,
 extern u32 rx51_secure_update_aux_cr(u32 set_bits, u32 clear_bits);
 extern u32 rx51_secure_rng_call(u32 ptr, u32 count, u32 flag);
 
+extern bool optee_available;
 void omap_secure_init(void);
 
 #ifdef CONFIG_SOC_HAS_REALTIME_COUNTER