Skip to content

Commit

Permalink
Unformat
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph M. Wintersteiger <[email protected]>
  • Loading branch information
wintersteiger committed Aug 21, 2020
1 parent ceecdb5 commit 6ae4dd4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 12 additions & 9 deletions src/enclave/enclave_oe.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#define AUXV_ENTRIES 13

char* at_platform = "x86_64";
char *at_platform = "x86_64";
sgxlkl_enclave_state_t sgxlkl_enclave_state = {0};

bool sgxlkl_in_sw_debug_mode()
Expand Down Expand Up @@ -55,25 +55,28 @@ static int _strncmp(const char* x, const char* y, size_t n)
return *px == *py ? 0 : *px < *py ? -1 : +1;
}

static void init_auxv(size_t* auxv, char* buf_ptr, char* pn)
static void
init_auxv(size_t *auxv, char* buf_ptr, char *pn)
{
// By default auxv[AT_RANDOM] points to a buffer with 16 random bytes.
uint64_t* rbuf = (uint64_t*)buf_ptr;
uint64_t *rbuf = (uint64_t*)buf_ptr;
buf_ptr += 16;
// TODO Use intrinsics
// if (!_rdrand64_step(&rbuf[0]))
// goto err;
register uint64_t rd;
__asm__ volatile("rdrand %0;" : "=r"(rd));
__asm__ volatile("rdrand %0;"
: "=r"(rd));
rbuf[0] = rd;
__asm__ volatile("rdrand %0;" : "=r"(rd));
__asm__ volatile("rdrand %0;"
: "=r"(rd));
rbuf[1] = rd;

memset(auxv, 0, 2 * sizeof(size_t) * AUXV_ENTRIES);
auxv[0] = AT_CLKTCK;
auxv[1] = 100;
auxv[2] = AT_EXECFN;
auxv[3] = (size_t)pn;
auxv[3] = (size_t) pn;
auxv[4] = AT_HWCAP;
auxv[5] = 0;
auxv[6] = AT_EGID;
Expand All @@ -86,7 +89,7 @@ static void init_auxv(size_t* auxv, char* buf_ptr, char* pn)
auxv[13] = 0;
auxv[14] = AT_PLATFORM;
memcpy(buf_ptr, at_platform, oe_strlen(at_platform) + 1);
auxv[15] = (size_t)buf_ptr;
auxv[15] = (size_t) buf_ptr;
buf_ptr += oe_strlen(at_platform) + 1;
auxv[16] = AT_SECURE;
auxv[17] = 0;
Expand Down Expand Up @@ -119,9 +122,9 @@ static void _prepare_elf_stack()
for (size_t i = 0; i < num_imported_env; i++)
num_bytes += oe_strlen(imported_env[i]) + 1;
num_ptrs += num_imported_env + 1;
num_ptrs += 2 * AUXV_ENTRIES; // auxv vector entries
num_ptrs += 2 * AUXV_ENTRIES; // auxv vector entries
num_bytes += oe_strlen(at_platform) + 1; // AT_PLATFORM
num_bytes += 16; // AT_RANDOM
num_bytes += 16; // AT_RANDOM

elf64_stack_t* stack = &sgxlkl_enclave_state.elf64_stack;
stack->data = oe_calloc_or_die(
Expand Down
2 changes: 0 additions & 2 deletions src/lkl/setup.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* clang-format off */

#include <arpa/inet.h>
#include <ctype.h>
#include <errno.h>
Expand Down

0 comments on commit 6ae4dd4

Please sign in to comment.