Source-Changes-HG archive

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

[src/bouyer-xenpvh]: src/sys/arch Reorganise sources to make it possible to i...



details:   https://anonhg.NetBSD.org/src/rev/e5d537613157
branches:  bouyer-xenpvh
changeset: 982934:e5d537613157
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Thu Apr 16 08:46:34 2020 +0000

description:
Reorganise sources to make it possible to include Xen PVHVM support in
native kernels. Among others:
- move xen/include/amd64/hypercall.h to amd64/include/xen and
  xen/include/i386/hypercall.h to i386/include/xen
- exclude some native files from the build for xenpv
- add xen to "machine" config statement for amd64 and i386
- split arch/xen/conf/files.xen to arch/xen/conf/files.xen (for pv drivers)
  and arch/xen/conf/files.xen.pv (for full pv support)
- add GENERIC_XENHVM kernel config which includes GENERIC and add Xen PV
  drivers.

diffstat:

 sys/arch/amd64/amd64/vector.S           |    6 +-
 sys/arch/amd64/conf/GENERIC_XENHVM      |   14 +
 sys/arch/amd64/conf/Makefile.amd64      |    4 +-
 sys/arch/amd64/conf/XEN3_DOM0           |    5 +-
 sys/arch/amd64/conf/files.amd64         |   18 +-
 sys/arch/amd64/conf/std.amd64           |    6 +-
 sys/arch/amd64/conf/std.xen             |    5 +-
 sys/arch/amd64/include/xen/hypercalls.h |  462 +++++++++++++++++++++++++
 sys/arch/i386/conf/GENERIC_XENHVM       |   14 +
 sys/arch/i386/conf/Makefile.i386        |    3 +-
 sys/arch/i386/conf/XEN3PAE_DOM0         |    4 +-
 sys/arch/i386/conf/files.i386           |   17 +-
 sys/arch/i386/conf/std.i386             |    5 +-
 sys/arch/i386/i386/machdep.c            |    8 +-
 sys/arch/i386/i386/vector.S             |    6 +-
 sys/arch/i386/include/xen/hypercalls.h  |  573 ++++++++++++++++++++++++++++++++
 sys/arch/x86/conf/files.x86             |   28 +-
 sys/arch/x86/include/intr.h             |    7 +-
 sys/arch/x86/x86/cpu_ucode.c            |    6 +-
 sys/arch/x86/x86/cpu_ucode_amd.c        |    6 +-
 sys/arch/x86/x86/cpu_ucode_intel.c      |    6 +-
 sys/arch/x86/x86/lapic.c                |   13 +-
 sys/arch/x86/x86/mainbus.c              |    9 +-
 sys/arch/xen/conf/Makefile.xen          |   22 +-
 sys/arch/xen/conf/files.xen             |  385 +--------------------
 sys/arch/xen/conf/files.xen.pv          |   47 ++
 sys/arch/xen/conf/std.xen               |    5 +-
 sys/arch/xen/include/amd64/hypercalls.h |  462 -------------------------
 sys/arch/xen/include/hypervisor.h       |    6 +-
 sys/arch/xen/include/i386/hypercalls.h  |  570 -------------------------------
 sys/arch/xen/include/intr.h             |    4 +-
 sys/arch/xen/include/xenpmap.h          |    4 +-
 sys/arch/xen/x86/hypervisor_machdep.c   |    5 +-
 sys/arch/xen/x86/xen_intr.c             |    7 +-
 sys/arch/xen/x86/xen_ipi.c              |   77 ++--
 sys/arch/xen/x86/xen_mainbus.c          |   25 +-
 sys/arch/xen/xen/evtchn.c               |    6 +-
 sys/arch/xen/xen/if_xennet_xenbus.c     |    5 +-
 sys/arch/xen/xen/xbd_xenbus.c           |    5 +-
 sys/arch/xen/xen/xen_machdep.c          |    5 +-
 sys/arch/xen/xen/xencons.c              |    5 +-
 sys/arch/xen/xenbus/xenbus_comms.c      |    5 +-
 sys/arch/xen/xenbus/xenbus_dev.c        |    5 +-
 43 files changed, 1305 insertions(+), 1575 deletions(-)

diffs (truncated from 3814 to 300 lines):

diff -r d5d8b0191ecf -r e5d537613157 sys/arch/amd64/amd64/vector.S
--- a/sys/arch/amd64/amd64/vector.S     Wed Apr 15 16:04:06 2020 +0000
+++ b/sys/arch/amd64/amd64/vector.S     Thu Apr 16 08:46:34 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vector.S,v 1.73.6.3 2020/04/12 17:25:52 bouyer Exp $   */
+/*     $NetBSD: vector.S,v 1.73.6.4 2020/04/16 08:46:34 bouyer Exp $   */
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -84,7 +84,7 @@
 #include "ioapic.h"
 #include "lapic.h"
 #include "assym.h"
-#ifndef XEN
+#ifndef XENPV
 #include "hyperv.h"
 #endif
 
@@ -108,6 +108,7 @@
  * segment registers.
  */
 
+#ifndef XENPV
 #if NLAPIC > 0
 #ifdef MULTIPROCESSOR
 IDTVEC(recurse_lapic_ipi)
@@ -309,7 +310,6 @@
 
 #endif /* NLAPIC > 0 */
 
-#ifndef XENPV
 /*
  * TLB shootdown handler.
  */
diff -r d5d8b0191ecf -r e5d537613157 sys/arch/amd64/conf/GENERIC_XENHVM
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/amd64/conf/GENERIC_XENHVM        Thu Apr 16 08:46:34 2020 +0000
@@ -0,0 +1,14 @@
+# $NetBSD: GENERIC_XENHVM,v 1.1.2.1 2020/04/16 08:46:34 bouyer Exp $
+
+include "arch/amd64/conf/GENERIC"
+
+options        XENPVHVM
+options        XEN
+no options     SVS             # Separate Virtual Space
+options        MAXPHYS=32768   #xbd doesn't handle 64k transfers
+hypervisor*    at mainbus?             # Xen hypervisor
+#vcpu*         at hypervisor?          # Xen virtual CPUs
+xenbus*                at hypervisor?          # Xen virtual bus
+xencons*       at hypervisor?          # Xen virtual console
+xennet*                at xenbus?              # Xen virtual network interface
+xbd*           at xenbus?              # Xen virtual block device
diff -r d5d8b0191ecf -r e5d537613157 sys/arch/amd64/conf/Makefile.amd64
--- a/sys/arch/amd64/conf/Makefile.amd64        Wed Apr 15 16:04:06 2020 +0000
+++ b/sys/arch/amd64/conf/Makefile.amd64        Thu Apr 16 08:46:34 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.amd64,v 1.82 2020/04/04 07:03:57 maxv Exp $
+#      $NetBSD: Makefile.amd64,v 1.82.2.1 2020/04/16 08:46:34 bouyer Exp $
 
 # Makefile for NetBSD
 #
@@ -77,6 +77,8 @@
 CFLAGS+=       ${KMSANFLAGS.${.IMPSRC:T}:U${KMSANFLAGS}}
 .endif
 
+EXTRA_INCLUDES= -I$S/external/mit/xen-include-public/dist/
+
 ##
 ## (3) libkern and compat
 ##
diff -r d5d8b0191ecf -r e5d537613157 sys/arch/amd64/conf/XEN3_DOM0
--- a/sys/arch/amd64/conf/XEN3_DOM0     Wed Apr 15 16:04:06 2020 +0000
+++ b/sys/arch/amd64/conf/XEN3_DOM0     Thu Apr 16 08:46:34 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOM0,v 1.175.4.1 2020/04/12 21:20:16 bouyer Exp $
+# $NetBSD: XEN3_DOM0,v 1.175.4.2 2020/04/16 08:46:34 bouyer Exp $
 
 include        "arch/amd64/conf/std.xen"
 
@@ -12,7 +12,7 @@
 #options       UVMHIST_PRINT
 #options       SYSCALL_DEBUG
 
-#ident         "XEN3_DOM0-$Revision: 1.175.4.1 $"
+#ident         "XEN3_DOM0-$Revision: 1.175.4.2 $"
 
 maxusers       32              # estimated number of users
 
@@ -224,6 +224,7 @@
 pci*           at pchb? bus ?
 ppb*           at pci? dev ? function ?        # PCI-PCI bridges
 pci*           at ppb? bus ?
+options        NO_PCI_MSI_MSIX
 
 # pci backend devices, used for PCI pass-through. To export a PCI device
 # to a domU, the device has to be attached to the pciback driver in the dom0.
diff -r d5d8b0191ecf -r e5d537613157 sys/arch/amd64/conf/files.amd64
--- a/sys/arch/amd64/conf/files.amd64   Wed Apr 15 16:04:06 2020 +0000
+++ b/sys/arch/amd64/conf/files.amd64   Thu Apr 16 08:46:34 2020 +0000
@@ -1,10 +1,8 @@
-#      $NetBSD: files.amd64,v 1.115 2020/01/09 00:42:24 manu Exp $
+#      $NetBSD: files.amd64,v 1.115.4.1 2020/04/16 08:46:34 bouyer Exp $
 #
 # new style config file for amd64 architecture
 #
 
-ifndef xen
-
 # maxpartitions must be first item in files.${ARCH}.newconf
 maxpartitions 16
 
@@ -37,7 +35,7 @@
 file   arch/amd64/amd64/spl.S                  machdep
 
 file   arch/amd64/amd64/amd64_trap.S           machdep
-file   arch/amd64/amd64/autoconf.c             machdep
+file   arch/amd64/amd64/autoconf.c             machdep & !xenpv
 file   arch/amd64/amd64/busfunc.S              machdep
 file   arch/amd64/amd64/cpu_in_cksum.S         (inet | inet6) & cpu_in_cksum
 file   arch/amd64/amd64/cpufunc.S              machdep
@@ -53,11 +51,11 @@
 file   arch/amd64/amd64/trap.c                 machdep
 file   arch/x86/x86/fpu.c                      machdep
 file   arch/x86/x86/dbregs.c                   machdep
-file   arch/x86/x86/spectre.c                  machdep
+file   arch/x86/x86/spectre.c                  machdep & !xenpv
 file   arch/amd64/amd64/lock_stubs.S           machdep
 file   dev/cons.c                              machdep
 
-file   arch/amd64/amd64/mptramp.S        multiprocessor
+file   arch/amd64/amd64/mptramp.S        multiprocessor & !xenpv
 
 #
 # Stack-less Just-In-Time compiler
@@ -91,9 +89,10 @@
 #
 
 # XXX BIOS32 only if something that uses it is configured!
-device mainbus: isabus, pcibus, bios32, acpibus, cpubus, ioapicbus, ipmibus
+device mainbus: isabus, pcibus, bios32, acpibus, cpubus, ioapicbus,
+       ipmibus, hypervisorbus
 attach mainbus at root
-file   arch/amd64/amd64/amd64_mainbus.c        mainbus
+file   arch/amd64/amd64/amd64_mainbus.c        mainbus & !xenpv
 file   arch/x86/x86/mainbus.c                  mainbus
 
 #
@@ -186,7 +185,7 @@
 include "dev/ieee1394/files.ieee1394"
 include "dev/apm/files.apm"
 include "dev/acpi/files.acpi"
-file   arch/amd64/acpi/acpi_wakeup_low.S       acpi
+file   arch/amd64/acpi/acpi_wakeup_low.S       acpi & !xenpv
 
 # Microsoft Hyper-V
 include "dev/hyperv/files.hyperv"
@@ -195,4 +194,3 @@
 file   dev/acpi/vmbus_acpi.c                   vmbus_acpi
 
 include        "arch/amd64/conf/majors.amd64"
-endif #xen
diff -r d5d8b0191ecf -r e5d537613157 sys/arch/amd64/conf/std.amd64
--- a/sys/arch/amd64/conf/std.amd64     Wed Apr 15 16:04:06 2020 +0000
+++ b/sys/arch/amd64/conf/std.amd64     Thu Apr 16 08:46:34 2020 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: std.amd64,v 1.11 2017/01/12 05:24:36 ryo Exp $
+# $NetBSD: std.amd64,v 1.11.26.1 2020/04/16 08:46:34 bouyer Exp $
 #
 # standard, required NetBSD/amd64 'options'
 
-machine amd64 x86
+machine amd64 x86 xen
 include        "conf/std"      # MI standard options
 
 options        CPU_IN_CKSUM
@@ -14,6 +14,8 @@
 options        CHILD_MAX=1024  # 160 is too few
 options        OPEN_MAX=1024   # 128 is too few
 
+options         __XEN_INTERFACE_VERSION__=0x00030208 # Xen 3.1 interface
+
 mainbus0 at root
 cpu* at mainbus?
 ioapic* at mainbus? apid ?
diff -r d5d8b0191ecf -r e5d537613157 sys/arch/amd64/conf/std.xen
--- a/sys/arch/amd64/conf/std.xen       Wed Apr 15 16:04:06 2020 +0000
+++ b/sys/arch/amd64/conf/std.xen       Thu Apr 16 08:46:34 2020 +0000
@@ -1,10 +1,11 @@
-# $NetBSD: std.xen,v 1.11 2019/02/04 18:14:53 cherry Exp $
+# $NetBSD: std.xen,v 1.11.10.1 2020/04/16 08:46:34 bouyer Exp $
 # NetBSD: std.i386,v 1.24 2003/02/26 21:33:36 fvdl Exp 
 #
 # standard, required NetBSD/i386 'options'
 
-machine xen amd64
+machine xen amd64 x86
 include        "conf/std"      # MI standard options
+include                "arch/xen/conf/files.xen.pv"
 
 options        XEN     #Xen support
 options        __XEN_INTERFACE_VERSION__=0x00030208 # Xen 3.1 interface
diff -r d5d8b0191ecf -r e5d537613157 sys/arch/amd64/include/xen/hypercalls.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/amd64/include/xen/hypercalls.h   Thu Apr 16 08:46:34 2020 +0000
@@ -0,0 +1,462 @@
+/* $NetBSD: hypercalls.h,v 1.1.2.1 2020/04/16 08:46:34 bouyer Exp $ */
+/******************************************************************************
+ * hypercall.h
+ * 
+ * Linux-specific hypervisor handling.
+ * 
+ * Copyright (c) 2002-2004, K A Fraser
+ * 
+ * 64-bit updates:
+ *   Benjamin Liu <benjamin.liu%intel.com@localhost>
+ *   Jun Nakajima <jun.nakajima%intel.com@localhost>
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef __HYPERCALL_H__
+#define __HYPERCALL_H__
+
+#define __STR(x) #x
+#define STR(x) __STR(x)
+
+#define HYPERCALL_STR(name)                                    \
+       "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"
+
+#define _hypercall0(type, name)                        \
+({                                             \
+       long __res;                             \
+       asm volatile (                          \
+               HYPERCALL_STR(name)             \
+               : "=a" (__res)                  \
+               :                               \
+               : "memory" );                   \
+       (type)__res;                            \
+})
+
+#define _hypercall1(type, name, a1)                            \
+({                                                             \
+       long __res, __ign1;                                     \
+       asm volatile (                                          \
+               HYPERCALL_STR(name)                             \
+               : "=a" (__res), "=D" (__ign1)                   \
+               : "1" ((long)(a1))                              \
+               : "memory" );                                   \
+       (type)__res;                                            \
+})
+
+#define _hypercall2(type, name, a1, a2)                                \
+({                                                             \
+       long __res, __ign1, __ign2;                             \
+       asm volatile (                                          \
+               HYPERCALL_STR(name)                             \
+               : "=a" (__res), "=D" (__ign1), "=S" (__ign2)    \
+               : "1" ((long)(a1)), "2" ((long)(a2))            \
+               : "memory" );                                   \
+       (type)__res;                                            \
+})
+
+#define _hypercall3(type, name, a1, a2, a3)                    \
+({                                                             \
+       long __res, __ign1, __ign2, __ign3;                     \
+       asm volatile (                                          \
+               HYPERCALL_STR(name)                             \
+               : "=a" (__res), "=D" (__ign1), "=S" (__ign2),   \
+               "=d" (__ign3)                                   \
+               : "1" ((long)(a1)), "2" ((long)(a2)),           \
+               "3" ((long)(a3))                                \
+               : "memory" );                                   \
+       (type)__res;                                            \
+})
+
+#define _hypercall4(type, name, a1, a2, a3, a4)                        \
+({                                                             \
+       long __res, __ign1, __ign2, __ign3;                     \



Home | Main Index | Thread Index | Old Index