Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/bouyer-xenpvh]: src/sys/arch Remove VM_GUEST_XEN and define only Xen sub...



details:   https://anonhg.NetBSD.org/src/rev/64e18b44a93a
branches:  bouyer-xenpvh
changeset: 930591:64e18b44a93a
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Wed Apr 08 17:59:16 2020 +0000

description:
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().

diffstat:

 sys/arch/amd64/amd64/genassym.cf |   4 +++-
 sys/arch/amd64/amd64/locore.S    |   4 +++-
 sys/arch/i386/i386/genassym.cf   |   4 +++-
 sys/arch/i386/i386/locore.S      |   6 ++++--
 sys/arch/x86/include/cpu.h       |   6 ++++--
 sys/arch/x86/x86/identcpu.c      |   6 +++---
 sys/arch/x86/x86/lapic.c         |   6 +++---
 sys/arch/x86/x86/x86_machdep.c   |  11 +++++++----
 sys/arch/xen/x86/autoconf.c      |   5 ++---
 sys/arch/xen/xen/hypervisor.c    |   8 ++++----
 10 files changed, 36 insertions(+), 24 deletions(-)

diffs (256 lines):

diff -r 466ed24b1e20 -r 64e18b44a93a sys/arch/amd64/amd64/genassym.cf
--- a/sys/arch/amd64/amd64/genassym.cf  Wed Apr 08 17:56:08 2020 +0000
+++ b/sys/arch/amd64/amd64/genassym.cf  Wed Apr 08 17:59:16 2020 +0000
@@ -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 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)
diff -r 466ed24b1e20 -r 64e18b44a93a sys/arch/amd64/amd64/locore.S
--- a/sys/arch/amd64/amd64/locore.S     Wed Apr 08 17:56:08 2020 +0000
+++ b/sys/arch/amd64/amd64/locore.S     Wed Apr 08 17:59:16 2020 +0000
@@ -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 @@
        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
diff -r 466ed24b1e20 -r 64e18b44a93a sys/arch/i386/i386/genassym.cf
--- a/sys/arch/i386/i386/genassym.cf    Wed Apr 08 17:56:08 2020 +0000
+++ b/sys/arch/i386/i386/genassym.cf    Wed Apr 08 17:59:16 2020 +0000
@@ -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 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)
diff -r 466ed24b1e20 -r 64e18b44a93a sys/arch/i386/i386/locore.S
--- a/sys/arch/i386/i386/locore.S       Wed Apr 08 17:56:08 2020 +0000
+++ b/sys/arch/i386/i386/locore.S       Wed Apr 08 17:59:16 2020 +0000
@@ -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 @@
        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.
diff -r 466ed24b1e20 -r 64e18b44a93a sys/arch/x86/include/cpu.h
--- a/sys/arch/x86/include/cpu.h        Wed Apr 08 17:56:08 2020 +0000
+++ b/sys/arch/x86/include/cpu.h        Wed Apr 08 17:59:16 2020 +0000
@@ -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 @@
 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,
diff -r 466ed24b1e20 -r 64e18b44a93a sys/arch/x86/x86/identcpu.c
--- a/sys/arch/x86/x86/identcpu.c       Wed Apr 08 17:56:08 2020 +0000
+++ b/sys/arch/x86/x86/identcpu.c       Wed Apr 08 17:59:16 2020 +0000
@@ -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 @@
                        } 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 ___" */
diff -r 466ed24b1e20 -r 64e18b44a93a sys/arch/x86/x86/lapic.c
--- a/sys/arch/x86/x86/lapic.c  Wed Apr 08 17:56:08 2020 +0000
+++ b/sys/arch/x86/x86/lapic.c  Wed Apr 08 17:59:16 2020 +0000
@@ -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 @@
                            !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 &&
diff -r 466ed24b1e20 -r 64e18b44a93a sys/arch/x86/x86/x86_machdep.c
--- a/sys/arch/x86/x86/x86_machdep.c    Wed Apr 08 17:56:08 2020 +0000
+++ b/sys/arch/x86/x86/x86_machdep.c    Wed Apr 08 17:59:16 2020 +0000
@@ -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 @@
 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 @@
 {
        struct sysctlnode node;
        const char *t = NULL;
-       char buf[8];
+       char buf[10];
 
        node = *rnode;
        node.sysctl_data = buf;
diff -r 466ed24b1e20 -r 64e18b44a93a sys/arch/xen/x86/autoconf.c
--- a/sys/arch/xen/x86/autoconf.c       Wed Apr 08 17:56:08 2020 +0000
+++ b/sys/arch/xen/x86/autoconf.c       Wed Apr 08 17:59:16 2020 +0000
@@ -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 @@
 #endif /* NBIOS32 > 0 */
        } else
 #endif /* DOM0OPS */
-               vm_guest = VM_GUEST_XEN;
 #ifdef PCIBIOS
        pcibios_init();
 #endif
diff -r 466ed24b1e20 -r 64e18b44a93a sys/arch/xen/xen/hypervisor.c
--- a/sys/arch/xen/xen/hypervisor.c     Wed Apr 08 17:56:08 2020 +0000
+++ b/sys/arch/xen/xen/hypervisor.c     Wed Apr 08 17:59:16 2020 +0000
@@ -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 @@
        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 @@
        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;



Home | Main Index | Thread Index | Old Index