Skip to contentSkip to conversation

Revert "selftests/x86: Recurse into subdirectories"

PATCH In review Jarkko Sakkinen 2 participants 7 messages Mar 20, 2020 – Mar 30, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Revert "selftests/x86: Recurse into subdirectories"

This reverts commit 565ceeb112045102d62493efb951e237d030e7e1.

---
 tools/testing/selftests/x86/Makefile | 44 ----------------------------
 1 file changed, 44 deletions(-)
tools/testing/selftests/x86/Makefile +0 -44
index dee6dadeba61..5d49bfec1e9a 100644
@@ -10,8 +10,6 @@ CAN_BUILD_I386 := $(shell ./check_cc.sh $(CC) trivial_32bit_program.c -m32)
 CAN_BUILD_X86_64 := $(shell ./check_cc.sh $(CC) trivial_64bit_program.c)
 CAN_BUILD_WITH_NOPIE := $(shell ./check_cc.sh $(CC) trivial_program.c -no-pie)
 
-SUBDIRS := sgx
-
 TARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs syscall_nt test_mremap_vdso \
 			check_initial_reg_state sigreturn iopl ioperm \
 			protection_keys test_vdso test_vsyscall mov_ss_trap \
@@ -61,48 +59,6 @@ endif
 
 ifeq ($(CAN_BUILD_X86_64),1)
 all: all_64
-	@for DIR in $(SUBDIRS); do \
-		BUILD_TARGET=$(OUTPUT)/$$DIR; \
-		mkdir $$BUILD_TARGET  -p; \
-		make OUTPUT=$$BUILD_TARGET -C $$DIR $@; \
-	done
-
-DEFAULT_RUN_TESTS := $(RUN_TESTS)
-override define RUN_TESTS
-	$(DEFAULT_RUN_TESTS)
-	@for TARGET in $(SUBDIRS); do \
-		BUILD_TARGET=$(OUTPUT)/$$TARGET; \
-		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests; \
-	done;
-endef
-
-DEFAULT_INSTALL_RULE := $(INSTALL_RULE)
-override define INSTALL_RULE
-	$(DEFAULT_INSTALL_RULE)
-	@for TARGET in $(SUBDIRS); do \
-		BUILD_TARGET=$(OUTPUT)/$$TARGET; \
-		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install; \
-	done;
-endef
-
-DEFAULT_EMIT_TESTS := $(EMIT_TESTS)
-override define EMIT_TESTS
-	$(DEFAULT_EMIT_TESTS)
-	@for TARGET in $(SUBDIRS); do \
-		BUILD_TARGET=$(OUTPUT)/$$TARGET; \
-		$(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests; \
-	done;
-endef
-
-DEFAULT_CLEAN := $(CLEAN)
-override define CLEAN
-	$(DEFAULT_CLEAN)
-	@for TARGET in $(SUBDIRS); do \
-		BUILD_TARGET=$(OUTPUT)/$$TARGET; \
-		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean; \
-	done;
-endef
-
 TEST_PROGS += $(BINARIES_64)
 EXTRA_CFLAGS += -DCAN_BUILD_64
 $(foreach t,$(TARGETS_C_64BIT_ALL),$(eval $(call gen-target-rule-64,$(t))))
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 selftests/x86/sgx: Move to selftests/sgx

Move selftest under the top level selftests directory so that we don't need to clutter x86/Makefile. The changes made for x86/Makefile caused also issues with packaging the selftests. Finally, SGX assets need their own tailored compilation environment.

With this change BuildRoot nicely packages both standard x86 selftests and our SGX test.

Cc Sean Christopherson <[email protected]>
---
 tools/testing/selftests/Makefile                     |  1 +
 tools/testing/selftests/{x86 => }/sgx/.gitignore     |  0
 tools/testing/selftests/{x86 => }/sgx/Makefile       | 12 +++++++++---
 tools/testing/selftests/{x86 => }/sgx/call.S         |  0
 tools/testing/selftests/{x86 => }/sgx/defines.h      |  4 ++--
 tools/testing/selftests/{x86 => }/sgx/encl.c         |  0
 tools/testing/selftests/{x86 => }/sgx/encl.lds       |  0
 .../testing/selftests/{x86 => }/sgx/encl_bootstrap.S |  0
 tools/testing/selftests/{x86 => }/sgx/main.c         |  0
 tools/testing/selftests/{x86 => }/sgx/main.h         |  0
 tools/testing/selftests/{x86 => }/sgx/sign.c         |  0
 11 files changed, 12 insertions(+), 5 deletions(-)
 rename tools/testing/selftests/{x86 => }/sgx/.gitignore (100%)
 rename tools/testing/selftests/{x86 => }/sgx/Makefile (83%)
 rename tools/testing/selftests/{x86 => }/sgx/call.S (100%)
 rename tools/testing/selftests/{x86 => }/sgx/defines.h (71%)
 rename tools/testing/selftests/{x86 => }/sgx/encl.c (100%)
 rename tools/testing/selftests/{x86 => }/sgx/encl.lds (100%)
 rename tools/testing/selftests/{x86 => }/sgx/encl_bootstrap.S (100%)
 rename tools/testing/selftests/{x86 => }/sgx/main.c (100%)
 rename tools/testing/selftests/{x86 => }/sgx/main.h (100%)
 rename tools/testing/selftests/{x86 => }/sgx/sign.c (100%)
tools/testing/selftests/Makefile +1 -0
index 6ec503912bea..183a050b5bda 100644
@@ -63,6 +63,7 @@ TARGETS += user
 TARGETS += vm
 TARGETS += x86
 TARGETS += zram
+TARGETS += sgx
 #Please keep the TARGETS list alphabetically sorted
 # Run "make quicktest=1 run_tests" or
 # "make quicktest=1 kselftest" from top level Makefile
tools/testing/selftests/sgx/.gitignore renamed from tools/testing/selftests/x86/sgx/.gitignore +0 -0
similarity index 100%
rename from tools/testing/selftests/x86/sgx/.gitignore
rename to tools/testing/selftests/sgx/.gitignore
tools/testing/selftests/sgx/Makefile renamed from tools/testing/selftests/x86/sgx/Makefile +9 -3
similarity index 83%
rename from tools/testing/selftests/x86/sgx/Makefile
rename to tools/testing/selftests/sgx/Makefile
index 789ebbbfddcb..d9c3b3a1983b 100644
@@ -1,6 +1,11 @@
-top_srcdir = ../../../../..
+top_srcdir = ../../../..
 
-include ../../lib.mk
+include ../lib.mk
+
+.PHONY: all clean
+
+CAN_BUILD_X86_64 := $(shell ../x86/check_cc.sh $(CC) \
+			    ../x86/trivial_64bit_program.c)
 
 ifndef OBJCOPY
 OBJCOPY := $(CROSS_COMPILE)objcopy
@@ -13,7 +18,9 @@ ENCL_CFLAGS := -Wall -Werror -static -nostdlib -nostartfiles -fPIC \
 
 TEST_CUSTOM_PROGS := $(OUTPUT)/test_sgx $(OUTPUT)/encl.bin
 
+ifeq ($(CAN_BUILD_X86_64), 1)
 all: $(TEST_CUSTOM_PROGS)
+endif
 
 $(OUTPUT)/test_sgx: $(OUTPUT)/main.o $(OUTPUT)/sign.o $(OUTPUT)/call.o
 	$(CC) $(HOST_CFLAGS) -o $@ $^ -lcrypto
@@ -40,4 +47,3 @@ EXTRA_CLEAN := \
 	$(OUTPUT)/test_sgx \
 	$(OUTPUT)/test_sgx.o \
 
-.PHONY: clean
tools/testing/selftests/sgx/call.S renamed from tools/testing/selftests/x86/sgx/call.S +0 -0
similarity index 100%
rename from tools/testing/selftests/x86/sgx/call.S
rename to tools/testing/selftests/sgx/call.S
tools/testing/selftests/sgx/defines.h renamed from tools/testing/selftests/x86/sgx/defines.h +2 -2
similarity index 71%
rename from tools/testing/selftests/x86/sgx/defines.h
rename to tools/testing/selftests/sgx/defines.h
index 0f91175088f6..8f4d17cf8cee 100644
@@ -13,7 +13,7 @@
 #define __aligned(x) __attribute__((__aligned__(x)))
 #define __packed __attribute__((packed))
 
-#include "../../../../../arch/x86/kernel/cpu/sgx/arch.h"
-#include "../../../../../arch/x86/include/uapi/asm/sgx.h"
+#include "../../../../arch/x86/kernel/cpu/sgx/arch.h"
+#include "../../../../arch/x86/include/uapi/asm/sgx.h"
 
 #endif /* DEFINES_H */
tools/testing/selftests/sgx/encl.c renamed from tools/testing/selftests/x86/sgx/encl.c +0 -0
similarity index 100%
rename from tools/testing/selftests/x86/sgx/encl.c
rename to tools/testing/selftests/sgx/encl.c
tools/testing/selftests/sgx/encl.lds renamed from tools/testing/selftests/x86/sgx/encl.lds +0 -0
similarity index 100%
rename from tools/testing/selftests/x86/sgx/encl.lds
rename to tools/testing/selftests/sgx/encl.lds
tools/testing/selftests/sgx/encl_bootstrap.S renamed from tools/testing/selftests/x86/sgx/encl_bootstrap.S +0 -0
similarity index 100%
rename from tools/testing/selftests/x86/sgx/encl_bootstrap.S
rename to tools/testing/selftests/sgx/encl_bootstrap.S
tools/testing/selftests/sgx/main.c renamed from tools/testing/selftests/x86/sgx/main.c +0 -0
similarity index 100%
rename from tools/testing/selftests/x86/sgx/main.c
rename to tools/testing/selftests/sgx/main.c
tools/testing/selftests/sgx/main.h renamed from tools/testing/selftests/x86/sgx/main.h +0 -0
similarity index 100%
rename from tools/testing/selftests/x86/sgx/main.h
rename to tools/testing/selftests/sgx/main.h
tools/testing/selftests/sgx/sign.c renamed from tools/testing/selftests/x86/sgx/sign.c +0 -0
similarity index 100%
rename from tools/testing/selftests/x86/sgx/sign.c
rename to tools/testing/selftests/sgx/sign.c
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 2/2] selftests/x86/sgx: Move to selftests/sgx

Quoted 10 lines · Jarkko Sakkinen

Move selftest under the top level selftests directory so that we don't need to clutter x86/Makefile. The changes made for x86/Makefile caused also issues with packaging the selftests. Finally, SGX assets need their own tailored compilation environment.

With this change BuildRoot nicely packages both standard x86 selftests and our SGX test.

Cc Sean Christopherson <[email protected]>

Promise that this my last update to selftests. Just wanted to hammer these quickly to cause minimum amount of distraction with the other patch set. Otherwise, would be very hard to focus on reviewing those chages. The changes I've done I think are no brainers. That's why I don't hold for long before merging.

/Jarkko

#3 lore raw

Re: [PATCH 2/2] selftests/x86/sgx: Move to selftests/sgx

Quoted 9 lines · Jarkko Sakkinen
Quoted 8 lines · Jarkko Sakkinen

Move selftest under the top level selftests directory so that we don't need to clutter x86/Makefile. The changes made for x86/Makefile caused also issues with packaging the selftests. Finally, SGX assets need their own tailored compilation environment.

With this change BuildRoot nicely packages both standard x86 selftests and our SGX test.

Quoted 8 lines
Quoted 2 lines
Cc Sean Christopherson <[email protected]>

Promise that this my last update to selftests. Just wanted to hammer these quickly to cause minimum amount of distraction with the other patch set. Otherwise, would be very hard to focus on reviewing those chages. The changes I've done I think are no brainers. That's why I don't hold for long before merging.

Merged:

# ./test_sgx
SUCCESS

Also:

# ls sgx
encl.bin  test_sgx
# ls x86
check_initial_reg_state_64  syscall_arg_fault_64
fsgsbase_64                 syscall_nt_64
ioperm_64                   syscall_numbering_64
iopl_64                     sysret_rip_64
mov_ss_trap_64              sysret_ss_attrs_64
protection_keys_64          test_mremap_vdso_64
sigreturn_64                test_vdso_64
single_step_syscall_64      test_vsyscall_64

/Jarkko

#4 lore raw

Re: [PATCH 2/2] selftests/x86/sgx: Move to selftests/sgx

Quoted 26 lines · Jarkko Sakkinen
Quoted 9 lines · Jarkko Sakkinen
Quoted 8 lines · Jarkko Sakkinen

Move selftest under the top level selftests directory so that we don't need to clutter x86/Makefile. The changes made for x86/Makefile caused also issues with packaging the selftests. Finally, SGX assets need their own tailored compilation environment.

With this change BuildRoot nicely packages both standard x86 selftests and our SGX test.

Quoted 8 lines
Quoted 2 lines
Cc Sean Christopherson <[email protected]>

Promise that this my last update to selftests. Just wanted to hammer these quickly to cause minimum amount of distraction with the other patch set. Otherwise, would be very hard to focus on reviewing those chages. The changes I've done I think are no brainers. That's why I don't hold for long before merging.

Merged:

# ./test_sgx
SUCCESS

Also:

Quoted 11 lines
# ls sgx
encl.bin  test_sgx
# ls x86
check_initial_reg_state_64  syscall_arg_fault_64
fsgsbase_64                 syscall_nt_64
ioperm_64                   syscall_numbering_64
iopl_64                     sysret_rip_64
mov_ss_trap_64              sysret_ss_attrs_64
protection_keys_64          test_mremap_vdso_64
sigreturn_64                test_vdso_64
single_step_syscall_64      test_vsyscall_64

Nothing else in the queue for selftests.

/Jarkko

#5 lore raw

Re: [PATCH 2/2] selftests/x86/sgx: Move to selftests/sgx

In reply to Jarkko Sakkinen
Quoted 39 lines · Jarkko Sakkinen

Move selftest under the top level selftests directory so that we don't need to clutter x86/Makefile. The changes made for x86/Makefile caused also issues with packaging the selftests. Finally, SGX assets need their own tailored compilation environment.

With this change BuildRoot nicely packages both standard x86 selftests and our SGX test.

Cc Sean Christopherson <[email protected]>
---
 tools/testing/selftests/Makefile                     |  1 +
 tools/testing/selftests/{x86 => }/sgx/.gitignore     |  0
 tools/testing/selftests/{x86 => }/sgx/Makefile       | 12 +++++++++---
 tools/testing/selftests/{x86 => }/sgx/call.S         |  0
 tools/testing/selftests/{x86 => }/sgx/defines.h      |  4 ++--
 tools/testing/selftests/{x86 => }/sgx/encl.c         |  0
 tools/testing/selftests/{x86 => }/sgx/encl.lds       |  0
 .../testing/selftests/{x86 => }/sgx/encl_bootstrap.S |  0
 tools/testing/selftests/{x86 => }/sgx/main.c         |  0
 tools/testing/selftests/{x86 => }/sgx/main.h         |  0
 tools/testing/selftests/{x86 => }/sgx/sign.c         |  0
 11 files changed, 12 insertions(+), 5 deletions(-)
 rename tools/testing/selftests/{x86 => }/sgx/.gitignore (100%)
 rename tools/testing/selftests/{x86 => }/sgx/Makefile (83%)
 rename tools/testing/selftests/{x86 => }/sgx/call.S (100%)
 rename tools/testing/selftests/{x86 => }/sgx/defines.h (71%)
 rename tools/testing/selftests/{x86 => }/sgx/encl.c (100%)
 rename tools/testing/selftests/{x86 => }/sgx/encl.lds (100%)
 rename tools/testing/selftests/{x86 => }/sgx/encl_bootstrap.S (100%)
 rename tools/testing/selftests/{x86 => }/sgx/main.c (100%)
 rename tools/testing/selftests/{x86 => }/sgx/main.h (100%)
 rename tools/testing/selftests/{x86 => }/sgx/sign.c (100%)
tools/testing/selftests/Makefile +0 -0
index 6ec503912bea..183a050b5bda 100644

tools/testing/selftests/Makefile TARGETS += user · line 66

Quoted 4 lines
tools/testing/selftests/Makefile +1 -0
@@ -63,6 +63,7 @@ TARGETS += user
 TARGETS += vm
 TARGETS += x86
 TARGETS += zram
+TARGETS += sgx

The scope of the subject for the selftest patch probably should be changed to drop the "x86" part, e.g.

selftests/sgx: Add a selftest for SGX

or
selftests: Add a selftest for SGX

instead of

selftests/x86: Add a selftest for SGX

#6 lore raw

Re: [PATCH 2/2] selftests/x86/sgx: Move to selftests/sgx

Quoted 11 lines · Sean Christopherson

The scope of the subject for the selftest patch probably should be changed to drop the "x86" part, e.g.

selftests/sgx: Add a selftest for SGX

or
selftests: Add a selftest for SGX

instead of

selftests/x86: Add a selftest for SGX

You are absolutely right as it is the change that adds the whole test suite.

/Jarkko