Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5318211rwd; Mon, 5 Jun 2023 01:36:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5XIWMlGSEWcF5YuQ3GR+XsBbL5HhMgjqJy5dscOCMKAVHBIsg55IRDDQU9mP7eWWY4tc6M X-Received: by 2002:a05:6830:1bd4:b0:6b1:d368:557c with SMTP id v20-20020a0568301bd400b006b1d368557cmr1785198ota.30.1685954178449; Mon, 05 Jun 2023 01:36:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685954178; cv=none; d=google.com; s=arc-20160816; b=QfJ7CU442SFySAf2DXLCMypKu8NjKxHbKv/a1XdJu7xu+c20jQIJ7Z0KkhzhO5GAKH vQP/9IcJJGEbiscButs0oipoHUun2WMZvbUkHh86n0joBy2Q/a266Dyh/dYPjZcWV0PD XPfO7/DHcTL8nAPYg5zBWHze5WwkzXAkingRJmxYq/VT8ijJ3KujDJRf1qKW59bB/Ee8 R4SPMzbWS/PXp/dPFxs9MKq6iAETBsAexUW1/h4QYmGSEEtadrPe1M6HuGWHS1A25k/N tLX2cjboo2AF09JZHuBGns9r+MXmPacXVXS4A4d/PcgI/Z4SmSmwfLGd7FYpzqMbtrha 0WoQ== 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=jkNHqo5pHCbvvcy11hhXHfk6GgGg9ljvcrFzVmefyCQ=; b=R6mkGtrQxcIS7gKLB298x9dnwO/n16buuQizrauiNttEFHge6QtMJ3S7WWElgR7Bit XYd/mB6rh6ol6B83ywl2GdXRCAc6yIPOJQT0SriEb8p/RHI7c0sKEwYvyTNx+bRBZ6je r3G3QFowdgH+EgDj08R4FQiu0mCdkbhs01Hstuvv2XB1ut84iCzUZ8/R/2LDjzYDIcZp 2zME3NQotkBuU5qhKRPEisO3KJ3zmmwDDHGYzcye2+1CMrKopMtI7OxH+WoQBcLN1Ai7 R8XjY6wrgikgBwmR+JCeRRyVe6NDYE+7uYAVly3MxB/zTgWbsqd0fE3muznhUyJWR7ib ZLvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Zu6xmXaS; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h71-20020a63834a000000b00543ab0cbecfsi1694412pge.158.2023.06.05.01.36.04; Mon, 05 Jun 2023 01:36:18 -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=@kernel.org header.s=k20201202 header.b=Zu6xmXaS; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229952AbjFEIMP (ORCPT + 99 others); Mon, 5 Jun 2023 04:12:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbjFEIMO (ORCPT ); Mon, 5 Jun 2023 04:12:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42E82A1; Mon, 5 Jun 2023 01:12:13 -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 CEBAF61349; Mon, 5 Jun 2023 08:12:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD463C433D2; Mon, 5 Jun 2023 08:12:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685952732; bh=0a3Erj1+y05IXqjDMWsbKoIt+bMhOMaYKv6SbF8QYx8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Zu6xmXaSJOaYGEZ1M18sqNTyQoodb/FtprpnZS9jE7WS1RsqZh7vr80D82GP+H1i8 Qbu+kLGLXkmXcf2oXs54XG8W5AAc+Szj5iw7w1esJF0pl3B4pku9TUNP0nnZRtgroI L7ysBaeg9qWTT4omm1x3jmC2/a5iIXjq4VNltoSIXSnirdvBxVCgizUUrQFclxA9A9 JI6H8n/NsAtikP0Klus6G9HwEipbiVd/EmoeyXvbNSuuqp00lQftKP5siTorJJyFWk NlQqlLQB4dqezssu+rEQF7hm50+nogklsOxP5i6Esuay261E/tRiQMISJtPYoOP/Ua Cp41VdtuUrJ+Q== Date: Mon, 5 Jun 2023 11:11:43 +0300 From: Mike Rapoport To: Steven Rostedt Cc: Nadav Amit , "Edgecombe, Rick P" , "kent.overstreet@linux.dev" , Thomas Gleixner , "mcgrof@kernel.org" , "deller@gmx.de" , "netdev@vger.kernel.org" , "davem@davemloft.net" , "linux@armlinux.org.uk" , "linux-mips@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "hca@linux.ibm.com" , "catalin.marinas@arm.com" , "linux-kernel@vger.kernel.org" , "linux-riscv@lists.infradead.org" , "linux-s390@vger.kernel.org" , "palmer@dabbelt.com" , "chenhuacai@kernel.org" , "mpe@ellerman.id.au" , "x86@kernel.org" , "tsbogend@alpha.franken.de" , "linux-trace-kernel@vger.kernel.org" , "linux-parisc@vger.kernel.org" , "christophe.leroy@csgroup.eu" , Will Deacon , "dinguyen@kernel.org" , "naveen.n.rao@linux.ibm.com" , "sparclinux@vger.kernel.org" , "linux-modules@vger.kernel.org" , "bpf@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "song@kernel.org" , "linux-mm@kvack.org" , "loongarch@lists.linux.dev" , Andrew Morton Subject: Re: [PATCH 12/13] x86/jitalloc: prepare to allocate exectuatble memory as ROX Message-ID: <20230605081143.GA3460@kernel.org> References: <20230601101257.530867-1-rppt@kernel.org> <20230601101257.530867-13-rppt@kernel.org> <0f50ac52a5280d924beeb131e6e4717b6ad9fdf7.camel@intel.com> <68b8160454518387c53508717ba5ed5545ff0283.camel@intel.com> <50D768D7-15BF-43B8-A5FD-220B25595336@gmail.com> <20230604225244.65be9103@rorschach.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230604225244.65be9103@rorschach.local.home> X-Spam-Status: No, score=-7.1 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 On Sun, Jun 04, 2023 at 10:52:44PM -0400, Steven Rostedt wrote: > On Thu, 1 Jun 2023 16:54:36 -0700 > Nadav Amit wrote: > > > > The way text_poke() is used here, it is creating a new writable alias > > > and flushing it for *each* write to the module (like for each write of > > > an individual relocation, etc). I was just thinking it might warrant > > > some batching or something. > > I am not advocating to do so, but if you want to have many efficient > > writes, perhaps you can just disable CR0.WP. Just saying that if you > > are about to write all over the memory, text_poke() does not provide > > too much security for the poking thread. Heh, this is definitely and easier hack to implement :) > Batching does exist, which is what the text_poke_queue() thing does. For module loading text_poke_queue() will still be much slower than a bunch of memset()s for no good reason because we don't need all the complexity of text_poke_bp_batch() for module initialization because we are sure we are not patching live code. What we'd need here is a new batching mode that will create a writable alias mapping at the beginning of apply_relocate_*() and module_finalize(), then it will use memcpy() to that writable alias and will tear the mapping down in the end. Another option is to teach alternatives to update a writable copy rather than do in place changes like Song suggested. My feeling is that it will be more intrusive change though. > -- Steve > -- Sincerely yours, Mike.