-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switched some of the SBI calls over to a struct-passing system. Only …
…CREATE and RUN have changed for now.
- Loading branch information
David Kohlbrenner
committed
Nov 1, 2018
1 parent
c9718ce
commit 6ed5bd9
Showing
6 changed files
with
121 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef _KEYSTONE_SBI_ARG_H_ | ||
#define _KEYSTONE_SBI_ARG_H_ | ||
|
||
struct keystone_sbi_pregion_t | ||
{ | ||
uintptr_t paddr; | ||
size_t size; | ||
}; | ||
|
||
struct keystone_sbi_create_t | ||
{ | ||
// Memory regions for the enclave | ||
struct keystone_sbi_pregion_t epm_region; | ||
struct keystone_sbi_pregion_t copy_region; | ||
|
||
// Outputs from the creation process | ||
unsigned int* eid_pptr; | ||
}; | ||
|
||
|
||
struct keystone_sbi_run_t | ||
{ | ||
unsigned int eid; | ||
uintptr_t entry_ptr; | ||
uintptr_t* ret_ptr; | ||
}; | ||
|
||
struct keystone_sbi_general_t | ||
{ | ||
unsigned int eid; | ||
}; | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,19 @@ | |
#include "enclave.h" | ||
#include <errno.h> | ||
|
||
uintptr_t mcall_sm_create_enclave(unsigned long base, unsigned long size, unsigned long eidptr) | ||
|
||
uintptr_t mcall_sm_create_enclave(uintptr_t create_args) | ||
{ | ||
struct keystone_sbi_create_t create_args_local; | ||
enclave_ret_t ret; | ||
ret = create_enclave((uintptr_t) base, (size_t) size, (unsigned int*) eidptr); | ||
ret = copy_region_from_host((struct keystone_sbi_create_t*)create_args, | ||
This comment has been minimized.
Sorry, something went wrong.
dayeol
Contributor
|
||
&create_args_local, | ||
sizeof(struct keystone_sbi_create_t)); | ||
|
||
if( ret != ENCLAVE_SUCCESS ) | ||
return ret; | ||
|
||
ret = create_enclave(create_args_local); | ||
return ret; | ||
} | ||
|
||
|
@@ -18,12 +27,24 @@ uintptr_t mcall_sm_destroy_enclave(unsigned long eid) | |
ret = destroy_enclave((unsigned int)eid); | ||
return ret; | ||
} | ||
|
||
uintptr_t mcall_sm_run_enclave(uintptr_t* host_regs, unsigned long eid, unsigned long ptr, unsigned long retval) | ||
uintptr_t mcall_sm_run_enclave(uintptr_t* regs, uintptr_t run_args, uintptr_t* entry_point) | ||
{ | ||
if(get_host_satp(eid) != read_csr(satp)) | ||
struct keystone_sbi_run_t run_args_local; | ||
enclave_ret_t ret; | ||
ret = copy_region_from_host((struct keystone_sbi_run_t*)run_args, | ||
This comment has been minimized.
Sorry, something went wrong. |
||
&run_args_local, | ||
sizeof(struct keystone_sbi_run_t)); | ||
|
||
if( ret != ENCLAVE_SUCCESS ) | ||
return ret; | ||
|
||
if(get_host_satp(run_args_local.eid) != read_csr(satp)) | ||
return ENCLAVE_NOT_ACCESSIBLE; | ||
return run_enclave(host_regs, (unsigned int) eid, (uintptr_t) ptr, (unsigned long*) retval); | ||
|
||
ret = run_enclave(regs, run_args_local); | ||
if( ret == ENCLAVE_SUCCESS ) | ||
*entry_point = run_args_local.entry_ptr; | ||
return ret; | ||
} | ||
|
||
uintptr_t mcall_sm_resume_enclave(uintptr_t* host_regs, unsigned long eid) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@dkohlbre See comments below,
Current usecase of this function only copies the OS input to SM local memory, which does not have to be checked for the overlaps with enclaves.
This function could be useful when the untrusted OS copies its data into an arbitrary physical address that the OS provides.
However, I think that the better way is to treat "untrusted memory" as an additional PMP region, and move overlap detection to region creation.
Then the PMP region can be referred by both of the OS (host) and the enclave using their own mapped virtual address, not physical address.