Re: [PATCH -v4] checkpatch: Check for .byte-spelled insn opcodes documentation on x86

From: Joe Perches
Date: Mon Oct 12 2020 - 13:18:02 EST


On Mon, 2020-10-12 at 19:15 +0200, Borislav Petkov wrote:
> On Mon, Oct 12, 2020 at 10:09:44AM -0700, Joe Perches wrote:
> > From: Borislav Petkov <bp@xxxxxxx>
> >
> > Instruction opcode bytes spelled using the gas directive .byte should
> > carry a comment above them stating which binutils version has added
> > support for the instruction mnemonic so that they can be replaced with
> > the mnemonic when that binutils version is equal or less than the
> > minimum-supported version by the kernel.
> >
> > Add a check for that.
> >
> > Requested-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> > Signed-off-by: Borislav Petkov <bp@xxxxxxx>
> > Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>
> > ---
> >
> > v4: trivial neatening of $Hex_byte and adding a mechanism to
> > only emit the message once per patched file (Joe)
> >
> > scripts/checkpatch.pl | 18 ++++++++++++++++++
> > 1 file changed, 18 insertions(+)
>
> ./scripts/checkpatch.pl /tmp/test
> Global symbol "$rawline" requires explicit package name (did you forget to declare "my $rawline"?) at ./scripts/checkpatch.pl line 6943.
> Global symbol "$herecurr" requires explicit package name (did you forget to declare "my $herecurr"?) at ./scripts/checkpatch.pl line 6948.
> Execution of ./scripts/checkpatch.pl aborted due to compilation errors.
>
> No workie.

Workie here. This is against -next.

$ ./scripts/checkpatch.pl -f arch/x86/include/asm/smap.h
WARNING: Please consider documenting which binutils version supports these .byte-spelled insn opcodes by adding "binutils version <num>" in a comment above them
#16: FILE: arch/x86/include/asm/smap.h:16:
+#define __ASM_CLAC ".byte 0x0f,0x01,0xca"

WARNING: Prefer using '"%s...", __func__' to using 'smap_save', this function's name, in a string
#60: FILE: arch/x86/include/asm/smap.h:60:
+ asm volatile ("# smap_save\n\t"

WARNING: Prefer using '"%s...", __func__' to using 'smap_restore', this function's name, in a string
#71: FILE: arch/x86/include/asm/smap.h:71:
+ asm volatile ("# smap_restore\n\t"

total: 0 errors, 3 warnings, 99 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

arch/x86/include/asm/smap.h has style problems, please review.

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.