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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_2 autolearn=no 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 32757C433B4 for ; Thu, 6 May 2021 13:25:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA76B613E8 for ; Thu, 6 May 2021 13:25:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233887AbhEFN0w (ORCPT ); Thu, 6 May 2021 09:26:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:59528 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230381AbhEFN0v (ORCPT ); Thu, 6 May 2021 09:26:51 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (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 D3735613DA; Thu, 6 May 2021 13:25:51 +0000 (UTC) Date: Thu, 6 May 2021 09:25:50 -0400 From: Steven Rostedt To: Palmer Dabbelt Cc: linux-riscv@lists.infradead.org, mingo@redhat.com, Paul Walmsley , aou@eecs.berkeley.edu, mhiramat@kernel.org, zong.li@sifive.com, guoren@linux.alibaba.com, Atish Patra , linux-kernel@vger.kernel.org, kernel-team@android.com, Palmer Dabbelt , Changbin Du Subject: Re: [PATCH] RISC-V: Don't check text_mutex during stop_machine Message-ID: <20210506092550.6c2206b3@gandalf.local.home> In-Reply-To: <20210506071041.417854-1-palmer@dabbelt.com> References: <20210506071041.417854-1-palmer@dabbelt.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 6 May 2021 00:10:41 -0700 Palmer Dabbelt wrote: > --- > In theory we should be able to avoid using stop_machine() with some > clever code sequences, but that's too big of a change to be considered a > fix. I also can't find the text I thought was in the ISA manual about > the allowed behaviors for concurrent modification of the instruction > stream, so I might have just mis-remembered that. > --- I wonder if you could at least use break points, as some other archs do, and what x86 does. If you have this make believe machine code: 00 00 00 00 nop And you want to turn it into a call. aa 12 34 56 bl ftrace_caller And if your architecture has a way to inject a break point on live code. Let's call this FF for the break point code. You can inject that first: FF 00 00 00 sync all CPUs where now all callers will hit this and jump to the break point handler, which simply does: ip = ip + 4; return; and returns back to the instruction after this nop/call. Change the rest of the instruction. FF 12 34 56 sync all CPUs so that they all see this new instruction, but are still triggering the break point. Then finally remove the break point. aa 12 34 56 And you just switched from the nop to the call without using stop machine. -- Steve