Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1310754pxu; Mon, 23 Nov 2020 18:01:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJx5rHlG0PqRqtBYnVTQsUn/Vge5Yan7DIrjTqiN5e9D4L3bdTwA4H+Sx7KEIrOzybyZzQtx X-Received: by 2002:aa7:d709:: with SMTP id t9mr1972443edq.305.1606183304924; Mon, 23 Nov 2020 18:01:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606183304; cv=none; d=google.com; s=arc-20160816; b=KsfRZpifrVuL09rTrIldBfN0HvSrkBj4Ta/6vGNdyOeH03HVGs1ZazfqLrjz1yJMAx KCadhPP0MWTjgn5HnkqoEVk3AR4ab/od0rRVkhrd4z0G4JNn2bEYMtQk46z40MD8G2VJ REE5qeG211Bm1TrkaJ9xnVjIHtNc5xavdbRbq+G+aCcyXP+eWeflqQV0HDzE1c8JImp7 jdDIPxmOKFor/FFmkPHa+cqB+apfplH/To4/pD9ew8YvzgaK00bHCL5aIWDmBEw4Bys9 QwJyjTqSSRU6CzLHYBSDtyyZSDcyj/kvCK+sJR/4Y/5rSKxFrUdcx9atE6SIaCssoQUP AdZg== 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=5Af32ATk450q4cf+EpCpu1ifmrPXOjR+axfMFUTZHzg=; b=ecDwPJV43I7ml+T5sR+mLOBntwiA2XSYPfcrF7mujwlKZWKcwZJjRbnWayez/wJ0k2 gqI6hLvF5thl+1R5rlXvQy5m3wBy3q5Qg15bE8pZQETQvpGspbvxFUg+TrUUd6kBxxCF wrRib/FgRTQ3iaYl2+FgrgsHwpZpTfS8Esvdx1UpJzayjMK4YIVTbr+ghSUvqP1jowcS 8G5m/VNH3JYOQE6rPdKmnl8xkY6YeaNLH7dX/v7ZsUAjvy9jPLm2GNkQD6yFDQOcU4AE ysqckLPrD5GIgz0dWluZSH+1jY57sMH6G+fKjQIu/9TFOjKJZnN/QOpgVfuxTKLlMufT fVHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2WcpdZaJ; 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 z23si4558040edl.420.2020.11.23.18.01.22; Mon, 23 Nov 2020 18:01:44 -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=2WcpdZaJ; 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 S1730914AbgKWMo5 (ORCPT + 99 others); Mon, 23 Nov 2020 07:44:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:56924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733112AbgKWMnm (ORCPT ); Mon, 23 Nov 2020 07:43:42 -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 2388C20732; Mon, 23 Nov 2020 12:43:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606135421; bh=dcc9ZYODhGy88IwftRQKbI3ECgtQ+Xsb/S2yYHQYT2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2WcpdZaJPs87ncFIUWlMpf7uXGp+w0D7aJPX3nIdHDoWc4ZMv2EyRXM9iFn/Rry71 9DGCKNdvFQVfDR7EpcAIXKLs1WAM/7ri8SwjoFX1xFiKABGgaIBzvdamBV3BTqWt2K h/UZHA9wTxAOG/BsFyALhgB5swBwKxvNXZotqwI4= 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.9 063/252] arm64: errata: Fix handling of 1418040 with late CPU onlining Date: Mon, 23 Nov 2020 13:20:13 +0100 Message-Id: <20201123121838.634027747@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121835.580259631@linuxfoundation.org> References: <20201123121835.580259631@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 89b4f0142c287..a986ecd0b0074 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -268,6 +268,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 f1804496b9350..2da5f3f9d345f 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -526,14 +526,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