Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Update multimem SBIs to not output value in retval #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/mprv.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int copy_block_to_sm(mprv_block *dst, uintptr_t src);
#define REGBYTES (1 << LOG_REGBYTES)
#define MPRV_BLOCK (REGBYTES * 8)

int copy_from_sm(uintptr_t dst, void *src_buf, size_t len)
static inline int copy_from_sm(uintptr_t dst, void *src_buf, size_t len)
{
uintptr_t src = (uintptr_t)src_buf;

Expand Down Expand Up @@ -63,7 +63,7 @@ int copy_from_sm(uintptr_t dst, void *src_buf, size_t len)
return 0;
}

int copy_to_sm(void *dst_buf, uintptr_t src, size_t len)
static inline int copy_to_sm(void *dst_buf, uintptr_t src, size_t len)
{
uintptr_t dst = (uintptr_t)dst_buf;

Expand Down
22 changes: 15 additions & 7 deletions src/plugins/multimem.c
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
#include "plugins/multimem.h"
#include "sm.h"
#include <sbi/sbi_console.h>
#include "mprv.h"

uintptr_t multimem_get_other_region_size(enclave_id eid)
uintptr_t multimem_get_other_region_size(enclave_id eid, size_t *size_out)
{
int mem_id = get_enclave_region_index(eid, REGION_OTHER);
return get_enclave_region_size(eid, mem_id);
if (mem_id == -1)
return -1;
size_t out = get_enclave_region_size(eid, mem_id);
return copy_word_from_sm((uintptr_t)size_out, &out);
}

uintptr_t multimem_get_other_region_addr(enclave_id eid)
uintptr_t multimem_get_other_region_addr(enclave_id eid, size_t *size_out)
{
int mem_id = get_enclave_region_index(eid, REGION_OTHER);
return get_enclave_region_base(eid, mem_id);
if (mem_id == -1)
return -1;
size_t out = get_enclave_region_base(eid, mem_id);
return copy_word_from_sm((uintptr_t)size_out, &out);
}

uintptr_t do_sbi_multimem(enclave_id eid, uintptr_t call_id)
uintptr_t do_sbi_multimem(enclave_id eid, uintptr_t call_id, uintptr_t arg0)
{
switch(call_id)
{
case MULTIMEM_GET_OTHER_REGION_SIZE:
return multimem_get_other_region_size(eid);
return multimem_get_other_region_size(eid, (size_t *)arg0);
case MULTIMEM_GET_OTHER_REGION_ADDR:
return multimem_get_other_region_addr(eid);
return multimem_get_other_region_addr(eid, (size_t *)arg0);
default:
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/multimem.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
#define MULTIMEM_GET_OTHER_REGION_SIZE 0x1
#define MULTIMEM_GET_OTHER_REGION_ADDR 0x2

uintptr_t do_sbi_multimem(enclave_id id, uintptr_t call_id);
uintptr_t do_sbi_multimem(enclave_id id, uintptr_t call_id, uintptr_t arg0);

#endif
2 changes: 1 addition & 1 deletion src/plugins/plugins.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ call_plugin(
switch(plugin_id) {
#ifdef PLUGIN_ENABLE_MULTIMEM
case PLUGIN_ID_MULTIMEM:
return do_sbi_multimem(id, call_id);
return do_sbi_multimem(id, call_id, arg0);
break;
#endif
default:
Expand Down