From 86786e6fc4ce58f5719c437038eb2d6f65fe3acc Mon Sep 17 00:00:00 2001 From: Daan Vanoverloop Date: Thu, 29 Feb 2024 09:32:04 +0000 Subject: [PATCH] Add debug opt-in --- libsgxstep/enclave.c | 7 +++++++ libsgxstep/enclave.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/libsgxstep/enclave.c b/libsgxstep/enclave.c index 871ac4f..2d2d97e 100644 --- a/libsgxstep/enclave.c +++ b/libsgxstep/enclave.c @@ -195,6 +195,13 @@ void* get_enclave_ssa_gprsgx_adrs(void) return get_enclave_base() + ossa + (cssa * SGX_SSAFRAMESIZE) - SGX_GPRSGX_SIZE; } +void set_debug_optin(void) +{ + void *tcs_addr = sgx_get_tcs(); + uint64_t flags = 0x1; + edbgwr(tcs_addr + 8, &flags, sizeof(flags)); +} + void print_enclave_info(void) { uint64_t read = 0xff; diff --git a/libsgxstep/enclave.h b/libsgxstep/enclave.h index bd093d3..b1c9857 100644 --- a/libsgxstep/enclave.h +++ b/libsgxstep/enclave.h @@ -106,5 +106,7 @@ void dump_gprsgx_region(gprsgx_region_t *gprsgx_region); uint64_t edbgrd_ssa_gprsgx(int gprsgx_field_offset); #define edbgrd_erip() edbgrd_ssa_gprsgx(SGX_GPRSGX_RIP_OFFSET) +void set_debug_optin(void); + #endif #endif