diff options
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r-- | sys/arch/amd64/amd64/mainbus.c | 11 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/vmm.c | 31 |
2 files changed, 23 insertions, 19 deletions
diff --git a/sys/arch/amd64/amd64/mainbus.c b/sys/arch/amd64/amd64/mainbus.c index 2d280b055dc..fbc226bcc8b 100644 --- a/sys/arch/amd64/amd64/mainbus.c +++ b/sys/arch/amd64/amd64/mainbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mainbus.c,v 1.38 2016/07/28 21:57:57 kettenis Exp $ */ +/* $OpenBSD: mainbus.c,v 1.39 2017/03/25 22:24:01 deraadt Exp $ */ /* $NetBSD: mainbus.c,v 1.1 2003/04/26 18:39:29 fvdl Exp $ */ /* @@ -159,6 +159,9 @@ mainbus_attach(struct device *parent, struct device *self, void *aux) #if NPCI > 0 union mainbus_attach_args mba; #endif +#if NVMM > 0 + extern int vmm_enabled(void); +#endif extern void (*setperf_setup)(struct cpu_info *); printf("\n"); @@ -246,8 +249,10 @@ mainbus_attach(struct device *parent, struct device *self, void *aux) #endif #if NVMM > 0 - mba.mba_busname = "vmm"; - config_found(self, &mba.mba_busname, mainbus_print); + if (vmm_enabled()) { + mba.mba_busname = "vmm"; + config_found(self, &mba.mba_busname, mainbus_print); + } #endif /* NVMM > 0 */ #if NEFIFB > 0 diff --git a/sys/arch/amd64/amd64/vmm.c b/sys/arch/amd64/amd64/vmm.c index 02fc76d2ca0..d2a18fddb20 100644 --- a/sys/arch/amd64/amd64/vmm.c +++ b/sys/arch/amd64/amd64/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.125 2017/03/24 09:06:02 mlarkin Exp $ */ +/* $OpenBSD: vmm.c,v 1.126 2017/03/25 22:24:01 deraadt Exp $ */ /* * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org> * @@ -100,6 +100,7 @@ struct vmm_softc { size_t vm_idx; /* next unique VM index */ }; +int vmm_enabled(void); int vmm_probe(struct device *, void *, void *); void vmm_attach(struct device *, struct device *, void *); int vmmopen(dev_t, int, int, struct proc *); @@ -259,26 +260,17 @@ extern struct gate_descriptor *idt; #define CR_LMSW 3 /* - * vmm_probe + * vmm_enabled * * Checks if we have at least one CPU with either VMX or SVM. * Returns 1 if we have at least one of either type, but not both, 0 otherwise. */ int -vmm_probe(struct device *parent, void *match, void *aux) +vmm_enabled(void) { struct cpu_info *ci; CPU_INFO_ITERATOR cii; - const char **busname = (const char **)aux; - int found_vmx, found_svm, vmm_disabled; - - /* Check if this probe is for us */ - if (strcmp(*busname, vmm_cd.cd_name) != 0) - return (0); - - found_vmx = 0; - found_svm = 0; - vmm_disabled = 0; + int found_vmx = 0, found_svm = 0, vmm_disabled = 0; /* Check if we have at least one CPU with either VMX or SVM */ CPU_INFO_FOREACH(cii, ci) { @@ -298,12 +290,19 @@ vmm_probe(struct device *parent, void *match, void *aux) if (found_vmx) return 1; - if (vmm_disabled) - printf("vmm disabled by firmware\n"); - return 0; } +int +vmm_probe(struct device *parent, void *match, void *aux) +{ + const char **busname = (const char **)aux; + + if (strcmp(*busname, vmm_cd.cd_name) != 0) + return (0); + return (1); +} + /* * vmm_attach * |