svn commit: r322660 - head/sys/amd64/sgx
Ruslan Bukin
br at FreeBSD.org
Fri Aug 18 14:47:08 UTC 2017
Author: br
Date: Fri Aug 18 14:47:06 2017
New Revision: 322660
URL: https://svnweb.freebsd.org/changeset/base/322660
Log:
Fix module unload when SGX support is not present in CPU.
Sponsored by: DARPA, AFRL
Modified:
head/sys/amd64/sgx/sgx.c
Modified: head/sys/amd64/sgx/sgx.c
==============================================================================
--- head/sys/amd64/sgx/sgx.c Fri Aug 18 14:30:12 2017 (r322659)
+++ head/sys/amd64/sgx/sgx.c Fri Aug 18 14:47:06 2017 (r322660)
@@ -1132,9 +1132,6 @@ sgx_load(void)
if ((cpu_stdext_feature & CPUID_STDEXT_SGX) == 0)
return (ENXIO);
- mtx_init(&sc->mtx_encls, "SGX ENCLS", NULL, MTX_DEF);
- mtx_init(&sc->mtx, "SGX driver", NULL, MTX_DEF);
-
error = sgx_get_epc_area(sc);
if (error) {
printf("%s: Failed to get Processor Reserved Memory area.\n",
@@ -1142,6 +1139,9 @@ sgx_load(void)
return (ENXIO);
}
+ mtx_init(&sc->mtx_encls, "SGX ENCLS", NULL, MTX_DEF);
+ mtx_init(&sc->mtx, "SGX driver", NULL, MTX_DEF);
+
TAILQ_INIT(&sc->enclaves);
sc->sgx_cdev = make_dev(&sgx_cdevsw, 0, UID_ROOT, GID_WHEEL,
@@ -1161,6 +1161,9 @@ sgx_unload(void)
struct sgx_softc *sc;
sc = &sgx_sc;
+
+ if ((sc->state & SGX_STATE_RUNNING) == 0)
+ return (0);
mtx_lock(&sc->mtx);
if (!TAILQ_EMPTY(&sc->enclaves)) {
More information about the svn-src-all
mailing list