diff options
author | Jarkko Sakkinen <jarkko@kernel.org> | 2021-06-10 10:30:19 +0200 |
---|---|---|
committer | Shuah Khan <skhan@linuxfoundation.org> | 2021-06-16 00:27:07 +0200 |
commit | 040efd1c35f93787cbd26be6fc6493592571f424 (patch) | |
tree | ea4981373a29bbd1ebbfed9ca75bb10db6c9f4a3 /tools | |
parent | selftests/sgx: Migrate to kselftest harness (diff) | |
download | linux-040efd1c35f93787cbd26be6fc6493592571f424.tar.xz linux-040efd1c35f93787cbd26be6fc6493592571f424.zip |
selftests/sgx: Dump enclave memory map
Often, it's useful to check whether /proc/self/maps looks sane when
dealing with memory mapped objects, especially when they are JIT'ish
dynamically constructed objects. Therefore, dump "/dev/sgx_enclave"
matching lines from the memory map in FIXTURE_SETUP().
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/sgx/main.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/testing/selftests/sgx/main.c b/tools/testing/selftests/sgx/main.c index 6da19b6bf287..14030f8b85ff 100644 --- a/tools/testing/selftests/sgx/main.c +++ b/tools/testing/selftests/sgx/main.c @@ -117,6 +117,8 @@ FIXTURE_SETUP(enclave) Elf64_Sym *sgx_enter_enclave_sym = NULL; struct vdso_symtab symtab; struct encl_segment *seg; + char maps_line[256]; + FILE *maps_file; unsigned int i; void *addr; @@ -167,6 +169,18 @@ FIXTURE_SETUP(enclave) memset(&self->run, 0, sizeof(self->run)); self->run.tcs = self->encl.encl_base; + maps_file = fopen("/proc/self/maps", "r"); + if (maps_file != NULL) { + while (fgets(maps_line, sizeof(maps_line), maps_file) != NULL) { + maps_line[strlen(maps_line) - 1] = '\0'; + + if (strstr(maps_line, "/dev/sgx_enclave")) + TH_LOG("%s", maps_line); + } + + fclose(maps_file); + } + err: if (!sgx_enter_enclave_sym) encl_delete(&self->encl); |