Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/xen/xenbus Merge the bouyer-xenpvh branch, bringing...



details:   https://anonhg.NetBSD.org/src/rev/ff6ac61d0e8c
branches:  trunk
changeset: 931292:ff6ac61d0e8c
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sat Apr 25 15:26:16 2020 +0000

description:
Merge the bouyer-xenpvh branch, bringing in Xen PV drivers support under HVM
guests in GENERIC.
Xen support can be disabled at runtime with
boot -c
disable hypervisor

diffstat:

 common/lib/libc/arch/i386/atomic/atomic.S |     4 +-
 sys/arch/amd64/amd64/genassym.cf          |    15 +-
 sys/arch/amd64/amd64/lock_stubs.S         |    20 +-
 sys/arch/amd64/amd64/locore.S             |     6 +-
 sys/arch/amd64/amd64/machdep.c            |    29 +-
 sys/arch/amd64/amd64/netbsd32_machdep.c   |     4 +-
 sys/arch/amd64/amd64/spl.S                |    94 +--
 sys/arch/amd64/amd64/vector.S             |   119 +--
 sys/arch/amd64/conf/GENERIC               |    13 +-
 sys/arch/amd64/conf/Makefile.amd64        |     4 +-
 sys/arch/amd64/conf/XEN3_DOM0             |     8 +-
 sys/arch/amd64/conf/XEN3_DOMU             |     6 +-
 sys/arch/amd64/conf/XEN3_PVHVM            |   185 -----
 sys/arch/amd64/conf/files.amd64           |    18 +-
 sys/arch/amd64/conf/std.amd64             |     5 +-
 sys/arch/amd64/conf/std.xen               |     5 +-
 sys/arch/amd64/include/asan.h             |     2 +-
 sys/arch/amd64/include/asm.h              |     2 +-
 sys/arch/amd64/include/frameasm.h         |    14 +-
 sys/arch/amd64/include/gdt.h              |     2 +-
 sys/arch/amd64/include/intrdefs.h         |     4 +-
 sys/arch/amd64/include/msan.h             |     2 +-
 sys/arch/amd64/include/pte.h              |     2 +-
 sys/arch/amd64/include/types.h            |     2 +-
 sys/arch/amd64/include/xen/hypercalls.h   |   462 +++++++++++++
 sys/arch/i386/conf/GENERIC                |    15 +-
 sys/arch/i386/conf/Makefile.i386          |     3 +-
 sys/arch/i386/conf/XEN3PAE_DOM0           |     6 +-
 sys/arch/i386/conf/XEN3PAE_DOMU           |     4 +-
 sys/arch/i386/conf/XEN3PAE_PVHVM          |   167 ----
 sys/arch/i386/conf/files.i386             |    17 +-
 sys/arch/i386/conf/std.i386               |     5 +-
 sys/arch/i386/conf/std.xen                |     7 +-
 sys/arch/i386/i386/genassym.cf            |    15 +-
 sys/arch/i386/i386/i386_trap.S            |    16 +-
 sys/arch/i386/i386/lock_stubs.S           |    21 +-
 sys/arch/i386/i386/locore.S               |    18 +-
 sys/arch/i386/i386/machdep.c              |    33 +-
 sys/arch/i386/i386/spl.S                  |    78 +-
 sys/arch/i386/i386/vector.S               |   188 +----
 sys/arch/i386/include/asm.h               |     2 +-
 sys/arch/i386/include/frameasm.h          |     9 +-
 sys/arch/i386/include/gdt.h               |     2 +-
 sys/arch/i386/include/intrdefs.h          |     4 +-
 sys/arch/i386/include/kcore.h             |     2 +-
 sys/arch/i386/include/pte.h               |     2 +-
 sys/arch/i386/include/xen/hypercalls.h    |   573 ++++++++++++++++
 sys/arch/x86/conf/files.x86               |    29 +-
 sys/arch/x86/include/apicvar.h            |     2 +-
 sys/arch/x86/include/cpu.h                |    41 +-
 sys/arch/x86/include/cpufunc.h            |     4 +-
 sys/arch/x86/include/cpuvar.h             |     5 +-
 sys/arch/x86/include/intr.h               |    31 +-
 sys/arch/x86/include/intrdefs.h           |     7 +-
 sys/arch/x86/include/machdep.h            |     8 +-
 sys/arch/x86/include/pci_machdep_common.h |     4 +-
 sys/arch/x86/include/pic.h                |     6 +-
 sys/arch/x86/include/pmap.h               |     2 +-
 sys/arch/x86/include/specialreg.h         |     2 +-
 sys/arch/x86/isa/clock.c                  |    29 +-
 sys/arch/x86/isa/isa_machdep.c            |     8 +-
 sys/arch/x86/pci/amdsmn.c                 |     4 +-
 sys/arch/x86/pci/amdzentemp.c             |     4 +-
 sys/arch/x86/pci/msipic.c                 |    10 +-
 sys/arch/x86/x86/bus_space.c              |     4 +-
 sys/arch/x86/x86/consinit.c               |     6 +-
 sys/arch/x86/x86/cpu.c                    |    29 +-
 sys/arch/x86/x86/cpu_ucode.c              |     6 +-
 sys/arch/x86/x86/cpu_ucode_amd.c          |     8 +-
 sys/arch/x86/x86/cpu_ucode_intel.c        |     6 +-
 sys/arch/x86/x86/hyperv.c                 |     4 +-
 sys/arch/x86/x86/i8259.c                  |    15 +-
 sys/arch/x86/x86/identcpu.c               |    14 +-
 sys/arch/x86/x86/identcpu_subr.c          |     2 +-
 sys/arch/x86/x86/intr.c                   |   273 ++-----
 sys/arch/x86/x86/ioapic.c                 |     7 +-
 sys/arch/x86/x86/lapic.c                  |    27 +-
 sys/arch/x86/x86/mainbus.c                |    27 +-
 sys/arch/x86/x86/patch.c                  |    10 +-
 sys/arch/x86/x86/pmap.c                   |    14 +-
 sys/arch/x86/x86/procfs_machdep.c         |     4 +-
 sys/arch/x86/x86/svs.c                    |     4 +-
 sys/arch/x86/x86/sys_machdep.c            |     4 +-
 sys/arch/x86/x86/tsc.c                    |     4 +-
 sys/arch/x86/x86/x86_autoconf.c           |     6 +-
 sys/arch/x86/x86/x86_machdep.c            |    38 +-
 sys/arch/x86/x86/x86_softintr.c           |   294 ++++++++
 sys/arch/xen/conf/Makefile.xen            |    22 +-
 sys/arch/xen/conf/files.compat            |     8 +-
 sys/arch/xen/conf/files.xen               |   386 +----------
 sys/arch/xen/conf/files.xen.pv            |    49 +
 sys/arch/xen/conf/std.xenversion          |     2 +-
 sys/arch/xen/include/Makefile             |     4 +-
 sys/arch/xen/include/amd64/hypercalls.h   |   462 -------------
 sys/arch/xen/include/evtchn.h             |     9 +-
 sys/arch/xen/include/hypervisor.h         |    12 +-
 sys/arch/xen/include/i386/hypercalls.h    |   570 ----------------
 sys/arch/xen/include/i82093var.h          |     2 +-
 sys/arch/xen/include/intr.h               |    12 +-
 sys/arch/xen/include/intrdefs.h           |     7 +-
 sys/arch/xen/include/xen.h                |     4 +-
 sys/arch/xen/include/xen_shm.h            |     2 +-
 sys/arch/xen/include/xenbus.h             |     2 +-
 sys/arch/xen/include/xenpmap.h            |     4 +-
 sys/arch/xen/include/xenring.h            |     2 +-
 sys/arch/xen/x86/autoconf.c               |     7 +-
 sys/arch/xen/x86/cpu.c                    |    34 +-
 sys/arch/xen/x86/hypervisor_machdep.c     |    95 +-
 sys/arch/xen/x86/pintr.c                  |     2 +-
 sys/arch/xen/x86/xen_bus_dma.c            |    11 +-
 sys/arch/xen/x86/xen_intr.c               |    83 +-
 sys/arch/xen/x86/xen_ipi.c                |    71 +-
 sys/arch/xen/x86/xen_mainbus.c            |    58 +-
 sys/arch/xen/x86/xen_shm_machdep.c        |     4 +-
 sys/arch/xen/x86/xenfunc.c                |    14 +-
 sys/arch/xen/xen/balloon.c                |     4 +-
 sys/arch/xen/xen/clock.c                  |  1007 ----------------------------
 sys/arch/xen/xen/evtchn.c                 |   171 ++--
 sys/arch/xen/xen/hypervisor.c             |   355 ++++++---
 sys/arch/xen/xen/if_xennet_xenbus.c       |     5 +-
 sys/arch/xen/xen/privcmd.c                |     4 +-
 sys/arch/xen/xen/xbd_xenbus.c             |     5 +-
 sys/arch/xen/xen/xbdback_xenbus.c         |     4 +-
 sys/arch/xen/xen/xen_clock.c              |  1013 +++++++++++++++++++++++++++++
 sys/arch/xen/xen/xen_machdep.c            |     5 +-
 sys/arch/xen/xen/xencons.c                |     5 +-
 sys/arch/xen/xen/xenevt.c                 |     6 +-
 sys/arch/xen/xen/xengnt.c                 |   118 +--
 sys/arch/xen/xenbus/xenbus_comms.c        |     5 +-
 sys/arch/xen/xenbus/xenbus_dev.c          |     5 +-
 sys/arch/xen/xenbus/xenbus_probe.c        |     4 +-
 131 files changed, 3629 insertions(+), 4241 deletions(-)

diffs (truncated from 11881 to 300 lines):

diff -r 842b768495c6 -r ff6ac61d0e8c common/lib/libc/arch/i386/atomic/atomic.S
--- a/common/lib/libc/arch/i386/atomic/atomic.S Sat Apr 25 13:51:04 2020 +0000
+++ b/common/lib/libc/arch/i386/atomic/atomic.S Sat Apr 25 15:26:16 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atomic.S,v 1.23 2018/07/18 13:39:36 bouyer Exp $       */
+/*     $NetBSD: atomic.S,v 1.24 2020/04/25 15:26:16 bouyer Exp $       */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -197,7 +197,7 @@
 ENDLABEL(membar_sync_end)
 
 #if defined(__HAVE_ATOMIC64_OPS) || defined(_KERNEL)
-#ifdef XEN
+#ifdef XENPV
 STRONG_ALIAS(_atomic_cas_64,_atomic_cas_cx8)
 #else
 ENTRY(_atomic_cas_64)
diff -r 842b768495c6 -r ff6ac61d0e8c sys/arch/amd64/amd64/genassym.cf
--- a/sys/arch/amd64/amd64/genassym.cf  Sat Apr 25 13:51:04 2020 +0000
+++ b/sys/arch/amd64/amd64/genassym.cf  Sat Apr 25 15:26: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.83 2020/04/25 15:26:16 bouyer Exp $
 
 #
 # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -246,13 +246,11 @@
 define CPU_INFO_GDT            offsetof(struct cpu_info, ci_gdt)
 define CPU_INFO_ILEVEL         offsetof(struct cpu_info, ci_ilevel)
 define CPU_INFO_IDEPTH         offsetof(struct cpu_info, ci_idepth)
-if !defined(XENPV)
 define CPU_INFO_IPENDING       offsetof(struct cpu_info, ci_ipending)
 define CPU_INFO_IMASKED        offsetof(struct cpu_info, ci_imasked)
 define CPU_INFO_IMASK          offsetof(struct cpu_info, ci_imask)
 define CPU_INFO_IUNMASK        offsetof(struct cpu_info, ci_iunmask)
 define CPU_INFO_ISOURCES       offsetof(struct cpu_info, ci_isources)
-endif
 define CPU_INFO_MTX_COUNT      offsetof(struct cpu_info, ci_mtx_count)
 define CPU_INFO_MTX_OLDSPL     offsetof(struct cpu_info, ci_mtx_oldspl)
 define  CPU_INFO_CPUID         offsetof(struct cpu_info, ci_cpuid)
@@ -325,6 +323,8 @@
 define IPL_PREEMPT             IPL_PREEMPT
 define IPL_NET                 IPL_NET
 define IPL_CLOCK               IPL_CLOCK
+define IPL_VM                  IPL_VM
+define IPL_SCHED               IPL_SCHED
 define IPL_HIGH                IPL_HIGH
 
 define LIR_IPI                 LIR_IPI
@@ -360,12 +360,13 @@
 
 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)
-define CPU_INFO_XMASK          offsetof(struct cpu_info, ci_xmask)
-define CPU_INFO_XUNMASK                offsetof(struct cpu_info, ci_xunmask)
-define CPU_INFO_XSOURCES       offsetof(struct cpu_info, ci_xsources)
+define SIR_XENIPL_VM           SIR_XENIPL_VM
+define SIR_XENIPL_SCHED                SIR_XENIPL_SCHED
+define SIR_XENIPL_HIGH         SIR_XENIPL_HIGH
 define EVTCHN_UPCALL_MASK      offsetof(struct vcpu_info, evtchn_upcall_mask)
 ifdef XENPV
 define XEN_PT_BASE             offsetof(struct start_info, pt_base)    
diff -r 842b768495c6 -r ff6ac61d0e8c sys/arch/amd64/amd64/lock_stubs.S
--- a/sys/arch/amd64/amd64/lock_stubs.S Sat Apr 25 13:51:04 2020 +0000
+++ b/sys/arch/amd64/amd64/lock_stubs.S Sat Apr 25 15:26:16 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lock_stubs.S,v 1.35 2019/12/08 20:00:56 ad Exp $       */
+/*     $NetBSD: lock_stubs.S,v 1.36 2020/04/25 15:26:16 bouyer Exp $   */
 
 /*
  * Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -126,18 +126,10 @@
        jnz     1f
        cmpl    CPU_INFO_ILEVEL(%r8), %edi
        jae     1f
-#if !defined(XENPV)
        movl    CPU_INFO_IUNMASK(%r8,%rdi,4), %esi
        CLI(ax)
        testl   CPU_INFO_IPENDING(%r8), %esi
        jnz     _C_LABEL(Xspllower)
-#endif
-#if defined(XEN)
-       movl    CPU_INFO_XUNMASK(%r8,%rdi,4), %esi
-       CLI(ax)
-       testl   CPU_INFO_XPENDING(%r8), %esi
-       jnz     _C_LABEL(Xspllower)
-#endif
        movl    %edi, CPU_INFO_ILEVEL(%r8)
        STI(ax)
 1:     rep                                     /* double byte ret as branch */
@@ -155,22 +147,12 @@
        cmpl    %edx,%ecx                       /* new level is lower? */
        jae     2f
 1:
-#if !defined(XENPV)
        movl    CPU_INFO_IPENDING(%rsi),%eax
        testl   %eax,CPU_INFO_IUNMASK(%rsi,%rcx,4)/* deferred interrupts? */
        jnz     3f
        movl    %eax,%ebx
        cmpxchg8b CPU_INFO_ISTATE(%rsi)         /* swap in new ilevel */
        jnz     4f
-#endif
-#if defined(XEN)
-       movl    CPU_INFO_XPENDING(%rsi),%eax
-       testl   %eax,CPU_INFO_XUNMASK(%rsi,%rcx,4)/* deferred interrupts? */
-       jnz     3f
-       movl    %edx, %eax
-       cmpxchgl %ecx, CPU_INFO_ILEVEL(%rsi)
-       jnz     4f
-#endif
 2:
        popq    %rbx
        ret
diff -r 842b768495c6 -r ff6ac61d0e8c sys/arch/amd64/amd64/locore.S
--- a/sys/arch/amd64/amd64/locore.S     Sat Apr 25 13:51:04 2020 +0000
+++ b/sys/arch/amd64/amd64/locore.S     Sat Apr 25 15:26: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.201 2020/04/25 15:26: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
@@ -1108,7 +1110,7 @@
 .Lskip_svs:
 #endif
 
-#ifndef XEN
+#ifndef XENPV
        movq    %r13,%rdi
        movq    %r12,%rsi
        callq   _C_LABEL(speculation_barrier)
diff -r 842b768495c6 -r ff6ac61d0e8c sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c    Sat Apr 25 13:51:04 2020 +0000
+++ b/sys/arch/amd64/amd64/machdep.c    Sat Apr 25 15:26:16 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.347 2020/04/21 20:13:39 jdolecek Exp $   */
+/*     $NetBSD: machdep.c,v 1.348 2020/04/25 15:26:16 bouyer Exp $     */
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.347 2020/04/21 20:13:39 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.348 2020/04/25 15:26:16 bouyer Exp $");
 
 #include "opt_modular.h"
 #include "opt_user_ldt.h"
@@ -280,14 +280,6 @@
 extern paddr_t pmap_pa_start, pmap_pa_end;
 #endif
 
-#ifndef XENPV
-void (*delay_func)(unsigned int) = i8254_delay;
-void (*initclock_func)(void) = i8254_initclocks;
-#else /* XENPV */
-void (*delay_func)(unsigned int) = xen_delay;
-void (*initclock_func)(void) = xen_initclocks;
-#endif
-
 struct nmistore {
        uint64_t cr3;
        uint64_t scratch;
@@ -727,9 +719,12 @@
 
                acpi_enter_sleep_state(ACPI_STATE_S5);
 #endif
-#ifdef XENPV
-               HYPERVISOR_shutdown();
-#endif /* XENPV */
+#ifdef XEN
+               if (vm_guest == VM_GUEST_XENPV ||
+                   vm_guest == VM_GUEST_XENPVH ||
+                   vm_guest == VM_GUEST_XENPVHVM)
+                       HYPERVISOR_shutdown();
+#endif /* XEN */
        }
 
        cpu_broadcast_halt();
@@ -1691,7 +1686,7 @@
        svs_init();
 #endif
        cpu_init_msrs(&cpu_info_primary, true);
-#ifndef XEN
+#ifndef XENPV
        cpu_speculation_init(&cpu_info_primary);
 #endif
 
@@ -2124,12 +2119,6 @@
        return 0;
 }
 
-void
-cpu_initclocks(void)
-{
-       (*initclock_func)();
-}
-
 int
 mm_md_kernacc(void *ptr, vm_prot_t prot, bool *handled)
 {
diff -r 842b768495c6 -r ff6ac61d0e8c sys/arch/amd64/amd64/netbsd32_machdep.c
--- a/sys/arch/amd64/amd64/netbsd32_machdep.c   Sat Apr 25 13:51:04 2020 +0000
+++ b/sys/arch/amd64/amd64/netbsd32_machdep.c   Sat Apr 25 15:26:16 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_machdep.c,v 1.135 2020/04/24 16:27:27 maxv Exp $      */
+/*     $NetBSD: netbsd32_machdep.c,v 1.136 2020/04/25 15:26:16 bouyer Exp $    */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.135 2020/04/24 16:27:27 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.136 2020/04/25 15:26:16 bouyer Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
diff -r 842b768495c6 -r ff6ac61d0e8c sys/arch/amd64/amd64/spl.S
--- a/sys/arch/amd64/amd64/spl.S        Sat Apr 25 13:51:04 2020 +0000
+++ b/sys/arch/amd64/amd64/spl.S        Sat Apr 25 15:26:16 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spl.S,v 1.43 2020/01/08 17:38:41 ad Exp $      */
+/*     $NetBSD: spl.S,v 1.44 2020/04/25 15:26:16 bouyer Exp $  */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -91,7 +91,6 @@
        ret
 END(splraise)
 
-#ifndef XEN
 /*
  * Xsoftintr()
  *
@@ -148,11 +147,11 @@
        movq    PCB_RSP0(%rdx),%rsp
 
        /* dispatch */
-       sti
+       STI(di)
        movq    %r15,%rdi               /* interrupted LWP */
        movl    IS_MAXLEVEL(%rax),%esi  /* ipl to run at */
        call    _C_LABEL(softint_dispatch)/* run handlers */
-       cli
+       CLI(di)
 
        /* restore old context */
        movq    L_PCB(%r15),%rcx
@@ -174,7 +173,7 @@
  */
 ENTRY(softintr_ret)
        incl    CPUVAR(MTX_COUNT)       /* re-adjust after mi_switch */
-       cli
+       CLI(ax)         /* %rax not used by Xspllower/Xdoreti */
        jmp     *%r13                   /* back to Xspllower/Xdoreti */
 END(softintr_ret)
 
@@ -196,11 +195,11 @@
  */
 IDTVEC(recurse_preempt)
        movl    $IPL_PREEMPT,CPUVAR(ILEVEL)
-       sti
+       STI(di)
        xorq    %rdi,%rdi
        KMSAN_INIT_ARG(8)
        call    _C_LABEL(kpreempt)
-       cli
+       CLI(di)
        jmp     *%r13                   /* back to Xspllower */
 IDTVEC_END(recurse_preempt)
 
@@ -211,60 +210,29 @@
  */
 IDTVEC(resume_preempt)
        movl    $IPL_PREEMPT,CPUVAR(ILEVEL)
-       sti
+       STI(ax)
        testq   $SEL_RPL,TF_CS(%rsp)
        jnz     1f
        movq    TF_RIP(%rsp),%rdi
        KMSAN_INIT_ARG(8)
        call    _C_LABEL(kpreempt)      /* from kernel */



Home | Main Index | Thread Index | Old Index