Tue Mar 7 20:26:12 2017 UTC ()
Pull up following revision(s) (requested by jnmeth in ticket #1328):
	sys/arch/xen/xen/hypervisor.c: revision 1.67
add machdep.xen.version sysctl to easily get hypervisor version


(snj)
diff -r1.65 -r1.65.4.1 src/sys/arch/xen/xen/hypervisor.c

cvs diff -r1.65 -r1.65.4.1 src/sys/arch/xen/xen/hypervisor.c (expand / switch to unified diff)

--- src/sys/arch/xen/xen/hypervisor.c 2014/02/01 20:07:07 1.65
+++ src/sys/arch/xen/xen/hypervisor.c 2017/03/07 20:26:12 1.65.4.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: hypervisor.c,v 1.65 2014/02/01 20:07:07 bouyer Exp $ */ 1/* $NetBSD: hypervisor.c,v 1.65.4.1 2017/03/07 20:26:12 snj Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2005 Manuel Bouyer. 4 * Copyright (c) 2005 Manuel Bouyer.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -43,32 +43,33 @@ @@ -43,32 +43,33 @@
43 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 43 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
44 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 44 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
45 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 45 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
46 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 46 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 47 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
48 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 48 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
49 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 49 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
50 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 50 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
51 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 51 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 */ 52 */
53 53
54 54
55#include <sys/cdefs.h> 55#include <sys/cdefs.h>
56__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.65 2014/02/01 20:07:07 bouyer Exp $"); 56__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.65.4.1 2017/03/07 20:26:12 snj Exp $");
57 57
58#include <sys/param.h> 58#include <sys/param.h>
59#include <sys/systm.h> 59#include <sys/systm.h>
60#include <sys/device.h> 60#include <sys/device.h>
61#include <sys/malloc.h> 61#include <sys/malloc.h>
 62#include <sys/sysctl.h>
62 63
63#include "xenbus.h" 64#include "xenbus.h"
64#include "xencons.h" 65#include "xencons.h"
65#include "isa.h" 66#include "isa.h"
66#include "pci.h" 67#include "pci.h"
67#include "acpica.h" 68#include "acpica.h"
68 69
69#include "opt_xen.h" 70#include "opt_xen.h"
70#include "opt_mpbios.h" 71#include "opt_mpbios.h"
71 72
72#include <xen/xen.h> 73#include <xen/xen.h>
73#include <xen/hypervisor.h> 74#include <xen/hypervisor.h>
74#include <xen/evtchn.h> 75#include <xen/evtchn.h>
@@ -193,34 +194,52 @@ hypervisor_vcpu_print(void *aux, const c @@ -193,34 +194,52 @@ hypervisor_vcpu_print(void *aux, const c
193 * Attach the hypervisor. 194 * Attach the hypervisor.
194 */ 195 */
195void 196void
196hypervisor_attach(device_t parent, device_t self, void *aux) 197hypervisor_attach(device_t parent, device_t self, void *aux)
197{ 198{
198 199
199#if NPCI >0 200#if NPCI >0
200#ifdef PCI_BUS_FIXUP 201#ifdef PCI_BUS_FIXUP
201 int pci_maxbus = 0; 202 int pci_maxbus = 0;
202#endif 203#endif
203#endif /* NPCI */ 204#endif /* NPCI */
204 union hypervisor_attach_cookie hac; 205 union hypervisor_attach_cookie hac;
205 char xen_extra_version[XEN_EXTRAVERSION_LEN]; 206 char xen_extra_version[XEN_EXTRAVERSION_LEN];
 207 static char xen_version_string[20];
 208 int rc;
 209 const struct sysctlnode *node = NULL;
206 210
207 xenkernfs_init(); 211 xenkernfs_init();
208 212
209 xen_version = HYPERVISOR_xen_version(XENVER_version, NULL); 213 xen_version = HYPERVISOR_xen_version(XENVER_version, NULL);
210 memset(xen_extra_version, 0, sizeof(xen_extra_version)); 214 memset(xen_extra_version, 0, sizeof(xen_extra_version));
211 HYPERVISOR_xen_version(XENVER_extraversion, xen_extra_version); 215 HYPERVISOR_xen_version(XENVER_extraversion, xen_extra_version);
212 aprint_normal(": Xen version %d.%d%s\n", XEN_MAJOR(xen_version), 216 rc = snprintf(xen_version_string, 20, "%d.%d%s", XEN_MAJOR(xen_version),
213 XEN_MINOR(xen_version), xen_extra_version); 217 XEN_MINOR(xen_version), xen_extra_version);
 218 aprint_normal(": Xen version %s\n", xen_version_string);
 219 if (rc >= 20)
 220 aprint_debug(": xen_version_string truncated\n");
 221
 222 sysctl_createv(NULL, 0, NULL, &node, 0,
 223 CTLTYPE_NODE, "xen",
 224 SYSCTL_DESCR("Xen top level node"),
 225 NULL, 0, NULL, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL);
 226
 227 if (node != NULL) {
 228 sysctl_createv(NULL, 0, &node, NULL, CTLFLAG_READONLY,
 229 CTLTYPE_STRING, "version",
 230 SYSCTL_DESCR("Xen hypervisor version"),
 231 NULL, 0, xen_version_string, 0, CTL_CREATE, CTL_EOL);
 232 }
214 233
215 xengnt_init(); 234 xengnt_init();
216 events_init(); 235 events_init();
217 236
218 memset(&hac, 0, sizeof(hac)); 237 memset(&hac, 0, sizeof(hac));
219 hac.hac_vcaa.vcaa_name = "vcpu"; 238 hac.hac_vcaa.vcaa_name = "vcpu";
220 hac.hac_vcaa.vcaa_caa.cpu_number = 0; 239 hac.hac_vcaa.vcaa_caa.cpu_number = 0;
221 hac.hac_vcaa.vcaa_caa.cpu_role = CPU_ROLE_BP; 240 hac.hac_vcaa.vcaa_caa.cpu_role = CPU_ROLE_BP;
222 hac.hac_vcaa.vcaa_caa.cpu_func = NULL; /* See xen/x86/cpu.c:vcpu_attach() */ 241 hac.hac_vcaa.vcaa_caa.cpu_func = NULL; /* See xen/x86/cpu.c:vcpu_attach() */
223 config_found_ia(self, "xendevbus", &hac.hac_vcaa, hypervisor_print); 242 config_found_ia(self, "xendevbus", &hac.hac_vcaa, hypervisor_print);
224 243
225#ifdef MULTIPROCESSOR 244#ifdef MULTIPROCESSOR
226 245