From patchwork Tue Dec 8 13:28:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 57869 Delivered-To: patches@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp26937lbb; Tue, 8 Dec 2015 05:28:59 -0800 (PST) X-Received: by 10.194.121.35 with SMTP id lh3mr3806713wjb.164.1449581337621; Tue, 08 Dec 2015 05:28:57 -0800 (PST) Return-Path: Received: from mail-wm0-x22c.google.com (mail-wm0-x22c.google.com. [2a00:1450:400c:c09::22c]) by mx.google.com with ESMTPS id y10si4329321wje.16.2015.12.08.05.28.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Dec 2015 05:28:57 -0800 (PST) Received-SPF: pass (google.com: domain of jens.wiklander@linaro.org designates 2a00:1450:400c:c09::22c as permitted sender) client-ip=2a00:1450:400c:c09::22c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 2a00:1450:400c:c09::22c as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dkim=pass header.i=@linaro-org.20150623.gappssmtp.com Received: by wmww144 with SMTP id w144so181004562wmw.1 for ; Tue, 08 Dec 2015 05:28:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wNrGNkmhcq3RkOnd+b0YHaJ+P4F4g6TKns7mMwAX7EA=; b=I9awrSvlzzaZLwD/chDSvsKY2kunZvPmOLAdE2gxSOaFC9mUOLAKhqNvWXV0yoQQZE +0kt4eqYttmglGRKve/gqkaPWcoJz2GbXZYSsga6mqvMNjGN3HGuooBPVjVB2LK1KrCt HiS6Ct0HhdgajcPuvEHAhPE6pTJzYjidz13EdUtW8bte+S43zApZmisYhWeIe4BanFZ5 ypwL4XCoVM2PV9npMABwKhEa8+8fNRfcHdUftHg9LaVZFdWcnQa9fX6d/MP0OZNO4ZdR OyPb3ygQhZ9IpgN7fu2DHGumBcwL0YJnfQBPRZksm+R6TCjspRLWk0lCnyyydheSYSg3 ugvQ== 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=wNrGNkmhcq3RkOnd+b0YHaJ+P4F4g6TKns7mMwAX7EA=; b=JY/cKcjsw6tw+vKSXOx11liKkCUbOefhgGIceAxr0yp5jOQ3KE9floZBUsR6iJv6vB Zy+Xykum39JRJpHSGbsw60BrJwaVfHdy3P7rtKW/ya1nk9/NZP+UFFtrHSPUONWBpsg1 6hnuDRxMM6JPUJ9vw925IkjenjKtkqYj/eoiOt1rxjiVhklDrCw8YkhUx3ijkvgEeL2D qLLjbKKj5t+Yn/3p240KnsptFxiaYTeG/EFVjsOqlKUIHeYNzCggBtPjgTZbh0w7PMgB jQ9sy6ZS3PGA5GCVKV24+iKqVXH/tY+PaF8+wY9YaSlSCtedK7GG7IvjbKQbLF03jH1N gEPg== X-Gm-Message-State: ALoCoQl6FXsDdwvciHVCe9IQ4a7X2P2/6h7AOiaHVcF94F942GSkzn5EP1ue1GZbB0i8pEEYrVrP9V4nSnKooj4dFHVm2Z0Wyg== X-Received: by 10.28.15.146 with SMTP id 140mr26046883wmp.79.1449581337428; Tue, 08 Dec 2015 05:28:57 -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 d2sm3035327wjy.16.2015.12.08.05.28.56 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 Dec 2015 05:28:56 -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 v5 2/4] arm: add implementation for arm-smccc Date: Tue, 8 Dec 2015 14:28:33 +0100 Message-Id: <1449581315-14519-3-git-send-email-jens.wiklander@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449581315-14519-1-git-send-email-jens.wiklander@linaro.org> References: <1449581315-14519-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..f6a3167 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -327,6 +327,7 @@ config ARCH_MULTIPLATFORM select CLKSRC_OF select COMMON_CLK select GENERIC_CLOCKEVENTS + select HAVE_ARM_SMCCC if CPU_V7 select MIGHT_HAVE_PCI select MULTI_IRQ_HANDLER select SPARSE_IRQ 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)