From: Steven Rostedt <rostedt@goodmis.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: torvalds@linux-foundation.org, dave.hansen@intel.com,
linux-kernel@vger.kernel.org, x86@kernel.org,
keescook@chromium.org, seanjc@google.com
Subject: Re: [PATCH 4/5] x86/ftrace: Remove SYSTEM_BOOTING exceptions
Date: Tue, 25 Oct 2022 16:59:56 -0400 [thread overview]
Message-ID: <20221025165956.415d82d9@gandalf.local.home> (raw)
In-Reply-To: <20221025201057.945960823@infradead.org>
On Tue, 25 Oct 2022 22:07:00 +0200
Peter Zijlstra <peterz@infradead.org> wrote:
> Now that text_poke is available before ftrace, remove the
> SYSTEM_BOOTING exceptions.
>
> Specifically, this cures a W+X case during boot.
We have W+X all over the place (the entire kernel text). And I don't think
we really want this.
This will slow down boots in general, as it will cause all static_branches
to use this memory page logic. And I don't think we really want to do
that at boot up when we don't need to.
I would change this to:
if (unlikely(system_state == SYSTEM_BOOTING) &&
core_kernel_text((unsigned long)addr)) {
This way we still do memcpy() on all core kernel text which is still
writable. It was the ftrace allocated trampoline that caused issues, not
the locations that were being updated.
-- Steve
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> arch/x86/kernel/alternative.c | 10 ----------
> arch/x86/kernel/ftrace.c | 3 +--
> 2 files changed, 1 insertion(+), 12 deletions(-)
>
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -1681,11 +1681,6 @@ void __ref text_poke_queue(void *addr, c
> {
> struct text_poke_loc *tp;
>
> - if (unlikely(system_state == SYSTEM_BOOTING)) {
> - text_poke_early(addr, opcode, len);
> - return;
> - }
> -
> text_poke_flush(addr);
>
> tp = &tp_vec[tp_vec_nr++];
> @@ -1707,11 +1702,6 @@ void __ref text_poke_bp(void *addr, cons
> {
> struct text_poke_loc tp;
>
> - if (unlikely(system_state == SYSTEM_BOOTING)) {
> - text_poke_early(addr, opcode, len);
> - return;
> - }
> -
> text_poke_loc_init(&tp, addr, opcode, len, emulate);
> text_poke_bp_batch(&tp, 1);
> }
> --- a/arch/x86/kernel/ftrace.c
> +++ b/arch/x86/kernel/ftrace.c
> @@ -415,8 +415,7 @@ create_trampoline(struct ftrace_ops *ops
>
> set_vm_flush_reset_perms(trampoline);
>
> - if (likely(system_state != SYSTEM_BOOTING))
> - set_memory_ro((unsigned long)trampoline, npages);
> + set_memory_ro((unsigned long)trampoline, npages);
> set_memory_x((unsigned long)trampoline, npages);
> return (unsigned long)trampoline;
> fail:
>
next prev parent reply other threads:[~2022-10-25 20:59 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-25 20:06 [PATCH 0/5] x86/ftrace: Cure boot time W+X mapping Peter Zijlstra
2022-10-25 20:06 ` [PATCH 1/5] mm: Move mm_cachep initialization to mm_init() Peter Zijlstra
2022-11-02 9:12 ` [tip: x86/mm] " tip-bot2 for Peter Zijlstra
2022-12-17 18:55 ` tip-bot2 for Peter Zijlstra
2022-10-25 20:06 ` [PATCH 2/5] x86/mm: Use mm_alloc() in poking_init() Peter Zijlstra
2022-11-02 9:12 ` [tip: x86/mm] " tip-bot2 for Peter Zijlstra
2022-12-17 18:55 ` tip-bot2 for Peter Zijlstra
2022-10-25 20:06 ` [PATCH 3/5] x86/mm: Initialize text poking earlier Peter Zijlstra
2022-11-02 9:12 ` [tip: x86/mm] " tip-bot2 for Peter Zijlstra
2022-12-17 18:55 ` tip-bot2 for Peter Zijlstra
2022-10-25 20:07 ` [PATCH 4/5] x86/ftrace: Remove SYSTEM_BOOTING exceptions Peter Zijlstra
2022-10-25 20:59 ` Steven Rostedt [this message]
2022-10-26 7:02 ` Peter Zijlstra
2022-11-02 9:12 ` [tip: x86/mm] " tip-bot2 for Peter Zijlstra
2022-12-17 18:55 ` tip-bot2 for Peter Zijlstra
2022-10-25 20:07 ` [PATCH 5/5] x86/mm: Do verify W^X at boot up Peter Zijlstra
2022-11-02 9:12 ` [tip: x86/mm] " tip-bot2 for Peter Zijlstra
2022-12-17 18:55 ` tip-bot2 for Peter Zijlstra
2022-10-25 23:07 ` [PATCH 0/5] x86/ftrace: Cure boot time W+X mapping Linus Torvalds
2022-10-25 23:17 ` Steven Rostedt
2022-10-26 7:15 ` Peter Zijlstra
2022-10-26 17:59 ` Linus Torvalds
2022-10-27 6:59 ` Peter Zijlstra
2022-10-29 11:30 ` Peter Zijlstra
2022-10-29 17:35 ` Linus Torvalds
2022-11-02 9:12 ` [tip: x86/mm] mm: Introduce set_memory_rox() tip-bot2 for Peter Zijlstra
2022-12-17 18:55 ` tip-bot2 for 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=20221025165956.415d82d9@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=dave.hansen@intel.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=seanjc@google.com \
--cc=torvalds@linux-foundation.org \
--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
all inboxes | Powered by JetHome®