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 3/9] arm: omap-common: add secure rom call API for secure devices
Date: Mon, 27 Jun 2016 09:19:18 -0500	[thread overview]
Message-ID: <1467037164-28093-4-git-send-email-dannenberg@ti.com> (raw)
In-Reply-To: <1467037164-28093-1-git-send-email-dannenberg@ti.com>

Adds a generic C-callable API for making secure ROM calls on OMAP and
OMAP-compatible devices. This API provides the important function of
flushing the ROM call arguments to memory from the cache, so that the
secure world will have a coherent view of those arguments. Then is
simply calls the omap_smc_sec routine.

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/Makefile     |  2 ++
 arch/arm/cpu/armv7/omap-common/sec-common.c | 51 +++++++++++++++++++++++++++++
 arch/arm/include/asm/omap_sec_common.h      | 21 ++++++++++++
 3 files changed, 74 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/omap-common/sec-common.c
 create mode 100644 arch/arm/include/asm/omap_sec_common.h

diff --git a/arch/arm/cpu/armv7/omap-common/Makefile b/arch/arm/cpu/armv7/omap-common/Makefile
index 87a7ac0..3172bae 100644
--- a/arch/arm/cpu/armv7/omap-common/Makefile
+++ b/arch/arm/cpu/armv7/omap-common/Makefile
@@ -36,3 +36,5 @@ obj-y	+= boot-common.o
 obj-y	+= lowlevel_init.o
 
 obj-y	+= mem-common.o
+
+obj-$(CONFIG_TI_SECURE_DEVICE) += sec-common.o
diff --git a/arch/arm/cpu/armv7/omap-common/sec-common.c b/arch/arm/cpu/armv7/omap-common/sec-common.c
new file mode 100644
index 0000000..4ec736f
--- /dev/null
+++ b/arch/arm/cpu/armv7/omap-common/sec-common.c
@@ -0,0 +1,51 @@
+/*
+ *
+ * Common security related functions for OMAP devices
+ *
+ * (C) Copyright 2016
+ * Texas Instruments, <www.ti.com>
+ *
+ * Daniel Allred <d-allred@ti.com>
+ * Andreas Dannenberg <dannenberg@ti.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <stdarg.h>
+
+#include <asm/arch/sys_proto.h>
+#include <asm/omap_common.h>
+#include <asm/omap_sec_common.h>
+
+static uint32_t secure_rom_call_args[5] __aligned(ARCH_DMA_MINALIGN);
+
+u32 secure_rom_call(u32 service, u32 proc_id, u32 flag, ...)
+{
+	int i;
+	u32 num_args;
+	va_list ap;
+
+	va_start(ap, flag);
+
+	num_args = va_arg(ap, u32);
+
+	if (num_args > 4)
+		return 1;
+
+	/* Copy args to aligned args structure */
+	for (i = 0; i < num_args; i++)
+		secure_rom_call_args[i + 1] = va_arg(ap, u32);
+
+	secure_rom_call_args[0] = num_args;
+
+	va_end(ap);
+
+	/* if data cache is enabled, flush the aligned args structure */
+	flush_dcache_range(
+		(unsigned int)&secure_rom_call_args[0],
+		(unsigned int)&secure_rom_call_args[0] +
+		roundup(sizeof(secure_rom_call_args), ARCH_DMA_MINALIGN));
+
+	return omap_smc_sec(service, proc_id, flag, secure_rom_call_args);
+}
diff --git a/arch/arm/include/asm/omap_sec_common.h b/arch/arm/include/asm/omap_sec_common.h
new file mode 100644
index 0000000..1f50f83
--- /dev/null
+++ b/arch/arm/include/asm/omap_sec_common.h
@@ -0,0 +1,21 @@
+/*
+ * (C) Copyright 2016
+ * Texas Instruments, <www.ti.com>
+ *
+ * Andreas Dannenberg <dannenberg@ti.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#ifndef	_OMAP_SEC_COMMON_H_
+#define	_OMAP_SEC_COMMON_H_
+
+#include <common.h>
+
+/*
+ * Invoke secure ROM API on high-security (HS) device variants. It formats
+ * the variable argument list into the format expected by the ROM code before
+ * triggering the actual low-level smc entry.
+ */
+u32 secure_rom_call(u32 service, u32 proc_id, u32 flag, ...);
+
+#endif /* _OMAP_SEC_COMMON_H_ */
-- 
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 ` [U-Boot] [PATCH v3 2/9] arm: omap-common: add secure smc entry 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, 3/9] arm: omap-common: add secure rom call API for secure devices 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-4-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