From patchwork Mon Jan 4 12:54:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 59131 Delivered-To: patches@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp5340501lbb; Mon, 4 Jan 2016 04:55:20 -0800 (PST) X-Received: by 10.194.88.10 with SMTP id bc10mr97549325wjb.49.1451912117728; Mon, 04 Jan 2016 04:55:17 -0800 (PST) Return-Path: Received: from mail-wm0-x22a.google.com (mail-wm0-x22a.google.com. [2a00:1450:400c:c09::22a]) by mx.google.com with ESMTPS id a17si92819312wjx.30.2016.01.04.04.55.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jan 2016 04:55:17 -0800 (PST) Received-SPF: pass (google.com: domain of jens.wiklander@linaro.org designates 2a00:1450:400c:c09::22a as permitted sender) client-ip=2a00:1450:400c:c09::22a; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 2a00:1450:400c:c09::22a as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dkim=pass header.i=@linaro.org Received: by mail-wm0-x22a.google.com with SMTP id b14so183205353wmb.1 for ; Mon, 04 Jan 2016 04:55:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3PIC6DDfWadD7J/I8NuKaUg8pePRNuKiG9MdWIhgqiQ=; b=S3rpWBYViMYMs0IF5wCG2TE84ljvNVVTj6vZioao2Tnp8/C+L2HLfZH5c5dOGhb5u7 AQ81/U7ZcDw6QixBQjh1x9gcioXvLcTPsdzLlGCNUrudJH+3QFGMTeqwsLZWKuJfrXPT 9Di9IgCeC9QhPHdjaJXIsh6mD2iSiDCLbkUqU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3PIC6DDfWadD7J/I8NuKaUg8pePRNuKiG9MdWIhgqiQ=; b=UeHo3iWqOUgIwX+1O+ZZf+3+/9vlKxvtGFYRpMvGGayOdgqq79MloIg4dD0w0Ln0Kt tHUZZWvXE7eVVYOLQQFd3wjONTwIxuTFpuZtYJoEJD2VcT1ZYUHuKiGoT7RlSox+EGSR RiFI03iN6gN6Szlb9O3sE/rvbGLNcjEzle+brrXIZdjlSYCpU1hGu6JbiQYQq1QiaV5b CRsnPXYwt2v4n0PFezgUKdaPIesDZ870stFgoy2zWLM1drhpyEAWcLLd/qV/1XI/m0Mq ZfUwBBHUs5N+yPglfIHCt+MBuWVKVJdsR9LeUmDdOYxlfHqGMywL5B1ePf34r1DeQmW2 rucQ== X-Gm-Message-State: ALoCoQkSGJCWXXz/fO4dHVLz8oSqvS0/qINw6WynfE9BjKHMDtvAN67jvp0cDN8n9CEbLEmNvaJIGo34CxdKc/weNcWl6HlhYA== X-Received: by 10.28.144.196 with SMTP id s187mr43766309wmd.9.1451912117509; Mon, 04 Jan 2016 04:55:17 -0800 (PST) Return-Path: Received: from ermac.urgonet (h-84-45.a175.priv.bahnhof.se. [79.136.84.45]) by smtp.gmail.com with ESMTPSA id j3sm62408812wmj.19.2016.01.04.04.55.15 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 04 Jan 2016 04:55:16 -0800 (PST) From: Jens Wiklander To: linux-arm-kernel@lists.infradead.org, Russell King Cc: Arnd Bergmann , Mark Rutland , Will Deacon , Catalin Marinas , Lorenzo Pieralisi , Kevin Hilman , Lars Persson , tyler.baker@linaro.org, Jens Wiklander Subject: [PATCH v8 2/4] arm: add implementation for arm-smccc Date: Mon, 4 Jan 2016 13:54:37 +0100 Message-Id: <1451912079-29258-3-git-send-email-jens.wiklander@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1451912079-29258-1-git-send-email-jens.wiklander@linaro.org> References: <1451912079-29258-1-git-send-email-jens.wiklander@linaro.org> Adds implementation for arm-smccc and enables CONFIG_HAVE_SMCCC for architectures that may support arm-smccc. It's the responsibility of the caller to know if the SMC instruction is supported by the platform. Reviewed-by: Lars Persson Signed-off-by: Jens Wiklander --- arch/arm/Kconfig | 1 + arch/arm/kernel/Makefile | 2 ++ arch/arm/kernel/armksyms.c | 6 +++++ arch/arm/kernel/smccc-call.S | 62 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 arch/arm/kernel/smccc-call.S -- 1.9.1 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 34e1569..36b9490 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -37,6 +37,7 @@ config ARM select HAVE_ARCH_KGDB if !CPU_ENDIAN_BE32 select HAVE_ARCH_SECCOMP_FILTER if (AEABI && !OABI_COMPAT) select HAVE_ARCH_TRACEHOOK + select HAVE_ARM_SMCCC if CPU_V7 select HAVE_BPF_JIT select HAVE_CC_STACKPROTECTOR select HAVE_CONTEXT_TRACKING diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index af9e59b..d2d0042 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-$(CONFIG_HAVE_ARM_SMCCC) += smccc-call.o + extra-y := $(head-y) vmlinux.lds diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c index f89811f..7e45f69 100644 --- a/arch/arm/kernel/armksyms.c +++ b/arch/arm/kernel/armksyms.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -175,3 +176,8 @@ EXPORT_SYMBOL(__gnu_mcount_nc); EXPORT_SYMBOL(__pv_phys_pfn_offset); EXPORT_SYMBOL(__pv_offset); #endif + +#ifdef CONFIG_HAVE_ARM_SMCCC +EXPORT_SYMBOL(arm_smccc_smc); +EXPORT_SYMBOL(arm_smccc_hvc); +#endif diff --git a/arch/arm/kernel/smccc-call.S b/arch/arm/kernel/smccc-call.S new file mode 100644 index 0000000..2e48b67 --- /dev/null +++ b/arch/arm/kernel/smccc-call.S @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2015, Linaro Limited + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + * + */ +#include + +#include +#include +#include + + /* + * Wrap c macros in asm macros to delay expansion until after the + * SMCCC asm macro is expanded. + */ + .macro SMCCC_SMC + __SMC(0) + .endm + + .macro SMCCC_HVC + __HVC(0) + .endm + + .macro SMCCC instr +UNWIND( .fnstart) + mov r12, sp + push {r4-r7} +UNWIND( .save {r4-r7}) + ldm r12, {r4-r7} + \instr + pop {r4-r7} + ldr r12, [sp, #(4 * 4)] + stm r12, {r0-r3} + bx lr +UNWIND( .fnend) + .endm + +/* + * void smccc_smc(unsigned long a0, unsigned long a1, unsigned long a2, + * unsigned long a3, unsigned long a4, unsigned long a5, + * unsigned long a6, unsigned long a7, struct arm_smccc_res *res) + */ +ENTRY(arm_smccc_smc) + SMCCC SMCCC_SMC +ENDPROC(arm_smccc_smc) + +/* + * void smccc_hvc(unsigned long a0, unsigned long a1, unsigned long a2, + * unsigned long a3, unsigned long a4, unsigned long a5, + * unsigned long a6, unsigned long a7, struct arm_smccc_res *res) + */ +ENTRY(arm_smccc_hvc) + SMCCC SMCCC_HVC +ENDPROC(arm_smccc_hvc)