Skip to content

Commit c085dfc

Browse files
rchatrehansendc
authored andcommitted
selftests/sgx: Rename test properties in preparation for more enclave tests
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 <[email protected]> Signed-off-by: Reinette Chatre <[email protected]> Signed-off-by: Dave Hansen <[email protected]> Acked-by: Jarkko Sakkinen <[email protected]> Acked-by: Dave Hansen <[email protected]> Link: https://lkml.kernel.org/r/023fda047c787cf330b88ed9337705edae6a0078.1636997631.git.reinette.chatre@intel.com
1 parent 41493a0 commit c085dfc

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

tools/testing/selftests/sgx/defines.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@
1919
#include "../../../../arch/x86/include/uapi/asm/sgx.h"
2020

2121
enum encl_op_type {
22-
ENCL_OP_PUT,
23-
ENCL_OP_GET,
22+
ENCL_OP_PUT_TO_BUFFER,
23+
ENCL_OP_GET_FROM_BUFFER,
2424
ENCL_OP_MAX,
2525
};
2626

2727
struct encl_op_header {
2828
uint64_t type;
2929
};
3030

31-
struct encl_op_put {
31+
struct encl_op_put_to_buf {
3232
struct encl_op_header header;
3333
uint64_t value;
3434
};
3535

36-
struct encl_op_get {
36+
struct encl_op_get_from_buf {
3737
struct encl_op_header header;
3838
uint64_t value;
3939
};

tools/testing/selftests/sgx/main.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -220,23 +220,23 @@ FIXTURE_TEARDOWN(enclave)
220220

221221
TEST_F(enclave, unclobbered_vdso)
222222
{
223-
struct encl_op_put put_op;
224-
struct encl_op_get get_op;
223+
struct encl_op_get_from_buf get_op;
224+
struct encl_op_put_to_buf put_op;
225225

226226
ASSERT_TRUE(setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata));
227227

228228
memset(&self->run, 0, sizeof(self->run));
229229
self->run.tcs = self->encl.encl_base;
230230

231-
put_op.header.type = ENCL_OP_PUT;
231+
put_op.header.type = ENCL_OP_PUT_TO_BUFFER;
232232
put_op.value = MAGIC;
233233

234234
EXPECT_EQ(ENCL_CALL(&put_op, &self->run, false), 0);
235235

236236
EXPECT_EEXIT(&self->run);
237237
EXPECT_EQ(self->run.user_data, 0);
238238

239-
get_op.header.type = ENCL_OP_GET;
239+
get_op.header.type = ENCL_OP_GET_FROM_BUFFER;
240240
get_op.value = 0;
241241

242242
EXPECT_EQ(ENCL_CALL(&get_op, &self->run, false), 0);
@@ -292,9 +292,9 @@ static unsigned long get_total_epc_mem(void)
292292

293293
TEST_F(enclave, unclobbered_vdso_oversubscribed)
294294
{
295+
struct encl_op_get_from_buf get_op;
296+
struct encl_op_put_to_buf put_op;
295297
unsigned long total_mem;
296-
struct encl_op_put put_op;
297-
struct encl_op_get get_op;
298298

299299
total_mem = get_total_epc_mem();
300300
ASSERT_NE(total_mem, 0);
@@ -303,15 +303,15 @@ TEST_F(enclave, unclobbered_vdso_oversubscribed)
303303
memset(&self->run, 0, sizeof(self->run));
304304
self->run.tcs = self->encl.encl_base;
305305

306-
put_op.header.type = ENCL_OP_PUT;
306+
put_op.header.type = ENCL_OP_PUT_TO_BUFFER;
307307
put_op.value = MAGIC;
308308

309309
EXPECT_EQ(ENCL_CALL(&put_op, &self->run, false), 0);
310310

311311
EXPECT_EEXIT(&self->run);
312312
EXPECT_EQ(self->run.user_data, 0);
313313

314-
get_op.header.type = ENCL_OP_GET;
314+
get_op.header.type = ENCL_OP_GET_FROM_BUFFER;
315315
get_op.value = 0;
316316

317317
EXPECT_EQ(ENCL_CALL(&get_op, &self->run, false), 0);
@@ -324,23 +324,23 @@ TEST_F(enclave, unclobbered_vdso_oversubscribed)
324324

325325
TEST_F(enclave, clobbered_vdso)
326326
{
327-
struct encl_op_put put_op;
328-
struct encl_op_get get_op;
327+
struct encl_op_get_from_buf get_op;
328+
struct encl_op_put_to_buf put_op;
329329

330330
ASSERT_TRUE(setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata));
331331

332332
memset(&self->run, 0, sizeof(self->run));
333333
self->run.tcs = self->encl.encl_base;
334334

335-
put_op.header.type = ENCL_OP_PUT;
335+
put_op.header.type = ENCL_OP_PUT_TO_BUFFER;
336336
put_op.value = MAGIC;
337337

338338
EXPECT_EQ(ENCL_CALL(&put_op, &self->run, true), 0);
339339

340340
EXPECT_EEXIT(&self->run);
341341
EXPECT_EQ(self->run.user_data, 0);
342342

343-
get_op.header.type = ENCL_OP_GET;
343+
get_op.header.type = ENCL_OP_GET_FROM_BUFFER;
344344
get_op.value = 0;
345345

346346
EXPECT_EQ(ENCL_CALL(&get_op, &self->run, true), 0);
@@ -360,8 +360,8 @@ static int test_handler(long rdi, long rsi, long rdx, long ursp, long r8, long r
360360

361361
TEST_F(enclave, clobbered_vdso_and_user_function)
362362
{
363-
struct encl_op_put put_op;
364-
struct encl_op_get get_op;
363+
struct encl_op_get_from_buf get_op;
364+
struct encl_op_put_to_buf put_op;
365365

366366
ASSERT_TRUE(setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata));
367367

@@ -371,15 +371,15 @@ TEST_F(enclave, clobbered_vdso_and_user_function)
371371
self->run.user_handler = (__u64)test_handler;
372372
self->run.user_data = 0xdeadbeef;
373373

374-
put_op.header.type = ENCL_OP_PUT;
374+
put_op.header.type = ENCL_OP_PUT_TO_BUFFER;
375375
put_op.value = MAGIC;
376376

377377
EXPECT_EQ(ENCL_CALL(&put_op, &self->run, true), 0);
378378

379379
EXPECT_EEXIT(&self->run);
380380
EXPECT_EQ(self->run.user_data, 0);
381381

382-
get_op.header.type = ENCL_OP_GET;
382+
get_op.header.type = ENCL_OP_GET_FROM_BUFFER;
383383
get_op.value = 0;
384384

385385
EXPECT_EQ(ENCL_CALL(&get_op, &self->run, true), 0);

tools/testing/selftests/sgx/test_encl.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,25 @@ static void *memcpy(void *dest, const void *src, size_t n)
1616
return dest;
1717
}
1818

19-
static void do_encl_op_put(void *op)
19+
static void do_encl_op_put_to_buf(void *op)
2020
{
21-
struct encl_op_put *op2 = op;
21+
struct encl_op_put_to_buf *op2 = op;
2222

2323
memcpy(&encl_buffer[0], &op2->value, 8);
2424
}
2525

26-
static void do_encl_op_get(void *op)
26+
static void do_encl_op_get_from_buf(void *op)
2727
{
28-
struct encl_op_get *op2 = op;
28+
struct encl_op_get_from_buf *op2 = op;
2929

3030
memcpy(&op2->value, &encl_buffer[0], 8);
3131
}
3232

3333
void encl_body(void *rdi, void *rsi)
3434
{
3535
const void (*encl_op_array[ENCL_OP_MAX])(void *) = {
36-
do_encl_op_put,
37-
do_encl_op_get,
36+
do_encl_op_put_to_buf,
37+
do_encl_op_get_from_buf,
3838
};
3939

4040
struct encl_op_header *op = (struct encl_op_header *)rdi;

0 commit comments

Comments
 (0)