From patchwork Wed Nov 11 10:04:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 56373 Delivered-To: patches@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1269302lbb; Wed, 11 Nov 2015 02:04:56 -0800 (PST) X-Received: by 10.112.161.168 with SMTP id xt8mr4100379lbb.88.1447236296624; Wed, 11 Nov 2015 02:04:56 -0800 (PST) Return-Path: Received: from mail-lf0-x229.google.com (mail-lf0-x229.google.com. [2a00:1450:4010:c07::229]) by mx.google.com with ESMTPS id jv8si5554780lbc.86.2015.11.11.02.04.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Nov 2015 02:04:56 -0800 (PST) Received-SPF: pass (google.com: domain of jens.wiklander@linaro.org designates 2a00:1450:4010:c07::229 as permitted sender) client-ip=2a00:1450:4010:c07::229; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 2a00:1450:4010:c07::229 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dkim=pass header.i=@linaro_org.20150623.gappssmtp.com Received: by lffu14 with SMTP id u14so13582991lff.1 for ; Wed, 11 Nov 2015 02:04:56 -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=pVnoitGUPomrFxf/exaKJu7dkGE6aOb5gaKtx7dkeEI=; b=Fe2fs/O7pOWYbzwjK0g+BVh9nrMYSqu5fsst5Hv2vD2mJ8l8s3c0ZYIMkGIQiufP5M 2AXtsqTUJ8Gg6hwBGmmwJT6t3MQAnohAnxN1drTZ8gBjJka46J/kISCNKjK5Znw6e0u6 d5iFuveeYh0ATOznV24XjA1HYYZRQD5/qnKrlIZ6kuyB7EVWAuVpINhH5gRzvPFcmzoO Ebtes4J300/FUEeZC9JHKd9Ud+Jtz0twk9e8cfIJlMFjU5qFlDjN9qKuHYYpCcW+Zz8v XPBWN7xiCkyuZZ11+otKZTFFVrYCku7nkAE0uW+64Nd6F22VXU9RoC9sH7nzdGhc7bQ3 ql/A== 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=pVnoitGUPomrFxf/exaKJu7dkGE6aOb5gaKtx7dkeEI=; b=KmaHjhUrwMkkKBU3sP7Z1n5U9PGMCHQH9L4THlXwma58540j/5BNxFlnK410Y67Cw7 nFnGG5OmLOR61Fg9iRpyuDPiVvLr0DmeRXRqq3E+FEuMqQk0NatVHSz/dw6xJDekh3N6 8bZ26szPFSwOW5442zgN1Jw2KJKGcFNnYdkC88XMIIEGLMTY9bGI5KMFd2pryCZSzZ3w SvIC/RtW5Wg69cJcQQyxdGOMXkrM/CVLDXgBJ/01vqFdndNG5y3QumeGsLrsjBoEbeW9 ZAU/E75GFeMoIVv9O/emchq7tmbCOolHCYXV3QpwwowXNhXtrhdqRwdC+6fHDAxJSThz 2b0A== X-Gm-Message-State: ALoCoQmNeypebvts1F2zaJkNLob9iDJDEpmNOrUhR2fumvewps1m0Uxl2RmmAsn8CzK8bFVhuE/H X-Received: by 10.25.154.203 with SMTP id c194mr4163510lfe.32.1447236296438; Wed, 11 Nov 2015 02:04:56 -0800 (PST) Return-Path: Received: from ermac.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 102sm1344558lft.21.2015.11.11.02.04.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Nov 2015 02:04:55 -0800 (PST) From: Jens Wiklander To: linux-arm-kernel@lists.infradead.org, Arnd Bergmann , Mark Rutland , Will Deacon , Catalin Marinas , Russell King Cc: Lars Persson , Jens Wiklander Subject: [PATCH v2 3/4] arm64: add implementation for arm-smccc Date: Wed, 11 Nov 2015 11:04:25 +0100 Message-Id: <1447236266-7491-4-git-send-email-jens.wiklander@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447236266-7491-1-git-send-email-jens.wiklander@linaro.org> References: <1447236266-7491-1-git-send-email-jens.wiklander@linaro.org> Adds implementation for arm-smccc and enables CONFIG_HAVE_SMCCC. Signed-off-by: Jens Wiklander --- arch/arm64/Kconfig | 1 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/asm-offsets.c | 3 +++ arch/arm64/kernel/smccc-call.S | 43 +++++++++++++++++++++++++++++++++++++++++ arch/arm64/kernel/smccc.c | 18 +++++++++++++++++ 5 files changed, 66 insertions(+) create mode 100644 arch/arm64/kernel/smccc-call.S create mode 100644 arch/arm64/kernel/smccc.c -- 1.9.1 diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 07d1811..a7332ca 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -89,6 +89,7 @@ config ARM64 select SPARSE_IRQ select SYSCTL_EXCEPTION_TRACE select HAVE_CONTEXT_TRACKING + select HAVE_ARM_SMCCC help ARM 64-bit (AArch64) Linux support. diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 22dc9bc..c61d758 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -36,6 +36,7 @@ arm64-obj-$(CONFIG_EFI) += efi.o efi-stub.o efi-entry.o arm64-obj-$(CONFIG_PCI) += pci.o arm64-obj-$(CONFIG_ARMV8_DEPRECATED) += armv8_deprecated.o arm64-obj-$(CONFIG_ACPI) += acpi.o +arm64-obj-$(CONFIG_HAVE_ARM_SMCCC) += smccc-call.o smccc.o obj-y += $(arm64-obj-y) vdso/ obj-m += $(arm64-obj-m) diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c index 8d89cf8..cfa0885 100644 --- a/arch/arm64/kernel/asm-offsets.c +++ b/arch/arm64/kernel/asm-offsets.c @@ -28,6 +28,7 @@ #include #include #include +#include int main(void) { @@ -161,5 +162,7 @@ int main(void) DEFINE(SLEEP_SAVE_SP_PHYS, offsetof(struct sleep_save_sp, save_ptr_stash_phys)); DEFINE(SLEEP_SAVE_SP_VIRT, offsetof(struct sleep_save_sp, save_ptr_stash)); #endif + DEFINE(ARM_SMCCC_RES_X0_OFFS, offsetof(struct arm_smccc_res, a0)); + DEFINE(ARM_SMCCC_RES_X2_OFFS, offsetof(struct arm_smccc_res, a2)); return 0; } diff --git a/arch/arm64/kernel/smccc-call.S b/arch/arm64/kernel/smccc-call.S new file mode 100644 index 0000000..ae0496f --- /dev/null +++ b/arch/arm64/kernel/smccc-call.S @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015, Linaro Limited + * + * 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. + * + */ +#include +#include + + .macro SMCCC instr + .cfi_startproc + \instr #0 + ldr x4, [sp] + stp x0, x1, [x4, #ARM_SMCCC_RES_X0_OFFS] + stp x2, x3, [x4, #ARM_SMCCC_RES_X2_OFFS] + ret + .cfi_endproc + .endm + +/* + * void arm_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 smc +ENDPROC(arm_smccc_smc) + +/* + * void arm_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 hvc +ENDPROC(arm_smccc_hvc) diff --git a/arch/arm64/kernel/smccc.c b/arch/arm64/kernel/smccc.c new file mode 100644 index 0000000..7941210 --- /dev/null +++ b/arch/arm64/kernel/smccc.c @@ -0,0 +1,18 @@ +/* + * 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 + +EXPORT_SYMBOL_GPL(arm_smccc_smc); +EXPORT_SYMBOL_GPL(arm_smccc_hvc);