Intel® Software Guard Extensions (Intel® SGX)
Discussion board focused on hardware-based isolation and memory encryption to provide extended code protection in solutions.

Where is saved register information in untrusted

Shohei_K_
Beginner
581 Views

Hi,I'm Shohei.I'm studying intel SGX in Japan.

I tried to get untrusted-stack information from enclave, but I couldn't do it.

When EENTER is called, where is saved register information in untrusted world. Is saved in Enclave?

Thank you

Shohei

0 Kudos
1 Solution
yunfeng7854
New Contributor I
581 Views

The enclaves and the outside have different stacks. On EENTER, the outside stack pointer RSP, RBP are saved in the state save area (SSA) frame of the current thread's TCS, for later restore on AEX. It is saved in the GPRSGX region of SSA frame. Here is the reference manual: https://software.intel.com/sites/default/files/managed/48/88/329298-002.pdf Sec. 2.9.1, Table 2-8.

Wenhao

View solution in original post

0 Kudos
4 Replies
yunfeng7854
New Contributor I
582 Views

The enclaves and the outside have different stacks. On EENTER, the outside stack pointer RSP, RBP are saved in the state save area (SSA) frame of the current thread's TCS, for later restore on AEX. It is saved in the GPRSGX region of SSA frame. Here is the reference manual: https://software.intel.com/sites/default/files/managed/48/88/329298-002.pdf Sec. 2.9.1, Table 2-8.

Wenhao

0 Kudos
Shohei_K_
Beginner
581 Views

Thank you for your answer. That information is good for me.

But I have another question. When I tried, I call GPRSGX region of SSA frame from enclave.Here is that code.

  _thread_data_t *thread_data;
  thread_data = get_thread_data();

  ssa_gpr_t *ssa_gpr = reinterpret_cast<ssa_gpr_t *>(thread_data->first_ssa_gpr);
  unsigned long addbp = ssa_gpr->REG(bp_u);

But addbp points enclave's stack ebp not uEBP. Where do you think there were mistakes?

Thank you

Shohei

0 Kudos
yunfeng7854
New Contributor I
581 Views

I tried your code and I believe it returned an address outside the enclave. Could you try again?

I am using Intel SDK version 1.8, with gcc version 5.4.0 on a Ubuntu 16.04 system.

Wenhao

0 Kudos
Shohei_K_
Beginner
581 Views

Thanks

That address is outside Enclave stack address? My code returns enclave stack ebp.

I tried this code in /Samplecode/SampleEnclave/Enclave/Trustedlibrary/Libc.cpp on SDK.

So I will check address outside the enclave again, and SDK, gcc, Ubuntu version.

Thanks a lot!

Shohei

0 Kudos
Reply