Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp276808imb; Thu, 28 Feb 2019 23:52:42 -0800 (PST) X-Google-Smtp-Source: APXvYqy1K8jpbSE+V2NRgXsG0K63LOdKfVUVjrcb36zenIXkJyZx0Z2QWtvrXfUIoGKfhQZQvit2 X-Received: by 2002:a65:60c7:: with SMTP id r7mr3675576pgv.37.1551426762402; Thu, 28 Feb 2019 23:52:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551426762; cv=none; d=google.com; s=arc-20160816; b=rSCe4O8prVxn+RKeeoyS55WRpt0Ha++ROtzCTEQChVcqgRRmwX8slhJgX0SmoA1eqw g7CW4NeD+mpDH9gIqjv1lCkJlBEDy9+sSqQ4ErTeeEizIPhNuu/N0uFz+8cOD8S5qtNN NTA1qog8aVFzZypPLq1hl6Yaztl+jaIw60DaUIMZaBTkNyrP9nc6hwOhLi/vTg9vcGfS 6MwYkGWookCiAEe56VzmHCT7WIn0JgyxIEmPSTUV42+UZzSY5xJk9wx6/m7DoELEeXnh BpInAoUXBme/u6iYE/othX+uV7AYkG7sXNE6cW2fXHC3bqjhF6RcCRSjGuO1BB6xNF37 GmlQ== 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:from:references:cc:to:subject; bh=AjYjC8ZfUaG6f/DeLSU8AyCg4RanY2ZjpTIPMnd1Dt0=; b=llQUL2jpUPnkr2+OrfLtY2//ox0ZX2t7Rd64y9m7khV+Wq1xGUq/pmvm2yJs7z+C5T b3yHRUtmTOx0cGUiXLgBYRy+dDVNX4HthI0NTj18Ft2lIY16qg6hDPd4fEFU4QP7sg6d xlrIxuqzNmMZTZESAUohFx8s3+1KT+wjk+HgQJt5BaLTiGp3USXdXEomHEpmkxUta98C fejZI1QqqZYV2KbZl8DP6IdxZcntfS5Q3++GvD9gC7dR2Gmq0Xf7uqvO4m7LpFZWyODF W/A2R2lIrhFlvKNirN1D0bAGKhbESLtDy40ug3OQHBHTUV2I5zxzRGrHbQIDfNWcNP1p YY1w== 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 a13si19645938pls.101.2019.02.28.23.52.27; Thu, 28 Feb 2019 23:52:42 -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 S1728279AbfCAG6X (ORCPT + 99 others); Fri, 1 Mar 2019 01:58:23 -0500 Received: from foss.arm.com ([217.140.101.70]:58620 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726025AbfCAG6X (ORCPT ); Fri, 1 Mar 2019 01:58:23 -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 DEF36EBD; Thu, 28 Feb 2019 22:58:22 -0800 (PST) Received: from [172.20.0.134] (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0D7653F5C1; Thu, 28 Feb 2019 22:58:21 -0800 (PST) Subject: Re: [PATCH v5 05/10] arm64: Use firmware to detect CPUs that are not affected by Spectre-v2 To: Jeremy Linton , linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, marc.zyngier@arm.com, suzuki.poulose@arm.com, Dave.Martin@arm.com, shankerd@codeaurora.org, julien.thierry@arm.com, mlangsdo@redhat.com, stefan.wahren@i2e.com, linux-kernel@vger.kernel.org References: <20190227010544.597579-1-jeremy.linton@arm.com> <20190227010544.597579-6-jeremy.linton@arm.com> From: Andre Przywara Message-ID: Date: Fri, 1 Mar 2019 00:58:19 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20190227010544.597579-6-jeremy.linton@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 2/26/19 7:05 PM, Jeremy Linton wrote: > From: Marc Zyngier > > The SMCCC ARCH_WORKAROUND_1 service can indicate that although the > firmware knows about the Spectre-v2 mitigation, this particular > CPU is not vulnerable, and it is thus not necessary to call > the firmware on this CPU. > > Let's use this information to our benefit. Yes, that matches the firmware interface description. > Signed-off-by: Marc Zyngier > Signed-off-by: Jeremy Linton Reviewed-by: Andre Przywara Cheers, Andre. > --- > arch/arm64/kernel/cpu_errata.c | 32 +++++++++++++++++++++++--------- > 1 file changed, 23 insertions(+), 9 deletions(-) > > diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c > index c8972255b365..77f021e78a28 100644 > --- a/arch/arm64/kernel/cpu_errata.c > +++ b/arch/arm64/kernel/cpu_errata.c > @@ -230,22 +230,36 @@ static int detect_harden_bp_fw(void) > case PSCI_CONDUIT_HVC: > arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID, > ARM_SMCCC_ARCH_WORKAROUND_1, &res); > - if ((int)res.a0 < 0) > + switch ((int)res.a0) { > + case 1: > + /* Firmware says we're just fine */ > + return 0; > + case 0: > + cb = call_hvc_arch_workaround_1; > + /* This is a guest, no need to patch KVM vectors */ > + smccc_start = NULL; > + smccc_end = NULL; > + break; > + default: > return -1; > - cb = call_hvc_arch_workaround_1; > - /* This is a guest, no need to patch KVM vectors */ > - smccc_start = NULL; > - smccc_end = NULL; > + } > break; > > case PSCI_CONDUIT_SMC: > arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID, > ARM_SMCCC_ARCH_WORKAROUND_1, &res); > - if ((int)res.a0 < 0) > + switch ((int)res.a0) { > + case 1: > + /* Firmware says we're just fine */ > + return 0; > + case 0: > + cb = call_smc_arch_workaround_1; > + smccc_start = __smccc_workaround_1_smc_start; > + smccc_end = __smccc_workaround_1_smc_end; > + break; > + default: > return -1; > - cb = call_smc_arch_workaround_1; > - smccc_start = __smccc_workaround_1_smc_start; > - smccc_end = __smccc_workaround_1_smc_end; > + } > break; > > default: >