diff mbox

[RFC] arm: Add generic smc wrapper

Message ID 1443701047-10101-1-git-send-email-larper@axis.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lars Persson Oct. 1, 2015, 12:04 p.m. UTC
This adds an smc wrapper according to the ARM standard for secure
monitor calling conventions (ARM DEN 0028A).

Signed-off-by: Lars Persson <larper@axis.com>
---
 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

Comments

kernel test robot Oct. 2, 2015, 5:13 a.m. UTC | #1
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
Arnd Bergmann Oct. 2, 2015, 10:16 p.m. UTC | #2
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)
>   > 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
diff mbox

Patch

diff --git a/arch/arm/include/asm/smc-call.h b/arch/arm/include/asm/smc-call.h
new file mode 100644
index 0000000..88a83d4
--- /dev/null
+++ b/arch/arm/include/asm/smc-call.h
@@ -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
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index af9e59b..f09d2d6 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -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
diff --git a/arch/arm/kernel/smc-call.S b/arch/arm/kernel/smc-call.S
new file mode 100644
index 0000000..a07ebf9
--- /dev/null
+++ b/arch/arm/kernel/smc-call.S
@@ -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)