selftests/sgx: Ensure enclave data available during debug print
authorReinette Chatre <reinette.chatre@intel.com>
Tue, 8 Feb 2022 21:48:41 +0000 (13:48 -0800)
committerDave Hansen <dave.hansen@linux.intel.com>
Fri, 11 Feb 2022 21:52:47 +0000 (13:52 -0800)
In support of debugging the SGX tests print details from
the enclave and its memory mappings if any failure is encountered
during enclave loading.

When a failure is encountered no data is printed because the
printing of the data is preceded by cleanup of the data.

Move the data cleanup after the data print.

Fixes: 147172148909 ("selftests/sgx: Dump segments and /proc/self/maps only on failure")
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lkml.kernel.org/r/dab672f771e9b99e50c17ae2a75dc0b020cb0ce9.1644355600.git.reinette.chatre@intel.com
tools/testing/selftests/sgx/main.c

index a7cd2c3e6f7e126974ee12d02caadba0788a6c7d..b0bd95a4730d5a22e7c3cb42fb04019011cf3aad 100644 (file)
@@ -186,8 +186,6 @@ static bool setup_test_encl(unsigned long heap_size, struct encl *encl,
        return true;
 
 err:
-       encl_delete(encl);
-
        for (i = 0; i < encl->nr_segments; i++) {
                seg = &encl->segment_tbl[i];
 
@@ -208,6 +206,8 @@ err:
 
        TH_LOG("Failed to initialize the test enclave.\n");
 
+       encl_delete(encl);
+
        return false;
 }