Skip to content

Commit

Permalink
libsgxstep: opt set TCS.FLAGS.DBGOPTIN only
Browse files Browse the repository at this point in the history
  • Loading branch information
jovanbulck committed Apr 11, 2024
1 parent 86786e6 commit 1f139de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libsgxstep/enclave.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,10 @@ void* get_enclave_ssa_gprsgx_adrs(void)
void set_debug_optin(void)
{
void *tcs_addr = sgx_get_tcs();
uint64_t flags = 0x1;
edbgwr(tcs_addr + 8, &flags, sizeof(flags));
uint64_t flags;
edbgrd(tcs_addr + SGX_TCS_FLAGS_OFFSET, &flags, sizeof(flags));
flags |= SGX_FLAGS_DBGOPTIN;
edbgwr(tcs_addr + SGX_TCS_FLAGS_OFFSET, &flags, sizeof(flags));
}

void print_enclave_info(void)
Expand Down
2 changes: 2 additions & 0 deletions libsgxstep/enclave.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ int edbgrdwr(void *adrs, void* res, int len, int write);
#define edbgwr(adrs, res, len) edbgrdwr(adrs, res, len, 1)

/* NOTE: incorrect GPRSGX size in Intel manual vol. 3D June 2016 p.38-7 */
#define SGX_TCS_FLAGS_OFFSET 8
#define SGX_TCS_OSSA_OFFSET 16
#define SGX_TCS_CSSA_OFFSET 24
#define SGX_GPRSGX_SIZE 184
#define SGX_GPRSGX_RIP_OFFSET 136
#define SGX_FLAGS_DBGOPTIN 0x1

/* HACK: to avoid having to retrieve the SSA framesize from the untrusted
runtime (driver), we assume a standard/hard-coded SSA framesize of 1 page */
Expand Down

0 comments on commit 1f139de

Please sign in to comment.