lkml.org 
[lkml]   [2019]   [Oct]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 09/16] x86/alternative: Remove text_poke_loc::len

* Peter Zijlstra <peterz@infradead.org> 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

\
 
 \ /
  Last update: 2019-10-21 10:58    [W:0.349 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site