Skip to contentSkip to conversation

selftest/sgx: Use rip relative addressing for encl_stack

PATCH Superseded Jarkko Sakkinen 1 participant 1 message Mar 22, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jarkko Sakkinen

author maintainer
#0 lore raw

PATCH 1/1 selftest/sgx: Use rip relative addressing for encl_stack

Simplify the test_encl_bootstrap.S flow by using rip-relative addressing. Compiler does the right thing here, and this removes dependency on where TCS entries need to be located in the binary, i.e. allows the binary layout changed freely in the future.

Cc Reinette Chatre <[email protected]>
Cc Dave Hansen <[email protected]>

---
This has been in my mind for a while and since the kselftest is seemingly growing, I thought it is better to get rid off such an artificial limitation on the binary layout.

 tools/testing/selftests/sgx/test_encl_bootstrap.S | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
tools/testing/selftests/sgx/test_encl_bootstrap.S +1 -5
index 82fb0dfcbd23..1c1b5c6c4ffe 100644
@@ -40,11 +40,7 @@
 	.text
 
 encl_entry:
-	# RBX contains the base address for TCS, which is the first address
-	# inside the enclave for TCS #1 and one page into the enclave for
-	# TCS #2. By adding the value of encl_stack to it, we get
-	# the absolute address for the stack.
-	lea	(encl_stack)(%rbx), %rax
+	lea	(encl_stack)(%rip), %rax
 	xchg	%rsp, %rax
 	push	%rax
 
Signature · 1 line
2.35.1