[PATCH v6 11/28] powerpc: Use a datatype for instructions

Jordan Niethe jniethe5 at gmail.com
Wed Apr 29 12:57:49 AEST 2020


On Wed, Apr 29, 2020 at 12:02 PM Alistair Popple <alistair at popple.id.au> wrote:
>
> Hi Jordan,
>
> I needed the below fix for building with CONFIG_STRICT_KERNEL_RWX enabled.
> Hopefully it's correct, I have not yet had a chance to test it beyond building
> it.
Thanks, I'll get that working.
>
> - Alistair
>
> ---
>  arch/powerpc/lib/code-patching.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-
> patching.c
> index ad5754c5f007..a8c8ffdb1ccd 100644
> --- a/arch/powerpc/lib/code-patching.c
> +++ b/arch/powerpc/lib/code-patching.c
> @@ -166,8 +166,8 @@ static int do_patch_instruction(struct ppc_inst *addr,
> struct ppc_inst instr)
>                 goto out;
>         }
>
> -       patch_addr = (unsigned int *)(text_poke_addr) +
> -                       ((kaddr & ~PAGE_MASK) / sizeof(unsigned int));
> +       patch_addr = (struct ppc_inst *)(text_poke_addr) +
> +               ((kaddr & ~PAGE_MASK) / sizeof(unsigned int));
Hmm, I think this might not give the expected result, with struct
ppc_inst being 8 long, compared to unsigned int being 4 long.
So the pointer arithmetic will not give the patch_addr you would expecting.

>
>         __patch_instruction(addr, instr, patch_addr);
>
> --
> 2.20.1
>
>
>
>


More information about the Linuxppc-dev mailing list