Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754118AbeAIC0g (ORCPT + 1 other); Mon, 8 Jan 2018 21:26:36 -0500 Received: from mail-by2nam03on0065.outbound.protection.outlook.com ([104.47.42.65]:8734 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751907AbeAIC0e (ORCPT ); Mon, 8 Jan 2018 21:26:34 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jayachandran.Nair@cavium.com; Date: Mon, 8 Jan 2018 18:26:20 -0800 From: Jayachandran C To: Will Deacon Cc: marc.zyngier@arm.com, linux-arm-kernel@lists.infradead.org, lorenzo.pieralisi@arm.com, ard.biesheuvel@linaro.org, catalin.marinas@arm.com, linux-kernel@vger.kernel.org, labbott@redhat.com, christoffer.dall@linaro.org Subject: Re: [PATCH 2/2] arm64: Branch predictor hardening for Cavium ThunderX2 Message-ID: <20180109022617.GA4924@jc-sabre> References: <20180108063115.GA163286@jc-sabre> <1515394416-166994-1-git-send-email-jnair@caviumnetworks.com> <1515394416-166994-2-git-send-email-jnair@caviumnetworks.com> <20180108164651.GQ25869@arm.com> <20180108171943.GA180149@jc-sabre> <20180108172341.GV25869@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180108172341.GV25869@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: BN6PR1301CA0035.namprd13.prod.outlook.com (2603:10b6:405:29::48) To SN2PR0701MB1070.namprd07.prod.outlook.com (2a01:111:e400:341f::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 41f2b79b-327e-48d6-de90-08d55708658d X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020);SRVR:SN2PR0701MB1070; X-Microsoft-Exchange-Diagnostics: 1;SN2PR0701MB1070;3:A1xFXoFwVwaamrphMPHo30FTKrnwjmDclRGmtgZTvv9PZwW5OUhKnNX8KOtjaU4b8ixgUVos3KklYJD+m3/eQf9fNeXJ+Ni2aqafh4QxhTIPtJBudoJCcP0hCHI9Isz73JNK8uiezk+/zeL94iAzM1d2XABtw5KLEJ53UxG1ng1wInVotP92hGvA6v745SmbkVuVQe9sCUtpoO6F+deL9/IQlI1GF6Usp990i20FcWGrhydQNfRjDYow+TI1jOrH;25:8U5L1l1+2NKPnZTR7tpNZSJjy3hs+6Ol2Yvd0VBGBW8cejty2E3+pphMezRuVAKIX7+WX0l6I9Ny0Ps0HRgEYbjKpLfb99H/z3Ho4jwP4YUdg3SfTMAyiMKS118FAgC/oBPzNaEMc4mtGXl2S0nSIyPONBxn5IVLM3ocwPgDR4vekffXi0zIIKacBWotgbEVV3uty9aqMnAum5H/gBwMw3+mYYwkj4vwmRaNvEs4RWk7IQ3fbPx/wuQDJkK9bRNb1p86KcjRX/WbctWeEVKsxoMu1elM03t0kPvTI2/Im1w5TZ30HMJTwGAGncTdpRKqNIdlUMZGUUuzX3eIxON1aA==;31:6SWqsKbZC2XnhOk7AwxQZg2E/+sI8SeLiBRGe00DUg6rInUGf76r0KyS3y+HHME44TjB+pBqWz8laDGgZCcNUrt3isxc+tjZhYUpm8PSqhW2jfeBXbYAKRTDsMax3CkVEKrPl/r+bOeDBJiWXQk6bIbfvH+bC5VVVzw+an6qgYxBBbyQRTul//LwMIpxC0RQmn+CqcG6klUhTWzawmVXJS6hgpAQCwqq8ZSTmq5l1j0= X-MS-TrafficTypeDiagnostic: SN2PR0701MB1070: X-Microsoft-Exchange-Diagnostics: 1;SN2PR0701MB1070;20:R+tsnWcUVyAy5qpIAejum7QRPn/zN3IIAdmmyz7GdqD152BOt1DEW0yD8xNrtzj5FkDXlvKKGMc389qsD7MXJOdWF753gxglvMGd7tMH1HXqpz1wBwEve2p7xNt5Osfe3EFEGChyalsyF08HRIm5QagVzsGV+IM+C5A8VaU9WVdU+NzPdkExxDEHtKL9fkWtw3GrbvmnwdfWlUtW6CZNNiQ9aysifhP5wtlL1P454OePhXoxk5a3lWmEWOfIS7qfZIubapPyGJclayuSFhyMpPACsl5/AmTLw7gqCNuVEQPc4UQ/Ave5JfWDgcu2yg9bVFXSLOePrTB0WpXjeVJmmyPv8LqJ3P7tdmUDUuSvBe14E/WiRdiiW+yMBrxMacnd4T6hYxX7mrOPQER239OmNQnIl7YunxTfw0lf2+A+Rg/TbJs5g7pHUN5qmR8tdovHj/t2n8CJ8q4inOFnTMenbVzYHbInQd8nd9sdgTPcoIuJCk4NqlExEU/AiLNaIAjr8XaAMdN8xtjm/kgY4o89gS/QKz2KYBo80Il8pRp597nBsuLV2+JNWHgwEyoVrcu+WwOoqZyEmhM5XcZRcLBiEMGX8K2CLI2eO2zi4yUQMMY=;4:ySH0A9cdtURFoBA5F3AMQc6zEKiuH5d/cZXiQ4qQXN5+yQ8S7G+azk5AueTtoS4q9mrRcfEaNjz9OXi0ZrlI1vsR8DRQOtl9Vas0/quHI4n3KQETnpcLr7WzyHbWU+IjYCC/1ouWlrFMBPyAoluZb7w5XBgeJL82SpiIw2GtvYnKw1JleXW7uHDz1xqOi9cJ7QVQSyxlT44oC3ATqWBqpT9VWQiovgcXG3eWEMRl4MhAYqnzB9EUuP59bwWYmTdPuHKHyCaRmoLUGLGvuk2r8lVMP7p90XXMePpRkql+Hk5lcGYfITz026agO4XcIgvs X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(20558992708506); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(5005006)(8121501046)(10201501046)(3231023)(944501075)(3002001)(93006095)(6041268)(20161123564045)(20161123558120)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:SN2PR0701MB1070;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:SN2PR0701MB1070; X-Forefront-PRVS: 0547116B72 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(366004)(376002)(346002)(396003)(39380400002)(39860400002)(189003)(199004)(24454002)(53936002)(6116002)(6496006)(3846002)(5660300001)(47776003)(7736002)(575784001)(2950100002)(66066001)(97736004)(6916009)(42882006)(1076002)(6666003)(305945005)(58126008)(8936002)(59450400001)(93886005)(2906002)(72206003)(16526018)(52116002)(105586002)(23726003)(33716001)(478600001)(33896004)(76176011)(316002)(16586007)(106356001)(81156014)(33656002)(55016002)(9686003)(81166006)(68736007)(6246003)(50466002)(25786009)(229853002)(4326008)(83506002)(8676002)(386003)(18370500001)(107986001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN2PR0701MB1070;H:jc-sabre;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN2PR0701MB1070;23:SdNf5QI9OvvETIil9e4gV+UWImraL6YX4FoQOTq?= =?us-ascii?Q?QrxQTXQNUIyRjs7VdevCuHGcARp1YGTnrvW7Z49PQGW2Po1uX8goHwfkVjMu?= =?us-ascii?Q?l+63LdbgY2HM05yFtngh9y53krlLgMoofYWsyBing6RhmIien0tzMHkhjfMm?= =?us-ascii?Q?SQvGWMVbrFKX+jjZ2idholA+jBxcFb4cXEZZ7GV3D8HoXOqMFpkgHzGmuscS?= =?us-ascii?Q?j70kOogQvyxGZ5pKmLxSO3KFgffB7UqRLnb9afEevQUduHPynhPjl1+3HFHa?= =?us-ascii?Q?Xq8l3+9qZ6QUq4P/XyPY4HqnVfPqEqF7I90As7IPl7u3u58/CXfCFBB0ErUl?= =?us-ascii?Q?7wr3hq4NYK7/ve5vwGx3LUpBjqSMYvm/GeZfaFsWRCNlozgPW6XQbGKjAmNB?= =?us-ascii?Q?O+u310+2tlXGsQbUh9F/wiJqDVFyhzNuQhkhxvTjXvRcgaFY7/g1oLiOcxaX?= =?us-ascii?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bwfAx9+ku5lF?= X-Microsoft-Exchange-Diagnostics: 1;SN2PR0701MB1070;6:AhGzddjbGmAnX04NTsKBVEbd9jknM1J9k80Uw/jKz9YgDRsphCcA24bQ0jydajKHjaEu3T7psyYCt8yPbIuxR1YWwTX6VxUMQiMox40R0JP0zA4AvR3C6fiFR1K18ZMNxlHly1z7oZ9ezWjdjWc6q3ANPFoiEyfi4EDPCaBB66xLMpDjm2LDaJCCmtstJPJ8+gdE8DrxHjXl0CA4R63MArs5tENNrxK/SQO1vhQWQ3H0crLXkoiOecPzdXcy57oD4AcqCNH1waW6hbns3GNK58n8d5j6rIdpgWl8ENgNOZ7l74xnbyzHZDf34JQarCbkxQnqJ7N+m4a+mxI93JgSy7UxgOm6sqEIJh1kK6w3WJA=;5:bb0sthilD/riB+7cCvOxyrEwvfmGnhD0kvtue+zI4RP0l0Y1pmxXhbUBTrfD32rP3S1a9QiYWBRjQCnKWwF+Wf0BIhGS8/AvqIaiGJEcKVUWplTNGsOi0AZXaSJIyxtpPufPV5UeOdTFvWUuu3VpyrxXAcpivDcNV2eGza0x2lc=;24:sf8ki1KuRAXfXlCSR7vdpoPJxRV0u9pL4c6azozuuejv0vTotfQKm359CS5uCuhbNIl6qLtXtsYZ85stkpk2sKFG0aGpAIX4ne8xMqHpa8M=;7:onQcOKDjE8cdZ9j4wCI8jiE/5O1xfckmEF7/wfmYPiZVOuKoLf3vb+BjDtQB+odmep5D+Ef7iK6k9wHOa/C7+cTQwkkbj1rPdcu0r9mFsJEW1fy+k6MOmKoY1sMnzjvaFtAQAeJ1TqsmDHG1RLtfeaWsLdfuMBaI+jhq/3qyBsQqiZlUJWMxFvjrzXCicte971IVq4C/OJ4wrpwwGGw60S4+oTRE6P6Xj3EPI4iPd9VxRuUyTizH6QEgJUBDtCVK SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2018 02:26:30.6694 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41f2b79b-327e-48d6-de90-08d55708658d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR0701MB1070 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Mon, Jan 08, 2018 at 05:23:41PM +0000, Will Deacon wrote: > On Mon, Jan 08, 2018 at 09:19:43AM -0800, Jayachandran C wrote: > > On Mon, Jan 08, 2018 at 04:46:52PM +0000, Will Deacon wrote: > > > On Sun, Jan 07, 2018 at 10:53:36PM -0800, Jayachandran C wrote: > > > > Use PSCI based mitigation for speculative execution attacks targeting > > > > the branch predictor. The approach is similar to the one used for > > > > Cortex-A CPUs, but in case of ThunderX2 we add another SMC call to > > > > test if the firmware supports the capability. > > > > > > > > If the secure firmware has been updated with the mitigation code to > > > > invalidate the branch target buffer, we use the PSCI version call to > > > > invoke it. > > > > > > > > Signed-off-by: Jayachandran C > > > > --- > > > > arch/arm64/kernel/cpu_errata.c | 38 ++++++++++++++++++++++++++++++++++++++ > > > > 1 file changed, 38 insertions(+) > > > > > > > > diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c > > > > index cb0fb37..abceb5d 100644 > > > > --- a/arch/arm64/kernel/cpu_errata.c > > > > +++ b/arch/arm64/kernel/cpu_errata.c > > > > @@ -124,6 +124,7 @@ static void install_bp_hardening_cb(const struct arm64_cpu_capabilities *entry, > > > > __install_bp_hardening_cb(fn, hyp_vecs_start, hyp_vecs_end); > > > > } > > > > > > > > +#include > > > > #include > > > > > > > > static int enable_psci_bp_hardening(void *data) > > > > @@ -138,6 +139,33 @@ static int enable_psci_bp_hardening(void *data) > > > > > > > > return 0; > > > > } > > > > + > > > > +#define CAVIUM_TX2_SIP_SMC_CALL 0xC200FF00 > > > > +#define CAVIUM_TX2_BTB_HARDEN_CAP 0xB0A0 > > > > + > > > > +static int enable_tx2_psci_bp_hardening(void *data) > > > > +{ > > > > + const struct arm64_cpu_capabilities *entry = data; > > > > + struct arm_smccc_res res; > > > > + > > > > + if (!entry->matches(entry, SCOPE_LOCAL_CPU)) > > > > + return; > > > > + > > > > + arm_smccc_smc(CAVIUM_TX2_SIP_SMC_CALL, CAVIUM_TX2_BTB_HARDEN_CAP, 0, 0, 0, 0, 0, 0, &res); > > > > > > One thing to be aware of here is that if somebody configures qemu to emulate > > > a TX2, this may actually disappear into EL3 and not return. You're better > > > off sticking with PSCI GET_VERSION in terms of portability, but it's your > > > call -- I'd expect you to deal with any breakage reports on the list due > > > to the SMC above. Fair? > > > > I don't like having a custom SMC here either. But Overloading PSCI get version > > is the problem as I wrote earlier - there is no way to check if the firmware > > implements BTB hardening with overloading. There is a good chance that users > > with old firmware will just fail without any warning. > > That's true, but there is precedent for this elsewhere. For example, CPU > errata that require a firmware change are often not probable. Also, your SMC > call won't always work (see the qemu comment below). Note that I'm not > saying I won't take this code, just that you need to be aware of what > you're doing. > > > Is there a reason for overloading PSCI get version? Allocating a new standard > > SMC number would make checking for existance and usage much simpler. > > PSCI get version is what we have today. We're working on extending PSCI to > allocate a new standard SMC number, but we need something that can be used > with existing firmware too and standardisation doesn't happen overnight. Can you hold this patchset until the SMC number is published? Otherwise we will end up with two incompatible interfaces, and the mess of supporting both. Or if there is a plan standardize this later, I can pickup a vendor specific SMC for now, and switch over to the standard one later. Any suggestions here? JC.