@@ -218,18 +218,38 @@ static void sgx_ipi_cb(void *info)
{
}
-static void sgx_eblock(struct sgx_epc_page *epc_page)
+static void sgx_eblock(struct sgx_encl *encl,
+ struct sgx_epc_page *epc_page)
{
- void *vaddr = sgx_get_epc_page(epc_page);
- BUG_ON(__eblock((unsigned long)vaddr));
+ void *vaddr;
+ int ret;
+
+ vaddr = sgx_get_epc_page(epc_page);
+ ret = __eblock((unsigned long)vaddr);
sgx_put_epc_page(vaddr);
+
+ if (ret) {
+ sgx_crit(encl, "EBLOCK returned %d\n", ret);
+ sgx_invalidate(encl);
+ smp_call_function(sgx_ipi_cb, NULL, 1);
+ }
+
}
-static void sgx_etrack(struct sgx_epc_page *epc_page)
+static void sgx_etrack(struct sgx_encl *encl)
{
- void *epc = sgx_get_epc_page(epc_page);
- BUG_ON(__etrack(epc));
+ void *epc;
+ int ret;
+
+ epc = sgx_get_epc_page(encl->secs_page.epc_page);
+ ret = __etrack(epc);
sgx_put_epc_page(epc);
+
+ if (ret) {
+ sgx_crit(encl, "ETRACK returned %d\n", ret);
+ sgx_invalidate(encl);
+ smp_call_function(sgx_ipi_cb, NULL, 1);
+ }
}
static int __sgx_ewb(struct sgx_encl *encl,
@@ -318,11 +338,11 @@ static void sgx_write_pages(struct sgx_encl *encl, struct list_head *src)
}
zap_vma_ptes(evma, entry->addr, PAGE_SIZE);
- sgx_eblock(entry->epc_page);
+ sgx_eblock(encl, entry->epc_page);
}
/* ETRACK */
- sgx_etrack(encl->secs_page.epc_page);
+ sgx_etrack(encl);
/* EWB */
while (!list_empty(src)) {
If the driver is operating correctly EBLOCK and ETRACK should never fail. This commit changes the error recovery from BUG() to killing the enclave if that ever happens as the use of BUG() is not favored in the mainline and also because this will ease the debugging in this situation. Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> --- drivers/platform/x86/intel_sgx_page_cache.c | 36 ++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 8 deletions(-)