Source-Changes-HG archive

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

[src/bouyer-xenpvh]: src/sys/arch On amd64, always use the cmpxchg8b version ...



details:   https://anonhg.NetBSD.org/src/rev/d5d8b0191ecf
branches:  bouyer-xenpvh
changeset: 982933:d5d8b0191ecf
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Wed Apr 15 16:04:06 2020 +0000

description:
On amd64, always use the cmpxchg8b version of spllower. All x86_64 host should
have it and we already rely on it in lock stubs.
On i386, always use i686_mutex_spin_exit and cx8_spllower for Xen;
Xen doesn't run on CPUs on CPUs lacking the required instructions anyway.
Skip x86_patch only for XENPV, and adjust for changes in assembly functions.
Tested on Xen PV and PVHVM, and on bare metal core i5.

diffstat:

 sys/arch/amd64/amd64/spl.S      |  50 +++-------------------------------------
 sys/arch/amd64/conf/XEN3_DOMU   |   6 +++-
 sys/arch/i386/i386/lock_stubs.S |  21 ++++------------
 sys/arch/i386/i386/spl.S        |  11 ++++----
 sys/arch/x86/include/cpufunc.h  |   4 +-
 sys/arch/x86/x86/patch.c        |  10 ++++----
 6 files changed, 27 insertions(+), 75 deletions(-)

diffs (277 lines):

diff -r c7d40f05a553 -r d5d8b0191ecf sys/arch/amd64/amd64/spl.S
--- a/sys/arch/amd64/amd64/spl.S        Tue Apr 14 16:53:57 2020 +0000
+++ b/sys/arch/amd64/amd64/spl.S        Wed Apr 15 16:04:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spl.S,v 1.43.4.6 2020/04/12 17:25:52 bouyer Exp $      */
+/*     $NetBSD: spl.S,v 1.43.4.7 2020/04/15 16:04:06 bouyer Exp $      */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -227,50 +227,12 @@
 /*
  * void spllower(int s);
  *
- * Must be the same size as cx8_spllower().  This must use
- * pushf/cli/popf as it is used early in boot where interrupts
- * are disabled via eflags/IE.
- */
-ENTRY(spllower)
-       cmpl    CPUVAR(ILEVEL),%edi
-       jae     1f
-       movl    CPUVAR(IUNMASK)(,%rdi,4),%edx
-       PUSHF(ax)
-       CLI(ax)
-       testl   CPUVAR(IPENDING),%edx
-       jnz     2f
-       movl    %edi,CPUVAR(ILEVEL)
-       POPF    /* clobbers %rdi */
-1:
-       ret
-       ret
-2:
-#ifdef XENPV
-       /*
-        * no need to call stipending, we're going to CLI again
-        * just drop the saved value on stack
-        */
-       addq    $8,%rsp
-#else
-       popf
-#endif
-       jmp     _C_LABEL(Xspllower)
-3:
-       .space 16
-       .align  16
-END(spllower)
-LABEL(spllower_end)
-
-#ifndef XENPV
-/*
- * void        cx8_spllower(int s);
- *
  * For cmpxchg8b, edx/ecx are the high words and eax/ebx the low.
  *
  * edx : eax = old level / old ipending
  * ecx : ebx = new level / old ipending
  */
-ENTRY(cx8_spllower)
+ENTRY(spllower)
        movl    CPUVAR(ILEVEL),%edx
        movq    %rbx,%r8
        cmpl    %edx,%edi                       /* new level is lower? */
@@ -292,15 +254,11 @@
        ret
 2:
        movq    %r8,%rbx
-       .type   _C_LABEL(cx8_spllower_patch), @function
-LABEL(cx8_spllower_patch)
        jmp     _C_LABEL(Xspllower)
 
        .align  16
-END(cx8_spllower_patch)
-END(cx8_spllower)
-LABEL(cx8_spllower_end)
-#endif /* !XENPV */
+END(spllower)
+LABEL(spllower_end)
 
 /*
  * void Xspllower(int s);
diff -r c7d40f05a553 -r d5d8b0191ecf sys/arch/amd64/conf/XEN3_DOMU
--- a/sys/arch/amd64/conf/XEN3_DOMU     Tue Apr 14 16:53:57 2020 +0000
+++ b/sys/arch/amd64/conf/XEN3_DOMU     Wed Apr 15 16:04:06 2020 +0000
@@ -1,17 +1,19 @@
-# $NetBSD: XEN3_DOMU,v 1.90.6.1 2020/04/08 17:56:08 bouyer Exp $
+# $NetBSD: XEN3_DOMU,v 1.90.6.2 2020/04/15 16:04:06 bouyer Exp $
 
 include        "arch/amd64/conf/std.xen"
 
 options                XENPV           # PV domU support
 options        MULTIPROCESSOR
 
+options        HZ=20
+
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
 #options       UVMHIST
 #options       UVMHIST_PRINT
 #options       SYSCALL_DEBUG
 
-#ident         "XEN3_DOMU-$Revision: 1.90.6.1 $"
+#ident         "XEN3_DOMU-$Revision: 1.90.6.2 $"
 
 maxusers       32              # estimated number of users
 
diff -r c7d40f05a553 -r d5d8b0191ecf sys/arch/i386/i386/lock_stubs.S
--- a/sys/arch/i386/i386/lock_stubs.S   Tue Apr 14 16:53:57 2020 +0000
+++ b/sys/arch/i386/i386/lock_stubs.S   Wed Apr 15 16:04:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lock_stubs.S,v 1.32 2019/12/08 20:00:56 ad Exp $       */
+/*     $NetBSD: lock_stubs.S,v 1.32.6.1 2020/04/15 16:04:06 bouyer Exp $       */
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: lock_stubs.S,v 1.32 2019/12/08 20:00:56 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lock_stubs.S,v 1.32.6.1 2020/04/15 16:04:06 bouyer Exp $");
 
 #include "opt_lockdebug.h"
 
@@ -223,7 +223,6 @@
        jmp     3b
 END(rw_tryenter)
 
-#ifndef XENPV
 
 /*
  * void mutex_spin_enter(kmutex_t *mtx);
@@ -254,6 +253,7 @@
 LABEL(mutex_spin_enter_end)
 END(mutex_spin_enter)
 
+#ifndef XENPV
 /*
  * Release a spin mutex and post a store fence.
  */
@@ -275,7 +275,9 @@
        .align  32
 LABEL(mutex_spin_exit_end)
 END(mutex_spin_exit)
-
+#else  /* XENPV */
+STRONG_ALIAS(mutex_spin_exit, i686_mutex_spin_exit)
+#endif /* !XENPV */
 /*
  * Patch for i686 CPUs where cli/sti is prohibitively expensive.
  * Must be the same size as mutex_spin_exit().
@@ -307,17 +309,6 @@
 LABEL(i686_mutex_spin_exit_end)
 END(i686_mutex_spin_exit)
 
-#else  /* !XENPV */
-
-/* For now; strong alias not working for some reason. */
-ENTRY(mutex_spin_enter)
-       jmp     _C_LABEL(mutex_vector_enter)
-
-ENTRY(mutex_spin_exit)
-       jmp     _C_LABEL(mutex_vector_exit)
-
-#endif /* !XENPV */
-
 #endif /* !LOCKDEBUG */
 
 /*
diff -r c7d40f05a553 -r d5d8b0191ecf sys/arch/i386/i386/spl.S
--- a/sys/arch/i386/i386/spl.S  Tue Apr 14 16:53:57 2020 +0000
+++ b/sys/arch/i386/i386/spl.S  Wed Apr 15 16:04:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spl.S,v 1.50.4.5 2020/04/12 17:25:52 bouyer Exp $      */
+/*     $NetBSD: spl.S,v 1.50.4.6 2020/04/15 16:04:06 bouyer Exp $      */
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: spl.S,v 1.50.4.5 2020/04/12 17:25:52 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spl.S,v 1.50.4.6 2020/04/15 16:04:06 bouyer Exp $");
 
 #include "opt_ddb.h"
 #include "opt_spldebug.h"
@@ -67,6 +67,7 @@
        ret
 END(splraise)
 
+#ifndef XENPV
 /*
  * void spllower(int s);
  *
@@ -110,8 +111,10 @@
        .align  32
 LABEL(spllower_end)
 END(spllower)
+#else  /* XENPV */
+STRONG_ALIAS(spllower, cx8_spllower)
+#endif /* !XENPV */
 
-#ifndef XENPV
 /*
  * void        cx8_spllower(int s);
  *
@@ -151,8 +154,6 @@
 LABEL(cx8_spllower_end)
 END(cx8_spllower)
 
-#endif /* XENPV */
-
 /*
  * void Xspllower(int s);
  *
diff -r c7d40f05a553 -r d5d8b0191ecf sys/arch/x86/include/cpufunc.h
--- a/sys/arch/x86/include/cpufunc.h    Tue Apr 14 16:53:57 2020 +0000
+++ b/sys/arch/x86/include/cpufunc.h    Wed Apr 15 16:04:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpufunc.h,v 1.37 2019/10/30 17:06:57 maxv Exp $        */
+/*     $NetBSD: cpufunc.h,v 1.37.6.1 2020/04/15 16:04:06 bouyer Exp $  */
 
 /*
  * Copyright (c) 1998, 2007, 2019 The NetBSD Foundation, Inc.
@@ -103,7 +103,7 @@
        return (low | ((uint64_t)high << 32));
 }
 
-#ifndef XEN
+#ifndef XENPV
 void   x86_hotpatch(uint32_t, const uint8_t *, size_t);
 void   x86_patch_window_open(u_long *, u_long *);
 void   x86_patch_window_close(u_long, u_long);
diff -r c7d40f05a553 -r d5d8b0191ecf sys/arch/x86/x86/patch.c
--- a/sys/arch/x86/x86/patch.c  Tue Apr 14 16:53:57 2020 +0000
+++ b/sys/arch/x86/x86/patch.c  Wed Apr 15 16:04:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: patch.c,v 1.37.6.2 2020/04/14 16:53:57 bouyer Exp $    */
+/*     $NetBSD: patch.c,v 1.37.6.3 2020/04/15 16:04:06 bouyer Exp $    */
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.37.6.2 2020/04/14 16:53:57 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.37.6.3 2020/04/15 16:04:06 bouyer Exp $");
 
 #include "opt_lockdebug.h"
 #ifdef i386
@@ -247,7 +247,6 @@
                    NULL
                );
        }
-#endif /* i386 */
 
 #if !defined(SPLDEBUG)
        if (!early && (cpu_feature[0] & CPUID_CX8) != 0) {
@@ -257,15 +256,16 @@
                    spllower, spllower_end,
                    cx8_spllower_patch
                );
-#if defined(i386) && !defined(LOCKDEBUG)
+#if !defined(LOCKDEBUG)
                patchfunc(
                    i686_mutex_spin_exit, i686_mutex_spin_exit_end,
                    mutex_spin_exit, mutex_spin_exit_end,
                    i686_mutex_spin_exit_patch
                );
-#endif /* i386 && !LOCKDEBUG */
+#endif /* !LOCKDEBUG */
        }
 #endif /* !SPLDEBUG */
+#endif /* i386 */
 
        /*
         * On some Opteron revisions, locked operations erroneously



Home | Main Index | Thread Index | Old Index