lkml.org 
[lkml]   [2023]   [Aug]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 5/8] selftests/sgx: Include memory clobber for inline asm in test enclave
Date
On Tue, 2023-08-08 at 12:31 -0700, Jo Van Bulck wrote:
> Add the "memory" clobber to the EMODPE and EACCEPT asm blocks to tell the
> compiler the assembly code accesses to the secinfo struct. This ensures
> the compiler treats the asm block as a memory barrier and the write to
> secinfo will be visible to ENCLU.
>
> Signed-off-by: Jo Van Bulck <jo.vanbulck@cs.kuleuven.be>
> ---
> tools/testing/selftests/sgx/test_encl.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/sgx/test_encl.c b/tools/testing/selftests/sgx/test_encl.c
> index c71dfbadd2d9..5b758eaf808c 100644
> --- a/tools/testing/selftests/sgx/test_encl.c
> +++ b/tools/testing/selftests/sgx/test_encl.c
> @@ -24,10 +24,11 @@ static void do_encl_emodpe(void *_op)
> secinfo.flags = op->flags;
>
> asm volatile(".byte 0x0f, 0x01, 0xd7"
> - :
> + : /* no outputs */
> : "a" (EMODPE),
> "b" (&secinfo),
> - "c" (op->epc_addr));
> + "c" (op->epc_addr)
> + : "memory" /* read from secinfo pointer */);
> }
>
> static void do_encl_eaccept(void *_op)
> @@ -42,7 +43,8 @@ static void do_encl_eaccept(void *_op)
> : "=a" (rax)
> : "a" (EACCEPT),
> "b" (&secinfo),
> - "c" (op->epc_addr));
> + "c" (op->epc_addr)
> + : "memory" /* read from secinfo pointer */);
>
> op->ret = rax;
> }

Reviewed-by: Kai Huang <kai.huang@intel.com>
\
 
 \ /
  Last update: 2023-08-18 13:33    [W:0.146 / U:0.656 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site