selftests/sgx: Provide per-op parameter structs for the test enclave
Jarkko Sakkinen
maintainerPATCH 1/1 selftests/sgx: Provide per-op parameter structs for the test enclave
To add more operations to the test enclave, the protocol needs to allow to have operations with varying parameters. Create a separate parameter struct for each existing operation, with the shared parameters in struct encl_op_header.
Signed-off-by Jarkko Sakkinen <[email protected]>
--- tools/testing/selftests/sgx/defines.h | 13 ++++++- tools/testing/selftests/sgx/main.c | 52 +++++++++++++------------ tools/testing/selftests/sgx/test_encl.c | 20 ++++++++-- 3 files changed, 56 insertions(+), 29 deletions(-)
tools/testing/selftests/sgx/defines.h +11 -2
@@ -23,9 +23,18 @@ enum encl_op_type { ENCL_OP_GET, }; -struct encl_op { +struct encl_op_header {uint64_t type; -uint64_t buffer; +}; + +struct encl_op_put { +struct encl_op_header header; +uint64_t value; +}; + +struct encl_op_get { +struct encl_op_header header; +uint64_t value; };#endif /* DEFINES_H */
tools/testing/selftests/sgx/main.c +28 -24
99 lines not on this page · raw message
tools/testing/selftests/sgx/test_encl.c +17 -3
@@ -16,17 +16,31 @@ static void *memcpy(void *dest, const void *src, size_t n)return dest; } +void do_encl_op_put (void *op) +{ +struct encl_op_put *op2 = op; + +memcpy (&encl_buffer[0 ], &op2->value,8 ); +} + +void do_encl_op_get (void *op) +{ +struct encl_op_get *op2 = op; + +memcpy (&op2->value, &encl_buffer[0 ],8 ); +} +void encl_body (void *rdi,void *rsi) { -struct encl_op *op = (struct encl_op *)rdi; +struct encl_op_header *op = (struct encl_op_header *)rdi;switch (op->type) {case ENCL_OP_PUT : -memcpy (&encl_buffer[0 ], &op->buffer,8 ); +do_encl_op_put (op);break ;case ENCL_OP_GET : -memcpy (&op->buffer, &encl_buffer[0 ],8 ); +do_encl_op_get (op);break ;default :
Signature · 1 line
2.32.0