* [PATCH v3 0/7] Fix the reported SGX selftest makefile issues
@ 2019-08-19 13:28 Jarkko Sakkinen
2019-08-19 13:28 ` [PATCH v3 1/7] selftests/x86/sgx: Fix objcopy call in the Makefile Jarkko Sakkinen
` (7 more replies)
0 siblings, 8 replies; 15+ messages in thread
From: Jarkko Sakkinen @ 2019-08-19 13:28 UTC (permalink / raw)
To: linux-sgx
Cc: serge.ayoun, shay.katz-zamir, sean.j.christopherson, Jarkko Sakkinen
Cedric Xing reported various issues in the selftest makefiles, which are
hopefully taken care by these patches.
As the last patch this patch set contains a patch that implements the
subdirectory traversal the for the x86 selftest directory tree. This
patch is meant to be a separate patch in the main SGX patch set so that
the bindings can be reviewed separately.
v3: 1,$s/SUB_DIRS/SUBDIRS/g
v2: Added patch to implement the traversal to the subdirectories
selftest.
Jarkko Sakkinen (7):
selftests/x86/sgx: Fix objcopy call in the Makefile
selftests/x86/sgx: Do not generate object files
selftests/x86/sgx: Add -I$(OUTPUT) when compiling encl_piggy.S
selftests/x86/sgx: Fix EXTRA_CLEAN
selftests/x86/sgx: Fix target in the Makefile
selftests/x86: Revert SGX changes
selftests/x86: Recurse into subdirectories
tools/testing/selftests/x86/Makefile | 54 +++++++++++++++++++-----
tools/testing/selftests/x86/sgx/Makefile | 33 ++++++++-------
tools/testing/selftests/x86/sgx/encl.lds | 1 +
3 files changed, 63 insertions(+), 25 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v3 1/7] selftests/x86/sgx: Fix objcopy call in the Makefile
2019-08-19 13:28 [PATCH v3 0/7] Fix the reported SGX selftest makefile issues Jarkko Sakkinen
@ 2019-08-19 13:28 ` Jarkko Sakkinen
2019-08-19 13:28 ` [PATCH v3 2/7] selftests/x86/sgx: Do not generate object files Jarkko Sakkinen
` (6 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Jarkko Sakkinen @ 2019-08-19 13:28 UTC (permalink / raw)
To: linux-sgx
Cc: serge.ayoun, shay.katz-zamir, sean.j.christopherson,
Jarkko Sakkinen, Cedric Xing
Use $(OBJCOPY) to point to the correct objcopy binary. Do not discard
.got.plt because we need to detect libcalls and fail the compilation if
they exist.
Cc: Sean Christopherson <sean.j.christopherson@intel.com>
Reported-by: Cedric Xing <cedric.xing@intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
tools/testing/selftests/x86/sgx/Makefile | 6 +++++-
tools/testing/selftests/x86/sgx/encl.lds | 1 +
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/x86/sgx/Makefile b/tools/testing/selftests/x86/sgx/Makefile
index 10136b73096b..fdd67478c52b 100644
--- a/tools/testing/selftests/x86/sgx/Makefile
+++ b/tools/testing/selftests/x86/sgx/Makefile
@@ -2,6 +2,10 @@ top_srcdir = ../../../../..
include ../../lib.mk
+ifndef OBJCOPY
+OBJCOPY := $(CROSS_COMPILE)objcopy
+endif
+
HOST_CFLAGS := -Wall -Werror -g $(INCLUDES) -fPIC -z noexecstack
ENCL_CFLAGS := -Wall -Werror -static -nostdlib -nostartfiles -fPIC \
-fno-stack-protector -mrdrnd $(INCLUDES)
@@ -23,7 +27,7 @@ $(OUTPUT)/encl_piggy.o: $(OUTPUT)/encl.bin $(OUTPUT)/encl.ss
$(CC) $(HOST_CFLAGS) -c encl_piggy.S -o $@
$(OUTPUT)/encl.bin: $(OUTPUT)/encl.elf $(OUTPUT)/sgxsign
- objcopy --remove-section=.got.plt -O binary $< $@
+ $(OBJCOPY) -O binary $< $@
$(OUTPUT)/encl.elf: $(OUTPUT)/encl.o $(OUTPUT)/encl_bootstrap.o
$(CC) $(ENCL_CFLAGS) -T encl.lds -o $@ $^
diff --git a/tools/testing/selftests/x86/sgx/encl.lds b/tools/testing/selftests/x86/sgx/encl.lds
index 2ee01ac3ec79..9a56d3064104 100644
--- a/tools/testing/selftests/x86/sgx/encl.lds
+++ b/tools/testing/selftests/x86/sgx/encl.lds
@@ -31,3 +31,4 @@ ASSERT(!DEFINED(.altinstructions), "ALTERNATIVES are not supported in enclaves")
ASSERT(!DEFINED(.altinstr_replacement), "ALTERNATIVES are not supported in enclaves")
ASSERT(!DEFINED(.discard.retpoline_safe), "RETPOLINE ALTERNATIVES are not supported in enclaves")
ASSERT(!DEFINED(.discard.nospec), "RETPOLINE ALTERNATIVES are not supported in enclaves")
+ASSERT(!DEFINED(.got.plt), "Libcalls are not supported in enclaves")
--
2.20.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 2/7] selftests/x86/sgx: Do not generate object files
2019-08-19 13:28 [PATCH v3 0/7] Fix the reported SGX selftest makefile issues Jarkko Sakkinen
2019-08-19 13:28 ` [PATCH v3 1/7] selftests/x86/sgx: Fix objcopy call in the Makefile Jarkko Sakkinen
@ 2019-08-19 13:28 ` Jarkko Sakkinen
2019-08-19 13:28 ` [PATCH v3 3/7] selftests/x86/sgx: Add -I$(OUTPUT) when compiling encl_piggy.S Jarkko Sakkinen
` (5 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Jarkko Sakkinen @ 2019-08-19 13:28 UTC (permalink / raw)
To: linux-sgx
Cc: serge.ayoun, shay.katz-zamir, sean.j.christopherson,
Jarkko Sakkinen, Cedric Xing
Invoke GCC in a way that it generates and links the binary in a single
step because we do not need the side products. Additionally, add a
missing dependency to encls.lds (i.e. make did not do anything if
encls.lds was changed).
Reported-by: Cedric Xing <cedric.xing@intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
tools/testing/selftests/x86/sgx/Makefile | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/tools/testing/selftests/x86/sgx/Makefile b/tools/testing/selftests/x86/sgx/Makefile
index fdd67478c52b..b96aff1a7fba 100644
--- a/tools/testing/selftests/x86/sgx/Makefile
+++ b/tools/testing/selftests/x86/sgx/Makefile
@@ -29,14 +29,8 @@ $(OUTPUT)/encl_piggy.o: $(OUTPUT)/encl.bin $(OUTPUT)/encl.ss
$(OUTPUT)/encl.bin: $(OUTPUT)/encl.elf $(OUTPUT)/sgxsign
$(OBJCOPY) -O binary $< $@
-$(OUTPUT)/encl.elf: $(OUTPUT)/encl.o $(OUTPUT)/encl_bootstrap.o
- $(CC) $(ENCL_CFLAGS) -T encl.lds -o $@ $^
-
-$(OUTPUT)/encl.o: encl.c
- $(CC) $(ENCL_CFLAGS) -c $< -o $@
-
-$(OUTPUT)/encl_bootstrap.o: encl_bootstrap.S
- $(CC) $(ENCL_CFLAGS) -c $< -o $@
+$(OUTPUT)/encl.elf: encl.lds encl.c encl_bootstrap.S
+ $(CC) $(ENCL_CFLAGS) -T $^ -o $@
$(OUTPUT)/encl.ss: $(OUTPUT)/encl.bin $(OUTPUT)/sgxsign
$(OUTPUT)/sgxsign signing_key.pem $(OUTPUT)/encl.bin $(OUTPUT)/encl.ss
--
2.20.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 3/7] selftests/x86/sgx: Add -I$(OUTPUT) when compiling encl_piggy.S
2019-08-19 13:28 [PATCH v3 0/7] Fix the reported SGX selftest makefile issues Jarkko Sakkinen
2019-08-19 13:28 ` [PATCH v3 1/7] selftests/x86/sgx: Fix objcopy call in the Makefile Jarkko Sakkinen
2019-08-19 13:28 ` [PATCH v3 2/7] selftests/x86/sgx: Do not generate object files Jarkko Sakkinen
@ 2019-08-19 13:28 ` Jarkko Sakkinen
2019-08-19 13:28 ` [PATCH v3 4/7] selftests/x86/sgx: Fix EXTRA_CLEAN Jarkko Sakkinen
` (4 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Jarkko Sakkinen @ 2019-08-19 13:28 UTC (permalink / raw)
To: linux-sgx
Cc: serge.ayoun, shay.katz-zamir, sean.j.christopherson,
Jarkko Sakkinen, Cedric Xing
We need to the build output directory to the include path when compiling
encl_piggy.S because otherwise the compiler can't reliably find encl.bin
and encl.ss.
Reported-by: Cedric Xing <cedric.xing@intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
tools/testing/selftests/x86/sgx/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/x86/sgx/Makefile b/tools/testing/selftests/x86/sgx/Makefile
index b96aff1a7fba..0b8813cc0b7f 100644
--- a/tools/testing/selftests/x86/sgx/Makefile
+++ b/tools/testing/selftests/x86/sgx/Makefile
@@ -24,7 +24,7 @@ $(OUTPUT)/sgx_call.o: sgx_call.S
$(CC) $(HOST_CFLAGS) -c $< -o $@
$(OUTPUT)/encl_piggy.o: $(OUTPUT)/encl.bin $(OUTPUT)/encl.ss
- $(CC) $(HOST_CFLAGS) -c encl_piggy.S -o $@
+ $(CC) $(HOST_CFLAGS) -I$(OUTPUT) -c encl_piggy.S -o $@
$(OUTPUT)/encl.bin: $(OUTPUT)/encl.elf $(OUTPUT)/sgxsign
$(OBJCOPY) -O binary $< $@
--
2.20.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 4/7] selftests/x86/sgx: Fix EXTRA_CLEAN
2019-08-19 13:28 [PATCH v3 0/7] Fix the reported SGX selftest makefile issues Jarkko Sakkinen
` (2 preceding siblings ...)
2019-08-19 13:28 ` [PATCH v3 3/7] selftests/x86/sgx: Add -I$(OUTPUT) when compiling encl_piggy.S Jarkko Sakkinen
@ 2019-08-19 13:28 ` Jarkko Sakkinen
2019-08-19 13:28 ` [PATCH v3 5/7] selftests/x86/sgx: Fix target in the Makefile Jarkko Sakkinen
` (3 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Jarkko Sakkinen @ 2019-08-19 13:28 UTC (permalink / raw)
To: linux-sgx
Cc: serge.ayoun, shay.katz-zamir, sean.j.christopherson,
Jarkko Sakkinen, Cedric Xing
1. Add missing build products to EXTRA_CLEAN.
2. Remove non-existent build products from EXTRA_CLEAN.
Reported-by: Cedric Xing <cedric.xing@intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
tools/testing/selftests/x86/sgx/Makefile | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/x86/sgx/Makefile b/tools/testing/selftests/x86/sgx/Makefile
index 0b8813cc0b7f..0f1c50c347d7 100644
--- a/tools/testing/selftests/x86/sgx/Makefile
+++ b/tools/testing/selftests/x86/sgx/Makefile
@@ -38,9 +38,14 @@ $(OUTPUT)/encl.ss: $(OUTPUT)/encl.bin $(OUTPUT)/sgxsign
$(OUTPUT)/sgxsign: sgxsign.c
$(CC) -o $@ $< -lcrypto
-EXTRA_CLEAN := $(OUTPUT)/sgx-selftest $(OUTPUT)/sgx-selftest.o \
- $(OUTPUT)/sgx_call.o $(OUTPUT)/encl.bin $(OUTPUT)/encl.ss \
- $(OUTPUT)/encl.elf $(OUTPUT)/encl.o $(OUTPUT)/encl_bootstrap.o \
- $(OUTPUT)/sgxsign
+EXTRA_CLEAN := \
+ $(OUTPUT)/encl.bin \
+ $(OUTPUT)/encl_piggy.o \
+ $(OUTPUT)/encl.elf \
+ $(OUTPUT)/encl.ss \
+ $(OUTPUT)/sgx_call.o \
+ $(OUTPUT)/sgxsign \
+ $(OUTPUT)/test_sgx \
+ $(OUTPUT)/test_sgx.o \
.PHONY: clean
--
2.20.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 5/7] selftests/x86/sgx: Fix target in the Makefile
2019-08-19 13:28 [PATCH v3 0/7] Fix the reported SGX selftest makefile issues Jarkko Sakkinen
` (3 preceding siblings ...)
2019-08-19 13:28 ` [PATCH v3 4/7] selftests/x86/sgx: Fix EXTRA_CLEAN Jarkko Sakkinen
@ 2019-08-19 13:28 ` Jarkko Sakkinen
2019-08-19 13:28 ` [PATCH v3 6/7] selftests/x86: Revert SGX changes Jarkko Sakkinen
` (2 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Jarkko Sakkinen @ 2019-08-19 13:28 UTC (permalink / raw)
To: linux-sgx
Cc: serge.ayoun, shay.katz-zamir, sean.j.christopherson, Jarkko Sakkinen
The target should be "all", not "all_64".
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
tools/testing/selftests/x86/sgx/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/x86/sgx/Makefile b/tools/testing/selftests/x86/sgx/Makefile
index 0f1c50c347d7..4310a5b6ecc7 100644
--- a/tools/testing/selftests/x86/sgx/Makefile
+++ b/tools/testing/selftests/x86/sgx/Makefile
@@ -11,7 +11,7 @@ ENCL_CFLAGS := -Wall -Werror -static -nostdlib -nostartfiles -fPIC \
-fno-stack-protector -mrdrnd $(INCLUDES)
TEST_CUSTOM_PROGS := $(OUTPUT)/test_sgx
-all_64: $(TEST_CUSTOM_PROGS)
+all: $(TEST_CUSTOM_PROGS)
$(TEST_CUSTOM_PROGS): $(OUTPUT)/main.o $(OUTPUT)/sgx_call.o \
$(OUTPUT)/encl_piggy.o
--
2.20.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 6/7] selftests/x86: Revert SGX changes
2019-08-19 13:28 [PATCH v3 0/7] Fix the reported SGX selftest makefile issues Jarkko Sakkinen
` (4 preceding siblings ...)
2019-08-19 13:28 ` [PATCH v3 5/7] selftests/x86/sgx: Fix target in the Makefile Jarkko Sakkinen
@ 2019-08-19 13:28 ` Jarkko Sakkinen
2019-08-19 13:28 ` [PATCH v3 7/7] selftests/x86: Recurse into subdirectories Jarkko Sakkinen
2019-08-22 3:31 ` [PATCH v3 0/7] Fix the reported SGX selftest makefile issues Sean Christopherson
7 siblings, 0 replies; 15+ messages in thread
From: Jarkko Sakkinen @ 2019-08-19 13:28 UTC (permalink / raw)
To: linux-sgx
Cc: serge.ayoun, shay.katz-zamir, sean.j.christopherson, Jarkko Sakkinen
The SGX changes are incorrect in the makefile but the more important
reason to revert the SGX changes is that we can split the binding
to a separate commit in our main patch set.
There is a design choice to be made whether to bound the selftest by
recursing from the x86 makefile or alternatively have it added to
TARGETS (i.e. TARGET += "x86/sgx"). Thus, the change that implements
the binding must a be a separate commit.
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
tools/testing/selftests/x86/Makefile | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile
index a1831406fd01..fa07d526fe39 100644
--- a/tools/testing/selftests/x86/Makefile
+++ b/tools/testing/selftests/x86/Makefile
@@ -1,7 +1,4 @@
# SPDX-License-Identifier: GPL-2.0
-
-SUBDIRS_64 := sgx
-
all:
include ../lib.mk
@@ -71,13 +68,6 @@ all_32: $(BINARIES_32)
all_64: $(BINARIES_64)
-all_64: $(SUBDIRS_64)
- @for DIR in $(SUBDIRS_64); do \
- BUILD_TARGET=$(OUTPUT)/$$DIR; \
- mkdir $$BUILD_TARGET -p; \
- make OUTPUT=$$BUILD_TARGET -C $$DIR $@; \
- done
-
EXTRA_CLEAN := $(BINARIES_32) $(BINARIES_64)
$(BINARIES_32): $(OUTPUT)/%_32: %.c
--
2.20.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 7/7] selftests/x86: Recurse into subdirectories
2019-08-19 13:28 [PATCH v3 0/7] Fix the reported SGX selftest makefile issues Jarkko Sakkinen
` (5 preceding siblings ...)
2019-08-19 13:28 ` [PATCH v3 6/7] selftests/x86: Revert SGX changes Jarkko Sakkinen
@ 2019-08-19 13:28 ` Jarkko Sakkinen
2019-08-22 3:42 ` Sean Christopherson
2019-08-22 3:31 ` [PATCH v3 0/7] Fix the reported SGX selftest makefile issues Sean Christopherson
7 siblings, 1 reply; 15+ messages in thread
From: Jarkko Sakkinen @ 2019-08-19 13:28 UTC (permalink / raw)
To: linux-sgx
Cc: serge.ayoun, shay.katz-zamir, sean.j.christopherson, Jarkko Sakkinen
Recurse into a list of subdirectories defined by SUBDIRS when running
x86 selftests. Override run_tests, install, emit_tests and clean
targets to implement this behaviour.
A possible alternative would be to add "x86/sgx" to TARGETS. However,
this would be problematic because detecting 64-bit build would have
to duplicated.
The implementation is derived from the makefiles of powerpc and sparc64
selftests.
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
tools/testing/selftests/x86/Makefile | 44 ++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile
index fa07d526fe39..80571bac8ed5 100644
--- a/tools/testing/selftests/x86/Makefile
+++ b/tools/testing/selftests/x86/Makefile
@@ -10,6 +10,8 @@ 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 mpx-mini-test ioperm \
protection_keys test_vdso test_vsyscall mov_ss_trap \
@@ -59,6 +61,48 @@ 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))))
--
2.20.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v3 0/7] Fix the reported SGX selftest makefile issues
2019-08-19 13:28 [PATCH v3 0/7] Fix the reported SGX selftest makefile issues Jarkko Sakkinen
` (6 preceding siblings ...)
2019-08-19 13:28 ` [PATCH v3 7/7] selftests/x86: Recurse into subdirectories Jarkko Sakkinen
@ 2019-08-22 3:31 ` Sean Christopherson
2019-08-22 14:58 ` Jarkko Sakkinen
7 siblings, 1 reply; 15+ messages in thread
From: Sean Christopherson @ 2019-08-22 3:31 UTC (permalink / raw)
To: Jarkko Sakkinen; +Cc: linux-sgx, serge.ayoun, shay.katz-zamir
On Mon, Aug 19, 2019 at 04:28:23PM +0300, Jarkko Sakkinen wrote:
> Cedric Xing reported various issues in the selftest makefiles, which are
> hopefully taken care by these patches.
>
> As the last patch this patch set contains a patch that implements the
> subdirectory traversal the for the x86 selftest directory tree. This
> patch is meant to be a separate patch in the main SGX patch set so that
> the bindings can be reviewed separately.
Doesn't have to be this series, but the build artifacts should be added
to .gitignore.
Untracked files:
(use "git add <file>..." to include in what will be committed)
sgx/encl.ss
sgx/sgxsign
sgx/test_sgx
>
> v3: 1,$s/SUB_DIRS/SUBDIRS/g
> v2: Added patch to implement the traversal to the subdirectories
> selftest.
>
> Jarkko Sakkinen (7):
> selftests/x86/sgx: Fix objcopy call in the Makefile
> selftests/x86/sgx: Do not generate object files
> selftests/x86/sgx: Add -I$(OUTPUT) when compiling encl_piggy.S
> selftests/x86/sgx: Fix EXTRA_CLEAN
> selftests/x86/sgx: Fix target in the Makefile
> selftests/x86: Revert SGX changes
> selftests/x86: Recurse into subdirectories
>
> tools/testing/selftests/x86/Makefile | 54 +++++++++++++++++++-----
> tools/testing/selftests/x86/sgx/Makefile | 33 ++++++++-------
> tools/testing/selftests/x86/sgx/encl.lds | 1 +
> 3 files changed, 63 insertions(+), 25 deletions(-)
>
> --
> 2.20.1
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3 7/7] selftests/x86: Recurse into subdirectories
2019-08-19 13:28 ` [PATCH v3 7/7] selftests/x86: Recurse into subdirectories Jarkko Sakkinen
@ 2019-08-22 3:42 ` Sean Christopherson
2019-08-22 14:59 ` Jarkko Sakkinen
0 siblings, 1 reply; 15+ messages in thread
From: Sean Christopherson @ 2019-08-22 3:42 UTC (permalink / raw)
To: Jarkko Sakkinen; +Cc: linux-sgx, serge.ayoun, shay.katz-zamir
On Mon, Aug 19, 2019 at 04:28:30PM +0300, Jarkko Sakkinen wrote:
> Recurse into a list of subdirectories defined by SUBDIRS when running
> x86 selftests. Override run_tests, install, emit_tests and clean
> targets to implement this behaviour.
The code looks good (which doesn't say much, my Makefile knowledge is
garbage), but the result is a bit odd. x86/sgx doesn't implement
emit_tests (or at least test_sgx doesn't show up), while the rest of the
x86 tests don't support install.
AFAICT the Makefile is itself weird; it's definitely different than other
selftests Makfiles. I don't see any reason to delay this patch, but it
feels like something here needs to be cleaned up.
> A possible alternative would be to add "x86/sgx" to TARGETS. However,
> this would be problematic because detecting 64-bit build would have
> to duplicated.
>
> The implementation is derived from the makefiles of powerpc and sparc64
> selftests.
>
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> ---
> tools/testing/selftests/x86/Makefile | 44 ++++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile
> index fa07d526fe39..80571bac8ed5 100644
> --- a/tools/testing/selftests/x86/Makefile
> +++ b/tools/testing/selftests/x86/Makefile
> @@ -10,6 +10,8 @@ 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 mpx-mini-test ioperm \
> protection_keys test_vdso test_vsyscall mov_ss_trap \
> @@ -59,6 +61,48 @@ 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))))
> --
> 2.20.1
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3 0/7] Fix the reported SGX selftest makefile issues
2019-08-22 3:31 ` [PATCH v3 0/7] Fix the reported SGX selftest makefile issues Sean Christopherson
@ 2019-08-22 14:58 ` Jarkko Sakkinen
0 siblings, 0 replies; 15+ messages in thread
From: Jarkko Sakkinen @ 2019-08-22 14:58 UTC (permalink / raw)
To: Sean Christopherson; +Cc: linux-sgx, serge.ayoun, shay.katz-zamir
On Wed, 2019-08-21 at 20:31 -0700, Sean Christopherson wrote:
> On Mon, Aug 19, 2019 at 04:28:23PM +0300, Jarkko Sakkinen wrote:
> > Cedric Xing reported various issues in the selftest makefiles, which are
> > hopefully taken care by these patches.
> >
> > As the last patch this patch set contains a patch that implements the
> > subdirectory traversal the for the x86 selftest directory tree. This
> > patch is meant to be a separate patch in the main SGX patch set so that
> > the bindings can be reviewed separately.
>
> Doesn't have to be this series, but the build artifacts should be added
> to .gitignore.
>
> Untracked files:
> (use "git add <file>..." to include in what will be committed)
>
> sgx/encl.ss
> sgx/sgxsign
> sgx/test_sgx
Oh, good catch. Lets do it as a separate patch after I've squashed
everything.
/Jarkko
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3 7/7] selftests/x86: Recurse into subdirectories
2019-08-22 3:42 ` Sean Christopherson
@ 2019-08-22 14:59 ` Jarkko Sakkinen
2019-08-22 15:02 ` Jarkko Sakkinen
0 siblings, 1 reply; 15+ messages in thread
From: Jarkko Sakkinen @ 2019-08-22 14:59 UTC (permalink / raw)
To: Sean Christopherson; +Cc: linux-sgx, serge.ayoun, shay.katz-zamir
On Wed, 2019-08-21 at 20:42 -0700, Sean Christopherson wrote:
> On Mon, Aug 19, 2019 at 04:28:30PM +0300, Jarkko Sakkinen wrote:
> > Recurse into a list of subdirectories defined by SUBDIRS when running
> > x86 selftests. Override run_tests, install, emit_tests and clean
> > targets to implement this behaviour.
>
> The code looks good (which doesn't say much, my Makefile knowledge is
> garbage), but the result is a bit odd. x86/sgx doesn't implement
> emit_tests (or at least test_sgx doesn't show up), while the rest of the
> x86 tests don't support install.
>
> AFAICT the Makefile is itself weird; it's definitely different than other
> selftests Makfiles. I don't see any reason to delay this patch, but it
> feels like something here needs to be cleaned up.
Lets fix emit_tests before sending v22.
/Jarkko
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3 7/7] selftests/x86: Recurse into subdirectories
2019-08-22 14:59 ` Jarkko Sakkinen
@ 2019-08-22 15:02 ` Jarkko Sakkinen
2019-08-22 16:13 ` Jarkko Sakkinen
0 siblings, 1 reply; 15+ messages in thread
From: Jarkko Sakkinen @ 2019-08-22 15:02 UTC (permalink / raw)
To: Sean Christopherson; +Cc: linux-sgx, serge.ayoun, shay.katz-zamir
On Thu, 2019-08-22 at 17:59 +0300, Jarkko Sakkinen wrote:
> On Wed, 2019-08-21 at 20:42 -0700, Sean Christopherson wrote:
> > On Mon, Aug 19, 2019 at 04:28:30PM +0300, Jarkko Sakkinen wrote:
> > > Recurse into a list of subdirectories defined by SUBDIRS when running
> > > x86 selftests. Override run_tests, install, emit_tests and clean
> > > targets to implement this behaviour.
> >
> > The code looks good (which doesn't say much, my Makefile knowledge is
> > garbage), but the result is a bit odd. x86/sgx doesn't implement
> > emit_tests (or at least test_sgx doesn't show up), while the rest of the
> > x86 tests don't support install.
> >
> > AFAICT the Makefile is itself weird; it's definitely different than other
> > selftests Makfiles. I don't see any reason to delay this patch, but it
> > feels like something here needs to be cleaned up.
>
> Lets fix emit_tests before sending v22.
Selftest patches have been squahed. Further improvements are welcome.
Thanks for the review!
/Jarkko
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3 7/7] selftests/x86: Recurse into subdirectories
2019-08-22 15:02 ` Jarkko Sakkinen
@ 2019-08-22 16:13 ` Jarkko Sakkinen
2019-08-22 16:14 ` Jarkko Sakkinen
0 siblings, 1 reply; 15+ messages in thread
From: Jarkko Sakkinen @ 2019-08-22 16:13 UTC (permalink / raw)
To: Sean Christopherson; +Cc: linux-sgx, serge.ayoun, shay.katz-zamir
On Thu, 2019-08-22 at 18:02 +0300, Jarkko Sakkinen wrote:
> On Thu, 2019-08-22 at 17:59 +0300, Jarkko Sakkinen wrote:
> > On Wed, 2019-08-21 at 20:42 -0700, Sean Christopherson wrote:
> > > On Mon, Aug 19, 2019 at 04:28:30PM +0300, Jarkko Sakkinen wrote:
> > > > Recurse into a list of subdirectories defined by SUBDIRS when running
> > > > x86 selftests. Override run_tests, install, emit_tests and clean
> > > > targets to implement this behaviour.
> > >
> > > The code looks good (which doesn't say much, my Makefile knowledge is
> > > garbage), but the result is a bit odd. x86/sgx doesn't implement
> > > emit_tests (or at least test_sgx doesn't show up), while the rest of the
> > > x86 tests don't support install.
> > >
> > > AFAICT the Makefile is itself weird; it's definitely different than other
> > > selftests Makfiles. I don't see any reason to delay this patch, but it
> > > feels like something here needs to be cleaned up.
> >
> > Lets fix emit_tests before sending v22.
>
> Selftest patches have been squahed. Further improvements are welcome.
> Thanks for the review!
At least my use case is satisfied with these fixes:
$ ls output/target/usr/lib/kselftests/x86
test_sgx
I can build initramfs now with the selftest bundled. Oddly enough none of the
other x86 selftests get included.
/Jarkko
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3 7/7] selftests/x86: Recurse into subdirectories
2019-08-22 16:13 ` Jarkko Sakkinen
@ 2019-08-22 16:14 ` Jarkko Sakkinen
0 siblings, 0 replies; 15+ messages in thread
From: Jarkko Sakkinen @ 2019-08-22 16:14 UTC (permalink / raw)
To: Sean Christopherson; +Cc: linux-sgx, serge.ayoun, shay.katz-zamir
On Thu, 2019-08-22 at 19:13 +0300, Jarkko Sakkinen wrote:
> On Thu, 2019-08-22 at 18:02 +0300, Jarkko Sakkinen wrote:
> > On Thu, 2019-08-22 at 17:59 +0300, Jarkko Sakkinen wrote:
> > > On Wed, 2019-08-21 at 20:42 -0700, Sean Christopherson wrote:
> > > > On Mon, Aug 19, 2019 at 04:28:30PM +0300, Jarkko Sakkinen wrote:
> > > > > Recurse into a list of subdirectories defined by SUBDIRS when running
> > > > > x86 selftests. Override run_tests, install, emit_tests and clean
> > > > > targets to implement this behaviour.
> > > >
> > > > The code looks good (which doesn't say much, my Makefile knowledge is
> > > > garbage), but the result is a bit odd. x86/sgx doesn't implement
> > > > emit_tests (or at least test_sgx doesn't show up), while the rest of the
> > > > x86 tests don't support install.
> > > >
> > > > AFAICT the Makefile is itself weird; it's definitely different than other
> > > > selftests Makfiles. I don't see any reason to delay this patch, but it
> > > > feels like something here needs to be cleaned up.
> > >
> > > Lets fix emit_tests before sending v22.
> >
> > Selftest patches have been squahed. Further improvements are welcome.
> > Thanks for the review!
>
> At least my use case is satisfied with these fixes:
>
> $ ls output/target/usr/lib/kselftests/x86
> test_sgx
>
> I can build initramfs now with the selftest bundled. Oddly enough none of the
> other x86 selftests get included.
# ls /usr/lib/kselftests/x86
test_sgx
# /usr/lib/kselftests/x86/test_sgx
Binary size 24576 (0x6000), SIGSTRUCT size 1808
Loading the enclave.
Input: 0x1122334455667788
Output: 0x1122334455667788
This is a big improvement for me :-) Do not have to upload selftest anymore
with minicom or scp.
/Jarkko
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2019-08-22 16:14 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-19 13:28 [PATCH v3 0/7] Fix the reported SGX selftest makefile issues Jarkko Sakkinen
2019-08-19 13:28 ` [PATCH v3 1/7] selftests/x86/sgx: Fix objcopy call in the Makefile Jarkko Sakkinen
2019-08-19 13:28 ` [PATCH v3 2/7] selftests/x86/sgx: Do not generate object files Jarkko Sakkinen
2019-08-19 13:28 ` [PATCH v3 3/7] selftests/x86/sgx: Add -I$(OUTPUT) when compiling encl_piggy.S Jarkko Sakkinen
2019-08-19 13:28 ` [PATCH v3 4/7] selftests/x86/sgx: Fix EXTRA_CLEAN Jarkko Sakkinen
2019-08-19 13:28 ` [PATCH v3 5/7] selftests/x86/sgx: Fix target in the Makefile Jarkko Sakkinen
2019-08-19 13:28 ` [PATCH v3 6/7] selftests/x86: Revert SGX changes Jarkko Sakkinen
2019-08-19 13:28 ` [PATCH v3 7/7] selftests/x86: Recurse into subdirectories Jarkko Sakkinen
2019-08-22 3:42 ` Sean Christopherson
2019-08-22 14:59 ` Jarkko Sakkinen
2019-08-22 15:02 ` Jarkko Sakkinen
2019-08-22 16:13 ` Jarkko Sakkinen
2019-08-22 16:14 ` Jarkko Sakkinen
2019-08-22 3:31 ` [PATCH v3 0/7] Fix the reported SGX selftest makefile issues Sean Christopherson
2019-08-22 14:58 ` Jarkko Sakkinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).