CVS commit: src/sys/rump

2015-06-15 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Jun 15 11:20:18 UTC 2015

Modified Files:
src/sys/rump: listsrcdirs

Log Message:
add mixerctl to userland utils


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/rump/listsrcdirs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/rump/listsrcdirs
diff -u src/sys/rump/listsrcdirs:1.31 src/sys/rump/listsrcdirs:1.32
--- src/sys/rump/listsrcdirs:1.31	Sat Apr 25 08:48:06 2015
+++ src/sys/rump/listsrcdirs	Mon Jun 15 11:20:18 2015
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-#	$NetBSD: listsrcdirs,v 1.31 2015/04/25 08:48:06 pooka Exp $
+#	$NetBSD: listsrcdirs,v 1.32 2015/06/15 11:20:18 pooka Exp $
 #
 
 #
@@ -106,7 +106,7 @@ lsrc usr /sbin/			mount_ext2fs mount_ffs
 lsrc usr /sbin/			newfs newfs_ext2fs newfs_msdos
 lsrc usr /sbin/			ping ping6 raidctl reboot
 lsrc usr /sbin/			rndctl route setkey sysctl umount
-lsrc usr /usr.bin/		kdump ktrace sockstat
+lsrc usr /usr.bin/		kdump ktrace mixerctl sockstat
 lsrc usr /usr.sbin/		arp dumpfs mdconfig ndp npf pcictl
 lsrc usr /usr.sbin/		rtadvd vnconfig wlanctl
 lsrc usr /external/bsd/		libelf libpcap tcpdump wpa



CVS commit: src/sys/rump

2015-06-15 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Jun 15 11:20:18 UTC 2015

Modified Files:
src/sys/rump: listsrcdirs

Log Message:
add mixerctl to userland utils


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/rump/listsrcdirs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc

2015-06-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 15 14:24:01 UTC 2015

Modified Files:
src/lib/libc: Makefile

Log Message:
Only create and install the tags file for the normal libc (not any of the
compat copies), because we don't want it to be overwritten by the compat
copies. This was detected by the evbarm mkimage complaining.


To generate a diff of this commit:
cvs rdiff -u -r1.168 -r1.169 src/lib/libc/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/rump/dev/lib/libpci

2015-06-15 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Jun 15 15:38:52 UTC 2015

Modified Files:
src/sys/rump/dev/lib/libpci: Makefile pci_at_mainbus.c pci_user.h
rumpdev_bus_dma.c rumpdev_bus_space.c

Log Message:
Add a userfeature definition for iospace.  I/O space is supported if
that flag is given and calling the init routine succeeds (and we're on
x86, which we probably need to be on anyway for this PCI component to
currently be supported).

Also, some adjustments to make things between flags consistent, namely
deprecate the Makefile variable RUMP_PCI_IOSPACE and don't require
userfeature.h to map 1:1 to the interfaces.

Includes contributions from Robert Millan.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/rump/dev/lib/libpci/Makefile \
src/sys/rump/dev/lib/libpci/pci_at_mainbus.c
cvs rdiff -u -r1.4 -r1.5 src/sys/rump/dev/lib/libpci/pci_user.h \
src/sys/rump/dev/lib/libpci/rumpdev_bus_dma.c \
src/sys/rump/dev/lib/libpci/rumpdev_bus_space.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/rump/dev/lib/libpci/Makefile
diff -u src/sys/rump/dev/lib/libpci/Makefile:1.5 src/sys/rump/dev/lib/libpci/Makefile:1.6
--- src/sys/rump/dev/lib/libpci/Makefile:1.5	Wed Jun  3 13:41:56 2015
+++ src/sys/rump/dev/lib/libpci/Makefile	Mon Jun 15 15:38:52 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.5 2015/06/03 13:41:56 pooka Exp $
+#	$NetBSD: Makefile,v 1.6 2015/06/15 15:38:52 pooka Exp $
 #
 
 RUMPTOP= ${TOPRUMP}
@@ -26,7 +26,7 @@ CPPFLAGS+= -I${.CURDIR}/opt -I${RUMPTOP}
 CPPFLAGS+= -I${RUMPTOP}/librump/rumpvfs
 
 .if ${RUMP_PCI_IOSPACE:Uno} == yes
-CPPFLAGS+=-DRUMP_PCI_IOSPACE
+.error RUMP_PCI_IOSPACE defined in Makefile.  Use userfeatures.h instead.
 .endif
 
 .PATH:			${RUMPCOMP_USER_PATH.rumpdev_pci}
Index: src/sys/rump/dev/lib/libpci/pci_at_mainbus.c
diff -u src/sys/rump/dev/lib/libpci/pci_at_mainbus.c:1.5 src/sys/rump/dev/lib/libpci/pci_at_mainbus.c:1.6
--- src/sys/rump/dev/lib/libpci/pci_at_mainbus.c:1.5	Fri Aug 22 14:28:58 2014
+++ src/sys/rump/dev/lib/libpci/pci_at_mainbus.c	Mon Jun 15 15:38:52 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_at_mainbus.c,v 1.5 2014/08/22 14:28:58 pooka Exp $	*/
+/*	$NetBSD: pci_at_mainbus.c,v 1.6 2015/06/15 15:38:52 pooka Exp $	*/
 
 /*
  * Copyright (c) 2010 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci_at_mainbus.c,v 1.5 2014/08/22 14:28:58 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_at_mainbus.c,v 1.6 2015/06/15 15:38:52 pooka Exp $);
 
 #include sys/param.h
 #include sys/conf.h
@@ -43,6 +43,8 @@ __KERNEL_RCSID(0, $NetBSD: pci_at_mainb
 #include rump_private.h
 #include rump_vfs_private.h
 
+#include pci_user.h
+
 RUMP_COMPONENT(RUMP_COMPONENT_DEV)
 {
 	extern const struct cdevsw pci_cdevsw;
@@ -80,8 +82,17 @@ RUMP_COMPONENT(RUMP_COMPONENT_DEV_AFTERM
 #endif
 	pba.pba_flags = PCI_FLAGS_MEM_OKAY |
 	PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY;;
-#ifdef RUMP_PCI_IOSPACE
-	pba.pba_flags |= PCI_FLAGS_IO_OKAY;
+
+#ifdef RUMPCOMP_USERFEATURE_PCI_IOSPACE
+	int error;
+
+	error = rumpcomp_pci_iospace_init();
+	if (!error) {
+		pba.pba_flags |= PCI_FLAGS_IO_OKAY;
+	} else {
+		aprint_error(pci: I/O space init error %d, I/O space not 
+		available\n, error);
+	}
 #endif
 
 	mainbus = device_find_by_driver_unit(mainbus, 0);

Index: src/sys/rump/dev/lib/libpci/pci_user.h
diff -u src/sys/rump/dev/lib/libpci/pci_user.h:1.4 src/sys/rump/dev/lib/libpci/pci_user.h:1.5
--- src/sys/rump/dev/lib/libpci/pci_user.h:1.4	Wed Jun  3 13:55:42 2015
+++ src/sys/rump/dev/lib/libpci/pci_user.h	Mon Jun 15 15:38:52 2015
@@ -1,3 +1,14 @@
+/*
+ * Possible userfeature macro flags:
+ *
+ *   RUMPCOMP_USERFEATURE_PCI_DMAFREE:
+ *	Support free'ing DMA memory.  If not, panic() when free() is called.
+ *
+ *   RUMPCOMP_USERFEATURE_PCI_IOSPACE
+ *	Support for PCI I/O space.  If yes, rumpcomp_pci_iospace_init()
+ *	must be provided.
+ */
+
 #include rumpcomp_userfeatures_pci.h
 
 void *rumpcomp_pci_map(unsigned long, unsigned long);
@@ -9,8 +20,8 @@ void *rumpcomp_pci_irq_establish(unsigne
 
 /* XXX: needs work: support boundary-restricted allocations */
 int rumpcomp_pci_dmalloc(size_t, size_t, unsigned long *, unsigned long *);
-#ifdef rumpcomp_pci_free
-void rumpcomp_pci_free(unsigned long, size_t);
+#ifdef RUMPCOMP_USERFEATURE_PCI_DMAFREE
+void rumpcomp_pci_dmafree(unsigned long, size_t);
 #endif
 
 struct rumpcomp_pci_dmaseg {
@@ -22,3 +33,7 @@ int rumpcomp_pci_dmamem_map(struct rumpc
 			void **);
 
 unsigned long rumpcomp_pci_virt_to_mach(void *);
+
+#ifdef RUMPCOMP_USERFEATURE_PCI_IOSPACE
+int rumpcomp_pci_iospace_init(void);
+#endif
Index: src/sys/rump/dev/lib/libpci/rumpdev_bus_dma.c
diff -u src/sys/rump/dev/lib/libpci/rumpdev_bus_dma.c:1.4 src/sys/rump/dev/lib/libpci/rumpdev_bus_dma.c:1.5
--- src/sys/rump/dev/lib/libpci/rumpdev_bus_dma.c:1.4	Wed Jun  3 

CVS commit: src/sys/rump/dev/lib/libpci

2015-06-15 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Jun 15 15:38:52 UTC 2015

Modified Files:
src/sys/rump/dev/lib/libpci: Makefile pci_at_mainbus.c pci_user.h
rumpdev_bus_dma.c rumpdev_bus_space.c

Log Message:
Add a userfeature definition for iospace.  I/O space is supported if
that flag is given and calling the init routine succeeds (and we're on
x86, which we probably need to be on anyway for this PCI component to
currently be supported).

Also, some adjustments to make things between flags consistent, namely
deprecate the Makefile variable RUMP_PCI_IOSPACE and don't require
userfeature.h to map 1:1 to the interfaces.

Includes contributions from Robert Millan.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/rump/dev/lib/libpci/Makefile \
src/sys/rump/dev/lib/libpci/pci_at_mainbus.c
cvs rdiff -u -r1.4 -r1.5 src/sys/rump/dev/lib/libpci/pci_user.h \
src/sys/rump/dev/lib/libpci/rumpdev_bus_dma.c \
src/sys/rump/dev/lib/libpci/rumpdev_bus_space.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/sys/dev/pci

2015-06-15 Thread Christos Zoulas
In article 557e89ae.8070...@execsw.org,
Masanobu SAITOH  msai...@execsw.org wrote:

 I thought it's not required to wait API was fixed and committed.

I think is better to wait or ask before committing when there is
doubt.

 To support only MSI is easy, but MSI-X is not. This commit includes not
only pci_intr_establish() stuff but also include other MSI-X stuff to setup
MSI-X vector table and interrupt related functions. And, it'll take time
to check regression or stability to make it enable by default, so it's
important other people to test with it.

Even with the broken API, there is no need to triplicate the
interrupt allocation code, kcpuset distribution as I've shown before
in a different patch. Yes, it is more general if you copy the the
code because the tx/rx/link code *can potentially* be different,
but in this case it is not.

christos



CVS commit: src/lib/libc

2015-06-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 15 14:24:01 UTC 2015

Modified Files:
src/lib/libc: Makefile

Log Message:
Only create and install the tags file for the normal libc (not any of the
compat copies), because we don't want it to be overwritten by the compat
copies. This was detected by the evbarm mkimage complaining.


To generate a diff of this commit:
cvs rdiff -u -r1.168 -r1.169 src/lib/libc/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/Makefile
diff -u src/lib/libc/Makefile:1.168 src/lib/libc/Makefile:1.169
--- src/lib/libc/Makefile:1.168	Mon Feb  9 17:44:34 2015
+++ src/lib/libc/Makefile	Mon Jun 15 10:24:01 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.168 2015/02/09 22:44:34 pooka Exp $
+#	$NetBSD: Makefile,v 1.169 2015/06/15 14:24:01 christos Exp $
 #	@(#)Makefile	8.2 (Berkeley) 2/3/94
 #
 # All library objects contain sccsid strings by default; they may be
@@ -130,7 +130,7 @@ REGEX_SPECIALS=[][)(^$$.?*\\;]
 MKREPRO_SED=   -e 's;${NETBSDSRCDIR:C/${REGEX_SPECIALS}//g};/usr/src;'
 .endif
 
-.if ${RUMPRUN} != yes
+.if !defined(MLIBDIR)  ${RUMPRUN} != yes
 realall: tags
 tags: ${SRCS}
 	${_MKTARGET_CREATE}



CVS commit: src/sys/arch/ews4800mips/ews4800mips

2015-06-15 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Mon Jun 15 16:53:17 UTC 2015

Modified Files:
src/sys/arch/ews4800mips/ews4800mips: cons_machdep.c

Log Message:
#include sys/cpu.h for curlwp


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/ews4800mips/ews4800mips/cons_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/filemon

2015-06-15 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Mon Jun 15 18:11:36 UTC 2015

Modified Files:
src/sys/dev/filemon: filemon_wrapper.c

Log Message:
Latest clang uses openat, filemon thus needs to handle it.

For the simple cases where path is absolute or dirfd is for cwd
we can handle this just like open.
For the remaining case we output an 'A' record to offer a clue that
a search for open dir is needed (earlier in the trace).


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/filemon/filemon_wrapper.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/filemon/filemon_wrapper.c
diff -u src/sys/dev/filemon/filemon_wrapper.c:1.5 src/sys/dev/filemon/filemon_wrapper.c:1.6
--- src/sys/dev/filemon/filemon_wrapper.c:1.5	Thu Mar 27 18:27:34 2014
+++ src/sys/dev/filemon/filemon_wrapper.c	Mon Jun 15 18:11:36 2015
@@ -24,7 +24,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: filemon_wrapper.c,v 1.5 2014/03/27 18:27:34 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: filemon_wrapper.c,v 1.6 2015/06/15 18:11:36 sjg Exp $);
 
 #include sys/param.h
 #include sys/types.h
@@ -160,6 +160,51 @@ filemon_wrapper_open(struct lwp * l, str
 }
 
 static int
+filemon_wrapper_openat(struct lwp * l, struct sys_openat_args * uap,
+register_t * retval)
+{
+	int ret;
+	int error;
+	size_t done;
+	struct filemon *filemon;
+
+	if ((ret = sys_openat(l, uap, retval)) == 0) {
+		filemon = filemon_lookup(curproc);
+
+		if (filemon) {
+			error = copyinstr(SCARG(uap, path), filemon-fm_fname1,
+			sizeof(filemon-fm_fname1), done);
+			if (error == 0) {
+if (filemon-fm_fname1[0] != '/' 
+SCARG(uap, fd) != AT_FDCWD) {
+	/*
+	 * Rats we cannot just treat like open.
+	 * Output an 'A' record as a clue.
+	 */
+	filemon_printf(filemon,
+		A %d %s\n,
+		curproc-p_pid,
+		filemon-fm_fname1);
+}
+if (SCARG(uap, oflags)  O_RDWR) {
+	/* we want a separate R record */
+	filemon_printf(filemon,
+		R %d %s\n,
+		curproc-p_pid,
+		filemon-fm_fname1);
+}			
+filemon_printf(filemon,
+%c %d %s\n,
+(SCARG(uap, oflags)  O_ACCMODE) ? 'W' : 'R',
+curproc-p_pid, filemon-fm_fname1);
+			}
+			rw_exit(filemon-fm_mtx);
+		}
+	}
+	return (ret);
+}
+
+static int
 filemon_wrapper_rename(struct lwp * l, struct sys_rename_args * uap,
 register_t * retval)
 {
@@ -311,6 +356,7 @@ filemon_wrapper_install(void)
 	sv_table[SYS_fork].sy_call = (sy_call_t *) filemon_wrapper_fork;
 	sv_table[SYS_link].sy_call = (sy_call_t *) filemon_wrapper_link;
 	sv_table[SYS_open].sy_call = (sy_call_t *) filemon_wrapper_open;
+	sv_table[SYS_openat].sy_call = (sy_call_t *) filemon_wrapper_openat;
 	sv_table[SYS_rename].sy_call = (sy_call_t *) filemon_wrapper_rename;
 	sv_table[SYS_symlink].sy_call = (sy_call_t *) filemon_wrapper_symlink;
 	sv_table[SYS_unlink].sy_call = (sy_call_t *) filemon_wrapper_unlink;
@@ -330,6 +376,7 @@ filemon_wrapper_deinstall(void)
 	sv_table[SYS_fork].sy_call = (sy_call_t *) sys_fork;
 	sv_table[SYS_link].sy_call = (sy_call_t *) sys_link;
 	sv_table[SYS_open].sy_call = (sy_call_t *) sys_open;
+	sv_table[SYS_openat].sy_call = (sy_call_t *) sys_openat;
 	sv_table[SYS_rename].sy_call = (sy_call_t *) sys_rename;
 	sv_table[SYS_symlink].sy_call = (sy_call_t *) sys_symlink;
 	sv_table[SYS_unlink].sy_call = (sy_call_t *) sys_unlink;



CVS commit: src/sys/dev/filemon

2015-06-15 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Mon Jun 15 18:11:36 UTC 2015

Modified Files:
src/sys/dev/filemon: filemon_wrapper.c

Log Message:
Latest clang uses openat, filemon thus needs to handle it.

For the simple cases where path is absolute or dirfd is for cwd
we can handle this just like open.
For the remaining case we output an 'A' record to offer a clue that
a search for open dir is needed (earlier in the trace).


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/filemon/filemon_wrapper.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/xinstall

2015-06-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 15 16:33:38 UTC 2015

Modified Files:
src/usr.bin/xinstall: Makefile xinstall.c

Log Message:
- improve error printing
- deduplicate run functions and don't use the shell so that we handle
  filenames with spaces and metacharacters consistently.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/xinstall/Makefile
cvs rdiff -u -r1.118 -r1.119 src/usr.bin/xinstall/xinstall.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xinstall/Makefile
diff -u src/usr.bin/xinstall/Makefile:1.23 src/usr.bin/xinstall/Makefile:1.24
--- src/usr.bin/xinstall/Makefile:1.23	Mon Jun 15 03:05:09 2015
+++ src/usr.bin/xinstall/Makefile	Mon Jun 15 12:33:38 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.23 2015/06/15 07:05:09 martin Exp $
+#	$NetBSD: Makefile,v 1.24 2015/06/15 16:33:38 christos Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
 
 .include bsd.own.mk
@@ -8,7 +8,8 @@ SRCS=	xinstall.c getid.c
 MAN=	install.1
 
 .PATH:		${NETBSDSRCDIR}/usr.sbin/mtree
-CPPFLAGS+=	-I${NETBSDSRCDIR}/usr.sbin/mtree -DHAVE_POSIX_SPAWN
+CPPFLAGS+=	-I${NETBSDSRCDIR}/usr.sbin/mtree
+CPPFLAGS+=	-DHAVE_POSIX_SPAWN
 
 .if (${HOSTPROG:U} == )
 DPADD+= ${LIBUTIL}

Index: src/usr.bin/xinstall/xinstall.c
diff -u src/usr.bin/xinstall/xinstall.c:1.118 src/usr.bin/xinstall/xinstall.c:1.119
--- src/usr.bin/xinstall/xinstall.c:1.118	Mon Jun 15 03:05:09 2015
+++ src/usr.bin/xinstall/xinstall.c	Mon Jun 15 12:33:38 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: xinstall.c,v 1.118 2015/06/15 07:05:09 martin Exp $	*/
+/*	$NetBSD: xinstall.c,v 1.119 2015/06/15 16:33:38 christos Exp $	*/
 
 /*
  * Copyright (c) 1987, 1993
@@ -46,7 +46,7 @@ __COPYRIGHT(@(#) Copyright (c) 1987, 19
 #if 0
 static char sccsid[] = @(#)xinstall.c	8.1 (Berkeley) 7/21/93;
 #else
-__RCSID($NetBSD: xinstall.c,v 1.118 2015/06/15 07:05:09 martin Exp $);
+__RCSID($NetBSD: xinstall.c,v 1.119 2015/06/15 16:33:38 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -84,7 +84,6 @@ __RCSID($NetBSD: xinstall.c,v 1.118 201
 #include pathnames.h
 #include mtree.h
 
-#define STRIP_ARGS_MAX 32
 #define BACKUP_SUFFIX .old
 
 static int	dobackup, dodir, dostrip, dolink, dopreserve, dorename, dounpriv;
@@ -137,7 +136,8 @@ static void	makelink(char *, char *);
 static void	metadata_log(const char *, const char *, struct timeval *,
 	const char *, const char *, off_t);
 static int	parseid(char *, id_t *);
-static void	strip(char *);
+static void 	run(const char *, const char *, const char *, int);
+static void	strip(const char *);
 __dead static void	usage(void);
 static char   *xbasename(char *);
 static char   *xdirname(char *);
@@ -160,7 +160,8 @@ main(int argc, char *argv[])
 		case 'a':
 			afterinstallcmd = strdup(optarg);
 			if (afterinstallcmd == NULL)
-errx(1, %s, strerror(ENOMEM));
+err(EXIT_FAILURE,
+Can't allocate after command);
 			break;
 		case 'B':
 			suffix = optarg;
@@ -229,14 +230,14 @@ main(int argc, char *argv[])
 	dolink |= LN_RELATIVE;
 	break;
 default:
-	errx(1, %c: invalid link type, *p);
+	errx(EXIT_FAILURE, %c: invalid link type, *p);
 	/* NOTREACHED */
 }
 			break;
 		case 'm':
 			haveopt_m = 1;
 			if (!(set = setmode(optarg)))
-err(1, Cannot set file mode `%s', optarg);
+err(EXIT_FAILURE, Cannot set file mode `%s', optarg);
 			mode = getmode(set, 0);
 			free(set);
 			break;
@@ -245,7 +246,7 @@ main(int argc, char *argv[])
 			break;
 		case 'N':
 			if (! setup_getid(optarg))
-errx(1,
+errx(EXIT_FAILURE,
 			Unable to use user and group databases in `%s',
 optarg);
 			break;
@@ -262,7 +263,7 @@ main(int argc, char *argv[])
 		case 'S':
 			stripArgs = strdup(optarg);
 			if (stripArgs == NULL)
-errx(1, %s, strerror(ENOMEM));
+err(EXIT_FAILURE, Can't allocate options);
 			/* fall through; -S implies -s */
 			/*FALLTHROUGH*/
 		case 's':
@@ -320,7 +321,7 @@ main(int argc, char *argv[])
 		if (gid_from_group(group, gid) == -1) {
 			id_t id;
 			if (!parseid(group, id))
-errx(1, unknown group %s, group);
+errx(EXIT_FAILURE, unknown group %s, group);
 			gid = id;
 		}
 		iflags |= HASGID;
@@ -329,7 +330,7 @@ main(int argc, char *argv[])
 		if (uid_from_user(owner, uid) == -1) {
 			id_t id;
 			if (!parseid(owner, id))
-errx(1, unknown user %s, owner);
+errx(EXIT_FAILURE, unknown user %s, owner);
 			uid = id;
 		}
 		iflags |= HASUID;
@@ -338,7 +339,7 @@ main(int argc, char *argv[])
 #if ! HAVE_NBTOOL_CONFIG_H
 	if (fflags  !dounpriv) {
 		if (string_to_flags(fflags, fileflags, NULL))
-			errx(1, %s: invalid flag, fflags);
+			errx(EXIT_FAILURE, %s: invalid flag, fflags);
 		/* restore fflags since string_to_flags() changed it */
 		fflags = flags_to_string(fileflags, -);
 		iflags |= SETFLAGS;
@@ -375,12 +376,12 @@ main(int argc, char *argv[])
 		/* makelink() handles checks for links */
 	

CVS commit: src/usr.bin/xinstall

2015-06-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 15 16:33:38 UTC 2015

Modified Files:
src/usr.bin/xinstall: Makefile xinstall.c

Log Message:
- improve error printing
- deduplicate run functions and don't use the shell so that we handle
  filenames with spaces and metacharacters consistently.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/xinstall/Makefile
cvs rdiff -u -r1.118 -r1.119 src/usr.bin/xinstall/xinstall.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/ews4800mips/ews4800mips

2015-06-15 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Mon Jun 15 16:53:17 UTC 2015

Modified Files:
src/sys/arch/ews4800mips/ews4800mips: cons_machdep.c

Log Message:
#include sys/cpu.h for curlwp


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/ews4800mips/ews4800mips/cons_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/ews4800mips/ews4800mips/cons_machdep.c
diff -u src/sys/arch/ews4800mips/ews4800mips/cons_machdep.c:1.7 src/sys/arch/ews4800mips/ews4800mips/cons_machdep.c:1.8
--- src/sys/arch/ews4800mips/ews4800mips/cons_machdep.c:1.7	Wed Aug  8 09:02:49 2012
+++ src/sys/arch/ews4800mips/ews4800mips/cons_machdep.c	Mon Jun 15 16:53:17 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: cons_machdep.c,v 1.7 2012/08/08 09:02:49 martin Exp $	*/
+/*	$NetBSD: cons_machdep.c,v 1.8 2015/06/15 16:53:17 matt Exp $	*/
 
 /*-
  * Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
@@ -30,11 +30,12 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cons_machdep.c,v 1.7 2012/08/08 09:02:49 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: cons_machdep.c,v 1.8 2015/06/15 16:53:17 matt Exp $);
 
 #include sys/param.h
-#include sys/systm.h
 #include sys/conf.h
+#include sys/cpu.h
+#include sys/systm.h
 
 #include dev/cons.h
 



CVS commit: src/sys/dev/filemon

2015-06-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 15 19:45:31 UTC 2015

Modified Files:
src/sys/dev/filemon: filemon_wrapper.c

Log Message:
staircase flattening police.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/filemon/filemon_wrapper.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/filemon/filemon_wrapper.c
diff -u src/sys/dev/filemon/filemon_wrapper.c:1.6 src/sys/dev/filemon/filemon_wrapper.c:1.7
--- src/sys/dev/filemon/filemon_wrapper.c:1.6	Mon Jun 15 14:11:36 2015
+++ src/sys/dev/filemon/filemon_wrapper.c	Mon Jun 15 15:45:31 2015
@@ -1,3 +1,5 @@
+/*	$NetBSD: filemon_wrapper.c,v 1.7 2015/06/15 19:45:31 christos Exp $	*/
+
 /*
  * Copyright (c) 2010, Juniper Networks, Inc.
  *
@@ -24,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: filemon_wrapper.c,v 1.6 2015/06/15 18:11:36 sjg Exp $);
+__KERNEL_RCSID(0, $NetBSD: filemon_wrapper.c,v 1.7 2015/06/15 19:45:31 christos Exp $);
 
 #include sys/param.h
 #include sys/types.h
@@ -41,27 +43,27 @@ static int
 filemon_wrapper_chdir(struct lwp * l, const struct sys_chdir_args * uap,
 register_t * retval)
 {
-	int ret;
 	int error;
 	size_t done;
 	struct filemon *filemon;
 	
-	if ((ret = sys_chdir(l, uap, retval)) == 0) {
-		filemon = filemon_lookup(curproc);
+	if ((error = sys_chdir(l, uap, retval)) != 0)
+		return 0;
 
-		if (filemon) {
+	filemon = filemon_lookup(curproc);
+	if (filemon == NULL)
+		return 0;
 
-			error = copyinstr(SCARG(uap, path), filemon-fm_fname1,
-			sizeof(filemon-fm_fname1), done);
-			if (error == 0) {
-filemon_printf(filemon,
-C %d %s\n,
-curproc-p_pid, filemon-fm_fname1);
-			}
-			rw_exit(filemon-fm_mtx);
-		}
-	}
-	return (ret);
+	error = copyinstr(SCARG(uap, path), filemon-fm_fname1,
+	sizeof(filemon-fm_fname1), done);
+	if (error)
+		goto out;
+
+	filemon_printf(filemon, C %d %s\n,
+	curproc-p_pid, filemon-fm_fname1);
+out:
+	rw_exit(filemon-fm_mtx);
+	return 0;
 }
 
 static int
@@ -69,232 +71,234 @@ filemon_wrapper_execve(struct lwp * l, s
 register_t * retval)
 {
 	char fname[MAXPATHLEN];
-	int ret;
 	int error;
 	size_t done;
 	struct filemon *filemon;
 	
-	error = copyinstr(SCARG(uap, path), fname, sizeof(fname), done);
+	if ((error = sys_execve(l, uap, retval)) != EJUSTRETURN)
+		return 0;
 
-	if ((ret = sys_execve(l, uap, retval)) == EJUSTRETURN  error == 0) {
-		filemon = filemon_lookup(curproc);
+	filemon = filemon_lookup(curproc);
+	if (filemon == NULL)
+		return 0;
 
-		if (filemon) {
-			filemon_printf(filemon, E %d %s\n,
-			curproc-p_pid, fname);
-			rw_exit(filemon-fm_mtx);
-		}
-	}
-	return (ret);
+	error = copyinstr(SCARG(uap, path), fname, sizeof(fname), done);
+	if (error)
+		goto out;
+
+	filemon_printf(filemon, E %d %s\n, curproc-p_pid, fname);
+out:
+	rw_exit(filemon-fm_mtx);
+	return 0;
 }
 
 
 static int
 filemon_wrapper_fork(struct lwp * l, const void *v, register_t * retval)
 {
-	int ret;
+	int error;
 	struct filemon *filemon;
 
-	if ((ret = sys_fork(l, v, retval)) == 0) {
-		filemon = filemon_lookup(curproc);
+	if ((error = sys_fork(l, v, retval)) != 0)
+		return error;
 
-		if (filemon) {
-			filemon_printf(filemon, F %d %ld\n,
-			curproc-p_pid, (long) retval[0]);
-			rw_exit(filemon-fm_mtx);
-		}
-	}
-	return (ret);
+	filemon = filemon_lookup(curproc);
+	if (filemon == NULL)
+		return 0;
+
+	filemon_printf(filemon, F %d %ld\n, curproc-p_pid, (long) retval[0]);
+
+	rw_exit(filemon-fm_mtx);
+	return 0;
 }
 
 static int
 filemon_wrapper_vfork(struct lwp * l, const void *v, register_t * retval)
 {
-	int ret;
+	int error;
 	struct filemon *filemon;
 
-	if ((ret = sys_vfork(l, v, retval)) == 0) {
-		filemon = filemon_lookup(curproc);
+	if ((error = sys_vfork(l, v, retval)) != 0)
+		return error;
+
+	filemon = filemon_lookup(curproc);
+	if (filemon == NULL)
+		return 0;
+
+	filemon_printf(filemon, F %d %ld\n, curproc-p_pid, (long) retval[0]);
 
-		if (filemon) {
-			filemon_printf(filemon, F %d %ld\n,
-			curproc-p_pid, (long) retval[0]);
-			rw_exit(filemon-fm_mtx);
-		}
+	rw_exit(filemon-fm_mtx);
+	return 0;
+}
+
+static void
+filemon_flags(struct filemon * filemon, int f)
+{
+	if (f  O_RDWR) {
+		/* we want a separate R record */
+		filemon_printf(filemon, R %d %s\n, curproc-p_pid,
+		filemon-fm_fname1);
 	}
-	return (ret);
+
+	filemon_printf(filemon, %c %d %s\n, (f  O_ACCMODE) ? 'W' : 'R',
+	curproc-p_pid, filemon-fm_fname1);
 }
 
 static int
 filemon_wrapper_open(struct lwp * l, struct sys_open_args * uap,
 register_t * retval)
 {
-	int ret;
 	int error;
 	size_t done;
 	struct filemon *filemon;
 
-	if ((ret = sys_open(l, uap, retval)) == 0) {
-		filemon = filemon_lookup(curproc);
+	if ((error = sys_open(l, uap, retval)) != 0)
+		return error;
 
-		if (filemon) {
-			error = copyinstr(SCARG(uap, path), filemon-fm_fname1,
-			sizeof(filemon-fm_fname1), done);
-	

CVS commit: src/sys/dev/filemon

2015-06-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 15 19:45:31 UTC 2015

Modified Files:
src/sys/dev/filemon: filemon_wrapper.c

Log Message:
staircase flattening police.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/filemon/filemon_wrapper.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/sys/dev/pci

2015-06-15 Thread Masanobu SAITOH
On 2015/06/14 5:42, Christos Zoulas wrote:
 In article 20150613154758.6971...@cvs.netbsd.org,
 SAITOH Masanobu source-changes-d@NetBSD.org wrote:
 -=-=-=-=-=-

 Module Name: src
 Committed By:msaitoh
 Date:Sat Jun 13 15:47:58 UTC 2015

 Modified Files:
  src/sys/dev/pci: if_wm.c if_wmreg.h

 Log Message:
 Add MSI/MSI-X support written by Kengo Nakahara. Some old devices' support
 is written by me. It's disabled by default. If you'd like to use, define
 WM_MSI_MSIX.

 Tested with:
  8254[3405617] (INTx even if it has MSI CAP because of a errata)
  8257[12], 82583 ICH8, ICH10, PCH2, PCH_LPT(I21[78]) (MSI)
  8257[456], 82580, I35[04], I21[01] (MSI-X)

 Not tested:
  82542, 82573, 80003, ICH9, PCH,

 
 I had raised quite a few issues about calcifying this interrupt API,
 also copying the code 3 times...
 
 christos

 I thought it's not required to wait API was fixed and committed.

 To support only MSI is easy, but MSI-X is not. This commit includes not
only pci_intr_establish() stuff but also include other MSI-X stuff to setup
MSI-X vector table and interrupt related functions. And, it'll take time
to check regression or stability to make it enable by default, so it's
important other people to test with it.

 The same work will be required for RAID controllders' drviers.

 Thanks.

-- 
---
SAITOH Masanobu (msai...@execsw.org
 msai...@netbsd.org)


CVS commit: src/usr.bin/xinstall

2015-06-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 15 07:05:09 UTC 2015

Modified Files:
src/usr.bin/xinstall: Makefile xinstall.c

Log Message:
Add optional support for posix_spawn (instead of vfork) and enable it for
the in-tree build.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/xinstall/Makefile
cvs rdiff -u -r1.117 -r1.118 src/usr.bin/xinstall/xinstall.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/xinstall

2015-06-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 15 07:05:09 UTC 2015

Modified Files:
src/usr.bin/xinstall: Makefile xinstall.c

Log Message:
Add optional support for posix_spawn (instead of vfork) and enable it for
the in-tree build.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/xinstall/Makefile
cvs rdiff -u -r1.117 -r1.118 src/usr.bin/xinstall/xinstall.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xinstall/Makefile
diff -u src/usr.bin/xinstall/Makefile:1.22 src/usr.bin/xinstall/Makefile:1.23
--- src/usr.bin/xinstall/Makefile:1.22	Wed Aug 17 14:00:30 2011
+++ src/usr.bin/xinstall/Makefile	Mon Jun 15 07:05:09 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.22 2011/08/17 14:00:30 christos Exp $
+#	$NetBSD: Makefile,v 1.23 2015/06/15 07:05:09 martin Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
 
 .include bsd.own.mk
@@ -8,7 +8,7 @@ SRCS=	xinstall.c getid.c
 MAN=	install.1
 
 .PATH:		${NETBSDSRCDIR}/usr.sbin/mtree
-CPPFLAGS+=	-I${NETBSDSRCDIR}/usr.sbin/mtree
+CPPFLAGS+=	-I${NETBSDSRCDIR}/usr.sbin/mtree -DHAVE_POSIX_SPAWN
 
 .if (${HOSTPROG:U} == )
 DPADD+= ${LIBUTIL}

Index: src/usr.bin/xinstall/xinstall.c
diff -u src/usr.bin/xinstall/xinstall.c:1.117 src/usr.bin/xinstall/xinstall.c:1.118
--- src/usr.bin/xinstall/xinstall.c:1.117	Sun Jul  6 20:54:47 2014
+++ src/usr.bin/xinstall/xinstall.c	Mon Jun 15 07:05:09 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: xinstall.c,v 1.117 2014/07/06 20:54:47 apb Exp $	*/
+/*	$NetBSD: xinstall.c,v 1.118 2015/06/15 07:05:09 martin Exp $	*/
 
 /*
  * Copyright (c) 1987, 1993
@@ -46,7 +46,7 @@ __COPYRIGHT(@(#) Copyright (c) 1987, 19
 #if 0
 static char sccsid[] = @(#)xinstall.c	8.1 (Berkeley) 7/21/93;
 #else
-__RCSID($NetBSD: xinstall.c,v 1.117 2014/07/06 20:54:47 apb Exp $);
+__RCSID($NetBSD: xinstall.c,v 1.118 2015/06/15 07:05:09 martin Exp $);
 #endif
 #endif /* not lint */
 
@@ -72,6 +72,10 @@ __RCSID($NetBSD: xinstall.c,v 1.117 201
 #include util.h
 #include vis.h
 
+#ifdef HAVE_POSIX_SPAWN
+#include spawn.h
+#endif
+
 #include md5.h
 #include rmd160.h
 #include sha1.h
@@ -965,9 +969,16 @@ copy(int from_fd, char *from_name, int t
 static void
 strip(char *to_name)
 {
+	int	status;
+#ifdef HAVE_POSIX_SPAWN
+	char	*args[4];
+	const char *stripprog;
+	int	rv;
+#else
 	static const char exec_failure[] = : exec of strip failed: ;
-	int	serrno, status;
-	const char * volatile stripprog, *progname;
+	int	serrno;
+	const char * volatile *progname, *stripprog;
+#endif
 	char *cmd;
 
 	if ((stripprog = getenv(STRIP)) == NULL || *stripprog == '\0') {
@@ -992,6 +1003,26 @@ strip(char *to_name)
 			err(1, asprintf failed);
 	}
 
+#ifdef HAVE_POSIX_SPAWN
+	status = -1;
+	if (stripArgs) {
+		args[0] = __UNCONST(sh);
+		args[1] = __UNCONST(-c);
+		args[2] = cmd;
+		args[3] = NULL;
+		rv = posix_spawn(NULL, _PATH_BSHELL, NULL, NULL, args, NULL);
+	} else {
+		args[0] = __UNCONST(strip);
+		args[1] = to_name;
+		args[2] = NULL;
+		rv = posix_spawnp(NULL, stripprog, NULL, NULL, args, NULL);
+	}
+
+	if (rv == 0)
+		wait(status);
+	if (rv || status == -1)
+		unlink(to_name);
+#else
 	switch (vfork()) {
 	case -1:
 		serrno = errno;
@@ -1016,6 +1047,7 @@ strip(char *to_name)
 		if (wait(status) == -1 || status)
 			(void)unlink(to_name);
 	}
+#endif
 
 	free(cmd);
 }
@@ -1028,9 +1060,33 @@ strip(char *to_name)
 static void
 afterinstall(const char *command, const char *to_name, int errunlink)
 {
-	int	serrno, status;
+#ifdef HAVE_POSIX_SPAWN
+	char	*args[4];
+	int	rv;
+#else
+	int	serrno;
+#endif
+	int	status;
 	char	*cmd;
 
+#ifdef HAVE_POSIX_SPAWN
+	/*
+	 * build up a command line and let /bin/sh
+	 * parse the arguments
+	 */
+	asprintf(cmd, %s %s, command, to_name);
+	args[0] = __UNCONST(sh);
+	args[1] = __UNCONST(-c);
+	args[2] = cmd;
+	args[3] = NULL;
+
+	rv = posix_spawn(NULL, _PATH_BSHELL, NULL, NULL, args, NULL);
+	if (rv == 0)
+		wait(status);
+	if ((rv || status == -1)  errunlink)
+		(void)unlink(to_name);
+	free(cmd);
+#else
 	switch (vfork()) {
 	case -1:
 		serrno = errno;
@@ -1061,6 +1117,7 @@ afterinstall(const char *command, const 
 		if ((wait(status) == -1 || status)  errunlink)
 			(void)unlink(to_name);
 	}
+#endif
 }
 
 /*



CVS commit: src/sys/arch/sparc64

2015-06-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 15 07:48:08 UTC 2015

Modified Files:
src/sys/arch/sparc64/include: cpu.h
src/sys/arch/sparc64/sparc64: mp_subr.S pmap.c

Log Message:
Slightly optimize the ITLB usage on secondary processors


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sys/arch/sparc64/include/cpu.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sparc64/sparc64/mp_subr.S
cvs rdiff -u -r1.295 -r1.296 src/sys/arch/sparc64/sparc64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/include/cpu.h
diff -u src/sys/arch/sparc64/include/cpu.h:1.114 src/sys/arch/sparc64/include/cpu.h:1.115
--- src/sys/arch/sparc64/include/cpu.h:1.114	Sat Jan  3 11:22:14 2015
+++ src/sys/arch/sparc64/include/cpu.h	Mon Jun 15 07:48:08 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.114 2015/01/03 11:22:14 palle Exp $ */
+/*	$NetBSD: cpu.h,v 1.115 2015/06/15 07:48:08 martin Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -268,7 +268,7 @@ extern vaddr_t cpu_spinup_trampoline;
 
 extern  char   *mp_tramp_code;
 extern  u_long  mp_tramp_code_len;
-extern  u_long  mp_tramp_tlb_slots;
+extern  u_long  mp_tramp_dtlb_slots, mp_tramp_itlb_slots;
 extern  u_long  mp_tramp_func;
 extern  u_long  mp_tramp_ci;
 

Index: src/sys/arch/sparc64/sparc64/mp_subr.S
diff -u src/sys/arch/sparc64/sparc64/mp_subr.S:1.8 src/sys/arch/sparc64/sparc64/mp_subr.S:1.9
--- src/sys/arch/sparc64/sparc64/mp_subr.S:1.8	Sun Nov  2 19:40:06 2014
+++ src/sys/arch/sparc64/sparc64/mp_subr.S	Mon Jun 15 07:48:08 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: mp_subr.S,v 1.8 2014/11/02 19:40:06 palle Exp $	*/
+/*	$NetBSD: mp_subr.S,v 1.9 2015/06/15 07:48:08 martin Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -214,19 +214,20 @@ ENTRY(sparc64_ipi_flush_pte_sun4v)
 	.text
 	.align 32
 1:	rd	%pc, %l0
-	LDULNG	[%l0 + (4f-1b)], %l1	! Load tlb slot count
+	LDULNG	[%l0 + (3f-1b)], %l1	! Load itlb slot count
 	LDULNG	[%l0 + (7f-1b)], %g2	! Load cpu_args address.
 	add	%l0, (6f-1b), %l2	! tlb slots
 	ld	[%g2 + CBA_CPUTYP], %g3 ! Load cputype
 	clr	%l3
-2:	cmp	%l3, %l1
-	be	CCCR, 3f
+.Litlb_loop:
+	cmp	%l3, %l1
+	be	CCCR, .Litlb_done
 	 nop
 	ldx	[%l2 + TTE_VPN], %l4
 	ldx	[%l2 + TTE_DATA], %l5
 #ifdef SUN4V	
 	cmp	%g3, CPU_SUN4V
-	bne,pt	%icc, 8f
+	bne,pt	%icc, .Litlb_4u
 	 nop
 	! sun4v
 	mov	%l4, %o0			! vaddr
@@ -236,10 +237,10 @@ ENTRY(sparc64_ipi_flush_pte_sun4v)
 	mov	FT_MMU_MAP_PERM_ADDR, %o5	! hv fast trap function
 	ta	ST_FAST_TRAP
 	cmp	%o0, 0
-	be,pt	%icc, 9f
+	be,pt	%icc, .Litlb_next
 	 nop
 	sir	! crash if mapping fails
-8:
+.Litlb_4u:
 #endif	
 	! sun4u
 	wr	%g0, ASI_DMMU, %asi
@@ -248,19 +249,60 @@ ENTRY(sparc64_ipi_flush_pte_sun4v)
 	wr	%g0, ASI_IMMU, %asi
 	stxa	%l4, [%g0 + TLB_TAG_ACCESS] %asi
 	stxa	%l5, [%g0] ASI_IMMU_DATA_IN
-9:		
+.Litlb_next:
 	membar	#Sync
 	flush	%l4
 	add	%l2, PTE_SIZE, %l2
 	add	%l3, 1, %l3
-	ba	%xcc, 2b
+	ba	%xcc, .Litlb_loop
 	 nop
-3:	LDULNG	[%l0 + (5f-1b)], %l1	! Load function
+.Litlb_done:
+	! continue the same loop (with indices and pointers et al),
+	! but load a new upper limit and do not push the entries into
+	! the itlb
+	LDULNG	[%l0 + (4f-1b)], %l1	! Load dtlb slot count
+.Ldtlb_loop:
+	cmp	%l3, %l1
+	be	CCCR, .Ldtlb_done
+	 nop
+	ldx	[%l2 + TTE_VPN], %l4
+	ldx	[%l2 + TTE_DATA], %l5
+#ifdef SUN4V	
+	cmp	%g3, CPU_SUN4V
+	bne,pt	%icc, .Ldtlb_4u
+	 nop
+	! sun4v
+	mov	%l4, %o0			! vaddr
+	clr	%o1! reserved
+	mov	%l5, %o2			! tte
+	mov	MAP_DTLB, %o3			! flags
+	mov	FT_MMU_MAP_PERM_ADDR, %o5	! hv fast trap function
+	ta	ST_FAST_TRAP
+	cmp	%o0, 0
+	be,pt	%icc, .Ldtlb_next
+	 nop
+	sir	! crash if mapping fails
+.Ldtlb_4u:
+#endif	
+	! sun4u
+	wr	%g0, ASI_DMMU, %asi
+	stxa	%l4, [%g0 + TLB_TAG_ACCESS] %asi
+	stxa	%l5, [%g0] ASI_DMMU_DATA_IN
+.Ldtlb_next:
+	membar	#Sync
+	flush	%l4
+	add	%l2, PTE_SIZE, %l2
+	add	%l3, 1, %l3
+	ba	%xcc, .Ldtlb_loop
+	 nop
+.Ldtlb_done:
+	LDULNG	[%l0 + (5f-1b)], %l1	! Load function
 	jmpl	%l1, %g0
 	 nop
 
 	.align PTRSZ
 4:	ULONG	0x0
+3:	ULONG	0x0
 5:	ULONG	0x0
 7:	ULONG	0x0
 	_ALIGN
@@ -276,8 +318,10 @@ DATA(mp_tramp_code)
 	POINTER	1b
 DATA(mp_tramp_code_len)
 	ULONG	6b-1b
-DATA(mp_tramp_tlb_slots)
+DATA(mp_tramp_dtlb_slots)
 	ULONG	4b-1b
+DATA(mp_tramp_itlb_slots)
+	ULONG	3b-1b
 DATA(mp_tramp_func)
 	ULONG	5b-1b
 DATA(mp_tramp_ci)

Index: src/sys/arch/sparc64/sparc64/pmap.c
diff -u src/sys/arch/sparc64/sparc64/pmap.c:1.295 src/sys/arch/sparc64/sparc64/pmap.c:1.296
--- src/sys/arch/sparc64/sparc64/pmap.c:1.295	Sun Jun 14 19:05:27 2015
+++ src/sys/arch/sparc64/sparc64/pmap.c	Mon Jun 15 07:48:08 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.295 2015/06/14 19:05:27 martin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.296 2015/06/15 07:48:08 martin Exp $	*/
 /*
  *
  * Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.295 2015/06/14 19:05:27 martin Exp $);

CVS commit: src/sys/arch/sparc64

2015-06-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 15 07:48:08 UTC 2015

Modified Files:
src/sys/arch/sparc64/include: cpu.h
src/sys/arch/sparc64/sparc64: mp_subr.S pmap.c

Log Message:
Slightly optimize the ITLB usage on secondary processors


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sys/arch/sparc64/include/cpu.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sparc64/sparc64/mp_subr.S
cvs rdiff -u -r1.295 -r1.296 src/sys/arch/sparc64/sparc64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.