Module Name: src
Committed By: bouyer
Date: Wed Apr 8 17:59:17 UTC 2020
Modified Files:
src/sys/arch/amd64/amd64 [bouyer-xenpvh]: genassym.cf locore.S
src/sys/arch/i386/i386 [bouyer-xenpvh]: genassym.cf locore.S
src/sys/arch/x86/include [bouyer-xenpvh]: cpu.h
src/sys/arch/x86/x86 [bouyer-xenpvh]: identcpu.c lapic.c x86_machdep.c
src/sys/arch/xen/x86 [bouyer-xenpvh]: autoconf.c
src/sys/arch/xen/xen [bouyer-xenpvh]: hypervisor.c
Log Message:
Remove VM_GUEST_XEN and define only Xen subtypes:
VM_GUEST_XENPV
VM_GUEST_XENPVH
VM_GUEST_XENHVM
VM_GUEST_XENPVHVM
Set vm_guest in the start routine, if it is hypervisor-specific (e.g Xen PV).
If vm_guest was not set early and we detect Xen in identify_hypervisor(),
assume it is VM_GUEST_XENHVM. Refine to VM_GUEST_PVXENHVM in
hypervisor_match().
To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.82.4.1 src/sys/arch/amd64/amd64/genassym.cf
cvs rdiff -u -r1.200 -r1.200.4.1 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.119 -r1.119.4.1 src/sys/arch/i386/i386/genassym.cf
cvs rdiff -u -r1.179 -r1.179.2.1 src/sys/arch/i386/i386/locore.S
cvs rdiff -u -r1.117 -r1.117.4.1 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.102 -r1.102.2.1 src/sys/arch/x86/x86/identcpu.c
cvs rdiff -u -r1.76 -r1.76.6.1 src/sys/arch/x86/x86/lapic.c
cvs rdiff -u -r1.137 -r1.137.2.1 src/sys/arch/x86/x86/x86_machdep.c
cvs rdiff -u -r1.23 -r1.23.8.1 src/sys/arch/xen/x86/autoconf.c
cvs rdiff -u -r1.73 -r1.73.2.1 src/sys/arch/xen/xen/hypervisor.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/amd64/amd64/genassym.cf
diff -u src/sys/arch/amd64/amd64/genassym.cf:1.82 src/sys/arch/amd64/amd64/genassym.cf:1.82.4.1
--- src/sys/arch/amd64/amd64/genassym.cf:1.82 Mon Feb 17 09:09:48 2020
+++ src/sys/arch/amd64/amd64/genassym.cf Wed Apr 8 17:59:16 2020
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.82 2020/02/17 09:09:48 skrll Exp $
+# $NetBSD: genassym.cf,v 1.82.4.1 2020/04/08 17:59:16 bouyer Exp $
#
# Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -360,6 +360,8 @@ define X86_BUS_SPACE_IO X86_BUS_SPACE_IO
define BST_TYPE offsetof(struct bus_space_tag, bst_type)
+define VM_GUEST_XENPV VM_GUEST_XENPV
+
ifdef XEN
define CPU_INFO_VCPU offsetof(struct cpu_info, ci_vcpu)
define CPU_INFO_XPENDING offsetof(struct cpu_info, ci_xpending)
Index: src/sys/arch/amd64/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.200 src/sys/arch/amd64/amd64/locore.S:1.200.4.1
--- src/sys/arch/amd64/amd64/locore.S:1.200 Wed Jan 15 18:47:23 2020
+++ src/sys/arch/amd64/amd64/locore.S Wed Apr 8 17:59:16 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.200 2020/01/15 18:47:23 ad Exp $ */
+/* $NetBSD: locore.S,v 1.200.4.1 2020/04/08 17:59:16 bouyer Exp $ */
/*
* Copyright-o-rama!
@@ -942,6 +942,8 @@ longmode_hi:
cpuid
movl %eax,_C_LABEL(cpuid_level)
+ movl $VM_GUEST_XENPV, _C_LABEL(vm_guest)
+
movq $cpu_info_primary,%rdi
movq %rdi,CPU_INFO_SELF(%rdi) /* ci->ci_self = ci */
movq $1,%rsi
Index: src/sys/arch/i386/i386/genassym.cf
diff -u src/sys/arch/i386/i386/genassym.cf:1.119 src/sys/arch/i386/i386/genassym.cf:1.119.4.1
--- src/sys/arch/i386/i386/genassym.cf:1.119 Mon Feb 17 09:09:48 2020
+++ src/sys/arch/i386/i386/genassym.cf Wed Apr 8 17:59:16 2020
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.119 2020/02/17 09:09:48 skrll Exp $
+# $NetBSD: genassym.cf,v 1.119.4.1 2020/04/08 17:59:16 bouyer Exp $
#
# Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -374,6 +374,8 @@ define L2_FRAME L2_FRAME
define PGOFSET PGOFSET
define PGSHIFT PGSHIFT
+define VM_GUEST_XENPV VM_GUEST_XENPV
+
ifdef XEN
define CPU_INFO_VCPU offsetof(struct cpu_info, ci_vcpu)
define CPU_INFO_XPENDING offsetof(struct cpu_info, ci_xpending)
Index: src/sys/arch/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.179 src/sys/arch/i386/i386/locore.S:1.179.2.1
--- src/sys/arch/i386/i386/locore.S:1.179 Fri Mar 27 21:05:03 2020
+++ src/sys/arch/i386/i386/locore.S Wed Apr 8 17:59:16 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.179 2020/03/27 21:05:03 ad Exp $ */
+/* $NetBSD: locore.S,v 1.179.2.1 2020/04/08 17:59:16 bouyer Exp $ */
/*
* Copyright-o-rama!
@@ -128,7 +128,7 @@
*/
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.179 2020/03/27 21:05:03 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.179.2.1 2020/04/08 17:59:16 bouyer Exp $");
#include "opt_copy_symtab.h"
#include "opt_ddb.h"
@@ -1115,6 +1115,8 @@ begin:
cpuid
movl %eax,RELOC(cpuid_level)
+ movl $VM_GUEST_XENPV, RELOC(vm_guest)
+
/*
* Use a temporary GDT page. We'll re-add it to uvm(9) once we're done
* using it.
Index: src/sys/arch/x86/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.117 src/sys/arch/x86/include/cpu.h:1.117.4.1
--- src/sys/arch/x86/include/cpu.h:1.117 Wed Jan 15 13:22:03 2020
+++ src/sys/arch/x86/include/cpu.h Wed Apr 8 17:59:16 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.117 2020/01/15 13:22:03 ad Exp $ */
+/* $NetBSD: cpu.h,v 1.117.4.1 2020/04/08 17:59:16 bouyer Exp $ */
/*
* Copyright (c) 1990 The Regents of the University of California.
@@ -496,7 +496,9 @@ void identify_hypervisor(void);
typedef enum vm_guest {
VM_GUEST_NO = 0,
VM_GUEST_VM,
- VM_GUEST_XEN,
+ VM_GUEST_XENPV,
+ VM_GUEST_XENPVH,
+ VM_GUEST_XENHVM,
VM_GUEST_XENPVHVM,
VM_GUEST_HV,
VM_GUEST_VMWARE,
Index: src/sys/arch/x86/x86/identcpu.c
diff -u src/sys/arch/x86/x86/identcpu.c:1.102 src/sys/arch/x86/x86/identcpu.c:1.102.2.1
--- src/sys/arch/x86/x86/identcpu.c:1.102 Sat Apr 4 14:49:35 2020
+++ src/sys/arch/x86/x86/identcpu.c Wed Apr 8 17:59:16 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: identcpu.c,v 1.102 2020/04/04 14:49:35 ad Exp $ */
+/* $NetBSD: identcpu.c,v 1.102.2.1 2020/04/08 17:59:16 bouyer Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.102 2020/04/04 14:49:35 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.102.2.1 2020/04/08 17:59:16 bouyer Exp $");
#include "opt_xen.h"
@@ -1129,7 +1129,7 @@ identify_hypervisor(void)
} else if (memcmp(hv_vendor, "KVMKVMKVM\0\0\0", 12) == 0)
vm_guest = VM_GUEST_KVM;
else if (memcmp(hv_vendor, "XenVMMXenVMM", 12) == 0)
- vm_guest = VM_GUEST_XEN;
+ vm_guest = VM_GUEST_XENHVM;
/* FreeBSD bhyve: "bhyve bhyve " */
/* OpenBSD vmm: "OpenBSDVMM58" */
/* NetBSD nvmm: "___ NVMM ___" */
Index: src/sys/arch/x86/x86/lapic.c
diff -u src/sys/arch/x86/x86/lapic.c:1.76 src/sys/arch/x86/x86/lapic.c:1.76.6.1
--- src/sys/arch/x86/x86/lapic.c:1.76 Sun Dec 1 08:23:09 2019
+++ src/sys/arch/x86/x86/lapic.c Wed Apr 8 17:59:16 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lapic.c,v 1.76 2019/12/01 08:23:09 maxv Exp $ */
+/* $NetBSD: lapic.c,v 1.76.6.1 2020/04/08 17:59:16 bouyer Exp $ */
/*-
* Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.76 2019/12/01 08:23:09 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.76.6.1 2020/04/08 17:59:16 bouyer Exp $");
#include "acpica.h"
#include "ioapic.h"
@@ -278,7 +278,7 @@ lapic_setup_bsp(paddr_t lapic_base)
!ISSET(regs[0], VCPUINFO_LEGACY_X2APIC))
reason = "inside VMWare without intr "
"redirection";
- } else if (vm_guest == VM_GUEST_XEN) {
+ } else if (vm_guest == VM_GUEST_XENHVM) {
reason = "due to running under XEN";
} else if (vm_guest == VM_GUEST_NO &&
CPUID_TO_FAMILY(curcpu()->ci_signature) == 6 &&
Index: src/sys/arch/x86/x86/x86_machdep.c
diff -u src/sys/arch/x86/x86/x86_machdep.c:1.137 src/sys/arch/x86/x86/x86_machdep.c:1.137.2.1
--- src/sys/arch/x86/x86/x86_machdep.c:1.137 Sat Apr 4 19:50:54 2020
+++ src/sys/arch/x86/x86/x86_machdep.c Wed Apr 8 17:59:16 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: x86_machdep.c,v 1.137 2020/04/04 19:50:54 christos Exp $ */
+/* $NetBSD: x86_machdep.c,v 1.137.2.1 2020/04/08 17:59:16 bouyer Exp $ */
/*-
* Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.137 2020/04/04 19:50:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.137.2.1 2020/04/08 17:59:16 bouyer Exp $");
#include "opt_modular.h"
#include "opt_physmem.h"
@@ -1255,7 +1255,10 @@ sysctl_machdep_tsc_enable(SYSCTLFN_ARGS)
static const char * const vm_guest_name[VM_LAST] = {
[VM_GUEST_NO] = "none",
[VM_GUEST_VM] = "generic",
- [VM_GUEST_XEN] = "Xen",
+ [VM_GUEST_XENPV] = "Xen PV",
+ [VM_GUEST_XENPVH] = "Xen PVH",
+ [VM_GUEST_XENHVM] = "Xen HVM",
+ [VM_GUEST_XENPVHVM] = "Xen PVHVM",
[VM_GUEST_HV] = "Hyper-V",
[VM_GUEST_VMWARE] = "VMware",
[VM_GUEST_KVM] = "KVM",
@@ -1266,7 +1269,7 @@ sysctl_machdep_hypervisor(SYSCTLFN_ARGS)
{
struct sysctlnode node;
const char *t = NULL;
- char buf[8];
+ char buf[10];
node = *rnode;
node.sysctl_data = buf;
Index: src/sys/arch/xen/x86/autoconf.c
diff -u src/sys/arch/xen/x86/autoconf.c:1.23 src/sys/arch/xen/x86/autoconf.c:1.23.8.1
--- src/sys/arch/xen/x86/autoconf.c:1.23 Fri May 24 14:28:48 2019
+++ src/sys/arch/xen/x86/autoconf.c Wed Apr 8 17:59:16 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.23 2019/05/24 14:28:48 nonaka Exp $ */
+/* $NetBSD: autoconf.c,v 1.23.8.1 2020/04/08 17:59:16 bouyer Exp $ */
/* NetBSD: autoconf.c,v 1.75 2003/12/30 12:33:22 pk Exp */
/*-
@@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.23 2019/05/24 14:28:48 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.23.8.1 2020/04/08 17:59:16 bouyer Exp $");
#include "opt_xen.h"
#include "opt_multiprocessor.h"
@@ -128,7 +128,6 @@ cpu_configure(void)
#endif /* NBIOS32 > 0 */
} else
#endif /* DOM0OPS */
- vm_guest = VM_GUEST_XEN;
#ifdef PCIBIOS
pcibios_init();
#endif
Index: src/sys/arch/xen/xen/hypervisor.c
diff -u src/sys/arch/xen/xen/hypervisor.c:1.73 src/sys/arch/xen/xen/hypervisor.c:1.73.2.1
--- src/sys/arch/xen/xen/hypervisor.c:1.73 Tue Apr 7 08:14:42 2020
+++ src/sys/arch/xen/xen/hypervisor.c Wed Apr 8 17:59:17 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor.c,v 1.73 2020/04/07 08:14:42 jdolecek Exp $ */
+/* $NetBSD: hypervisor.c,v 1.73.2.1 2020/04/08 17:59:17 bouyer Exp $ */
/*
* Copyright (c) 2005 Manuel Bouyer.
@@ -53,7 +53,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.73 2020/04/07 08:14:42 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.73.2.1 2020/04/08 17:59:17 bouyer Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -217,7 +217,7 @@ hypervisor_match(device_t parent, cfdata
int vec;
extern vaddr_t hypercall_page;
- if (vm_guest == VM_GUEST_XEN) {
+ if (vm_guest == VM_GUEST_XENHVM) {
aprint_normal("%s: Identified Guest XEN in HVM mode.\n",
haa->haa_busname);
@@ -415,7 +415,7 @@ hypervisor_match(device_t parent, cfdata
bi.common.len = sizeof(struct btinfo_rootdevice);
/* From i386/multiboot.c */
- /* $NetBSD: hypervisor.c,v 1.73 2020/04/07 08:14:42 jdolecek Exp $ */
+ /* $NetBSD: hypervisor.c,v 1.73.2.1 2020/04/08 17:59:17 bouyer Exp $ */
int i, len;
vaddr_t data;
extern struct bootinfo bootinfo;