Source-Changes-HG archive

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

[src/trunk]: src/sys/arch On Xen, copy just the bits we need from the trapfra...



details:   https://anonhg.NetBSD.org/src/rev/c8e4f31806d7
branches:  trunk
changeset: 445973:c8e4f31806d7
user:      cherry <cherry%NetBSD.org@localhost>
date:      Sun Nov 18 23:50:48 2018 +0000

description:
On Xen, copy just the bits we need from the trapframe for hardclock(9)
and statclock(9).

Current, the macros that use the trapframe are:
CLKF_USERMODE()
CLKF_PC()
CLKF_INTR()

Of these, CLKF_INTR() already ignores the frame and uses the ci_idepth
variable to do its job.

Convert the two remaining ones to do this, but only for XEN.

diffstat:

 sys/arch/amd64/include/cpu.h          |  7 ++++++-
 sys/arch/i386/include/cpu.h           |  7 ++++++-
 sys/arch/x86/include/cpu.h            |  5 +++--
 sys/arch/xen/x86/hypervisor_machdep.c |  7 ++++---
 sys/arch/xen/xen/clock.c              |  6 +++---
 5 files changed, 22 insertions(+), 10 deletions(-)

diffs (120 lines):

diff -r 0a9a2610f6a2 -r c8e4f31806d7 sys/arch/amd64/include/cpu.h
--- a/sys/arch/amd64/include/cpu.h      Sun Nov 18 23:03:36 2018 +0000
+++ b/sys/arch/amd64/include/cpu.h      Sun Nov 18 23:50:48 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.62 2018/03/16 12:21:50 maxv Exp $    */
+/*     $NetBSD: cpu.h,v 1.63 2018/11/18 23:50:48 cherry Exp $  */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -83,8 +83,13 @@
 }
 #endif /* __GNUC__ && !_MODULE */
 
+#ifdef XEN
+#define        CLKF_USERMODE(frame)    (curcpu()->ci_xen_clockf_usermode)
+#define CLKF_PC(frame)         (curcpu()->ci_xen_clockf_pc)
+#else /* XEN */
 #define        CLKF_USERMODE(frame)    USERMODE((frame)->cf_if.if_tf.tf_cs)
 #define CLKF_PC(frame)         ((frame)->cf_if.if_tf.tf_rip)
+#endif /* XEN */
 #define CLKF_INTR(frame)       (curcpu()->ci_idepth > 0)
 #define LWP_PC(l)              ((l)->l_md.md_regs->tf_rip)
 
diff -r 0a9a2610f6a2 -r c8e4f31806d7 sys/arch/i386/include/cpu.h
--- a/sys/arch/i386/include/cpu.h       Sun Nov 18 23:03:36 2018 +0000
+++ b/sys/arch/i386/include/cpu.h       Sun Nov 18 23:50:48 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.179 2017/09/17 09:41:35 maxv Exp $   */
+/*     $NetBSD: cpu.h,v 1.180 2018/11/18 23:50:48 cherry Exp $ */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -81,8 +81,13 @@
 }
 #endif
 
+#ifdef XEN
+#define        CLKF_USERMODE(frame)    (curcpu()->ci_xen_clockf_usermode)
+#define CLKF_PC(frame)         (curcpu()->ci_xen_clockf_pc)
+#else /* XEN */
 #define        CLKF_USERMODE(frame)    USERMODE((frame)->cf_if.if_cs)
 #define        CLKF_PC(frame)          ((frame)->cf_if.if_eip)
+#endif /* XEN */
 #define        CLKF_INTR(frame)        (curcpu()->ci_idepth > 0)
 #define        LWP_PC(l)               ((l)->l_md.md_regs->tf_eip)
 
diff -r 0a9a2610f6a2 -r c8e4f31806d7 sys/arch/x86/include/cpu.h
--- a/sys/arch/x86/include/cpu.h        Sun Nov 18 23:03:36 2018 +0000
+++ b/sys/arch/x86/include/cpu.h        Sun Nov 18 23:50:48 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.99 2018/11/18 10:24:09 cherry Exp $  */
+/*     $NetBSD: cpu.h,v 1.100 2018/11/18 23:50:48 cherry Exp $ */
 
 /*
  * Copyright (c) 1990 The Regents of the University of California.
@@ -286,7 +286,8 @@
         * Clockframe for timer interrupt handler.
         * Saved at entry via event callback.
         */
-       struct clockframe ci_event_clockframe;
+       vaddr_t ci_xen_clockf_pc; /* RIP at last event interrupt */
+       bool ci_xen_clockf_usermode; /* Was the guest in usermode ? */
 
        /* Event counters for various pathologies that might happen.  */
        struct evcnt    ci_xen_cpu_tsc_backwards_evcnt;
diff -r 0a9a2610f6a2 -r c8e4f31806d7 sys/arch/xen/x86/hypervisor_machdep.c
--- a/sys/arch/xen/x86/hypervisor_machdep.c     Sun Nov 18 23:03:36 2018 +0000
+++ b/sys/arch/xen/x86/hypervisor_machdep.c     Sun Nov 18 23:50:48 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hypervisor_machdep.c,v 1.31 2018/11/18 10:24:09 cherry Exp $   */
+/*     $NetBSD: hypervisor_machdep.c,v 1.32 2018/11/18 23:50:48 cherry Exp $   */
 
 /*
  *
@@ -54,7 +54,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.31 2018/11/18 10:24:09 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.32 2018/11/18 23:50:48 cherry Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -263,7 +263,8 @@
 
        /* Save trapframe for clock handler */
        KASSERT(regs != NULL);
-       ci->ci_event_clockframe.cf_if = *regs;
+       ci->ci_xen_clockf_usermode = USERMODE(regs->if_tf.tf_cs);
+       ci->ci_xen_clockf_pc = regs->if_tf.tf_rip;
 
        // DDD printf("do_hypervisor_callback\n");
 
diff -r 0a9a2610f6a2 -r c8e4f31806d7 sys/arch/xen/xen/clock.c
--- a/sys/arch/xen/xen/clock.c  Sun Nov 18 23:03:36 2018 +0000
+++ b/sys/arch/xen/xen/clock.c  Sun Nov 18 23:50:48 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clock.c,v 1.73 2018/11/18 10:24:10 cherry Exp $        */
+/*     $NetBSD: clock.c,v 1.74 2018/11/18 23:50:48 cherry Exp $        */
 
 /*-
  * Copyright (c) 2017, 2018 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.73 2018/11/18 10:24:10 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.74 2018/11/18 23:50:48 cherry Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -811,7 +811,7 @@
        KASSERT(cpu_intr_p());
        KASSERT(cookie == ci);
 
-       frame = &ci->ci_event_clockframe;
+       frame = NULL; /* We use values cached in curcpu()  */
 again:
        /*
         * Find how many nanoseconds of Xen system time has elapsed



Home | Main Index | Thread Index | Old Index