From patchwork Tue Dec 22 14:52:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 58932 Delivered-To: patches@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3282700lbb; Tue, 22 Dec 2015 06:53:04 -0800 (PST) X-Received: by 10.194.202.163 with SMTP id kj3mr26707010wjc.93.1450795984072; Tue, 22 Dec 2015 06:53:04 -0800 (PST) Return-Path: Received: from mail-wm0-x22f.google.com (mail-wm0-x22f.google.com. [2a00:1450:400c:c09::22f]) by mx.google.com with ESMTPS id a11si22344616wmi.4.2015.12.22.06.53.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:53:04 -0800 (PST) Received-SPF: pass (google.com: domain of jens.wiklander@linaro.org designates 2a00:1450:400c:c09::22f as permitted sender) client-ip=2a00:1450:400c:c09::22f; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 2a00:1450:400c:c09::22f as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dkim=pass header.i=@linaro.org Received: by mail-wm0-x22f.google.com with SMTP id l126so114768083wml.1 for ; Tue, 22 Dec 2015 06:53:03 -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=fMbbEOhtvcYv3G7K1LB1h6YbktQ+YpkBzSrfixkI6dk9nL13P+LrXuJBj3vhdXTkZp hQs+PcttSx8V+wKmPvFfBszN8O1do9bJnDc0DNWIUt0ZI7GXT3Wxe/+2N/zPmjEOi3nI uj2YSiHcnDMQwDqCH0pDL6DgYdgKRkmbKMNJs= 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=JDbrthk2K7HnaF3kkFWrjXeEr6us/u36HqPeBwpgvi+fRYb0lQJzzcUBqBfrgs69sX rOT2bctbTXrtz0tn1y/hWlKvVUb55UQA9pUx/vTuqSzJNDO3crCkIojOyKwtfdD7adMP +mEqu9X4X8pdUa+7xShORrgKESdNFa4eEsXNHm8oS/F9Y0SspKWOtR1SBc/IEONKjqDb CsHyclQLNgZe6+TeQavBWaX4yPPOPIX5X1jYAgvXNLhWtPGlzgzTNgIqNCHVFsesz82l sTMqOF06jCSeeBvLoU11TSwMAiw5fNGEB4aTjCba5YN//KvUtOEM9agvMg6mrVBk1R+e nhYg== X-Gm-Message-State: ALoCoQktmFwmtpMxzicD7qh6frQGpZyPMhSL/WOCPVbahzvpo3yayZw4fBjdw5sFEgWOSZf7Y8/OK4Pa9qOxpBbe42BnMIoUxA== X-Received: by 10.28.49.3 with SMTP id x3mr28872735wmx.53.1450795983842; Tue, 22 Dec 2015 06:53:03 -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 m65sm1753947wma.13.2015.12.22.06.53.00 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 22 Dec 2015 06:53:01 -0800 (PST) From: Jens Wiklander To: linux-arm-kernel@lists.infradead.org, Arnd Bergmann , Mark Rutland , Will Deacon , Catalin Marinas , Russell King , Lorenzo Pieralisi , Kevin Hilman Cc: Lars Persson , tyler.baker@linaro.org, Jens Wiklander Subject: [PATCH v7 2/4] arm: add implementation for arm-smccc Date: Tue, 22 Dec 2015 15:52:34 +0100 Message-Id: <1450795956-18223-3-git-send-email-jens.wiklander@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450795956-18223-1-git-send-email-jens.wiklander@linaro.org> References: <1450795956-18223-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)