Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1075887iob; Wed, 4 May 2022 14:09:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYLm2RdnlQ7yWxplACdpDQXDw0Z/UWzfbxNAxbcIThfzWVGYhI8KltsQy1v2BDW9Sj4Qkw X-Received: by 2002:a17:907:9715:b0:6f4:6ab1:23c6 with SMTP id jg21-20020a170907971500b006f46ab123c6mr12606000ejc.144.1651698587001; Wed, 04 May 2022 14:09:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651698586; cv=none; d=google.com; s=arc-20160816; b=XYGvFM4XrgxXf8DPMg5tQK5kPJJDGXqCTrtHvh4kRWsw+QHa5Hir+KAEVFrv7itQ/f uDAdQXXFjMKiKnrl3xm8AjFhhK0CHqxxnrvq3Tu8D2GM1+/KeQ8kRmXRW7VXS2OQj3vI fIzss0HKLsSfADHJjdRpdwT/Q02n7pL2yNujR0uhIq4GwwSWM/57N3F3bUqseCctASPG IY3qs8UPVIreW5NBC+fYij3ifbowzXOZklrFxgHhTDY14x0f7XzCQqqSvXhUX1IPTnJi FNtLes6tNhvijwcIq3jsuQtF8vWmUCXhRbqMsHQkB4iA2kyHiWIzGUr32UuZuUlMDmM1 /DCQ== 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=usb885nJpU6h8UXigQxw216gCN0Ie7dmk1YgCBFV/fg=; b=rufiU+cGici5R0Qr5vJ+FNNR9qEiWFWecCTT3bZQBvQbH4NAVoeUcf58FLB6ydZmeZ SNouZv6kNN3WpI51cOx5RdMrPtT/+UwuawEIb50cIvnpp0zpvsJsG8gPimwlLndmhYxs LgyeCC3TORqITvDfPWAkA/persvbkRs46UvGaS9vuvWGfk2CsmtPVAqjM2sWjBlkQ+7O uiKGMjn8DRt0YqyNqaKy0AHBYmaA+CSguCFyoqKlz/1MNOrNETZqS7TOV4qIITuE76OO HG+Zyg5/7NMeCenyq2LMG0AD6gyy/AXeJHX1isis4lN8n+ko9GkqNRmgVHRKv4mk0Ti9 esFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mLbjDECk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z17-20020a170906271100b006f3e83ede10si8910683ejc.510.2022.05.04.14.09.23; Wed, 04 May 2022 14:09:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mLbjDECk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1356835AbiEDRls (ORCPT + 99 others); Wed, 4 May 2022 13:41:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356861AbiEDRJq (ORCPT ); Wed, 4 May 2022 13:09:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B374275E6; Wed, 4 May 2022 09:56:06 -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 05FE4617A6; Wed, 4 May 2022 16:56:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4ED0EC385A5; Wed, 4 May 2022 16:56:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683365; bh=NEBsSG0/XWJf6FprfNFMo2p3cGJLwBZ8OJmNqMRtIGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mLbjDECkTDndE1NZkmDq+Jk3BjRs+Gq/6huVdS3k2fw+32fmQBEOtUQXMTsHtuRWI mkBm8Ihegu78DBqdrJmxfHqEBVPmD+g5+VPJ2fErrivpVu9ONf8tPLSXseG9NrX8tb eBcgpcyY3K/l6yUikNnSnOwYIxmDrNER67E4+CWc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guo Ren , Guo Ren , Palmer Dabbelt , Masami Hiramatsu Subject: [PATCH 5.17 050/225] riscv: patch_text: Fixup last cpu should be master Date: Wed, 4 May 2022 18:44:48 +0200 Message-Id: <20220504153114.601300055@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153110.096069935@linuxfoundation.org> References: <20220504153110.096069935@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=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 8ec1442953c66a1d8462cccd8c20b7ba561f5915 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. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Acked-by: Palmer Dabbelt Reviewed-by: Masami Hiramatsu Fixes: 043cb41a85de ("riscv: introduce interfaces to patch kernel code") Cc: stable@vger.kernel.org Signed-off-by: Palmer Dabbelt Signed-off-by: Greg Kroah-Hartman --- arch/riscv/kernel/patch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/riscv/kernel/patch.c +++ b/arch/riscv/kernel/patch.c @@ -104,7 +104,7 @@ static int patch_text_cb(void *data) struct patch_insn *patch = data; int ret = 0; - if (atomic_inc_return(&patch->cpu_count) == 1) { + if (atomic_inc_return(&patch->cpu_count) == num_online_cpus()) { ret = patch_text_nosync(patch->addr, &patch->insn, GET_INSN_LENGTH(patch->insn));