Received: by 10.223.176.5 with SMTP id f5csp2471183wra; Thu, 1 Feb 2018 00:53:58 -0800 (PST) X-Google-Smtp-Source: AH8x227ogPDdzbvlbWnHGw2Gz1SA3Hnc6vDRniHVIUX8P/x9twZNqREwgTcmhjQk3n71yq60bqXI X-Received: by 2002:a17:902:6ac4:: with SMTP id i4-v6mr31728299plt.304.1517475238280; Thu, 01 Feb 2018 00:53:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517475238; cv=none; d=google.com; s=arc-20160816; b=kM4TkS8xbVQ65J4LeSZ6scJh+7y8Us+auZJ0M2IJEP8wn3jGlXTL/2CDbrUBoFJkWC C+tK7795AaOO0uwrYzNnCek7IYK0OerUrNKGd6N6F6wqs+tAZlrda6Y7x+u0+FL4PQ1K CHumK+g85vS1IyJpr7tlrc2N8eFVD21aGAURZLbzRMkvsXsqRK2K/mnWeQVNgHeJIRr5 g28nclqKYz7H3rARhi/emnO8ZIsLjaVSY910lcZboVFKCKDWxOG6tjFO6+9lkQu5OdT6 rGvIUiyDE6Df0NtoPwt6Dea7z9uiPH6Z8xudhGL4pMcXFKnwANHxna4gev4XM5lHPTvq eoUA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=LJoYy92B03z04I40db4Qc3t4G3TPO5CvytjJWj4A2Xk=; b=Zw6feBrUI+T5+KmiwQVIGUylouTd+8cotppSLktotM+6eV6zBWA+GZaVchhSrUHSmo cXmBV/n/3XS9KSvf+a+I4vve9s9Uvjua7DGWC0FYlECRnEr0I+A4BV8DYpWaYsIMtsIg VR69kwLG/pK27GbSe1nsueZzr+BlFirmkltiGGckxQmIIvP+AVm4/yPDqVZJRkWfizch g9oIU6RxmG+HCXy1a7ZDsML5s25LSuyafVQK8rd0EsBDX96G7+FEQWfuieMRcCf4fABO lKpsbwdmL6Nyk3iuj4vGX2DiK/KebqJLW2oWcH6IJbN/A9HpVJi4AZZ6nZb53avixvls UvAA== 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 a9-v6si1129423pln.772.2018.02.01.00.53.43; Thu, 01 Feb 2018 00:53:58 -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 S1751804AbeBAIxO (ORCPT + 99 others); Thu, 1 Feb 2018 03:53:14 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:46416 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751448AbeBAIxN (ORCPT ); Thu, 1 Feb 2018 03:53:13 -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 26E4F80D; Thu, 1 Feb 2018 00:53:13 -0800 (PST) Received: from [10.1.207.62] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 074093F487; Thu, 1 Feb 2018 00:53:09 -0800 (PST) Subject: Re: [PATCH v2 16/16] arm64: Add ARM_SMCCC_ARCH_WORKAROUND_1 BP hardening support To: Hanjun Guo , Ard Biesheuvel Cc: Linux Kernel Mailing List , linux-arm-kernel , kvmarm , Catalin Marinas , Will Deacon , Peter Maydell , Christoffer Dall , Lorenzo Pieralisi , Mark Rutland , Robin Murphy , Jon Masters References: <20180129174559.1866-1-marc.zyngier@arm.com> <20180129174559.1866-17-marc.zyngier@arm.com> <476d111e-6fb0-9bef-2448-a94d0cc03f45@huawei.com> <49853e5e-f093-2e79-1cfb-182f51fcd6a0@arm.com> <501451b6-cc84-e8d3-b7b6-49a7de953976@arm.com> From: Marc Zyngier Organization: ARM Ltd Message-ID: <8183e28a-39e7-e4f0-d704-35a0beb14ef0@arm.com> Date: Thu, 1 Feb 2018 08:53:08 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/02/18 02:40, Hanjun Guo wrote: > On 2018/1/31 23:05, Marc Zyngier wrote: >> On 31/01/18 14:38, Ard Biesheuvel wrote: >>> On 31 January 2018 at 14:35, Ard Biesheuvel wrote: >>>> On 31 January 2018 at 14:11, Marc Zyngier wrote: >>>>> On 31/01/18 13:56, Hanjun Guo wrote: >>>>>> Hi Marc, >>>>>> >>>>>> On 2018/1/30 1:45, Marc Zyngier wrote: >>>>>>> static int enable_psci_bp_hardening(void *data) >>>>>>> { >>>>>>> const struct arm64_cpu_capabilities *entry = data; >>>>>>> >>>>>>> - if (psci_ops.get_version) >>>>>>> + if (psci_ops.get_version) { >>>>>>> + if (check_smccc_arch_workaround_1(entry)) >>>>>>> + return 0; >>>>>> >>>>>> If I'm using the new version SMCCC, the firmware have the choicARM_SMCCC_ARCH_WORKAROUND_1e to decide >>>>>> whether this machine needs the workaround, even if the CPU is vulnerable >>>>>> for CVE-2017-5715, but.. >>>>>> >>>>>>> + >>>>>>> install_bp_hardening_cb(entry, >>>>>>> (bp_hardening_cb_t)psci_ops.get_version, >>>>>>> __psci_hyp_bp_inval_start, >>>>>>> __psci_hyp_bp_inval_end); >>>>>> >>>>>> ..the code above seems will enable get_psci_version() for CPU and will >>>>>> trap to trust firmware even the new version of firmware didn't say >>>>>> we need the workaround, did I understand it correctly? >>>>> >>>>> Well, you only get there if we've established that your CPU is affected >>>>> (it has an entry matching its MIDR with the HARDEN_BRANCH_PREDICTOR >>>>> capability), and that entry points to enable_psci_bp_hardening. It is > > I understand, but A53, A57, A72 and etc are always in the list :) > >>>>> not the firmware that decides whether we need hardening, but the kernel. >>>>> The firmware merely provides a facility to apply the hardening. >>>>> >>>>>> I'm ask this because some platform will not expose to users to >>>>>> take advantage of CVE-2017-5715, and we can use different firmware >>>>>> to report we need such workaround or not, then use a single kernel >>>>>> image for both vulnerable platforms and no vulnerable ones. >>>>> >>>>> You cannot have your cake and eat it. If you don't want to workaround >>>>> the issue, you can disable the hardening. But asking for the same kernel >>>>> to do both depending on what the firmware reports doesn't make much >>>>> sense to me. >>>> >>>> The SMCCC v1.1. document does appear to imply that systems that >>>> implement SMCCC v1.1 but don't implement ARM_SMCCC_ARCH_WORKAROUND_1 >>>> should be assumed to be unaffected. >>>> >>>> """ >>>> If the discovery call returns NOT_SUPPORTED: >>>> • SMCCC_ARCH_WORKAROUND_1 must not be invoked on any PE in the system, and >>>> • none of the PEs in the system require firmware mitigation for CVE-2017-5715. >>>> """ >>>> >>>> How to deal with conflicting information in this regard (quirk table >>>> vs firmware implementation) is a matter of policy, of course. >> >> Yup. And the current approach fits the spec, I believe. The > > Yes, approach in this patch set fits the spec, it just conflicts with > MIDR based approach. No it doesn't. We know that A72 is affected. However you look at it, there is no way around that fact. So if you have an affected CPU *and* you implement SMCCC 1.1 with WORKAROUND_1, you get the mitigation. If your firmware doesn't implement it, blame your provider for supplying you with an outdated firmware. >> PSCI_GET_VERSION band-aid should normally be removed shortly after these >> patches hit mainline. > > I'm a big fan of this :) > >> >>> >>> ... and actually, perhaps it makes sense for the >>> SMCCC_ARCH_WORKAROUND_1 check to be completely independent of MIDR >>> based errata matching? >>> >>> I.e., if SMCCC v1.1 and SMCCC_ARCH_WORKAROUND_1 are both implemented, >>> we should probably invoke it even if the MIDR is not known to belong >>> to an affected implementation. >> >> This would have an impact on big-little systems, for which there is >> often a bunch of unaffected CPUs. > > I think it's what we are doing now, SMCCC v1.1 didn't provide the ability > to report per-cpu SMCCC_ARCH_WORKAROUND_1, and it said: > - The discovery call must return the same result on all PEs in the system. > - In heterogeneous systems with some PEs that require mitigation and others > that do not, the firmware must provide a safe implementation of this > function on all PEs. > > So from the spec that it's the firmware to take care of unaffected CPUs, > to the kernel it's the same. The spec makes it safe. The MIDR list makes it fast. M. -- Jazz is not dead. It just smells funny...