Skip to content
Permalink
Browse files

Implement oe_*_ocall_buffer for OP-TEE specifically.

  • Loading branch information
HernanGatta committed Jul 27, 2019
1 parent 677ffe6 commit c96a0962735f77824374bb94c9fd2731fd482fb7
Showing with 45 additions and 14 deletions.
  1. +2 −0 enclave/core/CMakeLists.txt
  2. +0 −14 enclave/core/hostcalls.c
  3. +24 −0 enclave/core/optee/hostcalls.c
  4. +19 −0 enclave/core/sgx/hostcalls.c
@@ -56,6 +56,7 @@ if (OE_SGX)
sgx/entropy.c
sgx/exception.c
sgx/globals.c
sgx/hostcalls.c
sgx/init.c
sgx/sgx_t_wrapper.c
sgx/jump.c
@@ -92,6 +93,7 @@ elseif (OE_TRUSTZONE)
optee/calls.c
optee/entropy.c
optee/header.c
optee/hostcalls.c
optee/globals.c
optee/gp.c
optee/keys.c
@@ -149,20 +149,6 @@ int oe_host_fprintf(int device, const char* fmt, ...)
return n;
}

// Function used by oeedger8r for allocating ocall buffers. This function can be
// optimized by allocating a buffer for making ocalls and pass it in to the
// ecall and making it available for use here.
void* oe_allocate_ocall_buffer(size_t size)
{
return oe_host_malloc(size);
}

// Function used by oeedger8r for freeing ocall buffers.
void oe_free_ocall_buffer(void* buffer)
{
oe_host_free(buffer);
}

// Function used by oeedger8r for allocating switchless ocall buffers.
// There are two possible approaches to implementing this function:
// 1. Preallocate a pool of host memory per thread for switchless ocalls
@@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#include <openenclave/corelibc/stdlib.h>
#include <openenclave/edger8r/enclave.h>
#include <openenclave/enclave.h>

// Function used by oeedger8r for allocating ocall buffers. This function can be
// optimized by allocating a buffer for making ocalls and pass it in to the
// ecall and making it available for use here.
//
// TODO: These are allocated inside the TA and subsequently marshalled by
// oe_ocall via libutee. This means that the arguments structure is
// needlessly copied twice in OP-TEE.
void* oe_allocate_ocall_buffer(size_t size)
{
return oe_malloc(size);
}

// Function used by oeedger8r for freeing ocall buffers.
void oe_free_ocall_buffer(void* buffer)
{
oe_free(buffer);
}
@@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#include <openenclave/edger8r/enclave.h>
#include <openenclave/enclave.h>

// Function used by oeedger8r for allocating ocall buffers. This function can be
// optimized by allocating a buffer for making ocalls and pass it in to the
// ecall and making it available for use here.
void* oe_allocate_ocall_buffer(size_t size)
{
return oe_host_malloc(size);
}

// Function used by oeedger8r for freeing ocall buffers.
void oe_free_ocall_buffer(void* buffer)
{
oe_host_free(buffer);
}

0 comments on commit c96a096

Please sign in to comment.
You can’t perform that action at this time.