Source-Changes-HG archive

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

[src/netbsd-8]: src Pull up following revision(s) (requested by maxv in ticke...



details:   https://anonhg.NetBSD.org/src/rev/436aef378e8a
branches:  netbsd-8
changeset: 434166:436aef378e8a
user:      snj <snj%NetBSD.org@localhost>
date:      Tue Aug 01 23:18:30 2017 +0000

description:
Pull up following revision(s) (requested by maxv in ticket #164):
        distrib/sets/lists/base/md.amd64: revision 1.269
        distrib/sets/lists/debug/md.amd64: revision 1.97
        sys/arch/amd64/conf/GENERIC: revision 1.460
        sys/arch/amd64/conf/files.amd64: revision 1.89
        sys/arch/i386/conf/GENERIC: revision 1.1157
        sys/arch/i386/conf/files.i386: revision 1.379
        sys/arch/i386/i386/i386_trap.S: revision 1.7-1.8
        sys/arch/i386/include/frameasm.h: revision 1.16
        sys/arch/x86/include/sysarch.h: revision 1.12
        sys/arch/x86/x86/pmc.c: revision 1.8-1.10
        sys/arch/x86/x86/sys_machdep.c: revision 1.36
        sys/arch/xen/conf/files.compat: revision 1.26
        sys/secmodel/suser/secmodel_suser.c: revision 1.43
        sys/sys/kauth.h: revision 1.74
        usr.bin/pmc/Makefile: revision 1.5
        usr.bin/pmc/pmc.1: revision 1.12-1.13
        usr.bin/pmc/pmc.c: revision 1.24-1.25
style
--
style
--
Disable interrupts for T_NMI (inline calltrap). Note that there's still a
way to evade the NMI mode here, if a segment register faults in
INTRFASTEXIT; but we don't care. I didn't test this change, but it seems
fine enough.
--
Make the PMC syscalls privileged.
--
Check argc, and add a message.
--
include opt_pmc.h
--
Build the pmc tool on amd64.
--
Properly handle overflows, and take them into account in userland.
--
Update.
--
Enable PMCs by default.
--
Sort sections. Fix macro usage.

diffstat:

 distrib/sets/lists/base/md.amd64    |    3 +-
 distrib/sets/lists/debug/md.amd64   |    3 +-
 sys/arch/amd64/conf/GENERIC         |    6 +-
 sys/arch/amd64/conf/files.amd64     |    3 +-
 sys/arch/i386/conf/GENERIC          |    6 +-
 sys/arch/i386/conf/files.i386       |    4 +-
 sys/arch/i386/i386/i386_trap.S      |  116 ++++++++++++++++++++------------
 sys/arch/i386/include/frameasm.h    |   26 +++---
 sys/arch/x86/include/sysarch.h      |    3 +-
 sys/arch/x86/x86/pmc.c              |  129 ++++++++++++++++++++++++++++++-----
 sys/arch/x86/x86/sys_machdep.c      |    5 +-
 sys/arch/xen/conf/files.compat      |    4 +-
 sys/secmodel/suser/secmodel_suser.c |   23 +++---
 sys/sys/kauth.h                     |    3 +-
 usr.bin/pmc/Makefile                |    4 +-
 usr.bin/pmc/pmc.1                   |   30 +++++--
 usr.bin/pmc/pmc.c                   |   27 ++++++-
 17 files changed, 278 insertions(+), 117 deletions(-)

diffs (truncated from 1077 to 300 lines):

diff -r 6a82247aff63 -r 436aef378e8a distrib/sets/lists/base/md.amd64
--- a/distrib/sets/lists/base/md.amd64  Tue Aug 01 23:12:06 2017 +0000
+++ b/distrib/sets/lists/base/md.amd64  Tue Aug 01 23:18:30 2017 +0000
@@ -1,9 +1,10 @@
-# $NetBSD: md.amd64,v 1.268 2017/01/24 11:09:14 nonaka Exp $
+# $NetBSD: md.amd64,v 1.268.4.1 2017/08/01 23:18:30 snj Exp $
 ./dev/lms0                                     base-obsolete           obsolete
 ./dev/mms0                                     base-obsolete           obsolete
 ./libexec/ld.elf_so-i386                       base-sys-shlib          compat,pic
 ./usr/bin/fdformat                             base-util-bin
 ./usr/bin/iasl                                 base-util-bin
+./usr/bin/pmc                                  base-util-bin
 ./usr/lib/i386/libi386.so.1                    base-compat-shlib       compat,pic
 ./usr/lib/i386/libi386.so.1.0                  base-compat-shlib       compat,pic
 ./usr/lib/i386/libproc.so.0                    base-compat-shlib       compat,pic,dtrace
diff -r 6a82247aff63 -r 436aef378e8a distrib/sets/lists/debug/md.amd64
--- a/distrib/sets/lists/debug/md.amd64 Tue Aug 01 23:12:06 2017 +0000
+++ b/distrib/sets/lists/debug/md.amd64 Tue Aug 01 23:18:30 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: md.amd64,v 1.96 2017/05/07 02:05:56 kamil Exp $
+# $NetBSD: md.amd64,v 1.96.2.1 2017/08/01 23:18:30 snj Exp $
 ./usr/lib/i386/12.202++_g.a                    comp-c-debuglib         debuglib,compat,12.202xx
 ./usr/lib/i386/libi386_g.a                     comp-c-debuglib         debuglib,compat
 ./usr/lib/i386/libiberty_g.a                   comp-obsolete           obsolete
@@ -6,6 +6,7 @@
 ./usr/libdata/debug/libexec/ld.elf_so-i386.debug       comp-sys-debug          debug,compat
 ./usr/libdata/debug/usr/bin/fdformat.debug     comp-util-debug         debug
 ./usr/libdata/debug/usr/bin/iasl.debug         comp-util-debug         debug
+./usr/libdata/debug/usr/bin/pmc.debug          comp-util-debug         debug
 ./usr/libdata/debug/usr/lib/i386/libi386.so.1.0.debug  comp-compat-shlib       compat,pic,debug
 ./usr/libdata/debug/usr/lib/i386/libpam.so.4.1.debug   comp-compat-shlib       compat,pic,debug,pam
 ./usr/libdata/debug/usr/lib/i386/libproc.so.0.0.debug  comp-compat-shlib       compat,pic,debug,dtrace
diff -r 6a82247aff63 -r 436aef378e8a sys/arch/amd64/conf/GENERIC
--- a/sys/arch/amd64/conf/GENERIC       Tue Aug 01 23:12:06 2017 +0000
+++ b/sys/arch/amd64/conf/GENERIC       Tue Aug 01 23:18:30 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.459.2.1 2017/07/05 13:58:48 martin Exp $
+# $NetBSD: GENERIC,v 1.459.2.2 2017/08/01 23:18:30 snj Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident         "GENERIC-$Revision: 1.459.2.1 $"
+#ident         "GENERIC-$Revision: 1.459.2.2 $"
 
 maxusers       64              # estimated number of users
 
@@ -81,7 +81,7 @@
 powernow0      at cpu0         # AMD PowerNow! and Cool'n'Quiet (non-ACPI)
 vmt0           at cpu0         # VMware Tools
 
-#options       PMC             # performance-monitoring counters support
+options        PMC             # performance-monitoring counters support
 
 # Alternate buffer queue strategies for better responsiveness under high
 # disk I/O load.
diff -r 6a82247aff63 -r 436aef378e8a sys/arch/amd64/conf/files.amd64
--- a/sys/arch/amd64/conf/files.amd64   Tue Aug 01 23:12:06 2017 +0000
+++ b/sys/arch/amd64/conf/files.amd64   Tue Aug 01 23:18:30 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.amd64,v 1.88 2016/12/15 12:04:17 kamil Exp $
+#      $NetBSD: files.amd64,v 1.88.8.1 2017/08/01 23:18:30 snj Exp $
 #
 # new style config file for amd64 architecture
 #
@@ -24,6 +24,7 @@
 # with the i386 (they include the opt_*.h for these)
 #
 
+defflag                        PMC
 defflag                        USER_LDT
 defflag eisa.h EISA
 
diff -r 6a82247aff63 -r 436aef378e8a sys/arch/i386/conf/GENERIC
--- a/sys/arch/i386/conf/GENERIC        Tue Aug 01 23:12:06 2017 +0000
+++ b/sys/arch/i386/conf/GENERIC        Tue Aug 01 23:18:30 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.1156.2.1 2017/07/05 13:58:48 martin Exp $
+# $NetBSD: GENERIC,v 1.1156.2.2 2017/08/01 23:18:30 snj Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident         "GENERIC-$Revision: 1.1156.2.1 $"
+#ident         "GENERIC-$Revision: 1.1156.2.2 $"
 
 maxusers       64              # estimated number of users
 
@@ -42,7 +42,7 @@
 vmt0           at cpu0         # VMware Tools
 
 options        MTRR            # memory-type range register syscall support
-#options       PMC             # performance-monitoring counters support
+options        PMC             # performance-monitoring counters support
 
 options        MULTIBOOT       # Multiboot support (see multiboot(8))
 
diff -r 6a82247aff63 -r 436aef378e8a sys/arch/i386/conf/files.i386
--- a/sys/arch/i386/conf/files.i386     Tue Aug 01 23:12:06 2017 +0000
+++ b/sys/arch/i386/conf/files.i386     Tue Aug 01 23:18:30 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.i386,v 1.378 2017/03/10 14:40:56 maxv Exp $
+#      $NetBSD: files.i386,v 1.378.6.1 2017/08/01 23:18:30 snj Exp $
 #
 # new style config file for i386 architecture
 #
@@ -21,6 +21,8 @@
 # VM86 emulation
 defflag                        VM86
 
+defflag                        PMC
+
 # User-settable LDT (used by WINE)
 defflag                        USER_LDT
 
diff -r 6a82247aff63 -r 436aef378e8a sys/arch/i386/i386/i386_trap.S
--- a/sys/arch/i386/i386/i386_trap.S    Tue Aug 01 23:12:06 2017 +0000
+++ b/sys/arch/i386/i386/i386_trap.S    Tue Aug 01 23:18:30 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i386_trap.S,v 1.6 2017/02/27 06:46:59 chs Exp $        */
+/*     $NetBSD: i386_trap.S,v 1.6.6.1 2017/08/01 23:18:30 snj Exp $    */
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -35,7 +35,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-/*-
+/*
  * Copyright (c) 1998, 2007, 2009 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
@@ -66,7 +66,7 @@
 
 #if 0
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.6 2017/02/27 06:46:59 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.6.6.1 2017/08/01 23:18:30 snj Exp $");
 #endif
 
 /*
@@ -78,10 +78,10 @@
  * (possibly the next clock tick).  Thus, we disable interrupt before checking,
  * and only enable them again on the final `iret' or before calling the AST
  * handler.
- */ 
+ */
 
-#define TRAP(a)                        pushl $(a) ; jmp _C_LABEL(alltraps)
-#define ZTRAP(a)               pushl $0 ; TRAP(a)
+#define TRAP(a)                pushl $(a) ; jmp _C_LABEL(alltraps)
+#define ZTRAP(a)       pushl $0 ; TRAP(a)
 
 #ifdef IPKDB
 #define BPTTRAP(a)     pushl $0; pushl $(a); jmp _C_LABEL(bpttraps)
@@ -89,29 +89,49 @@
 #define BPTTRAP(a)     ZTRAP(a)
 #endif
 
-
        .text
 IDTVEC(trap00)
        ZTRAP(T_DIVIDE)
 IDTVEC_END(trap00)
+
 IDTVEC(trap01)
        BPTTRAP(T_TRCTRAP)
 IDTVEC_END(trap01)
+
+/*
+ * Non Maskable Interrupts are a special case: they can be triggered even
+ * with interrupts disabled, and once triggered they block further NMIs
+ * until an 'iret' instruction is executed.
+ *
+ * Therefore we don't enable interrupts, because the CPU could switch to
+ * another LWP, call 'iret' and unintentionally leave the NMI mode.
+ */
 IDTVEC(trap02)
-       pushl $0
-       pushl $(T_NMI)
+       pushl   $0
+       pushl   $(T_NMI)
        INTRENTRY
-       jmp _C_LABEL(calltrap)
+
+       addl    $1,CPUVAR(NTRAP)        /* statistical info */
+       adcl    $0,CPUVAR(NTRAP)+4
+       pushl   %esp
+       call    _C_LABEL(trap)
+       addl    $4,%esp
+
+       INTRFASTEXIT
 IDTVEC_END(trap02)
+
 IDTVEC(trap03)
        BPTTRAP(T_BPTFLT)
 IDTVEC_END(trap03)
+
 IDTVEC(trap04)
        ZTRAP(T_OFLOW)
 IDTVEC_END(trap04)
+
 IDTVEC(trap05)
        ZTRAP(T_BOUND)
 IDTVEC_END(trap05)
+
 /*
  * Privileged instruction fault.
  */
@@ -124,21 +144,21 @@
 
        /* Check if this is a user fault. */
        /* XXX this was 0x0020 in FreeBSD */
-       cmpl    $GSEL(GCODE_SEL, SEL_KPL), 4(%esp)   /* Check code segment. */
+       cmpl    $GSEL(GCODE_SEL, SEL_KPL),4(%esp) /* Check code segment. */
 
        /* If so, just handle it as a normal trap. */
        jne     norm_ill
-              
+
        /*
         * This is a kernel instruction fault that might have been caused
         * by a DTrace provider.
         */
-       
+
        /*
         * Set our jump address for the jump back in the event that
         * the exception wasn't caused by DTrace at all.
         */
-       movl    $norm_ill, dtrace_invop_calltrap_addr
+       movl    $norm_ill,dtrace_invop_calltrap_addr
 
        /* Jump to the code hooked in by DTrace. */
        jmpl    *dtrace_invop_jump_addr
@@ -154,8 +174,9 @@
        ZTRAP(T_PRIVINFLT)
 IDTVEC_END(trap06)
 #endif
+
 IDTVEC(trap07)
-       pushl   $0                      # dummy error code
+       pushl   $0                      /* dummy error code */
        pushl   $T_DNA
        INTRENTRY
 #ifdef DIAGNOSTIC
@@ -166,24 +187,31 @@
        addl    $4,%esp
        jmp     _C_LABEL(trapreturn)
 IDTVEC_END(trap07)
+
 IDTVEC(trap08)
        TRAP(T_DOUBLEFLT)
 IDTVEC_END(trap08)
+
 IDTVEC(trap09)
        ZTRAP(T_FPOPFLT)
 IDTVEC_END(trap09)
+
 IDTVEC(trap0a)
        TRAP(T_TSSFLT)
 IDTVEC_END(trap0a)
+
 IDTVEC(trap0b)
        TRAP(T_SEGNPFLT)
 IDTVEC_END(trap0b)
+
 IDTVEC(trap0c)
        TRAP(T_STKFLT)
 IDTVEC_END(trap0c)
+
 IDTVEC(trap0d)
        TRAP(T_PROTFLT)
 IDTVEC_END(trap0d)
+
 IDTVEC(trap0e)
 #ifndef XEN
        pushl   $T_PAGEFLT
@@ -197,9 +225,9 @@
        jne     calltrap
        movb    $T_PRIVINFLT,TF_TRAPNO(%esp)
        jmp     calltrap
-#else /* !XEN */
+#else
        TRAP(T_PAGEFLT)
-#endif /* !XEN */
+#endif
 IDTVEC_END(trap0e)
 
 IDTVEC(intrspurious)
@@ -208,11 +236,11 @@
         * The Pentium Pro local APIC may erroneously call this vector for a
         * default IR7.  Just ignore it.



Home | Main Index | Thread Index | Old Index