[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <CUE1GHCIZXGV.28B1TA9UD7WH9@seitikki>
Date: Fri, 28 Jul 2023 19:05:51 +0000
From: "Jarkko Sakkinen" <jarkko@...nel.org>
To: "Jo Van Bulck" <jo.vanbulck@...kuleuven.be>,
<linux-sgx@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Cc: <dave.hansen@...ux.intel.com>
Subject: Re: [PATCH 3/5] selftests/sgx: Ensure correct secinfo struct
alignment in test enclave.
On Mon Jul 24, 2023 at 4:58 PM UTC, Jo Van Bulck wrote:
> Declare the secinfo struct as volatile to prevent compiler optimizations
> from passing an unaligned pointer to ENCLU.
>
> Signed-off-by: Jo Van Bulck <jo.vanbulck@...kuleuven.be>
> ---
> tools/testing/selftests/sgx/test_encl.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/sgx/test_encl.c b/tools/testing/selftests/sgx/test_encl.c
> index 4e31a6c3d673..aba301abefb8 100644
> --- a/tools/testing/selftests/sgx/test_encl.c
> +++ b/tools/testing/selftests/sgx/test_encl.c
> @@ -18,7 +18,8 @@ enum sgx_enclu_function {
>
> static void do_encl_emodpe(void *_op)
> {
> - struct sgx_secinfo secinfo __aligned(sizeof(struct sgx_secinfo)) = {0};
> + /* declare secinfo volatile to preserve alignment */
> + volatile struct sgx_secinfo secinfo __aligned(sizeof(struct sgx_secinfo)) = {0};
> struct encl_op_emodpe *op = _op;
>
> secinfo.flags = op->flags;
> @@ -32,7 +33,8 @@ static void do_encl_emodpe(void *_op)
>
> static void do_encl_eaccept(void *_op)
> {
> - struct sgx_secinfo secinfo __aligned(sizeof(struct sgx_secinfo)) = {0};
> + /* declare secinfo volatile to preserve alignment */
> + volatile struct sgx_secinfo secinfo __aligned(sizeof(struct sgx_secinfo)) = {0};
> struct encl_op_eaccept *op = _op;
> int rax;
>
> --
> 2.34.1
Reviewed-by: Jarkko Sakkinen <jarkko@...nel.org>
BR, Jarkko
Powered by blists - more mailing lists