Messages in this thread | | | Date | Thu, 7 Feb 2019 19:15:52 -0500 | From | Steven Rostedt <> | Subject | Re: [PATCH V4 5/9] x86/alternative: Split text_poke_bp() into tree steps |
| |
On Mon, 4 Feb 2019 20:58:58 +0100 Daniel Bristot de Oliveira <bristot@redhat.com> wrote:
> > +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); > + text_poke(addr, &int3, sizeof(int3)); > +} > +
> + > +static void patch_first_byte(void *addr, const void *opcode, unsigned char int3) > +{ > + /* patch the first byte */ > + text_poke(addr, opcode, sizeof(int3)); > +}
Hmm, perhaps get rid of the first function entirely, and just do... (although why have the "int3" here anyway?)
> + > /** > * text_poke_bp() -- update instructions on live kernel on SMP > * @addr: address to patch > @@ -791,27 +814,21 @@ void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler) > { > unsigned char int3 = 0xcc; > > - bp_int3_handler = handler; > - bp_int3_addr = (u8 *)addr + sizeof(int3); > - bp_patching_in_progress = true; > - > lockdep_assert_held(&text_mutex); > > + bp_patching_in_progress = true; > /* > * Corresponding read barrier in int3 notifier for making sure the > * in_progress and handler are correctly ordered wrt. patching. > */ > smp_wmb(); > > - text_poke(addr, &int3, sizeof(int3)); > + text_poke_bp_set_handler(addr, handler, int3);
patch_first_byte(addr, &int3, int3);
Which could be just:
patch_first_byte(addr, &int3);
if we remove passing in int3 (for its size?).
-- Steve
> > on_each_cpu(do_sync_core, NULL, 1); > > if (len - sizeof(int3) > 0) { > - /* patch all but the first byte */ > - text_poke((char *)addr + sizeof(int3), > - (const char *) opcode + sizeof(int3), > - len - sizeof(int3)); > + patch_all_but_first_byte(addr, opcode, len, int3); > /* > * According to Intel, this core syncing is very likely > * not necessary and we'd be safe even without it. But > @@ -820,8 +837,7 @@ void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler) > on_each_cpu(do_sync_core, NULL, 1); > } > > - /* patch the first byte */ > - text_poke(addr, opcode, sizeof(int3)); > + patch_first_byte(addr, opcode, int3); > > on_each_cpu(do_sync_core, NULL, 1); > /*
| |