Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2270168iof; Wed, 8 Jun 2022 01:01:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSLw1VRlTi3mBhDLJ1el6j4aJV70aPUrLIMwnG/nXflKj8PvHGaySBnsRoqwv+tSJCQQco X-Received: by 2002:a17:90b:4b51:b0:1e8:71cb:4d18 with SMTP id mi17-20020a17090b4b5100b001e871cb4d18mr18967665pjb.108.1654675296905; Wed, 08 Jun 2022 01:01:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654675296; cv=none; d=google.com; s=arc-20160816; b=prKi0zfUMo/3eFxdDcvU2i7zBETJqpWrmc+F1hFd1Q4krmCR4hiJspMyNYMKp4XZO7 GajFB57fTI7ASIrnKlbPiAO76mjq9sNcFxdC8UJJ3nbWOPgnc2NPPwkhFqeTaR8xa082 sUKfudnU4IRXmZ6CXE2zB9zguimShgZCWasMmfNo5Yv80x8yT7XKMPZdavP8+KLa/WNA vwnBDPlTLoEtypcEEuyCp62/nP6J0BO8wsHNnsVHX1v4Tr4h7kVAUgsJr6F/AP9RctFA zkE6sagaJkI8LsXsL7L4M3ZCwZ+ETje5nJbC6eFfPuPXsLIsBxSG5UdxWHlkUSXACETB ce6g== 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=/FPO8jQG372iLSV5nuaoiLw6AN9RwFisKPDtVnPZyqI=; b=gu45a1NeB4jhOEkY+p5Q79U6T33JR7IvIbC4ZVF0kf2tSMk7umWVei+8rEZeTHioXk yBVz++LXV8jwGZ9dLK4r3hg4TLW0+MAGWW2ZuntIKcsRzC/qA+i9nPPGTXVQxVumzaLL 31q9vqCDIMK91OKnv+7mVl1eFWgrlIOmqPgVQ5IXnJtLuEtjaV1kbqmN8joi9C25YLX/ KTDMFoM3+Kr/8EcDIJ+NE2NBVEBtedSa83DhuH2DsenPuS9FPGLuxB4nichuEUR16nzl l3qI9Hu3CDp145BKbFpkHe68s82ALPIpPJzSNKsJ3gYCBqsQqafjOVyMvrCBMNDyASwe suXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RCa9l8ut; 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 k13-20020a056a00134d00b0051c44065606si4603664pfu.357.2022.06.08.01.01.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:01:36 -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=RCa9l8ut; 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 117D91EE6C6; Wed, 8 Jun 2022 00:31:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378269AbiFGVmV (ORCPT + 99 others); Tue, 7 Jun 2022 17:42:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378552AbiFGUwP (ORCPT ); Tue, 7 Jun 2022 16:52:15 -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 9F4231248F1; Tue, 7 Jun 2022 11:42:26 -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 CBFA1615CE; Tue, 7 Jun 2022 18:42:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8B92C385A2; Tue, 7 Jun 2022 18:42:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654627345; bh=M/NcB8WX6Wqp97huGdzefR0XgbpT9OSioDVVk20zTLM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RCa9l8ut/cWRrsnqajJkEYS34MOkrnn9/jdsxUSGavt/d9en5Leoze0miDDv/xd3G qC/OSvQ3IYp223ekJaLEJ+lmv7beNN4PbKihBPCFqbjn1TqnN7XxmdxEn3oS1CNjJ4 bklndcumDA34WXP7yRPZeVcyY2YTEPuYJuwEUAbM= 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.17 707/772] csky: patch_text: Fixup last cpu should be master Date: Tue, 7 Jun 2022 19:04:59 +0200 Message-Id: <20220607165009.881028038@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164948.980838585@linuxfoundation.org> References: <20220607164948.980838585@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 @@ -30,7 +30,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);