diff mbox series

[1/2] ARM: at91: add sam_linux_is_in_normal_world() function

Message ID 20220606145701.185552-2-clement.leger@bootlin.com (mailing list archive)
State New, archived
Headers show
Series ARM: at91: add support for L2 cache write_sec() callback | expand

Commit Message

Clément Léger June 6, 2022, 2:57 p.m. UTC
Add sam_linux_is_in_normal_world() which allows to know if Linux is
running in the normal world or not. This function is used by code
which needs to differentiate the world in which Linux is running.

Signed-off-by: Clément Léger <clement.leger@bootlin.com>
---
 arch/arm/mach-at91/sam_secure.c | 6 ++++++
 arch/arm/mach-at91/sam_secure.h | 1 +
 2 files changed, 7 insertions(+)

Comments

Claudiu Beznea July 4, 2022, 6:19 a.m. UTC | #1
Hi, Clement,

On 06.06.2022 17:57, Clément Léger wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> Add sam_linux_is_in_normal_world() which allows to know if Linux is
> running in the normal world or not. This function is used by code
> which needs to differentiate the world in which Linux is running.
> 
> Signed-off-by: Clément Léger <clement.leger@bootlin.com>
> ---
>  arch/arm/mach-at91/sam_secure.c | 6 ++++++
>  arch/arm/mach-at91/sam_secure.h | 1 +
>  2 files changed, 7 insertions(+)
> 
> diff --git a/arch/arm/mach-at91/sam_secure.c b/arch/arm/mach-at91/sam_secure.c
> index 2a01f7a7d13f..1ec8c8b9d119 100644
> --- a/arch/arm/mach-at91/sam_secure.c
> +++ b/arch/arm/mach-at91/sam_secure.c
> @@ -27,6 +27,12 @@ struct arm_smccc_res sam_smccc_call(u32 fn, u32 arg0, u32 arg1)
>         return res;
>  }
> 
> +bool sam_linux_is_in_normal_world(void)
> +{
> +       /* If optee has been detected, then we are running in normal world */

In case optee hasn't been detected don't we run also in normal world?
What I want to say is that maybe you can change the function name to
something like sam_linux_is_optee_available().

Thank you,
Claudiu Beznea

> +       return optee_available;
> +}
> +
>  void __init sam_secure_init(void)
>  {
>         struct device_node *np;
> diff --git a/arch/arm/mach-at91/sam_secure.h b/arch/arm/mach-at91/sam_secure.h
> index 1e7d8b20ba1e..6d8c01f9c5f0 100644
> --- a/arch/arm/mach-at91/sam_secure.h
> +++ b/arch/arm/mach-at91/sam_secure.h
> @@ -14,5 +14,6 @@
> 
>  void __init sam_secure_init(void);
>  struct arm_smccc_res sam_smccc_call(u32 fn, u32 arg0, u32 arg1);
> +bool sam_linux_is_in_normal_world(void);
> 
>  #endif /* SAM_SECURE_H */
> --
> 2.36.1
>
Clément Léger July 4, 2022, 5:34 p.m. UTC | #2
Le 2022-07-04 08:19, Claudiu.Beznea@microchip.com a écrit :
> Hi, Clement,
> 
> On 06.06.2022 17:57, Clément Léger wrote:
>> EXTERNAL EMAIL: Do not click links or open attachments unless you know 
>> the content is safe
>> 
>> Add sam_linux_is_in_normal_world() which allows to know if Linux is
>> running in the normal world or not. This function is used by code
>> which needs to differentiate the world in which Linux is running.
>> 
>> Signed-off-by: Clément Léger <clement.leger@bootlin.com>
>> ---
>>  arch/arm/mach-at91/sam_secure.c | 6 ++++++
>>  arch/arm/mach-at91/sam_secure.h | 1 +
>>  2 files changed, 7 insertions(+)
>> 
>> diff --git a/arch/arm/mach-at91/sam_secure.c 
>> b/arch/arm/mach-at91/sam_secure.c
>> index 2a01f7a7d13f..1ec8c8b9d119 100644
>> --- a/arch/arm/mach-at91/sam_secure.c
>> +++ b/arch/arm/mach-at91/sam_secure.c
>> @@ -27,6 +27,12 @@ struct arm_smccc_res sam_smccc_call(u32 fn, u32 
>> arg0, u32 arg1)
>>         return res;
>>  }
>> 
>> +bool sam_linux_is_in_normal_world(void)
>> +{
>> +       /* If optee has been detected, then we are running in normal 
>> world */
> 
> In case optee hasn't been detected don't we run also in normal world?
> What I want to say is that maybe you can change the function name to
> something like sam_linux_is_optee_available().

I would say it depends on the bootloader configuration, but Linux can 
run
in secure world also. It would not change a lot of thing though.
However, you are right sam_linux_optee_is_available() seems easier to
understand ;)

Clément
Claudiu Beznea July 20, 2022, 8:29 a.m. UTC | #3
On 04.07.2022 20:34, clement.leger@bootlin.com wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the
> content is safe
> 
> Le 2022-07-04 08:19, Claudiu.Beznea@microchip.com a écrit :
>> Hi, Clement,
>>
>> On 06.06.2022 17:57, Clément Léger wrote:
>>> EXTERNAL EMAIL: Do not click links or open attachments unless you know
>>> the content is safe
>>>
>>> Add sam_linux_is_in_normal_world() which allows to know if Linux is
>>> running in the normal world or not. This function is used by code
>>> which needs to differentiate the world in which Linux is running.
>>>
>>> Signed-off-by: Clément Léger <clement.leger@bootlin.com>
>>> ---
>>>  arch/arm/mach-at91/sam_secure.c | 6 ++++++
>>>  arch/arm/mach-at91/sam_secure.h | 1 +
>>>  2 files changed, 7 insertions(+)
>>>
>>> diff --git a/arch/arm/mach-at91/sam_secure.c
>>> b/arch/arm/mach-at91/sam_secure.c
>>> index 2a01f7a7d13f..1ec8c8b9d119 100644
>>> --- a/arch/arm/mach-at91/sam_secure.c
>>> +++ b/arch/arm/mach-at91/sam_secure.c
>>> @@ -27,6 +27,12 @@ struct arm_smccc_res sam_smccc_call(u32 fn, u32
>>> arg0, u32 arg1)
>>>         return res;
>>>  }
>>>
>>> +bool sam_linux_is_in_normal_world(void)
>>> +{
>>> +       /* If optee has been detected, then we are running in normal
>>> world */
>>
>> In case optee hasn't been detected don't we run also in normal world?
>> What I want to say is that maybe you can change the function name to
>> something like sam_linux_is_optee_available().
> 
> I would say it depends on the bootloader configuration, but Linux can
> run
> in secure world also. It would not change a lot of thing though.
> However, you are right sam_linux_optee_is_available() seems easier to
> understand ;)

Changed the name and applied it to at91-soc, thanks!

> 
> Clément
diff mbox series

Patch

diff --git a/arch/arm/mach-at91/sam_secure.c b/arch/arm/mach-at91/sam_secure.c
index 2a01f7a7d13f..1ec8c8b9d119 100644
--- a/arch/arm/mach-at91/sam_secure.c
+++ b/arch/arm/mach-at91/sam_secure.c
@@ -27,6 +27,12 @@  struct arm_smccc_res sam_smccc_call(u32 fn, u32 arg0, u32 arg1)
 	return res;
 }
 
+bool sam_linux_is_in_normal_world(void)
+{
+	/* If optee has been detected, then we are running in normal world */
+	return optee_available;
+}
+
 void __init sam_secure_init(void)
 {
 	struct device_node *np;
diff --git a/arch/arm/mach-at91/sam_secure.h b/arch/arm/mach-at91/sam_secure.h
index 1e7d8b20ba1e..6d8c01f9c5f0 100644
--- a/arch/arm/mach-at91/sam_secure.h
+++ b/arch/arm/mach-at91/sam_secure.h
@@ -14,5 +14,6 @@ 
 
 void __init sam_secure_init(void);
 struct arm_smccc_res sam_smccc_call(u32 fn, u32 arg0, u32 arg1);
+bool sam_linux_is_in_normal_world(void);
 
 #endif /* SAM_SECURE_H */