Source-Changes-HG archive

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

[src/bouyer-xenpvh]: src/sys/arch sync with bouyer-xenpvh-base2 (HEAD)



details:   https://anonhg.NetBSD.org/src/rev/7daafea02b04
branches:  bouyer-xenpvh
changeset: 1025007:7daafea02b04
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sat Apr 25 13:16:48 2020 +0000

description:
sync with bouyer-xenpvh-base2 (HEAD)

diffstat:

 sys/arch/x86/conf/files.x86           |    5 +-
 sys/arch/x86/x86/cpu.c                |   68 +++-
 sys/arch/x86/x86/i8259.c              |   10 +-
 sys/arch/xen/conf/files.xen           |   36 +--
 sys/arch/xen/x86/hypervisor_machdep.c |    6 +-
 sys/arch/xen/x86/xen_intr.c           |   25 +-
 sys/arch/xen/x86/xen_ipi.c            |    6 +-
 sys/arch/xen/xen/xbdback_xenbus.c     |  498 +++++++++++++++++++++------------
 8 files changed, 403 insertions(+), 251 deletions(-)

diffs (truncated from 1361 to 300 lines):

diff -r 4d6e14c54f08 -r 7daafea02b04 sys/arch/x86/conf/files.x86
--- a/sys/arch/x86/conf/files.x86       Sat Apr 25 11:44:29 2020 +0000
+++ b/sys/arch/x86/conf/files.x86       Sat Apr 25 13:16:48 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.x86,v 1.107.10.2 2020/04/16 08:46:34 bouyer Exp $
+#      $NetBSD: files.x86,v 1.107.10.3 2020/04/25 13:16:48 bouyer Exp $
 
 # options for MP configuration through the MP spec
 defflag opt_mpbios.h MPBIOS MPDEBUG MPBIOS_SCANPCI
@@ -59,7 +59,7 @@
 attach odcm at cpufeaturebus
 file   arch/x86/x86/odcm.c             odcm
 
-device padlock: opencrypto
+device padlock: opencrypto, rijndael
 attach padlock at cpufeaturebus
 file   arch/x86/x86/via_padlock.c      padlock
 
@@ -91,6 +91,7 @@
 file   arch/x86/x86/errata.c           machdep
 file   arch/x86/x86/genfb_machdep.c    machdep
 file   arch/x86/x86/identcpu.c         machdep
+file   arch/x86/x86/identcpu_subr.c    machdep
 file   arch/x86/x86/i8259.c            machdep & (!xenpv | dom0ops)
 file   arch/x86/x86/intr.c             machdep & !xenpv
 file   arch/x86/x86/x86_softintr.c     machdep
diff -r 4d6e14c54f08 -r 7daafea02b04 sys/arch/x86/x86/cpu.c
--- a/sys/arch/x86/x86/cpu.c    Sat Apr 25 11:44:29 2020 +0000
+++ b/sys/arch/x86/x86/cpu.c    Sat Apr 25 13:16:48 2020 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: cpu.c,v 1.181.4.4 2020/04/20 11:29:00 bouyer Exp $     */
+/*     $NetBSD: cpu.c,v 1.181.4.5 2020/04/25 13:16:48 bouyer Exp $     */
 
 /*
- * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
+ * Copyright (c) 2000-2020 NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.181.4.4 2020/04/20 11:29:00 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.181.4.5 2020/04/25 13:16:48 bouyer Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"                /* for MPDEBUG */
@@ -73,6 +73,7 @@
 #include "lapic.h"
 #include "ioapic.h"
 #include "acpica.h"
+#include "hpet.h"
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -119,6 +120,7 @@
 #endif
 
 #include <dev/ic/mc146818reg.h>
+#include <dev/ic/hpetvar.h>
 #include <i386/isa/nvram.h>
 #include <dev/isa/isareg.h>
 
@@ -202,6 +204,8 @@
 #endif
 struct cpu_info *cpu_starting;
 
+int (*cpu_nullop_ptr)(void *) = nullop;
+
 #ifdef MULTIPROCESSOR
 void           cpu_hatch(void *);
 static void    cpu_boot_secondary(struct cpu_info *ci);
@@ -433,8 +437,11 @@
         * must be done to allow booting other processors.
         */
        if (!again) {
+               /* Make sure DELAY() (likely i8254_delay()) is initialized. */
+               DELAY(1);
+
+               /* Basic init. */
                atomic_or_32(&ci->ci_flags, CPUF_PRESENT | CPUF_PRIMARY);
-               /* Basic init. */
                cpu_intr_init(ci);
                cpu_get_tsc_freq(ci);
                cpu_init(ci);
@@ -451,8 +458,6 @@
                                lapic_calibrate_timer(ci);
                }
 #endif
-               /* Make sure DELAY() is initialized. */
-               DELAY(1);
                kcsan_cpu_init(ci);
                again = true;
        }
@@ -718,7 +723,6 @@
 
        if (ci != &cpu_info_primary) {
                /* Synchronize TSC */
-               wbinvd();
                atomic_or_32(&ci->ci_flags, CPUF_RUNNING);
                tsc_sync_ap(ci);
        } else {
@@ -734,6 +738,14 @@
        kcpuset_t *cpus;
        u_long i;
 
+#if NHPET > 0
+       /* Use HPET delay, and re-calibrate TSC on boot CPU using HPET. */
+       if (hpet_delay_p() && x86_delay == i8254_delay) {
+               delay_func = x86_delay = hpet_delay;
+               cpu_get_tsc_freq(curcpu());
+       }
+#endif
+
        /* Now that we know the number of CPUs, patch the text segment. */
        x86_patch(false);
 
@@ -842,7 +854,6 @@
                 */
                psl = x86_read_psl();
                x86_disable_intr();
-               wbinvd();
                tsc_sync_bp(ci);
                x86_write_psl(psl);
        }
@@ -873,7 +884,6 @@
                drift = ci->ci_data.cpu_cc_skew;
                psl = x86_read_psl();
                x86_disable_intr();
-               wbinvd();
                tsc_sync_bp(ci);
                x86_write_psl(psl);
                drift -= ci->ci_data.cpu_cc_skew;
@@ -919,7 +929,6 @@
         * Synchronize the TSC for the first time. Note that interrupts are
         * off at this point.
         */
-       wbinvd();
        atomic_or_32(&ci->ci_flags, CPUF_PRESENT);
        tsc_sync_ap(ci);
 
@@ -1306,16 +1315,45 @@
        return cpu_stop(dv);
 }
 
+/* Get the TSC frequency and set it to ci->ci_data.cpu_cc_freq. */
 void
 cpu_get_tsc_freq(struct cpu_info *ci)
 {
-       uint64_t last_tsc;
+       uint64_t freq = 0, t0, t1;
+       int64_t overhead;
+
+       if (cpu_hascounter())
+               freq = cpu_tsc_freq_cpuid(ci);
 
-       if (cpu_hascounter()) {
-               last_tsc = cpu_counter_serializing();
+       if (freq != 0) {
+               /* Use TSC frequency taken from CPUID. */
+               ci->ci_data.cpu_cc_freq = freq;
+       } else {
+               /*
+                * Work out the approximate overhead involved below.
+                * Discard the result of the first go around the loop.
+                */
+               overhead = 0;           
+               for (int i = 0; i <= 8; i++) {
+                       __insn_barrier();
+                       t0 = cpu_counter_serializing();
+                       (*cpu_nullop_ptr)(NULL);
+                       t1 = cpu_counter_serializing();
+                       __insn_barrier();
+                       if (i > 0) {
+                               overhead += (t1 - t0);
+                       }
+               }
+               overhead >>= 3;
+
+               /* Now warm up x86_delay() and do the calibration. */
+               x86_delay(1);
+               __insn_barrier();
+               t0 = cpu_counter_serializing();
                x86_delay(100000);
-               ci->ci_data.cpu_cc_freq =
-                   (cpu_counter_serializing() - last_tsc) * 10;
+               t1 = cpu_counter_serializing();
+               __insn_barrier();
+               ci->ci_data.cpu_cc_freq = (t1 - t0 - overhead) * 10;
        }
 }
 
diff -r 4d6e14c54f08 -r 7daafea02b04 sys/arch/x86/x86/i8259.c
--- a/sys/arch/x86/x86/i8259.c  Sat Apr 25 11:44:29 2020 +0000
+++ b/sys/arch/x86/x86/i8259.c  Sat Apr 25 13:16:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i8259.c,v 1.23.10.2 2020/04/19 19:39:10 bouyer Exp $   */
+/*     $NetBSD: i8259.c,v 1.23.10.3 2020/04/25 13:16:48 bouyer Exp $   */
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -70,9 +70,9 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i8259.c,v 1.23.10.2 2020/04/19 19:39:10 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i8259.c,v 1.23.10.3 2020/04/25 13:16:48 bouyer Exp $");
 
-#include <sys/param.h> 
+#include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/syslog.h>
@@ -83,7 +83,7 @@
 #include <dev/ic/i8259reg.h>
 
 #include <machine/pio.h>
-#include <machine/cpufunc.h>  
+#include <machine/cpufunc.h>
 #include <machine/cpu.h>
 #include <machine/pic.h>
 #include <machine/i8259.h>
@@ -166,7 +166,7 @@
                /* reset; program device, level-triggered, four bytes */
                outb(IO_ICU2 + PIC_ICW1, ICW1_SELECT | ICW1_LTIM | ICW1_IC4);
        else
-#endif 
+#endif
                /* reset; program device, four bytes */
                outb(IO_ICU2 + PIC_ICW1, ICW1_SELECT | ICW1_IC4);
 
diff -r 4d6e14c54f08 -r 7daafea02b04 sys/arch/xen/conf/files.xen
--- a/sys/arch/xen/conf/files.xen       Sat Apr 25 11:44:29 2020 +0000
+++ b/sys/arch/xen/conf/files.xen       Sat Apr 25 13:16:48 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.xen,v 1.180.2.7 2020/04/25 10:52:26 bouyer Exp $
+#      $NetBSD: files.xen,v 1.180.2.8 2020/04/25 13:16:48 bouyer Exp $
 
 defflag        opt_xen.h                       XEN XENPVH XENPVHVM PAE
 
@@ -10,37 +10,3 @@
 file   arch/xen/x86/xen_mainbus.c              xen
 file   arch/xen/xen/xen_clock.c                xen
 file   arch/xen/x86/xen_bus_dma.c              xen
-
-define hypervisorbus {}
-define xendevbus {}
-
-# Xen hypervisor
-device hypervisor { [apid = -1]}: isabus, pcibus, sysmon_power, xendevbus, acpibus
-attach hypervisor at hypervisorbus
-file   arch/xen/xen/hypervisor.c       hypervisor needs-flag
-file   arch/xen/xen/shutdown_xenbus.c  hypervisor
-
-# Xenbus
-device xenbus {[id = -1]}
-attach xenbus at xendevbus
-file arch/xen/xenbus/xenbus_client.c xenbus needs-flag
-file arch/xen/xenbus/xenbus_comms.c xenbus needs-flag
-file arch/xen/xenbus/xenbus_dev.c xenbus needs-flag
-file arch/xen/xenbus/xenbus_probe.c xenbus needs-flag
-file arch/xen/xenbus/xenbus_xs.c xenbus needs-flag
-
-# Xen console support
-device xencons: tty
-attach xencons at xendevbus
-file   arch/xen/xen/xencons.c          xencons needs-flag
-
-# Xen Network driver
-device xennet: arp, ether, ifnet
-attach xennet at xenbus
-file   arch/xen/xen/if_xennet_xenbus.c xennet needs-flag
-file   arch/xen/xen/xennet_checksum.c  xvif | xennet
-
-# Xen Block device driver and wd/sd/cd identities
-device xbd: disk
-attach xbd at xenbus
-file   arch/xen/xen/xbd_xenbus.c       xbd
diff -r 4d6e14c54f08 -r 7daafea02b04 sys/arch/xen/x86/hypervisor_machdep.c
--- a/sys/arch/xen/x86/hypervisor_machdep.c     Sat Apr 25 11:44:29 2020 +0000
+++ b/sys/arch/xen/x86/hypervisor_machdep.c     Sat Apr 25 13:16:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hypervisor_machdep.c,v 1.36.8.6 2020/04/25 11:23:57 bouyer Exp $       */
+/*     $NetBSD: hypervisor_machdep.c,v 1.36.8.7 2020/04/25 13:16:48 bouyer Exp $       */
 
 /*
  *
@@ -54,7 +54,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.36.8.6 2020/04/25 11:23:57 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.36.8.7 2020/04/25 13:16:48 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -477,7 +477,7 @@
        KASSERT(ci->ci_ilevel == IPL_NONE);
 



Home | Main Index | Thread Index | Old Index