Received: by 10.223.176.46 with SMTP id f43csp977367wra; Wed, 24 Jan 2018 08:43:56 -0800 (PST) X-Google-Smtp-Source: AH8x227jDiM9Nnn66KE35yaGYlX+alCmfthLU74ggDM0WYO42zK1nJKryjZ9eoCxhx0pBrb9JfRz X-Received: by 10.98.75.146 with SMTP id d18mr13647106pfj.11.1516812236126; Wed, 24 Jan 2018 08:43:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516812236; cv=none; d=google.com; s=arc-20160816; b=kkqZGNe2iNaDIQty6m8+aW2wAowLb0qMjaoYfusPfkDw8IkYZ6/62fo8kn9+TQ/X9/ j4fCFDguoMeWBnWGFr9fwGpm/YdK/K0m6bDA477Bg63rLz2iDqid7yZcX52iW0koaWiC VPCv89BvHnfnRg45prFuXP7YSHC/Z82CjbrLadcoCvFX1zL32AFZzU+Nkn6Frk4VLEac 1mmO/UdiEclmdCXdAyVCaQdZsWXcMztf9xrY7iJyyiOb1EnQW6Evl9Y4Wt5bmMQK1sXg 7QLpUI28lM+2lWpznm3tkjeyeK46l5ZWQkbiRyZXs5GuhnE9eEy2vP0IN2sVufA9M1Q5 /Usg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=QnGdEcvlKqETWz13sudB3nwkf3+Wu3l0WtcRzs1fjRc=; b=OAV0qp6U1CWBwb9JniNZvemRtcjV/idhk+Xng9gBa8DwCUkz4RCq64o+DFXm7DfVqQ JYTjsLSEPvYgTMvTMsGClwJS0UKeY5mhQx2qFqmv5SvjHxVt0E5e1DT2zIOM0rIfJx/6 eK39Uz73qh8IdIvAvM9zy60zkn0kW/M0PrQ6sYo6cxmnKKGZFt2G0twbM503Re97kZsu Km6bRGlFmQCMLFSfwswfO8m+QEx6ZD8VHVwMyzRKIOsmGt0uMDWlmEwNKkXyQyQ7ph13 FZnhVQ0eNSACsAlvZKXwy+pjZVU6iI0c8QNaMdCSXZ6+wZSlGSlr7p99JkiYNRvkM4Hq hJTQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k130si332506pgc.358.2018.01.24.08.43.41; Wed, 24 Jan 2018 08:43:56 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964826AbeAXQnR (ORCPT + 99 others); Wed, 24 Jan 2018 11:43:17 -0500 Received: from foss.arm.com ([217.140.101.70]:55404 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934237AbeAXQnQ (ORCPT ); Wed, 24 Jan 2018 11:43:16 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0BF3280D; Wed, 24 Jan 2018 08:43:16 -0800 (PST) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D02433F318; Wed, 24 Jan 2018 08:43:15 -0800 (PST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id A16931AE2F4A; Wed, 24 Jan 2018 16:43:24 +0000 (GMT) Date: Wed, 24 Jan 2018 16:43:24 +0000 From: Will Deacon To: Mark Salter Cc: Marc Zyngier , Khuong Dinh , linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, jcm@redhat.com, lorenzo.pieralisi@arm.com, ard.biesheuvel@linaro.org, linux-kernel@vger.kernel.org, christoffer.dall@linaro.org, patches@apm.com Subject: Re: [PATCH] arm64: turn off xgene branch prediction while in kernel space Message-ID: <20180124164324.GA30462@arm.com> References: <1516760007-14670-1-git-send-email-kdinh@apm.com> <1516811703.2957.47.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1516811703.2957.47.camel@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 24, 2018 at 11:35:03AM -0500, Mark Salter wrote: > On Wed, 2018-01-24 at 10:58 +0000, Marc Zyngier wrote: > > Khuong, > > > > On 24/01/18 02:13, Khuong Dinh wrote: > > > Aliasing attacks against CPU branch predictors can allow an attacker to > > > redirect speculative control flow on some CPUs and potentially divulge > > > information from one context to another. > > > > > > This patch only supports for XGene processors. > > > > > > Signed-off-by: Mark Salter > > > Signed-off-by: Khuong Dinh > > > --- > > > arch/arm64/include/asm/cpucaps.h | 3 ++- > > > arch/arm64/include/asm/fixmap.h | 4 ++++ > > > arch/arm64/kernel/cpu_errata.c | 18 ++++++++++++++++++ > > > arch/arm64/kernel/entry.S | 28 ++++++++++++++++++++++++++++ > > > arch/arm64/kernel/smp.c | 34 ++++++++++++++++++++++++++++++++++ > > > 5 files changed, 86 insertions(+), 1 deletions(-) > > > > > > diff --git a/arch/arm64/include/asm/cpucaps.h b/arch/arm64/include/asm/cpucaps.h > > > index bb26382..dc9ada1 100644 > > > --- a/arch/arm64/include/asm/cpucaps.h > > > +++ b/arch/arm64/include/asm/cpucaps.h > > > @@ -45,7 +45,8 @@ > > > #define ARM64_HARDEN_BRANCH_PREDICTOR 24 > > > #define ARM64_HARDEN_BP_POST_GUEST_EXIT 25 > > > #define ARM64_HAS_RAS_EXTN 26 > > > +#define ARM64_XGENE_HARDEN_BRANCH_PREDICTOR 27 > > > > > > > Why isn't this using the infrastructure that is already in place? > > That infrastructure relies on a cpu-specific flush of the branch > predictor. XGene does not have the ability to flush the branch > predictor. It can only turn it on or off. So how does this patch protect one user application from another? Sounds like you need to turn the thing off at boot and leave it that way, or find a sequence of branch instructions to effectively do the invalidation. Will