Thu Apr 16 17:46:44 2020 UTC ()
Don't try to attach hypervisor on non Xen; no more error messages about
hypervisor when booting on bare metal.


(bouyer)
diff -r1.6.12.1 -r1.6.12.2 src/sys/arch/xen/x86/xen_mainbus.c

cvs diff -r1.6.12.1 -r1.6.12.2 src/sys/arch/xen/x86/xen_mainbus.c (expand / switch to unified diff)

--- src/sys/arch/xen/x86/xen_mainbus.c 2020/04/16 08:46:35 1.6.12.1
+++ src/sys/arch/xen/x86/xen_mainbus.c 2020/04/16 17:46:44 1.6.12.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: xen_mainbus.c,v 1.6.12.1 2020/04/16 08:46:35 bouyer Exp $ */ 1/* $NetBSD: xen_mainbus.c,v 1.6.12.2 2020/04/16 17:46:44 bouyer Exp $ */
2/* NetBSD: mainbus.c,v 1.19 2017/05/23 08:54:39 nonaka Exp */ 2/* NetBSD: mainbus.c,v 1.19 2017/05/23 08:54:39 nonaka Exp */
3/* NetBSD: mainbus.c,v 1.53 2003/10/27 14:11:47 junyoung Exp */ 3/* NetBSD: mainbus.c,v 1.53 2003/10/27 14:11:47 junyoung Exp */
4 4
5/* 5/*
6 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 6 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -23,27 +23,27 @@ @@ -23,27 +23,27 @@
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35#include <sys/cdefs.h> 35#include <sys/cdefs.h>
36__KERNEL_RCSID(0, "$NetBSD: xen_mainbus.c,v 1.6.12.1 2020/04/16 08:46:35 bouyer Exp $"); 36__KERNEL_RCSID(0, "$NetBSD: xen_mainbus.c,v 1.6.12.2 2020/04/16 17:46:44 bouyer Exp $");
37 37
38#include <sys/param.h> 38#include <sys/param.h>
39#include <sys/systm.h> 39#include <sys/systm.h>
40#include <sys/device.h> 40#include <sys/device.h>
41 41
42#include <sys/bus.h> 42#include <sys/bus.h>
43 43
44#include "hypervisor.h" 44#include "hypervisor.h"
45#include "pci.h" 45#include "pci.h"
46 46
47#include "opt_xen.h" 47#include "opt_xen.h"
48#include "opt_mpbios.h" 48#include "opt_mpbios.h"
49#include "opt_pcifixup.h" 49#include "opt_pcifixup.h"
@@ -111,38 +111,49 @@ union xen_mainbus_attach_args { @@ -111,38 +111,49 @@ union xen_mainbus_attach_args {
111#if NIPMI > 0 111#if NIPMI > 0
112 struct ipmi_attach_args mba_ipmi; 112 struct ipmi_attach_args mba_ipmi;
113#endif 113#endif
114}; 114};
115 115
116/* 116/*
117 * Attach the mainbus. 117 * Attach the mainbus.
118 */ 118 */
119void 119void
120xen_mainbus_attach(device_t parent, device_t self, void *aux) 120xen_mainbus_attach(device_t parent, device_t self, void *aux)
121{ 121{
122 union xen_mainbus_attach_args mba; 122 union xen_mainbus_attach_args mba;
123 123
 124 switch(vm_guest) {
 125 case VM_GUEST_XENPV:
124#if NIPMI > 0 && defined(XENPV) 126#if NIPMI > 0 && defined(XENPV)
125 memset(&mba.mba_ipmi, 0, sizeof(mba.mba_ipmi)); 127 memset(&mba.mba_ipmi, 0, sizeof(mba.mba_ipmi));
126 mba.mba_ipmi.iaa_iot = x86_bus_space_io; 128 mba.mba_ipmi.iaa_iot = x86_bus_space_io;
127 mba.mba_ipmi.iaa_memt = x86_bus_space_mem; 129 mba.mba_ipmi.iaa_memt = x86_bus_space_mem;
128 if (ipmi_probe(&mba.mba_ipmi)) 130 if (ipmi_probe(&mba.mba_ipmi))
129 config_found_ia(self, "ipmibus", &mba.mba_ipmi, 0); 131 config_found_ia(self, "ipmibus", &mba.mba_ipmi, 0);
130#endif 132#endif
131 133 /* FALLTHROUGH */
132 mba.mba_haa.haa_busname = "hypervisor"; 134 case VM_GUEST_XENHVM:
133 config_found_ia(self, "hypervisorbus", &mba.mba_haa, xen_mainbus_print); 135 mba.mba_haa.haa_busname = "hypervisor";
134 136 config_found_ia(self, "hypervisorbus",
135 /* save/restore for Xen */ 137 &mba.mba_haa, xen_mainbus_print);
136 if (!pmf_device_register(self, NULL, NULL)) 138 break;
137 aprint_error_dev(self, "couldn't establish power handler\n"); 139 default:
 140 return;
 141 }
 142
 143 if (vm_guest == VM_GUEST_XENPV) {
 144 /* save/restore for Xen */
 145 if (!pmf_device_register(self, NULL, NULL))
 146 aprint_error_dev(self,
 147 "couldn't establish power handler\n");
 148 }
138} 149}
139 150
140static int 151static int
141xen_mainbus_print(void *aux, const char *pnp) 152xen_mainbus_print(void *aux, const char *pnp)
142{ 153{
143 union xen_mainbus_attach_args *mba = aux; 154 union xen_mainbus_attach_args *mba = aux;
144 155
145 if (pnp) 156 if (pnp)
146 aprint_normal("%s at %s", mba->mba_busname, pnp); 157 aprint_normal("%s at %s", mba->mba_busname, pnp);
147 return UNCONF; 158 return UNCONF;
148} 159}