[PATCH v4 12/13] selftests/sgx: Remove redundant enclave base address save/restore

Jo Van Bulck posted 13 patches 2 years, 3 months ago
There is a newer version of this series
[PATCH v4 12/13] selftests/sgx: Remove redundant enclave base address save/restore
Posted by Jo Van Bulck 2 years, 3 months ago
Remove redundant push/pop pair that stores and restores the enclave base
address in the test enclave, as it is never used after the pop and can
anyway be easily retrieved via the __encl_base symbol.

Signed-off-by: Jo Van Bulck <jo.vanbulck@cs.kuleuven.be>
---
 tools/testing/selftests/sgx/test_encl_bootstrap.S | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/tools/testing/selftests/sgx/test_encl_bootstrap.S b/tools/testing/selftests/sgx/test_encl_bootstrap.S
index 4e55d91566c4..28fe5d2ac0af 100644
--- a/tools/testing/selftests/sgx/test_encl_bootstrap.S
+++ b/tools/testing/selftests/sgx/test_encl_bootstrap.S
@@ -58,12 +58,9 @@ encl_entry_core:
 	push	%rax
 
 	push	%rcx # push the address after EENTER
-	push	%rbx # push the enclave base address
 
 	call	encl_body
 
-	pop	%rbx # pop the enclave base address
-
 	/* Clear volatile GPRs, except RAX (EEXIT function). */
 	xor     %rcx, %rcx
 	xor     %rdx, %rdx
-- 
2.25.1
Re: [PATCH v4 12/13] selftests/sgx: Remove redundant enclave base address save/restore
Posted by Huang, Kai 2 years, 3 months ago
On Fri, 2023-08-25 at 15:32 +0200, Jo Van Bulck wrote:
> Remove redundant push/pop pair that stores and restores the enclave base
> address in the test enclave, as it is never used after the pop and can
> anyway be easily retrieved via the __encl_base symbol.
> 
> Signed-off-by: Jo Van Bulck <jo.vanbulck@cs.kuleuven.be>

Acked-by: Kai Huang <kai.huang@intel.com>

Nit below...

> ---
>  tools/testing/selftests/sgx/test_encl_bootstrap.S | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/sgx/test_encl_bootstrap.S b/tools/testing/selftests/sgx/test_encl_bootstrap.S
> index 4e55d91566c4..28fe5d2ac0af 100644
> --- a/tools/testing/selftests/sgx/test_encl_bootstrap.S
> +++ b/tools/testing/selftests/sgx/test_encl_bootstrap.S
> @@ -58,12 +58,9 @@ encl_entry_core:
>  	push	%rax
>  
>  	push	%rcx # push the address after EENTER
> -	push	%rbx # push the enclave base address
>  
>  	call	encl_body
>  
> -	pop	%rbx # pop the enclave base address
> -
>  	/* Clear volatile GPRs, except RAX (EEXIT function). */
>  	xor     %rcx, %rcx
>  	xor     %rdx, %rdx

... please move this patch before patch 2?

Otherwise, strictly speaking patch 2 isn't complete, because after you apply
patch 2 you still have this code which is obviously wrong -- %rbx is no longer
enclave base address (although it never was even in the current upstream code).
Re: [PATCH v4 12/13] selftests/sgx: Remove redundant enclave base address save/restore
Posted by Jo Van Bulck 2 years, 3 months ago
On 29.08.23 13:00, Huang, Kai wrote:
> ... please move this patch before patch 2?
> 
> Otherwise, strictly speaking patch 2 isn't complete, because after you apply
> patch 2 you still have this code which is obviously wrong -- %rbx is no longer
> enclave base address (although it never was even in the current upstream code).

Okay, moving this ahead.

Best,
Jo