From: Petr Pavlu <petr.pavlu@suse.com>
To: Mike Rapoport <rppt@kernel.org>
Cc: x86@kernel.org, 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>,
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: Re: [PATCH v2 06/10] module: introduce MODULE_STATE_GONE
Date: Thu, 23 Jan 2025 15:16:28 +0100 [thread overview]
Message-ID: <4a9ca024-fc25-4fe0-94d5-65899b2cec6b@suse.com> (raw)
In-Reply-To: <20250121095739.986006-7-rppt@kernel.org>
On 1/21/25 10:57, Mike Rapoport wrote:
> In order to use execmem's API for temporal remapping of the memory
> allocated from ROX cache as writable, there is a need to distinguish
> between the state when the module is being formed and the state when it is
> deconstructed and freed so that when module_memory_free() is called from
> error paths during module loading it could restore ROX mappings.
>
> Replace open coded checks for MODULE_STATE_UNFORMED with a helper
> function module_is_formed() and add a new MODULE_STATE_GONE that will be
> set when the module is deconstructed and freed.
I don't fully follow why this case requires a new module state. My
understanding it that the function load_module() has the necessary
context that after calling layout_and_allocate(), the updated ROX
mappings need to be restored. I would then expect the function to be
appropriately able to unwind this operation in case of an error. It
could be done by having a helper that walks the mappings and calls
execmem_restore_rox(), or if you want to keep it in module_memory_free()
as done in the patch #7 then a flag could be passed down to
module_deallocate() -> free_mod_mem() -> module_memory_free()?
It is at least good that MODULE_STATE_GONE is only set in free_module()
past the sysfs teardown, so it never shows in
/sys/module/<mod>/initstate. Otherwise, this would require teaching kmod
about this state as well.
--
Thanks,
Petr
next prev parent reply other threads:[~2025-01-23 14:16 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-21 9:57 [PATCH v2 00/10] x86/module: rework ROX cache to avoid writable copy Mike Rapoport
2025-01-21 9:57 ` [PATCH v2 01/10] x86/mm/pat: cpa-test: fix length for CPA_ARRAY test Mike Rapoport
2025-01-21 9:57 ` [PATCH v2 02/10] x86/mm/pat: drop duplicate variable in cpa_flush() Mike Rapoport
2025-01-21 9:57 ` [PATCH v2 03/10] x86/mm/pat: restore large ROX pages after fragmentation Mike Rapoport
2025-01-21 9:57 ` [PATCH v2 04/10] execmem: don't remove ROX cache from the direct map Mike Rapoport
2025-01-21 9:57 ` [PATCH v2 05/10] execmem: add API for temporal remapping as RW and restoring ROX afterwards Mike Rapoport
2025-01-21 9:57 ` [PATCH v2 06/10] module: introduce MODULE_STATE_GONE Mike Rapoport
2025-01-23 14:16 ` Petr Pavlu [this message]
2025-01-24 11:06 ` Mike Rapoport
2025-01-24 12:59 ` Petr Pavlu
2025-01-24 13:34 ` Petr Mladek
2025-01-21 9:57 ` [PATCH v2 07/10] module: switch to execmem API for remapping as RW and restoring ROX Mike Rapoport
2025-01-21 9:57 ` [PATCH v2 08/10] Revert "x86/module: prepare module loading for ROX allocations of text" Mike Rapoport
2025-01-21 9:57 ` [PATCH v2 09/10] module: drop unused module_writable_address() Mike Rapoport
2025-01-21 9:57 ` [PATCH v2 10/10] x86: re-enable EXECMEM_ROX support Mike Rapoport
2025-01-21 12:36 ` [PATCH v2 00/10] x86/module: rework ROX cache to avoid writable copy Peter Zijlstra
2025-01-22 9:51 ` Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4a9ca024-fc25-4fe0-94d5-65899b2cec6b@suse.com \
--to=petr.pavlu@suse.com \
--cc=akpm@linux-foundation.org \
--cc=anton.ivanov@cambridgegreys.com \
--cc=bp@alien8.de \
--cc=brendan.higgins@linux.dev \
--cc=da.gomez@samsung.com \
--cc=danielt@kernel.org \
--cc=dave.hansen@linux.intel.com \
--cc=davidgow@google.com \
--cc=dianders@chromium.org \
--cc=hpa@zytor.com \
--cc=jason.wessel@windriver.com \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=johannes@sipsolutions.net \
--cc=jpoimboe@kernel.org \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=kirill.shutemov@linux.intel.com \
--cc=kunit-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-modules@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=live-patching@vger.kernel.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=luto@kernel.org \
--cc=mark.rutland@arm.com \
--cc=mbenes@suse.cz \
--cc=mcgrof@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=richard@nod.at \
--cc=rmoar@google.com \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
--cc=samitolvanen@google.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox