From: Hari Bathini <hbathini@linux.ibm.com>
To: Benjamin Gray <bgray@linux.ibm.com>, linuxppc-dev@lists.ozlabs.org
Cc: Naveen N Rao <naveen@kernel.org>
Subject: Re: [PATCH v4 2/5] powerpc/code-patching: Add data patch alignment check
Date: Tue, 20 Aug 2024 12:33:27 +0530 [thread overview]
Message-ID: <398e285c-6146-4dbc-b439-8f9e8f34a903@linux.ibm.com> (raw)
In-Reply-To: <20240515024445.236364-3-bgray@linux.ibm.com>
On 15/05/24 8:14 am, Benjamin Gray wrote:
> The new data patching still needs to be aligned within a
> cacheline too for the flushes to work correctly. To simplify
> this requirement, we just say data patches must be aligned.
>
> Detect when data patching is not aligned, returning an invalid
> argument error.
>
> Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
Reviewed-by: Hari Bathini <hbathini@linux.ibm.com>
>
> ---
>
> v3: * New in v3
> ---
> arch/powerpc/include/asm/code-patching.h | 6 ++++++
> arch/powerpc/lib/code-patching.c | 6 ++++++
> 2 files changed, 12 insertions(+)
>
> diff --git a/arch/powerpc/include/asm/code-patching.h b/arch/powerpc/include/asm/code-patching.h
> index 21a36e2c4e26..e7f14720f630 100644
> --- a/arch/powerpc/include/asm/code-patching.h
> +++ b/arch/powerpc/include/asm/code-patching.h
> @@ -95,11 +95,17 @@ int patch_ulong(void *addr, unsigned long val);
>
> static inline int patch_uint(void *addr, unsigned int val)
> {
> + if (!IS_ALIGNED((unsigned long)addr, sizeof(unsigned int)))
> + return -EINVAL;
> +
> return patch_instruction(addr, ppc_inst(val));
> }
>
> static inline int patch_ulong(void *addr, unsigned long val)
> {
> + if (!IS_ALIGNED((unsigned long)addr, sizeof(unsigned long)))
> + return -EINVAL;
> +
> return patch_instruction(addr, ppc_inst(val));
> }
>
> diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
> index 18f762616db9..384b275d1bc5 100644
> --- a/arch/powerpc/lib/code-patching.c
> +++ b/arch/powerpc/lib/code-patching.c
> @@ -386,12 +386,18 @@ NOKPROBE_SYMBOL(patch_instruction);
>
> int patch_uint(void *addr, unsigned int val)
> {
> + if (!IS_ALIGNED((unsigned long)addr, sizeof(unsigned int)))
> + return -EINVAL;
> +
> return patch_mem(addr, val, false);
> }
> NOKPROBE_SYMBOL(patch_uint);
>
> int patch_ulong(void *addr, unsigned long val)
> {
> + if (!IS_ALIGNED((unsigned long)addr, sizeof(unsigned long)))
> + return -EINVAL;
> +
> return patch_mem(addr, val, true);
> }
> NOKPROBE_SYMBOL(patch_ulong);
next prev parent reply other threads:[~2024-08-20 7:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-15 2:44 [PATCH v4 0/5] Add generic data patching functions Benjamin Gray
2024-05-15 2:44 ` [PATCH v4 1/5] powerpc/code-patching: Add generic memory patching Benjamin Gray
2024-08-20 7:02 ` Hari Bathini
2024-05-15 2:44 ` [PATCH v4 2/5] powerpc/code-patching: Add data patch alignment check Benjamin Gray
2024-08-20 7:03 ` Hari Bathini [this message]
2024-05-15 2:44 ` [PATCH v4 3/5] powerpc/64: Convert patch_instruction() to patch_u32() Benjamin Gray
2024-08-20 6:59 ` Hari Bathini
2024-05-15 2:44 ` [PATCH v4 4/5] powerpc/32: Convert patch_instruction() to patch_uint() Benjamin Gray
2024-08-20 7:00 ` Hari Bathini
2024-05-15 2:44 ` [PATCH v4 5/5] powerpc/code-patching: Add boot selftest for data patching Benjamin Gray
2024-08-20 7:00 ` Hari Bathini
2024-08-27 7:13 ` [PATCH v4 0/5] Add generic data patching functions 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=398e285c-6146-4dbc-b439-8f9e8f34a903@linux.ibm.com \
--to=hbathini@linux.ibm.com \
--cc=bgray@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=naveen@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;
as well as URLs for NNTP newsgroup(s).