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=-11.5 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,USER_AGENT_SANE_1 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 26669C2D0A3 for ; Fri, 6 Nov 2020 12:29:57 +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 8966F2071A for ; Fri, 6 Nov 2020 12:29:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="wzNy+JKY"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="zIvKc/Bi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8966F2071A 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-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vCyqZM0RCoQzbFFKktOXGpPhKrEQQZzNEjbNtBWT9LQ=; b=wzNy+JKYipv6bMoH2GZajwK5S ZC5nQ1UNkKm+6ajLxSpZJPZAUGQRuNo6bxb3lB/osOkKLQzH4qq5CAKaTiniPC7+Mbq3B+YSBfbRo vBwyEqRkdMVEwOGtvivxpCBKIT7e+GPINQsT5vuyvCcQTr8tPXknBFdK7DizF0MmRtARfcny76ed0 sgHbcdfrzEBBoxh4jcxlwCmmzA+DUb1WfQwu06Rpgdl8ZO9qnOqA4ZlKQo9oUl4ACvMXilZGt4J3F jxSeOKHGcq/xs9IjeO+Io6Wz8oYlbw3e0Q35VZS0ykO5lQ3SoBywdydX72dcVfYJ9C0tQDHKurENb 605bwPWDQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kb0rL-0002a5-UU; Fri, 06 Nov 2020 12:28:51 +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 1kb0rI-0002ZP-Tw for linux-arm-kernel@lists.infradead.org; Fri, 06 Nov 2020 12:28:50 +0000 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (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 4C5432071A; Fri, 6 Nov 2020 12:28:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604665727; bh=2GrOb9ZrfUEyeaQtyY5SUfUg45IUjZlpA5n1HJYawm4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=zIvKc/BisSmU+R7ptgovED4dPAK+MVWkAGvICfZZo67pM4oY3BZr+t939dNIO7xgu 23wKlgmPQ1zB6kGiVtjl0AAvgOJJ6gmSyuSsC+sgKwMRDHXOc7yjRMHIBkgqhyt78l XEhN6Dh+iUHornUN2PCP9FkUpp4DWkpr4tw4p+90= Date: Fri, 6 Nov 2020 12:28:42 +0000 From: Will Deacon To: Suzuki K Poulose Subject: Re: [PATCH] arm64: errata: Fix handling of 1418040 with late CPU onlining Message-ID: <20201106122842.GA10317@willie-the-truck> References: <20201106114952.10032-1-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201106_072849_591484_17326DFC X-CRM114-Status: GOOD ( 31.52 ) 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 , Marc Zyngier , Stephen Boyd , Catalin Marinas , kernel-team@android.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Nov 06, 2020 at 12:18:32PM +0000, Suzuki K Poulose wrote: > On 11/6/20 11:49 AM, 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. > > The capability state is not altered after the SMP boot for all types > of caps. The weak caps are there to allow a late CPU to turn online > without getting "banned". This may be something we could relax with > a new flag in the scope. I did look briefly into that, but it's really difficult to enable the static key as this operation can block so you end up having to defer it past the point of signalling the completion back to the CPU doing cpu_up(). So I figured I'd focus on fixing the current problem for now. > > 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()! > > This comment applies to all the types, so it may be confusing. And the > comment already mentions that the feature is detected at boot time. The other types don't allow a late CPU to come online with the feature though, so I don't think it's quite the same. Given that we made this mistake for this erratum workaround and previously for SSBS, I wanted to add something to the comment to try to avoid others falling into this trap. Ideally, we'd warn when calling cpus_have_*cap() for one of these things, but that adds runtime cost that we'd probably have to gate behind a DEBUG option. > > */ > > #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; > > val = read_sysreg(cntkctl_el1); > > > > > This change as such looks good to me. > > Reviewed-by: Suzuki K Poulose Thanks! Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel