Re: [PATCH V4 5/9] x86/alternative: Split text_poke_bp() into tree steps

From: Steven Rostedt
Date: Thu Feb 07 2019 - 19:12:00 EST


On Mon, 4 Feb 2019 20:58:58 +0100
Daniel Bristot de Oliveira <bristot@xxxxxxxxxx> wrote:

> diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
> index d458c7973c56..202af29c43c0 100644
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -767,6 +767,29 @@ int poke_int3_handler(struct pt_regs *regs)
>
> }
>
> +static void text_poke_bp_set_handler(void *addr, void *handler,
> + unsigned char int3)
> +{
> + bp_int3_handler = handler;
> + bp_int3_addr = (u8 *)addr + sizeof(int3);

Why add the above update to the handler in this function? It looks
strange in this patch. Then I thought, "hmm, maybe it has a reason to
be here in other patches". Then I see in patch 7, you *REMOVE* these
awkward lines from this function! Let's not move them here to begin
with.

We then don't even need to pass in "handler". And perhaps rename it to
just "text_poke_bp_add_int3()"?

-- Steve


> + text_poke(addr, &int3, sizeof(int3));
> +}
> +
> +static void patch_all_but_first_byte(void *addr, const void *opcode,
> + size_t len, unsigned char int3)
> +{
> + /* patch all but the first byte */
> + text_poke((char *)addr + sizeof(int3),
> + (const char *) opcode + sizeof(int3),
> + len - sizeof(int3));
> +}
> +