From: "Jarkko Sakkinen" <jarkko@kernel.org>
To: "Jo Van Bulck" <jo.vanbulck@cs.kuleuven.be>,
<linux-sgx@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <dave.hansen@linux.intel.com>
Subject: Re: [PATCH 2/5] selftests/sgx: Fix function pointer relocation in test enclave.
Date: Fri, 28 Jul 2023 19:05:12 +0000 [thread overview]
Message-ID: <CUE1FZAK9NCU.3QTCUB3OBJMK8@seitikki> (raw)
In-Reply-To: <20230724165832.15797-3-jo.vanbulck@cs.kuleuven.be>
On Mon Jul 24, 2023 at 4:58 PM UTC, Jo Van Bulck wrote:
> Relocate encl_op_array entries at runtime relative to the enclave base to
> ensure correct function pointer when compiling the test enclave with -Os.
>
> Signed-off-by: Jo Van Bulck <jo.vanbulck@cs.kuleuven.be>
> ---
> tools/testing/selftests/sgx/test_encl.c | 6 ++++--
> tools/testing/selftests/sgx/test_encl.lds | 1 +
> tools/testing/selftests/sgx/test_encl_bootstrap.S | 5 +++++
> 3 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/sgx/test_encl.c b/tools/testing/selftests/sgx/test_encl.c
> index c0d6397295e3..4e31a6c3d673 100644
> --- a/tools/testing/selftests/sgx/test_encl.c
> +++ b/tools/testing/selftests/sgx/test_encl.c
> @@ -119,9 +119,11 @@ static void do_encl_op_nop(void *_op)
>
> }
>
> +uint64_t get_enclave_base(void);
> +
> void encl_body(void *rdi, void *rsi)
> {
> - const void (*encl_op_array[ENCL_OP_MAX])(void *) = {
> + static void (*encl_op_array[ENCL_OP_MAX])(void *) = {
> do_encl_op_put_to_buf,
> do_encl_op_get_from_buf,
> do_encl_op_put_to_addr,
> @@ -135,5 +137,5 @@ void encl_body(void *rdi, void *rsi)
> struct encl_op_header *op = (struct encl_op_header *)rdi;
>
> if (op->type < ENCL_OP_MAX)
> - (*encl_op_array[op->type])(op);
> + (*(get_enclave_base() + encl_op_array[op->type]))(op);
> }
> diff --git a/tools/testing/selftests/sgx/test_encl.lds b/tools/testing/selftests/sgx/test_encl.lds
> index a1ec64f7d91f..ca659db2a534 100644
> --- a/tools/testing/selftests/sgx/test_encl.lds
> +++ b/tools/testing/selftests/sgx/test_encl.lds
> @@ -10,6 +10,7 @@ PHDRS
> SECTIONS
> {
> . = 0;
> + __enclave_base = .;
> .tcs : {
> *(.tcs*)
> } : tcs
> diff --git a/tools/testing/selftests/sgx/test_encl_bootstrap.S b/tools/testing/selftests/sgx/test_encl_bootstrap.S
> index 03ae0f57e29d..6126dbd7ad1c 100644
> --- a/tools/testing/selftests/sgx/test_encl_bootstrap.S
> +++ b/tools/testing/selftests/sgx/test_encl_bootstrap.S
> @@ -86,6 +86,11 @@ encl_entry_core:
> mov $4, %rax
> enclu
>
> + .global get_enclave_base
> +get_enclave_base:
> + lea __enclave_base(%rip), %rax
> + ret
> +
> .section ".data", "aw"
>
> encl_ssa_tcs1:
> --
> 2.34.1
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
BR, Jarkko
next prev parent reply other threads:[~2023-07-28 19:05 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-24 16:58 [PATCH 0/5] selftests/sgx: Fix compilation errors Jo Van Bulck
2023-07-24 16:58 ` [PATCH 1/5] selftests/sgx: Fix uninitialized pointer dereference in error path Jo Van Bulck
2023-07-28 19:03 ` Jarkko Sakkinen
2023-08-07 6:06 ` Jo Van Bulck
2023-07-28 19:04 ` Jarkko Sakkinen
2023-08-03 3:51 ` Huang, Kai
2023-08-07 6:15 ` Jo Van Bulck
2023-07-24 16:58 ` [PATCH 2/5] selftests/sgx: Fix function pointer relocation in test enclave Jo Van Bulck
2023-07-28 19:05 ` Jarkko Sakkinen [this message]
2023-08-03 3:58 ` Huang, Kai
2023-08-07 7:13 ` Jo Van Bulck
2023-08-18 12:54 ` Huang, Kai
2023-08-19 2:30 ` Jo Van Bulck
2023-08-21 11:04 ` Huang, Kai
2023-08-21 13:24 ` Jo Van Bulck
2023-07-24 16:58 ` [PATCH 3/5] selftests/sgx: Ensure correct secinfo struct alignment " Jo Van Bulck
2023-07-28 19:05 ` Jarkko Sakkinen
2023-08-03 4:00 ` Huang, Kai
2023-08-07 9:21 ` Jo Van Bulck
2023-07-24 16:58 ` [PATCH 4/5] selftests/sgx: Ensure expected enclave data buffer size and placement Jo Van Bulck
2023-07-28 19:19 ` Jarkko Sakkinen
2023-08-07 9:41 ` Jo Van Bulck
2023-08-18 13:07 ` Huang, Kai
2023-08-19 1:11 ` Jo Van Bulck
2023-08-03 4:22 ` Huang, Kai
2023-08-07 9:50 ` Jo Van Bulck
2023-07-24 16:58 ` [PATCH 5/5] selftests/sgx: Enclave freestanding compilation + separate linker options Jo Van Bulck
2023-07-28 19:22 ` Jarkko Sakkinen
2023-08-07 10:03 ` Jo Van Bulck
2023-07-28 19:01 ` [PATCH 0/5] selftests/sgx: Fix compilation errors Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CUE1FZAK9NCU.3QTCUB3OBJMK8@seitikki \
--to=jarkko@kernel.org \
--cc=dave.hansen@linux.intel.com \
--cc=jo.vanbulck@cs.kuleuven.be \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sgx@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox