Skip to contentSkip to conversation

arm64: Add SMC and HVC commands

PATCH Superseded Michalis Pappas 3 participants 8 messages Apr 13, 2018 – May 8, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 arm64: Add SMC and HVC commands

This patch adds smc and hvc commands, that allow issuing Secure Monitor Calls and Hypervisor Calls conforming to the ARM SMC Calling Convention.

Add Kconfig items to allow each command can be individually enabled.

---

Changes for v2:
- Update help message with additional information on usefulness
- Remove default=n from Kconfig

Changes for v3:
- Replace dependency on ARM64 with ARM_SMCCC in Kconfig

Changes for v4:
- Add list of changes

 cmd/Kconfig  | 14 ++++++++++
 cmd/Makefile |  2 ++
 cmd/smccc.c  | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 88 insertions(+)
 create mode 100644 cmd/smccc.c
cmd/Kconfig +14 -0
index 136836d146..2176b98ccb 100644
@@ -1348,6 +1348,20 @@ config CMD_HASH
 	  saved to memory or to an environment variable. It is also possible
 	  to verify a hash against data in memory.
 
+config CMD_HVC
+	bool "Support the 'hvc' command"
+	depends on ARM_SMCCC
+	help
+	  Allows issuing Hypervisor Calls (HVCs). Mostly useful for
+	  development and testing.
+
+config CMD_SMC
+	bool "Support the 'smc' command"
+	depends on ARM_SMCCC
+	help
+	  Allows issuing Secure Monitor Calls (SMCs). Mostly useful for
+	  development and testing.
+
 config HASH_VERIFY
 	bool "hash -v"
 	depends on CMD_HASH
cmd/Makefile +2 -0
index 9a358e4801..5656a1a40a 100644
@@ -61,6 +61,7 @@ obj-$(CONFIG_CMD_FS_GENERIC) += fs.o
 obj-$(CONFIG_CMD_FUSE) += fuse.o
 obj-$(CONFIG_CMD_GETTIME) += gettime.o
 obj-$(CONFIG_CMD_GPIO) += gpio.o
+obj-$(CONFIG_CMD_HVC) += smccc.o
 obj-$(CONFIG_CMD_I2C) += i2c.o
 obj-$(CONFIG_CMD_IOTRACE) += iotrace.o
 obj-$(CONFIG_CMD_HASH) += hash.o
@@ -113,6 +114,7 @@ obj-$(CONFIG_CMD_SHA1SUM) += sha1sum.o
 obj-$(CONFIG_CMD_SETEXPR) += setexpr.o
 obj-$(CONFIG_CMD_SPI) += spi.o
 obj-$(CONFIG_CMD_STRINGS) += strings.o
+obj-$(CONFIG_CMD_SMC) += smccc.o
 obj-$(CONFIG_CMD_TERMINAL) += terminal.o
 obj-$(CONFIG_CMD_TIME) += time.o
 obj-$(CONFIG_CMD_TRACE) += trace.o
cmd/smccc.c new file +72 -0

72 lines not on this page · raw message

--
2.17.0

#1 lore raw

PATCH v4 1/1 arm64: Add SMC and HVC commands

Quoted 15 lines · Michalis Pappas

This patch adds smc and hvc commands, that allow issuing Secure Monitor Calls and Hypervisor Calls conforming to the ARM SMC Calling Convention.

Add Kconfig items to allow each command can be individually enabled.

---

Changes for v2:
- Update help message with additional information on usefulness
- Remove default=n from Kconfig

Changes for v3:
- Replace dependency on ARM64 with ARM_SMCCC in Kconfig

Quoted 8 lines

Changes for v4:
- Add list of changes

 cmd/Kconfig  | 14 ++++++++++
 cmd/Makefile |  2 ++
 cmd/smccc.c  | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 88 insertions(+)
 create mode 100644 cmd/smccc.c

Thanks.

#2 lore raw

PATCH v4 1/1 arm64: Add SMC and HVC commands

In reply to Michalis Pappas
Quoted 148 lines · Michalis Pappas

This patch adds smc and hvc commands, that allow issuing Secure Monitor Calls and Hypervisor Calls conforming to the ARM SMC Calling Convention.

Add Kconfig items to allow each command can be individually enabled.

---

Changes for v2:
- Update help message with additional information on usefulness
- Remove default=n from Kconfig

Changes for v3:
- Replace dependency on ARM64 with ARM_SMCCC in Kconfig

Changes for v4:
- Add list of changes

  cmd/Kconfig  | 14 ++++++++++
  cmd/Makefile |  2 ++
  cmd/smccc.c  | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 88 insertions(+)

create mode 100644 cmd/smccc.c

cmd/Kconfig +14 -0
index 136836d146..2176b98ccb 100644
@@ -1348,6 +1348,20 @@ config CMD_HASH
  	  saved to memory or to an environment variable. It is also possible
  	  to verify a hash against data in memory.
 
+config CMD_HVC
+	bool "Support the 'hvc' command"
+	depends on ARM_SMCCC
+	help
+	  Allows issuing Hypervisor Calls (HVCs). Mostly useful for
+	  development and testing.
+
+config CMD_SMC
+	bool "Support the 'smc' command"
+	depends on ARM_SMCCC
+	help
+	  Allows issuing Secure Monitor Calls (SMCs). Mostly useful for
+	  development and testing.
+
  config HASH_VERIFY
  	bool "hash -v"
  	depends on CMD_HASH
cmd/Makefile +2 -0
index 9a358e4801..5656a1a40a 100644
@@ -61,6 +61,7 @@ obj-$(CONFIG_CMD_FS_GENERIC) += fs.o
  obj-$(CONFIG_CMD_FUSE) += fuse.o
  obj-$(CONFIG_CMD_GETTIME) += gettime.o
  obj-$(CONFIG_CMD_GPIO) += gpio.o
+obj-$(CONFIG_CMD_HVC) += smccc.o
  obj-$(CONFIG_CMD_I2C) += i2c.o
  obj-$(CONFIG_CMD_IOTRACE) += iotrace.o
  obj-$(CONFIG_CMD_HASH) += hash.o
@@ -113,6 +114,7 @@ obj-$(CONFIG_CMD_SHA1SUM) += sha1sum.o
  obj-$(CONFIG_CMD_SETEXPR) += setexpr.o
  obj-$(CONFIG_CMD_SPI) += spi.o
  obj-$(CONFIG_CMD_STRINGS) += strings.o
+obj-$(CONFIG_CMD_SMC) += smccc.o
  obj-$(CONFIG_CMD_TERMINAL) += terminal.o
  obj-$(CONFIG_CMD_TIME) += time.o
  obj-$(CONFIG_CMD_TRACE) += trace.o
cmd/smccc.c new file +72 -1
new file mode 100644
index 0000000000..2fa7c23999
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2018
+ * Michalis Pappas <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#include <asm/psci.h>
+#include <common.h>
+#include <command.h>
+#include <linux/arm-smccc.h>
+#include <linux/compiler.h>
+#include <linux/psci.h>
+
+static int do_call(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	struct arm_smccc_res res;
+
+	unsigned long fid;
+
+	unsigned long a1;
+	unsigned long a2;
+	unsigned long a3;
+	unsigned long a4;
+	unsigned long a5;
+	unsigned long a6;
+	unsigned long a7;
+
+	if (argc < 2)
+		return CMD_RET_USAGE;
+
+	fid = simple_strtoul(argv[1], NULL, 16);
+
+	a1 = argc > 2 ? simple_strtoul(argv[2], NULL, 16) : 0;
+	a2 = argc > 3 ? simple_strtoul(argv[3], NULL, 16) : 0;
+	a3 = argc > 4 ? simple_strtoul(argv[4], NULL, 16) : 0;
+	a4 = argc > 5 ? simple_strtoul(argv[5], NULL, 16) : 0;
+	a5 = argc > 6 ? simple_strtoul(argv[6], NULL, 16) : 0;
+	a6 = argc > 7 ? simple_strtoul(argv[7], NULL, 16) : 0;
+	a7 = argc > 8 ? simple_strtoul(argv[8], NULL, 16) : 0;
+
+	if (!strcmp(argv[0], "smc"))
+		arm_smccc_smc(fid, a1, a2, a3, a4, a5, a6, a7, &res);
+	else
+		arm_smccc_hvc(fid, a1, a2, a3, a4, a5, a6, a7, &res);
+
+	printf("Res:  %ld %ld %ld %ld\n", res.a0, res.a1, res.a2, res.a3);
+
+	return 0;
+}
+
+#ifdef CONFIG_CMD_SMC
+U_BOOT_CMD(
+	smc,	8,		2,	do_call,
+	"Issue a Secure Monitor Call",
+	"<fid> [arg1 ... arg6] [id]\n"
+	"  - fid Function ID\n"
+	"  - arg SMC arguments, passed to X1-X6 (default to zero)\n"
+	"  - id  Secure OS ID / Session ID, passed to W7 (defaults to zero)\n"
+);
+#endif
+
+#ifdef CONFIG_CMD_HVC
+U_BOOT_CMD(
+	hvc,	8,		2,	do_call,
+	"Issue a Hypervisor Call",
+	"<fid> [arg1...arg7] [id]\n"
+	"  - fid Function ID\n"
+	"  - arg HVC arguments, passed to X1-X6 (default to zero)\n"
+	"  - id  Session ID, passed to W7 (defaults to zero)\n"
+);
+#endif
+
--
Quoted 2 lines

2.17.0

Hi,

all review comments have been satsified, happy to merge this one?

Thanks,

Michalis

#3 lore raw

PATCH v4 1/1 arm64: Add SMC and HVC commands

Quoted 157 lines · Michalis Pappas
Quoted 153 lines · Michalis Pappas

This patch adds smc and hvc commands, that allow issuing Secure Monitor Calls and Hypervisor Calls conforming to the ARM SMC Calling Convention.

Add Kconfig items to allow each command can be individually enabled.

---

Changes for v2:
   - Update help message with additional information on usefulness
   - Remove default=n from Kconfig

Changes for v3:
   - Replace dependency on ARM64 with ARM_SMCCC in Kconfig

Changes for v4:
   - Add list of changes

  cmd/Kconfig  | 14 ++++++++++
  cmd/Makefile |  2 ++
  cmd/smccc.c  | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++

  3 files changed, 88 insertions(+)

  create mode 100644 cmd/smccc.c

cmd/Kconfig +0 -0
index 136836d146..2176b98ccb 100644
@@ -1348,6 +1348,20 @@ config CMD_HASH

        saved to memory or to an environment variable. It is also possible
        to verify a hash against data in memory.

cmd/Kconfig +14 -0
+config CMD_HVC
+    bool "Support the 'hvc' command"
+    depends on ARM_SMCCC
+    help
+      Allows issuing Hypervisor Calls (HVCs). Mostly useful for
+      development and testing.
+
+config CMD_SMC
+    bool "Support the 'smc' command"
+    depends on ARM_SMCCC
+    help
+      Allows issuing Secure Monitor Calls (SMCs). Mostly useful for
+      development and testing.
+

  config HASH_VERIFY
      bool "hash -v"
      depends on CMD_HASH

cmd/Makefile +0 -0
index 9a358e4801..5656a1a40a 100644
@@ -61,6 +61,7 @@ obj-$(CONFIG_CMD_FS_GENERIC) += fs.o

  obj-$(CONFIG_CMD_FUSE) += fuse.o
  obj-$(CONFIG_CMD_GETTIME) += gettime.o
  obj-$(CONFIG_CMD_GPIO) += gpio.o
+obj-$(CONFIG_CMD_HVC) += smccc.o
  obj-$(CONFIG_CMD_I2C) += i2c.o
  obj-$(CONFIG_CMD_IOTRACE) += iotrace.o
  obj-$(CONFIG_CMD_HASH) += hash.o

cmd/Makefile +0 -0
@@ -113,6 +114,7 @@ obj-$(CONFIG_CMD_SHA1SUM) += sha1sum.o

  obj-$(CONFIG_CMD_SETEXPR) += setexpr.o
  obj-$(CONFIG_CMD_SPI) += spi.o
  obj-$(CONFIG_CMD_STRINGS) += strings.o
+obj-$(CONFIG_CMD_SMC) += smccc.o
  obj-$(CONFIG_CMD_TERMINAL) += terminal.o
  obj-$(CONFIG_CMD_TIME) += time.o
  obj-$(CONFIG_CMD_TRACE) += trace.o

cmd/smccc.c new file +14 -0
new file mode 100644
index 0000000000..2fa7c23999
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2018
+ * Michalis Pappas <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+#include <asm/psci.h>
+#include <common.h>
+#include <command.h>
+#include <linux/arm-smccc.h>
+#include <linux/compiler.h>
+#include <linux/psci.h>
+
+static int do_call(cmd_tbl_t *cmdtp, int flag, int argc, char * 

const argv[])

cmd/smccc.c new file +44 -0
+{
+    struct arm_smccc_res res;
+
+    unsigned long fid;
+
+    unsigned long a1;
+    unsigned long a2;
+    unsigned long a3;
+    unsigned long a4;
+    unsigned long a5;
+    unsigned long a6;
+    unsigned long a7;
+
+    if (argc < 2)
+        return CMD_RET_USAGE;
+
+    fid = simple_strtoul(argv[1], NULL, 16);
+
+    a1 = argc > 2 ? simple_strtoul(argv[2], NULL, 16) : 0;
+    a2 = argc > 3 ? simple_strtoul(argv[3], NULL, 16) : 0;
+    a3 = argc > 4 ? simple_strtoul(argv[4], NULL, 16) : 0;
+    a4 = argc > 5 ? simple_strtoul(argv[5], NULL, 16) : 0;
+    a5 = argc > 6 ? simple_strtoul(argv[6], NULL, 16) : 0;
+    a6 = argc > 7 ? simple_strtoul(argv[7], NULL, 16) : 0;
+    a7 = argc > 8 ? simple_strtoul(argv[8], NULL, 16) : 0;
+
+    if (!strcmp(argv[0], "smc"))
+        arm_smccc_smc(fid, a1, a2, a3, a4, a5, a6, a7, &res);
+    else
+        arm_smccc_hvc(fid, a1, a2, a3, a4, a5, a6, a7, &res);
+
+    printf("Res:  %ld %ld %ld %ld\n", res.a0, res.a1, res.a2, res.a3);
+
+    return 0;
+}
+
+#ifdef CONFIG_CMD_SMC
+U_BOOT_CMD(
+    smc,    8,        2,    do_call,
+    "Issue a Secure Monitor Call",
+    "<fid> [arg1 ... arg6] [id]\n"
+    "  - fid Function ID\n"
+    "  - arg SMC arguments, passed to X1-X6 (default to zero)\n"
+    "  - id  Secure OS ID / Session ID, passed to W7 (defaults to 

zero)\n"

cmd/smccc.c new file +14 -0
+);
+#endif
+
+#ifdef CONFIG_CMD_HVC
+U_BOOT_CMD(
+    hvc,    8,        2,    do_call,
+    "Issue a Hypervisor Call",
+    "<fid> [arg1...arg7] [id]\n"
+    "  - fid Function ID\n"
+    "  - arg HVC arguments, passed to X1-X6 (default to zero)\n"
+    "  - id  Session ID, passed to W7 (defaults to zero)\n"
+);
+#endif
+
Signature · 1 line
2.17.0

Hi,

Quoted 5 lines

all review comments have been satsified, happy to merge this one?

Thanks,

Michalis

Hi, any news on this one?

#4 lore raw

PATCH v4 1/1 arm64: Add SMC and HVC commands

Hi,

Quoted 27 lines · Michalis Pappas
Quoted 26 lines · Michalis Pappas
Quoted 24 lines · Michalis Pappas

This patch adds smc and hvc commands, that allow issuing Secure Monitor Calls and Hypervisor Calls conforming to the ARM SMC Calling Convention.

Add Kconfig items to allow each command can be individually enabled.

---

Changes for v2:
- Update help message with additional information on usefulness
- Remove default=n from Kconfig

Changes for v3:
- Replace dependency on ARM64 with ARM_SMCCC in Kconfig

Changes for v4:
- Add list of changes

  cmd/Kconfig  | 14 ++++++++++
  cmd/Makefile |  2 ++
  cmd/smccc.c  | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 88 insertions(+)

create mode 100644 cmd/smccc.c

[..]

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

Hi,

Quoted 9 lines
Quoted 5 lines

all review comments have been satsified, happy to merge this one?

Thanks,

Michalis

Hi, any news on this one?

You can see the patch status here: http://patchwork.ozlabs.org/patch/897869/

It is in Tom's queue. From the release page
<https://www.denx.de/wiki/U-Boot/ReleaseCycle>, the next release is 7th May, so merging should happen after that.

Regards,
Simon

#5 lore raw

PATCH v4 1/1 arm64: Add SMC and HVC commands

Quoted 5 lines · Simon Glass

You can see the patch status here:
http://patchwork.ozlabs.org/patch/897869/
<http://patchwork.ozlabs.org/patch/897869/>

Quoted 7 lines

It is in Tom's queue. From the release page
<https://www.denx.de/wiki/U-Boot/ReleaseCycle>, the next release is 7th May, so merging should happen after that.

Regards,
Simon

Hi Simon,

I wasn't aware of the above, many thanks for pointing them out

Michalis

#6 lore raw

PATCH v4 1/1 arm64: Add SMC and HVC commands

Hi,

Quoted 4 lines · Michalis Pappas

On 05/02/2018 10:32 PM, Simon Glass wrote:

You can see the patch status here:

http://patchwork.ozlabs.org/patch/897869/

Quoted 2 lines

It is in Tom's queue. From the release page, the next release is 7th May,

so

Quoted 9 lines

merging should happen after that.

Regards,
Simon

Hi Simon,

I wasn't aware of the above, many thanks for pointing them out

You're welcome!

Regards,
Simon

#7 lore raw

PATCH v4 1/1 arm64: Add SMC and HVC commands

In reply to Michalis Pappas
Quoted 7 lines · Michalis Pappas

This patch adds smc and hvc commands, that allow issuing Secure Monitor Calls and Hypervisor Calls conforming to the ARM SMC Calling Convention.

Add Kconfig items to allow each command can be individually enabled.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180508/662593cb/attachment.sig>