Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1238138pxu; Mon, 23 Nov 2020 15:36:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyP3QFSSLjQ2UHzRE64FrpXz3n2U5L2/M1+QFLhZriequrEJKP9jqz6OIsMqZ7ajdvGYjMM X-Received: by 2002:a05:6402:308b:: with SMTP id de11mr1542128edb.5.1606174575421; Mon, 23 Nov 2020 15:36:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606174575; cv=none; d=google.com; s=arc-20160816; b=pEjgttP6vFdKoPG7zIYSPT/Qx8vQ2y5rmLMexseSa/cgNsKj4evafpjmZDck2TRWdp IWu8l+XyV8KgUoEuUIZaMZOwPx5sEM9w4vmI6xJYrad9mF0hXY9MYsnozj0ms/TbfJRV jt24nboPyKTLQkjG21GyYxIsGBL+9Sns6LAdGqTPHc10ZcZZ9bHnAaz7TWIvbu16Oo3l TSv2A9DuyDERM9F+ke/Er2Cr+HtqRhxyU+tFtPnb0WMlQBkVTn0qbhriQOYv5tYm7hgh QJPu1C+i3Llckv7+OJpmTok5h1SVvn0HCTeGs9DNxqg7YSTURJAy/zzP4uzEtykPBqoH zuOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4L04tYJ0pKs/rUgBluata2vXUVobVL39IHAfz7HsaYU=; b=VX/x4FYHaYbEJOalrYXDabeZIMuE9ZP7T1nBcrX5ts2eTGiMN04sOfFnT2JoWsRoPJ 97OmtcMgxnIBZBQZDJK9IuNERymTT20LRVa6z7Eftdm1f89v3poKnYnRB5ulAQAxsd6O 7CqAGASXZqMOIHNGQ9crGNxXOrrZSN0Ypl21Xz7U5OdVWhKLJx6UI7FMGd406m3ShRxD 5O+iCprTPiaDQHifOs4QBm6XPjh3YaAYW09n/P6ktU4akRK7uM9wbztBRBJH8rLO/yIU D/13kOS4x16YMm6SEuDQyrSSrNWbudomCIpm2UFid29L2QX9CtodHA05LE43Eek75pJP ltGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dn6Svqg5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b13si7326639eje.225.2020.11.23.15.35.53; Mon, 23 Nov 2020 15:36:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dn6Svqg5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731501AbgKWMfS (ORCPT + 99 others); Mon, 23 Nov 2020 07:35:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:47202 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731493AbgKWMfO (ORCPT ); Mon, 23 Nov 2020 07:35:14 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A5BBF20857; Mon, 23 Nov 2020 12:35:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134914; bh=mn5e3Dlske3ZUDRWwFsai4wH+HucmlGe0HDn+//g7NM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dn6Svqg5yuHZ9ycOF6sI6ppMdd9pp5uiQ4vtTvyDUO7UNEGA7iWyK34DxeeHgfC7x LgXmoJZCPvm0RL1X71CQM4mEwJz4JWSkoFnv4PI6fPW5/6dyf50HvmZEOv42odnvz/ wJIldw1QWOWHN7QFq9nYnLCqxyGJULVgAwskyM8I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sai Prakash Ranjan , Stephen Boyd , Catalin Marinas , Mark Rutland , Suzuki K Poulose , Marc Zyngier , Will Deacon , Sasha Levin Subject: [PATCH 5.4 038/158] arm64: errata: Fix handling of 1418040 with late CPU onlining Date: Mon, 23 Nov 2020 13:21:06 +0100 Message-Id: <20201123121821.770103880@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121819.943135899@linuxfoundation.org> References: <20201123121819.943135899@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Will Deacon [ Upstream commit f969f03888b9438fdb227b6460d99ede5737326d ] In a surprising turn of events, it transpires that CPU capabilities configured as ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE are never set as the result of late-onlining. Therefore our handling of erratum 1418040 does not get activated if it is not required by any of the boot CPUs, even though we allow late-onlining of an affected CPU. In order to get things working again, replace the cpus_have_const_cap() invocation with an explicit check for the current CPU using this_cpu_has_cap(). Cc: Sai Prakash Ranjan Cc: Stephen Boyd Cc: Catalin Marinas Cc: Mark Rutland Reviewed-by: Suzuki K Poulose Acked-by: Marc Zyngier Link: https://lore.kernel.org/r/20201106114952.10032-1-will@kernel.org Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/include/asm/cpufeature.h | 2 ++ arch/arm64/kernel/process.c | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 10d3048dec7c2..ccae05da98a7f 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -262,6 +262,8 @@ extern struct arm64_ftr_reg arm64_ftr_reg_ctrel0; /* * CPU feature detected at boot time based on feature of one or more CPUs. * All possible conflicts for a late CPU are ignored. + * NOTE: this means that a late CPU with the feature will *not* cause the + * capability to be advertised by cpus_have_*cap()! */ #define ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE \ (ARM64_CPUCAP_SCOPE_LOCAL_CPU | \ diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 10190c4b16dc4..7d7cfa128b71b 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -511,14 +511,13 @@ static void erratum_1418040_thread_switch(struct task_struct *prev, bool prev32, next32; u64 val; - if (!(IS_ENABLED(CONFIG_ARM64_ERRATUM_1418040) && - cpus_have_const_cap(ARM64_WORKAROUND_1418040))) + if (!IS_ENABLED(CONFIG_ARM64_ERRATUM_1418040)) return; prev32 = is_compat_thread(task_thread_info(prev)); next32 = is_compat_thread(task_thread_info(next)); - if (prev32 == next32) + if (prev32 == next32 || !this_cpu_has_cap(ARM64_WORKAROUND_1418040)) return; val = read_sysreg(cntkctl_el1); -- 2.27.0