Message ID | 20250126074733.1384926-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 5EF35C02181 for <linux-mm@archiver.kernel.org>; Sun, 26 Jan 2025 07:47:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C87742800EA; Sun, 26 Jan 2025 02:47:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C377C2800E8; Sun, 26 Jan 2025 02:47:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AFEF82800EA; Sun, 26 Jan 2025 02:47:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 92D3D2800E8 for <linux-mm@kvack.org>; Sun, 26 Jan 2025 02:47:56 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0C0931C9031 for <linux-mm@kvack.org>; Sun, 26 Jan 2025 07:47:56 +0000 (UTC) X-FDA: 83048824152.23.8BDF595 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id 64B1740009 for <linux-mm@kvack.org>; Sun, 26 Jan 2025 07:47:54 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=O52qDEge; spf=pass (imf01.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737877674; 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=YIQ0s0g5S9fyvQvFERMkRZcwWuhXAVgFU48sXR83+1U=; b=JJJEY5B9EUNhiqwNibcDDQJKsyje0qzN4aSLeH1w8YAz57Fm/6+d348B7DKCrfYLkerR2k 9kaFKDcaR7wrONRLafwswgMtkSQg6GyQoYOgpWezsOG7WAg0N2zQvhhChRZHkrDFWKxPA3 lauTcCgQUwi2cuEyeVAf82iLG8MoGX0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=O52qDEge; spf=pass (imf01.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737877674; a=rsa-sha256; cv=none; b=OC586Aml8TNlI7bWuTLwbrZQ1I1gyJgb3jSdnMDOAEWz8zfuP6g222CNXSivRCI8bJL75C 7NDfD9JrvgTFCrC9l5cJaI5UEzczXsWKXDyht6r0VsSkcJKfcvHZz1ctXQCkpp2C6TOkhE HuoyKKGUhw6alKeFIGxu9cnHAEaD2K4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0E6585C5720; Sun, 26 Jan 2025 07:47:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0308BC4CED3; Sun, 26 Jan 2025 07:47:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737877672; bh=HLFoZ/RTXnZ46FvNWum031IGZxxS7sqpbzrgDdi90jg=; h=From:To:Cc:Subject:Date:From; b=O52qDEgeuHxYD2iQ4xVmnqYxiwXRFmkUqlcKMuNcYvDExkrNljEPYGIg5HmQGU/Ug /xLdmcQJl0r8LS6YITXOURsoDrFjRH7Vf1NWeYRZBpPHxIex/Heg933xHgI+2XQYQt T2FyMaAF6aDVsZgf2jH9M6BmaqSKuErVdM2ekeSAQHgs1ra7L/qWcBRJVfXA7Bwui6 JQIw6oanU4TdzC3qTSdWgiP5J0Fs8IwRp9NtQsJf2dYunc46TUkAwiH5EfpWpSIW0G dhh2niwb+KzVKCI36j9CIUaA95SSBjMVt9Aoz8DpyaXk0a5r20lhoEcG6fpH76MmtA YFbdLW4stYwdA== From: Mike Rapoport <rppt@kernel.org> To: x86@kernel.org Cc: Andrew Morton <akpm@linux-foundation.org>, 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>, Lorenzo Stoakes <lorenzo.stoakes@oracle.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 Subject: [PATCH v3 0/9] x86/module: rework ROX cache to avoid writable copy Date: Sun, 26 Jan 2025 09:47:24 +0200 Message-ID: <20250126074733.1384926-1-rppt@kernel.org> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 64B1740009 X-Stat-Signature: b5dxe9uck5i4ybiac51gsxehqnq8a359 X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1737877674-627216 X-HE-Meta: U2FsdGVkX1/SUVCwsT8cf6O8hIIgVblTHduwxH030mjOd4QbOlAM42pK6DcEeWUWW6N62AOohSAmi5mX5RN441OtmPiH/vbEGSIKaFRmEsWL4OhkvAVMpt4W8JvAUp6b/qc6u3VNYcAPgdW/YxkpN5Kx6p41xG34OScVYN+50+/NnCGbZ5SRWkNUXIA5BlQWijft+YrE8KMT0JpUrSb/AuEcxT9JkSu8pKl1URf7mcKbLuPl1qewgxuxjy09oib4I5x/gGEJi6XB1ZOF/31HM8eqsqNVQjT4P6uGDPtYc7iazpkg5rQG0304Vi1kqsGRtkTeub47TPlsyh+LXLJEkacswjNjym+gA5wnz3CB0VL8CoFY59UHPAT4JMl7FSFAV2kpSeBAYSoQBujAVYS6Q03qVHMP9N+EeAAg/xXZDPo/3iDI69bQ6RQ9CZYc2L9KXOO1AXAxkkj0LikL2LGd+JZwpir5H5QF3F8KQHr/zRGrbvmIAKqE66ZwsOO9GdcAdXfrkuBVTcmROn4H08I4kkvs35IZy2hoislNixrkjW+77SCT6//T7eO8HBzG9iiycp9/OyojfnZ/wFOBIwDLerEJ2x3j7p1/7xVp2LVF9ogRQKqwYwhKfr/1mkZl6TunkaeE243HeItK45mMgrwKHjJTWemrK4tSi+Igh0QbuFaLQXQE7tzfKWh5FGFtAZhyAapMWkj2zCbVvyjCppUAhIT/YjUx2JN0+H8qoSRKVmOrr36lmsPxPSRLO7FhA2dkiqJutWj3Pro+hLWw5BHhaibFGvBjJfconMmhF724OGRUC9E6QiVsqIkoRqsKdAy5pq6d8hqe6SaVNrRRggGnzCO/gezDHDerkMtfAnQkw102IPyojDh8cTgi1O8MVsyl7yO36q1pxLuz9mxswS/aGDJJDucURSVQn17F8IRi6R0OgF3M+EI4XqmM/8rxnjMEEUe2a1lsUEucPoHtFtk 8nZvyg0z tGPWEAHFfTyjw+KOTYBfvRGVFP6g5ZGPRg2a456vqENfeATjBha9rEkaW0hu6S/nRWzaNwNQulMBURtS5qIHNBuYfG1r1zTB0hd+0mzKQOEnD93BnU2n33OKK5GQd5+2YbIziFJxWFIiY+xFHrilH1gTtnCaSnBFJgPIgQf9S/3eOvkzQ1ChQ5d5dCKukbb3MeYvEOEkAyVfGJvSJnyukh4/LSm8VZ2zv2EnPjphECsZKM0VxOo7m7I3KNMKFRdGVBTXBxnXqrchbVjTlw7DwbqUh2btiKwtXsWZU 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
|
On Sun, Jan 26, 2025 at 09:47:24AM +0200, Mike Rapoport wrote: > v3 changes: > * instead of adding a new module state handle ROX restoration locally in > load_module() as Petr suggested OK, updated the patches I have pending for post -rc1.
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_rox() capable of restoring large pages (more details are in patch 3). Since this is really about x86, I believe this should go in via tip tree. The patches also available in git https://git.kernel.org/rppt/h/execmem/x86-rox/v10 v3 changes: * instead of adding a new module state handle ROX restoration locally in load_module() as Petr suggested v2: https://lore.kernel.org/all/20250121095739.986006-1-rppt@kernel.org * only collapse large mappings in set_memory_rox() * simplify RW <-> ROX remapping * don't remove ROX cache pages from the direct map (patch 4) v1: https://lore.kernel.org/all/20241227072825.1288491-1-rppt@kernel.org [1] https://lore.kernel.org/all/20241209083818.GK8562@noisy.programming.kicks-ass.net Kirill A. Shutemov (1): x86/mm/pat: restore large ROX pages after fragmentation Mike Rapoport (Microsoft) (8): x86/mm/pat: cpa-test: fix length for CPA_ARRAY test x86/mm/pat: drop duplicate variable in cpa_flush() execmem: don't remove ROX cache from the direct map execmem: add API for temporal remapping as RW and restoring ROX afterwards module: 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() x86: re-enable EXECMEM_ROX support arch/um/kernel/um_arch.c | 11 +- arch/x86/Kconfig | 1 + 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 | 220 ++++++++++++++++++++++++++- include/linux/execmem.h | 31 ++++ include/linux/module.h | 16 -- include/linux/moduleloader.h | 4 - include/linux/vm_event_item.h | 2 + kernel/module/main.c | 78 +++------- kernel/module/strict_rwx.c | 9 +- mm/execmem.c | 39 +++-- mm/vmstat.c | 2 + 18 files changed, 422 insertions(+), 268 deletions(-) base-commit: ffd294d346d185b70e28b1a28abe367bbfe53c04