Received: by 10.223.176.46 with SMTP id f43csp1069630wra; Fri, 19 Jan 2018 06:30:46 -0800 (PST) X-Google-Smtp-Source: ACJfBovuW85TOcKo2FWaDzeD5IlkK90BEab9mBfNj9JV2sCu5MpI0NVE4TRf8wINdQ/LpLB/+yZi X-Received: by 2002:a17:902:d917:: with SMTP id c23-v6mr1733752plz.231.1516372246708; Fri, 19 Jan 2018 06:30:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516372246; cv=none; d=google.com; s=arc-20160816; b=QsjIlYGmvK+uemxT4o60Kx4O7+MYjKu5FI3OlStcjnKhx51kd9rm1mmWzaFi0hGzB4 g9m6UeNUrF1dHi50rpb0I80gnAsAIx7zq0vMJF5cs7WX9mqBqyTZV/vo8r1MTvUrXQVs AnrdqwYTHnz1WVkUh4v3p3LxH1wTrt0cq4ZAKH86IuUkWwhDp2sJtuuEVBRdmeqob8Je 0JZcGJ+SgbzNj8Tbvu0gTgP11CMDH4N/HVg361hPWfCTflfN41BdUqwpye2zBpXN0M5j ZMAMzM0rVSF2jtXVywekPtDgf6InB3zwc2tJ258x7dGXEziGbvkiRkg6Rrp0GGYjP69l fbDw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=FbDPkmQowEIZkCh/axXEsO4X7zkMMnXlkuRaO21v9O0=; b=FxoaQsnsdnXf22Ba+NVCXc1cZbUe2jnHmfISPGxQPZ3LP2qt9ZMj0idFdyES8ux7Ns bTyPFzCRtxg1/JVQfCNB6z5FDbzRp0Ti4SeC8kkU6PQR+2b6K13JhPKIqmG3Sr93AyR+ UFSEeLVaGfnGEBdYhyGc3dkfWfUeWeKZ51cfRPex7e3eJW2nnfAskU57OCzRnlGJZ0zG FViO5Flim3z9tFTGJkHyNjFrxMPe6CjcEXRXuqyAV7GY5eW2Sh2OmKEvP+8EP1li4/XV 89aPgpJ+jFKRzdLLNFSvS0KikL9Iet/TEYnnEYyi8+hStzd0hSzAeakYFwkiiLFAW8GY iLTw== 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 q12-v6si865945plk.730.2018.01.19.06.30.32; Fri, 19 Jan 2018 06:30:46 -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 S1755946AbeASO2Q (ORCPT + 99 others); Fri, 19 Jan 2018 09:28:16 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:39374 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754947AbeASO2K (ORCPT ); Fri, 19 Jan 2018 09:28:10 -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 853CF1435; Fri, 19 Jan 2018 06:28:09 -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 557283F41F; Fri, 19 Jan 2018 06:28:09 -0800 (PST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id E70971AE0F4E; Fri, 19 Jan 2018 14:28:15 +0000 (GMT) Date: Fri, 19 Jan 2018 14:28:15 +0000 From: Will Deacon To: Li Kun Cc: Yisheng Xie , lorenzo.pieralisi@arm.com, ard.biesheuvel@linaro.org, marc.zyngier@arm.com, catalin.marinas@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, labbott@redhat.com, christoffer.dall@linaro.org Subject: Re: [PATCH v2 07/11] arm64: Add skeleton to harden the branch predictor against aliasing attacks Message-ID: <20180119142814.GA8421@arm.com> References: <1515157961-20963-1-git-send-email-will.deacon@arm.com> <1515157961-20963-8-git-send-email-will.deacon@arm.com> <01c224eb-9bec-6b16-7ecf-14837cc107b6@huawei.com> <20180117100715.GA27892@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 Fri, Jan 19, 2018 at 11:37:24AM +0800, Li Kun wrote: > 在 2018/1/17 18:07, Will Deacon 写道: > >On Wed, Jan 17, 2018 at 12:10:33PM +0800, Yisheng Xie wrote: > >>On 2018/1/5 21:12, Will Deacon wrote: > >>>diff --git a/arch/arm64/mm/context.c b/arch/arm64/mm/context.c > >>>index 5f7097d0cd12..d99b36555a16 100644 > >>>--- a/arch/arm64/mm/context.c > >>>+++ b/arch/arm64/mm/context.c > >>>@@ -246,6 +246,8 @@ asmlinkage void post_ttbr_update_workaround(void) > >>> "ic iallu; dsb nsh; isb", > >>> ARM64_WORKAROUND_CAVIUM_27456, > >>> CONFIG_CAVIUM_ERRATUM_27456)); > >>>+ > >>>+ arm64_apply_bp_hardening(); > >>> } > >>post_ttbr_update_workaround was used for fix Cavium erratum 2745? so does that > >>means, if we do not have this erratum, we do not need arm64_apply_bp_hardening()? > >>when mm_swtich and kernel_exit? > >> > >> From the code logical, it seems not only related to erratum 2745 anymore? > >>should it be renamed? > >post_ttbr_update_workaround just runs code after a TTBR update, which > >includes mitigations against variant 2 of "spectre" and also a workaround > >for a Cavium erratum. These are separate issues. > But AFAIU, according to the theory of spectre, we don't need to clear the > BTB every time we return to user? > If we enable CONFIG_ARM64_SW_TTBR0_PAN, there will be a call to > arm64_apply_bp_hardening every time kernel exit to el0. > kernel_exit > post_ttbr_update_workaround > arm64_apply_bp_hardening That's a really good point, thanks. What it means is that post_ttbr_update_workaround is actually the wrong place for this, and we should be doing it more directly on the switch_mm path -- probably in check_and_switch_context. Will