Re: [PATCH v2 02/14] x86/alternatives: Optimize optimize_nops()

2021-03-22 Thread Borislav Petkov
On Mon, Mar 22, 2021 at 09:17:57AM +0100, Peter Zijlstra wrote: > You've make it only replace a single stream of NOPs. Which is probably > fine, but... :-) Yap, since I added the padding thing there should be no need to put NOPs in the middle. > So mine, while a little more complicated, will repl

Re: [PATCH v2 02/14] x86/alternatives: Optimize optimize_nops()

2021-03-22 Thread Peter Zijlstra
On Sun, Mar 21, 2021 at 01:06:47PM +0100, Borislav Petkov wrote: > I think I've made this simpler; pasting the whole function and not the > diff because former is easier to read: You've make it only replace a single stream of NOPs. Which is probably fine, but... :-) So mine, while a little more

Re: [PATCH v2 02/14] x86/alternatives: Optimize optimize_nops()

2021-03-21 Thread Borislav Petkov
On Thu, Mar 18, 2021 at 06:11:05PM +0100, Peter Zijlstra wrote: > --- a/arch/x86/kernel/alternative.c > +++ b/arch/x86/kernel/alternative.c > @@ -345,19 +345,39 @@ recompute_jump(struct alt_instr *a, u8 * > static void __init_or_module noinline optimize_nops(struct alt_instr *a, u8 > *instr) > {

[PATCH v2 02/14] x86/alternatives: Optimize optimize_nops()

2021-03-18 Thread Peter Zijlstra
Currently optimize_nops() scans to see if the alternative starts with NOPs. However, the emit pattern is: 141: \oldinstr 142: .skip (len-(142b-141b)), 0x90 That is, when oldinstr is short, we pad the tail with NOPs. This case never gets optimized. Rewrite optimize_nops() to replace any str