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

Commit

Permalink
Merge pull request #52 from keystone-enclave/fix-multimem-sbi
Browse files Browse the repository at this point in the history
Update multimem SBI calls to get output in arg0
  • Loading branch information
dayeol authored Apr 20, 2021
2 parents 44dda3a + 5e05188 commit 9fbe2ac
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
14 changes: 8 additions & 6 deletions paging.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,24 @@ void paging_dec_user_page(void)

void init_paging(uintptr_t user_pa_start, uintptr_t user_pa_end)
{
uintptr_t addr;
uintptr_t size;
uintptr_t addr = 0;
uintptr_t size = 0;
uintptr_t* trap_table = &rt_trap_table;

/* query if there is backing store */
size = MEGAPAGE_DOWN(sbi_query_multimem());
int ret = sbi_query_multimem(&size);
size = MEGAPAGE_DOWN(size);

if (!size) {
if (ret || !size) {
warn("no backing store found\n");
return;
}

/* query the backing store PA */
addr = MEGAPAGE_UP(sbi_query_multimem_addr());
ret = sbi_query_multimem_addr(&addr);
addr = MEGAPAGE_UP(addr);

if (!addr) {
if (ret || !addr) {
warn("address is zero\n");
return;
}
Expand Down
12 changes: 6 additions & 6 deletions sbi.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ sbi_random() {
}

uintptr_t
sbi_query_multimem() {
return SBI_CALL_2(SBI_EXT_EXPERIMENTAL_KEYSTONE_ENCLAVE,
SBI_SM_CALL_PLUGIN, SM_MULTIMEM_PLUGIN_ID, SM_MULTIMEM_CALL_GET_SIZE);
sbi_query_multimem(size_t *size) {
return SBI_CALL_3(SBI_EXT_EXPERIMENTAL_KEYSTONE_ENCLAVE,
SBI_SM_CALL_PLUGIN, SM_MULTIMEM_PLUGIN_ID, SM_MULTIMEM_CALL_GET_SIZE, size);
}

uintptr_t
sbi_query_multimem_addr() {
return SBI_CALL_2(SBI_EXT_EXPERIMENTAL_KEYSTONE_ENCLAVE,
SBI_SM_CALL_PLUGIN, SM_MULTIMEM_PLUGIN_ID, SM_MULTIMEM_CALL_GET_ADDR);
sbi_query_multimem_addr(uintptr_t *addr) {
return SBI_CALL_3(SBI_EXT_EXPERIMENTAL_KEYSTONE_ENCLAVE,
SBI_SM_CALL_PLUGIN, SM_MULTIMEM_PLUGIN_ID, SM_MULTIMEM_CALL_GET_ADDR, addr);
}

uintptr_t
Expand Down
5 changes: 3 additions & 2 deletions sbi.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define __SBI_H_

#include <stdint.h>
#include <stddef.h>

#define SBI_SET_TIMER 0
#define SBI_CONSOLE_PUTCHAR 1
Expand Down Expand Up @@ -38,9 +39,9 @@ sbi_exit_enclave(uint64_t retval);
uintptr_t
sbi_random();
uintptr_t
sbi_query_multimem();
sbi_query_multimem(size_t *size);
uintptr_t
sbi_query_multimem_addr();
sbi_query_multimem_addr(uintptr_t *addr);
uintptr_t
sbi_attest_enclave(void* report, void* buf, uintptr_t len);
uintptr_t
Expand Down

0 comments on commit 9fbe2ac

Please sign in to comment.