From patchwork Fri Mar 9 09:07:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 10270405 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 37C116016D for ; Fri, 9 Mar 2018 10:36:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2210429CF6 for ; Fri, 9 Mar 2018 10:36:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16E0E29D85; Fri, 9 Mar 2018 10:36:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7E26029CF6 for ; Fri, 9 Mar 2018 10:36:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=AcESWef2ZD/+Do1YdMsoHUz/LFrcYzb40zmhEk1ovV0=; b=Kt2fpMKwKge1Z5SL3qMZLXhpTr XagcAPhUej9ZEJM05TIFK0Lbf1rADRQ+qrs+sJStGxGDBK9YRVPh1aSrZcs2z6kgeoJ5pWsZlMNcj cuUduhbyTFEnG7T4Jka3IDCnsl+izfu7xpzuil4G5pF+MI7+qdZuZDRl/T6q1AI7VZvCx8prkFXPR trndCZQTRLebEXDs9ciY8cBJqz458kS0Eh4H350LADsruk9IaF4BHIsbd28kd9Nf3dy4BzWsxsT3y 9RKwhzDQlqlp6cYztepx4eW4mHRMM5UgujuMrFS8tKL7HfAM7OVgkDaMKEWBSdug3XYeRln7RI/IC Fq72BCLg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1euFNg-0007p4-Ko; Fri, 09 Mar 2018 10:36:08 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1euF7b-0002qN-8L for linux-arm-kernel@bombadil.infradead.org; Fri, 09 Mar 2018 10:19:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=XJPvakhpGTwfJqfdiSnQRG/ko1ltsqxwESiqqwSVUWo=; b=SR29hHCT0cAH7TJaZ63bZwOpT Jha8OFLOBS5Ak2sbnfun5Zz9JWgRIS1fSSDn+2lolySpn8jxIXHIVTU/sH6zgL1BaosxPGXLI/Cc6 juhcKF7Gtik2sVl9Pxs7eog1Lgi+Hm3mDhY/W8d2TtwVceqpFTRy19/MQGfxINUF3d/4a08YRgmsB KIKHAvDobEAc+4ZXZ5/nFn5pTYJkli0YaTdS1Gu0uAUVPbFjxjvlvlb7jeWhHDqVzaJ4OkryBtKr4 ox7Ei91vTWwYujlapKDMY7bV0tmD5N7HCYmVkilLJMFS5GdyRENwmF0RF+uhxcz1ebpIDKGTtb2YT vRgUPPQpA==; Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]) by merlin.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1euE3y-0002hF-5F for linux-arm-kernel@lists.infradead.org; Fri, 09 Mar 2018 09:11:42 +0000 Received: by mail-pf0-x241.google.com with SMTP id u5so1052630pfh.6 for ; Fri, 09 Mar 2018 01:11:31 -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=XJPvakhpGTwfJqfdiSnQRG/ko1ltsqxwESiqqwSVUWo=; b=a0In+2ueIat83pnnsE4l3TaEZKCP4O4l9W322XDBGbfLesPJjtfsr3jpKXCdwY7rQw W/FAASN8d0SeeJmnXJqqIiVUU6B6BISIVuS1WEaXY89Opid9xCqgbIPKMRtp8AypTWXY pZODU8roSfuV5gLArbxtolxuAL0Gg4eQIaPEA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XJPvakhpGTwfJqfdiSnQRG/ko1ltsqxwESiqqwSVUWo=; b=BqVAqe59iHRCP+zvlZaAg0Kay8SBRK/wyG+MsXb3ocQcvejB3ByCHyxd9tHtD8XPXG Ouc7G7GR5nOZm1JvNml/1YTlBqs6w+2wUN8rPyYDM6fV9wphn8DQqajodflmxfDIq93f 0ccXaecNSsyehI/qnhHWs25RhbbrvA0lioY9obyoTVucOZIRSgozaBehPOrXBExaLwwR Yb4U56P6r6nNDU2w9+iFmDgLGGPoydeshQAvtZzwiboeOnSk7OE0WHZnafQE6edBY+0k UtBcjq0OFDpWDEtctAJlGTyQBnkLY0hBX2Svojq+0JoyP/F1c6+dCq/KCT/xgtwJDw23 cUzA== X-Gm-Message-State: APf1xPD9he7QevDqEq6atU66gF6aSb8Q2EaXKScO+lvv2wP7+PLE4F49 lOvZT/sG/QSra+Us1QPyRLpm9A== X-Google-Smtp-Source: AG47ELulVxFisXkcxyyZSruUgF4ljha9GD7t9r4Ry8NbHzpG9ZLOAs8hWnW+Q+kbECw+WLBGI8QIMg== X-Received: by 10.98.31.79 with SMTP id f76mr29433708pff.60.1520586689370; Fri, 09 Mar 2018 01:11:29 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id c7sm1961752pfg.36.2018.03.09.01.11.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Mar 2018 01:11:28 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , broonie@linaro.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 29/39] ARM: 8480/2: arm64: add implementation for arm-smccc Date: Fri, 9 Mar 2018 17:07:12 +0800 Message-Id: <20180309090722.26279-30-alex.shi@linaro.org> X-Mailer: git-send-email 2.16.2.440.gc6284da In-Reply-To: <20180309090722.26279-1-alex.shi@linaro.org> References: <20180309090722.26279-1-alex.shi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180309_041142_245980_57334712 X-CRM114-Status: GOOD ( 20.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alex Shi , Russell King , Jens Wiklander MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jens Wiklander commit 14457459f9ca2ff8521686168ea179edc3a56a44 upstream. Adds implementation for arm-smccc and enables CONFIG_HAVE_SMCCC. Acked-by: Will Deacon Signed-off-by: Jens Wiklander Signed-off-by: Russell King Signed-off-by: Alex Shi --- arch/arm64/Kconfig | 1 + arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/arm64ksyms.c | 5 ++++ arch/arm64/kernel/asm-offsets.c | 3 +++ arch/arm64/kernel/smccc-call.S | 43 +++++++++++++++++++++++++++++++++ 5 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/kernel/smccc-call.S diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index a7cf7dd99c1c..1e233e81430e 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -92,6 +92,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 3404ad0f9d8a..fa131fc27321 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -17,7 +17,7 @@ arm64-obj-y := debug-monitors.o entry.o irq.o fpsimd.o \ hyp-stub.o psci.o psci-call.o cpu_ops.o insn.o \ return_address.o cpuinfo.o cpu_errata.o \ cpufeature.o alternative.o cacheinfo.o \ - smp.o smp_spin_table.o topology.o + smp.o smp_spin_table.o topology.o smccc-call.o extra-$(CONFIG_EFI) := efi-entry.o diff --git a/arch/arm64/kernel/arm64ksyms.c b/arch/arm64/kernel/arm64ksyms.c index 3b6d8cc9dfe0..678f30b05a45 100644 --- a/arch/arm64/kernel/arm64ksyms.c +++ b/arch/arm64/kernel/arm64ksyms.c @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -68,3 +69,7 @@ EXPORT_SYMBOL(test_and_change_bit); #ifdef CONFIG_FUNCTION_TRACER EXPORT_SYMBOL(_mcount); #endif + + /* arm-smccc */ +EXPORT_SYMBOL(arm_smccc_smc); +EXPORT_SYMBOL(arm_smccc_hvc); diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c index 087cf9a65359..7c4146a4257b 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) { @@ -162,5 +163,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 000000000000..ae0496fa4235 --- /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)