From patchwork Fri Nov 8 18:49:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 178925 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3122567ilf; Fri, 8 Nov 2019 10:53:03 -0800 (PST) X-Google-Smtp-Source: APXvYqx5bnvo1l2+HBt77+lzp4ldUd+IVgYGfrZcjjhNX/m4fSaU3s4LEPAOFmVIKlzFxQS2JNpk X-Received: by 2002:a17:906:298b:: with SMTP id x11mr10364048eje.257.1573239183487; Fri, 08 Nov 2019 10:53:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573239183; cv=none; d=google.com; s=arc-20160816; b=Ec/1tjoT9Wa76a+Muk0OexxZTRh6z8TlhT/8Os9KI4oVZUoj748wyFCIbg/5MZsweM oB/ORnDtT1anYvgBLeMG91moRKLvCiy88FGcKZIsBcW5wbJhcKPo5BlGg0ELWNhylTkT MVJ4msuJIa+A88r8jEj5ks31503r036jno55NaSuTkNMoIMh8pcHDHB+w//QMyQNeCwA oNhb4JEEZcROIYSrNLH2O3NX9vdriw7x7W5gWCdfeUWMp8wqzu1jQmoe/q/OwHIBOh12 t5iDBaJv70AjQ075vkSdmkXF0Rz2EmQ3/eJmcSQmYNm6NdRKrhodvDohTUdMQkobHAuQ AEWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sfDrMzOKcteZClbzlB+8Wd8kiaOGaLoXCaZFowd7DUs=; b=uSYIQLDDJ/x9E21SzYSIzaOLvFqIxQ4ChTcooL7FKfEtSbm+oZu6MaC9p7GN9B1lE8 jF4gT50xvKqxSAgSQzLz6InxJo1FVaojmgGtJnlbkffQew66q/OIluGemJQ9wE+dmxJN RsU1+iOrMdK9fckOHWGfMrM5lyZMpcMXpN/eT4CD85iqdWMj83zJugV53h43jd0JVagS TdgKcxev8jEf74GD9gUxQGx/1iNpDMlaBSfuFwvAu7T3iTdAv16ye4P9lEl/oP8c5mLC v4RUhySfAjidcrd7E1qqettXQSLil7hLv2XqPxNp74b7DnNJ35xj5vmVd+E2TGutkQsR YtAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="GVxJS/RH"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p48si4984962eda.80.2019.11.08.10.53.03; Fri, 08 Nov 2019 10:53:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="GVxJS/RH"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732061AbfKHSxC (ORCPT + 14 others); Fri, 8 Nov 2019 13:53:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:49444 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732030AbfKHSxB (ORCPT ); Fri, 8 Nov 2019 13:53:01 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E0592214DB; Fri, 8 Nov 2019 18:52:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573239179; bh=3z24VMb6w2aEusAaHy6nE0web8vjYf2I0RI5Q+3sXNU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GVxJS/RHh4/fU/DaUIxKITCgZ+g7F6pEQWkhL9zVWa14nwZeaOYwjHnLlA1exioBf 7PXSnFgrl+47XdEwerUgPDp2TcuMPXuPe12Efq66f+vIAyQ7YRrKtlgREjtZRcwHsc FtpXItvdpHeQIBpwnWqCzH33R3UdRLMElQubW/00= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Lars Persson , Jens Wiklander , Russell King , Ard Biesheuvel Subject: [PATCH 4.4 26/75] ARM: 8479/2: add implementation for arm-smccc Date: Fri, 8 Nov 2019 19:49:43 +0100 Message-Id: <20191108174733.563457851@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191108174708.135680837@linuxfoundation.org> References: <20191108174708.135680837@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jens Wiklander Commit b329f95d70f3f955093e9a2b18ac1ed3587a8f73 upstream. 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 Signed-off-by: Russell King Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- 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(+) --- 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 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile @@ -91,4 +91,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 --- 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 --- /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) From patchwork Fri Nov 8 18:49:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 178928 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3122869ilf; Fri, 8 Nov 2019 10:53:20 -0800 (PST) X-Google-Smtp-Source: APXvYqxbR2xaz73z26vMJeQDs4XNMgTjsEePWRXy+vxqwtkmSQeVsFMEXXfrqU4nKfm5vV8rNL3n X-Received: by 2002:a50:fa4a:: with SMTP id c10mr11976078edq.51.1573239200223; Fri, 08 Nov 2019 10:53:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573239200; cv=none; d=google.com; s=arc-20160816; b=XTo2+rbBWYOobJXYAADUC/0PefQmW7k95uHp1VcIvnDaS0Z9ueJ/NmAhJQYnmePwFX lMmAV12whRxuYbaCcBczaz3uaDHYzsNszS3NlDSD3j9D+q4rsVD01S/kQICYw1SS97Wr uPYTi/1cK/vBbJZXf9Q/R3wP8yLJho2v9sxIY5wJhIBlkrWj+4pTJO2+l7ZyahME107D ZqSn/GZ0zshUtFH6xxnbu1hRb5tAlIVE+g4K8AjBohz1VRo8DQ0K0QZTXev0Dwnaeiig vBbffdkrI1zeWsuLFPTKacvq2Co77zNiE0I+ThVFACzzYSX55y09zwaKDhC0sDGyoKsc +wRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Kwrq5y5M+rqYeUQWRGOgEGzpKeJ6j9ribeQVMNkzUA4=; b=B3tSwE9YwqnGcEYQkHFUw38YaJrsQS2Er3p+ut4HGkvij+g0QGA7ew6q1c8QRDA+YX CHkpoM6qUHMg1D8w3PW0C0dkpNjnALWH2dNh88jtCsBedJRO2lLwbpNIY1r84ckFW95E 0eAVtlrz1VztFrWXt0H3T529G2Zan12BEPvfx+/X/NbcrtIPPZzlL7EHwtkE7WlEgM9M BfWW3PW2eniNX3rgyI223rW9SJvkkFVWIhJUZKj2THXyq4mr4NDYPGivubKeIjG59j3+ +8wUlMl0KOkWk3JnBD1kWx8oFMu6WcAE50ehi/PiBgX7IjabrI8z7ezS1emOerjJhEmE x7hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iX4tZrDM; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m4si1526887eja.96.2019.11.08.10.53.20; Fri, 08 Nov 2019 10:53:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iX4tZrDM; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732246AbfKHSxS (ORCPT + 14 others); Fri, 8 Nov 2019 13:53:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:49842 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732122AbfKHSxR (ORCPT ); Fri, 8 Nov 2019 13:53:17 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 612BA21924; Fri, 8 Nov 2019 18:53:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573239196; bh=AUWUl9y/HXQGf4YubuBpfo8aTTh0j9s1D++vVwfuq8A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iX4tZrDMhcz+jfe8YLvX7VETYTpHP00UNyxJ+PT4Vk/2WFSxty0DxAtC5XOnWDMIp 3UcRvGCZafUBYNwEYumLCv4iR3ira5jPP2t+fCoGnusIphJPzUVpQDQVHEcXHNDBgh 3nseEteNnYoWAQC/UjGIokkYfoR3qFZLkxDFcocI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Ard Biesheuvel , Christoffer Dall , Marc Zyngier , Catalin Marinas , Greg Hackmann , Ard Biesheuvel , Mark Rutland Subject: [PATCH 4.4 31/75] arm/arm64: KVM: Advertise SMCCC v1.1 Date: Fri, 8 Nov 2019 19:49:48 +0100 Message-Id: <20191108174739.963545191@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191108174708.135680837@linuxfoundation.org> References: <20191108174708.135680837@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier commit 09e6be12effdb33bf7210c8867bbd213b66a499e upstream. The new SMC Calling Convention (v1.1) allows for a reduced overhead when calling into the firmware, and provides a new feature discovery mechanism. Make it visible to KVM guests. Tested-by: Ard Biesheuvel Reviewed-by: Christoffer Dall Signed-off-by: Marc Zyngier Signed-off-by: Catalin Marinas [v4.9: account for files moved to virt/ upstream] Signed-off-by: Mark Rutland [v4.9 backport] Tested-by: Greg Hackmann Signed-off-by: Greg Kroah-Hartman [ardb: restrict to include/linux/arm-smccc.h, drop KVM bits] Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- include/linux/arm-smccc.h | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) --- a/include/linux/arm-smccc.h +++ b/include/linux/arm-smccc.h @@ -14,9 +14,6 @@ #ifndef __LINUX_ARM_SMCCC_H #define __LINUX_ARM_SMCCC_H -#include -#include - /* * This file provides common defines for ARM SMC Calling Convention as * specified in @@ -60,6 +57,24 @@ #define ARM_SMCCC_OWNER_TRUSTED_OS 50 #define ARM_SMCCC_OWNER_TRUSTED_OS_END 63 +#define ARM_SMCCC_VERSION_1_0 0x10000 +#define ARM_SMCCC_VERSION_1_1 0x10001 + +#define ARM_SMCCC_VERSION_FUNC_ID \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_SMC_32, \ + 0, 0) + +#define ARM_SMCCC_ARCH_FEATURES_FUNC_ID \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_SMC_32, \ + 0, 1) + +#ifndef __ASSEMBLY__ + +#include +#include + /** * struct arm_smccc_res - Result from SMC/HVC call * @a0-a3 result values from registers 0 to 3 @@ -101,4 +116,5 @@ asmlinkage void arm_smccc_hvc(unsigned l unsigned long a5, unsigned long a6, unsigned long a7, struct arm_smccc_res *res); +#endif /*__ASSEMBLY__*/ #endif /*__LINUX_ARM_SMCCC_H*/ From patchwork Fri Nov 8 18:49:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 178951 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3161949ilf; Fri, 8 Nov 2019 11:24:01 -0800 (PST) X-Google-Smtp-Source: APXvYqw+ZhUO/ZpiHyrjkwtvZc7YvalnBKfXHsYM9Woj0hgpVuSRvY26sqESaU3ibc/WMiYg2Yvd X-Received: by 2002:a17:906:5859:: with SMTP id h25mr10668273ejs.2.1573241041488; Fri, 08 Nov 2019 11:24:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573241041; cv=none; d=google.com; s=arc-20160816; b=kVqX9E2P7xegRIJ8owAVwr/USc6o6KIoasSHcwhMv/TliheKh00+lRlRWMGsluZ9H7 PvgiisVLUl50SoSKsMoxHEvEfzVs8s7wFX0ppzbyY9EnvV4zZHvFZXzmb6WaniUSQJWw 4pt20ltNIGSEgD3BHhdXmyeuNBdBEwmBEq2mZ56uejNiTiX2Mk4/R7kUIyOwOIZJey57 OlpFeXILOfLwBhQ7YGfsyMh1FJvxVMW0hq8AMs5eAlBUDztc/SnGzSdPtH/DEAip34+9 reDQMmM7Clzxpbsv4AASEflZL9YT+POoekUbJpWh9UgzjKedTeaoT5ZLXEkHvEj7XugZ c8Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Re0ICCxZOABeS1fRydp7wQl5vFVi1D2Rycz8MiT/G28=; b=TKp2b7GWu8uBTfGMfzNA4xoFjAdis5EtLeM0e1DcgZiO6AZIxPna9GoWEkUFHViAw2 Hl/zymyOX2s2TWCklR/VCwLCj0CBvsbghnGxCghfrnaXMVna17vTiUpeQ8BJBMLzF2eo nm0L2VeEl/taR9dos9BVC08QezBgOiTd1jMw02XvAqGHo0XBzVJcmj61HUlvkC2sZ2P+ JCRwBJuxgglnOLDUMTN+HkpkytKLybZ8ahc6XNCFvBup1RO/qS/WTjagzjbFTTZ0TiBl 2XJ5vsWWkkN2l2IDS9NqCdFfpeWNEcqL67nxmNLeLV9S2lAEO/Fgq7Jt3a8+NvTACvOn dhCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=q+OVtS0N; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cc20si5332705edb.201.2019.11.08.11.24.01; Fri, 08 Nov 2019 11:24:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=q+OVtS0N; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388568AbfKHTYA (ORCPT + 14 others); Fri, 8 Nov 2019 14:24:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:49898 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732258AbfKHSxT (ORCPT ); Fri, 8 Nov 2019 13:53:19 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0CBD0218AE; Fri, 8 Nov 2019 18:53:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573239199; bh=BklGw2CHk0rhA5E7/1cYkeaiRWPgm4YdmDA/LT6GVH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q+OVtS0NF4D8rr5dZDM1Zj3FRU2NymJ+eWbce0Y3zKzL9Tt1lsJOzEhDwJW4n0O+4 mSX/o6Flm4gUVgwOtU7zwiXhYYyj0S7Gq++nogGII4s6RAAqjVA2kORt0VTIbS6Qtk RgH5eqa7pUZgrY1JGF+dYWc6sN+rRUEiATeJWwjs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Ard Biesheuvel , Christoffer Dall , Marc Zyngier , Catalin Marinas , Greg Hackmann , Ard Biesheuvel , Mark Rutland Subject: [PATCH 4.4 32/75] arm64: KVM: Report SMCCC_ARCH_WORKAROUND_1 BP hardening support Date: Fri, 8 Nov 2019 19:49:49 +0100 Message-Id: <20191108174741.407382517@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191108174708.135680837@linuxfoundation.org> References: <20191108174708.135680837@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier commit 6167ec5c9145cdf493722dfd80a5d48bafc4a18a upstream. A new feature of SMCCC 1.1 is that it offers firmware-based CPU workarounds. In particular, SMCCC_ARCH_WORKAROUND_1 provides BP hardening for CVE-2017-5715. If the host has some mitigation for this issue, report that we deal with it using SMCCC_ARCH_WORKAROUND_1, as we apply the host workaround on every guest exit. Tested-by: Ard Biesheuvel Reviewed-by: Christoffer Dall Signed-off-by: Marc Zyngier Signed-off-by: Catalin Marinas [v4.9: account for files moved to virt/ upstream] Signed-off-by: Mark Rutland [v4.9 backport] Tested-by: Greg Hackmann Signed-off-by: Greg Kroah-Hartman [ardb: restrict to include/linux/arm-smccc.h] Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- include/linux/arm-smccc.h | 5 +++++ 1 file changed, 5 insertions(+) --- a/include/linux/arm-smccc.h +++ b/include/linux/arm-smccc.h @@ -70,6 +70,11 @@ ARM_SMCCC_SMC_32, \ 0, 1) +#define ARM_SMCCC_ARCH_WORKAROUND_1 \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_SMC_32, \ + 0, 0x8000) + #ifndef __ASSEMBLY__ #include From patchwork Fri Nov 8 18:49:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 178929 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3122944ilf; Fri, 8 Nov 2019 10:53:25 -0800 (PST) X-Google-Smtp-Source: APXvYqwIuTojZcPXmAaw/cP9DWvFrgeoF1UawD3/kSH4EIiawPmK67PEXJ5/U78nAmN4KPYSHYDL X-Received: by 2002:aa7:d499:: with SMTP id b25mr12046258edr.64.1573239205314; Fri, 08 Nov 2019 10:53:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573239205; cv=none; d=google.com; s=arc-20160816; b=llWXj5EDAXIZod7g+TsdV1o1m/wBWVni5f1Dylo0t+k4D4ShjOv8tEpufrL9xBAZzq ItYsAXcWlYBdqdMO8hcuplTrtFfw9qLJYqFLt7pnFlyrSlZY4ctcuZDCsVXK6xocXLlT SHc/+U6jgsYZTp0hiAznLLZmM96y39AaRFPnb0/Mqha4Pap0xLsJ/rNQoliG/l/Zjl7T zjJXrRZgR7GOoHBhoORRthLRasOqf2qBQSrFmf5V5JqjC9Ks7HT7mAt/v9yU5mmib5hW BTj8MpeV3s8g0zgXx9qF8lxRAsWBCPmcEk23CgaXYnjuD/bYZKMUZHiiZgwSO2WAyBjE aOeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mfR/rlp/NEM+swxuWpS4bY3bWzKmPznWF1/gb4vYD7k=; b=a4T47IxNKQk4i0HZqiO/MMgAl4V0NOiKPHNW/e6d5Oy27vetpEUWr9TpMiB+3QhRps QER5+qLFsOGUyuA6oQoFuNV1zL8++Ron1xyjAL7zeL/ZEpDNvk6YqqfK5MPYw4y0lhly hJecFToIDVLj5lBJ2HW9HHUaxycOD870E8+nWFBcCOrg3vwm7/w716xnY6H3bADt0Dxb 4MEJJAKB0Cjc73Kimn/2ANePPuczB5cgUKHMEK6c1uR/ZmzEKK7Wk47a339IPXrncWjW X27/rdtjDvWMQwJVxELZUFXnmEWobSpatfU/1U/yQ6EOaCHDvxJkHqHV1pDI+2AbETK7 cEGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QFpJYXS9; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t17si4617768ejg.44.2019.11.08.10.53.25; Fri, 08 Nov 2019 10:53:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QFpJYXS9; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732304AbfKHSxY (ORCPT + 14 others); Fri, 8 Nov 2019 13:53:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:49990 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732293AbfKHSxX (ORCPT ); Fri, 8 Nov 2019 13:53:23 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2BE5E21924; Fri, 8 Nov 2019 18:53:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573239202; bh=uzsmDvzuczXlA0AHuxY816KKdpnievb3gfSuNS9tpm8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QFpJYXS9OzobqDbti3T9sPaW3iuKT1/kRG3gXv27CR1uHd5YVq2xZIYvgyrjUqDk3 B1HjTewpBfKPcFnhYsPRuC3KNp3/mXVUkzEo+DkWkAr8/9sJLSYiqp0/hvN4b8d5DL NlqyrCc7p20PXXsyb/MGKcGCKFbf+vxE1tMYqUb0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Lorenzo Pieralisi , Robin Murphy , Ard Biesheuvel , Marc Zyngier , Catalin Marinas , Greg Hackmann , Ard Biesheuvel , Mark Rutland Subject: [PATCH 4.4 33/75] firmware/psci: Expose PSCI conduit Date: Fri, 8 Nov 2019 19:49:50 +0100 Message-Id: <20191108174742.289495161@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191108174708.135680837@linuxfoundation.org> References: <20191108174708.135680837@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier commit 09a8d6d48499f93e2abde691f5800081cd858726 upstream. In order to call into the firmware to apply workarounds, it is useful to find out whether we're using HVC or SMC. Let's expose this through the psci_ops. Acked-by: Lorenzo Pieralisi Reviewed-by: Robin Murphy Tested-by: Ard Biesheuvel Signed-off-by: Marc Zyngier Signed-off-by: Catalin Marinas Signed-off-by: Mark Rutland [v4.9 backport] Tested-by: Greg Hackmann Signed-off-by: Greg Kroah-Hartman Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/psci.c | 28 +++++++++++++++++++++++----- include/linux/psci.h | 7 +++++++ 2 files changed, 30 insertions(+), 5 deletions(-) --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -55,7 +55,9 @@ bool psci_tos_resident_on(int cpu) return cpu == resident_cpu; } -struct psci_operations psci_ops; +struct psci_operations psci_ops = { + .conduit = PSCI_CONDUIT_NONE, +}; typedef unsigned long (psci_fn)(unsigned long, unsigned long, unsigned long, unsigned long); @@ -206,6 +208,22 @@ static unsigned long psci_migrate_info_u 0, 0, 0); } +static void set_conduit(enum psci_conduit conduit) +{ + switch (conduit) { + case PSCI_CONDUIT_HVC: + invoke_psci_fn = __invoke_psci_fn_hvc; + break; + case PSCI_CONDUIT_SMC: + invoke_psci_fn = __invoke_psci_fn_smc; + break; + default: + WARN(1, "Unexpected PSCI conduit %d\n", conduit); + } + + psci_ops.conduit = conduit; +} + static int get_set_conduit_method(struct device_node *np) { const char *method; @@ -218,9 +236,9 @@ static int get_set_conduit_method(struct } if (!strcmp("hvc", method)) { - invoke_psci_fn = __invoke_psci_fn_hvc; + set_conduit(PSCI_CONDUIT_HVC); } else if (!strcmp("smc", method)) { - invoke_psci_fn = __invoke_psci_fn_smc; + set_conduit(PSCI_CONDUIT_SMC); } else { pr_warn("invalid \"method\" property: %s\n", method); return -EINVAL; @@ -480,9 +498,9 @@ int __init psci_acpi_init(void) pr_info("probing for conduit method from ACPI.\n"); if (acpi_psci_use_hvc()) - invoke_psci_fn = __invoke_psci_fn_hvc; + set_conduit(PSCI_CONDUIT_HVC); else - invoke_psci_fn = __invoke_psci_fn_smc; + set_conduit(PSCI_CONDUIT_SMC); return psci_probe(); } --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -24,6 +24,12 @@ bool psci_tos_resident_on(int cpu); bool psci_power_state_loses_context(u32 state); bool psci_power_state_is_valid(u32 state); +enum psci_conduit { + PSCI_CONDUIT_NONE, + PSCI_CONDUIT_SMC, + PSCI_CONDUIT_HVC, +}; + struct psci_operations { int (*cpu_suspend)(u32 state, unsigned long entry_point); int (*cpu_off)(u32 state); @@ -32,6 +38,7 @@ struct psci_operations { int (*affinity_info)(unsigned long target_affinity, unsigned long lowest_affinity_level); int (*migrate_info_type)(void); + enum psci_conduit conduit; }; extern struct psci_operations psci_ops; From patchwork Fri Nov 8 18:49:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 178933 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3124236ilf; Fri, 8 Nov 2019 10:54:36 -0800 (PST) X-Google-Smtp-Source: APXvYqyEzWMEoibE7h1gf8TJCJllrxsvxmdvL72GhHnP7Qmkbn3sWh58WmC9jcmgyKTfmXH2M6j6 X-Received: by 2002:a05:6402:1397:: with SMTP id b23mr12138498edv.196.1573239276471; Fri, 08 Nov 2019 10:54:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573239276; cv=none; d=google.com; s=arc-20160816; b=rRuoozEtr1gViocMecR3jM79bRYqrMtXISvRExN1XWsrzVBU9l9CaXKqpVKdFzCTfy PpblqLQq8I+5nR+PoPEEKx47u3W1q0D7b5jvkArzrxILQOomaKkkVoAtqTKY2NZ9E4UM mH95cv8H0abeuPKXQo9k3nn5iloFE27Xx4Qq7B/EFd0UDPF0PdNj1mSWJ506wXhhDTpB 90eGyUOrY++3TugxIX2rodVBHTcsJSivPW4qDJlWw72RpFL+KUAoZfc0W926P+XjRWxS MkxEKYb4fyOpkoRa1U65agFaI8uwYg4TUZmRbO/gDheFb4m2HEmNwyLOwavnYwGqXzm7 q1aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uQ6vxliBnuqFpkNqOzpjHq9RTmEba8Ys/GT63NqsnoA=; b=tWVIbwgSmUX1s8TC/SXyEkY3A6JVO7pbYAAoS6GTJStmR5+AdvXhPgEdVKAoJi9bJx E7XaPEpQzEQhGWfoi70iSGMoUBtpVLcgMicYh3+WR8abvg3PKad1JgAxqFNUnYwTDLYp CCLRgI9AjwQQXkvEcuBgAQYbuHAKefO0g1y0vmr+JQpO5R3SfUCy0imYF8jLHQM8AgWM TYV2SCFGJdswcD1+KCBxkJ4AmXTyfSM9dx5byCUNXfLHhDBf3/9Fcma2/Crjb79nZ5Ni RPQLcQjiAzIS3RFmQEjV+/idwJOpnXy+uyhkt+PqCy3tsW504hIeczmWT04pUhkBwdUu 2o7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kqDSjdTo; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o1si4166483eje.298.2019.11.08.10.54.36; Fri, 08 Nov 2019 10:54:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kqDSjdTo; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732947AbfKHSy2 (ORCPT + 14 others); Fri, 8 Nov 2019 13:54:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:51406 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727559AbfKHSyY (ORCPT ); Fri, 8 Nov 2019 13:54:24 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 05C9521D7F; Fri, 8 Nov 2019 18:54:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573239263; bh=wuf/8sbxeqrQDFNdCPZk/wONDsGgggqmt0P9phCsHPw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kqDSjdToNN75Z3F7RHqMFbpj8vzvJn04Rtk5RFbvtL7OkfKaUjX7znVyMIHI2TRz+ jeqSlXFaHV6bZCIL77GdlC3/9ngkU2qJoEw9UXkNtoLvctIMtLhVVAZRUDFzKoJMMi lP7k4f8lFrIr83s9em7RHdCqhgARc6yAebEiZlRI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Julien Grall , Marc Zyngier , Will Deacon , Sasha Levin , Ard Biesheuvel Subject: [PATCH 4.4 38/75] arm/arm64: smccc-1.1: Make return values unsigned long Date: Fri, 8 Nov 2019 19:49:55 +0100 Message-Id: <20191108174746.463484664@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191108174708.135680837@linuxfoundation.org> References: <20191108174708.135680837@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier [ Upstream commit 1d8f574708a3fb6f18c85486d0c5217df893c0cf ] An unfortunate consequence of having a strong typing for the input values to the SMC call is that it also affects the type of the return values, limiting r0 to 32 bits and r{1,2,3} to whatever was passed as an input. Let's turn everything into "unsigned long", which satisfies the requirements of both architectures, and allows for the full range of return values. Reported-by: Julien Grall Signed-off-by: Marc Zyngier Signed-off-by: Will Deacon Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- include/linux/arm-smccc.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) --- a/include/linux/arm-smccc.h +++ b/include/linux/arm-smccc.h @@ -167,31 +167,31 @@ asmlinkage void arm_smccc_hvc(unsigned l #define __declare_arg_0(a0, res) \ struct arm_smccc_res *___res = res; \ - register u32 r0 asm("r0") = a0; \ + register unsigned long r0 asm("r0") = (u32)a0; \ register unsigned long r1 asm("r1"); \ register unsigned long r2 asm("r2"); \ register unsigned long r3 asm("r3") #define __declare_arg_1(a0, a1, res) \ struct arm_smccc_res *___res = res; \ - register u32 r0 asm("r0") = a0; \ - register typeof(a1) r1 asm("r1") = a1; \ + register unsigned long r0 asm("r0") = (u32)a0; \ + register unsigned long r1 asm("r1") = a1; \ register unsigned long r2 asm("r2"); \ register unsigned long r3 asm("r3") #define __declare_arg_2(a0, a1, a2, res) \ struct arm_smccc_res *___res = res; \ - register u32 r0 asm("r0") = a0; \ - register typeof(a1) r1 asm("r1") = a1; \ - register typeof(a2) r2 asm("r2") = a2; \ + register unsigned long r0 asm("r0") = (u32)a0; \ + register unsigned long r1 asm("r1") = a1; \ + register unsigned long r2 asm("r2") = a2; \ register unsigned long r3 asm("r3") #define __declare_arg_3(a0, a1, a2, a3, res) \ struct arm_smccc_res *___res = res; \ - register u32 r0 asm("r0") = a0; \ - register typeof(a1) r1 asm("r1") = a1; \ - register typeof(a2) r2 asm("r2") = a2; \ - register typeof(a3) r3 asm("r3") = a3 + register unsigned long r0 asm("r0") = (u32)a0; \ + register unsigned long r1 asm("r1") = a1; \ + register unsigned long r2 asm("r2") = a2; \ + register unsigned long r3 asm("r3") = a3 #define __declare_arg_4(a0, a1, a2, a3, a4, res) \ __declare_arg_3(a0, a1, a2, a3, res); \