Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/nvmm Don't allow unloading when there are still VMs ...
details: https://anonhg.NetBSD.org/src/rev/a498994268cf
branches: trunk
changeset: 998097:a498994268cf
user: maxv <maxv%NetBSD.org@localhost>
date: Sun Apr 07 14:05:15 2019 +0000
description:
Don't allow unloading when there are still VMs registered, and don't allow
auto-unloading at all. Not a big problem actually, because since I changed
the module class it's not auto-loadable anymore.
diffstat:
sys/dev/nvmm/nvmm.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diffs (70 lines):
diff -r d2a1608931c0 -r a498994268cf sys/dev/nvmm/nvmm.c
--- a/sys/dev/nvmm/nvmm.c Sun Apr 07 13:50:29 2019 +0000
+++ b/sys/dev/nvmm/nvmm.c Sun Apr 07 14:05:15 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm.c,v 1.12 2019/03/28 19:00:40 maxv Exp $ */
+/* $NetBSD: nvmm.c,v 1.13 2019/04/07 14:05:15 maxv Exp $ */
/*
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.12 2019/03/28 19:00:40 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.13 2019/04/07 14:05:15 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -53,6 +53,7 @@
#include <dev/nvmm/nvmm_ioctl.h>
static struct nvmm_machine machines[NVMM_MAX_MACHINES];
+static volatile unsigned int nmachines __cacheline_aligned;
static const struct nvmm_impl *nvmm_impl_list[] = {
&nvmm_x86_svm, /* x86 AMD SVM */
@@ -80,6 +81,7 @@
mach->present = true;
*ret = mach;
+ atomic_inc_uint(&nmachines);
return 0;
}
@@ -92,6 +94,7 @@
KASSERT(rw_write_held(&mach->lock));
KASSERT(mach->present);
mach->present = false;
+ atomic_dec_uint(&nmachines);
}
static int
@@ -845,7 +848,6 @@
for (n = 0; n < NVMM_MAX_VCPUS; n++) {
mutex_destroy(&machines[i].cpus[n].lock);
}
- /* TODO need to free stuff, etc */
}
(*nvmm_impl->fini)();
@@ -963,6 +965,9 @@
return 0;
case MODULE_CMD_FINI:
+ if (nmachines > 0) {
+ return EBUSY;
+ }
#if defined(_MODULE)
{
error = devsw_detach(NULL, &nvmm_cdevsw);
@@ -974,6 +979,9 @@
nvmm_fini();
return 0;
+ case MODULE_CMD_AUTOUNLOAD:
+ return EBUSY;
+
default:
return ENOTTY;
}
Home |
Main Index |
Thread Index |
Old Index