Skip to content

Commit 9012f6b

Browse files
jenswi-linaroAlex Shi
authored andcommitted
ARM: 8480/2: arm64: add implementation for arm-smccc
Adds implementation for arm-smccc and enables CONFIG_HAVE_SMCCC. Acked-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> (cherry picked from commit 14457459f9ca2ff8521686168ea179edc3a56a44) Signed-off-by: Alex Shi <alex.shi@linaro.org>
1 parent cfec979 commit 9012f6b

5 files changed

Lines changed: 53 additions & 1 deletion

File tree

arch/arm64/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ config ARM64
9292
select SPARSE_IRQ
9393
select SYSCTL_EXCEPTION_TRACE
9494
select HAVE_CONTEXT_TRACKING
95+
select HAVE_ARM_SMCCC
9596
help
9697
ARM 64-bit (AArch64) Linux support.
9798

arch/arm64/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ arm64-obj-y := debug-monitors.o entry.o irq.o fpsimd.o \
1717
hyp-stub.o psci.o psci-call.o cpu_ops.o insn.o \
1818
return_address.o cpuinfo.o cpu_errata.o \
1919
cpufeature.o alternative.o cacheinfo.o \
20-
smp.o smp_spin_table.o topology.o
20+
smp.o smp_spin_table.o topology.o smccc-call.o
2121

2222
extra-$(CONFIG_EFI) := efi-entry.o
2323

arch/arm64/kernel/arm64ksyms.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/syscalls.h>
2727
#include <linux/uaccess.h>
2828
#include <linux/io.h>
29+
#include <linux/arm-smccc.h>
2930

3031
#include <asm/checksum.h>
3132

@@ -68,3 +69,7 @@ EXPORT_SYMBOL(test_and_change_bit);
6869
#ifdef CONFIG_FUNCTION_TRACER
6970
EXPORT_SYMBOL(_mcount);
7071
#endif
72+
73+
/* arm-smccc */
74+
EXPORT_SYMBOL(arm_smccc_smc);
75+
EXPORT_SYMBOL(arm_smccc_hvc);

arch/arm64/kernel/asm-offsets.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <asm/suspend.h>
2929
#include <asm/vdso_datapage.h>
3030
#include <linux/kbuild.h>
31+
#include <linux/arm-smccc.h>
3132

3233
int main(void)
3334
{
@@ -162,5 +163,7 @@ int main(void)
162163
DEFINE(SLEEP_SAVE_SP_PHYS, offsetof(struct sleep_save_sp, save_ptr_stash_phys));
163164
DEFINE(SLEEP_SAVE_SP_VIRT, offsetof(struct sleep_save_sp, save_ptr_stash));
164165
#endif
166+
DEFINE(ARM_SMCCC_RES_X0_OFFS, offsetof(struct arm_smccc_res, a0));
167+
DEFINE(ARM_SMCCC_RES_X2_OFFS, offsetof(struct arm_smccc_res, a2));
165168
return 0;
166169
}

arch/arm64/kernel/smccc-call.S

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2015, Linaro Limited
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License Version 2 as
6+
* published by the Free Software Foundation.
7+
*
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*
13+
*/
14+
#include <linux/linkage.h>
15+
#include <asm/asm-offsets.h>
16+
17+
.macro SMCCC instr
18+
.cfi_startproc
19+
\instr #0
20+
ldr x4, [sp]
21+
stp x0, x1, [x4, #ARM_SMCCC_RES_X0_OFFS]
22+
stp x2, x3, [x4, #ARM_SMCCC_RES_X2_OFFS]
23+
ret
24+
.cfi_endproc
25+
.endm
26+
27+
/*
28+
* void arm_smccc_smc(unsigned long a0, unsigned long a1, unsigned long a2,
29+
* unsigned long a3, unsigned long a4, unsigned long a5,
30+
* unsigned long a6, unsigned long a7, struct arm_smccc_res *res)
31+
*/
32+
ENTRY(arm_smccc_smc)
33+
SMCCC smc
34+
ENDPROC(arm_smccc_smc)
35+
36+
/*
37+
* void arm_smccc_hvc(unsigned long a0, unsigned long a1, unsigned long a2,
38+
* unsigned long a3, unsigned long a4, unsigned long a5,
39+
* unsigned long a6, unsigned long a7, struct arm_smccc_res *res)
40+
*/
41+
ENTRY(arm_smccc_hvc)
42+
SMCCC hvc
43+
ENDPROC(arm_smccc_hvc)

0 commit comments

Comments
 (0)