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 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 76B95D3C92E for ; Sat, 19 Oct 2024 22:30:50 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4XWGVx0HDGz2yMX; Sun, 20 Oct 2024 09:30:49 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=147.75.193.91 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1729377048; cv=none; b=hmlJ+UXqXqAaP/ng3jZBPpfQEpaKSCkqvZ7gJliIdyVwzJPOrNZnRZ4dG0mzuroSVIv2NklQZN48bJRH1pl5z6D4YFLdhWtAkDFqTn0+xlb9KzaW24wnfHrR397vFFDajmWHIxR0ipzJ7gd7pXX/oNWg+cEwcoUOLdkMbc0nsVobmmuN3zEx7qnh0/MNrXh/FYp4gV8WWLi+ljOsnReP4Hnmtru1AuI2F29z1SSwrhapmA3Rv6lI8F8F0cYqIg93y5rRcLGpqs5reV6Dmel+aPfcfJ7J57fICMYvrbus3PwpLMUcYytewGLg0y+F1udTAl56mRzVZjWu76I9I6I2zQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1729377048; c=relaxed/relaxed; bh=VuHy1HrHdhUjSm/D9WaG63hW9NcA1Axd/7XrPQvY+Bo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=D34ku3R2UL6zS05C38kdWVag92xa/tuW273VD/8v6AMavA353XhGAR2ajmEiCuV6LtRTxaNHEY1tVCeTK8lJaDeWsa9RMpBEfcSTGF2QAFf7cIEjTke9BxWQBpWTAnC+PH2ZmToxYbB+HvlVwwyrdwllQYga26r9N5JdTztixgMK6FB9BPjyrLNPcf+EFWpk1I9PfqlBxBALN2CuLCoGVddRChV2Cb6Q5XeCwKURUcKFvzT0WXOVO0UBT2Swz057Vw6V6Xp5hdF2mSyodizHLnwqjgyOeNQ+bwJXB5d7d1WKpEgYguHTeKcL8mujqvhm8rY5H5xxyCRb7dpD1FF7Bw== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=CErL8/nt; dkim-atps=neutral; spf=pass (client-ip=147.75.193.91; helo=nyc.source.kernel.org; envelope-from=mcgrof@kernel.org; receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=CErL8/nt; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=147.75.193.91; helo=nyc.source.kernel.org; envelope-from=mcgrof@kernel.org; receiver=lists.ozlabs.org) Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4XWGVv6B3xz2yMP for ; Sun, 20 Oct 2024 09:30:47 +1100 (AEDT) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 0111FA40448; Sat, 19 Oct 2024 22:30:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF36EC4CEC5; Sat, 19 Oct 2024 22:30:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729377044; bh=QyfIXk+096xDFBJfNhGtA+h7+x144NJyXqGZEWCxEbA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CErL8/nta/6r/1WJkkwG/t5evnd+rztuMKPvEAcvD2SnHlbG8tiM8oebQum4YnbtM jKRTZBaC+ATcd4VCxL5682bSGxbHvqjRzPrn6cR/xecdWEBWr3gweQycvt1RfyCGs7 MiXNOy+V4Fewi4RfizJAsZmsup5CQWNXqWmaamyVMyXGW/hUqx3sW49nhqNlGd3ZzY ETj4BkT4BYSwhfn/AQ96YSvs+Sq6IlTIlZXVNMpeHMX+0ZQjv+FZRA/RKrz+t3dZ4u 1qH1N38SWuCE3fte75V0TIkKwCKF9lts668sBgQlwW5eAV1dEKJXhxg+1WEdnmmBQI jKYmcc+lcknEw== Date: Sat, 19 Oct 2024 15:30:41 -0700 From: Luis Chamberlain To: Mike Rapoport Cc: Andrew Morton , Andreas Larsson , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Brian Cain , Catalin Marinas , Christoph Hellwig , Christophe Leroy , Dave Hansen , Dinh Nguyen , Geert Uytterhoeven , Guo Ren , Helge Deller , Huacai Chen , Ingo Molnar , Johannes Berg , John Paul Adrian Glaubitz , Kent Overstreet , "Liam R. Howlett" , Mark Rutland , Masami Hiramatsu , Matt Turner , Max Filippov , Michael Ellerman , Michal Simek , Oleg Nesterov , Palmer Dabbelt , Peter Zijlstra , Richard Weinberger , Russell King , Song Liu , Stafford Horne , Steven Rostedt , Suren Baghdasaryan , Thomas Bogendoerfer , Thomas Gleixner , Uladzislau Rezki , Vineet Gupta , Will Deacon , bpf@vger.kernel.org, linux-alpha@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-trace-kernel@vger.kernel.org, linux-um@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH v6 4/8] module: prepare to handle ROX allocations for text Message-ID: References: <20241016122424.1655560-1-rppt@kernel.org> <20241016122424.1655560-5-rppt@kernel.org> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Post: List-Subscribe: , , List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241016122424.1655560-5-rppt@kernel.org> On Wed, Oct 16, 2024 at 03:24:20PM +0300, Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" > > In order to support ROX allocations for module text, it is necessary to > handle modifications to the code, such as relocations and alternatives > patching, without write access to that memory. > > One option is to use text patching, but this would make module loading > extremely slow and will expose executable code that is not finally formed. > > A better way is to have memory allocated with ROX permissions contain > invalid instructions and keep a writable, but not executable copy of the > module text. The relocations and alternative patches would be done on the > writable copy using the addresses of the ROX memory. > Once the module is completely ready, the updated text will be copied to ROX > memory using text patching in one go and the writable copy will be freed. > > Add support for that to module initialization code and provide necessary > interfaces in execmem. > > Signed-off-by: Mike Rapoport (Microsoft) Reviewd-by: Luis Chamberlain Luis