public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andreas Dannenberg <dannenberg@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 2/9] arm: omap-common: add secure smc entry
Date: Mon, 27 Jun 2016 09:19:17 -0500	[thread overview]
Message-ID: <1467037164-28093-3-git-send-email-dannenberg@ti.com> (raw)
In-Reply-To: <1467037164-28093-1-git-send-email-dannenberg@ti.com>

From: Daniel Allred <d-allred@ti.com>

Add an interface for calling secure ROM APIs across a range of OMAP and
OMAP compatible high-security (HS) device variants. While at it, also
perform minor cleanup/alignment without any change in functionality.

Signed-off-by: Daniel Allred <d-allred@ti.com>
Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
 arch/arm/cpu/armv7/omap-common/lowlevel_init.S | 45 ++++++++++++++++++++------
 arch/arm/include/asm/omap_common.h             |  6 ++++
 2 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap-common/lowlevel_init.S b/arch/arm/cpu/armv7/omap-common/lowlevel_init.S
index 5283135..66a3b3d 100644
--- a/arch/arm/cpu/armv7/omap-common/lowlevel_init.S
+++ b/arch/arm/cpu/armv7/omap-common/lowlevel_init.S
@@ -16,9 +16,10 @@
 #include <asm/arch/spl.h>
 #include <linux/linkage.h>
 
+.arch_extension sec
+
 #ifdef CONFIG_SPL
 ENTRY(save_boot_params)
-
 	ldr	r1, =OMAP_SRAM_SCRATCH_BOOT_PARAMS
 	str	r0, [r1]
 	b	save_boot_params_ret
@@ -26,14 +27,40 @@ ENDPROC(save_boot_params)
 #endif
 
 ENTRY(omap_smc1)
-	PUSH	{r4-r12, lr}	@ save registers - ROM code may pollute
+	push	{r4-r12, lr}	@ save registers - ROM code may pollute
 				@ our registers
-	MOV	r12, r0		@ Service
-	MOV	r0, r1		@ Argument
-	DSB
-	DMB
-	.word	0xe1600070	@ SMC #0 - hand assembled for GCC versions
-				@ call ROM Code API for the service requested
+	mov	r12, r0		@ Service
+	mov	r0, r1		@ Argument
 
-	POP	{r4-r12, pc}
+	dsb
+	dmb
+	smc	0		@ SMC #0 to enter monitor mode
+				@ call ROM Code API for the service requested
+	pop	{r4-r12, pc}
 ENDPROC(omap_smc1)
+
+ENTRY(omap_smc_sec)
+	push	{r4-r12, lr}	@ save registers - ROM code may pollute
+				@ our registers
+	mov	r6, #0xFF	@ Indicate new Task call
+	mov	r12, #0x00	@ Secure Service ID in R12
+
+	dsb
+	dmb
+	smc	0		@ SMC #0 to enter monitor mode
+
+	b	omap_smc_sec_end @ exit at end of the service execution
+	nop
+
+	@ In case of IRQ happening in Secure, then ARM will branch here.
+	@ At that moment, IRQ will be pending and ARM will jump to Non Secure
+	@ IRQ handler
+	mov	r12, #0xFE
+
+	dsb
+	dmb
+	smc	0		@ SMC #0 to enter monitor mode
+
+omap_smc_sec_end:
+	pop	{r4-r12, pc}
+ENDPROC(omap_smc_sec)
diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h
index 07f3848..605c549 100644
--- a/arch/arm/include/asm/omap_common.h
+++ b/arch/arm/include/asm/omap_common.h
@@ -627,6 +627,12 @@ void recalibrate_iodelay(void);
 
 void omap_smc1(u32 service, u32 val);
 
+/*
+ * Low-level helper function used when performing secure ROM calls on high-
+ * security (HS) device variants by doing a specially-formed smc entry.
+ */
+u32 omap_smc_sec(u32 service, u32 proc_id, u32 flag, u32 *params);
+
 void enable_edma3_clocks(void);
 void disable_edma3_clocks(void);
 
-- 
2.6.4

  parent reply	other threads:[~2016-06-27 14:19 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-27 14:19 [U-Boot] [PATCH v3 0/9] Secure Boot by Authenticating/Decrypting SPL FIT blobs Andreas Dannenberg
2016-06-27 14:19 ` [U-Boot] [PATCH v3 1/9] arm: cache: add missing dummy functions for when dcache disabled Andreas Dannenberg
2016-07-16 13:47   ` [U-Boot] [U-Boot, v3, " Tom Rini
2016-06-27 14:19 ` Andreas Dannenberg [this message]
2016-07-16 13:47   ` [U-Boot] [U-Boot, v3, 2/9] arm: omap-common: add secure smc entry Tom Rini
2016-06-27 14:19 ` [U-Boot] [PATCH v3 3/9] arm: omap-common: add secure rom call API for secure devices Andreas Dannenberg
2016-07-16 13:47   ` [U-Boot] [U-Boot, v3, " Tom Rini
2016-06-27 14:19 ` [U-Boot] [PATCH v3 4/9] arm: omap-common: secure ROM signature verify API Andreas Dannenberg
2016-07-16 13:47   ` [U-Boot] [U-Boot, v3, " Tom Rini
2016-06-27 14:19 ` [U-Boot] [PATCH v3 5/9] arm: omap-common: Update to generate secure U-Boot FIT blob Andreas Dannenberg
2016-07-16 13:47   ` [U-Boot] [U-Boot, v3, " Tom Rini
2016-06-27 14:19 ` [U-Boot] [PATCH v3 6/9] spl: fit: add support for post-processing of images Andreas Dannenberg
2016-06-29  3:28   ` Simon Glass
2016-06-29 14:19     ` Andreas Dannenberg
2016-07-16 13:47   ` [U-Boot] [U-Boot, v3, " Tom Rini
2016-06-27 14:19 ` [U-Boot] [PATCH v3 7/9] arm: omap5: add U-Boot FIT signing and SPL image post-processing Andreas Dannenberg
2016-07-16 13:47   ` [U-Boot] [U-Boot, v3, " Tom Rini
2016-06-27 14:19 ` [U-Boot] [PATCH v3 8/9] arm: am4x: " Andreas Dannenberg
2016-07-16 13:47   ` [U-Boot] [U-Boot, v3, " Tom Rini
2016-06-27 14:19 ` [U-Boot] [PATCH v3 9/9] doc: Update info on using secure devices from TI Andreas Dannenberg
2016-07-16 13:47   ` [U-Boot] [U-Boot, v3, " Tom Rini
2016-07-14 13:55 ` [U-Boot] [PATCH v3 0/9] Secure Boot by Authenticating/Decrypting SPL FIT blobs Andreas Dannenberg
2016-07-14 14:57   ` Tom Rini
2016-07-14 15:22     ` Andreas Dannenberg
2016-07-14 14:59   ` Simon Glass
2016-07-20 18:19 ` Andreas Dannenberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467037164-28093-3-git-send-email-dannenberg@ti.com \
    --to=dannenberg@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox