Add a selftest to call __vsgx_enter_enclave() from C. Suggested-by: Jarkko Sakkinen <jarkko.sakkinen@xxxxxxxxxxxxxxx> Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> --- tools/testing/selftests/x86/sgx/main.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/x86/sgx/main.c b/tools/testing/selftests/x86/sgx/main.c index 9b89946a976b..bf64fa857983 100644 --- a/tools/testing/selftests/x86/sgx/main.c +++ b/tools/testing/selftests/x86/sgx/main.c @@ -21,7 +21,7 @@ #define PAGE_SIZE 4096 static const uint64_t MAGIC = 0x1122334455667788ULL; -void *eenter; +vdso_sgx_enter_enclave_t eenter; struct vdso_symtab { Elf64_Sym *elf_symtab; @@ -376,5 +376,17 @@ int main(int argc, char *argv[], char *envp[]) printf("Output: 0x%lx\n", result); + printf("Input: 0x%lx\n", MAGIC); + result = 0; + + /* Invoke the vDSO directly. */ + eenter((unsigned long)&MAGIC, (unsigned long)&result, 0, 2, 0, 0, + (void *)secs.base, &exception, NULL); + if (result != MAGIC) { + fprintf(stderr, "0x%lx != 0x%lx\n", result, MAGIC); + exit(1); + } + printf("Output: 0x%lx\n", result); + exit(0); } -- 2.24.1