mbox series

[v4,0/7] selftests/x86: fix build errors and warnings found via clang

Message ID 20240704072431.111640-1-jhubbard@nvidia.com (mailing list archive)
Headers show
Series selftests/x86: fix build errors and warnings found via clang | expand

Message

John Hubbard July 4, 2024, 7:24 a.m. UTC
Changes since v3:

1) Rebased onto Linux 6.10-rc6+.

2) Added Muhammad's acks for the series.

Cover letter for v3:

Hi,

Dave Hansen, Muhammad Usama Anjum, here is the combined series that we
discussed yesterday [1].

As I mentioned then, this is a bit intrusive--but no more than
necessary, IMHO. Specifically, it moves some clang-un-inlineable things
out to "pure" assembly code files.

I've tested this by building with clang, then running each binary on my
x86_64 test system with today's 6.10-rc1, and comparing the console and
dmesg output to a gcc-based build without these patches applied. Aside
from timestamps and virtual addresses, it looks identical.

Earlier cover letter:

Just a bunch of build and warnings fixes that show up when building with
clang. Some of these depend on each other, so I'm sending them as a
series.

Changes since v2:

1) Dropped my test_FISTTP.c patch, and picked up Muhammad's fix instead,
   seeing as how that was posted first.

2) Updated patch descriptions to reflect that Valentin Obst's build fix
   for LLVM [1] has already been merged into Linux main.

3) Minor wording and typo corrections in the commit logs throughout.

Changes since the first version:
1) Rebased onto Linux 6.10-rc1

Enjoy!

[1] https://lore.kernel.org/44428518-4d21-4de7-8587-04eceefb330d@nvidia.com

thanks,
John Hubbard

John Hubbard (6):
  selftests/x86: fix Makefile dependencies to work with clang
  selftests/x86: build fsgsbase_restore.c with clang
  selftests/x86: build sysret_rip.c with clang
  selftests/x86: avoid -no-pie warnings from clang during compilation
  selftests/x86: remove (or use) unused variables and functions
  selftests/x86: fix printk warnings reported by clang

Muhammad Usama Anjum (1):
  selftests: x86: test_FISTTP: use fisttps instead of ambiguous fisttp

 tools/testing/selftests/x86/Makefile          | 31 +++++++++++++++----
 tools/testing/selftests/x86/amx.c             | 16 ----------
 .../testing/selftests/x86/clang_helpers_32.S  | 11 +++++++
 .../testing/selftests/x86/clang_helpers_64.S  | 28 +++++++++++++++++
 tools/testing/selftests/x86/fsgsbase.c        |  6 ----
 .../testing/selftests/x86/fsgsbase_restore.c  | 11 +++----
 tools/testing/selftests/x86/sigreturn.c       |  2 +-
 .../testing/selftests/x86/syscall_arg_fault.c |  1 -
 tools/testing/selftests/x86/sysret_rip.c      | 20 ++++--------
 tools/testing/selftests/x86/test_FISTTP.c     |  8 ++---
 tools/testing/selftests/x86/test_vsyscall.c   | 15 +++------
 tools/testing/selftests/x86/vdso_restorer.c   |  2 ++
 12 files changed, 87 insertions(+), 64 deletions(-)
 create mode 100644 tools/testing/selftests/x86/clang_helpers_32.S
 create mode 100644 tools/testing/selftests/x86/clang_helpers_64.S


base-commit: 795c58e4c7fc6163d8fb9f2baa86cfe898fa4b19

Comments

Shuah Khan July 9, 2024, 8:34 p.m. UTC | #1
On 7/4/24 01:24, John Hubbard wrote:
> Changes since v3:
> 
> 1) Rebased onto Linux 6.10-rc6+.
> 
> 2) Added Muhammad's acks for the series.
> 
> Cover letter for v3:
> 
> Hi,
> 
> Dave Hansen, Muhammad Usama Anjum, here is the combined series that we
> discussed yesterday [1].
> 
> As I mentioned then, this is a bit intrusive--but no more than
> necessary, IMHO. Specifically, it moves some clang-un-inlineable things
> out to "pure" assembly code files.
> 
> I've tested this by building with clang, then running each binary on my
> x86_64 test system with today's 6.10-rc1, and comparing the console and
> dmesg output to a gcc-based build without these patches applied. Aside
> from timestamps and virtual addresses, it looks identical.
> 
> Earlier cover letter:
> 
> Just a bunch of build and warnings fixes that show up when building with
> clang. Some of these depend on each other, so I'm sending them as a
> series.
> 
> Changes since v2:
> 
> 1) Dropped my test_FISTTP.c patch, and picked up Muhammad's fix instead,
>     seeing as how that was posted first.
> 
> 2) Updated patch descriptions to reflect that Valentin Obst's build fix
>     for LLVM [1] has already been merged into Linux main.
> 
> 3) Minor wording and typo corrections in the commit logs throughout.
> 
> Changes since the first version:
> 1) Rebased onto Linux 6.10-rc1
> 
> Enjoy!
> 
> [1] https://lore.kernel.org/44428518-4d21-4de7-8587-04eceefb330d@nvidia.com
> 
> thanks,
> John Hubbard
> 
> John Hubbard (6):
>    selftests/x86: fix Makefile dependencies to work with clang
>    selftests/x86: build fsgsbase_restore.c with clang
>    selftests/x86: build sysret_rip.c with clang
>    selftests/x86: avoid -no-pie warnings from clang during compilation
>    selftests/x86: remove (or use) unused variables and functions
>    selftests/x86: fix printk warnings reported by clang
> 

> Muhammad Usama Anjum (1):
>    selftests: x86: test_FISTTP: use fisttps instead of ambiguous fisttp


Usama and John,

I am seeing checkpatch warnings in this series.

v4-3-7
WARNING: externs should be avoided in .c files
#210: FILE: tools/testing/selftests/x86/fsgsbase_restore.c:46:
+unsigned int dereference_seg_base(void);

ARNING: Consecutive strings are generally better as a single string
#156: FILE: tools/testing/selftests/x86/test_FISTTP.c:28:
+	"	fisttps	res16""\n"

WARNING: Consecutive strings are generally better as a single string
#165: FILE: tools/testing/selftests/x86/test_FISTTP.c:48:
+	"	fisttps	res16""\n"

WARNING: Consecutive strings are generally better as a single string
#174: FILE: tools/testing/selftests/x86/test_FISTTP.c:69:
+	"	fisttps	res16""\n"

WARNING: Consecutive strings are generally better as a single string
#183: FILE: tools/testing/selftests/x86/test_FISTTP.c:91:
+	"	fisttps	res16""\n"

total: 0 errors, 5 warnings, 32 lines checked

Can you take a look at these and see if they can be fixed. Send me
v5 with these fixed - I will pull these in for 6.11-rc1

thanks,
-- Shuah
John Hubbard July 9, 2024, 8:40 p.m. UTC | #2
On 7/9/24 1:34 PM, Shuah Khan wrote:
> On 7/4/24 01:24, John Hubbard wrote:
...>> Muhammad Usama Anjum (1):
>>    selftests: x86: test_FISTTP: use fisttps instead of ambiguous fisttp
> 
> 
> Usama and John,
> 
> I am seeing checkpatch warnings in this series.
> 
> v4-3-7
> WARNING: externs should be avoided in .c files
> #210: FILE: tools/testing/selftests/x86/fsgsbase_restore.c:46:
> +unsigned int dereference_seg_base(void);
> 
> ARNING: Consecutive strings are generally better as a single string
> #156: FILE: tools/testing/selftests/x86/test_FISTTP.c:28:
> +    "    fisttps    res16""\n"
> 
> WARNING: Consecutive strings are generally better as a single string
> #165: FILE: tools/testing/selftests/x86/test_FISTTP.c:48:
> +    "    fisttps    res16""\n"
> 
> WARNING: Consecutive strings are generally better as a single string
> #174: FILE: tools/testing/selftests/x86/test_FISTTP.c:69:
> +    "    fisttps    res16""\n"
> 
> WARNING: Consecutive strings are generally better as a single string
> #183: FILE: tools/testing/selftests/x86/test_FISTTP.c:91:
> +    "    fisttps    res16""\n"
> 
> total: 0 errors, 5 warnings, 32 lines checked
> 
> Can you take a look at these and see if they can be fixed. Send me
> v5 with these fixed - I will pull these in for 6.11-rc1
> 
> thanks,
> -- Shuah

Hi Shuah,

These warnings are pre-existing. For such things, it's usually prudent
to avoid changing them--or at least, not in the same patch.

I think it's best to submit the patch (and series) as-is. If the x86
team wants the above things cleaned up (which I seriously doubt), they'll
let us know.

Yes?


thanks,
Shuah Khan July 9, 2024, 8:51 p.m. UTC | #3
On 7/9/24 14:40, John Hubbard wrote:
> On 7/9/24 1:34 PM, Shuah Khan wrote:
>> On 7/4/24 01:24, John Hubbard wrote:
> ...>> Muhammad Usama Anjum (1):
>>>    selftests: x86: test_FISTTP: use fisttps instead of ambiguous fisttp
>>
>>
>> Usama and John,
>>
>> I am seeing checkpatch warnings in this series.
>>
>> v4-3-7
>> WARNING: externs should be avoided in .c files
>> #210: FILE: tools/testing/selftests/x86/fsgsbase_restore.c:46:
>> +unsigned int dereference_seg_base(void);

This one looked new though.

thanks,
-- Shuah
Shuah Khan July 9, 2024, 8:55 p.m. UTC | #4
On 7/9/24 14:51, Shuah Khan wrote:
> On 7/9/24 14:40, John Hubbard wrote:
>> On 7/9/24 1:34 PM, Shuah Khan wrote:
>>> On 7/4/24 01:24, John Hubbard wrote:
>> ...>> Muhammad Usama Anjum (1):
>>>>    selftests: x86: test_FISTTP: use fisttps instead of ambiguous fisttp
>>>
>>>
>>> Usama and John,
>>>
>>> I am seeing checkpatch warnings in this series.
>>>
>>> v4-3-7
>>> WARNING: externs should be avoided in .c files
>>> #210: FILE: tools/testing/selftests/x86/fsgsbase_restore.c:46:
>>> +unsigned int dereference_seg_base(void);
> 
> This one looked new though.
> 

Never mind. Looks like there are a few existing warns - pulling
these now for Linux 6.11-rc1.

Thank you both for fixing these.

thanks,
-- Shuah