From patchwork Tue Jun 12 21:36:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 138382 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp5876893lji; Tue, 12 Jun 2018 14:36:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJOXBRG3Kae70Fghqd/kWPKcdxxqxOInzRu1Pk55ERnf4nOw4xTAA0Vc6YSL8nSKcSejMhU X-Received: by 2002:a17:902:4424:: with SMTP id k33-v6mr2203292pld.242.1528839403126; Tue, 12 Jun 2018 14:36:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528839403; cv=none; d=google.com; s=arc-20160816; b=YTQpZTWvyGeBkT8oFSd7MnN77gT4jr8FBbMLMzkWFmnRjhqhiPaiMhnKhwHUWMMUDG TlP9qfDhczNSmqAH+epm4KldhZnCV6zh+KrpPbH5gVzvnccIg0dxOQuDkij2/d7a/HnE 3H+hjL9K94GVg/PMgij4NvkmYnN8CToJDZLmfYsqL9QrifnoANzEAy6v6DaCEYKKLVaM pspDSInRKbB1MZKa/hoEPj8m1GvDhLFwSCHcsbbMSZ4VzxP1q3muiIJXk8QTAZz695kf D5eFa8Y5DZAwz+jv92hI8wOecqyl2aNEOl6JfaFPrxT7auPPFJHkxP7pXfaWSeg7nxa+ 3J+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature:arc-authentication-results; bh=wWFEhqCbzXOGrKstfGASSx2UrXNzrew7rdc+B16xSb8=; b=VglED96siSAhYOY8jfSSVXOXN1G+Xb2ua1MmRi3jeu5bgqEXEU0xdcKCAEVFH3aCMj MUlFw/oNlSCI3Y1GR+cSwDBeVatj/rSPGfCjyUihgdUcu1UswDUmPSwEjiF3S181zxSG jkovR9HSj7Y0LKeBbbEYYH+Qae5r8W7lTjY8iXexsOh18/xK8WCc6mh3gc8UP+9jPX7i 4KWuijVWo+f/raRAAoM08g+nXM6mgjcvmH9ekC8XvNz3PnZqAVEp2uvwFghCacQwMRfK ASsc6f8H4YdmuuiSf4G4sdRor6BVyRVy6kzXDOFZRiCLQos0hjefwullNIxKtybUzou3 7TQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ZVuSi28b; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f6-v6si1138705plm.448.2018.06.12.14.36.42; Tue, 12 Jun 2018 14:36:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@ti.com header.s=ti-com-17Q1 header.b=ZVuSi28b; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934556AbeFLVgl (ORCPT + 30 others); Tue, 12 Jun 2018 17:36:41 -0400 Received: from fllnx210.ext.ti.com ([198.47.19.17]:50030 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933696AbeFLVgi (ORCPT ); Tue, 12 Jun 2018 17:36:38 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id w5CLaFQQ014513; Tue, 12 Jun 2018 16:36:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1528839375; bh=wWFEhqCbzXOGrKstfGASSx2UrXNzrew7rdc+B16xSb8=; h=From:To:CC:Subject:Date; b=ZVuSi28bmLIX3KWZ/0YUeD+O9rb9DeQf8G4PMAXIxEPu+6iXCFEuuIJhEIGXxzXjY BcOhE6iYP9j4Ln2oH1H0yVs1/Y0Lt+oFQo/Jr1l/Wea6i98MQFTRR5b1om3O+SuEys Ee2jElMhcWUlhrmje5p5Ou/2PJHBRM1NcFF7dagE= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w5CLaFiP031234; Tue, 12 Jun 2018 16:36:15 -0500 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Tue, 12 Jun 2018 16:36:15 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Tue, 12 Jun 2018 16:36:15 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w5CLaFru018444; Tue, 12 Jun 2018 16:36:15 -0500 From: Nishanth Menon To: Russell King , Tony Lindgren CC: , , , Nishanth Menon Subject: [PATCH] ARM: DRA7/OMAP5: Enable ACTLR[0] (Enable invalidates of BTB) for secondary cores Date: Tue, 12 Jun 2018 16:36:11 -0500 Message-ID: <20180612213611.2484-1-nm@ti.com> X-Mailer: git-send-email 2.15.1 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Call secure services to enable ACTLR[0] (Enable invalidates of BTB with ICIALLU) when branch hardening is enabled for kernel. Signed-off-by: Nishanth Menon --- Based on: next-20180612 + Uboot series posted: https://marc.info/?l=u-boot&m=152883522011042&w=2 With Just u-boot changes alone: OMAP5-uevm: https://pastebin.ubuntu.com/p/9yDM22bJ6n/ with kernel changes added on: https://pastebin.ubuntu.com/p/gXPBGGYRPX/ arch/arm/mach-omap2/omap-smp.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) -- 2.15.1 diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c index 69df3620eca5..28fc80ea675b 100644 --- a/arch/arm/mach-omap2/omap-smp.c +++ b/arch/arm/mach-omap2/omap-smp.c @@ -109,6 +109,32 @@ void omap5_erratum_workaround_801819(void) static inline void omap5_erratum_workaround_801819(void) { } #endif +#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR +static void omap5_harden_predictor(void) +{ + u32 acr, acr_mask; + + asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r" (acr)); + + /* + * BIT(0) - Disables streaming. All write-allocate lines allocate in + */ + acr_mask = BIT(0); + + /* do we already have it done.. if yes, skip expensive smc */ + if ((acr & acr_mask) == acr_mask) + return; + + acr |= acr_mask; + omap_smc1(OMAP5_DRA7_MON_SET_ACR_INDEX, acr); + + pr_debug("%s: ARM ACR setup for CVE_2017_5715 applied on CPU%d\n", + __func__, smp_processor_id()); +} +#else +static inline void omap5_harden_predictor(void) { } +#endif + static void omap4_secondary_init(unsigned int cpu) { /* @@ -131,6 +157,8 @@ static void omap4_secondary_init(unsigned int cpu) set_cntfreq(); /* Configure ACR to disable streaming WA for 801819 */ omap5_erratum_workaround_801819(); + /* Enable ACR to allow for ICUALLU workaround */ + omap5_harden_predictor(); } /*