linux-sgx.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Reinette Chatre <reinette.chatre@intel.com>,
	linux-sgx@vger.kernel.org, shuah@kernel.org
Cc: seanjc@google.com, bp@alien8.de, dave.hansen@linux.intel.com,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 11/14] selftests/sgx: Rename test properties in preparation for more enclave tests
Date: Thu, 16 Sep 2021 18:20:09 +0300	[thread overview]
Message-ID: <5896058a1eb841946d2e9aa6c5c67f4da6e432c8.camel@kernel.org> (raw)
In-Reply-To: <9a1d5d79c624fa7bb0dc89387fc7b3ab49d36dd0.1631731214.git.reinette.chatre@intel.com>

On Wed, 2021-09-15 at 13:31 -0700, Reinette Chatre wrote:
> SGX selftests prepares a data structure outside of the enclave with
> the type of and data for the operation that needs to be run within
> the enclave. At this time only two complementary operations are supported
> by the enclave: copying a value from outside the enclave into a default
> buffer within the enclave and reading a value from the enclave's default
> buffer into a variable accessible outside the enclave.
> 
> In preparation for more operations supported by the enclave the names of the
> current enclave operations are changed to more accurately reflect the
> operations and more easily distinguish it from future operations:
> 
> * The enums ENCL_OP_PUT and ENCL_OP_GET are renamed to ENCL_OP_PUT_TO_BUFFER
>   and ENCL_OP_GET_FROM_BUFFER respectively.
> * The structs encl_op_put and encl_op_get are renamed to encl_op_put_to_buf
>   and encl_op_get_from_buf respectively.
> * The enclave functions do_encl_op_put and do_encl_op_get are renamed to
>   do_encl_op_put_to_buf and do_encl_op_get_from_buf respectively.
> 
> No functional changes.
> 
> Suggested-by: Jarkko Sakkinen <jarkko@kernel.org>
> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
> ---
>  tools/testing/selftests/sgx/defines.h   |  8 +++----
>  tools/testing/selftests/sgx/main.c      | 32 ++++++++++++-------------
>  tools/testing/selftests/sgx/test_encl.c | 12 +++++-----
>  3 files changed, 26 insertions(+), 26 deletions(-)
> 
> diff --git a/tools/testing/selftests/sgx/defines.h b/tools/testing/selftests/sgx/defines.h
> index 6ff95a766287..9ea0c7882dfb 100644
> --- a/tools/testing/selftests/sgx/defines.h
> +++ b/tools/testing/selftests/sgx/defines.h
> @@ -19,8 +19,8 @@
>  #include "../../../../arch/x86/include/uapi/asm/sgx.h"
>  
>  enum encl_op_type {
> -	ENCL_OP_PUT,
> -	ENCL_OP_GET,
> +	ENCL_OP_PUT_TO_BUFFER,
> +	ENCL_OP_GET_FROM_BUFFER,
>  	ENCL_OP_MAX,
>  };
>  
> @@ -28,12 +28,12 @@ struct encl_op_header {
>  	uint64_t type;
>  };
>  
> -struct encl_op_put {
> +struct encl_op_put_to_buf {
>  	struct encl_op_header header;
>  	uint64_t value;
>  };
>  
> -struct encl_op_get {
> +struct encl_op_get_from_buf {
>  	struct encl_op_header header;
>  	uint64_t value;
>  };
> diff --git a/tools/testing/selftests/sgx/main.c b/tools/testing/selftests/sgx/main.c
> index a107fc576094..3eb9b89ece5f 100644
> --- a/tools/testing/selftests/sgx/main.c
> +++ b/tools/testing/selftests/sgx/main.c
> @@ -220,15 +220,15 @@ FIXTURE_TEARDOWN(enclave)
>  
>  TEST_F(enclave, unclobbered_vdso)
>  {
> -	struct encl_op_put put_op;
> -	struct encl_op_get get_op;
> +	struct encl_op_get_from_buf get_op;
> +	struct encl_op_put_to_buf put_op;
>  
>  	ASSERT_TRUE(setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata));
>  
>  	memset(&self->run, 0, sizeof(self->run));
>  	self->run.tcs = self->encl.encl_base;
>  
> -	put_op.header.type = ENCL_OP_PUT;
> +	put_op.header.type = ENCL_OP_PUT_TO_BUFFER;
>  	put_op.value = MAGIC;
>  
>  	EXPECT_EQ(ENCL_CALL(&put_op, &self->run, false), 0);
> @@ -236,7 +236,7 @@ TEST_F(enclave, unclobbered_vdso)
>  	EXPECT_EEXIT(&self->run);
>  	EXPECT_EQ(self->run.user_data, 0);
>  
> -	get_op.header.type = ENCL_OP_GET;
> +	get_op.header.type = ENCL_OP_GET_FROM_BUFFER;
>  	get_op.value = 0;
>  
>  	EXPECT_EQ(ENCL_CALL(&get_op, &self->run, false), 0);
> @@ -277,9 +277,9 @@ static bool sysfs_get_ulong(const char *path, unsigned long *value)
>  
>  TEST_F(enclave, unclobbered_vdso_oversubscribed)
>  {
> +	struct encl_op_get_from_buf get_op;
> +	struct encl_op_put_to_buf put_op;
>  	unsigned long total_mem;
> -	struct encl_op_put put_op;
> -	struct encl_op_get get_op;
>  
>  	ASSERT_TRUE(sysfs_get_ulong(SGX_TOTAL_MEM_PATH, &total_mem));
>  	ASSERT_TRUE(setup_test_encl(total_mem, &self->encl, _metadata));
> @@ -287,7 +287,7 @@ TEST_F(enclave, unclobbered_vdso_oversubscribed)
>  	memset(&self->run, 0, sizeof(self->run));
>  	self->run.tcs = self->encl.encl_base;
>  
> -	put_op.header.type = ENCL_OP_PUT;
> +	put_op.header.type = ENCL_OP_PUT_TO_BUFFER;
>  	put_op.value = MAGIC;
>  
>  	EXPECT_EQ(ENCL_CALL(&put_op, &self->run, false), 0);
> @@ -295,7 +295,7 @@ TEST_F(enclave, unclobbered_vdso_oversubscribed)
>  	EXPECT_EEXIT(&self->run);
>  	EXPECT_EQ(self->run.user_data, 0);
>  
> -	get_op.header.type = ENCL_OP_GET;
> +	get_op.header.type = ENCL_OP_GET_FROM_BUFFER;
>  	get_op.value = 0;
>  
>  	EXPECT_EQ(ENCL_CALL(&get_op, &self->run, false), 0);
> @@ -308,15 +308,15 @@ TEST_F(enclave, unclobbered_vdso_oversubscribed)
>  
>  TEST_F(enclave, clobbered_vdso)
>  {
> -	struct encl_op_put put_op;
> -	struct encl_op_get get_op;
> +	struct encl_op_get_from_buf get_op;
> +	struct encl_op_put_to_buf put_op;
>  
>  	ASSERT_TRUE(setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata));
>  
>  	memset(&self->run, 0, sizeof(self->run));
>  	self->run.tcs = self->encl.encl_base;
>  
> -	put_op.header.type = ENCL_OP_PUT;
> +	put_op.header.type = ENCL_OP_PUT_TO_BUFFER;
>  	put_op.value = MAGIC;
>  
>  	EXPECT_EQ(ENCL_CALL(&put_op, &self->run, true), 0);
> @@ -324,7 +324,7 @@ TEST_F(enclave, clobbered_vdso)
>  	EXPECT_EEXIT(&self->run);
>  	EXPECT_EQ(self->run.user_data, 0);
>  
> -	get_op.header.type = ENCL_OP_GET;
> +	get_op.header.type = ENCL_OP_GET_FROM_BUFFER;
>  	get_op.value = 0;
>  
>  	EXPECT_EQ(ENCL_CALL(&get_op, &self->run, true), 0);
> @@ -344,8 +344,8 @@ static int test_handler(long rdi, long rsi, long rdx, long ursp, long r8, long r
>  
>  TEST_F(enclave, clobbered_vdso_and_user_function)
>  {
> -	struct encl_op_put put_op;
> -	struct encl_op_get get_op;
> +	struct encl_op_get_from_buf get_op;
> +	struct encl_op_put_to_buf put_op;
>  
>  	ASSERT_TRUE(setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata));
>  
> @@ -355,7 +355,7 @@ TEST_F(enclave, clobbered_vdso_and_user_function)
>  	self->run.user_handler = (__u64)test_handler;
>  	self->run.user_data = 0xdeadbeef;
>  
> -	put_op.header.type = ENCL_OP_PUT;
> +	put_op.header.type = ENCL_OP_PUT_TO_BUFFER;
>  	put_op.value = MAGIC;
>  
>  	EXPECT_EQ(ENCL_CALL(&put_op, &self->run, true), 0);
> @@ -363,7 +363,7 @@ TEST_F(enclave, clobbered_vdso_and_user_function)
>  	EXPECT_EEXIT(&self->run);
>  	EXPECT_EQ(self->run.user_data, 0);
>  
> -	get_op.header.type = ENCL_OP_GET;
> +	get_op.header.type = ENCL_OP_GET_FROM_BUFFER;
>  	get_op.value = 0;
>  
>  	EXPECT_EQ(ENCL_CALL(&get_op, &self->run, true), 0);
> diff --git a/tools/testing/selftests/sgx/test_encl.c b/tools/testing/selftests/sgx/test_encl.c
> index f11eb8315704..4e8da738173f 100644
> --- a/tools/testing/selftests/sgx/test_encl.c
> +++ b/tools/testing/selftests/sgx/test_encl.c
> @@ -16,16 +16,16 @@ static void *memcpy(void *dest, const void *src, size_t n)
>  	return dest;
>  }
>  
> -static void do_encl_op_put(void *op)
> +static void do_encl_op_put_to_buf(void *op)
>  {
> -	struct encl_op_put *op2 = op;
> +	struct encl_op_put_to_buf *op2 = op;
>  
>  	memcpy(&encl_buffer[0], &op2->value, 8);
>  }
>  
> -static void do_encl_op_get(void *op)
> +static void do_encl_op_get_from_buf(void *op)
>  {
> -	struct encl_op_get *op2 = op;
> +	struct encl_op_get_from_buf *op2 = op;
>  
>  	memcpy(&op2->value, &encl_buffer[0], 8);
>  }
> @@ -33,8 +33,8 @@ static void do_encl_op_get(void *op)
>  void encl_body(void *rdi,  void *rsi)
>  {
>  	const void (*encl_op_array[ENCL_OP_MAX])(void *) = {
> -		do_encl_op_put,
> -		do_encl_op_get,
> +		do_encl_op_put_to_buf,
> +		do_encl_op_get_from_buf,
>  	};
>  
>  	struct encl_op_header *op = (struct encl_op_header *)rdi;


Acked-by: Jarkko Sakkinen <jarkko@kernel.org>

/Jarkko


  reply	other threads:[~2021-09-16 15:20 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15 20:30 [PATCH 00/14] selftests/sgx: Oversubscription, page permission, thread entry Reinette Chatre
2021-09-15 20:30 ` [PATCH 01/14] selftests/x86/sgx: Fix a benign linker warning Reinette Chatre
2021-09-16 14:38   ` Jarkko Sakkinen
2021-09-16 14:39     ` Jarkko Sakkinen
2021-09-16 17:31       ` Reinette Chatre
2021-09-15 20:30 ` [PATCH 02/14] x86/sgx: Add /sys/kernel/debug/x86/sgx_total_mem Reinette Chatre
2021-09-16 14:09   ` Jarkko Sakkinen
2021-09-16 15:35     ` Reinette Chatre
2021-09-15 20:30 ` [PATCH 03/14] selftests/sgx: Assign source for each segment Reinette Chatre
2021-09-15 20:30 ` [PATCH 04/14] selftests/sgx: Make data measurement for an enclave segment optional Reinette Chatre
2021-09-15 20:30 ` [PATCH 05/14] selftests/sgx: Create a heap for the test enclave Reinette Chatre
2021-09-15 20:30 ` [PATCH 06/14] selftests/sgx: Dump segments and /proc/self/maps only on failure Reinette Chatre
2021-09-15 20:30 ` [PATCH 07/14] selftests/sgx: Encpsulate the test enclave creation Reinette Chatre
2021-09-15 20:30 ` [PATCH 08/14] selftests/sgx: Move setup_test_encl() to each TEST_F() Reinette Chatre
2021-09-15 20:30 ` [PATCH 09/14] selftests/sgx: Add a new kselftest: unclobbered_vdso_oversubscribed Reinette Chatre
2021-09-15 20:31 ` [PATCH 10/14] selftests/sgx: Provide per-op parameter structs for the test enclave Reinette Chatre
2021-09-15 20:31 ` [PATCH 11/14] selftests/sgx: Rename test properties in preparation for more enclave tests Reinette Chatre
2021-09-16 15:20   ` Jarkko Sakkinen [this message]
2021-09-15 20:31 ` [PATCH 12/14] selftests/sgx: Add page permission and exception test Reinette Chatre
2021-09-16 15:21   ` Jarkko Sakkinen
2021-09-16 15:37     ` Reinette Chatre
2021-09-16 15:30   ` Dave Hansen
2021-09-16 15:50     ` Reinette Chatre
2021-09-15 20:31 ` [PATCH 13/14] selftests/sgx: Enable multiple thread support Reinette Chatre
2021-09-16 15:23   ` Jarkko Sakkinen
2021-09-15 20:31 ` [PATCH 14/14] selftests/sgx: Add test for multiple TCS entry Reinette Chatre
2021-09-16 15:24   ` Jarkko Sakkinen
2021-09-16 14:13 ` [PATCH 00/14] selftests/sgx: Oversubscription, page permission, thread entry Jarkko Sakkinen
2021-09-16 15:37 ` Dave Hansen
2021-09-16 16:14   ` Reinette Chatre
2021-09-16 16:15 ` 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=5896058a1eb841946d2e9aa6c5c67f4da6e432c8.camel@kernel.org \
    --to=jarkko@kernel.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-sgx@vger.kernel.org \
    --cc=reinette.chatre@intel.com \
    --cc=seanjc@google.com \
    --cc=shuah@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;
as well as URLs for NNTP newsgroup(s).