summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorAndy Fiddaman <omnios@citrus-it.co.uk>2019-02-07 00:02:27 +0000
committerPatrick Mooney <pmooney@pfmooney.com>2020-04-28 16:44:52 +0000
commit454f0c49f9d5b08ab88fe3db5788d9e5e6a7cf0f (patch)
tree4e80bd57e2dc498ab4bbef42396b1a9e1ff9539d /usr/src
parent761dea5e2659dff417ad5cdddda547702c3966ae (diff)
downloadillumos-joyent-454f0c49f9d5b08ab88fe3db5788d9e5e6a7cf0f.tar.gz
12529 want exclusive hma registration
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com> Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com> Reviewed by: Toomas Soome <tsoome@me.com> Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/pkg/manifests/system-header.mf1
-rw-r--r--usr/src/uts/i86pc/os/hma.c59
-rw-r--r--usr/src/uts/i86pc/sys/Makefile1
-rw-r--r--usr/src/uts/i86pc/sys/hma.h1
4 files changed, 50 insertions, 12 deletions
diff --git a/usr/src/pkg/manifests/system-header.mf b/usr/src/pkg/manifests/system-header.mf
index bb961d21ce..0a3e045e1a 100644
--- a/usr/src/pkg/manifests/system-header.mf
+++ b/usr/src/pkg/manifests/system-header.mf
@@ -1677,6 +1677,7 @@ $(i386_ONLY)file path=usr/platform/i86pc/include/sys/cram.h
$(i386_ONLY)file path=usr/platform/i86pc/include/sys/ddi_subrdefs.h
$(i386_ONLY)file path=usr/platform/i86pc/include/sys/debug_info.h
$(i386_ONLY)file path=usr/platform/i86pc/include/sys/fastboot.h
+$(i386_ONLY)file path=usr/platform/i86pc/include/sys/hma.h
$(i386_ONLY)file path=usr/platform/i86pc/include/sys/mach_mmu.h
$(i386_ONLY)file path=usr/platform/i86pc/include/sys/machclock.h
$(i386_ONLY)file path=usr/platform/i86pc/include/sys/machcpuvar.h
diff --git a/usr/src/uts/i86pc/os/hma.c b/usr/src/uts/i86pc/os/hma.c
index 9678894da0..a41ff3e0d1 100644
--- a/usr/src/uts/i86pc/os/hma.c
+++ b/usr/src/uts/i86pc/os/hma.c
@@ -32,6 +32,7 @@ struct hma_reg {
static kmutex_t hma_lock;
static list_t hma_registrations;
+static boolean_t hma_exclusive = B_FALSE;
static boolean_t hma_vmx_ready = B_FALSE;
static const char *hma_vmx_error = NULL;
@@ -100,18 +101,14 @@ hma_init(void)
}
}
-hma_reg_t *
-hma_register(const char *name)
+static hma_reg_t *
+hma_register_backend(const char *name)
{
struct hma_reg *reg;
boolean_t is_ready;
- VERIFY(name != NULL);
-
- reg = kmem_zalloc(sizeof (*reg), KM_SLEEP);
- reg->hr_name = name;
+ ASSERT(MUTEX_HELD(&hma_lock));
- mutex_enter(&hma_lock);
switch (cpuid_getvendor(CPU)) {
case X86_VENDOR_Intel:
is_ready = hma_vmx_ready;
@@ -124,12 +121,48 @@ hma_register(const char *name)
break;
}
- if (!is_ready) {
- kmem_free(reg, sizeof (*reg));
- reg = NULL;
- } else {
- list_insert_tail(&hma_registrations, reg);
+ if (!is_ready)
+ return (NULL);
+
+ reg = kmem_zalloc(sizeof (*reg), KM_SLEEP);
+ reg->hr_name = name;
+ list_insert_tail(&hma_registrations, reg);
+
+ return (reg);
+}
+
+hma_reg_t *
+hma_register(const char *name)
+{
+ struct hma_reg *reg = NULL;
+
+ VERIFY(name != NULL);
+
+ mutex_enter(&hma_lock);
+
+ if (!hma_exclusive)
+ reg = hma_register_backend(name);
+
+ mutex_exit(&hma_lock);
+
+ return (reg);
+}
+
+hma_reg_t *
+hma_register_exclusive(const char *name)
+{
+ struct hma_reg *reg = NULL;
+
+ VERIFY(name != NULL);
+
+ mutex_enter(&hma_lock);
+
+ if (list_is_empty(&hma_registrations)) {
+ reg = hma_register_backend(name);
+ if (reg != NULL)
+ hma_exclusive = B_TRUE;
}
+
mutex_exit(&hma_lock);
return (reg);
@@ -143,6 +176,8 @@ hma_unregister(hma_reg_t *reg)
mutex_enter(&hma_lock);
list_remove(&hma_registrations, reg);
+ if (hma_exclusive && list_is_empty(&hma_registrations))
+ hma_exclusive = B_FALSE;
mutex_exit(&hma_lock);
kmem_free(reg, sizeof (*reg));
}
diff --git a/usr/src/uts/i86pc/sys/Makefile b/usr/src/uts/i86pc/sys/Makefile
index 292cd04c2b..8eff4c905c 100644
--- a/usr/src/uts/i86pc/sys/Makefile
+++ b/usr/src/uts/i86pc/sys/Makefile
@@ -46,6 +46,7 @@ HDRS= \
ddi_subrdefs.h \
debug_info.h \
fastboot.h \
+ hma.h \
mach_mmu.h \
machclock.h \
machcpuvar.h \
diff --git a/usr/src/uts/i86pc/sys/hma.h b/usr/src/uts/i86pc/sys/hma.h
index 688f09bfb7..16ab708896 100644
--- a/usr/src/uts/i86pc/sys/hma.h
+++ b/usr/src/uts/i86pc/sys/hma.h
@@ -38,6 +38,7 @@ extern "C" {
*/
typedef struct hma_reg hma_reg_t;
extern hma_reg_t *hma_register(const char *);
+extern hma_reg_t *hma_register_exclusive(const char *);
extern void hma_unregister(hma_reg_t *);
/*