All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Benjamin Gray <bgray@linux.ibm.com>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Cc: "jniethe5@gmail.com" <jniethe5@gmail.com>,
	"cmr@bluescreens.de" <cmr@bluescreens.de>,
	"ajd@linux.ibm.com" <ajd@linux.ibm.com>,
	"npiggin@gmail.com" <npiggin@gmail.com>
Subject: Re: [PATCH v10 2/9] powerpc/code-patching: Use WARN_ON and fix check in poking_init
Date: Wed, 9 Nov 2022 06:12:06 +0000	[thread overview]
Message-ID: <9790e4a7-4d28-6040-a80b-39ab2674dd51@csgroup.eu> (raw)
In-Reply-To: <20221109045112.187069-3-bgray@linux.ibm.com>



Le 09/11/2022 à 05:51, Benjamin Gray a écrit :
> BUG_ON() when failing to initialise the code patching window is
> unnecessary, and use of BUG_ON is discouraged. We don't set
> poking_init_done in this case, so failure to init the boot CPU will
> result in a strict RWX error when a following patch_instruction uses
> raw_patch_instruction. If it only fails for later CPUs, they won't be
> onlined in the first place.
> 
> 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: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
> v10:	* Don't mention caller recovery
> 	* Don't set poking_init_done on failure
> 	* Add setup return code comment from later patch
> 	* Reviewed-by not applied because of above changes
> v9:	* Reword commit message to explain why init failure is not fatal
> ---
>   arch/powerpc/lib/code-patching.c | 17 +++++++++--------
>   1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
> index ad0cf3108dd0..3055eef7dcdc 100644
> --- a/arch/powerpc/lib/code-patching.c
> +++ b/arch/powerpc/lib/code-patching.c
> @@ -81,16 +81,17 @@ 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));
> +	int ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
> +				    "powerpc/text_poke:online",
> +				    text_area_cpu_up,
> +				    text_area_cpu_down);
> +
> +	/* cpuhp_setup_state returns >= 0 on success */
> +	if (WARN_ON(ret < 0))
> +		return;
> +
>   	static_branch_enable(&poking_init_done);
>   }
>   

  reply	other threads:[~2022-11-09  6:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09  4:51 [PATCH v10 0/9] powerpc/code-patching: Use temporary mm for Radix MMU Benjamin Gray
2022-11-09  4:51 ` [PATCH v10 1/9] powerpc: Allow clearing and restoring registers independent of saved breakpoint state Benjamin Gray
2022-11-09  4:51 ` [PATCH v10 2/9] powerpc/code-patching: Use WARN_ON and fix check in poking_init Benjamin Gray
2022-11-09  6:12   ` Christophe Leroy [this message]
2022-11-09  4:51 ` [PATCH v10 3/9] powerpc/mm: Remove extern from function prototypes Benjamin Gray
2022-11-09  6:16   ` Christophe Leroy
2022-11-25  3:12   ` Andrew Donnellan
2022-11-09  4:51 ` [PATCH v10 4/9] powerpc/mm: Remove empty hash__ functions Benjamin Gray
2022-11-09  6:16   ` Christophe Leroy
2022-11-09  4:51 ` [PATCH v10 5/9] cxl: Use radix__flush_all_mm instead of generic flush_all_mm Benjamin Gray
2022-11-09  6:16   ` Christophe Leroy
2022-11-25  2:42   ` Andrew Donnellan
2022-11-09  4:51 ` [PATCH v10 6/9] powerpc/mm: Remove flush_all_mm, local_flush_all_mm Benjamin Gray
2022-11-09  6:17   ` Christophe Leroy
2022-11-09  4:51 ` [PATCH v10 7/9] powerpc/tlb: Add local flush for page given mm_struct and psize Benjamin Gray
2022-11-09  6:18   ` Christophe Leroy
2022-11-09  4:51 ` [PATCH v10 8/9] powerpc/code-patching: Use temporary mm for Radix MMU Benjamin Gray
2022-12-15 20:17   ` Nathan Chancellor
2022-12-15 20:17     ` Nathan Chancellor
2022-12-16  0:23     ` Michael Ellerman
2022-11-09  4:51 ` [PATCH v10 9/9] powerpc/code-patching: Consolidate and cache per-cpu patching context Benjamin Gray
2022-11-09  6:23   ` Christophe Leroy
2022-12-08 12:39 ` [PATCH v10 0/9] powerpc/code-patching: Use temporary mm for Radix MMU Michael Ellerman

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=9790e4a7-4d28-6040-a80b-39ab2674dd51@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=ajd@linux.ibm.com \
    --cc=bgray@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.