public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Joe Perches <joe@perches.com>
Cc: X86 ML <x86@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Andy Whitcroft <apw@canonical.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH] checkpatch: Check for .byte-spelled insn opcodes documentation on x86
Date: Sat, 10 Oct 2020 12:54:21 +0200	[thread overview]
Message-ID: <20201010105421.GA24674@zn.tnic> (raw)
In-Reply-To: <b57a59bc80e432c7696b347a223eb12339013970.camel@perches.com>

On Fri, Oct 09, 2020 at 11:01:18AM -0700, Joe Perches wrote:
> Given the location, this only works on .c and .h files.
> It does not work on .S files.  Should it?

Probably not because there will be too many false positives. .byte is
used not only to spell instruction opcodes in .S files. And the main
case we're addressing here is using those .byte spelled opcodes in asm
volatile constructs so...

> No need for a capture group.

Debugging leftover, gone now.

> Please use @ not " as all the other $realfile comparisons
> use that form when expecting a /

Done.

> So it looks like the regex would be more complete as:
> 
> 	if ($realfile =~ m@^arch/x86/@ &&
> 	    $rawline =~ /\.byte\s+(?:$Constant|(?:\\)?$Ident|"\s*$Ident)\b/) {

This is much less readable than what I have now (yes, realfile test
should come first):

	if ($realfile =~ m@^arch/x86/@ && $rawline =~ /\.byte[\s0-9a-fx,]+/) {

Also, this

	$rawline =~ /\.byte\s+(?:$Constant|(?:\\)?$Ident|"\s*$Ident)\b/) {

matches

	".byte 0x66"

This

	$rawline =~ /\.byte[\s0-9a-fx,]+)) {

matches

	".byte 0x66, 0x0f, 0x38, 0xf8, 0x02"

which is what it needs to match.

> A patch can modify any number of files.
> 
> This should use ctx_locate_comment($file ? 0 : $first_line, $linenr)
> as checkpatch tests work on patch contexts not the entire
> file before this line.

Done.

> No need for the $!comment test

Done.

> checkpatch uses only a single line output only before $herecurr
> Output line length doesn't matter.

Well, this:

WARNING: Please document which binutils version supports these .byte-spelled
        insn opcodes by adding "binutils version <num>" in a comment above them.
#90: FILE: arch/x86/include/asm/special_insns.h:254:
+       asm volatile(".byte 0x66, 0x0f, 0x38, 0xf8, 0x02"


is easier readable than this:

WARNING: Please document which binutils version supports these .byte-spelledinsn opcodes by adding "binutils version <num>" in a comment above them.
#90: FILE: arch/x86/include/asm/special_insns.h:254:
+       asm volatile(".byte 0x66, 0x0f, 0x38, 0xf8, 0x02"

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

  reply	other threads:[~2020-10-10 22:58 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-09 16:14 [PATCH] checkpatch: Check for .byte-spelled insn opcodes documentation on x86 Borislav Petkov
2020-10-09 18:01 ` Joe Perches
2020-10-10 10:54   ` Borislav Petkov [this message]
2020-10-10 10:55     ` [PATCH -v2] " Borislav Petkov
2020-10-10 15:27     ` [PATCH] " Joe Perches
2020-10-10 16:11       ` Borislav Petkov
2020-10-10 16:47         ` Joe Perches
2020-10-12 14:21           ` Borislav Petkov
2020-10-12 14:23             ` [PATCH -v3] " Borislav Petkov
2020-10-12 15:04               ` Joe Perches
2020-10-12 15:02             ` [PATCH] " Joe Perches
2020-10-12 17:09             ` [PATCH -v4] " Joe Perches
2020-10-12 17:15               ` Borislav Petkov
2020-10-12 17:17                 ` Joe Perches
2020-10-12 17:31                   ` Borislav Petkov
2020-10-12 17:40                     ` Joe Perches
2020-10-12 17:55                       ` Borislav Petkov
2020-10-12 18:03                         ` Joe Perches
2020-10-10 15:38     ` [PATCH] " Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201010105421.GA24674@zn.tnic \
    --to=bp@alien8.de \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox