Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4664710iob; Sun, 8 May 2022 21:08:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEoVL6Evukjv/OkGBitNF1nwg/gRUAVtof/SeEPwbbCrk1n9zBBRnvy31yHjBet329sd63 X-Received: by 2002:a17:90b:38d1:b0:1dc:902a:46fe with SMTP id nn17-20020a17090b38d100b001dc902a46femr16121923pjb.243.1652069320018; Sun, 08 May 2022 21:08:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652069320; cv=none; d=google.com; s=arc-20160816; b=z58mXMMjnlnsF64d8YQVirUY6eYUhxUbOFLMBMf4dSrhucagw2Eh6R5EcuxkwASqIz ZIRHVcNuuVJZfHUac3jvFJ4eH7HHAsZQPmr1qCBR6RedvCm9vSeGqYL/KphJduy+rzEH fqlQUrTCv4C6mYharXZVOhoSq/o2lnj84/RK+1Xyuft8MUfBJ+0lYrLD2iEyB/ztuQ3p fShvDwqWzZAkuynshydVya+mZFi6K5v8A86A3NzviYz8eR1zGL0YUSFxwqZ6+7u9pOc9 f9MrXHYNpQ0hNwf16RyUzUljnVgvJFf1DrVBC0IQNO/14rDeHm82VEyqswyjUNYFH7oL 6a0A== 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=nNW5lI/pBQQfSMGMDVVJrTBWW4CITWu25dOnoe33jIY=; b=DNYfhkTAxv8A5dqis+g3efCWEkZaEMpSvadMF/mjgZ7MIC1qfhZFfkmM2vlqh6afbR xVv8xK9vifgJvfqy/A0OCMSYKgPp6OIYmthQHFjnGi3qEJniFxk4qFxxITH+onpmG5nY nZolnwt4oWxkbzOmla2xvXM0lq4Yo5kG1AVQRMhCRxAksTiewBetxYFZlX+NuJ1e5D31 riRiDT3mGl0EUmKaDcc7gvQUeOnaZLA21iCI1R2JYDpLlzPwKKmpQkua/hXJQeewVNuk Auj5jtDV6NipeUVBK5ofR7I4C+sZyBr8GGrHLJRVTa1GIiohKxNGSb24wyZpsEX0aUiS Nftg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NMPAbiIn; 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 c24-20020a637258000000b003c64b1d1bdfsi10399684pgn.460.2022.05.08.21.08.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 21:08:40 -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=NMPAbiIn; 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 63750102778; Sun, 8 May 2022 21:06:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355342AbiEDRER (ORCPT + 99 others); Wed, 4 May 2022 13:04:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354608AbiEDQ6y (ORCPT ); Wed, 4 May 2022 12:58:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55D511FCC9; Wed, 4 May 2022 09:50:47 -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 ams.source.kernel.org (Postfix) with ESMTPS id 0AA20B82792; Wed, 4 May 2022 16:50:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D118C385A5; Wed, 4 May 2022 16:50:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683044; bh=Q0Kg/EArx821a5Fy8d/3If2cJ8xy+zC5AZDlUXUfY4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NMPAbiInIlGU2BJy4IOVg89jmWTenxY9sTdovHUCngY1P9H+Ud2dj4mVJG2UbnYJc 4uYcQLb/mP7WhyBHzKfDU/eEa6eB99gd0syYXrO2bPz1cj/wY46aMq6+C+eDTl9YDU 7Z4fsF5tNJOSkFAH47OEOlpj5uiNGFPgW889E5z8= 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.10 035/129] riscv: patch_text: Fixup last cpu should be master Date: Wed, 4 May 2022 18:43:47 +0200 Message-Id: <20220504153024.031128517@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153021.299025455@linuxfoundation.org> References: <20220504153021.299025455@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=-2.6 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 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 @@ -100,7 +100,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));