All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
@ 2021-01-20  7:25 ` Aditya Srivastava
  0 siblings, 0 replies; 32+ messages in thread
From: Aditya Srivastava @ 2021-01-20  7:25 UTC (permalink / raw)
  To: linux-kernel
  Cc: yashsri421, lukas.bulwahn, dwaipayanray1, broonie, joe,
	linux-kernel-mentees, clang-built-linux

Local symbols prefixed with '.L' do not emit symbol table entries, as
they have special meaning for the assembler.

'.L' prefixed symbols can be used within a code region, but should be
avoided for denoting a range of code via 'SYM_*_START/END' annotations.

Add a new check to emit a warning on finding the usage of '.L' symbols
in '.S' files, if it lies within SYM_*_START/END annotation pair.

Suggested-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/lkml/20210112210154.GI4646@sirena.org.uk/
Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
---
 scripts/checkpatch.pl | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7030c4d6d126..858b5def61e9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2501,6 +2501,9 @@ sub process {
 
 	my $checklicenseline = 1;
 
+	# record SYM_*_START/END annotation pair count, for AVOID_L_PREFIX
+	my $sym_start_block = 0;
+
 	sanitise_line_reset();
 	my $line;
 	foreach my $rawline (@rawlines) {
@@ -3590,6 +3593,25 @@ sub process {
 			}
 		}
 
+# check for .L prefix local symbols in .S files
+		if ($realfile =~ /\.S$/) {
+			if ($line =~ /SYM_.*_START/ ||
+			    (defined $context_function && $context_function =~ /SYM_.*_START/)) {
+				$sym_start_block++;
+			}
+
+			if ($line=~ /\.L\S+/ &&		# line contains .L prefixed local symbol
+			    $sym_start_block > 0) {	# lies between SYM_*_START and SYM_*_END pair
+				WARN("AVOID_L_PREFIX",
+					"Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/asm-annotations.rst\n" . $herecurr);
+			}
+
+			if ($line =~ /SYM_.*_END/ ||
+			    (defined $context_function && $context_function =~ /SYM_.*_END/)) {
+				$sym_start_block--;
+			}
+		}
+
 # check we are in a valid source file C or perl if not then ignore this hunk
 		next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Linux-kernel-mentees] [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
@ 2021-01-20  7:25 ` Aditya Srivastava
  0 siblings, 0 replies; 32+ messages in thread
From: Aditya Srivastava @ 2021-01-20  7:25 UTC (permalink / raw)
  To: linux-kernel
  Cc: yashsri421, dwaipayanray1, clang-built-linux, broonie, joe,
	linux-kernel-mentees

Local symbols prefixed with '.L' do not emit symbol table entries, as
they have special meaning for the assembler.

'.L' prefixed symbols can be used within a code region, but should be
avoided for denoting a range of code via 'SYM_*_START/END' annotations.

Add a new check to emit a warning on finding the usage of '.L' symbols
in '.S' files, if it lies within SYM_*_START/END annotation pair.

Suggested-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/lkml/20210112210154.GI4646@sirena.org.uk/
Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
---
 scripts/checkpatch.pl | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7030c4d6d126..858b5def61e9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2501,6 +2501,9 @@ sub process {
 
 	my $checklicenseline = 1;
 
+	# record SYM_*_START/END annotation pair count, for AVOID_L_PREFIX
+	my $sym_start_block = 0;
+
 	sanitise_line_reset();
 	my $line;
 	foreach my $rawline (@rawlines) {
@@ -3590,6 +3593,25 @@ sub process {
 			}
 		}
 
+# check for .L prefix local symbols in .S files
+		if ($realfile =~ /\.S$/) {
+			if ($line =~ /SYM_.*_START/ ||
+			    (defined $context_function && $context_function =~ /SYM_.*_START/)) {
+				$sym_start_block++;
+			}
+
+			if ($line=~ /\.L\S+/ &&		# line contains .L prefixed local symbol
+			    $sym_start_block > 0) {	# lies between SYM_*_START and SYM_*_END pair
+				WARN("AVOID_L_PREFIX",
+					"Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/asm-annotations.rst\n" . $herecurr);
+			}
+
+			if ($line =~ /SYM_.*_END/ ||
+			    (defined $context_function && $context_function =~ /SYM_.*_END/)) {
+				$sym_start_block--;
+			}
+		}
+
 # check we are in a valid source file C or perl if not then ignore this hunk
 		next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
 
-- 
2.17.1

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
  2021-01-20  7:25 ` [Linux-kernel-mentees] " Aditya Srivastava
@ 2021-01-20  9:21   ` Joe Perches
  -1 siblings, 0 replies; 32+ messages in thread
From: Joe Perches @ 2021-01-20  9:21 UTC (permalink / raw)
  To: Aditya Srivastava, linux-kernel
  Cc: lukas.bulwahn, dwaipayanray1, broonie, linux-kernel-mentees,
	clang-built-linux

On Wed, 2021-01-20 at 12:55 +0530, Aditya Srivastava wrote:
> Local symbols prefixed with '.L' do not emit symbol table entries, as
> they have special meaning for the assembler.
> 
> '.L' prefixed symbols can be used within a code region, but should be
> avoided for denoting a range of code via 'SYM_*_START/END' annotations.
> 
> Add a new check to emit a warning on finding the usage of '.L' symbols
> in '.S' files, if it lies within SYM_*_START/END annotation pair.

I believe this needs a test for $file as it won't work well on
patches as the SYM_*_START/END may not be in the patch context.

Also, is this supposed to work for local labels like '.L<foo>:'?
I don't think a warning should be generated for those.



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
@ 2021-01-20  9:21   ` Joe Perches
  0 siblings, 0 replies; 32+ messages in thread
From: Joe Perches @ 2021-01-20  9:21 UTC (permalink / raw)
  To: Aditya Srivastava, linux-kernel
  Cc: broonie, linux-kernel-mentees, clang-built-linux, dwaipayanray1

On Wed, 2021-01-20 at 12:55 +0530, Aditya Srivastava wrote:
> Local symbols prefixed with '.L' do not emit symbol table entries, as
> they have special meaning for the assembler.
> 
> '.L' prefixed symbols can be used within a code region, but should be
> avoided for denoting a range of code via 'SYM_*_START/END' annotations.
> 
> Add a new check to emit a warning on finding the usage of '.L' symbols
> in '.S' files, if it lies within SYM_*_START/END annotation pair.

I believe this needs a test for $file as it won't work well on
patches as the SYM_*_START/END may not be in the patch context.

Also, is this supposed to work for local labels like '.L<foo>:'?
I don't think a warning should be generated for those.


_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
  2021-01-20  9:21   ` [Linux-kernel-mentees] " Joe Perches
@ 2021-01-20 12:53     ` Aditya
  -1 siblings, 0 replies; 32+ messages in thread
From: Aditya @ 2021-01-20 12:53 UTC (permalink / raw)
  To: Joe Perches, linux-kernel
  Cc: lukas.bulwahn, dwaipayanray1, broonie, linux-kernel-mentees,
	clang-built-linux

On 20/1/21 2:51 pm, Joe Perches wrote:
> On Wed, 2021-01-20 at 12:55 +0530, Aditya Srivastava wrote:
>> Local symbols prefixed with '.L' do not emit symbol table entries, as
>> they have special meaning for the assembler.
>>
>> '.L' prefixed symbols can be used within a code region, but should be
>> avoided for denoting a range of code via 'SYM_*_START/END' annotations.
>>
>> Add a new check to emit a warning on finding the usage of '.L' symbols
>> in '.S' files, if it lies within SYM_*_START/END annotation pair.
> 
> I believe this needs a test for $file as it won't work well on
> patches as the SYM_*_START/END may not be in the patch context.
> 
Okay.

> Also, is this supposed to work for local labels like '.L<foo>:'?
> I don't think a warning should be generated for those.
> 
Yes, currently it will generate warning for all symbols which start
with .L and have non- white character symbol following it, if it is
lying within SYM_*_START/END annotation pair.

Should I reduce the check to \.L_\S+ instead? (please note "_"
following ".L")
Pardon me, I'm not good with assembly :/

Thanks
Aditya

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
@ 2021-01-20 12:53     ` Aditya
  0 siblings, 0 replies; 32+ messages in thread
From: Aditya @ 2021-01-20 12:53 UTC (permalink / raw)
  To: Joe Perches, linux-kernel
  Cc: broonie, linux-kernel-mentees, clang-built-linux, dwaipayanray1

On 20/1/21 2:51 pm, Joe Perches wrote:
> On Wed, 2021-01-20 at 12:55 +0530, Aditya Srivastava wrote:
>> Local symbols prefixed with '.L' do not emit symbol table entries, as
>> they have special meaning for the assembler.
>>
>> '.L' prefixed symbols can be used within a code region, but should be
>> avoided for denoting a range of code via 'SYM_*_START/END' annotations.
>>
>> Add a new check to emit a warning on finding the usage of '.L' symbols
>> in '.S' files, if it lies within SYM_*_START/END annotation pair.
> 
> I believe this needs a test for $file as it won't work well on
> patches as the SYM_*_START/END may not be in the patch context.
> 
Okay.

> Also, is this supposed to work for local labels like '.L<foo>:'?
> I don't think a warning should be generated for those.
> 
Yes, currently it will generate warning for all symbols which start
with .L and have non- white character symbol following it, if it is
lying within SYM_*_START/END annotation pair.

Should I reduce the check to \.L_\S+ instead? (please note "_"
following ".L")
Pardon me, I'm not good with assembly :/

Thanks
Aditya
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
  2021-01-20 12:53     ` [Linux-kernel-mentees] " Aditya
@ 2021-01-20 18:43       ` Joe Perches
  -1 siblings, 0 replies; 32+ messages in thread
From: Joe Perches @ 2021-01-20 18:43 UTC (permalink / raw)
  To: Aditya, linux-kernel
  Cc: lukas.bulwahn, dwaipayanray1, broonie, linux-kernel-mentees,
	clang-built-linux

On Wed, 2021-01-20 at 18:23 +0530, Aditya wrote:
> On 20/1/21 2:51 pm, Joe Perches wrote:
> > On Wed, 2021-01-20 at 12:55 +0530, Aditya Srivastava wrote:
> > > Local symbols prefixed with '.L' do not emit symbol table entries, as
> > > they have special meaning for the assembler.
> > > 
> > > '.L' prefixed symbols can be used within a code region, but should be
> > > avoided for denoting a range of code via 'SYM_*_START/END' annotations.
> > > 
> > > Add a new check to emit a warning on finding the usage of '.L' symbols
> > > in '.S' files, if it lies within SYM_*_START/END annotation pair.
> > 
> > I believe this needs a test for $file as it won't work well on
> > patches as the SYM_*_START/END may not be in the patch context.
> > 
> Okay.
> 
> > Also, is this supposed to work for local labels like '.L<foo>:'?
> > I don't think a warning should be generated for those.
> > 
> Yes, currently it will generate warning for all symbols which start
> with .L and have non- white character symbol following it, if it is
> lying within SYM_*_START/END annotation pair.
> 
> Should I reduce the check to \.L_\S+ instead? (please note "_"
> following ".L")

Use grep first.  That would still match several existing labels.

> Pardon me, I'm not good with assembly :/

Spending time reading docs can help with that.

Mark?  Can you please comment about the below?

I believe the test should be:

	if ($realfile =~ /\.S$/ &&
	    $line =~ /^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
		WARN(...);
	}

so that only this code currently matches:

$ git grep -P '^\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L' -- '*.S'
arch/x86/boot/compressed/head_32.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
arch/x86/boot/compressed/head_32.S:SYM_FUNC_END(.Lrelocated)
arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lrelocated)
arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lpaging_enabled)
arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lpaging_enabled)
arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lno_longmode)
arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lno_longmode)
arch/x86/boot/pmjump.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lin_pm32)
arch/x86/boot/pmjump.S:SYM_FUNC_END(.Lin_pm32)
arch/x86/entry/entry_64.S:SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs)
arch/x86/entry/entry_64.S:SYM_CODE_END(.Lbad_gs)
arch/x86/lib/copy_user_64.S:SYM_CODE_START_LOCAL(.Lcopy_user_handle_tail)
arch/x86/lib/copy_user_64.S:SYM_CODE_END(.Lcopy_user_handle_tail)
arch/x86/lib/getuser.S:SYM_CODE_START_LOCAL(.Lbad_get_user_clac)
arch/x86/lib/getuser.S:SYM_CODE_END(.Lbad_get_user_clac)
arch/x86/lib/getuser.S:SYM_CODE_START_LOCAL(.Lbad_get_user_8_clac)
arch/x86/lib/getuser.S:SYM_CODE_END(.Lbad_get_user_8_clac)
arch/x86/lib/putuser.S:SYM_CODE_START_LOCAL(.Lbad_put_user_clac)
arch/x86/lib/putuser.S:SYM_CODE_END(.Lbad_put_user_clac)
arch/x86/realmode/rm/wakeup_asm.S:SYM_DATA_START_LOCAL(.Lwakeup_idt)
arch/x86/realmode/rm/wakeup_asm.S:SYM_DATA_END(.Lwakeup_idt)



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
@ 2021-01-20 18:43       ` Joe Perches
  0 siblings, 0 replies; 32+ messages in thread
From: Joe Perches @ 2021-01-20 18:43 UTC (permalink / raw)
  To: Aditya, linux-kernel
  Cc: broonie, linux-kernel-mentees, clang-built-linux, dwaipayanray1

On Wed, 2021-01-20 at 18:23 +0530, Aditya wrote:
> On 20/1/21 2:51 pm, Joe Perches wrote:
> > On Wed, 2021-01-20 at 12:55 +0530, Aditya Srivastava wrote:
> > > Local symbols prefixed with '.L' do not emit symbol table entries, as
> > > they have special meaning for the assembler.
> > > 
> > > '.L' prefixed symbols can be used within a code region, but should be
> > > avoided for denoting a range of code via 'SYM_*_START/END' annotations.
> > > 
> > > Add a new check to emit a warning on finding the usage of '.L' symbols
> > > in '.S' files, if it lies within SYM_*_START/END annotation pair.
> > 
> > I believe this needs a test for $file as it won't work well on
> > patches as the SYM_*_START/END may not be in the patch context.
> > 
> Okay.
> 
> > Also, is this supposed to work for local labels like '.L<foo>:'?
> > I don't think a warning should be generated for those.
> > 
> Yes, currently it will generate warning for all symbols which start
> with .L and have non- white character symbol following it, if it is
> lying within SYM_*_START/END annotation pair.
> 
> Should I reduce the check to \.L_\S+ instead? (please note "_"
> following ".L")

Use grep first.  That would still match several existing labels.

> Pardon me, I'm not good with assembly :/

Spending time reading docs can help with that.

Mark?  Can you please comment about the below?

I believe the test should be:

	if ($realfile =~ /\.S$/ &&
	    $line =~ /^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
		WARN(...);
	}

so that only this code currently matches:

$ git grep -P '^\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L' -- '*.S'
arch/x86/boot/compressed/head_32.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
arch/x86/boot/compressed/head_32.S:SYM_FUNC_END(.Lrelocated)
arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lrelocated)
arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lpaging_enabled)
arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lpaging_enabled)
arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lno_longmode)
arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lno_longmode)
arch/x86/boot/pmjump.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lin_pm32)
arch/x86/boot/pmjump.S:SYM_FUNC_END(.Lin_pm32)
arch/x86/entry/entry_64.S:SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs)
arch/x86/entry/entry_64.S:SYM_CODE_END(.Lbad_gs)
arch/x86/lib/copy_user_64.S:SYM_CODE_START_LOCAL(.Lcopy_user_handle_tail)
arch/x86/lib/copy_user_64.S:SYM_CODE_END(.Lcopy_user_handle_tail)
arch/x86/lib/getuser.S:SYM_CODE_START_LOCAL(.Lbad_get_user_clac)
arch/x86/lib/getuser.S:SYM_CODE_END(.Lbad_get_user_clac)
arch/x86/lib/getuser.S:SYM_CODE_START_LOCAL(.Lbad_get_user_8_clac)
arch/x86/lib/getuser.S:SYM_CODE_END(.Lbad_get_user_8_clac)
arch/x86/lib/putuser.S:SYM_CODE_START_LOCAL(.Lbad_put_user_clac)
arch/x86/lib/putuser.S:SYM_CODE_END(.Lbad_put_user_clac)
arch/x86/realmode/rm/wakeup_asm.S:SYM_DATA_START_LOCAL(.Lwakeup_idt)
arch/x86/realmode/rm/wakeup_asm.S:SYM_DATA_END(.Lwakeup_idt)


_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
  2021-01-20 18:43       ` [Linux-kernel-mentees] " Joe Perches
@ 2021-01-20 18:57         ` Nick Desaulniers via Linux-kernel-mentees
  -1 siblings, 0 replies; 32+ messages in thread
From: Nick Desaulniers @ 2021-01-20 18:57 UTC (permalink / raw)
  To: Josh Poimboeuf
  Cc: Aditya, LKML, Lukas Bulwahn, dwaipayanray1, Mark Brown,
	linux-kernel-mentees, clang-built-linux, Joe Perches

On Wed, Jan 20, 2021 at 10:43 AM Joe Perches <joe@perches.com> wrote:
>
> On Wed, 2021-01-20 at 18:23 +0530, Aditya wrote:
> > On 20/1/21 2:51 pm, Joe Perches wrote:
> > > On Wed, 2021-01-20 at 12:55 +0530, Aditya Srivastava wrote:
> > > > Local symbols prefixed with '.L' do not emit symbol table entries, as
> > > > they have special meaning for the assembler.
> > > >
> > > > '.L' prefixed symbols can be used within a code region, but should be
> > > > avoided for denoting a range of code via 'SYM_*_START/END' annotations.
> > > >
> > > > Add a new check to emit a warning on finding the usage of '.L' symbols
> > > > in '.S' files, if it lies within SYM_*_START/END annotation pair.
> > >
> > > I believe this needs a test for $file as it won't work well on
> > > patches as the SYM_*_START/END may not be in the patch context.
> > >
> > Okay.
> >
> > > Also, is this supposed to work for local labels like '.L<foo>:'?
> > > I don't think a warning should be generated for those.
> > >
> > Yes, currently it will generate warning for all symbols which start
> > with .L and have non- white character symbol following it, if it is
> > lying within SYM_*_START/END annotation pair.
> >
> > Should I reduce the check to \.L_\S+ instead? (please note "_"
> > following ".L")
>
> Use grep first.  That would still match several existing labels.
>
> > Pardon me, I'm not good with assembly :/
>
> Spending time reading docs can help with that.
>
> Mark?  Can you please comment about the below?
>
> I believe the test should be:
>
>         if ($realfile =~ /\.S$/ &&
>             $line =~ /^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
>                 WARN(...);
>         }
>
> so that only this code currently matches:
>
> $ git grep -P '^\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L' -- '*.S'
> arch/x86/boot/compressed/head_32.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
> arch/x86/boot/compressed/head_32.S:SYM_FUNC_END(.Lrelocated)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lrelocated)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lpaging_enabled)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lpaging_enabled)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lno_longmode)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lno_longmode)
> arch/x86/boot/pmjump.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lin_pm32)
> arch/x86/boot/pmjump.S:SYM_FUNC_END(.Lin_pm32)
> arch/x86/entry/entry_64.S:SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs)
> arch/x86/entry/entry_64.S:SYM_CODE_END(.Lbad_gs)
> arch/x86/lib/copy_user_64.S:SYM_CODE_START_LOCAL(.Lcopy_user_handle_tail)
> arch/x86/lib/copy_user_64.S:SYM_CODE_END(.Lcopy_user_handle_tail)
> arch/x86/lib/getuser.S:SYM_CODE_START_LOCAL(.Lbad_get_user_clac)
> arch/x86/lib/getuser.S:SYM_CODE_END(.Lbad_get_user_clac)
> arch/x86/lib/getuser.S:SYM_CODE_START_LOCAL(.Lbad_get_user_8_clac)
> arch/x86/lib/getuser.S:SYM_CODE_END(.Lbad_get_user_8_clac)
> arch/x86/lib/putuser.S:SYM_CODE_START_LOCAL(.Lbad_put_user_clac)
> arch/x86/lib/putuser.S:SYM_CODE_END(.Lbad_put_user_clac)
> arch/x86/realmode/rm/wakeup_asm.S:SYM_DATA_START_LOCAL(.Lwakeup_idt)
> arch/x86/realmode/rm/wakeup_asm.S:SYM_DATA_END(.Lwakeup_idt)

Josh, I assume objtool does not annotate code under:
arch/x86/boot/
arch/x86/entry/
arch/x86/realmode/
?

The rest, ie
arch/x86/lib/
seem potentially relevant?
-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
@ 2021-01-20 18:57         ` Nick Desaulniers via Linux-kernel-mentees
  0 siblings, 0 replies; 32+ messages in thread
From: Nick Desaulniers via Linux-kernel-mentees @ 2021-01-20 18:57 UTC (permalink / raw)
  To: Josh Poimboeuf
  Cc: Aditya, dwaipayanray1, LKML, clang-built-linux, Mark Brown,
	Joe Perches, linux-kernel-mentees

On Wed, Jan 20, 2021 at 10:43 AM Joe Perches <joe@perches.com> wrote:
>
> On Wed, 2021-01-20 at 18:23 +0530, Aditya wrote:
> > On 20/1/21 2:51 pm, Joe Perches wrote:
> > > On Wed, 2021-01-20 at 12:55 +0530, Aditya Srivastava wrote:
> > > > Local symbols prefixed with '.L' do not emit symbol table entries, as
> > > > they have special meaning for the assembler.
> > > >
> > > > '.L' prefixed symbols can be used within a code region, but should be
> > > > avoided for denoting a range of code via 'SYM_*_START/END' annotations.
> > > >
> > > > Add a new check to emit a warning on finding the usage of '.L' symbols
> > > > in '.S' files, if it lies within SYM_*_START/END annotation pair.
> > >
> > > I believe this needs a test for $file as it won't work well on
> > > patches as the SYM_*_START/END may not be in the patch context.
> > >
> > Okay.
> >
> > > Also, is this supposed to work for local labels like '.L<foo>:'?
> > > I don't think a warning should be generated for those.
> > >
> > Yes, currently it will generate warning for all symbols which start
> > with .L and have non- white character symbol following it, if it is
> > lying within SYM_*_START/END annotation pair.
> >
> > Should I reduce the check to \.L_\S+ instead? (please note "_"
> > following ".L")
>
> Use grep first.  That would still match several existing labels.
>
> > Pardon me, I'm not good with assembly :/
>
> Spending time reading docs can help with that.
>
> Mark?  Can you please comment about the below?
>
> I believe the test should be:
>
>         if ($realfile =~ /\.S$/ &&
>             $line =~ /^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
>                 WARN(...);
>         }
>
> so that only this code currently matches:
>
> $ git grep -P '^\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L' -- '*.S'
> arch/x86/boot/compressed/head_32.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
> arch/x86/boot/compressed/head_32.S:SYM_FUNC_END(.Lrelocated)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lrelocated)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lpaging_enabled)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lpaging_enabled)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lno_longmode)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lno_longmode)
> arch/x86/boot/pmjump.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lin_pm32)
> arch/x86/boot/pmjump.S:SYM_FUNC_END(.Lin_pm32)
> arch/x86/entry/entry_64.S:SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs)
> arch/x86/entry/entry_64.S:SYM_CODE_END(.Lbad_gs)
> arch/x86/lib/copy_user_64.S:SYM_CODE_START_LOCAL(.Lcopy_user_handle_tail)
> arch/x86/lib/copy_user_64.S:SYM_CODE_END(.Lcopy_user_handle_tail)
> arch/x86/lib/getuser.S:SYM_CODE_START_LOCAL(.Lbad_get_user_clac)
> arch/x86/lib/getuser.S:SYM_CODE_END(.Lbad_get_user_clac)
> arch/x86/lib/getuser.S:SYM_CODE_START_LOCAL(.Lbad_get_user_8_clac)
> arch/x86/lib/getuser.S:SYM_CODE_END(.Lbad_get_user_8_clac)
> arch/x86/lib/putuser.S:SYM_CODE_START_LOCAL(.Lbad_put_user_clac)
> arch/x86/lib/putuser.S:SYM_CODE_END(.Lbad_put_user_clac)
> arch/x86/realmode/rm/wakeup_asm.S:SYM_DATA_START_LOCAL(.Lwakeup_idt)
> arch/x86/realmode/rm/wakeup_asm.S:SYM_DATA_END(.Lwakeup_idt)

Josh, I assume objtool does not annotate code under:
arch/x86/boot/
arch/x86/entry/
arch/x86/realmode/
?

The rest, ie
arch/x86/lib/
seem potentially relevant?
-- 
Thanks,
~Nick Desaulniers
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
  2021-01-20 18:57         ` [Linux-kernel-mentees] " Nick Desaulniers via Linux-kernel-mentees
@ 2021-01-20 22:59           ` Josh Poimboeuf
  -1 siblings, 0 replies; 32+ messages in thread
From: Josh Poimboeuf @ 2021-01-20 22:59 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Aditya, LKML, Lukas Bulwahn, dwaipayanray1, Mark Brown,
	linux-kernel-mentees, clang-built-linux, Joe Perches

On Wed, Jan 20, 2021 at 10:57:03AM -0800, Nick Desaulniers wrote:
> > $ git grep -P '^\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L' -- '*.S'
> > arch/x86/boot/compressed/head_32.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
> > arch/x86/boot/compressed/head_32.S:SYM_FUNC_END(.Lrelocated)
> > arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
> > arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lrelocated)
> > arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lpaging_enabled)
> > arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lpaging_enabled)
> > arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lno_longmode)
> > arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lno_longmode)
> > arch/x86/boot/pmjump.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lin_pm32)
> > arch/x86/boot/pmjump.S:SYM_FUNC_END(.Lin_pm32)
> > arch/x86/entry/entry_64.S:SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs)
> > arch/x86/entry/entry_64.S:SYM_CODE_END(.Lbad_gs)
> > arch/x86/lib/copy_user_64.S:SYM_CODE_START_LOCAL(.Lcopy_user_handle_tail)
> > arch/x86/lib/copy_user_64.S:SYM_CODE_END(.Lcopy_user_handle_tail)
> > arch/x86/lib/getuser.S:SYM_CODE_START_LOCAL(.Lbad_get_user_clac)
> > arch/x86/lib/getuser.S:SYM_CODE_END(.Lbad_get_user_clac)
> > arch/x86/lib/getuser.S:SYM_CODE_START_LOCAL(.Lbad_get_user_8_clac)
> > arch/x86/lib/getuser.S:SYM_CODE_END(.Lbad_get_user_8_clac)
> > arch/x86/lib/putuser.S:SYM_CODE_START_LOCAL(.Lbad_put_user_clac)
> > arch/x86/lib/putuser.S:SYM_CODE_END(.Lbad_put_user_clac)
> > arch/x86/realmode/rm/wakeup_asm.S:SYM_DATA_START_LOCAL(.Lwakeup_idt)
> > arch/x86/realmode/rm/wakeup_asm.S:SYM_DATA_END(.Lwakeup_idt)
> 
> Josh, I assume objtool does not annotate code under:
> arch/x86/boot/
> arch/x86/entry/
> arch/x86/realmode/
> ?
> 
> The rest, ie
> arch/x86/lib/
> seem potentially relevant?

Both arch/x86/entry/* and arch/x86/lib/* are read by objtool and should
probably be fixed up.

-- 
Josh


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
@ 2021-01-20 22:59           ` Josh Poimboeuf
  0 siblings, 0 replies; 32+ messages in thread
From: Josh Poimboeuf @ 2021-01-20 22:59 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Aditya, dwaipayanray1, LKML, clang-built-linux, Mark Brown,
	Joe Perches, linux-kernel-mentees

On Wed, Jan 20, 2021 at 10:57:03AM -0800, Nick Desaulniers wrote:
> > $ git grep -P '^\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L' -- '*.S'
> > arch/x86/boot/compressed/head_32.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
> > arch/x86/boot/compressed/head_32.S:SYM_FUNC_END(.Lrelocated)
> > arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
> > arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lrelocated)
> > arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lpaging_enabled)
> > arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lpaging_enabled)
> > arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lno_longmode)
> > arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lno_longmode)
> > arch/x86/boot/pmjump.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lin_pm32)
> > arch/x86/boot/pmjump.S:SYM_FUNC_END(.Lin_pm32)
> > arch/x86/entry/entry_64.S:SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs)
> > arch/x86/entry/entry_64.S:SYM_CODE_END(.Lbad_gs)
> > arch/x86/lib/copy_user_64.S:SYM_CODE_START_LOCAL(.Lcopy_user_handle_tail)
> > arch/x86/lib/copy_user_64.S:SYM_CODE_END(.Lcopy_user_handle_tail)
> > arch/x86/lib/getuser.S:SYM_CODE_START_LOCAL(.Lbad_get_user_clac)
> > arch/x86/lib/getuser.S:SYM_CODE_END(.Lbad_get_user_clac)
> > arch/x86/lib/getuser.S:SYM_CODE_START_LOCAL(.Lbad_get_user_8_clac)
> > arch/x86/lib/getuser.S:SYM_CODE_END(.Lbad_get_user_8_clac)
> > arch/x86/lib/putuser.S:SYM_CODE_START_LOCAL(.Lbad_put_user_clac)
> > arch/x86/lib/putuser.S:SYM_CODE_END(.Lbad_put_user_clac)
> > arch/x86/realmode/rm/wakeup_asm.S:SYM_DATA_START_LOCAL(.Lwakeup_idt)
> > arch/x86/realmode/rm/wakeup_asm.S:SYM_DATA_END(.Lwakeup_idt)
> 
> Josh, I assume objtool does not annotate code under:
> arch/x86/boot/
> arch/x86/entry/
> arch/x86/realmode/
> ?
> 
> The rest, ie
> arch/x86/lib/
> seem potentially relevant?

Both arch/x86/entry/* and arch/x86/lib/* are read by objtool and should
probably be fixed up.

-- 
Josh

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
  2021-01-20 18:43       ` [Linux-kernel-mentees] " Joe Perches
@ 2021-01-22 13:18         ` Aditya
  -1 siblings, 0 replies; 32+ messages in thread
From: Aditya @ 2021-01-22 13:18 UTC (permalink / raw)
  To: Joe Perches, linux-kernel
  Cc: lukas.bulwahn, dwaipayanray1, broonie, linux-kernel-mentees,
	clang-built-linux

On 21/1/21 12:13 am, Joe Perches wrote:
> On Wed, 2021-01-20 at 18:23 +0530, Aditya wrote:
>> On 20/1/21 2:51 pm, Joe Perches wrote:
>>> On Wed, 2021-01-20 at 12:55 +0530, Aditya Srivastava wrote:
>>>> Local symbols prefixed with '.L' do not emit symbol table entries, as
>>>> they have special meaning for the assembler.
>>>>
>>>> '.L' prefixed symbols can be used within a code region, but should be
>>>> avoided for denoting a range of code via 'SYM_*_START/END' annotations.
>>>>
>>>> Add a new check to emit a warning on finding the usage of '.L' symbols
>>>> in '.S' files, if it lies within SYM_*_START/END annotation pair.
>>>
>>> I believe this needs a test for $file as it won't work well on
>>> patches as the SYM_*_START/END may not be in the patch context.
>>>
>> Okay.
>>
>>> Also, is this supposed to work for local labels like '.L<foo>:'?
>>> I don't think a warning should be generated for those.
>>>
>> Yes, currently it will generate warning for all symbols which start
>> with .L and have non- white character symbol following it, if it is
>> lying within SYM_*_START/END annotation pair.
>>
>> Should I reduce the check to \.L_\S+ instead? (please note "_"
>> following ".L")
> 
> Use grep first.  That would still match several existing labels.
> 
>> Pardon me, I'm not good with assembly :/
> 
> Spending time reading docs can help with that.
> 
> Mark?  Can you please comment about the below?
> 
> I believe the test should be:
> 
> 	if ($realfile =~ /\.S$/ &&
> 	    $line =~ /^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {

Joe, with this regex, we won't be able to match
"jmp  .L_restore
SYM_FUNC_END(\name)"

which was replaced in this patch in the discussion:
https://groups.google.com/g/clang-built-linux/c/-drkmLgu-cU/m/phKe-Tb6CgAJ

Here, "jmp  .L_restore" was also replaced to fix the error.

However, if this
regex(/^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) is
correct, maybe we don't need to check for $file as we are now checking
for just one line.

What do you think?

Thanks
Aditya

> 		WARN(...);
> 	}
> 
> so that only this code currently matches:
> 
> $ git grep -P '^\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L' -- '*.S'
> arch/x86/boot/compressed/head_32.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
> arch/x86/boot/compressed/head_32.S:SYM_FUNC_END(.Lrelocated)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lrelocated)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lpaging_enabled)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lpaging_enabled)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lno_longmode)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lno_longmode)
> arch/x86/boot/pmjump.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lin_pm32)
> arch/x86/boot/pmjump.S:SYM_FUNC_END(.Lin_pm32)
> arch/x86/entry/entry_64.S:SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs)
> arch/x86/entry/entry_64.S:SYM_CODE_END(.Lbad_gs)
> arch/x86/lib/copy_user_64.S:SYM_CODE_START_LOCAL(.Lcopy_user_handle_tail)
> arch/x86/lib/copy_user_64.S:SYM_CODE_END(.Lcopy_user_handle_tail)
> arch/x86/lib/getuser.S:SYM_CODE_START_LOCAL(.Lbad_get_user_clac)
> arch/x86/lib/getuser.S:SYM_CODE_END(.Lbad_get_user_clac)
> arch/x86/lib/getuser.S:SYM_CODE_START_LOCAL(.Lbad_get_user_8_clac)
> arch/x86/lib/getuser.S:SYM_CODE_END(.Lbad_get_user_8_clac)
> arch/x86/lib/putuser.S:SYM_CODE_START_LOCAL(.Lbad_put_user_clac)
> arch/x86/lib/putuser.S:SYM_CODE_END(.Lbad_put_user_clac)
> arch/x86/realmode/rm/wakeup_asm.S:SYM_DATA_START_LOCAL(.Lwakeup_idt)
> arch/x86/realmode/rm/wakeup_asm.S:SYM_DATA_END(.Lwakeup_idt)
> 
> 


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
@ 2021-01-22 13:18         ` Aditya
  0 siblings, 0 replies; 32+ messages in thread
From: Aditya @ 2021-01-22 13:18 UTC (permalink / raw)
  To: Joe Perches, linux-kernel
  Cc: broonie, linux-kernel-mentees, clang-built-linux, dwaipayanray1

On 21/1/21 12:13 am, Joe Perches wrote:
> On Wed, 2021-01-20 at 18:23 +0530, Aditya wrote:
>> On 20/1/21 2:51 pm, Joe Perches wrote:
>>> On Wed, 2021-01-20 at 12:55 +0530, Aditya Srivastava wrote:
>>>> Local symbols prefixed with '.L' do not emit symbol table entries, as
>>>> they have special meaning for the assembler.
>>>>
>>>> '.L' prefixed symbols can be used within a code region, but should be
>>>> avoided for denoting a range of code via 'SYM_*_START/END' annotations.
>>>>
>>>> Add a new check to emit a warning on finding the usage of '.L' symbols
>>>> in '.S' files, if it lies within SYM_*_START/END annotation pair.
>>>
>>> I believe this needs a test for $file as it won't work well on
>>> patches as the SYM_*_START/END may not be in the patch context.
>>>
>> Okay.
>>
>>> Also, is this supposed to work for local labels like '.L<foo>:'?
>>> I don't think a warning should be generated for those.
>>>
>> Yes, currently it will generate warning for all symbols which start
>> with .L and have non- white character symbol following it, if it is
>> lying within SYM_*_START/END annotation pair.
>>
>> Should I reduce the check to \.L_\S+ instead? (please note "_"
>> following ".L")
> 
> Use grep first.  That would still match several existing labels.
> 
>> Pardon me, I'm not good with assembly :/
> 
> Spending time reading docs can help with that.
> 
> Mark?  Can you please comment about the below?
> 
> I believe the test should be:
> 
> 	if ($realfile =~ /\.S$/ &&
> 	    $line =~ /^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {

Joe, with this regex, we won't be able to match
"jmp  .L_restore
SYM_FUNC_END(\name)"

which was replaced in this patch in the discussion:
https://groups.google.com/g/clang-built-linux/c/-drkmLgu-cU/m/phKe-Tb6CgAJ

Here, "jmp  .L_restore" was also replaced to fix the error.

However, if this
regex(/^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) is
correct, maybe we don't need to check for $file as we are now checking
for just one line.

What do you think?

Thanks
Aditya

> 		WARN(...);
> 	}
> 
> so that only this code currently matches:
> 
> $ git grep -P '^\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L' -- '*.S'
> arch/x86/boot/compressed/head_32.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
> arch/x86/boot/compressed/head_32.S:SYM_FUNC_END(.Lrelocated)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lrelocated)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lpaging_enabled)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lpaging_enabled)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lno_longmode)
> arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lno_longmode)
> arch/x86/boot/pmjump.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lin_pm32)
> arch/x86/boot/pmjump.S:SYM_FUNC_END(.Lin_pm32)
> arch/x86/entry/entry_64.S:SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs)
> arch/x86/entry/entry_64.S:SYM_CODE_END(.Lbad_gs)
> arch/x86/lib/copy_user_64.S:SYM_CODE_START_LOCAL(.Lcopy_user_handle_tail)
> arch/x86/lib/copy_user_64.S:SYM_CODE_END(.Lcopy_user_handle_tail)
> arch/x86/lib/getuser.S:SYM_CODE_START_LOCAL(.Lbad_get_user_clac)
> arch/x86/lib/getuser.S:SYM_CODE_END(.Lbad_get_user_clac)
> arch/x86/lib/getuser.S:SYM_CODE_START_LOCAL(.Lbad_get_user_8_clac)
> arch/x86/lib/getuser.S:SYM_CODE_END(.Lbad_get_user_8_clac)
> arch/x86/lib/putuser.S:SYM_CODE_START_LOCAL(.Lbad_put_user_clac)
> arch/x86/lib/putuser.S:SYM_CODE_END(.Lbad_put_user_clac)
> arch/x86/realmode/rm/wakeup_asm.S:SYM_DATA_START_LOCAL(.Lwakeup_idt)
> arch/x86/realmode/rm/wakeup_asm.S:SYM_DATA_END(.Lwakeup_idt)
> 
> 

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
  2021-01-22 13:18         ` [Linux-kernel-mentees] " Aditya
@ 2021-01-22 19:10           ` Joe Perches
  -1 siblings, 0 replies; 32+ messages in thread
From: Joe Perches @ 2021-01-22 19:10 UTC (permalink / raw)
  To: Aditya, linux-kernel
  Cc: lukas.bulwahn, dwaipayanray1, broonie, linux-kernel-mentees,
	clang-built-linux

On Fri, 2021-01-22 at 18:48 +0530, Aditya wrote:
> On 21/1/21 12:13 am, Joe Perches wrote:
> > I believe the test should be:
> > 
> > 	if ($realfile =~ /\.S$/ &&
> > 	    $line =~ /^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
> 
> Joe, with this regex, we won't be able to match
> "jmp  .L_restore
> SYM_FUNC_END(\name)"

I think that's not an issue.

> which was replaced in this patch in the discussion:
> https://groups.google.com/g/clang-built-linux/c/-drkmLgu-cU/m/phKe-Tb6CgAJ
> 
> Here, "jmp  .L_restore" was also replaced to fix the error.

Notice that this line was also replaced in the same patch:

 #ifdef CONFIG_PREEMPTION
-SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
+SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore)


> However, if this
> regex(/^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) is
> correct, maybe we don't need to check for $file as we are now checking
> for just one line.
> 
> What do you think?

The test I wrote was complete, did not use $file and emits a
warning on the use of CODE_SYM_START_LOCAL_NOALIGN(.L_restore)

I think it's sufficient.


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
@ 2021-01-22 19:10           ` Joe Perches
  0 siblings, 0 replies; 32+ messages in thread
From: Joe Perches @ 2021-01-22 19:10 UTC (permalink / raw)
  To: Aditya, linux-kernel
  Cc: broonie, linux-kernel-mentees, clang-built-linux, dwaipayanray1

On Fri, 2021-01-22 at 18:48 +0530, Aditya wrote:
> On 21/1/21 12:13 am, Joe Perches wrote:
> > I believe the test should be:
> > 
> > 	if ($realfile =~ /\.S$/ &&
> > 	    $line =~ /^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
> 
> Joe, with this regex, we won't be able to match
> "jmp  .L_restore
> SYM_FUNC_END(\name)"

I think that's not an issue.

> which was replaced in this patch in the discussion:
> https://groups.google.com/g/clang-built-linux/c/-drkmLgu-cU/m/phKe-Tb6CgAJ
> 
> Here, "jmp  .L_restore" was also replaced to fix the error.

Notice that this line was also replaced in the same patch:

 #ifdef CONFIG_PREEMPTION
-SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
+SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore)


> However, if this
> regex(/^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) is
> correct, maybe we don't need to check for $file as we are now checking
> for just one line.
> 
> What do you think?

The test I wrote was complete, did not use $file and emits a
warning on the use of CODE_SYM_START_LOCAL_NOALIGN(.L_restore)

I think it's sufficient.

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
  2021-01-22 19:10           ` [Linux-kernel-mentees] " Joe Perches
@ 2021-01-22 20:13             ` Aditya
  -1 siblings, 0 replies; 32+ messages in thread
From: Aditya @ 2021-01-22 20:13 UTC (permalink / raw)
  To: Joe Perches, linux-kernel
  Cc: lukas.bulwahn, dwaipayanray1, broonie, linux-kernel-mentees,
	clang-built-linux

On 23/1/21 12:40 am, Joe Perches wrote:
> On Fri, 2021-01-22 at 18:48 +0530, Aditya wrote:
>> On 21/1/21 12:13 am, Joe Perches wrote:
>>> I believe the test should be:
>>>
>>> 	if ($realfile =~ /\.S$/ &&
>>> 	    $line =~ /^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
>>
>> Joe, with this regex, we won't be able to match
>> "jmp  .L_restore
>> SYM_FUNC_END(\name)"
> 
> I think that's not an issue.
> 
>> which was replaced in this patch in the discussion:
>> https://groups.google.com/g/clang-built-linux/c/-drkmLgu-cU/m/phKe-Tb6CgAJ
>>
>> Here, "jmp  .L_restore" was also replaced to fix the error.
> 
> Notice that this line was also replaced in the same patch:
> 
>  #ifdef CONFIG_PREEMPTION
> -SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
> +SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore)
> 
> 
>> However, if this
>> regex(/^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) is
>> correct, maybe we don't need to check for $file as we are now checking
>> for just one line.
>>
>> What do you think?
> 
> The test I wrote was complete, did not use $file and emits a
> warning on the use of CODE_SYM_START_LOCAL_NOALIGN(.L_restore)
> 
> I think it's sufficient.
> 

Okay, Thanks.. I will send the modified patch :)

Thanks
Aditya

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
@ 2021-01-22 20:13             ` Aditya
  0 siblings, 0 replies; 32+ messages in thread
From: Aditya @ 2021-01-22 20:13 UTC (permalink / raw)
  To: Joe Perches, linux-kernel
  Cc: broonie, linux-kernel-mentees, clang-built-linux, dwaipayanray1

On 23/1/21 12:40 am, Joe Perches wrote:
> On Fri, 2021-01-22 at 18:48 +0530, Aditya wrote:
>> On 21/1/21 12:13 am, Joe Perches wrote:
>>> I believe the test should be:
>>>
>>> 	if ($realfile =~ /\.S$/ &&
>>> 	    $line =~ /^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
>>
>> Joe, with this regex, we won't be able to match
>> "jmp  .L_restore
>> SYM_FUNC_END(\name)"
> 
> I think that's not an issue.
> 
>> which was replaced in this patch in the discussion:
>> https://groups.google.com/g/clang-built-linux/c/-drkmLgu-cU/m/phKe-Tb6CgAJ
>>
>> Here, "jmp  .L_restore" was also replaced to fix the error.
> 
> Notice that this line was also replaced in the same patch:
> 
>  #ifdef CONFIG_PREEMPTION
> -SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
> +SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore)
> 
> 
>> However, if this
>> regex(/^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) is
>> correct, maybe we don't need to check for $file as we are now checking
>> for just one line.
>>
>> What do you think?
> 
> The test I wrote was complete, did not use $file and emits a
> warning on the use of CODE_SYM_START_LOCAL_NOALIGN(.L_restore)
> 
> I think it's sufficient.
> 

Okay, Thanks.. I will send the modified patch :)

Thanks
Aditya
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
  2021-01-22 20:13             ` [Linux-kernel-mentees] " Aditya
@ 2021-01-22 20:36               ` Fāng-ruì Sòng via Linux-kernel-mentees
  -1 siblings, 0 replies; 32+ messages in thread
From: Fāng-ruì Sòng @ 2021-01-22 20:36 UTC (permalink / raw)
  To: Aditya
  Cc: Joe Perches, LKML, lukas.bulwahn, dwaipayanray1, Mark Brown,
	linux-kernel-mentees, clang-built-linux

On Fri, Jan 22, 2021 at 12:13 PM Aditya <yashsri421@gmail.com> wrote:
>
> On 23/1/21 12:40 am, Joe Perches wrote:
> > On Fri, 2021-01-22 at 18:48 +0530, Aditya wrote:
> >> On 21/1/21 12:13 am, Joe Perches wrote:
> >>> I believe the test should be:
> >>>
> >>>     if ($realfile =~ /\.S$/ &&
> >>>         $line =~ /^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
> >>
> >> Joe, with this regex, we won't be able to match
> >> "jmp  .L_restore
> >> SYM_FUNC_END(\name)"
> >
> > I think that's not an issue.
> >
> >> which was replaced in this patch in the discussion:
> >> https://groups.google.com/g/clang-built-linux/c/-drkmLgu-cU/m/phKe-Tb6CgAJ
> >>
> >> Here, "jmp  .L_restore" was also replaced to fix the error.
> >
> > Notice that this line was also replaced in the same patch:
> >
> >  #ifdef CONFIG_PREEMPTION
> > -SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
> > +SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore)
> >
> >
> >> However, if this
> >> regex(/^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) is
> >> correct, maybe we don't need to check for $file as we are now checking
> >> for just one line.
> >>
> >> What do you think?
> >
> > The test I wrote was complete, did not use $file and emits a
> > warning on the use of CODE_SYM_START_LOCAL_NOALIGN(.L_restore)
> >
> > I think it's sufficient.
> >
>
> Okay, Thanks.. I will send the modified patch :)
>
> Thanks
> Aditya

I am slightly concerned with the direction here.   jmp .Lsym is fine
and is probably preferable in cases where you absolutely want to emit
a local symbol.
(there is a related -z unique-symbol GNU ld+FGKASLR thing I shall
analyze in my spare time)

If the problem is just that STT_SECTION symbols are missing, can
objtool do something to conceptually synthesize them?

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files
@ 2021-01-22 20:36               ` Fāng-ruì Sòng via Linux-kernel-mentees
  0 siblings, 0 replies; 32+ messages in thread
From: Fāng-ruì Sòng via Linux-kernel-mentees @ 2021-01-22 20:36 UTC (permalink / raw)
  To: Aditya
  Cc: dwaipayanray1, LKML, clang-built-linux, Mark Brown, Joe Perches,
	linux-kernel-mentees

On Fri, Jan 22, 2021 at 12:13 PM Aditya <yashsri421@gmail.com> wrote:
>
> On 23/1/21 12:40 am, Joe Perches wrote:
> > On Fri, 2021-01-22 at 18:48 +0530, Aditya wrote:
> >> On 21/1/21 12:13 am, Joe Perches wrote:
> >>> I believe the test should be:
> >>>
> >>>     if ($realfile =~ /\.S$/ &&
> >>>         $line =~ /^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
> >>
> >> Joe, with this regex, we won't be able to match
> >> "jmp  .L_restore
> >> SYM_FUNC_END(\name)"
> >
> > I think that's not an issue.
> >
> >> which was replaced in this patch in the discussion:
> >> https://groups.google.com/g/clang-built-linux/c/-drkmLgu-cU/m/phKe-Tb6CgAJ
> >>
> >> Here, "jmp  .L_restore" was also replaced to fix the error.
> >
> > Notice that this line was also replaced in the same patch:
> >
> >  #ifdef CONFIG_PREEMPTION
> > -SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
> > +SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore)
> >
> >
> >> However, if this
> >> regex(/^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) is
> >> correct, maybe we don't need to check for $file as we are now checking
> >> for just one line.
> >>
> >> What do you think?
> >
> > The test I wrote was complete, did not use $file and emits a
> > warning on the use of CODE_SYM_START_LOCAL_NOALIGN(.L_restore)
> >
> > I think it's sufficient.
> >
>
> Okay, Thanks.. I will send the modified patch :)
>
> Thanks
> Aditya

I am slightly concerned with the direction here.   jmp .Lsym is fine
and is probably preferable in cases where you absolutely want to emit
a local symbol.
(there is a related -z unique-symbol GNU ld+FGKASLR thing I shall
analyze in my spare time)

If the problem is just that STT_SECTION symbols are missing, can
objtool do something to conceptually synthesize them?
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH v2] checkpatch: add warning for avoiding .L prefix symbols in assembly files
  2021-01-22 20:13             ` [Linux-kernel-mentees] " Aditya
@ 2021-01-23 15:14               ` Aditya Srivastava
  -1 siblings, 0 replies; 32+ messages in thread
From: Aditya Srivastava @ 2021-01-23 15:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: yashsri421, lukas.bulwahn, dwaipayanray1, broonie, joe,
	ndesaulniers, jpoimboe, linux-kernel-mentees, clang-built-linux

objtool requires that all code must be contained in an ELF symbol.
Symbol names that have a '.L' prefix do not emit symbol table entries, as
they have special meaning for the assembler.

'.L' prefixed symbols can be used within a code region, but should be
avoided for denoting a range of code via 'SYM_*_START/END' annotations.

Add a new check to emit a warning on finding the usage of '.L' symbols
for '.S' files in arch/x86/entry/* and arch/x86/lib/*, if it denotes
range of code via SYM_*_START/END annotation pair.

Suggested-by: Mark Brown <broonie@kernel.org>
Link: https://groups.google.com/g/clang-built-linux/c/-drkmLgu-cU/m/4staOlf-CgAJ
Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
---
* Applies perfectly on next-20210122

Changes in v2:
- Reduce the check to only SYM_*_START/END lines
- Reduce the check for only .S files in arch/x86/entry/* and arch/x86/lib/* as suggested by Josh and Nick
- Modify commit message

 scripts/checkpatch.pl | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7030c4d6d126..e36cdf96dfe3 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3590,6 +3590,13 @@ sub process {
 			}
 		}
 
+# check for .L prefix local symbols in .S files
+		if ($realfile =~ m@^arch/x86/(?:entry|lib)/.*\.S$@ &&
+		    $line =~ /^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
+			WARN("AVOID_L_PREFIX",
+			     "Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/asm-annotations.rst\n" . $herecurr);
+		}
+
 # check we are in a valid source file C or perl if not then ignore this hunk
 		next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Linux-kernel-mentees] [PATCH v2] checkpatch: add warning for avoiding .L prefix symbols in assembly files
@ 2021-01-23 15:14               ` Aditya Srivastava
  0 siblings, 0 replies; 32+ messages in thread
From: Aditya Srivastava @ 2021-01-23 15:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: yashsri421, dwaipayanray1, ndesaulniers, clang-built-linux,
	broonie, jpoimboe, joe, linux-kernel-mentees

objtool requires that all code must be contained in an ELF symbol.
Symbol names that have a '.L' prefix do not emit symbol table entries, as
they have special meaning for the assembler.

'.L' prefixed symbols can be used within a code region, but should be
avoided for denoting a range of code via 'SYM_*_START/END' annotations.

Add a new check to emit a warning on finding the usage of '.L' symbols
for '.S' files in arch/x86/entry/* and arch/x86/lib/*, if it denotes
range of code via SYM_*_START/END annotation pair.

Suggested-by: Mark Brown <broonie@kernel.org>
Link: https://groups.google.com/g/clang-built-linux/c/-drkmLgu-cU/m/4staOlf-CgAJ
Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
---
* Applies perfectly on next-20210122

Changes in v2:
- Reduce the check to only SYM_*_START/END lines
- Reduce the check for only .S files in arch/x86/entry/* and arch/x86/lib/* as suggested by Josh and Nick
- Modify commit message

 scripts/checkpatch.pl | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7030c4d6d126..e36cdf96dfe3 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3590,6 +3590,13 @@ sub process {
 			}
 		}
 
+# check for .L prefix local symbols in .S files
+		if ($realfile =~ m@^arch/x86/(?:entry|lib)/.*\.S$@ &&
+		    $line =~ /^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
+			WARN("AVOID_L_PREFIX",
+			     "Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/asm-annotations.rst\n" . $herecurr);
+		}
+
 # check we are in a valid source file C or perl if not then ignore this hunk
 		next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
 
-- 
2.17.1

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH v2] checkpatch: add warning for avoiding .L prefix symbols in assembly files
  2021-01-23 15:14               ` [Linux-kernel-mentees] " Aditya Srivastava
@ 2021-01-23 17:21                 ` Joe Perches
  -1 siblings, 0 replies; 32+ messages in thread
From: Joe Perches @ 2021-01-23 17:21 UTC (permalink / raw)
  To: Aditya Srivastava, linux-kernel
  Cc: lukas.bulwahn, dwaipayanray1, broonie, ndesaulniers, jpoimboe,
	linux-kernel-mentees, clang-built-linux

On Sat, 2021-01-23 at 20:44 +0530, Aditya Srivastava wrote:
> objtool requires that all code must be contained in an ELF symbol.
> Symbol names that have a '.L' prefix do not emit symbol table entries, as
> they have special meaning for the assembler.
> 
> '.L' prefixed symbols can be used within a code region, but should be
> avoided for denoting a range of code via 'SYM_*_START/END' annotations.
> 
> Add a new check to emit a warning on finding the usage of '.L' symbols
> for '.S' files in arch/x86/entry/* and arch/x86/lib/*, if it denotes
> range of code via SYM_*_START/END annotation pair.
> 
> Suggested-by: Mark Brown <broonie@kernel.org>
> Link: https://groups.google.com/g/clang-built-linux/c/-drkmLgu-cU/m/4staOlf-CgAJ

Please do not use groups.google.com links, or if you must, please
use links that are readable.

For instance, this is a better link as it shows the context without
struggling with the poor interface:

https://groups.google.com/g/clang-built-linux/c/E-naBMt_1SM

> Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
> ---
> * Applies perfectly on next-20210122
> 
> Changes in v2:
> - Reduce the check to only SYM_*_START/END lines
> - Reduce the check for only .S files in arch/x86/entry/* and arch/x86/lib/* as suggested by Josh and Nick

I think that's unnecessary.

> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -3590,6 +3590,13 @@ sub process {
>  			}
>  		}
>  
> 
> +# check for .L prefix local symbols in .S files
> +		if ($realfile =~ m@^arch/x86/(?:entry|lib)/.*\.S$@ &&

Using /.S$/ should be enough

> +		    $line =~ /^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {

This might need to be

+		    $line =~ /^\+\s*(?:[A-Z]+_)?SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {

> +			WARN("AVOID_L_PREFIX",
> +			     "Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/asm-annotations.rst\n" . $herecurr);
> +		}
> +



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH v2] checkpatch: add warning for avoiding .L prefix symbols in assembly files
@ 2021-01-23 17:21                 ` Joe Perches
  0 siblings, 0 replies; 32+ messages in thread
From: Joe Perches @ 2021-01-23 17:21 UTC (permalink / raw)
  To: Aditya Srivastava, linux-kernel
  Cc: dwaipayanray1, ndesaulniers, clang-built-linux, broonie,
	jpoimboe, linux-kernel-mentees

On Sat, 2021-01-23 at 20:44 +0530, Aditya Srivastava wrote:
> objtool requires that all code must be contained in an ELF symbol.
> Symbol names that have a '.L' prefix do not emit symbol table entries, as
> they have special meaning for the assembler.
> 
> '.L' prefixed symbols can be used within a code region, but should be
> avoided for denoting a range of code via 'SYM_*_START/END' annotations.
> 
> Add a new check to emit a warning on finding the usage of '.L' symbols
> for '.S' files in arch/x86/entry/* and arch/x86/lib/*, if it denotes
> range of code via SYM_*_START/END annotation pair.
> 
> Suggested-by: Mark Brown <broonie@kernel.org>
> Link: https://groups.google.com/g/clang-built-linux/c/-drkmLgu-cU/m/4staOlf-CgAJ

Please do not use groups.google.com links, or if you must, please
use links that are readable.

For instance, this is a better link as it shows the context without
struggling with the poor interface:

https://groups.google.com/g/clang-built-linux/c/E-naBMt_1SM

> Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
> ---
> * Applies perfectly on next-20210122
> 
> Changes in v2:
> - Reduce the check to only SYM_*_START/END lines
> - Reduce the check for only .S files in arch/x86/entry/* and arch/x86/lib/* as suggested by Josh and Nick

I think that's unnecessary.

> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -3590,6 +3590,13 @@ sub process {
>  			}
>  		}
>  
> 
> +# check for .L prefix local symbols in .S files
> +		if ($realfile =~ m@^arch/x86/(?:entry|lib)/.*\.S$@ &&

Using /.S$/ should be enough

> +		    $line =~ /^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {

This might need to be

+		    $line =~ /^\+\s*(?:[A-Z]+_)?SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {

> +			WARN("AVOID_L_PREFIX",
> +			     "Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/asm-annotations.rst\n" . $herecurr);
> +		}
> +


_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH v2] checkpatch: add warning for avoiding .L prefix symbols in assembly files
  2021-01-23 17:21                 ` [Linux-kernel-mentees] " Joe Perches
@ 2021-01-23 18:23                   ` Aditya
  -1 siblings, 0 replies; 32+ messages in thread
From: Aditya @ 2021-01-23 18:23 UTC (permalink / raw)
  To: Joe Perches, linux-kernel
  Cc: lukas.bulwahn, dwaipayanray1, broonie, ndesaulniers, jpoimboe,
	linux-kernel-mentees, clang-built-linux

On 23/1/21 10:51 pm, Joe Perches wrote:
> On Sat, 2021-01-23 at 20:44 +0530, Aditya Srivastava wrote:
>> objtool requires that all code must be contained in an ELF symbol.
>> Symbol names that have a '.L' prefix do not emit symbol table entries, as
>> they have special meaning for the assembler.
>>
>> '.L' prefixed symbols can be used within a code region, but should be
>> avoided for denoting a range of code via 'SYM_*_START/END' annotations.
>>
>> Add a new check to emit a warning on finding the usage of '.L' symbols
>> for '.S' files in arch/x86/entry/* and arch/x86/lib/*, if it denotes
>> range of code via SYM_*_START/END annotation pair.
>>
>> Suggested-by: Mark Brown <broonie@kernel.org>
>> Link: https://groups.google.com/g/clang-built-linux/c/-drkmLgu-cU/m/4staOlf-CgAJ
> 
> Please do not use groups.google.com links, or if you must, please
> use links that are readable.
> 
> For instance, this is a better link as it shows the context without
> struggling with the poor interface:
> 
> https://groups.google.com/g/clang-built-linux/c/E-naBMt_1SM
> 

Okay, Got it.. I'll use lkml link for the best.

>> Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
>> ---
>> * Applies perfectly on next-20210122
>>
>> Changes in v2:
>> - Reduce the check to only SYM_*_START/END lines
>> - Reduce the check for only .S files in arch/x86/entry/* and arch/x86/lib/* as suggested by Josh and Nick
> 
> I think that's unnecessary.
> 
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
>> @@ -3590,6 +3590,13 @@ sub process {
>>  			}
>>  		}
>>  
>>
>> +# check for .L prefix local symbols in .S files
>> +		if ($realfile =~ m@^arch/x86/(?:entry|lib)/.*\.S$@ &&
> 
> Using /.S$/ should be enough
> 
>> +		    $line =~ /^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
> 
> This might need to be
> 
> +		    $line =~ /^\+\s*(?:[A-Z]+_)?SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
> 

Okay.. Thanks. I'll modify the patch accordingly.

Thanks
Aditya
>> +			WARN("AVOID_L_PREFIX",
>> +			     "Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/asm-annotations.rst\n" . $herecurr);
>> +		}
>> +
> 
> 


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH v2] checkpatch: add warning for avoiding .L prefix symbols in assembly files
@ 2021-01-23 18:23                   ` Aditya
  0 siblings, 0 replies; 32+ messages in thread
From: Aditya @ 2021-01-23 18:23 UTC (permalink / raw)
  To: Joe Perches, linux-kernel
  Cc: dwaipayanray1, ndesaulniers, clang-built-linux, broonie,
	jpoimboe, linux-kernel-mentees

On 23/1/21 10:51 pm, Joe Perches wrote:
> On Sat, 2021-01-23 at 20:44 +0530, Aditya Srivastava wrote:
>> objtool requires that all code must be contained in an ELF symbol.
>> Symbol names that have a '.L' prefix do not emit symbol table entries, as
>> they have special meaning for the assembler.
>>
>> '.L' prefixed symbols can be used within a code region, but should be
>> avoided for denoting a range of code via 'SYM_*_START/END' annotations.
>>
>> Add a new check to emit a warning on finding the usage of '.L' symbols
>> for '.S' files in arch/x86/entry/* and arch/x86/lib/*, if it denotes
>> range of code via SYM_*_START/END annotation pair.
>>
>> Suggested-by: Mark Brown <broonie@kernel.org>
>> Link: https://groups.google.com/g/clang-built-linux/c/-drkmLgu-cU/m/4staOlf-CgAJ
> 
> Please do not use groups.google.com links, or if you must, please
> use links that are readable.
> 
> For instance, this is a better link as it shows the context without
> struggling with the poor interface:
> 
> https://groups.google.com/g/clang-built-linux/c/E-naBMt_1SM
> 

Okay, Got it.. I'll use lkml link for the best.

>> Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
>> ---
>> * Applies perfectly on next-20210122
>>
>> Changes in v2:
>> - Reduce the check to only SYM_*_START/END lines
>> - Reduce the check for only .S files in arch/x86/entry/* and arch/x86/lib/* as suggested by Josh and Nick
> 
> I think that's unnecessary.
> 
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
>> @@ -3590,6 +3590,13 @@ sub process {
>>  			}
>>  		}
>>  
>>
>> +# check for .L prefix local symbols in .S files
>> +		if ($realfile =~ m@^arch/x86/(?:entry|lib)/.*\.S$@ &&
> 
> Using /.S$/ should be enough
> 
>> +		    $line =~ /^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
> 
> This might need to be
> 
> +		    $line =~ /^\+\s*(?:[A-Z]+_)?SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
> 

Okay.. Thanks. I'll modify the patch accordingly.

Thanks
Aditya
>> +			WARN("AVOID_L_PREFIX",
>> +			     "Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/asm-annotations.rst\n" . $herecurr);
>> +		}
>> +
> 
> 

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH v3] checkpatch: add warning for avoiding .L prefix symbols in assembly files
  2021-01-23 18:23                   ` [Linux-kernel-mentees] " Aditya
@ 2021-01-23 19:04                     ` Aditya Srivastava
  -1 siblings, 0 replies; 32+ messages in thread
From: Aditya Srivastava @ 2021-01-23 19:04 UTC (permalink / raw)
  To: joe
  Cc: yashsri421, lukas.bulwahn, dwaipayanray1, broonie, ndesaulniers,
	jpoimboe, linux-kernel-mentees, clang-built-linux, linux-kernel

objtool requires that all code must be contained in an ELF symbol.
Symbol names that have a '.L' prefix do not emit symbol table entries, as
they have special meaning for the assembler.

'.L' prefixed symbols can be used within a code region, but should be
avoided for denoting a range of code via 'SYM_*_START/END' annotations.

Add a new check to emit a warning on finding the usage of '.L' symbols
for '.S' files, if it denotes range of code via SYM_*_START/END
annotation pair.

Suggested-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/lkml/20210112210154.GI4646@sirena.org.uk
Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
---
* Applies perfectly on next-20210122

Changes in v3:
- Modify regex for SYM_*_START/END pair
- remove check for arch/x86/entry/* and arch/x86/lib/*
- change 'Link:' in commit message to lkml
- Modify commit description accordingly

Changes in v2:
- Reduce the check to only SYM_*_START/END lines
- Reduce the check for only .S files in arch/x86/entry/* and arch/x86/lib/* as suggested by Josh and Nick
- Modify commit message

 scripts/checkpatch.pl | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7030c4d6d126..4a03326c87b6 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3590,6 +3590,13 @@ sub process {
 			}
 		}
 
+# check for .L prefix local symbols in .S files
+		if ($realfile =~ /\.S$/ &&
+		    $line =~ /^\+\s*(?:[A-Z]+_)?SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
+			WARN("AVOID_L_PREFIX",
+			     "Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/asm-annotations.rst\n" . $herecurr);
+		}
+
 # check we are in a valid source file C or perl if not then ignore this hunk
 		next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Linux-kernel-mentees] [PATCH v3] checkpatch: add warning for avoiding .L prefix symbols in assembly files
@ 2021-01-23 19:04                     ` Aditya Srivastava
  0 siblings, 0 replies; 32+ messages in thread
From: Aditya Srivastava @ 2021-01-23 19:04 UTC (permalink / raw)
  To: joe
  Cc: yashsri421, dwaipayanray1, ndesaulniers, linux-kernel,
	clang-built-linux, broonie, jpoimboe, linux-kernel-mentees

objtool requires that all code must be contained in an ELF symbol.
Symbol names that have a '.L' prefix do not emit symbol table entries, as
they have special meaning for the assembler.

'.L' prefixed symbols can be used within a code region, but should be
avoided for denoting a range of code via 'SYM_*_START/END' annotations.

Add a new check to emit a warning on finding the usage of '.L' symbols
for '.S' files, if it denotes range of code via SYM_*_START/END
annotation pair.

Suggested-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/lkml/20210112210154.GI4646@sirena.org.uk
Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
---
* Applies perfectly on next-20210122

Changes in v3:
- Modify regex for SYM_*_START/END pair
- remove check for arch/x86/entry/* and arch/x86/lib/*
- change 'Link:' in commit message to lkml
- Modify commit description accordingly

Changes in v2:
- Reduce the check to only SYM_*_START/END lines
- Reduce the check for only .S files in arch/x86/entry/* and arch/x86/lib/* as suggested by Josh and Nick
- Modify commit message

 scripts/checkpatch.pl | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7030c4d6d126..4a03326c87b6 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3590,6 +3590,13 @@ sub process {
 			}
 		}
 
+# check for .L prefix local symbols in .S files
+		if ($realfile =~ /\.S$/ &&
+		    $line =~ /^\+\s*(?:[A-Z]+_)?SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
+			WARN("AVOID_L_PREFIX",
+			     "Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/asm-annotations.rst\n" . $herecurr);
+		}
+
 # check we are in a valid source file C or perl if not then ignore this hunk
 		next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
 
-- 
2.17.1

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH v3] checkpatch: add warning for avoiding .L prefix symbols in assembly files
  2021-01-23 19:04                     ` [Linux-kernel-mentees] " Aditya Srivastava
@ 2021-01-23 21:01                       ` Joe Perches
  -1 siblings, 0 replies; 32+ messages in thread
From: Joe Perches @ 2021-01-23 21:01 UTC (permalink / raw)
  To: Aditya Srivastava, Andrew Morton
  Cc: lukas.bulwahn, dwaipayanray1, broonie, ndesaulniers, jpoimboe,
	linux-kernel-mentees, clang-built-linux, linux-kernel

On Sun, 2021-01-24 at 00:34 +0530, Aditya Srivastava wrote:
> objtool requires that all code must be contained in an ELF symbol.
> Symbol names that have a '.L' prefix do not emit symbol table entries, as
> they have special meaning for the assembler.
> 
> '.L' prefixed symbols can be used within a code region, but should be
> avoided for denoting a range of code via 'SYM_*_START/END' annotations.
> 
> Add a new check to emit a warning on finding the usage of '.L' symbols
> for '.S' files, if it denotes range of code via SYM_*_START/END
> annotation pair.
> 
> Suggested-by: Mark Brown <broonie@kernel.org>
> Link: https://lore.kernel.org/lkml/20210112210154.GI4646@sirena.org.uk
> Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>

Acked-by: Joe Perches <joe@perches.com>

> ---
> * Applies perfectly on next-20210122
> 
> Changes in v3:
> - Modify regex for SYM_*_START/END pair
> - remove check for arch/x86/entry/* and arch/x86/lib/*
> - change 'Link:' in commit message to lkml
> - Modify commit description accordingly
> 
> Changes in v2:
> - Reduce the check to only SYM_*_START/END lines
> - Reduce the check for only .S files in arch/x86/entry/* and arch/x86/lib/* as suggested by Josh and Nick
> - Modify commit message
> 
>  scripts/checkpatch.pl | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 7030c4d6d126..4a03326c87b6 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3590,6 +3590,13 @@ sub process {
>  			}
>  		}
>  
> 
> +# check for .L prefix local symbols in .S files
> +		if ($realfile =~ /\.S$/ &&
> +		    $line =~ /^\+\s*(?:[A-Z]+_)?SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
> +			WARN("AVOID_L_PREFIX",
> +			     "Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/asm-annotations.rst\n" . $herecurr);
> +		}
> +
>  # check we are in a valid source file C or perl if not then ignore this hunk
>  		next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
>  
> 



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH v3] checkpatch: add warning for avoiding .L prefix symbols in assembly files
@ 2021-01-23 21:01                       ` Joe Perches
  0 siblings, 0 replies; 32+ messages in thread
From: Joe Perches @ 2021-01-23 21:01 UTC (permalink / raw)
  To: Aditya Srivastava, Andrew Morton
  Cc: dwaipayanray1, ndesaulniers, linux-kernel, clang-built-linux,
	broonie, jpoimboe, linux-kernel-mentees

On Sun, 2021-01-24 at 00:34 +0530, Aditya Srivastava wrote:
> objtool requires that all code must be contained in an ELF symbol.
> Symbol names that have a '.L' prefix do not emit symbol table entries, as
> they have special meaning for the assembler.
> 
> '.L' prefixed symbols can be used within a code region, but should be
> avoided for denoting a range of code via 'SYM_*_START/END' annotations.
> 
> Add a new check to emit a warning on finding the usage of '.L' symbols
> for '.S' files, if it denotes range of code via SYM_*_START/END
> annotation pair.
> 
> Suggested-by: Mark Brown <broonie@kernel.org>
> Link: https://lore.kernel.org/lkml/20210112210154.GI4646@sirena.org.uk
> Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>

Acked-by: Joe Perches <joe@perches.com>

> ---
> * Applies perfectly on next-20210122
> 
> Changes in v3:
> - Modify regex for SYM_*_START/END pair
> - remove check for arch/x86/entry/* and arch/x86/lib/*
> - change 'Link:' in commit message to lkml
> - Modify commit description accordingly
> 
> Changes in v2:
> - Reduce the check to only SYM_*_START/END lines
> - Reduce the check for only .S files in arch/x86/entry/* and arch/x86/lib/* as suggested by Josh and Nick
> - Modify commit message
> 
>  scripts/checkpatch.pl | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 7030c4d6d126..4a03326c87b6 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3590,6 +3590,13 @@ sub process {
>  			}
>  		}
>  
> 
> +# check for .L prefix local symbols in .S files
> +		if ($realfile =~ /\.S$/ &&
> +		    $line =~ /^\+\s*(?:[A-Z]+_)?SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
> +			WARN("AVOID_L_PREFIX",
> +			     "Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/asm-annotations.rst\n" . $herecurr);
> +		}
> +
>  # check we are in a valid source file C or perl if not then ignore this hunk
>  		next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
>  
> 


_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH v3] checkpatch: add warning for avoiding .L prefix symbols in assembly files
  2021-01-23 21:01                       ` [Linux-kernel-mentees] " Joe Perches
@ 2021-01-25 18:15                         ` Nick Desaulniers via Linux-kernel-mentees
  -1 siblings, 0 replies; 32+ messages in thread
From: Nick Desaulniers @ 2021-01-25 18:15 UTC (permalink / raw)
  To: Joe Perches
  Cc: Aditya Srivastava, Andrew Morton, Lukas Bulwahn, dwaipayanray1,
	Mark Brown, Josh Poimboeuf, linux-kernel-mentees,
	clang-built-linux, LKML

On Sat, Jan 23, 2021 at 1:01 PM Joe Perches <joe@perches.com> wrote:
>
> On Sun, 2021-01-24 at 00:34 +0530, Aditya Srivastava wrote:
> > objtool requires that all code must be contained in an ELF symbol.
> > Symbol names that have a '.L' prefix do not emit symbol table entries, as
> > they have special meaning for the assembler.
> >
> > '.L' prefixed symbols can be used within a code region, but should be
> > avoided for denoting a range of code via 'SYM_*_START/END' annotations.
> >
> > Add a new check to emit a warning on finding the usage of '.L' symbols
> > for '.S' files, if it denotes range of code via SYM_*_START/END
> > annotation pair.
> >
> > Suggested-by: Mark Brown <broonie@kernel.org>
> > Link: https://lore.kernel.org/lkml/20210112210154.GI4646@sirena.org.uk
> > Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
>
> Acked-by: Joe Perches <joe@perches.com>

Acked-by: Nick Desaulniers <ndesaulniers@google.com>

Thanks for the patch Aditya!

>
> > ---
> > * Applies perfectly on next-20210122
> >
> > Changes in v3:
> > - Modify regex for SYM_*_START/END pair
> > - remove check for arch/x86/entry/* and arch/x86/lib/*
> > - change 'Link:' in commit message to lkml
> > - Modify commit description accordingly
> >
> > Changes in v2:
> > - Reduce the check to only SYM_*_START/END lines
> > - Reduce the check for only .S files in arch/x86/entry/* and arch/x86/lib/* as suggested by Josh and Nick
> > - Modify commit message
> >
> >  scripts/checkpatch.pl | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > index 7030c4d6d126..4a03326c87b6 100755
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -3590,6 +3590,13 @@ sub process {
> >                       }
> >               }
> >
> >
> > +# check for .L prefix local symbols in .S files
> > +             if ($realfile =~ /\.S$/ &&
> > +                 $line =~ /^\+\s*(?:[A-Z]+_)?SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
> > +                     WARN("AVOID_L_PREFIX",
> > +                          "Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/asm-annotations.rst\n" . $herecurr);
> > +             }
> > +
> >  # check we are in a valid source file C or perl if not then ignore this hunk
> >               next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
> >
> >
>
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH v3] checkpatch: add warning for avoiding .L prefix symbols in assembly files
@ 2021-01-25 18:15                         ` Nick Desaulniers via Linux-kernel-mentees
  0 siblings, 0 replies; 32+ messages in thread
From: Nick Desaulniers via Linux-kernel-mentees @ 2021-01-25 18:15 UTC (permalink / raw)
  To: Joe Perches
  Cc: Aditya Srivastava, dwaipayanray1, LKML, clang-built-linux,
	Mark Brown, Josh Poimboeuf, Andrew Morton, linux-kernel-mentees

On Sat, Jan 23, 2021 at 1:01 PM Joe Perches <joe@perches.com> wrote:
>
> On Sun, 2021-01-24 at 00:34 +0530, Aditya Srivastava wrote:
> > objtool requires that all code must be contained in an ELF symbol.
> > Symbol names that have a '.L' prefix do not emit symbol table entries, as
> > they have special meaning for the assembler.
> >
> > '.L' prefixed symbols can be used within a code region, but should be
> > avoided for denoting a range of code via 'SYM_*_START/END' annotations.
> >
> > Add a new check to emit a warning on finding the usage of '.L' symbols
> > for '.S' files, if it denotes range of code via SYM_*_START/END
> > annotation pair.
> >
> > Suggested-by: Mark Brown <broonie@kernel.org>
> > Link: https://lore.kernel.org/lkml/20210112210154.GI4646@sirena.org.uk
> > Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
>
> Acked-by: Joe Perches <joe@perches.com>

Acked-by: Nick Desaulniers <ndesaulniers@google.com>

Thanks for the patch Aditya!

>
> > ---
> > * Applies perfectly on next-20210122
> >
> > Changes in v3:
> > - Modify regex for SYM_*_START/END pair
> > - remove check for arch/x86/entry/* and arch/x86/lib/*
> > - change 'Link:' in commit message to lkml
> > - Modify commit description accordingly
> >
> > Changes in v2:
> > - Reduce the check to only SYM_*_START/END lines
> > - Reduce the check for only .S files in arch/x86/entry/* and arch/x86/lib/* as suggested by Josh and Nick
> > - Modify commit message
> >
> >  scripts/checkpatch.pl | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > index 7030c4d6d126..4a03326c87b6 100755
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -3590,6 +3590,13 @@ sub process {
> >                       }
> >               }
> >
> >
> > +# check for .L prefix local symbols in .S files
> > +             if ($realfile =~ /\.S$/ &&
> > +                 $line =~ /^\+\s*(?:[A-Z]+_)?SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
> > +                     WARN("AVOID_L_PREFIX",
> > +                          "Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/asm-annotations.rst\n" . $herecurr);
> > +             }
> > +
> >  # check we are in a valid source file C or perl if not then ignore this hunk
> >               next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
> >
> >
>
>


-- 
Thanks,
~Nick Desaulniers
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2021-01-25 18:22 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20  7:25 [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files Aditya Srivastava
2021-01-20  7:25 ` [Linux-kernel-mentees] " Aditya Srivastava
2021-01-20  9:21 ` Joe Perches
2021-01-20  9:21   ` [Linux-kernel-mentees] " Joe Perches
2021-01-20 12:53   ` Aditya
2021-01-20 12:53     ` [Linux-kernel-mentees] " Aditya
2021-01-20 18:43     ` Joe Perches
2021-01-20 18:43       ` [Linux-kernel-mentees] " Joe Perches
2021-01-20 18:57       ` Nick Desaulniers
2021-01-20 18:57         ` [Linux-kernel-mentees] " Nick Desaulniers via Linux-kernel-mentees
2021-01-20 22:59         ` Josh Poimboeuf
2021-01-20 22:59           ` [Linux-kernel-mentees] " Josh Poimboeuf
2021-01-22 13:18       ` Aditya
2021-01-22 13:18         ` [Linux-kernel-mentees] " Aditya
2021-01-22 19:10         ` Joe Perches
2021-01-22 19:10           ` [Linux-kernel-mentees] " Joe Perches
2021-01-22 20:13           ` Aditya
2021-01-22 20:13             ` [Linux-kernel-mentees] " Aditya
2021-01-22 20:36             ` Fāng-ruì Sòng
2021-01-22 20:36               ` [Linux-kernel-mentees] " Fāng-ruì Sòng via Linux-kernel-mentees
2021-01-23 15:14             ` [PATCH v2] " Aditya Srivastava
2021-01-23 15:14               ` [Linux-kernel-mentees] " Aditya Srivastava
2021-01-23 17:21               ` Joe Perches
2021-01-23 17:21                 ` [Linux-kernel-mentees] " Joe Perches
2021-01-23 18:23                 ` Aditya
2021-01-23 18:23                   ` [Linux-kernel-mentees] " Aditya
2021-01-23 19:04                   ` [PATCH v3] " Aditya Srivastava
2021-01-23 19:04                     ` [Linux-kernel-mentees] " Aditya Srivastava
2021-01-23 21:01                     ` Joe Perches
2021-01-23 21:01                       ` [Linux-kernel-mentees] " Joe Perches
2021-01-25 18:15                       ` Nick Desaulniers
2021-01-25 18:15                         ` [Linux-kernel-mentees] " Nick Desaulniers via Linux-kernel-mentees

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.