From bfc9361963796259733fa920fbcc8347525ec170 Mon Sep 17 00:00:00 2001 From: Mike Larkin Date: Sun, 6 Dec 2015 18:31:27 +0000 Subject: 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 --- sys/arch/amd64/amd64/vmm.c | 15 ++++++++++----- 1 file 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 * @@ -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) { -- cgit v1.2.3