Skip to contentSkip to conversation

arm: Add generic smc wrapper

RFC In review Lars Persson 3 participants 3 messages Oct 1, 2015 – Oct 2, 2015 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

RFC 1/1 arm: Add generic smc wrapper

This adds an smc wrapper according to the ARM standard for secure monitor calling conventions (ARM DEN 0028A).

---
 arch/arm/include/asm/smc-call.h | 12 ++++++++++++
 arch/arm/kernel/Makefile        |  2 ++
 arch/arm/kernel/smc-call.S      | 22 ++++++++++++++++++++++
 3 files changed, 36 insertions(+)
 create mode 100644 arch/arm/include/asm/smc-call.h
 create mode 100644 arch/arm/kernel/smc-call.S
arch/arm/include/asm/smc-call.h new file +12 -0
new file mode 100644
index 0000000..88a83d4
@@ -0,0 +1,12 @@
+/*
+ * Wrapper for secure monitor calls using the ARM SMC calling
+ * convention.
+ */
+#ifndef __ASM_SMC_CALL_H
+#define __ASM_SMC_CALL_H
+
+#include <linux/types.h>
+
+extern int invoke_smc(u32 function_id, u32 arg0, u32 arg1, u32 arg2);
+
+#endif
arch/arm/kernel/Makefile +2 -0
index af9e59b..f09d2d6 100644
@@ -92,4 +92,6 @@ obj-y				+= psci-call.o
 obj-$(CONFIG_SMP)		+= psci_smp.o
 endif
 
+obj-y		+= smc-call.o
+
 extra-y := $(head-y) vmlinux.lds
arch/arm/kernel/smc-call.S new file +22 -0
new file mode 100644
index 0000000..a07ebf9
@@ -0,0 +1,22 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Copied from: psci-call.S.
+ */
+
+#include <linux/linkage.h>
+
+#include <asm/opcodes-sec.h>
+
+/* int invoke_smc(u32 function_id, u32 arg0, u32 arg1, u32 arg2) */
+ENTRY(invoke_smc)
+	__SMC(0)
+	bx	lr
+ENDPROC(invoke_smc)
Signature · 1 line
2.1.4
#1 lore raw
config: arm-rpc_defconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross #…

Hi Lars,

[auto build test results on v4.3-rc3 -- if it's inappropriate base, please ignore]

config: arm-rpc_defconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm

All error/warnings (new ones prefixed by >>):

arch/arm/kernel/smc-call.S: Assembler messages:

>> arch/arm/kernel/smc-call.S:21: Error: selected processor does not support ARM mode `bx lr'

vim +21 arch/arm/kernel/smc-call.S

    15	
    16	#include <asm/opcodes-sec.h>
    17	
    18	/* int invoke_smc(u32 function_id, u32 arg0, u32 arg1, u32 arg2) */
    19	ENTRY(invoke_smc)
    20		__SMC(0)
  > 21		bx	lr
    22	ENDPROC(invoke_smc)

---
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/octet-stream
Size: 12414 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151002/a8a9624f/attachment-0001.obj>

#2 lore raw
Quoted 11 lines · On Friday 02 October 2015 13:13:24 kbuild test robot wrote:
    15  
    16  #include <asm/opcodes-sec.h>
    17  
    18  /* int invoke_smc(u32 function_id, u32 arg0, u32 arg1, u32 arg2) */
    19  ENTRY(invoke_smc)
    20          __SMC(0)
Quoted 1 line

21 bx lr

22 ENDPROC(invoke_smc)

Maybe compile this only for ARMv6 and ARMv7? The error was for an ARMv3/v4 build, which has neither SMC nor bx.

Arnd