Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2161235iof; Tue, 7 Jun 2022 21:47:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw69aRyQrJyEcdMBRuskjoaWGf/ujllgfzAZMXH/5LL5AoWt6dp5vMWjpzzfzcGFJg37A1J X-Received: by 2002:a63:87c2:0:b0:3fe:ac5:5d25 with SMTP id i185-20020a6387c2000000b003fe0ac55d25mr5045881pge.153.1654663674490; Tue, 07 Jun 2022 21:47:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654663674; cv=none; d=google.com; s=arc-20160816; b=iVy2D5ObU+RQLEK6hGxAy3gNd/c7/RR76GKjyiT2/u0oEQZd3q2xtDWbS8ZN9raOEz dTA8R7lHNJpbEyBsFhJ+pexV8HARIhGDvwlKc63SJ389dKme7b+KcIVGWhBpllDYRDML FSaPX+IFORZpk6oqa/3toyP7kKJiRnqw8Nq5bY0A1/EzCCdczv6YJraKbaBs3lA6ZcwI akOhoIN05bixcdKPLZYKmXSjUFl+uT995AYGc/wILykh4xE8vNYdkz8XdFDxjTJgnXYM Yn4DP2gQj95SQA+yPdw/89Po6LPxPRmP2O1zplUA7CEpnzamOu7gWdnasLemxPd+WifC kK6A== 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=ycXP/dAuC49AQ8S8jw/Ve3csVEGbkTqNqP8nJZyfaGg=; b=bknPAm1AvNnfaqEegd8a+rx8BDpd9iK4QDGyHv7vbStLBfPNZrIgEX/YYuL16IjZj7 yUGqYnXsrW7tB8zqS6i6TMcBlRyWpAgQ7Ufu9SvbS/xpA26izoxsUyvNB9Jm7JiZ1CfZ ONwWGEIUip8tspbYPWRpwb3nGH3grYD85CQrsjEHx+zv5xSO8xe/IRNKV3aITNrk1Yhg mEAqIgB+G0F3uuZh5cxjOHGuFcV99zhojbYgH8lgBrF6spxNidhxM/Rsnom7TUCAkG+H I0JBcawbOOJEIwW4s1HQyfK/rQe4l2OEcrI/7yubcwFBKMqGMptr05lGTlcQD5/3FJHm L/ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U0TmU5k6; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k8-20020a056a00168800b00518d5ac69a1si30054007pfc.216.2022.06.07.21.47.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:47:54 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U0TmU5k6; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 14CDC38DD37; Tue, 7 Jun 2022 21:19:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350052AbiFGSFT (ORCPT + 99 others); Tue, 7 Jun 2022 14:05:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349034AbiFGRqn (ORCPT ); Tue, 7 Jun 2022 13:46:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09EDC2BD; Tue, 7 Jun 2022 10:36:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DF9D8614D8; Tue, 7 Jun 2022 17:36:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE4F7C385A5; Tue, 7 Jun 2022 17:36:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654623368; bh=ZsBH+abYMj2l1STkIQRTzR0SQKeKcobrxNXlw/MWR3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U0TmU5k6UpxTW8fGczsqT81tVPo9CdmtgAI0gjlUgg5SX1NdcG/+4ijXgVt7W7yQg HBNoVIoa/X8Zh9O5YXREPsng2EcRdachLg5+mx8UbrN156MMoTaPQDIDv6zIXMRBSA ldz3TN2HJnMWGb0NonvP5Rgc+fOmwfGZMwJfSqfU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guo Ren , Guo Ren , Masami Hiramatsu Subject: [PATCH 5.10 393/452] csky: patch_text: Fixup last cpu should be master Date: Tue, 7 Jun 2022 19:04:10 +0200 Message-Id: <20220607164920.274774457@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guo Ren commit 8c4d16471e2babe9bdfe41d6ef724526629696cb upstream. These patch_text implementations are using stop_machine_cpuslocked infrastructure with atomic cpu_count. The original idea: When the master CPU patch_text, the others should wait for it. But current implementation is using the first CPU as master, which couldn't guarantee the remaining CPUs are waiting. This patch changes the last CPU as the master to solve the potential risk. Fixes: 33e53ae1ce41 ("csky: Add kprobes supported") Signed-off-by: Guo Ren Signed-off-by: Guo Ren Reviewed-by: Masami Hiramatsu Cc: Signed-off-by: Greg Kroah-Hartman --- arch/csky/kernel/probes/kprobes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/csky/kernel/probes/kprobes.c +++ b/arch/csky/kernel/probes/kprobes.c @@ -28,7 +28,7 @@ static int __kprobes patch_text_cb(void struct csky_insn_patch *param = priv; unsigned int addr = (unsigned int)param->addr; - if (atomic_inc_return(¶m->cpu_count) == 1) { + if (atomic_inc_return(¶m->cpu_count) == num_online_cpus()) { *(u16 *) addr = cpu_to_le16(param->opcode); dcache_wb_range(addr, addr + 2); atomic_inc(¶m->cpu_count);