Messages in this thread |  | | Date | Mon, 4 Apr 2022 00:25:51 +0200 | From | Borislav Petkov <> | Subject | Re: [PATCH 1/5] x86/alternative: simplify DUMP_BYTES macro |
| |
On Fri, Mar 11, 2022 at 05:43:08PM +0300, Alexey Dobriyan wrote: > Avoid zero length check with clever whitespace placement in the format > string. > > Signed-off-by: Alexey Dobriyan (CloudLinux) <adobriyan@gmail.com> > --- > arch/x86/kernel/alternative.c | 21 +++++++++------------ > 1 file changed, 9 insertions(+), 12 deletions(-) > > diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c > index 5007c3ffe96f..6c9758ee6810 100644 > --- a/arch/x86/kernel/alternative.c > +++ b/arch/x86/kernel/alternative.c > @@ -66,13 +66,10 @@ do { \ > if (unlikely(debug_alternative)) { \ > int j; \ > \ > - if (!(len)) \ > - break; \ > - \ > printk(KERN_DEBUG pr_fmt(fmt), ##args); \ > - for (j = 0; j < (len) - 1; j++) \ > - printk(KERN_CONT "%02hhx ", buf[j]); \ > - printk(KERN_CONT "%02hhx\n", buf[j]); \ > + for (j = 0; j < (len); j++) \ > + printk(KERN_CONT " %02hhx", buf[j]); \ > + printk(KERN_CONT "\n"); \ > } \ > } while (0)
That doesn't work always.
Before:
SMP alternatives: feat: 9*32+0, old: (current_save_fsgs+0x32/0xa0 (ffffffff81017762) len: 5), repl: (ffffffff89997c78, len: 0) SMP alternatives: ffffffff81017762: old_insn: eb 32 0f 1f 00 SMP alternatives: ffffffff81017762: final_insn: 90 90 90 90 90 SMP alternatives: ffffffff81017762: [0:5) optimized NOPs: 0f 1f 44 00 00
After:
SMP alternatives: feat: 9*32+0, old: (current_save_fsgs+0x32/0xa0 (ffffffff81017762) len: 5), repl: (ffffffff89997c78, len: 0) SMP alternatives: ffffffff81017762: old_insn: eb 32 0f 1f 00 SMP alternatives: ffffffff89997c78: rpl_insn: <----- * SMP alternatives: ffffffff81017762: final_insn: 90 90 90 90 90 SMP alternatives: ffffffff81017762: [0:5) optimized NOPs: 0f 1f 44 00 00
there is no replacement insn in this case:
static __always_inline bool _static_cpu_has(u16 bit) { asm_volatile_goto( ALTERNATIVE_TERNARY("jmp 6f", %P[feature], "", "jmp %l[t_no]") ^^
-- Regards/Gruss, Boris.
https://people.kernel.org/tglx/notes-about-netiquette
|  |