@@ -60,6 +60,7 @@ struct encl_op_eaccept {
struct encl_op_header header;
uint64_t epc_addr;
uint64_t flags;
+ uint64_t len;
uint64_t ret;
};
@@ -35,14 +35,22 @@ static void do_encl_eaccept(void *_op)
struct sgx_secinfo secinfo __aligned(sizeof(struct sgx_secinfo)) = {0};
struct encl_op_eaccept *op = _op;
int rax;
+ if (op->len == 0)
+ op->len = 4096;
secinfo.flags = op->flags;
-
- asm volatile(".byte 0x0f, 0x01, 0xd7"
- : "=a" (rax)
- : "a" (EACCEPT),
- "b" (&secinfo),
- "c" (op->epc_addr));
+ for (uint64_t addr = op->epc_addr;
+ addr < op->epc_addr + op->len; addr += 4096) {
+ asm volatile(".byte 0x0f, 0x01, 0xd7"
+ : "=a" (rax)
+ : "a" (EACCEPT),
+ "b" (&secinfo),
+ "c" (addr));
+ if (rax) {
+ op->ret = rax;
+ return;
+ }
+ }
op->ret = rax;
}
So we can EACCEPT multiple pages inside enclave without EEXIT, preparing for testing with MADV_WILLNEED for ranges bigger than a single page. Signed-off-by: Haitao Huang <haitao.huang@linux.intel.com> --- tools/testing/selftests/sgx/defines.h | 1 + tools/testing/selftests/sgx/test_encl.c | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-)