Received: by 10.223.176.46 with SMTP id f43csp2558040wra; Sun, 21 Jan 2018 22:53:08 -0800 (PST) X-Google-Smtp-Source: AH8x227yj1GRZ8IthQGk7BQ7xWS9ilZ5m4CeEiUzO96nlLqviZXZT4vIQ3I5JE3DA8r76oapWJGl X-Received: by 10.99.123.87 with SMTP id k23mr6430432pgn.228.1516603988232; Sun, 21 Jan 2018 22:53:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516603988; cv=none; d=google.com; s=arc-20160816; b=eNs/eriyIYz2hJUDowMo4sihOAYV8Y3bgfpKfNHfGiRpTstaCpf4CPdRK7392RKiAO S+APpOzr1sBpeeon0Tn87w41NC0Xb0tFF7sTi5zuMtYDedoIoM12oedOzC6N42ctJv9S MDejzXsX0wL1J9laU6NjbByJv8AqpaHb7qC2cqSoc2KLbZaEXzutw4m2S/9BCYdemRr0 2UUfcaP13ljTJRmFIrm+jq/aC3Xadqt2OtYPny0s2P0fxEea9yjwR7InqOYc1jXTIJTU rMxgfrFed0RblK5vEksIN2KJmTuydZqu6bUKul84uZGx7W0x/3k5buS7EJn2NbWg8Z+4 lXLg== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=M4LtZqofs7oAc8P+h+34p8w1Ee8KymqKGqUxQHS/6H4=; b=vlj0RZ+UN/aj6CkvN2FeyJFpmhyUUNOHnR6CxCeqb19qQLJ6f4Hr2xFXaw53kNXbh1 akQzTtpt8mhFnno46lKoS3Y4ILmD4JfKMhOYSpoHatvwQufGBdhfu5gBvuzXKu6ATu1v 7Y99KNMl9VEJM6eFu435g5QFlwKcV7MJIv2a8V2TqAehi+aDzaOoGj3dw4UEso+kQZUy HUTY73mHsLiz6qndUPO/yUnjmlMXzfAzX6pMZp574z+K8BIEvb+0PdGj0HIPG/rFWF+9 XQRMCejhR+Xcfr23NYOkkq1dYIkLMFvqbb/4LuM1vVVhJqOjb1+tdxbEQURiqpljtfVA D4UA== 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 y19si13034109pgv.114.2018.01.21.22.52.53; Sun, 21 Jan 2018 22:53:08 -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 S1751128AbeAVGw2 (ORCPT + 99 others); Mon, 22 Jan 2018 01:52:28 -0500 Received: from szxga02-in.huawei.com ([45.249.212.188]:2515 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751062AbeAVGw1 (ORCPT ); Mon, 22 Jan 2018 01:52:27 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [10.3.19.206]) by Forcepoint Email with ESMTP id C37E07FD9A25E; Mon, 22 Jan 2018 14:52:23 +0800 (CST) Received: from [10.111.203.133] (10.111.203.133) by smtp.huawei.com (10.3.19.206) with Microsoft SMTP Server (TLS) id 14.3.361.1; Mon, 22 Jan 2018 14:52:18 +0800 Subject: Re: [PATCH v2 07/11] arm64: Add skeleton to harden the branch predictor against aliasing attacks To: Will Deacon 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> <20180119142814.GA8421@arm.com> CC: Yisheng Xie , , , , , , , , From: Li Kun Message-ID: <7cb8f7d6-8f81-efa8-3a83-f95c5af7e8ab@huawei.com> Date: Mon, 22 Jan 2018 14:52:18 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <20180119142814.GA8421@arm.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.111.203.133] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/1/19 22:28, Will Deacon Wrote: > 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. Yes, that's exactly what i mean.:-) > > Will -- Best Regards Li Kun