From: Benjamin Gray <bgray@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: ajd@linux.ibm.com, jniethe5@gmail.com,
Benjamin Gray <bgray@linux.ibm.com>,
npiggin@gmail.com, cmr@bluescreens.de
Subject: [PATCH v9 3/7] powerpc/code-patching: Use WARN_ON and fix check in poking_init
Date: Tue, 25 Oct 2022 15:44:05 +1100 [thread overview]
Message-ID: <20221025044409.448755-4-bgray@linux.ibm.com> (raw)
In-Reply-To: <20221025044409.448755-1-bgray@linux.ibm.com>
BUG_ON() when failing to initialise the code patching window is
excessive, as most critical patching happens during boot before strict
RWX control is enabled. Failure to patch after boot is not inherently
fatal, so aborting the kernel is better determined by the caller.
The return value of cpuhp_setup_state() is also >= 0 on success,
so check for < 0.
Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
Reviewed-by: Russell Currey <ruscur@russell.cc>
---
v9: * Reword commit message to explain why init failure is not fatal
---
arch/powerpc/lib/code-patching.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
index 54e145247643..3b3b09d5d2e1 100644
--- a/arch/powerpc/lib/code-patching.c
+++ b/arch/powerpc/lib/code-patching.c
@@ -82,16 +82,13 @@ static int text_area_cpu_down(unsigned int cpu)
static __ro_after_init DEFINE_STATIC_KEY_FALSE(poking_init_done);
-/*
- * Although BUG_ON() is rude, in this case it should only happen if ENOMEM, and
- * we judge it as being preferable to a kernel that will crash later when
- * someone tries to use patch_instruction().
- */
void __init poking_init(void)
{
- BUG_ON(!cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
- "powerpc/text_poke:online", text_area_cpu_up,
- text_area_cpu_down));
+ WARN_ON(cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
+ "powerpc/text_poke:online",
+ text_area_cpu_up,
+ text_area_cpu_down) < 0);
+
static_branch_enable(&poking_init_done);
}
--
2.37.3
next prev parent reply other threads:[~2022-10-25 4:45 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-25 4:44 [PATCH v9 0/7] Use per-CPU temporary mappings for patching on Radix MMU Benjamin Gray
2022-10-25 4:44 ` [PATCH v9 1/7] powerpc: Allow clearing and restoring registers independent of saved breakpoint state Benjamin Gray
2022-10-25 4:44 ` [PATCH v9 2/7] powerpc/code-patching: Handle RWX patching initialisation error Benjamin Gray
2022-11-02 9:36 ` Christophe Leroy
2022-11-02 22:37 ` Benjamin Gray
2022-10-25 4:44 ` Benjamin Gray [this message]
2022-11-02 9:38 ` [PATCH v9 3/7] powerpc/code-patching: Use WARN_ON and fix check in poking_init Christophe Leroy
2022-11-02 22:42 ` Benjamin Gray
2022-10-25 4:44 ` [PATCH v9 4/7] powerpc/code-patching: Verify instruction patch succeeded Benjamin Gray
2022-10-26 0:47 ` Benjamin Gray
2022-11-02 9:43 ` Christophe Leroy
2022-11-02 10:13 ` Christophe Leroy
2022-11-02 23:02 ` Benjamin Gray
2022-11-02 22:58 ` Benjamin Gray
2022-10-25 4:44 ` [PATCH v9 5/7] powerpc/tlb: Add local flush for page given mm_struct and psize Benjamin Gray
2022-11-02 9:56 ` Christophe Leroy
2022-11-03 0:39 ` Benjamin Gray
2022-11-03 0:45 ` Andrew Donnellan
2022-11-07 6:58 ` Benjamin Gray
2022-11-07 12:28 ` Nicholas Piggin
2022-10-25 4:44 ` [PATCH v9 6/7] powerpc/code-patching: Use temporary mm for Radix MMU Benjamin Gray
2022-11-02 10:11 ` Christophe Leroy
2022-11-03 3:10 ` Benjamin Gray
2022-11-08 5:16 ` Benjamin Gray
2022-10-25 4:44 ` [PATCH v9 7/7] powerpc/code-patching: Consolidate and cache per-cpu patching context Benjamin Gray
2022-11-02 10:17 ` Christophe Leroy
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=20221025044409.448755-4-bgray@linux.ibm.com \
--to=bgray@linux.ibm.com \
--cc=ajd@linux.ibm.com \
--cc=cmr@bluescreens.de \
--cc=jniethe5@gmail.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=npiggin@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).