diff mbox series

[for_v37,4/6] selftests/sgx: Update the SGX selftest to match the reworked vDSO API

Message ID 20200904104437.29555-5-sean.j.christopherson@intel.com (mailing list archive)
State New, archived
Headers show
Series x86/vdso: x86/sgx: Rework SGX vDSO API | expand

Commit Message

Sean Christopherson Sept. 4, 2020, 10:44 a.m. UTC
Update the call to __vdso_sgx_enter_enclave() to use the sgx_enclave_run
struct instead of cramming parameters into the function call itself.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 tools/testing/selftests/sgx/call.S | 10 +++-------
 tools/testing/selftests/sgx/main.c | 11 +++++------
 tools/testing/selftests/sgx/main.h |  2 +-
 3 files changed, 9 insertions(+), 14 deletions(-)

Comments

Jarkko Sakkinen Sept. 4, 2020, 2:07 p.m. UTC | #1
On Fri, Sep 04, 2020 at 03:44:35AM -0700, Sean Christopherson wrote:
> Update the call to __vdso_sgx_enter_enclave() to use the sgx_enclave_run
> struct instead of cramming parameters into the function call itself.
> 
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>

Acked-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

/Jarkko
diff mbox series

Patch

diff --git a/tools/testing/selftests/sgx/call.S b/tools/testing/selftests/sgx/call.S
index 77131e83db424..c4837965dfbb4 100644
--- a/tools/testing/selftests/sgx/call.S
+++ b/tools/testing/selftests/sgx/call.S
@@ -31,15 +31,11 @@  sgx_call_vdso:
 	.cfi_rel_offset		%rbx, 0
 	push	$0
 	.cfi_adjust_cfa_offset	8
-	push	0x48(%rsp)
-	.cfi_adjust_cfa_offset	8
-	push	0x48(%rsp)
-	.cfi_adjust_cfa_offset	8
-	push	0x48(%rsp)
+	push	0x38(%rsp)
 	.cfi_adjust_cfa_offset	8
 	call	*eenter(%rip)
-	add	$0x20, %rsp
-	.cfi_adjust_cfa_offset	-0x20
+	add	$0x10, %rsp
+	.cfi_adjust_cfa_offset	-0x10
 	pop	%rbx
 	.cfi_adjust_cfa_offset	-8
 	pop	%r12
diff --git a/tools/testing/selftests/sgx/main.c b/tools/testing/selftests/sgx/main.c
index 8d95569e7a66f..17f36e590fbd2 100644
--- a/tools/testing/selftests/sgx/main.c
+++ b/tools/testing/selftests/sgx/main.c
@@ -125,7 +125,7 @@  static Elf64_Sym *vdso_symtab_get(struct vdso_symtab *symtab, const char *name)
 
 int main(int argc, char *argv[], char *envp[])
 {
-	struct sgx_enclave_exception exception;
+	struct sgx_enclave_run run;
 	struct vdso_symtab symtab;
 	Elf64_Sym *eenter_sym;
 	uint64_t result = 0;
@@ -156,7 +156,8 @@  int main(int argc, char *argv[], char *envp[])
 		}
 	}
 
-	memset(&exception, 0, sizeof(exception));
+	memset(&run, 0, sizeof(run));
+	run.tcs = encl.encl_base;
 
 	addr = vdso_get_base_addr(envp);
 	if (!addr)
@@ -171,8 +172,7 @@  int main(int argc, char *argv[], char *envp[])
 
 	eenter = addr + eenter_sym->st_value;
 
-	sgx_call_vdso((void *)&MAGIC, &result, 0, EENTER, NULL, NULL,
-		      (void *)encl.encl_base, &exception, NULL);
+	sgx_call_vdso((void *)&MAGIC, &result, 0, EENTER, NULL, NULL, &run);
 	if (result != MAGIC) {
 		printf("FAIL: sgx_call_vdso(), expected: 0x%lx, got: 0x%lx\n",
 		       MAGIC, result);
@@ -181,8 +181,7 @@  int main(int argc, char *argv[], char *envp[])
 
 	/* Invoke the vDSO directly. */
 	result = 0;
-	eenter((unsigned long)&MAGIC, (unsigned long)&result, 0, EENTER, 0, 0,
-	       (void *)encl.encl_base, &exception, NULL);
+	eenter((unsigned long)&MAGIC, (unsigned long)&result, 0, EENTER, 0, 0, &run);
 	if (result != MAGIC) {
 		printf("FAIL: eenter(), expected: 0x%lx, got: 0x%lx\n",
 		       MAGIC, result);
diff --git a/tools/testing/selftests/sgx/main.h b/tools/testing/selftests/sgx/main.h
index 999422cc73438..2b4777942500f 100644
--- a/tools/testing/selftests/sgx/main.h
+++ b/tools/testing/selftests/sgx/main.h
@@ -33,6 +33,6 @@  bool encl_measure(struct encl *encl);
 bool encl_build(struct encl *encl);
 
 int sgx_call_vdso(void *rdi, void *rsi, long rdx, u32 leaf, void *r8, void *r9,
-		  void *tcs, struct sgx_enclave_exception *ei, void *cb);
+		  struct sgx_enclave_run *run);
 
 #endif /* MAIN_H */