Received: by 10.223.176.5 with SMTP id f5csp1467421wra; Wed, 31 Jan 2018 06:55:55 -0800 (PST) X-Google-Smtp-Source: AH8x2278XpjRFDTfjyehQvvbFtRb6JWoAsX1QPjPcdq0ugNnE0BbVhcaaIH9x0xFiL3wVZCV6Idj X-Received: by 2002:a17:902:12f:: with SMTP id 44-v6mr27376856plb.403.1517410554891; Wed, 31 Jan 2018 06:55:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517410554; cv=none; d=google.com; s=arc-20160816; b=GFDf7rFk27Pjmp0B3BQVxL+B0hPy8labcDkCoG6pTG2xsz0YdEX4gEeGHo1JBU9lLJ Vo1393us9anQycl1k9LqWCtP/4ez8ZVCZbRfaql8iCoIQjgcWLw5oMEbrPjWIEE/creD bGk4KIZQay8r0Ir8VLrXefED2eSOiG8F/+Ym8JlgRDa/BGMa0IV9AqCqjzuuvvZiwhUt ZjPnCZhG+kG+eX+7JQQY7U2n53AfzwOkUf0ojIc3dKT/xf+vftLSjXLV6VNz/5tOoZgD eB2t3JrMEhhRFKQlki8giLoXTU6Yw+SULJPRhNm/20k7cJO0bRuYZJVaEd23HhlVjZ/2 JxUg== 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:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=M8xlxmqM+kUlvtiM8aPBkg6K2f2wMeSgYMfFemYjSj0=; b=mmfDub7Hgx4Bhx31gORo7HXVyqKfru4+s4kU8fkMJFvmSjLo0eZEdJ2t9z/xfC7PSW bxLNADCdM2wOybu7gJdEJjkDZ9q+HIjFMaXTeyDOWABQYRqkxD3244DSrs4yC1LF6ll7 OZyLnV+lHsNYc+dLIO9uuLQoaT+tSa9m4LFKP2V1QLoKcNAutKjJ0Iowx6Tq9pnBeecl BU9dxf+VnF+CpOLyuKZqIASOHWvo8gATn46AKbU02cV5GEMTCLv+YkYffhFHePTMGNtn Hh89znDlPtOg7aIubODebYZK0Xok8dZK449deKh2IaQtOQv9B3BdEVyblIlvWwVzxSYZ 99ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DzHhJrww; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l7-v6si4958708plk.510.2018.01.31.06.55.39; Wed, 31 Jan 2018 06:55:54 -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; dkim=pass header.i=@linaro.org header.s=google header.b=DzHhJrww; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932080AbeAaOfR (ORCPT + 99 others); Wed, 31 Jan 2018 09:35:17 -0500 Received: from mail-io0-f196.google.com ([209.85.223.196]:42770 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751899AbeAaOfQ (ORCPT ); Wed, 31 Jan 2018 09:35:16 -0500 Received: by mail-io0-f196.google.com with SMTP id 25so15396053ioj.9 for ; Wed, 31 Jan 2018 06:35:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=M8xlxmqM+kUlvtiM8aPBkg6K2f2wMeSgYMfFemYjSj0=; b=DzHhJrwwY3BfXQT4Hu3VzOXwy5a8Bdd6R5UbhMwifvx2cgrwXQf56BNngblsecieZb wMmtWHxkbd2m5rcifBlm/2Ylciku2cr2ssw6164g1LYyrtnki6Dg0/e12so5sKO5tgaK 0r/98CTVKBzr1a6eVtx1MQqf7gPO8FS3u/jv0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=M8xlxmqM+kUlvtiM8aPBkg6K2f2wMeSgYMfFemYjSj0=; b=Pax6pCXae+4bf1MDd0/PVws6LCvPlKE1lMmkaFKoK9Vh7euG8bqDyJUPxb0mD6OOsl KOPRYNHyf2kmGyKjM65Msvbc+/dhgfY2Q0iNKF7GYsstqE0pCDnGKscjOTSB7F8WDs3k +YjX6yORE/53nwCXtKik5RC5rEB16WQq4q6J05WN/3lWNnIElH3afx48pgxa7Cmk+Z1i euTdDD4fGxgyytCVZu8Sd6kv2k8lbetlLre9jxNt8no738Q4/sWn9G5mTEzgP8QE2/6M 3WFYexm3tv2SG9RXMwZ+zWCwqxAQTrLO+4mdx/K5MWeTMDPzdVvAhrkUDGR3qjNkhy7P kDrQ== X-Gm-Message-State: AKwxytevgGv1Lt57sRgh5WTd5ZHosj1CZrVbwIYwATMRECVQZfLgJYx4 CJlJwyKNBSs9vg+ljEDou6rpQYcxYdNDG+nFhk8ieA== X-Received: by 10.107.20.194 with SMTP id 185mr33172499iou.127.1517409315484; Wed, 31 Jan 2018 06:35:15 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.112.13 with HTTP; Wed, 31 Jan 2018 06:35:14 -0800 (PST) In-Reply-To: <49853e5e-f093-2e79-1cfb-182f51fcd6a0@arm.com> 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> From: Ard Biesheuvel Date: Wed, 31 Jan 2018 14:35:14 +0000 Message-ID: Subject: Re: [PATCH v2 16/16] arm64: Add ARM_SMCCC_ARCH_WORKAROUND_1 BP hardening support To: Marc Zyngier Cc: Hanjun Guo , Linux Kernel Mailing List , linux-arm-kernel , kvmarm , Catalin Marinas , Will Deacon , Peter Maydell , Christoffer Dall , Lorenzo Pieralisi , Mark Rutland , Robin Murphy , Jon Masters Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 =3D 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_ver= sion, >>> __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 > 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: =E2=80=A2 SMCCC_ARCH_WORKAROUND_1 must not be invoked on any PE in the syst= em, and =E2=80=A2 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.