[PATCH 0/8] selftests: x86: build suite with clang

Muhammad Usama Anjum posted 8 patches 1 year, 7 months ago
tools/testing/selftests/x86/Makefile            |  9 +++++----
tools/testing/selftests/x86/amx.c               | 16 ----------------
tools/testing/selftests/x86/fsgsbase.c          |  6 ------
tools/testing/selftests/x86/fsgsbase_restore.c  |  2 +-
tools/testing/selftests/x86/syscall_arg_fault.c |  1 -
tools/testing/selftests/x86/test_FISTTP.c       |  8 ++++----
tools/testing/selftests/x86/test_vsyscall.c     |  5 -----
7 files changed, 10 insertions(+), 37 deletions(-)
[PATCH 0/8] selftests: x86: build suite with clang
Posted by Muhammad Usama Anjum 1 year, 7 months ago
This series fixes build errors found by clang to allow the x86 suite to
get built with the clang.

Unfortunately, there is one bug [1] in the clang becuase of which
extended asm isn't handled correctly by it and build fails for
sysret_rip.c. Hence even after this series the build of this test would
fail with clang. Should we disable this test for now when clang is used
until the bug is fixed in clang? Not sure. Any opinions?

[1] https://github.com/llvm/llvm-project/issues/53728

Muhammad Usama Anjum (8):
  selftests: x86: Remove dependence of headers file
  selftests: x86: check_initial_reg_state: remove -no-pie while using
    -static
  selftests: x86: test_vsyscall: remove unused function
  selftests: x86: fsgsbase_restore: fix asm directive from =rm to =r
  selftests: x86: syscall_arg_fault_32: remove unused variable
  selftests: x86: test_FISTTP: use fisttps instead of ambigous fisttp
  selftests: x86: fsgsbase: Remove unused function and variable
  selftests: x86: amx: Remove unused functions

 tools/testing/selftests/x86/Makefile            |  9 +++++----
 tools/testing/selftests/x86/amx.c               | 16 ----------------
 tools/testing/selftests/x86/fsgsbase.c          |  6 ------
 tools/testing/selftests/x86/fsgsbase_restore.c  |  2 +-
 tools/testing/selftests/x86/syscall_arg_fault.c |  1 -
 tools/testing/selftests/x86/test_FISTTP.c       |  8 ++++----
 tools/testing/selftests/x86/test_vsyscall.c     |  5 -----
 7 files changed, 10 insertions(+), 37 deletions(-)

-- 
2.39.2
Re: [PATCH 0/8] selftests: x86: build suite with clang
Posted by Muhammad Usama Anjum 1 year, 6 months ago
Soft reminder

On 5/1/24 5:29 PM, Muhammad Usama Anjum wrote:
> This series fixes build errors found by clang to allow the x86 suite to
> get built with the clang.
> 
> Unfortunately, there is one bug [1] in the clang becuase of which
> extended asm isn't handled correctly by it and build fails for
> sysret_rip.c. Hence even after this series the build of this test would
> fail with clang. Should we disable this test for now when clang is used
> until the bug is fixed in clang? Not sure. Any opinions?
> 
> [1] https://github.com/llvm/llvm-project/issues/53728
> 
> Muhammad Usama Anjum (8):
>   selftests: x86: Remove dependence of headers file
>   selftests: x86: check_initial_reg_state: remove -no-pie while using
>     -static
>   selftests: x86: test_vsyscall: remove unused function
>   selftests: x86: fsgsbase_restore: fix asm directive from =rm to =r
>   selftests: x86: syscall_arg_fault_32: remove unused variable
>   selftests: x86: test_FISTTP: use fisttps instead of ambigous fisttp
>   selftests: x86: fsgsbase: Remove unused function and variable
>   selftests: x86: amx: Remove unused functions
> 
>  tools/testing/selftests/x86/Makefile            |  9 +++++----
>  tools/testing/selftests/x86/amx.c               | 16 ----------------
>  tools/testing/selftests/x86/fsgsbase.c          |  6 ------
>  tools/testing/selftests/x86/fsgsbase_restore.c  |  2 +-
>  tools/testing/selftests/x86/syscall_arg_fault.c |  1 -
>  tools/testing/selftests/x86/test_FISTTP.c       |  8 ++++----
>  tools/testing/selftests/x86/test_vsyscall.c     |  5 -----
>  7 files changed, 10 insertions(+), 37 deletions(-)
> 

-- 
BR,
Muhammad Usama Anjum
Re: [PATCH 0/8] selftests: x86: build suite with clang
Posted by Shuah Khan 1 year, 6 months ago
On 5/27/24 23:04, Muhammad Usama Anjum wrote:
> Soft reminder
> 
> On 5/1/24 5:29 PM, Muhammad Usama Anjum wrote:
>> This series fixes build errors found by clang to allow the x86 suite to
>> get built with the clang.
>>
>> Unfortunately, there is one bug [1] in the clang becuase of which
>> extended asm isn't handled correctly by it and build fails for
>> sysret_rip.c. Hence even after this series the build of this test would
>> fail with clang. Should we disable this test for now when clang is used
>> until the bug is fixed in clang? Not sure. Any opinions?
>>
>> [1] https://github.com/llvm/llvm-project/issues/53728
>>
>> Muhammad Usama Anjum (8):
>>    selftests: x86: Remove dependence of headers file
>>    selftests: x86: check_initial_reg_state: remove -no-pie while using
>>      -static
>>    selftests: x86: test_vsyscall: remove unused function
>>    selftests: x86: fsgsbase_restore: fix asm directive from =rm to =r
>>    selftests: x86: syscall_arg_fault_32: remove unused variable
>>    selftests: x86: test_FISTTP: use fisttps instead of ambigous fisttp
>>    selftests: x86: fsgsbase: Remove unused function and variable
>>    selftests: x86: amx: Remove unused functions
>>
>>   tools/testing/selftests/x86/Makefile            |  9 +++++----
>>   tools/testing/selftests/x86/amx.c               | 16 ----------------
>>   tools/testing/selftests/x86/fsgsbase.c          |  6 ------
>>   tools/testing/selftests/x86/fsgsbase_restore.c  |  2 +-
>>   tools/testing/selftests/x86/syscall_arg_fault.c |  1 -
>>   tools/testing/selftests/x86/test_FISTTP.c       |  8 ++++----
>>   tools/testing/selftests/x86/test_vsyscall.c     |  5 -----
>>   7 files changed, 10 insertions(+), 37 deletions(-)
>>
> 

These patches usually go through x86 repo.

I need ack from x86 maintainers to take these. I don't see x86 list
cc'ed.

Please make sure to include everybody on these threads to get quicker
response.

thanks,
-- Shuah
Re: [PATCH 0/8] selftests: x86: build suite with clang
Posted by Dave Hansen 1 year, 6 months ago
On 6/7/24 13:50, Shuah Khan wrote:
> These patches usually go through x86 repo.
> 
> I need ack from x86 maintainers to take these. I don't see x86 list
> cc'ed.
> 
> Please make sure to include everybody on these threads to get quicker
> response.

John Hubbard (cc'd) had a partially overlapping set with these.  He and
Muhammad were going to work together to get a set they could both get
behind.  I _think_ John picked up one of Muhammad's, but we haven't
heard back from Muhammad last I checked.
Re: [PATCH 0/8] selftests: x86: build suite with clang
Posted by John Hubbard 1 year, 6 months ago
On 6/7/24 2:17 PM, Dave Hansen wrote:
> On 6/7/24 13:50, Shuah Khan wrote:
>> These patches usually go through x86 repo.
>>
>> I need ack from x86 maintainers to take these. I don't see x86 list
>> cc'ed.
>>
>> Please make sure to include everybody on these threads to get quicker
>> response.
> 
> John Hubbard (cc'd) had a partially overlapping set with these.  He and
> Muhammad were going to work together to get a set they could both get
> behind.  I _think_ John picked up one of Muhammad's, but we haven't
> heard back from Muhammad last I checked.
  
Yes I did that.  My latest series has 1 fix from Muhammad and 6 more
from me. Muhammad hasn't formally ack'd nor responded to the latest
series [1] yet, although he was OK doing it this way [2].

[1] https://lore.kernel.org/20240531193838.108454-1-jhubbard@nvidia.com

[2] https://lore.kernel.org/046d2d1d-3583-426b-b745-59f3696fb418@collabora.com


thanks,
-- 
John Hubbard
NVIDIA
Re: [PATCH 0/8] selftests: x86: build suite with clang
Posted by Muhammad Usama Anjum 1 year, 7 months ago
On 5/1/24 6:29 AM, Muhammad Usama Anjum wrote:
> This series fixes build errors found by clang to allow the x86 suite to
> get built with the clang.
> 
> Unfortunately, there is one bug [1] in the clang becuase of which
> extended asm isn't handled correctly by it and build fails for
> sysret_rip.c. Hence even after this series the build of this test would
> fail with clang. Should we disable this test for now when clang is used
> until the bug is fixed in clang? Not sure. Any opinions?
Its seems like the bug has been fixed in clang. I'll verify it in next
release and draft a patch separately to fix that error.

I think this series is good to accept then.

> 
> [1] https://github.com/llvm/llvm-project/issues/53728
> 
> Muhammad Usama Anjum (8):
>   selftests: x86: Remove dependence of headers file
>   selftests: x86: check_initial_reg_state: remove -no-pie while using
>     -static
>   selftests: x86: test_vsyscall: remove unused function
>   selftests: x86: fsgsbase_restore: fix asm directive from =rm to =r
>   selftests: x86: syscall_arg_fault_32: remove unused variable
>   selftests: x86: test_FISTTP: use fisttps instead of ambigous fisttp
>   selftests: x86: fsgsbase: Remove unused function and variable
>   selftests: x86: amx: Remove unused functions
> 
>  tools/testing/selftests/x86/Makefile            |  9 +++++----
>  tools/testing/selftests/x86/amx.c               | 16 ----------------
>  tools/testing/selftests/x86/fsgsbase.c          |  6 ------
>  tools/testing/selftests/x86/fsgsbase_restore.c  |  2 +-
>  tools/testing/selftests/x86/syscall_arg_fault.c |  1 -
>  tools/testing/selftests/x86/test_FISTTP.c       |  8 ++++----
>  tools/testing/selftests/x86/test_vsyscall.c     |  5 -----
>  7 files changed, 10 insertions(+), 37 deletions(-)
> 

-- 
BR,
Muhammad Usama Anjum
Re: [PATCH 0/8] selftests: x86: build suite with clang
Posted by Fangrui Song 1 year, 7 months ago
On Wed, May 1, 2024 at 5:29 AM Muhammad Usama Anjum
<usama.anjum@collabora.com> wrote:
>
> This series fixes build errors found by clang to allow the x86 suite to
> get built with the clang.
>
> Unfortunately, there is one bug [1] in the clang becuase of which
> extended asm isn't handled correctly by it and build fails for
> sysret_rip.c. Hence even after this series the build of this test would
> fail with clang. Should we disable this test for now when clang is used
> until the bug is fixed in clang? Not sure. Any opinions?
>
> [1] https://github.com/llvm/llvm-project/issues/53728

I've closed https://github.com/llvm/llvm-project/issues/53728
(constant expression folding for relocatable file output
(MCObjectStreamer)).

I've sent a patch to address https://github.com/llvm/llvm-project/issues/62520
(constant expression folding for relocatable file output  when inline
assembly is used).

(I am subscribed to llvm@lists.linux.dev but rarely read it. I noticed
this message accidentally :) )

> Muhammad Usama Anjum (8):
>   selftests: x86: Remove dependence of headers file
>   selftests: x86: check_initial_reg_state: remove -no-pie while using
>     -static
>   selftests: x86: test_vsyscall: remove unused function
>   selftests: x86: fsgsbase_restore: fix asm directive from =rm to =r
>   selftests: x86: syscall_arg_fault_32: remove unused variable
>   selftests: x86: test_FISTTP: use fisttps instead of ambigous fisttp
>   selftests: x86: fsgsbase: Remove unused function and variable
>   selftests: x86: amx: Remove unused functions
>
>  tools/testing/selftests/x86/Makefile            |  9 +++++----
>  tools/testing/selftests/x86/amx.c               | 16 ----------------
>  tools/testing/selftests/x86/fsgsbase.c          |  6 ------
>  tools/testing/selftests/x86/fsgsbase_restore.c  |  2 +-
>  tools/testing/selftests/x86/syscall_arg_fault.c |  1 -
>  tools/testing/selftests/x86/test_FISTTP.c       |  8 ++++----
>  tools/testing/selftests/x86/test_vsyscall.c     |  5 -----
>  7 files changed, 10 insertions(+), 37 deletions(-)
>
> --
> 2.39.2
>
>


-- 
宋方睿
Re: [PATCH 0/8] selftests: x86: build suite with clang
Posted by Fangrui Song 1 year, 7 months ago
On Mon, May 6, 2024 at 4:26 PM Fangrui Song <maskray@google.com> wrote:
>
> On Wed, May 1, 2024 at 5:29 AM Muhammad Usama Anjum
> <usama.anjum@collabora.com> wrote:
> >
> > This series fixes build errors found by clang to allow the x86 suite to
> > get built with the clang.
> >
> > Unfortunately, there is one bug [1] in the clang becuase of which
> > extended asm isn't handled correctly by it and build fails for
> > sysret_rip.c. Hence even after this series the build of this test would
> > fail with clang. Should we disable this test for now when clang is used
> > until the bug is fixed in clang? Not sure. Any opinions?
> >
> > [1] https://github.com/llvm/llvm-project/issues/53728
>
> I've closed https://github.com/llvm/llvm-project/issues/53728
> (constant expression folding for relocatable file output
> (MCObjectStreamer)).
>
> I've sent a patch to address https://github.com/llvm/llvm-project/issues/62520
> (constant expression folding for relocatable file output  when inline
> assembly is used).
>
> (I am subscribed to llvm@lists.linux.dev but rarely read it. I noticed
> this message accidentally :) )

On the LLVM/Clang side, I've landed
https://github.com/llvm/llvm-project/pull/91082 to make the following
.if directive work for clang -c. clang -S still doesn't work
(https://discourse.llvm.org/t/rfc-clang-assembly-object-equivalence-for-files-with-inline-assembly/78841/4?u=maskray)
but people can probably live with that

```
% cat b.cc
asm(R"(
.pushsection .text,"ax"
.globl _start; _start: ret
.if . -_start == 1
  ret
.endif
.popsection
)");

% clang -c b.cc     # succeeded with this patch
% clang -S b.cc     # still failed
<inline asm>:4:5: error: expected absolute expression
    4 | .if . -_start == 1
      |     ^
1 error generated.
```


> > Muhammad Usama Anjum (8):
> >   selftests: x86: Remove dependence of headers file
> >   selftests: x86: check_initial_reg_state: remove -no-pie while using
> >     -static
> >   selftests: x86: test_vsyscall: remove unused function
> >   selftests: x86: fsgsbase_restore: fix asm directive from =rm to =r
> >   selftests: x86: syscall_arg_fault_32: remove unused variable
> >   selftests: x86: test_FISTTP: use fisttps instead of ambigous fisttp
> >   selftests: x86: fsgsbase: Remove unused function and variable
> >   selftests: x86: amx: Remove unused functions
> >
> >  tools/testing/selftests/x86/Makefile            |  9 +++++----
> >  tools/testing/selftests/x86/amx.c               | 16 ----------------
> >  tools/testing/selftests/x86/fsgsbase.c          |  6 ------
> >  tools/testing/selftests/x86/fsgsbase_restore.c  |  2 +-
> >  tools/testing/selftests/x86/syscall_arg_fault.c |  1 -
> >  tools/testing/selftests/x86/test_FISTTP.c       |  8 ++++----
> >  tools/testing/selftests/x86/test_vsyscall.c     |  5 -----
> >  7 files changed, 10 insertions(+), 37 deletions(-)
> >
> > --
> > 2.39.2
> >
> >