Source-Changes-HG archive

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

[src/trunk]: src/sys/arch XenPV: in cpu_switchto(), reset ci_xen_clockf_userm...



details:   https://anonhg.NetBSD.org/src/rev/23c1f4e01145
branches:  trunk
changeset: 366754:23c1f4e01145
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sun Jun 12 11:36:42 2022 +0000

description:
XenPV: in cpu_switchto(), reset ci_xen_clockf_usermode/ci_xen_clockf_pc,
in case a clock interrupt is deffered while we're switching lwp.
Fix a (rare) panic:
panic: kernel diagnostic assertion "p != NULL" failed: file "/usr/src/sys/kern/kern_clock.c", line 438
seen when xen_timer_handler() is called from the splx() at the end of
mi_switch()

diffstat:

 sys/arch/amd64/amd64/genassym.cf |   4 +++-
 sys/arch/amd64/amd64/locore.S    |  12 +++++++++++-
 sys/arch/i386/i386/genassym.cf   |   7 ++++++-
 sys/arch/i386/i386/locore.S      |  13 +++++++++++--
 4 files changed, 31 insertions(+), 5 deletions(-)

diffs (96 lines):

diff -r 20fe102f070c -r 23c1f4e01145 sys/arch/amd64/amd64/genassym.cf
--- a/sys/arch/amd64/amd64/genassym.cf  Sun Jun 12 08:55:36 2022 +0000
+++ b/sys/arch/amd64/amd64/genassym.cf  Sun Jun 12 11:36:42 2022 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: genassym.cf,v 1.86 2022/05/24 15:55:19 bouyer Exp $
+#      $NetBSD: genassym.cf,v 1.87 2022/06/12 11:36:42 bouyer Exp $
 
 #
 # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -376,6 +376,8 @@
 define XEN_PT_BASE             offsetof(struct start_info, pt_base)    
 define XEN_NR_PT_FRAMES                offsetof(struct start_info, nr_pt_frames)
 define __HYPERVISOR_iret       __HYPERVISOR_iret
+define CPU_INFO_XEN_CLOCKF_USERMODE offsetof(struct cpu_info, ci_xen_clockf_usermode)
+define CPU_INFO_XEN_CLOCKF_PC  offsetof(struct cpu_info, ci_xen_clockf_pc)
 endif /* XENPV */
 endif /* XEN */
 
diff -r 20fe102f070c -r 23c1f4e01145 sys/arch/amd64/amd64/locore.S
--- a/sys/arch/amd64/amd64/locore.S     Sun Jun 12 08:55:36 2022 +0000
+++ b/sys/arch/amd64/amd64/locore.S     Sun Jun 12 11:36:42 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.212 2021/11/10 15:59:07 msaitoh Exp $     */
+/*     $NetBSD: locore.S,v 1.213 2022/06/12 11:36:42 bouyer Exp $      */
 
 /*
  * Copyright-o-rama!
@@ -1183,6 +1183,16 @@
        movq    %r12,%rcx
        xchgq   %rcx,CPUVAR(CURLWP)
 
+#ifdef XENPV
+       /* if we are there, we're obviously not in user context.
+        * reset ci_xen_clockf_* in case the splx() at the end of mi_switch()
+        * triggers a deffered call do xen_timer_handler()
+        */
+       movb    $0, CPUVAR(XEN_CLOCKF_USERMODE)
+       movq    $_C_LABEL(cpu_switchto), CPUVAR(XEN_CLOCKF_PC)
+#endif
+
+
        /* Skip the rest if returning to a pinned LWP. */
        testb   %dl,%dl         /* returning = true ? */
        jnz     .Lswitch_return
diff -r 20fe102f070c -r 23c1f4e01145 sys/arch/i386/i386/genassym.cf
--- a/sys/arch/i386/i386/genassym.cf    Sun Jun 12 08:55:36 2022 +0000
+++ b/sys/arch/i386/i386/genassym.cf    Sun Jun 12 11:36:42 2022 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: genassym.cf,v 1.123 2022/05/24 15:55:19 bouyer Exp $
+#      $NetBSD: genassym.cf,v 1.124 2022/06/12 11:36:42 bouyer Exp $
 
 #
 # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -392,3 +392,8 @@
 define HYPERVISOR_sched_op     __HYPERVISOR_sched_op
 define SCHEDOP_yield           SCHEDOP_yield
 endif /* XEN */
+
+ifdef XENPV
+define CPU_INFO_XEN_CLOCKF_USERMODE offsetof(struct cpu_info, ci_xen_clockf_usermode)
+define CPU_INFO_XEN_CLOCKF_PC  offsetof(struct cpu_info, ci_xen_clockf_pc)
+endif /* XENPV */
diff -r 20fe102f070c -r 23c1f4e01145 sys/arch/i386/i386/locore.S
--- a/sys/arch/i386/i386/locore.S       Sun Jun 12 08:55:36 2022 +0000
+++ b/sys/arch/i386/i386/locore.S       Sun Jun 12 11:36:42 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.188 2022/05/31 18:04:11 bouyer Exp $      */
+/*     $NetBSD: locore.S,v 1.189 2022/06/12 11:36:42 bouyer Exp $      */
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.188 2022/05/31 18:04:11 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.189 2022/06/12 11:36:42 bouyer Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -1407,6 +1407,15 @@
        movl    %edi,%ecx
        xchgl   %ecx,CPUVAR(CURLWP)
 
+#ifdef XENPV
+       /* if we are there, we're obviously not in user context.
+        * reset ci_xen_clockf_* in case the splx() at the end of mi_switch()
+        * triggers a deffered call do xen_timer_handler()
+        */
+       movb    $0, CPUVAR(XEN_CLOCKF_USERMODE)
+       movl    $_C_LABEL(cpu_switchto), CPUVAR(XEN_CLOCKF_PC)
+#endif
+
        /* Skip the rest if returning to a pinned LWP. */
        testl   %edx,%edx
        jnz     switch_return



Home | Main Index | Thread Index | Old Index