All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] selftests: x86: build suite with clang
@ 2024-05-01 12:29 Muhammad Usama Anjum
  2024-05-01 12:29 ` [PATCH 1/8] selftests: x86: Remove dependence of headers file Muhammad Usama Anjum
                   ` (10 more replies)
  0 siblings, 11 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2024-05-01 12:29 UTC (permalink / raw
  To: Shuah Khan, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Muhammad Usama Anjum, Rick Edgecombe,
	Mike Rapoport (IBM), Ingo Molnar, Dave Hansen, Alexey Dobriyan,
	Binbin Wu, Chang S. Bae, Kirill A. Shutemov, linux-kselftest,
	linux-kernel, llvm
  Cc: kernel

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


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

* [PATCH 1/8] selftests: x86: Remove dependence of headers file
  2024-05-01 12:29 [PATCH 0/8] selftests: x86: build suite with clang Muhammad Usama Anjum
@ 2024-05-01 12:29 ` Muhammad Usama Anjum
  2024-05-01 12:29 ` [PATCH 2/8] selftests: x86: check_initial_reg_state: remove -no-pie while using -static Muhammad Usama Anjum
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2024-05-01 12:29 UTC (permalink / raw
  To: Shuah Khan, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Muhammad Usama Anjum, Rick Edgecombe,
	Mike Rapoport (IBM), Ingo Molnar, Dave Hansen, Alexey Dobriyan,
	Binbin Wu, Chang S. Bae, Kirill A. Shutemov, linux-kselftest,
	linux-kernel, llvm
  Cc: kernel

Remove header file dependence to remove the following error caught by
clang.

clang: error: cannot specify -o when generating multiple output files

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/x86/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile
index 0b872c0a42d20..671b1819694ff 100644
--- a/tools/testing/selftests/x86/Makefile
+++ b/tools/testing/selftests/x86/Makefile
@@ -72,10 +72,10 @@ all_64: $(BINARIES_64)
 
 EXTRA_CLEAN := $(BINARIES_32) $(BINARIES_64)
 
-$(BINARIES_32): $(OUTPUT)/%_32: %.c helpers.h
+$(BINARIES_32): $(OUTPUT)/%_32: %.c
 	$(CC) -m32 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl -lm
 
-$(BINARIES_64): $(OUTPUT)/%_64: %.c helpers.h
+$(BINARIES_64): $(OUTPUT)/%_64: %.c
 	$(CC) -m64 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl
 
 # x86_64 users should be encouraged to install 32-bit libraries
-- 
2.39.2


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

* [PATCH 2/8] selftests: x86: check_initial_reg_state: remove -no-pie while using -static
  2024-05-01 12:29 [PATCH 0/8] selftests: x86: build suite with clang Muhammad Usama Anjum
  2024-05-01 12:29 ` [PATCH 1/8] selftests: x86: Remove dependence of headers file Muhammad Usama Anjum
@ 2024-05-01 12:29 ` Muhammad Usama Anjum
  2024-05-01 12:29 ` [PATCH 3/8] selftests: x86: test_vsyscall: remove unused function Muhammad Usama Anjum
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2024-05-01 12:29 UTC (permalink / raw
  To: Shuah Khan, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Muhammad Usama Anjum, Rick Edgecombe,
	Mike Rapoport (IBM), Ingo Molnar, Dave Hansen, Alexey Dobriyan,
	Binbin Wu, Chang S. Bae, Kirill A. Shutemov, linux-kselftest,
	linux-kernel, llvm
  Cc: kernel

The -static clang flag ignores -no-pie flag. Hence following warning is
generated. Fix the warning by removing the -no-pie flag before
specifying -static flag.

clang: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/x86/Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile
index 671b1819694ff..b0f5b5ff79b8d 100644
--- a/tools/testing/selftests/x86/Makefile
+++ b/tools/testing/selftests/x86/Makefile
@@ -108,8 +108,9 @@ $(OUTPUT)/test_syscall_vdso_32: thunks_32.S
 # check_initial_reg_state is special: it needs a custom entry, and it
 # needs to be static so that its interpreter doesn't destroy its initial
 # state.
-$(OUTPUT)/check_initial_reg_state_32: CFLAGS += -Wl,-ereal_start -static
-$(OUTPUT)/check_initial_reg_state_64: CFLAGS += -Wl,-ereal_start -static
+CFLAGS2:=$(filter-out -no-pie,$(CFLAGS))
+$(OUTPUT)/check_initial_reg_state_32: CFLAGS2 += -Wl,-ereal_start -static
+$(OUTPUT)/check_initial_reg_state_64: CFLAGS2 += -Wl,-ereal_start -static
 
 $(OUTPUT)/nx_stack_32: CFLAGS += -Wl,-z,noexecstack
 $(OUTPUT)/nx_stack_64: CFLAGS += -Wl,-z,noexecstack
-- 
2.39.2


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

* [PATCH 3/8] selftests: x86: test_vsyscall: remove unused function
  2024-05-01 12:29 [PATCH 0/8] selftests: x86: build suite with clang Muhammad Usama Anjum
  2024-05-01 12:29 ` [PATCH 1/8] selftests: x86: Remove dependence of headers file Muhammad Usama Anjum
  2024-05-01 12:29 ` [PATCH 2/8] selftests: x86: check_initial_reg_state: remove -no-pie while using -static Muhammad Usama Anjum
@ 2024-05-01 12:29 ` Muhammad Usama Anjum
  2024-05-01 12:29 ` [PATCH 4/8] selftests: x86: fsgsbase_restore: fix asm directive from =rm to =r Muhammad Usama Anjum
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2024-05-01 12:29 UTC (permalink / raw
  To: Shuah Khan, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Muhammad Usama Anjum, Rick Edgecombe,
	Mike Rapoport (IBM), Ingo Molnar, Dave Hansen, Alexey Dobriyan,
	Binbin Wu, Chang S. Bae, Kirill A. Shutemov, linux-kselftest,
	linux-kernel, llvm
  Cc: kernel

Remove unused function to fix the following warning:

test_vsyscall.c:100:19: warning: unused function 'sys_clock_gettime' [-Wunused-function]
  100 | static inline int sys_clock_gettime(clockid_t id, struct timespec *ts)

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/x86/test_vsyscall.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/tools/testing/selftests/x86/test_vsyscall.c b/tools/testing/selftests/x86/test_vsyscall.c
index d4c8e8d79d389..1c9895cfc660b 100644
--- a/tools/testing/selftests/x86/test_vsyscall.c
+++ b/tools/testing/selftests/x86/test_vsyscall.c
@@ -97,11 +97,6 @@ static inline long sys_gtod(struct timeval *tv, struct timezone *tz)
 	return syscall(SYS_gettimeofday, tv, tz);
 }
 
-static inline int sys_clock_gettime(clockid_t id, struct timespec *ts)
-{
-	return syscall(SYS_clock_gettime, id, ts);
-}
-
 static inline long sys_time(time_t *t)
 {
 	return syscall(SYS_time, t);
-- 
2.39.2


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

* [PATCH 4/8] selftests: x86: fsgsbase_restore: fix asm directive from =rm to =r
  2024-05-01 12:29 [PATCH 0/8] selftests: x86: build suite with clang Muhammad Usama Anjum
                   ` (2 preceding siblings ...)
  2024-05-01 12:29 ` [PATCH 3/8] selftests: x86: test_vsyscall: remove unused function Muhammad Usama Anjum
@ 2024-05-01 12:29 ` Muhammad Usama Anjum
  2024-05-01 12:29 ` [PATCH 5/8] selftests: x86: syscall_arg_fault_32: remove unused variable Muhammad Usama Anjum
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2024-05-01 12:29 UTC (permalink / raw
  To: Shuah Khan, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Muhammad Usama Anjum, Rick Edgecombe,
	Mike Rapoport (IBM), Ingo Molnar, Dave Hansen, Alexey Dobriyan,
	Binbin Wu, Chang S. Bae, Kirill A. Shutemov, linux-kselftest,
	linux-kernel, llvm
  Cc: kernel

The clang gives unknown use of instruction mnemonic error. Fix it by
specifying =r only. The operand would be placed in register only.

fsgsbase_restore.c:45:16: error: unknown use of instruction mnemonic without a size suffix
   45 |         asm volatile ("mov %" SEG ":(0), %0" : "=rm" (ret));
      |                       ^
<inline asm>:1:2: note: instantiated into assembly here
    1 |         mov %fs:(0), 20(%esp)
      |         ^
fsgsbase_restore.c:45:16: error: unknown use of instruction mnemonic without a size suffix
   45 |         asm volatile ("mov %" SEG ":(0), %0" : "=rm" (ret));
      |                       ^
<inline asm>:1:2: note: instantiated into assembly here
    1 |         mov %fs:(0), 20(%esp)
      |         ^

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/x86/fsgsbase_restore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/x86/fsgsbase_restore.c b/tools/testing/selftests/x86/fsgsbase_restore.c
index 6fffadc515791..12871b482185b 100644
--- a/tools/testing/selftests/x86/fsgsbase_restore.c
+++ b/tools/testing/selftests/x86/fsgsbase_restore.c
@@ -42,7 +42,7 @@
 static unsigned int dereference_seg_base(void)
 {
 	int ret;
-	asm volatile ("mov %" SEG ":(0), %0" : "=rm" (ret));
+	asm volatile ("mov %" SEG ":(0), %0" : "=r" (ret));
 	return ret;
 }
 
-- 
2.39.2


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

* [PATCH 5/8] selftests: x86: syscall_arg_fault_32: remove unused variable
  2024-05-01 12:29 [PATCH 0/8] selftests: x86: build suite with clang Muhammad Usama Anjum
                   ` (3 preceding siblings ...)
  2024-05-01 12:29 ` [PATCH 4/8] selftests: x86: fsgsbase_restore: fix asm directive from =rm to =r Muhammad Usama Anjum
@ 2024-05-01 12:29 ` Muhammad Usama Anjum
  2024-05-01 12:29 ` [PATCH 6/8] selftests: x86: test_FISTTP: use fisttps instead of ambigous fisttp Muhammad Usama Anjum
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2024-05-01 12:29 UTC (permalink / raw
  To: Shuah Khan, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Muhammad Usama Anjum, Rick Edgecombe,
	Mike Rapoport (IBM), Ingo Molnar, Dave Hansen, Alexey Dobriyan,
	Binbin Wu, Chang S. Bae, Kirill A. Shutemov, linux-kselftest,
	linux-kernel, llvm
  Cc: kernel

Remove unused global variable.

syscall_arg_fault.c:32:30: warning: unused variable 'sig_traps' [-Wunused-variable]
   32 | static volatile sig_atomic_t sig_traps;

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/x86/syscall_arg_fault.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/x86/syscall_arg_fault.c b/tools/testing/selftests/x86/syscall_arg_fault.c
index 461fa41a4d02a..48ab065a76f9b 100644
--- a/tools/testing/selftests/x86/syscall_arg_fault.c
+++ b/tools/testing/selftests/x86/syscall_arg_fault.c
@@ -29,7 +29,6 @@ static void sethandler(int sig, void (*handler)(int, siginfo_t *, void *),
 		err(1, "sigaction");
 }
 
-static volatile sig_atomic_t sig_traps;
 static sigjmp_buf jmpbuf;
 
 static volatile sig_atomic_t n_errs;
-- 
2.39.2


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

* [PATCH 6/8] selftests: x86: test_FISTTP: use fisttps instead of ambigous fisttp
  2024-05-01 12:29 [PATCH 0/8] selftests: x86: build suite with clang Muhammad Usama Anjum
                   ` (4 preceding siblings ...)
  2024-05-01 12:29 ` [PATCH 5/8] selftests: x86: syscall_arg_fault_32: remove unused variable Muhammad Usama Anjum
@ 2024-05-01 12:29 ` Muhammad Usama Anjum
  2024-05-01 12:29 ` [PATCH 7/8] selftests: x86: fsgsbase: Remove unused function and variable Muhammad Usama Anjum
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2024-05-01 12:29 UTC (permalink / raw
  To: Shuah Khan, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Muhammad Usama Anjum, Rick Edgecombe,
	Mike Rapoport (IBM), Ingo Molnar, Dave Hansen, Alexey Dobriyan,
	Binbin Wu, Chang S. Bae, Kirill A. Shutemov, linux-kselftest,
	linux-kernel, llvm
  Cc: kernel

Use fisttps instead of fisttp to specify correctly that the output
variable is of size short.

test_FISTTP.c:28:3: error: ambiguous instructions require an explicit suffix (could be 'fisttps', or 'fisttpl')
   28 |         "       fisttp  res16""\n"
      |          ^
<inline asm>:3:2: note: instantiated into assembly here
    3 |         fisttp  res16
      |         ^
test_FISTTP.c:48:3: error: ambiguous instructions require an explicit suffix (could be 'fisttps', or 'fisttpl')
   48 |         "       fisttp  res16""\n"
      |          ^
<inline asm>:3:2: note: instantiated into assembly here
    3 |         fisttp  res16
      |         ^
test_FISTTP.c:69:3: error: ambiguous instructions require an explicit suffix (could be 'fisttps', or 'fisttpl')
   69 |         "       fisttp  res16""\n"
      |          ^
<inline asm>:4:2: note: instantiated into assembly here
    4 |         fisttp  res16
      |         ^
test_FISTTP.c:91:3: error: ambiguous instructions require an explicit suffix (could be 'fisttps', or 'fisttpl')
   91 |         "       fisttp  res16""\n"
      |          ^
<inline asm>:3:2: note: instantiated into assembly here
    3 |         fisttp  res16
      |         ^

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/x86/test_FISTTP.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/x86/test_FISTTP.c b/tools/testing/selftests/x86/test_FISTTP.c
index 09789c0ce3e9c..b9ae9d8cebcb3 100644
--- a/tools/testing/selftests/x86/test_FISTTP.c
+++ b/tools/testing/selftests/x86/test_FISTTP.c
@@ -25,7 +25,7 @@ int test(void)
 	feclearexcept(FE_DIVBYZERO|FE_INEXACT|FE_INVALID|FE_OVERFLOW|FE_UNDERFLOW);
 	asm volatile ("\n"
 	"	fld1""\n"
-	"	fisttp	res16""\n"
+	"	fisttps	res16""\n"
 	"	fld1""\n"
 	"	fisttpl	res32""\n"
 	"	fld1""\n"
@@ -45,7 +45,7 @@ int test(void)
 	feclearexcept(FE_DIVBYZERO|FE_INEXACT|FE_INVALID|FE_OVERFLOW|FE_UNDERFLOW);
 	asm volatile ("\n"
 	"	fldpi""\n"
-	"	fisttp	res16""\n"
+	"	fisttps	res16""\n"
 	"	fldpi""\n"
 	"	fisttpl	res32""\n"
 	"	fldpi""\n"
@@ -66,7 +66,7 @@ int test(void)
 	asm volatile ("\n"
 	"	fldpi""\n"
 	"	fchs""\n"
-	"	fisttp	res16""\n"
+	"	fisttps	res16""\n"
 	"	fldpi""\n"
 	"	fchs""\n"
 	"	fisttpl	res32""\n"
@@ -88,7 +88,7 @@ int test(void)
 	feclearexcept(FE_DIVBYZERO|FE_INEXACT|FE_INVALID|FE_OVERFLOW|FE_UNDERFLOW);
 	asm volatile ("\n"
 	"	fldln2""\n"
-	"	fisttp	res16""\n"
+	"	fisttps	res16""\n"
 	"	fldln2""\n"
 	"	fisttpl	res32""\n"
 	"	fldln2""\n"
-- 
2.39.2


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

* [PATCH 7/8] selftests: x86: fsgsbase: Remove unused function and variable
  2024-05-01 12:29 [PATCH 0/8] selftests: x86: build suite with clang Muhammad Usama Anjum
                   ` (5 preceding siblings ...)
  2024-05-01 12:29 ` [PATCH 6/8] selftests: x86: test_FISTTP: use fisttps instead of ambigous fisttp Muhammad Usama Anjum
@ 2024-05-01 12:29 ` Muhammad Usama Anjum
  2024-05-01 12:29 ` [PATCH 8/8] selftests: x86: amx: Remove unused functions Muhammad Usama Anjum
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2024-05-01 12:29 UTC (permalink / raw
  To: Shuah Khan, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Muhammad Usama Anjum, Rick Edgecombe,
	Mike Rapoport (IBM), Ingo Molnar, Dave Hansen, Alexey Dobriyan,
	Binbin Wu, Chang S. Bae, Kirill A. Shutemov, linux-kselftest,
	linux-kernel, llvm
  Cc: kernel

Remove unused code.

fsgsbase.c:112:20: warning: unused function 'wrfsbase' [-Wunused-function]
  112 | static inline void wrfsbase(unsigned long fsbase)
      |                    ^~~~~~~~
fsgsbase.c:215:22: warning: unused variable 'remote_hard_zero' [-Wunused-variable]
  215 | static volatile bool remote_hard_zero;
      |                      ^~~~~~~~~~~~~~~~

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/x86/fsgsbase.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/tools/testing/selftests/x86/fsgsbase.c b/tools/testing/selftests/x86/fsgsbase.c
index 8c780cce941da..50cf32de63139 100644
--- a/tools/testing/selftests/x86/fsgsbase.c
+++ b/tools/testing/selftests/x86/fsgsbase.c
@@ -109,11 +109,6 @@ static inline void wrgsbase(unsigned long gsbase)
 	asm volatile("wrgsbase %0" :: "r" (gsbase) : "memory");
 }
 
-static inline void wrfsbase(unsigned long fsbase)
-{
-	asm volatile("wrfsbase %0" :: "r" (fsbase) : "memory");
-}
-
 enum which_base { FS, GS };
 
 static unsigned long read_base(enum which_base which)
@@ -212,7 +207,6 @@ static void mov_0_gs(unsigned long initial_base, bool schedule)
 }
 
 static volatile unsigned long remote_base;
-static volatile bool remote_hard_zero;
 static volatile unsigned int ftx;
 
 /*
-- 
2.39.2


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

* [PATCH 8/8] selftests: x86: amx: Remove unused functions
  2024-05-01 12:29 [PATCH 0/8] selftests: x86: build suite with clang Muhammad Usama Anjum
                   ` (6 preceding siblings ...)
  2024-05-01 12:29 ` [PATCH 7/8] selftests: x86: fsgsbase: Remove unused function and variable Muhammad Usama Anjum
@ 2024-05-01 12:29 ` Muhammad Usama Anjum
  2024-05-06 23:26 ` [PATCH 0/8] selftests: x86: build suite with clang Fangrui Song
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2024-05-01 12:29 UTC (permalink / raw
  To: Shuah Khan, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Muhammad Usama Anjum, Rick Edgecombe,
	Mike Rapoport (IBM), Ingo Molnar, Dave Hansen, Alexey Dobriyan,
	Binbin Wu, Chang S. Bae, Kirill A. Shutemov, linux-kselftest,
	linux-kernel, llvm
  Cc: kernel

Remove unused code.

amx.c:42:24: warning: unused function 'xgetbv' [-Wunused-function]
   42 | static inline uint64_t xgetbv(uint32_t index)
      |                        ^~~~~~
amx.c:167:24: warning: unused function 'get_xstatebv' [-Wunused-function]
  167 | static inline uint64_t get_xstatebv(struct xsave_buffer *buffer)
      |                        ^~~~~~~~~~~~

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/x86/amx.c | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/tools/testing/selftests/x86/amx.c b/tools/testing/selftests/x86/amx.c
index 95aad6d8849be..1fdf35a4d7f63 100644
--- a/tools/testing/selftests/x86/amx.c
+++ b/tools/testing/selftests/x86/amx.c
@@ -39,16 +39,6 @@ struct xsave_buffer {
 	};
 };
 
-static inline uint64_t xgetbv(uint32_t index)
-{
-	uint32_t eax, edx;
-
-	asm volatile("xgetbv;"
-		     : "=a" (eax), "=d" (edx)
-		     : "c" (index));
-	return eax + ((uint64_t)edx << 32);
-}
-
 static inline void xsave(struct xsave_buffer *xbuf, uint64_t rfbm)
 {
 	uint32_t rfbm_lo = rfbm;
@@ -164,12 +154,6 @@ static inline void clear_xstate_header(struct xsave_buffer *buffer)
 	memset(&buffer->header, 0, sizeof(buffer->header));
 }
 
-static inline uint64_t get_xstatebv(struct xsave_buffer *buffer)
-{
-	/* XSTATE_BV is at the beginning of the header: */
-	return *(uint64_t *)&buffer->header;
-}
-
 static inline void set_xstatebv(struct xsave_buffer *buffer, uint64_t bv)
 {
 	/* XSTATE_BV is at the beginning of the header: */
-- 
2.39.2


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

* Re: [PATCH 0/8] selftests: x86: build suite with clang
  2024-05-01 12:29 [PATCH 0/8] selftests: x86: build suite with clang Muhammad Usama Anjum
                   ` (7 preceding siblings ...)
  2024-05-01 12:29 ` [PATCH 8/8] selftests: x86: amx: Remove unused functions Muhammad Usama Anjum
@ 2024-05-06 23:26 ` Fangrui Song
  2024-05-15 22:20   ` Fangrui Song
  2024-05-16 14:06 ` Muhammad Usama Anjum
  2024-05-28  5:04 ` Muhammad Usama Anjum
  10 siblings, 1 reply; 16+ messages in thread
From: Fangrui Song @ 2024-05-06 23:26 UTC (permalink / raw
  To: Muhammad Usama Anjum
  Cc: Shuah Khan, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Rick Edgecombe, Mike Rapoport (IBM), Ingo Molnar,
	Dave Hansen, Alexey Dobriyan, Binbin Wu, Chang S. Bae,
	Kirill A. Shutemov, linux-kselftest, linux-kernel, llvm, kernel

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
>
>


-- 
宋方睿

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

* Re: [PATCH 0/8] selftests: x86: build suite with clang
  2024-05-06 23:26 ` [PATCH 0/8] selftests: x86: build suite with clang Fangrui Song
@ 2024-05-15 22:20   ` Fangrui Song
  0 siblings, 0 replies; 16+ messages in thread
From: Fangrui Song @ 2024-05-15 22:20 UTC (permalink / raw
  To: Muhammad Usama Anjum
  Cc: Shuah Khan, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Rick Edgecombe, Mike Rapoport (IBM), Ingo Molnar,
	Dave Hansen, Alexey Dobriyan, Binbin Wu, Chang S. Bae,
	Kirill A. Shutemov, linux-kselftest, linux-kernel, llvm, kernel

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
> >
> >

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

* Re: [PATCH 0/8] selftests: x86: build suite with clang
  2024-05-01 12:29 [PATCH 0/8] selftests: x86: build suite with clang Muhammad Usama Anjum
                   ` (8 preceding siblings ...)
  2024-05-06 23:26 ` [PATCH 0/8] selftests: x86: build suite with clang Fangrui Song
@ 2024-05-16 14:06 ` Muhammad Usama Anjum
  2024-05-28  5:04 ` Muhammad Usama Anjum
  10 siblings, 0 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2024-05-16 14:06 UTC (permalink / raw
  To: Shuah Khan, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Rick Edgecombe, Mike Rapoport (IBM), Ingo Molnar,
	Dave Hansen, Alexey Dobriyan, Binbin Wu, Chang S. Bae,
	Kirill A. Shutemov, linux-kselftest, linux-kernel, llvm, maskray
  Cc: Muhammad Usama Anjum, kernel

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

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

* Re: [PATCH 0/8] selftests: x86: build suite with clang
  2024-05-01 12:29 [PATCH 0/8] selftests: x86: build suite with clang Muhammad Usama Anjum
                   ` (9 preceding siblings ...)
  2024-05-16 14:06 ` Muhammad Usama Anjum
@ 2024-05-28  5:04 ` Muhammad Usama Anjum
  2024-06-07 20:50   ` Shuah Khan
  10 siblings, 1 reply; 16+ messages in thread
From: Muhammad Usama Anjum @ 2024-05-28  5:04 UTC (permalink / raw
  To: Shuah Khan, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Rick Edgecombe, Mike Rapoport (IBM), Ingo Molnar,
	Dave Hansen, Alexey Dobriyan, Binbin Wu, Chang S. Bae,
	Kirill A. Shutemov, linux-kselftest, linux-kernel, llvm
  Cc: Muhammad Usama Anjum, kernel

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

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

* Re: [PATCH 0/8] selftests: x86: build suite with clang
  2024-05-28  5:04 ` Muhammad Usama Anjum
@ 2024-06-07 20:50   ` Shuah Khan
  2024-06-07 21:17     ` Dave Hansen
  0 siblings, 1 reply; 16+ messages in thread
From: Shuah Khan @ 2024-06-07 20:50 UTC (permalink / raw
  To: Muhammad Usama Anjum, Shuah Khan, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Rick Edgecombe,
	Mike Rapoport (IBM), Ingo Molnar, Dave Hansen, Alexey Dobriyan,
	Binbin Wu, Chang S. Bae, Kirill A. Shutemov, linux-kselftest,
	linux-kernel, llvm
  Cc: kernel, Shuah Khan

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

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

* Re: [PATCH 0/8] selftests: x86: build suite with clang
  2024-06-07 20:50   ` Shuah Khan
@ 2024-06-07 21:17     ` Dave Hansen
  2024-06-07 21:25       ` John Hubbard
  0 siblings, 1 reply; 16+ messages in thread
From: Dave Hansen @ 2024-06-07 21:17 UTC (permalink / raw
  To: Shuah Khan, Muhammad Usama Anjum, Shuah Khan, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Rick Edgecombe,
	Mike Rapoport (IBM), Ingo Molnar, Dave Hansen, Alexey Dobriyan,
	Binbin Wu, Chang S. Bae, Kirill A. Shutemov, linux-kselftest,
	linux-kernel, llvm, John Hubbard
  Cc: kernel

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.



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

* Re: [PATCH 0/8] selftests: x86: build suite with clang
  2024-06-07 21:17     ` Dave Hansen
@ 2024-06-07 21:25       ` John Hubbard
  0 siblings, 0 replies; 16+ messages in thread
From: John Hubbard @ 2024-06-07 21:25 UTC (permalink / raw
  To: Dave Hansen, Shuah Khan, Muhammad Usama Anjum, Shuah Khan,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Rick Edgecombe, Mike Rapoport (IBM), Ingo Molnar, Dave Hansen,
	Alexey Dobriyan, Binbin Wu, Chang S. Bae, Kirill A. Shutemov,
	linux-kselftest, linux-kernel, llvm
  Cc: kernel

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


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

end of thread, other threads:[~2024-06-07 21:25 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-01 12:29 [PATCH 0/8] selftests: x86: build suite with clang Muhammad Usama Anjum
2024-05-01 12:29 ` [PATCH 1/8] selftests: x86: Remove dependence of headers file Muhammad Usama Anjum
2024-05-01 12:29 ` [PATCH 2/8] selftests: x86: check_initial_reg_state: remove -no-pie while using -static Muhammad Usama Anjum
2024-05-01 12:29 ` [PATCH 3/8] selftests: x86: test_vsyscall: remove unused function Muhammad Usama Anjum
2024-05-01 12:29 ` [PATCH 4/8] selftests: x86: fsgsbase_restore: fix asm directive from =rm to =r Muhammad Usama Anjum
2024-05-01 12:29 ` [PATCH 5/8] selftests: x86: syscall_arg_fault_32: remove unused variable Muhammad Usama Anjum
2024-05-01 12:29 ` [PATCH 6/8] selftests: x86: test_FISTTP: use fisttps instead of ambigous fisttp Muhammad Usama Anjum
2024-05-01 12:29 ` [PATCH 7/8] selftests: x86: fsgsbase: Remove unused function and variable Muhammad Usama Anjum
2024-05-01 12:29 ` [PATCH 8/8] selftests: x86: amx: Remove unused functions Muhammad Usama Anjum
2024-05-06 23:26 ` [PATCH 0/8] selftests: x86: build suite with clang Fangrui Song
2024-05-15 22:20   ` Fangrui Song
2024-05-16 14:06 ` Muhammad Usama Anjum
2024-05-28  5:04 ` Muhammad Usama Anjum
2024-06-07 20:50   ` Shuah Khan
2024-06-07 21:17     ` Dave Hansen
2024-06-07 21:25       ` John Hubbard

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.