Skip to contentSkip to conversation

ARM: smccc-call: Use r12 to route secure monitor calls on TI platforms

PATCH In review Andrew F. Davis 4 participants 11 messages Sep 18, 2017 – Sep 21, 2017

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ARM: smccc-call: Use r12 to route secure monitor calls on TI platforms

Our ROM Secure Monitor(SM) uses the value in r12 to determine which service is being requested by an SMC call. This inline with the ARM recommended SMC Calling Convention(SMCCC), which partitions the values in R0 for this task, OP-TEE's SM follows the ARM recommended convention.

We need a way to signal that a call is for the OP-TEE SM and not for the ROM SM in a way that is safe for the ROM SM, in case it is still present. We do this by putting a value of 0x200 in r12 when the call is for OP-TEE or any other ARM by modifying the SMCCC caller function.

There are four combinations of events:

If the ROM SM is present and we make a legacy style SMC call, as we do in early boot, the call will not have r12 set to 0x200 as these calls go through existing mach-omap2/ SMC handlers, so all is well.

If the ROM SM is present and we make an SMCCC style call, r12 will be set to 0x200 and ROM SM will see this as an invalid service call and safely return to the normal world.

If OP-TEE is present and we make a legacy style SMC call, r12 will not be set to 0x200, and OP-TEE will emulate the functionality that the call is requesting.

If OP-TEE is present and we make an SMCC style call, r12 is checked and as it will be 0x200 we can ignore it and treat the rest of the registers in the standard SMCCC way.

To eliminate the need for other platforms to load this r12 sentinel value on every SMC call we add a TI specific SMC function that can be selected by users at run-time on TI platforms.

---
 arch/arm/kernel/armksyms.c   |  1 +
 arch/arm/kernel/smccc-call.S | 25 +++++++++++++++++++++++++
 include/linux/arm-smccc.h    | 16 ++++++++++++++++
 3 files changed, 42 insertions(+)
arch/arm/kernel/armksyms.c +1 -0
index 5266fd9ad6b4..6216c4678137 100644
@@ -182,4 +182,5 @@ EXPORT_SYMBOL(__pv_offset);
 #ifdef CONFIG_HAVE_ARM_SMCCC
 EXPORT_SYMBOL(__arm_smccc_smc);
 EXPORT_SYMBOL(__arm_smccc_hvc);
+EXPORT_SYMBOL(arm_ti_smccc_smc);
 #endif
arch/arm/kernel/smccc-call.S +25 -0
index e5d43066b889..7a30c253f284 100644
@@ -43,6 +43,21 @@ UNWIND(	.save	{r4-r7})
 UNWIND(	.fnend)
 	.endm
 
+	.macro TI_SMCCC instr
+UNWIND(	.fnstart)
+	mov	r12, sp
+	push	{r4-r11}
+UNWIND(	.save	{r4-r11})
+	ldm	r12, {r4-r7}
+	mov	r12, #0x200
+	\instr
+	pop	{r4-r11}
+	ldr	r12, [sp, #(4 * 4)]
+	stm	r12, {r0-r3}
+	bx	lr
+UNWIND(	.fnend)
+	.endm
+
 /*
  * void smccc_smc(unsigned long a0, unsigned long a1, unsigned long a2,
  *		  unsigned long a3, unsigned long a4, unsigned long a5,
@@ -62,3 +77,13 @@ ENDPROC(__arm_smccc_smc)
 ENTRY(__arm_smccc_hvc)
 	SMCCC SMCCC_HVC
 ENDPROC(__arm_smccc_hvc)
+
+/*
+ * void ti_smccc_smc(unsigned long a0, unsigned long a1, unsigned long a2,
+ *		     unsigned long a3, unsigned long a4, unsigned long a5,
+ *		     unsigned long a6, unsigned long a7,
+ *		     struct arm_smccc_res *res)
+ */
+ENTRY(arm_ti_smccc_smc)
+	TI_SMCCC SMCCC_SMC
+ENDPROC(arm_ti_smccc_smc)
include/linux/arm-smccc.h +16 -0
index 4c5bca38c653..5254c03b784a 100644
@@ -130,5 +130,21 @@ asmlinkage void __arm_smccc_hvc(unsigned long a0, unsigned long a1,
 
 #define arm_smccc_hvc_quirk(...) __arm_smccc_hvc(__VA_ARGS__)
 
+/**
+ * arm_ti_smccc_smc() - make TI SMC calls
+ * @a0-a7: arguments passed in registers 0 to 7
+ * @res: result values from registers 0 to 3
+ *
+ * This function is used to make TI style SMC calls following a TI proprietary
+ * SMC Call. The content of the supplied params are copied to registers 0 to 7
+ * and register 12 is set to a sentinel value prior to the SMC instruction.
+ * The return values are updated with the content from register 0 to 3 on
+ * return from the SMC instruction.
+ */
+asmlinkage void arm_ti_smccc_smc(unsigned long a0, unsigned long a1,
+			unsigned long a2, unsigned long a3, unsigned long a4,
+			unsigned long a5, unsigned long a6, unsigned long a7,
+			struct arm_smccc_res *res);
+
 #endif /*__ASSEMBLY__*/
 #endif /*__LINUX_ARM_SMCCC_H*/
Signature · 6 lines
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

PATCH 2/2 tee: optee: allow selection of ti-smc as a calling method

On TI platforms OP-TEE must be called using a modified SMC call, allow the selection of this though DT.

---
 Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.txt | 2 ++
 drivers/tee/optee/core.c                                           | 2 ++
 2 files changed, 4 insertions(+)
Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.txt +2 -0
index d38834c67dff..a3275ecdf186 100644
@@ -20,6 +20,8 @@ the reference implementation maintained by Linaro.
                    "hvc" : HVC #0, with the register assignments specified
 		           in drivers/tee/optee/optee_smc.h
 
+                   "ti-smc" : Similar to "smc" with TI specific register
+		              adjustments
 
 
 Example:
drivers/tee/optee/core.c +2 -0
index 7952357df9c8..dfa9de590d98 100644
@@ -441,6 +441,8 @@ static optee_invoke_fn *get_invoke_func(struct device_node *np)
 		return optee_smccc_hvc;
 	else if (!strcmp("smc", method))
 		return optee_smccc_smc;
+	else if (!strcmp("ti-smc", method))
+		return arm_ti_smccc_smc;
 
 	pr_warn("invalid \"method\" property: %s\n", method);
 	return ERR_PTR(-EINVAL);
Signature · 1 line
2.14.1
#2 lore raw

Re: [PATCH 2/2] tee: optee: allow selection of ti-smc as a calling method

Quoted 14 lines · Andrew F. Davis

On TI platforms OP-TEE must be called using a modified SMC call, allow the selection of this though DT.

---
 Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.txt | 2 ++
 drivers/tee/optee/core.c                                           | 2 ++
 2 files changed, 4 insertions(+)
Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.txt +0 -0
index d38834c67dff..a3275ecdf186 100644

Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.txt the reference implementation maintained by Linaro. · line 24

Quoted 5 lines
Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.txt +2 -0
@@ -20,6 +20,8 @@ the reference implementation maintained by Linaro.
                    "hvc" : HVC #0, with the register assignments specified
                           in drivers/tee/optee/optee_smc.h
 
+                   "ti-smc" : Similar to "smc" with TI specific register
+                             adjustments

Sigh, really? IMO, this should be determined from the compatible string. Then the next TI (or any vendor) specific thing can be handled without a DT change.

Maybe some day we'll figure out that not just h/w needs to be probe-able, but all the firmware pieces do too.

Rob

#3 lore raw

Re: [PATCH 2/2] tee: optee: allow selection of ti-smc as a calling method

Quoted 18 lines · Rob Herring
Quoted 17 lines · Andrew F. Davis

On TI platforms OP-TEE must be called using a modified SMC call, allow the selection of this though DT.

---
 Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.txt | 2 ++
 drivers/tee/optee/core.c                                           | 2 ++
 2 files changed, 4 insertions(+)
Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.txt +0 -0
index d38834c67dff..a3275ecdf186 100644
@@ -20,6 +20,8 @@ the reference implementation maintained by Linaro.
                    "hvc" : HVC #0, with the register assignments specified
                           in drivers/tee/optee/optee_smc.h
 
Quoted 7 lines

Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.txt the reference implementation maintained by Linaro. · line 24

Quoted 2 lines
Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.txt +2 -0
+                   "ti-smc" : Similar to "smc" with TI specific register
+                             adjustments

Sigh, really? IMO, this should be determined from the compatible string. Then the next TI (or any vendor) specific thing can be handled without a DT change.

Which compatible string, do you mean the OP-TEE driver check the top level platform compatible string?

Quoted 5 lines

Maybe some day we'll figure out that not just h/w needs to be probe-able, but all the firmware pieces do too.

Rob

#4 lore raw

Re: [PATCH 2/2] tee: optee: allow selection of ti-smc as a calling method

Quoted 27 lines · Andrew F. Davis
Quoted 18 lines · Rob Herring
Quoted 17 lines · Andrew F. Davis

On TI platforms OP-TEE must be called using a modified SMC call, allow the selection of this though DT.

---
 Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.txt | 2 ++
 drivers/tee/optee/core.c                                           | 2 ++
 2 files changed, 4 insertions(+)
Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.txt +0 -0
index d38834c67dff..a3275ecdf186 100644
@@ -20,6 +20,8 @@ the reference implementation maintained by Linaro.
                    "hvc" : HVC #0, with the register assignments specified
                           in drivers/tee/optee/optee_smc.h
 
Quoted 7 lines

Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.txt the reference implementation maintained by Linaro. · line 24

Quoted 2 lines
Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.txt +2 -0
+                   "ti-smc" : Similar to "smc" with TI specific register
+                             adjustments

Sigh, really? IMO, this should be determined from the compatible string. Then the next TI (or any vendor) specific thing can be handled without a DT change.

Quoted 2 lines

Which compatible string, do you mean the OP-TEE driver check the top level platform compatible string?

No, you need to have something like "ti,optee-tz" for the driver to match on because your implementation is different.

Rob

maintainer
#5 lore raw

Re: [PATCH 2/2] tee: optee: allow selection of ti-smc as a calling method

In reply to Andrew F. Davis
Quoted 14 lines · Andrew F. Davis

On TI platforms OP-TEE must be called using a modified SMC call, allow the selection of this though DT.

---
 Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.txt | 2 ++
 drivers/tee/optee/core.c                                           | 2 ++
 2 files changed, 4 insertions(+)
Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.txt +0 -0
index d38834c67dff..a3275ecdf186 100644

Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.txt the reference implementation maintained by Linaro. · line 24

Quoted 5 lines
Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.txt +2 -0
@@ -20,6 +20,8 @@ the reference implementation maintained by Linaro.
                    "hvc" : HVC #0, with the register assignments specified
 		           in drivers/tee/optee/optee_smc.h
 
+                   "ti-smc" : Similar to "smc" with TI specific register
+		              adjustments

... which are what, exactly? Specified where?

As Rob said, this should really have a new compat string.

Thanks,
Mark.

Quoted 19 lines
Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.txt +0 -0
 Example:
drivers/tee/optee/core.c +2 -0
index 7952357df9c8..dfa9de590d98 100644
@@ -441,6 +441,8 @@ static optee_invoke_fn *get_invoke_func(struct device_node *np)
 		return optee_smccc_hvc;
 	else if (!strcmp("smc", method))
 		return optee_smccc_smc;
+	else if (!strcmp("ti-smc", method))
+		return arm_ti_smccc_smc;
 
 	pr_warn("invalid \"method\" property: %s\n", method);
 	return ERR_PTR(-EINVAL);
Signature · 1 line
2.14.1
#6 lore raw

Re: [PATCH 2/2] tee: optee: allow selection of ti-smc as a calling method

In reply to Andrew F. Davis
url: https://github.com/0day-ci/linux/commits/Andrew-F-Davis/ARM-smccc-call-Use-r12-to-route-secure-monitor-calls-on-TI-platforms/20170920-052543 config: arm64-allmodconfig (attached as .config)…

Hi Andrew,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.14-rc1 next-20170919]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Andrew-F-Davis/ARM-smccc-call-Use-r12-to-route-secure-monitor-calls-on-TI-platforms/20170920-052543
config: arm64-allmodconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm64

All errors (new ones prefixed by >>):

>> ERROR: "arm_ti_smccc_smc" [drivers/tee/optee/optee.ko] undefined!

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 57549 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170920/bc8005a8/attachment-0001.gz>

#7 lore raw

Re: [PATCH 2/2] tee: optee: allow selection of ti-smc as a calling method

In reply to Andrew F. Davis
url: https://github.com/0day-ci/linux/commits/Andrew-F-Davis/ARM-smccc-call-Use-r12-to-route-secure-monitor-calls-on-TI-platforms/20170920-052543 config: arm64-defconfig (attached as .config)…

Hi Andrew,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.14-rc1 next-20170919]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Andrew-F-Davis/ARM-smccc-call-Use-r12-to-route-secure-monitor-calls-on-TI-platforms/20170920-052543
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm64

All errors (new ones prefixed by >>):

drivers/tee/optee/core.o: In function `get_invoke_func':

>> drivers/tee/optee/core.c:445: undefined reference to `arm_ti_smccc_smc'
   drivers/tee/optee/core.c:445:(.init.text+0xc0): relocation truncated to fit: R_AARCH64_ADR_PREL_PG_HI21 against undefined symbol `arm_ti_smccc_smc'
>> drivers/tee/optee/core.c:445: undefined reference to `arm_ti_smccc_smc'

vim +445 drivers/tee/optee/core.c

428
429 static optee_invoke_fn *get_invoke_func(struct device_node *np)
430 {
431 const char *method;
432
433 pr_info("probing for conduit method from DT.\n");
434
435 if (of_property_read_string(np, "method", &method)) {
436 pr_warn("missing \"method\" property\n");
437 return ERR_PTR(-ENXIO);
438 }
439
440 if (!strcmp("hvc", method))
441 return optee_smccc_hvc;
442 else if (!strcmp("smc", method))
443 return optee_smccc_smc;
444 else if (!strcmp("ti-smc", method))

 > 445			return arm_ti_smccc_smc;

446
447 pr_warn("invalid \"method\" property: %s\n", method);
448 return ERR_PTR(-EINVAL);
449 }
450

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 36756 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170920/95051a8b/attachment-0001.gz>

maintainer
#8 lore raw
In reply to Andrew F. Davis
Quoted 4 lines · Andrew F. Davis

Our ROM Secure Monitor(SM) uses the value in r12 to determine which service is being requested by an SMC call. This inline with the ARM recommended SMC Calling Convention(SMCCC), which partitions the values in R0 for this task, OP-TEE's SM follows the ARM recommended convention.

I can't parse this last sentence. What exactly is inline with the SMCCC?

AFAICT, the SMCCC says r12 is "The Intra-Procedure-call scratch register", which is not a paramter, service ID, etc.

Quoted 4 lines

We need a way to signal that a call is for the OP-TEE SM and not for the ROM SM in a way that is safe for the ROM SM, in case it is still present. We do this by putting a value of 0x200 in r12 when the call is for OP-TEE or any other ARM by modifying the SMCCC caller function.

So IIUC, you have a secure monitor which is not SMCCC compliant, but you want to use it at the same time as OP-TEE, which is SMCCC compliant.

It would be much better to have a new version of that monitor that was SMCCC compliant, and have to update the code for that, than to have to move OP-TEE away from standards compliance.

Quoted 9 lines

There are four combinations of events:

If the ROM SM is present and we make a legacy style SMC call, as we do in early boot, the call will not have r12 set to 0x200 as these calls go through existing mach-omap2/ SMC handlers, so all is well.

If the ROM SM is present and we make an SMCCC style call, r12 will be set to 0x200 and ROM SM will see this as an invalid service call and safely return to the normal world.

So you're going to describe OP-TEE as present even when it's not!?

That's simply wrong.

Quoted 3 lines

If OP-TEE is present and we make a legacy style SMC call, r12 will not be set to 0x200, and OP-TEE will emulate the functionality that the call is requesting.

AFAICT this means that OP-TEE completely replaces your existing monitor.

Please fix this properly. Implement SMCCC-compliant versions of those calls you wish to retain, and come up with a new binding for those. Describe that in the DT for systems which have OP-TEE providing these services.

Systems with the old monitor should have that descrbied in their DT, and not OP-TEE.

That completely removes the need to come up with a new OP-TEE binding extension, and aligns your FW for forward compatibility with future services.

Thanks,
Mark.

#9 lore raw
Quoted 8 lines · Mark Rutland
Quoted 4 lines · Andrew F. Davis

Our ROM Secure Monitor(SM) uses the value in r12 to determine which service is being requested by an SMC call. This inline with the ARM recommended SMC Calling Convention(SMCCC), which partitions the values in R0 for this task, OP-TEE's SM follows the ARM recommended convention.

I can't parse this last sentence. What exactly is inline with the SMCCC?

My bad, I meant "This 'is not' inline with the ARM..."

Quoted 3 lines

AFAICT, the SMCCC says r12 is "The Intra-Procedure-call scratch register", which is not a paramter, service ID, etc.

Right, which is why our old secure monitor is not inline with the SMCCC, it uses r12 and not r0.

Quoted 8 lines
Quoted 4 lines

We need a way to signal that a call is for the OP-TEE SM and not for the ROM SM in a way that is safe for the ROM SM, in case it is still present. We do this by putting a value of 0x200 in r12 when the call is for OP-TEE or any other ARM by modifying the SMCCC caller function.

So IIUC, you have a secure monitor which is not SMCCC compliant, but you want to use it at the same time as OP-TEE, which is SMCCC compliant.

Not at the same time, our old secure monitor is in ROM, it will be present anytime OP-TEE is not installed. OP-TEE is not mandatory, and so any call to the secure side must be safe for both secure monitors.

Quoted 4 lines

It would be much better to have a new version of that monitor that was SMCCC compliant, and have to update the code for that, than to have to move OP-TEE away from standards compliance.

The current monitor is part of ROM and dates back to OMAP3 days, so looks to pre-date ARM standardizing the SMCCC by several years, so I hope our lack of compliance here can be forgiven here..

Luckily, OP-TEE does not have to move away from compliance to support our platforms, it only needs to check for this sentinel value in r12, which it already has support upstream for:

https://github.com/OP-TEE/optee_os/blob/master/core/arch/arm/plat-ti/sm_platform_handler_a15.c#L34

Quoted 6 lines
Quoted 6 lines

There are four combinations of events:

If the ROM SM is present and we make a legacy style SMC call, as we do in early boot, the call will not have r12 set to 0x200 as these calls go through existing mach-omap2/ SMC handlers, so all is well.

Quoted 8 lines
Quoted 3 lines

If the ROM SM is present and we make an SMCCC style call, r12 will be set to 0x200 and ROM SM will see this as an invalid service call and safely return to the normal world.

So you're going to describe OP-TEE as present even when it's not!?

That's simply wrong.

This particular case should never happen as we only add the OP-TEE DT node after having installed OP-TEE during boot. It is listed here only for completeness and to show that it is safe even if it did occur.

Quoted 6 lines
Quoted 3 lines

If OP-TEE is present and we make a legacy style SMC call, r12 will not be set to 0x200, and OP-TEE will emulate the functionality that the call is requesting.

AFAICT this means that OP-TEE completely replaces your existing monitor.

Correct.

Quoted 5 lines

Please fix this properly. Implement SMCCC-compliant versions of those calls you wish to retain, and come up with a new binding for those. Describe that in the DT for systems which have OP-TEE providing these services.

This might not be possible, these old SMCs are made very early and are used all over our existing platform code:

git grep "smc" -- arch/arm/mach-omap2

Quoted 3 lines

Systems with the old monitor should have that descrbied in their DT, and not OP-TEE.

All systems have the old monitor by default, OP-TEE is the new and optional case, I think its node should be the entity modified when adding something OP-TEE specific like this.

Quoted 4 lines

That completely removes the need to come up with a new OP-TEE binding extension, and aligns your FW for forward compatibility with future services.

I agree this would be nice, but due to the above this may simply not be reasonably possible.

Thanks,
Andrew

Quoted 2 lines

Thanks,
Mark

maintainer
#10 lore raw
Quoted 14 lines · Andrew F. Davis
Quoted 8 lines · Mark Rutland
Quoted 4 lines · Andrew F. Davis

We need a way to signal that a call is for the OP-TEE SM and not for the ROM SM in a way that is safe for the ROM SM, in case it is still present. We do this by putting a value of 0x200 in r12 when the call is for OP-TEE or any other ARM by modifying the SMCCC caller function.

So IIUC, you have a secure monitor which is not SMCCC compliant, but you want to use it at the same time as OP-TEE, which is SMCCC compliant.

Not at the same time, our old secure monitor is in ROM, it will be present anytime OP-TEE is not installed. OP-TEE is not mandatory, and so any call to the secure side must be safe for both secure monitors.

Quoted 7 lines
Quoted 3 lines

It would be much better to have a new version of that monitor that was SMCCC compliant, and have to update the code for that, than to have to move OP-TEE away from standards compliance.

The current monitor is part of ROM and dates back to OMAP3 days, so looks to pre-date ARM standardizing the SMCCC by several years, so I hope our lack of compliance here can be forgiven here..

For the existing ROM, as that stands, certainly. I appreciate it's older than SMCCC.

Quoted 5 lines

Luckily, OP-TEE does not have to move away from compliance to support our platforms, it only needs to check for this sentinel value in r12, which it already has support upstream for:

https://github.com/OP-TEE/optee_os/blob/master/core/arch/arm/plat-ti/sm_platform_handler_a15.c#L34

That *is* a move away from compliance, as an SMCCC-compliant TEE should not look at r12, and an SMCCC-compliant client can (and will) leave arbitrary values in r12.

[...]

Quoted 13 lines
Quoted 5 lines
Quoted 3 lines

If OP-TEE is present and we make a legacy style SMC call, r12 will not be set to 0x200, and OP-TEE will emulate the functionality that the call is requesting.

AFAICT this means that OP-TEE completely replaces your existing monitor.

Correct.

Quoted 4 lines

Please fix this properly. Implement SMCCC-compliant versions of those calls you wish to retain, and come up with a new binding for those. Describe that in the DT for systems which have OP-TEE providing these services.

Quoted 4 lines

This might not be possible, these old SMCs are made very early and are used all over our existing platform code:

git grep "smc" -- arch/arm/mach-omap2

Given that one can build a multi-platform kernel, parts of the DT have already been parsed (in order to determine that the machine is an OMAP2) before any of this is executed.

These are not too early to preclude runtime switching based on the DT.

I can appreciate that it's a pain to have to alter these, but it's certainly possible, and it would eliminate the problem rather than spreading it further.

Quoted 6 lines
Quoted 2 lines

Systems with the old monitor should have that descrbied in their DT, and not OP-TEE.

All systems have the old monitor by default, OP-TEE is the new and optional case, I think its node should be the entity modified when adding something OP-TEE specific like this.

... and so the DT can also be altered to describe a new SMCCC-compliant set of OMAP2 SMCs in this case.

Thanks,
Mark.