Message ID | 20241227072825.1288491-1-rppt@kernel.org (mailing list archive) |
---|---|
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DC04E7718B for <linux-mm@archiver.kernel.org>; Fri, 27 Dec 2024 07:28:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA4E96B007B; Fri, 27 Dec 2024 02:28:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D2DA96B0082; Fri, 27 Dec 2024 02:28:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCDA46B0083; Fri, 27 Dec 2024 02:28:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A1D936B007B for <linux-mm@kvack.org>; Fri, 27 Dec 2024 02:28:48 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 25BCE1612D1 for <linux-mm@kvack.org>; Fri, 27 Dec 2024 07:28:48 +0000 (UTC) X-FDA: 82939909794.03.CB683DF Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf01.hostedemail.com (Postfix) with ESMTP id 273C440005 for <linux-mm@kvack.org>; Fri, 27 Dec 2024 07:28:14 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VWflVN7V; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of rppt@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735284486; a=rsa-sha256; cv=none; b=XtOqmANdLhPB2p6oqSOAj6BxzS8K6Jlwz8JyOKJiY9bzIKUgYXbd2gVFiy/ud0dGp8gHhv Tmxg6DAU/ZNuYaU0vis5JEe9kPFoGhYn7/Tdkqh1W9Kd4vHxRODPy1B/IRq6RE1U8ki8di lv22HjuVz02WDGUBcUVCapM8gdKEYWE= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VWflVN7V; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of rppt@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1735284486; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=qcorEnshSlUvWUIclIaQ7O5Fp0YwV8Jv7lKKOj/FCyU=; b=ogA9l4L8ldPQpRnoKESvsETim4fBeb7IqR933j1nwIODFr9LNvrhBv9Q5bQNQzIWQ1Ktdm Ji8bQ3Wf4YOvmPK1GKIQsk0UQWddIi27Ku8LVzYmcRFrF6l6WxSFxSoqw6VXfMQrev3Lfh V6sSJvhAZgiDGn4SVyoE81/8+bIc7zY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id BC6DCA41191; Fri, 27 Dec 2024 07:26:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BECBC4CED0; Fri, 27 Dec 2024 07:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735284525; bh=jbs+82vTwYkxQ3EpjI+1yvm0nBPBr9HhcF8xhKMgyb4=; h=From:To:Cc:Subject:Date:From; b=VWflVN7Vf0mMrePAw/GmezMrZdtva3K3h36HGmBxa/KroU575WF5NJHeh0C6TXNjF qQhJ4X9PGAqzjrUVpQRiVvwIGMd+mISM5MQXFvk45sfhmzlny3nUqVMIbeY6kdii/w zWWKCDoOIlTrr71quUFFRbqLg+DHcfKtQtVHdMmb1lnaMhGLAzyiY7V3autquhweL9 gpxz7kV3lQ4EAySR1yDZ2syQZsNyGHLgB/w6HxDmV2RAqrWKXeYkMQOMk5oc3c8Pn5 sSBAIqOuQ0ZL0h2iDfLAfuFMjvlnSpx46Mfk1CVcx/gQmlnCTUUVbl2c6KeEM5cwGT y+LUWaqHdI5Jg== From: Mike Rapoport <rppt@kernel.org> To: Andrew Morton <akpm@linux-foundation.org> Cc: Andy Lutomirski <luto@kernel.org>, Anton Ivanov <anton.ivanov@cambridgegreys.com>, Borislav Petkov <bp@alien8.de>, Brendan Higgins <brendan.higgins@linux.dev>, Daniel Gomez <da.gomez@samsung.com>, Daniel Thompson <danielt@kernel.org>, Dave Hansen <dave.hansen@linux.intel.com>, David Gow <davidgow@google.com>, Douglas Anderson <dianders@chromium.org>, Ingo Molnar <mingo@redhat.com>, Jason Wessel <jason.wessel@windriver.com>, Jiri Kosina <jikos@kernel.org>, Joe Lawrence <joe.lawrence@redhat.com>, Johannes Berg <johannes@sipsolutions.net>, Josh Poimboeuf <jpoimboe@kernel.org>, "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>, Luis Chamberlain <mcgrof@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Masami Hiramatsu <mhiramat@kernel.org>, Mike Rapoport <rppt@kernel.org>, Miroslav Benes <mbenes@suse.cz>, "H. Peter Anvin" <hpa@zytor.com>, Peter Zijlstra <peterz@infradead.org>, Petr Mladek <pmladek@suse.com>, Petr Pavlu <petr.pavlu@suse.com>, Rae Moar <rmoar@google.com>, Richard Weinberger <richard@nod.at>, Sami Tolvanen <samitolvanen@google.com>, Shuah Khan <shuah@kernel.org>, Song Liu <song@kernel.org>, Steven Rostedt <rostedt@goodmis.org>, Thomas Gleixner <tglx@linutronix.de>, kgdb-bugreport@lists.sourceforge.net, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-um@lists.infradead.org, live-patching@vger.kernel.org, x86@kernel.org Subject: [PATCH 0/8] x86/module: rework ROX cache to avoid writable copy Date: Fri, 27 Dec 2024 09:28:17 +0200 Message-ID: <20241227072825.1288491-1-rppt@kernel.org> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Stat-Signature: ycbdszb5qnyqrpe1rgga9axurswzopwg X-Rspam-User: X-Rspamd-Queue-Id: 273C440005 X-Rspamd-Server: rspam08 X-HE-Tag: 1735284494-965177 X-HE-Meta: U2FsdGVkX19XeNIPfQRv/G+jR7cGdA9yukIUXxGJ9ot807lE0ax1Jy8wXW615A+TKTLAq19EsWKHi2soRcoNzoYlN6IHxyJ/STAFAVzJCd7v9Z066go4KdHvgtVR3Bhk7Q7BFjCwrZfAWJ0ABRwkPlEZd3huB47nLDZ9x/2EHWVqeiwN4BoWrOKp4na4M50p7mLwBbeO1GGv96NYmOmBuuJwoElCZrBVj+UPVIJJFsLuWT3QQO0YeehDUpLXKGSaECjd+sSujP27UbMhI8T1AW/Nxg6L+LtgWmf0vMumEtV9SlhYK8CjZmeRIGhIMahjlp2nUeob941lR3wQcpCht4fajlWHG9LDUVU2s74yutm+c+WXB5CiK3JB5w5FS7nesBwUlOr62brpAjgR/IpK5m1r+k3XyzvADsGyVRfw9p1UQIipmMP0I+UE9v6JDSqC9G0YXQ+iEJ84BoKONgy7nY9tNNKbLd2bajafVAX5vVOC/rp4uLSg/QPxCOi0jJaJQ7IeslWs/mBrmFuoBqDUgwy3S0cPnHv0p6K8I2f3nZZ4jisCiD1aAGrO7PJAIx+wLnftLtycnqt9/v+KYuoPb+2jsssGp4n0WWiEjIY/mMm0f8C1i4Y532Mm9zV2gKE9Vl0nXCPRGtoJQHRTGjfpXpjS1iXBGTSqp5ajflkGxjrFDQu+8ePgtit65+sQm4fE9RG/K3hOcuphdGrrS4xzi35x+1O3Ruimgkh0gqsN4LXUT2gkFVevQsOZQoqeJlH0QAfv2/U2tuVTdvhAChI1DPPezH5QueVWauguoR2DW9C8gkgRf3orL0o0VGVlpvt+OvzmZ13x9m95hobIWzemUEc71RcaD3Gi9bhvIWewBCO8F/WBzJyyc+oRNRBSjvqXw4aYjo3D/Y5tAC/7Cj1N4h4D/Up4twkCLygDQEcB/bgCEE8eqjl41L/MgKh7xDhtx7mnREl3E3QgH0Evjpm eHzvw+0C bOSUvJPGeNDhIMt72utPv1DINp582Qd3LytsLKAU+g1LhjLfxHh7PSXpZKeqQCWJG/tmXO3WF36zojgMOX70CGbgr+qZTBmNV6/Isba00bQuyGO9L5ROvrVKDWXpXDNSAe+2SmK4yZFhcClP2F1WRvnZKikQyJeeA8zBhP8sRB+JH2I4QZS4sCpi6cvaUM81Ld+IKqay1kj8Opxe9nM9c6ksrxOLj6viKOGPkD7ngnbqKfffPSLaYaE9S9gS39+0NtiThz+4fbWPwfBJdoylDEaFIn7PGfv8HgW6Z X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
x86/module: rework ROX cache to avoid writable copy
|
expand
|
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Following Peter's comments [1] these patches rework handling of ROX caches for module text allocations. Instead of using a writable copy that really complicates alternatives patching, temporarily remap parts of a large ROX page as RW for the time of module formation and then restore it's ROX protections when the module is ready. To keep the ROX memory mapped with large pages, make set_memory code capable of restoring large pages (more details are in patch 3). The patches also available in git https://git.kernel.org/rppt/h/execmem/x86-rox/v8 [1] https://lore.kernel.org/all/20241209083818.GK8562@noisy.programming.kicks-ass.net Kirill A. Shutemov (1): x86/mm/pat: Restore large pages after fragmentation Mike Rapoport (Microsoft) (7): x86/mm/pat: cpa-test: fix length for CPA_ARRAY test x86/mm/pat: drop duplicate variable in cpa_flush() execmem: add API for temporal remapping as RW and restoring ROX afterwards module: introduce MODULE_STATE_GONE modules: switch to execmem API for remapping as RW and restoring ROX Revert "x86/module: prepare module loading for ROX allocations of text" module: drop unused module_writable_address() arch/um/kernel/um_arch.c | 11 +- arch/x86/entry/vdso/vma.c | 3 +- arch/x86/include/asm/alternative.h | 14 +- arch/x86/include/asm/pgtable_types.h | 2 + arch/x86/kernel/alternative.c | 181 ++++++--------- arch/x86/kernel/ftrace.c | 30 ++- arch/x86/kernel/module.c | 45 ++-- arch/x86/mm/pat/cpa-test.c | 2 +- arch/x86/mm/pat/set_memory.c | 216 +++++++++++++++++- include/linux/execmem.h | 31 +++ include/linux/module.h | 21 +- include/linux/moduleloader.h | 4 - include/linux/vm_event_item.h | 2 + kernel/module/kallsyms.c | 8 +- kernel/module/kdb.c | 2 +- kernel/module/main.c | 86 ++----- kernel/module/procfs.c | 2 +- kernel/module/strict_rwx.c | 9 +- kernel/tracepoint.c | 2 + lib/kunit/test.c | 2 + mm/execmem.c | 118 ++++++++-- mm/vmstat.c | 2 + samples/livepatch/livepatch-callbacks-demo.c | 1 + .../test_modules/test_klp_callbacks_demo.c | 1 + .../test_modules/test_klp_callbacks_demo2.c | 1 + .../livepatch/test_modules/test_klp_state.c | 1 + .../livepatch/test_modules/test_klp_state2.c | 1 + 27 files changed, 511 insertions(+), 287 deletions(-)