From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AFEDC2D0A3 for ; Fri, 6 Nov 2020 12:16:07 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0D1FD20715 for ; Fri, 6 Nov 2020 12:16:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="RQN7jBoR"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="O5hRej54" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D1FD20715 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:References:In-Reply-To:Subject:To:From: Date:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=v3TihLAM6veoEihzmlscpyl9U7Xt4L6n2Q227ss0i7c=; b=RQN7jBoRRnlUmS2eENAXvt2+i jXaHs6cMiFmHVGlXcIO8NQtKJiUpu48wkcR++n06RjeoUXVIIaIM3oXyGklHZ8SGdRKqtl9BeItna 1Ij0xQH5jR6DQjhMWnjxgUovKtIOxQbG6pqQx6mHDo2MAOAXqTcJ/Xf05psRt43txitF2/yQ+wn+L 4uKF8RcfCS0x5EabURGeqMG7rasA/GynZqGhiwcYaZ96mkzR+lBUoSl94oc3s4DDs8oESNUxPXYuY 0GTzDgvDdwEk2y2VNUk6dDa8fLUa3LUry1NhWwp1vHg//5H8MOPQtGJzZ7PfDwEqCfs4mh8p1aC0L Q2e5ydiqA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kb0ed-0000yi-H7; Fri, 06 Nov 2020 12:15:43 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kb0eY-0000xI-Ur for linux-arm-kernel@lists.infradead.org; Fri, 06 Nov 2020 12:15:42 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (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 D10DE20715; Fri, 6 Nov 2020 12:15:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604664938; bh=VB1PBkNaM4nmlKVwBhKWBI+ogJ0IRcArbied6kvqJTg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=O5hRej54dGVgRdEKLLKGrG57h+1uqUi9jbKN28IENyI2EQY3zujIqqhGluMT8+RE/ 08ASvlSHKRCQ2W26txs+Pw8NsDueMJm802EGZw8pZGmyhJBD420giVjS/GrO4VMeAL H/jScJLUgMx/TBBXFkT+0It+KzcYjHEhDapOTjxI= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1kb0eU-008C5j-Np; Fri, 06 Nov 2020 12:15:34 +0000 MIME-Version: 1.0 Date: Fri, 06 Nov 2020 12:15:34 +0000 From: Marc Zyngier To: Will Deacon Subject: Re: [PATCH] arm64: errata: Fix handling of 1418040 with late CPU onlining In-Reply-To: <20201106114952.10032-1-will@kernel.org> References: <20201106114952.10032-1-will@kernel.org> User-Agent: Roundcube Webmail/1.4.9 Message-ID: <0df3bbc4d9060dbba49ba120d9d88e88@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: will@kernel.org, linux-arm-kernel@lists.infradead.org, kernel-team@android.com, saiprakash.ranjan@codeaurora.org, swboyd@chromium.org, catalin.marinas@arm.com, mark.rutland@arm.com, suzuki.poulose@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201106_071539_266898_50403863 X-CRM114-Status: GOOD ( 23.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Sai Prakash Ranjan , Suzuki Poulose , Catalin Marinas , Stephen Boyd , kernel-team@android.com, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2020-11-06 11:49, Will Deacon wrote: > 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: Marc Zyngier > Cc: Sai Prakash Ranjan > Cc: Stephen Boyd > Cc: Catalin Marinas > Cc: Mark Rutland > Cc: Suzuki Poulose > Signed-off-by: Will Deacon > --- > > Found by code inspection and compile-tested only, so I would really > appreciate a second look. > > 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 f7e7144af174..c59c16a6ea8b 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 4784011cecac..a47a40ec6ad9 100644 > --- a/arch/arm64/kernel/process.c > +++ b/arch/arm64/kernel/process.c > @@ -522,14 +522,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; It is not going to be cheap to switch between 32 and 64bit. Hopefully it doesn't happen too often... :-(. Acked-by: Marc Zyngier M. -- Jazz is not dead. It just smells funny... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel