Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp535910rwd; Thu, 1 Jun 2023 03:42:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7hOzASwG/fsdkOgtHXefQNf28AsxNTRmwct0P0qQT4ncZ6hhnTYLKt0Z9j17x0grniAAa2 X-Received: by 2002:a92:d791:0:b0:338:d170:6e32 with SMTP id d17-20020a92d791000000b00338d1706e32mr6352076iln.7.1685616126871; Thu, 01 Jun 2023 03:42:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685616126; cv=none; d=google.com; s=arc-20160816; b=KdvUaysxMkKDZkWYey8V/fZOUFWxBZzyqh8inOt3RTPN3cxpedhheyJmEaVs0Ts4vH xXHSpScwAlrSZOjoKLvHEd2d1Dq1lMWo1bL//NSTmmBgm2bdLhR44Jp5YYIv+FvymImm r43yuj7rya1B3Hi1gsasevCPaAqdURkLsrsFOh18Y+OFCGPDbDmfUYxvyVKtYxnW1+3n ug5dcGZVfcgra5JuPu72GmC0BrHaQrrSGc08WfM0PAKmRnayQ3Z/NOPx4obmfwODr398 fCuCnBK2zI/eU8tjRE4uIi6WFlbBU9FcBsKGboilQ986BmTGinqe2tw9z7AuTegGUtcq aVdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=eO/OU9rxkp8hXKcShXmqMYIGO9NNy/sl1o++FVK8OV8=; b=qS2fn5KKK+KkhPTjew7QY6vd4OU6NtGMxzuDJVo+ZPLTTyvLelSyr37ACMVaXK6FBh HnsX/lBYsE6GEthv4RzWbiYaGa3Xsg/oU3KdM3bTVO8jyj/uNFTPeYbljM6HV1XFSxai 3rzJviP2YzuuUuM/tjJfqRE/N3iuq3YN42eWoJ8E1D8NWd5cmMPDSV8oo9PWh83sF9IZ p+y/STCr/tp7IcGonmQvVd+3IgV4Zqhfuy20WYnXDc2m8Rg/lnPsQQblupo/MZKhDBkl 8c0JJ1c7a3xTXrjq7s4Oey7w3rkweg0ae5UWiRnbcP4vpu34Jux1gqfJO0ZaBz20+QfV XoZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=j5qEB66O; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w4-20020a637b04000000b0053439c18c47si357843pgc.240.2023.06.01.03.41.54; Thu, 01 Jun 2023 03:42:06 -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=@infradead.org header.s=casper.20170209 header.b=j5qEB66O; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232439AbjFAKbx (ORCPT + 99 others); Thu, 1 Jun 2023 06:31:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232289AbjFAKbt (ORCPT ); Thu, 1 Jun 2023 06:31:49 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EFFD137; Thu, 1 Jun 2023 03:31:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=eO/OU9rxkp8hXKcShXmqMYIGO9NNy/sl1o++FVK8OV8=; b=j5qEB66OyejLhukROTeex8RZO2 8KI1zzfHFM0FSLCqza9uhEVgX/c6zEyu5qHGxX7CJjO0P8cMHhiatrGDyBr1rwPhvt1GBzYI3w9hK 7k0I9xbsAZWFem/1PDEo2VNDt00sI8oyAzzTxJA4uo4MvXyvrVy0amUmV0Fe6tnUgHehB/WpCQHa0 E82Y4vUZviXiJKDYelnzUm/Nrm/arC8TppikUDhcTNAzuZOH6BUuoSoQ5fKrxoZnJc+dZbGtWiKRX XlzWY1ePr9L+jMWFfjfVYehLflBFoPhhFwj8zZHz6jYQh5Ua/7Uf898zVO4+XMxyKyYJVXo3IJNI+ 6+NetZlw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1q4fa1-008HDp-EN; Thu, 01 Jun 2023 10:30:53 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 3A54F30031F; Thu, 1 Jun 2023 12:30:51 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0D9D021484ABB; Thu, 1 Jun 2023 12:30:51 +0200 (CEST) Date: Thu, 1 Jun 2023 12:30:50 +0200 From: Peter Zijlstra To: Mike Rapoport Cc: linux-kernel@vger.kernel.org, Andrew Morton , Catalin Marinas , Christophe Leroy , "David S. Miller" , Dinh Nguyen , Heiko Carstens , Helge Deller , Huacai Chen , Kent Overstreet , Luis Chamberlain , Michael Ellerman , "Naveen N. Rao" , Palmer Dabbelt , Russell King , Song Liu , Steven Rostedt , Thomas Bogendoerfer , Thomas Gleixner , Will Deacon , bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, sparclinux@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH 12/13] x86/jitalloc: prepare to allocate exectuatble memory as ROX Message-ID: <20230601103050.GT4253@hirez.programming.kicks-ass.net> References: <20230601101257.530867-1-rppt@kernel.org> <20230601101257.530867-13-rppt@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230601101257.530867-13-rppt@kernel.org> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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 On Thu, Jun 01, 2023 at 01:12:56PM +0300, Mike Rapoport wrote: > +static void __init_or_module do_text_poke(void *addr, const void *opcode, size_t len) > +{ > + if (system_state < SYSTEM_RUNNING) { > + text_poke_early(addr, opcode, len); > + } else { > + mutex_lock(&text_mutex); > + text_poke(addr, opcode, len); > + mutex_unlock(&text_mutex); > + } > +} So I don't much like do_text_poke(); why? > diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c > index aa99536b824c..d50595f2c1a6 100644 > --- a/arch/x86/kernel/ftrace.c > +++ b/arch/x86/kernel/ftrace.c > @@ -118,10 +118,13 @@ ftrace_modify_code_direct(unsigned long ip, const char *old_code, > return ret; > > /* replace the text with the new text */ > - if (ftrace_poke_late) > + if (ftrace_poke_late) { > text_poke_queue((void *)ip, new_code, MCOUNT_INSN_SIZE, NULL); > - else > - text_poke_early((void *)ip, new_code, MCOUNT_INSN_SIZE); > + } else { > + mutex_lock(&text_mutex); > + text_poke((void *)ip, new_code, MCOUNT_INSN_SIZE); > + mutex_unlock(&text_mutex); > + } > return 0; > } And in the above case it's actively wrong for loosing the _queue() thing.