Re: [PATCH v4 09/16] x86/alternative: Remove text_poke_loc::len

From: Ingo Molnar
Date: Mon Oct 21 2019 - 04:58:37 EST



* Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:

> * Second step: update all but the first byte of the patched range.
> */
> for (do_sync = 0, i = 0; i < nr_entries; i++) {
> - if (tp[i].len - sizeof(int3) > 0) {
> + int len = text_opcode_size(tp[i].opcode);
> +
> + if (len - sizeof(int3) > 0) {
> text_poke((char *)tp[i].addr + sizeof(int3),
> (const char *)tp[i].text + sizeof(int3),
> - tp[i].len - sizeof(int3));
> + len - sizeof(int3));
> do_sync++;
> }

Readability side note: 'sizeof(int3)' is a really weird way to write '1'
and I had to double check it's not measuring the size of some larger
entity.

I think it might make sense to just break out INT3_SIZE from
arch/x86/kernel/kprobes/opt.c into a header, rename it to INS_INT3_SIZE
and define it to 1, because the opt.c use is pretty obfuscated as well:

#define INT3_SIZE sizeof(kprobe_opcode_t)

Where kprobe_opcode_t is u8 on x86 (and won't ever be anything else).

?

Thanks,

Ingo