* [PATCH for_v25 1/4] selftests/x86: Fix INCLUDES definition in SGX Makefile
2019-12-20 22:54 [PATCH for_v25 0/4] selftests/x86: x86/sgx: Minor selftest cleanup Sean Christopherson
@ 2019-12-20 22:54 ` Sean Christopherson
2019-12-20 22:54 ` [PATCH for_v25 2/4] x86/sgx: Add missing linux/bits.h include in sgx/arch.h Sean Christopherson
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Sean Christopherson @ 2019-12-20 22:54 UTC (permalink / raw)
To: Jarkko Sakkinen; +Cc: linux-sgx
Define INCLUDES to reference the top-level tools/include when building
SGX selftests in preparation of adding a missing linux/bits.h include
in sgx/arch.h.
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
tools/testing/selftests/x86/sgx/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/x86/sgx/Makefile b/tools/testing/selftests/x86/sgx/Makefile
index a09ef5f965dc..f838700029e2 100644
--- a/tools/testing/selftests/x86/sgx/Makefile
+++ b/tools/testing/selftests/x86/sgx/Makefile
@@ -6,6 +6,7 @@ ifndef OBJCOPY
OBJCOPY := $(CROSS_COMPILE)objcopy
endif
+INCLUDES := -I$(top_srcdir)/tools/include
HOST_CFLAGS := -Wall -Werror -g $(INCLUDES) -fPIC -z noexecstack
ENCL_CFLAGS := -Wall -Werror -static -nostdlib -nostartfiles -fPIC \
-fno-stack-protector -mrdrnd $(INCLUDES)
@@ -33,7 +34,7 @@ $(OUTPUT)/encl.ss: $(OUTPUT)/encl.bin
$(OUTPUT)/sgxsign signing_key.pem $(OUTPUT)/encl.bin $(OUTPUT)/encl.ss
$(OUTPUT)/sgxsign: sgxsign.c
- $(CC) -o $@ $< -lcrypto
+ $(CC) $(INCLUDES) -o $@ $< -lcrypto
EXTRA_CLEAN := \
$(OUTPUT)/encl.bin \
--
2.24.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH for_v25 2/4] x86/sgx: Add missing linux/bits.h include in sgx/arch.h
2019-12-20 22:54 [PATCH for_v25 0/4] selftests/x86: x86/sgx: Minor selftest cleanup Sean Christopherson
2019-12-20 22:54 ` [PATCH for_v25 1/4] selftests/x86: Fix INCLUDES definition in SGX Makefile Sean Christopherson
@ 2019-12-20 22:54 ` Sean Christopherson
2019-12-20 22:55 ` [PATCH for_v25 3/4] selftests/x86: Add .gitignore for SGX selftest Sean Christopherson
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Sean Christopherson @ 2019-12-20 22:54 UTC (permalink / raw)
To: Jarkko Sakkinen; +Cc: linux-sgx
Include linux/bits.h for its defitions of BIT() and GENMASK*().
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
arch/x86/kernel/cpu/sgx/arch.h | 1 +
tools/testing/selftests/x86/sgx/defines.h | 22 ----------------------
2 files changed, 1 insertion(+), 22 deletions(-)
diff --git a/arch/x86/kernel/cpu/sgx/arch.h b/arch/x86/kernel/cpu/sgx/arch.h
index 7a5d24b4d1bb..dbd652be9b53 100644
--- a/arch/x86/kernel/cpu/sgx/arch.h
+++ b/arch/x86/kernel/cpu/sgx/arch.h
@@ -8,6 +8,7 @@
#ifndef _ASM_X86_SGX_ARCH_H
#define _ASM_X86_SGX_ARCH_H
+#include <linux/bits.h>
#include <linux/types.h>
#define SGX_CPUID 0x12
diff --git a/tools/testing/selftests/x86/sgx/defines.h b/tools/testing/selftests/x86/sgx/defines.h
index 1e67f2f29f42..87264f85cb9f 100644
--- a/tools/testing/selftests/x86/sgx/defines.h
+++ b/tools/testing/selftests/x86/sgx/defines.h
@@ -8,31 +8,9 @@
#include <stdint.h>
-typedef uint8_t u8;
-typedef uint16_t u16;
-typedef uint32_t u32;
-typedef uint64_t u64;
-
#define __aligned(x) __attribute__((__aligned__(x)))
#define __packed __attribute__((packed))
-/* Derived from asm-generic/bitsperlong.h. */
-#if __x86_64__
-#define BITS_PER_LONG 64
-#else
-#define BITS_PER_LONG 32
-#endif
-#define BITS_PER_LONG_LONG 64
-
-/* Taken from linux/bits.h. */
-#define BIT(nr) (1UL << (nr))
-#define BIT_ULL(nr) (1ULL << (nr))
-#define GENMASK(h, l) \
- (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
-#define GENMASK_ULL(h, l) \
- (((~0ULL) - (1ULL << (l)) + 1) & \
- (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
-
#include "../../../../../arch/x86/kernel/cpu/sgx/arch.h"
#include "../../../../../arch/x86/include/uapi/asm/sgx.h"
--
2.24.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH for_v25 3/4] selftests/x86: Add .gitignore for SGX selftest
2019-12-20 22:54 [PATCH for_v25 0/4] selftests/x86: x86/sgx: Minor selftest cleanup Sean Christopherson
2019-12-20 22:54 ` [PATCH for_v25 1/4] selftests/x86: Fix INCLUDES definition in SGX Makefile Sean Christopherson
2019-12-20 22:54 ` [PATCH for_v25 2/4] x86/sgx: Add missing linux/bits.h include in sgx/arch.h Sean Christopherson
@ 2019-12-20 22:55 ` Sean Christopherson
2019-12-20 22:55 ` [PATCH for_v25 4/4] selftests/x86: Remove redundant kernel include Sean Christopherson
2020-01-02 16:49 ` [PATCH for_v25 0/4] selftests/x86: x86/sgx: Minor selftest cleanup Jarkko Sakkinen
4 siblings, 0 replies; 6+ messages in thread
From: Sean Christopherson @ 2019-12-20 22:55 UTC (permalink / raw)
To: Jarkko Sakkinen; +Cc: linux-sgx
Add a .gitignore for SGX to ignore its build output.
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
tools/testing/selftests/x86/sgx/.gitignore | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 tools/testing/selftests/x86/sgx/.gitignore
diff --git a/tools/testing/selftests/x86/sgx/.gitignore b/tools/testing/selftests/x86/sgx/.gitignore
new file mode 100644
index 000000000000..98eb2d439606
--- /dev/null
+++ b/tools/testing/selftests/x86/sgx/.gitignore
@@ -0,0 +1,3 @@
+encl.ss
+sgxsign
+test_sgx
--
2.24.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH for_v25 4/4] selftests/x86: Remove redundant kernel include
2019-12-20 22:54 [PATCH for_v25 0/4] selftests/x86: x86/sgx: Minor selftest cleanup Sean Christopherson
` (2 preceding siblings ...)
2019-12-20 22:55 ` [PATCH for_v25 3/4] selftests/x86: Add .gitignore for SGX selftest Sean Christopherson
@ 2019-12-20 22:55 ` Sean Christopherson
2020-01-02 16:49 ` [PATCH for_v25 0/4] selftests/x86: x86/sgx: Minor selftest cleanup Jarkko Sakkinen
4 siblings, 0 replies; 6+ messages in thread
From: Sean Christopherson @ 2019-12-20 22:55 UTC (permalink / raw)
To: Jarkko Sakkinen; +Cc: linux-sgx
The SGX selftests incorporate any and all necessary kernel includes in
defines.h, remove redundant includes from main.c so that the obnoxiously
long paths don't need to be updated if the kernel files are renamed.
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
tools/testing/selftests/x86/sgx/main.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/tools/testing/selftests/x86/sgx/main.c b/tools/testing/selftests/x86/sgx/main.c
index a94ba894b020..d97cc3cf0093 100644
--- a/tools/testing/selftests/x86/sgx/main.c
+++ b/tools/testing/selftests/x86/sgx/main.c
@@ -16,8 +16,6 @@
#include <sys/time.h>
#include <sys/types.h>
#include "defines.h"
-#include "../../../../../arch/x86/kernel/cpu/sgx/arch.h"
-#include "../../../../../arch/x86/include/uapi/asm/sgx.h"
#include "sgx_call.h"
#define PAGE_SIZE 4096
--
2.24.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH for_v25 0/4] selftests/x86: x86/sgx: Minor selftest cleanup
2019-12-20 22:54 [PATCH for_v25 0/4] selftests/x86: x86/sgx: Minor selftest cleanup Sean Christopherson
` (3 preceding siblings ...)
2019-12-20 22:55 ` [PATCH for_v25 4/4] selftests/x86: Remove redundant kernel include Sean Christopherson
@ 2020-01-02 16:49 ` Jarkko Sakkinen
4 siblings, 0 replies; 6+ messages in thread
From: Jarkko Sakkinen @ 2020-01-02 16:49 UTC (permalink / raw)
To: Sean Christopherson; +Cc: linux-sgx
On Fri, Dec 20, 2019 at 02:54:57PM -0800, Sean Christopherson wrote:
> Add a .gitignore entry for the selftests and cleanup the includes to remove
> some homebrewed definitions in sgx/defines.h.
>
> Sean Christopherson (4):
> selftests/x86: Fix INCLUDES definition in SGX Makefile
> x86/sgx: Add missing linux/bits.h include in sgx/arch.h
> selftests/x86: Add .gitignore for SGX selftest
> selftests/x86: Remove redundant kernel include
>
> arch/x86/kernel/cpu/sgx/arch.h | 1 +
> tools/testing/selftests/x86/sgx/.gitignore | 3 +++
> tools/testing/selftests/x86/sgx/Makefile | 3 ++-
> tools/testing/selftests/x86/sgx/defines.h | 22 ----------------------
> tools/testing/selftests/x86/sgx/main.c | 2 --
> 5 files changed, 6 insertions(+), 25 deletions(-)
> create mode 100644 tools/testing/selftests/x86/sgx/.gitignore
>
> --
> 2.24.1
>
Thank you. I merged everything.
/Jarkko
^ permalink raw reply [flat|nested] 6+ messages in thread