diff options
author | Mike Larkin <mlarkin@cvs.openbsd.org> | 2015-12-06 18:31:27 +0000 |
---|---|---|
committer | Mike Larkin <mlarkin@cvs.openbsd.org> | 2015-12-06 18:31:27 +0000 |
commit | bfc9361963796259733fa920fbcc8347525ec170 (patch) | |
tree | 606386f11f696bc900b291a89fe7006e316c945f /sys/arch | |
parent | bdfac6fb6d9c228b1e2bd1606d42f9f9879064ac (diff) |
don't allow opening of /dev/vmm if we are in an unsupported configuration
or if vmm0 didn't attach, prevents later panics if we try to use vmm in
such a state.
reported by many on tech/misc
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/amd64/vmm.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sys/arch/amd64/amd64/vmm.c b/sys/arch/amd64/amd64/vmm.c index 4459933af98..fcb942d7904 100644 --- a/sys/arch/amd64/amd64/vmm.c +++ b/sys/arch/amd64/amd64/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.16 2015/12/06 01:16:58 mlarkin Exp $ */ +/* $OpenBSD: vmm.c,v 1.17 2015/12/06 18:31:26 mlarkin Exp $ */ /* * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org> * @@ -287,6 +287,15 @@ vmm_activate(struct device *self, int act) int vmmopen(dev_t dev, int flag, int mode, struct proc *p) { + /* Don't allow open if we didn't attach */ + if (vmm_softc == NULL) + return (ENODEV); + + /* Don't allow open if we didn't detect any supported CPUs */ + /* XXX presently this means EPT until SP and SVM are back */ + if (vmm_softc->mode != VMM_MODE_EPT) + return (ENODEV); + return 0; } @@ -301,10 +310,6 @@ vmmioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) { int ret; - /* Don't allow ioctls if we have no supported CPUs */ - if (vmm_softc->mode == VMM_MODE_UNKNOWN) - return (ENOTTY); - switch (cmd) { case VMM_IOC_CREATE: if ((ret = vmm_start()) != 0) { |