lkml.org 
[lkml]   [2020]   [Oct]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] checkpatch: Check for .byte-spelled insn opcodes documentation on x86
Date
From: Borislav Petkov <bp@suse.de>

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@infradead.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
---
scripts/checkpatch.pl | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 504d2e431c60..cfa81f1640cd 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6858,6 +6858,18 @@ sub process {
WARN("DUPLICATED_SYSCTL_CONST",
"duplicated sysctl range checking value '$1', consider using the shared one in include/linux/sysctl.h\n" . $herecurr);
}
+
+# document which binutils version supports the actual insn mnemonic so that the naked opcode bytes can be replaced.
+# x86-only.
+ if ($rawline =~ /(\.byte[\s0-9a-fx,]+)/ && $realfile =~ "^arch/x86/") {
+ my $comment = ctx_locate_comment(0, $linenr);
+ if (! $comment || ($comment !~ /binutils version [0-9.]+/ms)) {
+ WARN("MISSING_BINUTILS_VERSION",
+ "Please document which binutils version supports these .byte-spelled\n" .
+ "\tinsn opcodes by adding \"binutils version <num>\" in a comment" .
+ " above them.\n" . $herecurr);
+ }
+ }
}

# If we have no input at all, then there is nothing to report on
--
2.21.0
\
 
 \ /
  Last update: 2020-10-09 18:15    [W:0.178 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site