CVS commit: src/usr.sbin/flashctl

2011-03-20 Thread Adam Hoka
Module Name:src
Committed By:   ahoka
Date:   Sun Mar 20 06:10:27 UTC 2011

Modified Files:
src/usr.sbin/flashctl: flashctl.c

Log Message:
Fix markbad command


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/flashctl/flashctl.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.sbin/flashctl/flashctl.c
diff -u src/usr.sbin/flashctl/flashctl.c:1.1 src/usr.sbin/flashctl/flashctl.c:1.2
--- src/usr.sbin/flashctl/flashctl.c:1.1	Sat Feb 26 18:07:32 2011
+++ src/usr.sbin/flashctl/flashctl.c	Sun Mar 20 06:10:27 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: flashctl.c,v 1.1 2011/02/26 18:07:32 ahoka Exp $	*/
+/*	$NetBSD: flashctl.c,v 1.2 2011/03/20 06:10:27 ahoka Exp $	*/
 
 /*-
  * Copyright (c) 2010 Department of Software Engineering,
@@ -57,8 +57,10 @@
 
 	setprogname(argv[0]);
 
-	if (argc  3)
+	if (argc  3) {
 		usage();
+		exit(1);
+	}
 
 	device = argv[1];
 	command = argv[2];
@@ -66,8 +68,9 @@
 	argv += 3;
 
 	fd = open(device, O_RDWR, 0);
-	if (fd == -1)
+	if (fd == -1) {
 		err(EXIT_FAILURE, can't open flash device);
+	}
 
 	if (!strcmp(erase, command)) {
 		struct flash_info_params ip;
@@ -176,14 +179,24 @@
 			addr += ip.ip_erase_size;
 		}
 
-		if (hasbad)
+		if (hasbad) {
 			printf(Done.\n);
-		else
+		} else {
 			printf(No bad blocks found.\n);
+		}
 	} else if (!strcmp(markbad, command)) {
 		flash_addr_t address;
+
+		/* TODO: maybe we should let the user specify
+		 * multiple blocks?
+		 */
+		if (argc != 1) {
+			warnx(invalid number of arguments);
+			error = 1;
+			goto out;
+		}
 		
-		error = to_intmax(n, argv[1]);
+		error = to_intmax(n, argv[0]);
 		if (error) {
 			warnx(strerror(error));
 			goto out;
@@ -244,6 +257,4 @@
 	getprogname());
 	fprintf(stderr,%s device markbad address\n,
 	getprogname());
-	
-	exit(1);
 }



CVS commit: xsrc/external/mit/xf86-video-ati/dist

2011-03-20 Thread matthew green
Module Name:xsrc
Committed By:   mrg
Date:   Sun Mar 20 07:08:19 UTC 2011

Update of /cvsroot/xsrc/external/mit/xf86-video-ati/dist
In directory ivanova.netbsd.org:/tmp/cvs-serv1648

Log Message:
initial import of xf86-video-ati-6.14.1.  changes include:

- several Xv fixes
- lots of kms/other stuff we can't use yet
- fixes for some crashes

Status:

Vendor Tag: xorg
Release Tags:   xf86-video-ati-6-14-1

U xsrc/external/mit/xf86-video-ati/dist/INSTALL
U xsrc/external/mit/xf86-video-ati/dist/configure.ac
U xsrc/external/mit/xf86-video-ati/dist/configure
U xsrc/external/mit/xf86-video-ati/dist/Makefile.in
U xsrc/external/mit/xf86-video-ati/dist/README
U xsrc/external/mit/xf86-video-ati/dist/COPYING
U xsrc/external/mit/xf86-video-ati/dist/install-sh
U xsrc/external/mit/xf86-video-ati/dist/config.guess
U xsrc/external/mit/xf86-video-ati/dist/compile
U xsrc/external/mit/xf86-video-ati/dist/depcomp
U xsrc/external/mit/xf86-video-ati/dist/config.h.in
U xsrc/external/mit/xf86-video-ati/dist/config.sub
U xsrc/external/mit/xf86-video-ati/dist/aclocal.m4
U xsrc/external/mit/xf86-video-ati/dist/Makefile.am
U xsrc/external/mit/xf86-video-ati/dist/ChangeLog
U xsrc/external/mit/xf86-video-ati/dist/ltmain.sh
U xsrc/external/mit/xf86-video-ati/dist/missing
U xsrc/external/mit/xf86-video-ati/dist/src/atipcirename.h
U xsrc/external/mit/xf86-video-ati/dist/src/ativersion.h
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_atombios.h
U xsrc/external/mit/xf86-video-ati/dist/src/Makefile.in
U xsrc/external/mit/xf86-video-ati/dist/src/theatre_detect.h
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_exa_shared.h
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_exa.c
U xsrc/external/mit/xf86-video-ati/dist/src/legacy_output.c
U xsrc/external/mit/xf86-video-ati/dist/src/r600_exa.c
U xsrc/external/mit/xf86-video-ati/dist/src/evergreen_state.h
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_cursor.c
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_output.c
U xsrc/external/mit/xf86-video-ati/dist/src/atombios_crtc.c
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_textured_video.c
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_crtc.c
U xsrc/external/mit/xf86-video-ati/dist/src/theatre_reg.h
U xsrc/external/mit/xf86-video-ati/dist/src/theatre.c
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_macros.h
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_modes.c
U xsrc/external/mit/xf86-video-ati/dist/src/evergreen_exa.c
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_version.h
C xsrc/external/mit/xf86-video-ati/dist/src/radeon_driver.c
U xsrc/external/mit/xf86-video-ati/dist/src/atimodule.c
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_mm_i2c.c
U xsrc/external/mit/xf86-video-ati/dist/src/atipciids.h
U xsrc/external/mit/xf86-video-ati/dist/src/radeon.h
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_chipset_gen.h
U xsrc/external/mit/xf86-video-ati/dist/src/evergreen_reg_auto.h
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_probe.c
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_accel.c
C xsrc/external/mit/xf86-video-ati/dist/src/r6xx_accel.c
U xsrc/external/mit/xf86-video-ati/dist/src/r600_reg.h
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_textured_videofuncs.c
U xsrc/external/mit/xf86-video-ati/dist/src/theatre_detect.c
U xsrc/external/mit/xf86-video-ati/dist/src/theatre200.h
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_chipinfo_gen.h
U xsrc/external/mit/xf86-video-ati/dist/src/legacy_crtc.c
U xsrc/external/mit/xf86-video-ati/dist/src/evergreen_reg.h
U xsrc/external/mit/xf86-video-ati/dist/src/r600_reg_r7xx.h
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_video.c
U xsrc/external/mit/xf86-video-ati/dist/src/ati.h
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_exa_shared.c
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_legacy_memory.c
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_video.h
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_dri.c
U xsrc/external/mit/xf86-video-ati/dist/src/theatre_module.c
U xsrc/external/mit/xf86-video-ati/dist/src/theatre200.c
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_commonfuncs.c
U xsrc/external/mit/xf86-video-ati/dist/src/r600_shader.h
U xsrc/external/mit/xf86-video-ati/dist/src/simple_list.h
U xsrc/external/mit/xf86-video-ati/dist/src/r600_shader.c
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_pm.c
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_misc.c
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_exa_funcs.c
U xsrc/external/mit/xf86-video-ati/dist/src/theatre_detect_module.c
U xsrc/external/mit/xf86-video-ati/dist/src/theatre200_module.c
U xsrc/external/mit/xf86-video-ati/dist/src/r600_reg_r6xx.h
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_render.c
U xsrc/external/mit/xf86-video-ati/dist/src/drmmode_display.h
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_kms.c
U xsrc/external/mit/xf86-video-ati/dist/src/radeon_vip.c
U 

CVS commit: xsrc/external/mit/xf86-video-ati/dist/src

2011-03-20 Thread matthew green
Module Name:xsrc
Committed By:   mrg
Date:   Sun Mar 20 07:08:58 UTC 2011

Modified Files:
xsrc/external/mit/xf86-video-ati/dist/src: r6xx_accel.c radeon_driver.c

Log Message:
merge xf86-video-ati 6.14.1


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
xsrc/external/mit/xf86-video-ati/dist/src/r6xx_accel.c
cvs rdiff -u -r1.8 -r1.9 \
xsrc/external/mit/xf86-video-ati/dist/src/radeon_driver.c

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

Modified files:

Index: xsrc/external/mit/xf86-video-ati/dist/src/r6xx_accel.c
diff -u xsrc/external/mit/xf86-video-ati/dist/src/r6xx_accel.c:1.4 xsrc/external/mit/xf86-video-ati/dist/src/r6xx_accel.c:1.5
--- xsrc/external/mit/xf86-video-ati/dist/src/r6xx_accel.c:1.4	Mon Feb 21 00:58:48 2011
+++ xsrc/external/mit/xf86-video-ati/dist/src/r6xx_accel.c	Sun Mar 20 07:08:58 2011
@@ -41,6 +41,25 @@
 #include radeon_vbo.h
 #include radeon_exa_shared.h
 
+static const uint32_t R600_ROP[16] = {
+RADEON_ROP3_ZERO, /* GXclear*/
+RADEON_ROP3_DSa,  /* Gxand  */
+RADEON_ROP3_SDna, /* GXandReverse   */
+RADEON_ROP3_S,/* GXcopy */
+RADEON_ROP3_DSna, /* GXandInverted  */
+RADEON_ROP3_D,/* GXnoop */
+RADEON_ROP3_DSx,  /* GXxor  */
+RADEON_ROP3_DSo,  /* GXor   */
+RADEON_ROP3_DSon, /* GXnor  */
+RADEON_ROP3_DSxn, /* GXequiv*/
+RADEON_ROP3_Dn,   /* GXinvert   */
+RADEON_ROP3_SDno, /* GXorReverse*/
+RADEON_ROP3_Sn,   /* GXcopyInverted */
+RADEON_ROP3_DSno, /* GXorInverted   */
+RADEON_ROP3_DSan, /* GXnand */
+RADEON_ROP3_ONE,  /* GXset  */
+};
+
 /* we try and batch operations together under KMS -
but it doesn't work yet without misrendering */
 #define KMS_MULTI_OP 1
@@ -203,7 +222,7 @@
 void
 r600_set_render_target(ScrnInfoPtr pScrn, drmBufPtr ib, cb_config_t *cb_conf, uint32_t domain)
 {
-uint32_t cb_color_info;
+uint32_t cb_color_info, cb_color_control;
 int pitch, slice, h;
 RADEONInfoPtr info = RADEONPTR(pScrn);
 
@@ -276,6 +295,21 @@
 RELOC_BATCH(cb_conf-bo, 0, domain);
 END_BATCH();
 
+BEGIN_BATCH(9);
+EREG(ib, CB_TARGET_MASK,  (cb_conf-pmask  TARGET0_ENABLE_shift));
+cb_color_control = R600_ROP[cb_conf-rop] |
+	(cb_conf-blend_enable  TARGET_BLEND_ENABLE_shift);
+if (info-ChipFamily == CHIP_FAMILY_R600) {
+	/* no per-MRT blend on R600 */
+	EREG(ib, CB_COLOR_CONTROL,cb_color_control);
+	EREG(ib, CB_BLEND_CONTROL,cb_conf-blendcntl);
+} else {
+	if (cb_conf-blend_enable)
+	cb_color_control |= PER_MRT_BLEND_bit;
+	EREG(ib, CB_COLOR_CONTROL,cb_color_control);
+	EREG(ib, CB_BLEND0_CONTROL,   cb_conf-blendcntl);
+}
+END_BATCH();
 }
 
 static void
@@ -385,6 +419,21 @@
 }
 
 void
+r600_set_spi(ScrnInfoPtr pScrn, drmBufPtr ib, int vs_export_count, int num_interp)
+{
+RADEONInfoPtr info = RADEONPTR(pScrn);
+
+BEGIN_BATCH(8);
+/* Interpolator setup */
+EREG(ib, SPI_VS_OUT_CONFIG, (vs_export_count  VS_EXPORT_COUNT_shift));
+PACK0(ib, SPI_PS_IN_CONTROL_0, 3);
+E32(ib, (num_interp  NUM_INTERP_shift));
+E32(ib, 0);
+E32(ib, 0);
+END_BATCH();
+}
+
+void
 r600_fs_setup(ScrnInfoPtr pScrn, drmBufPtr ib, shader_config_t *fs_conf, uint32_t domain)
 {
 RADEONInfoPtr info = RADEONPTR(pScrn);
@@ -1002,7 +1051,7 @@
 for (i = 0; i  PA_SC_VPORT_SCISSOR_0_TL_num; i++)
 	r600_set_vport_scissor(pScrn, ib, i, 0, 0, 8192, 8192);
 
-BEGIN_BATCH(42);
+BEGIN_BATCH(49);
 PACK0(ib, PA_SC_MPASS_PS_CNTL, 2);
 E32(ib, 0);
 if (info-ChipFamily  CHIP_FAMILY_RV770)
@@ -1046,6 +1095,19 @@
 else
 	EREG(ib, R7xx_SPI_THREAD_GROUPING,(1  PS_GROUPING_shift));
 
+/* default Interpolator setup */
+EREG(ib, SPI_VS_OUT_ID_0, ((0  SEMANTIC_0_shift) |
+			   (1  SEMANTIC_1_shift)));
+PACK0(ib, SPI_PS_INPUT_CNTL_0 + (0  2), 2);
+/* SPI_PS_INPUT_CNTL_0 maps to GPR[0] - load with semantic id 0 */
+E32(ib, ((0 SEMANTIC_shift)	|
+	 (0x01  DEFAULT_VAL_shift)	|
+	 SEL_CENTROID_bit));
+/* SPI_PS_INPUT_CNTL_1 maps to GPR[1] - load with semantic id 1 */
+E32(ib, ((1 SEMANTIC_shift)	|
+	 (0x01  DEFAULT_VAL_shift)	|
+	 SEL_CENTROID_bit));
+
 PACK0(ib, SPI_INPUT_Z, 4);
 E32(ib, 0); // SPI_INPUT_Z
 E32(ib, 0); // SPI_FOG_CNTL
@@ -1122,7 +1184,11 @@
 BEGIN_BATCH(8 + count);
 EREG(ib, VGT_PRIMITIVE_TYPE, draw_conf-prim_type);
 PACK3(ib, IT_INDEX_TYPE, 1);
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+E32(ib, IT_INDEX_TYPE_SWAP_MODE(ENDIAN_8IN32) | draw_conf-index_type);
+#else
 E32(ib, draw_conf-index_type);
+#endif
 PACK3(ib, IT_NUM_INSTANCES, 1);
 E32(ib, draw_conf-num_instances);
 
@@ -1152,7 +1218,11 @@
 BEGIN_BATCH(10);
 EREG(ib, VGT_PRIMITIVE_TYPE, draw_conf-prim_type);
 PACK3(ib, IT_INDEX_TYPE, 1);
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+

CVS commit: xsrc/external/mit/xf86-video-ati/include

2011-03-20 Thread matthew green
Module Name:xsrc
Committed By:   mrg
Date:   Sun Mar 20 07:09:33 UTC 2011

Modified Files:
xsrc/external/mit/xf86-video-ati/include: config.h

Log Message:
update for xf86-video-ati 6.14.1


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 xsrc/external/mit/xf86-video-ati/include/config.h

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

Modified files:

Index: xsrc/external/mit/xf86-video-ati/include/config.h
diff -u xsrc/external/mit/xf86-video-ati/include/config.h:1.10 xsrc/external/mit/xf86-video-ati/include/config.h:1.11
--- xsrc/external/mit/xf86-video-ati/include/config.h:1.10	Mon Feb 21 01:01:00 2011
+++ xsrc/external/mit/xf86-video-ati/include/config.h	Sun Mar 20 07:09:33 2011
@@ -83,7 +83,7 @@
 #define PACKAGE_NAME xf86-video-ati
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING xf86-video-ati 6.14.0
+#define PACKAGE_STRING xf86-video-ati 6.14.1
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME xf86-video-ati
@@ -92,7 +92,7 @@
 #undef PACKAGE_URL
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION 6.14.0
+#define PACKAGE_VERSION 6.14.1
 
 /* Major version of this package */
 #define PACKAGE_VERSION_MAJOR 6
@@ -101,7 +101,7 @@
 #define PACKAGE_VERSION_MINOR 14
 
 /* Patch version of this package */
-#define PACKAGE_VERSION_PATCHLEVEL 0
+#define PACKAGE_VERSION_PATCHLEVEL 1
 
 /* Enable DRI2 code */
 #define RADEON_DRI2 1
@@ -119,7 +119,7 @@
 #define USE_XAA 1
 
 /* Version number of package */
-#define VERSION 6.14.0
+#define VERSION 6.14.1
 
 /* Enable DRI driver support */
 #define XF86DRI 1



CVS commit: src/distrib/sparc64/cdroms/installcd

2011-03-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 20 09:04:53 UTC 2011

Modified Files:
src/distrib/sparc64/cdroms/installcd: Makefile

Log Message:
Add /usr/bin/getopt, it is needed by /usr/mdec/binstall.
Noticed by Jaime Fournier.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/distrib/sparc64/cdroms/installcd/Makefile

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

Modified files:

Index: src/distrib/sparc64/cdroms/installcd/Makefile
diff -u src/distrib/sparc64/cdroms/installcd/Makefile:1.9 src/distrib/sparc64/cdroms/installcd/Makefile:1.10
--- src/distrib/sparc64/cdroms/installcd/Makefile:1.9	Fri Jan 14 10:26:36 2011
+++ src/distrib/sparc64/cdroms/installcd/Makefile	Sun Mar 20 09:04:53 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.9 2011/01/14 10:26:36 tsutsui Exp $
+#	$NetBSD: Makefile,v 1.10 2011/03/20 09:04:53 martin Exp $
 CDBASE=		sparc64cd		# gives ${CDBASE}.iso
 CDRELEASE=	true			# include $RELEASEDIR/$MACHINE
 
@@ -23,9 +23,10 @@
 # CDRUNTIME+=	./stand
 CDRUNTIME+=	./tmp
 CDRUNTIME+=	./usr/bin/ftp
+CDRUNTIME+=	./usr/bin/getopt
+CDRUNTIME+=	./usr/bin/gunzip
 CDRUNTIME+=	./usr/bin/gzcat
 CDRUNTIME+=	./usr/bin/gzip
-CDRUNTIME+=	./usr/bin/gunzip
 CDRUNTIME+=	./usr/bin/grep
 CDRUNTIME+=	./usr/bin/less
 CDRUNTIME+=	./usr/bin/more



CVS commit: xsrc/external/mit/xf86-video-ati/dist/src

2011-03-20 Thread matthew green
Module Name:xsrc
Committed By:   mrg
Date:   Sun Mar 20 10:40:24 UTC 2011

Modified Files:
xsrc/external/mit/xf86-video-ati/dist/src: r600_exa.c
radeon_textured_video.c

Log Message:
avoid drmmode_get_height_align() in non XF86MODE (KMS) code.
fixes this on r6xx/r7xx.  (other cards wouldn't have called
into the path that failed.)


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.7 -r1.2 \
xsrc/external/mit/xf86-video-ati/dist/src/r600_exa.c
cvs rdiff -u -r1.1.1.6 -r1.2 \
xsrc/external/mit/xf86-video-ati/dist/src/radeon_textured_video.c

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

Modified files:

Index: xsrc/external/mit/xf86-video-ati/dist/src/r600_exa.c
diff -u xsrc/external/mit/xf86-video-ati/dist/src/r600_exa.c:1.1.1.7 xsrc/external/mit/xf86-video-ati/dist/src/r600_exa.c:1.2
--- xsrc/external/mit/xf86-video-ati/dist/src/r600_exa.c:1.1.1.7	Sun Mar 20 07:08:03 2011
+++ xsrc/external/mit/xf86-video-ati/dist/src/r600_exa.c	Sun Mar 20 10:40:24 2011
@@ -621,8 +621,12 @@
 	return FALSE;
 
 if (accel_state-same_surface == TRUE) {
+#if defined(XF86DRM_MODE)
 	unsigned height = RADEON_ALIGN(pDst-drawable.height,
    drmmode_get_height_align(pScrn, accel_state-dst_obj.tiling_flags));
+#else
+	unsigned height = pDst-drawable.height;
+#endif
 	unsigned long size = height * accel_state-dst_obj.pitch * pDst-drawable.bitsPerPixel/8;
 
 #if defined(XF86DRM_MODE)

Index: xsrc/external/mit/xf86-video-ati/dist/src/radeon_textured_video.c
diff -u xsrc/external/mit/xf86-video-ati/dist/src/radeon_textured_video.c:1.1.1.6 xsrc/external/mit/xf86-video-ati/dist/src/radeon_textured_video.c:1.2
--- xsrc/external/mit/xf86-video-ati/dist/src/radeon_textured_video.c:1.1.1.6	Sun Mar 20 07:08:03 2011
+++ xsrc/external/mit/xf86-video-ati/dist/src/radeon_textured_video.c	Sun Mar 20 10:40:24 2011
@@ -248,7 +248,11 @@
 BoxRec dstBox;
 int dst_width = width, dst_height = height;
 int aligned_height;
+#ifdef XF86DRM_MODE
 int h_align = drmmode_get_height_align(pScrn, 0);
+#else
+int h_align = 1;
+#endif
 /* make the compiler happy */
 s2offset = s3offset = srcPitch2 = 0;
 



CVS commit: src/sbin/fsck_ffs

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 11:41:25 UTC 2011

Modified Files:
src/sbin/fsck_ffs: setup.c

Log Message:
initialise memory allocated for uquot_user_hash  uquot_group_hash.
Pointed out by Nicolas Joly.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sbin/fsck_ffs/setup.c

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

Modified files:

Index: src/sbin/fsck_ffs/setup.c
diff -u src/sbin/fsck_ffs/setup.c:1.91 src/sbin/fsck_ffs/setup.c:1.92
--- src/sbin/fsck_ffs/setup.c:1.91	Sun Mar  6 17:08:16 2011
+++ src/sbin/fsck_ffs/setup.c	Sun Mar 20 11:41:24 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: setup.c,v 1.91 2011/03/06 17:08:16 bouyer Exp $	*/
+/*	$NetBSD: setup.c,v 1.92 2011/03/20 11:41:24 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = @(#)setup.c	8.10 (Berkeley) 5/9/95;
 #else
-__RCSID($NetBSD: setup.c,v 1.91 2011/03/06 17:08:16 bouyer Exp $);
+__RCSID($NetBSD: setup.c,v 1.92 2011/03/20 11:41:24 bouyer Exp $);
 #endif
 #endif /* not lint */
 
@@ -565,9 +565,9 @@
 			q2h_hash_mask);
 		}
 		uquot_user_hash =
-		malloc((1  q2h_hash_shift) * sizeof(struct uquot_hash));
+		calloc((1  q2h_hash_shift), sizeof(struct uquot_hash));
 		uquot_group_hash =
-		malloc((1  q2h_hash_shift) * sizeof(struct uquot_hash));
+		calloc((1  q2h_hash_shift), sizeof(struct uquot_hash));
 		if (uquot_user_hash == NULL || uquot_group_hash == NULL)
 			errexit(Cannot allocate space for quotas hash\n);
 	} else {



CVS commit: src/sys/fs/msdosfs

2011-03-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Mar 20 12:21:28 UTC 2011

Modified Files:
src/sys/fs/msdosfs: msdosfs_denode.c msdosfs_vnops.c

Log Message:
When extending a file, either by truncating or by writing past EOF make
sure the unallocated remainder of the last page gets zeroed.

Detected by fsx.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/fs/msdosfs/msdosfs_denode.c
cvs rdiff -u -r1.73 -r1.74 src/sys/fs/msdosfs/msdosfs_vnops.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/fs/msdosfs/msdosfs_denode.c
diff -u src/sys/fs/msdosfs/msdosfs_denode.c:1.40 src/sys/fs/msdosfs/msdosfs_denode.c:1.41
--- src/sys/fs/msdosfs/msdosfs_denode.c:1.40	Wed Jul 21 17:52:10 2010
+++ src/sys/fs/msdosfs/msdosfs_denode.c	Sun Mar 20 12:21:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_denode.c,v 1.40 2010/07/21 17:52:10 hannken Exp $	*/
+/*	$NetBSD: msdosfs_denode.c,v 1.41 2011/03/20 12:21:28 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.40 2010/07/21 17:52:10 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.41 2011/03/20 12:21:28 hannken Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -583,7 +583,7 @@
 	uvm_vnp_setwritesize(DETOV(dep), (voff_t)dep-de_FileSize);
 	dep-de_flag |= DE_UPDATE|DE_MODIFIED;
 	uvm_vnp_zerorange(DETOV(dep), (off_t)osize,
-	(size_t)(dep-de_FileSize - osize));
+	(size_t)(round_page(dep-de_FileSize) - osize));
 	uvm_vnp_setsize(DETOV(dep), (voff_t)dep-de_FileSize);
 	return (deupdat(dep, 1));
 }

Index: src/sys/fs/msdosfs/msdosfs_vnops.c
diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.73 src/sys/fs/msdosfs/msdosfs_vnops.c:1.74
--- src/sys/fs/msdosfs/msdosfs_vnops.c:1.73	Sat Mar 19 20:05:21 2011
+++ src/sys/fs/msdosfs/msdosfs_vnops.c	Sun Mar 20 12:21:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.73 2011/03/19 20:05:21 hannken Exp $	*/
+/*	$NetBSD: msdosfs_vnops.c,v 1.74 2011/03/20 12:21:28 hannken Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.73 2011/03/19 20:05:21 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.74 2011/03/20 12:21:28 hannken Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -554,6 +554,7 @@
 	u_long count;
 	vsize_t bytelen;
 	off_t oldoff;
+	size_t rem;
 	struct uio *uio = ap-a_uio;
 	struct vnode *vp = ap-a_vp;
 	struct denode *dep = VTODE(vp);
@@ -623,6 +624,10 @@
 		dep-de_FileSize = uio-uio_offset + resid;
 		/* hint uvm to not read in extended part */
 		uvm_vnp_setwritesize(vp, dep-de_FileSize);
+		/* zero out the remainder of the last page */
+		rem = round_page(dep-de_FileSize) - dep-de_FileSize;
+		if (rem  0)
+			uvm_vnp_zerorange(vp, (off_t)dep-de_FileSize, rem);
 		extended = 1;
 	}
 



CVS commit: src/lib/libedit

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 12:36:15 UTC 2011

Modified Files:
src/lib/libedit: el.c

Log Message:
Fix use-after-free. Discovered by running tests with MALLOC_OPTIONS=J
(should this be the default for tests ?), pointed out by njoly@


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/lib/libedit/el.c

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

Modified files:

Index: src/lib/libedit/el.c
diff -u src/lib/libedit/el.c:1.61 src/lib/libedit/el.c:1.62
--- src/lib/libedit/el.c:1.61	Thu Jan 27 23:11:40 2011
+++ src/lib/libedit/el.c	Sun Mar 20 12:36:14 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: el.c,v 1.61 2011/01/27 23:11:40 christos Exp $	*/
+/*	$NetBSD: el.c,v 1.62 2011/03/20 12:36:14 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = @(#)el.c	8.2 (Berkeley) 1/3/94;
 #else
-__RCSID($NetBSD: el.c,v 1.61 2011/01/27 23:11:40 christos Exp $);
+__RCSID($NetBSD: el.c,v 1.62 2011/03/20 12:36:14 bouyer Exp $);
 #endif
 #endif /* not lint  not SCCSID */
 
@@ -135,13 +135,13 @@
 	sig_end(el);
 
 	el_free((ptr_t) el-el_prog);
-	el_free((ptr_t) el);
 #ifdef WIDECHAR
 	el_free((ptr_t) el-el_scratch.cbuff);
 	el_free((ptr_t) el-el_scratch.wbuff);
 	el_free((ptr_t) el-el_lgcyconv.cbuff);
 	el_free((ptr_t) el-el_lgcyconv.wbuff);
 #endif
+	el_free((ptr_t) el);
 }
 
 



CVS commit: src/etc/etc.sandpoint

2011-03-20 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Mar 20 12:40:58 UTC 2011

Modified Files:
src/etc/etc.sandpoint: MAKEDEV.conf

Log Message:
Added missing devices: usb, sysmon, altq


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/etc/etc.sandpoint/MAKEDEV.conf

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

Modified files:

Index: src/etc/etc.sandpoint/MAKEDEV.conf
diff -u src/etc/etc.sandpoint/MAKEDEV.conf:1.11 src/etc/etc.sandpoint/MAKEDEV.conf:1.12
--- src/etc/etc.sandpoint/MAKEDEV.conf:1.11	Tue Mar  1 09:17:06 2011
+++ src/etc/etc.sandpoint/MAKEDEV.conf	Sun Mar 20 12:40:58 2011
@@ -1,4 +1,4 @@
-# $NetBSD: MAKEDEV.conf,v 1.11 2011/03/01 09:17:06 phx Exp $
+# $NetBSD: MAKEDEV.conf,v 1.12 2011/03/20 12:40:58 phx Exp $
 
 init)
 	makedev std tty00 tty01 opty ptm pty0
@@ -10,8 +10,9 @@
 	makedev tty00 tty01
 	makedev wd0 wd1
 	makedev sd0 sd1 sd2 st0 cd0 ss0 ch0 uk0
+	makedev	usbs
 	makedev scsibus0 scsibus1
-	makedev pci0 cfs satmgr power
+	makedev pci0 altq sysmon kttcp cfs satmgr
 	;;
 
 ramdisk|floppy)



CVS commit: src/distrib/utils/sysinst/arch/sandpoint

2011-03-20 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Mar 20 12:43:40 UTC 2011

Modified Files:
src/distrib/utils/sysinst/arch/sandpoint: md.c

Log Message:
Use sysctl-node machdep.prodfamily to decide about the kernel to install and
to fix the console speed in /etc/ttys.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/distrib/utils/sysinst/arch/sandpoint/md.c

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

Modified files:

Index: src/distrib/utils/sysinst/arch/sandpoint/md.c
diff -u src/distrib/utils/sysinst/arch/sandpoint/md.c:1.33 src/distrib/utils/sysinst/arch/sandpoint/md.c:1.34
--- src/distrib/utils/sysinst/arch/sandpoint/md.c:1.33	Tue Feb  1 01:42:14 2011
+++ src/distrib/utils/sysinst/arch/sandpoint/md.c	Sun Mar 20 12:43:40 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: md.c,v 1.33 2011/02/01 01:42:14 joerg Exp $ */
+/*	$NetBSD: md.c,v 1.34 2011/03/20 12:43:40 phx Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -41,7 +41,9 @@
 #include sys/param.h
 #include sys/sysctl.h
 #include sys/utsname.h
+
 #include stdio.h
+#include string.h
 #include util.h
 
 #include defs.h
@@ -49,6 +51,8 @@
 #include msg_defs.h
 #include menu_defs.h
 
+static char *prodname;
+
 void
 md_init(void)
 {
@@ -57,26 +61,35 @@
 void
 md_init_set_status(int flags)
 {
-	struct utsname instsys;
+	static const char mib_name[] = machdep.prodfamily;
+	static char unknown[] = unknown;
+	size_t len;
 
 	(void)flags;
 
 	/*
-	 * Get the name of the Install Kernel we are running under and
+	 * Determine the product family of the board we are running on and
 	 * enable the installation of the corresponding GENERIC kernel.
 	 *
 	 * Note:  In md.h the two kernels are disabled.  If they are
 	 *enabled there the logic here needs to be switched.
 	 */
-uname(instsys);
-if (strstr(instsys.version, (INSTALL_KURO)))
+	if (sysctlbyname(mib_name, NULL, len, NULL, 0) != 0) {
+		prodname = unknown;
+		return;
+	}
+	prodname = malloc(len);
+	sysctlbyname(mib_name, prodname, len, NULL, 0);
+printf(\n***\n*** Installing on %s\n***\n, prodname);
+
+	if (strcmp(prodname, kurobox) == 0)
 		/*
-		 * Running the KuroBox Installation Kernel, so enable KUROBOX
+		 * Running on a KuroBox family product, so enable KUROBOX
 		 */
 		set_kernel_set(SET_KERNEL_2);
 else
 		/*
-		 * Running the GENERIC Installation Kernel, so enable GENERIC
+		 * Otherwise enable GENERIC
 		 */
 		set_kernel_set(SET_KERNEL_1);
 }
@@ -159,15 +172,30 @@
 md_cleanup_install(void)
 {
 #ifndef DEBUG
+	int new_speed;
+	char sed_cmd[64];
+
 	enable_rc_conf();
 
 	/*
-	 * For KUROBOX set the console speed to 57600 in /etc/ttys.
+	 * Set the console speed in /etc/ttys depending on the board.
+	 * The default speed is 115200, which is patched when needed.
 	 */
-	if (get_kernel_set() == SET_KERNEL_2)
-		run_program(RUN_CHROOT,
-		sed -an -e 's/115200/57600/;H;$!d;g;w /etc/ttys'
-		 /etc/ttys);
+	if (strcmp(prodname, kurobox) == 0)
+		new_speed = 57600;			/* KuroBox */
+
+	else if (strcmp(prodname, dlink) == 0 ||	/* D-Link DSM-G600 */
+	strcmp(prodname, nhnas) == 0)		/* NH23x, All6250 */
+		new_speed = 9600;
+	
+	else
+		new_speed = 0;
+
+	if (new_speed != 0) {
+		snprintf(sed_cmd, 64, sed -an -e 's/115200/%d/;H;$!d;g;w
+		/etc/ttys' /etc/ttys, new_speed);
+		run_program(RUN_CHROOT, sed_cmd);
+	}
 #endif
 }
 



CVS commit: src/share/man/man7

2011-03-20 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Sun Mar 20 13:07:39 UTC 2011

Modified Files:
src/share/man/man7: security.7

Log Message:
Now that this is a generic page, clarify the AUTHORS section a little.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/share/man/man7/security.7

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

Modified files:

Index: src/share/man/man7/security.7
diff -u src/share/man/man7/security.7:1.6 src/share/man/man7/security.7:1.7
--- src/share/man/man7/security.7:1.6	Sat Mar 19 08:42:41 2011
+++ src/share/man/man7/security.7	Sun Mar 20 13:07:38 2011
@@ -1,4 +1,4 @@
-.\ $NetBSD: security.7,v 1.6 2011/03/19 08:42:41 wiz Exp $
+.\ $NetBSD: security.7,v 1.7 2011/03/20 13:07:38 jruoho Exp $
 .\
 .\ Copyright (c) 2006, 2011 Elad Efrat e...@netbsd.org
 .\ All rights reserved.
@@ -25,7 +25,7 @@
 .\ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\
-.Dd March 18, 2011
+.Dd March 20, 2011
 .Dt SECURITY 7
 .Os
 .Sh NAME
@@ -440,4 +440,5 @@
 .Xr sysctl 8 ,
 .Xr veriexec 8
 .Sh AUTHORS
-.An Elad Efrat Aq e...@netbsd.org
+Many of the security features were pioneered by
+.An Elad Efrat Aq e...@netbsd.org .



CVS commit: src/sys/arch/sandpoint/conf

2011-03-20 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Mar 20 17:10:46 UTC 2011

Modified Files:
src/sys/arch/sandpoint/conf: GENERIC

Log Message:
More networking options.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/sandpoint/conf/GENERIC

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/sandpoint/conf/GENERIC
diff -u src/sys/arch/sandpoint/conf/GENERIC:1.56 src/sys/arch/sandpoint/conf/GENERIC:1.57
--- src/sys/arch/sandpoint/conf/GENERIC:1.56	Sat Mar 19 16:05:35 2011
+++ src/sys/arch/sandpoint/conf/GENERIC	Sun Mar 20 17:10:46 2011
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.56 2011/03/19 16:05:35 phx Exp $
+# $NetBSD: GENERIC,v 1.57 2011/03/20 17:10:46 phx Exp $
 #
 # machine description file for GENERIC NAS
 # 
@@ -22,7 +22,7 @@
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		GENERIC-$Revision: 1.56 $
+#ident 		GENERIC-$Revision: 1.57 $
 
 maxusers	32
 
@@ -102,8 +102,27 @@
 #options 	FFS_NO_SNAPSHOT	# No FFS snapshot support
 #options 	EXT2FS_SYSTEM_FLAGS # makes ext2fs file flags (append and
 
-options 	INET
+# Networking options
+#options 	GATEWAY		# packet forwarding
+options 	INET		# IP + ICMP + TCP + UDP
 options 	INET6		# IPV6
+#options 	IPSEC		# IP security
+#options 	IPSEC_ESP	# IP security (encryption part; define w/IPSEC)
+#options 	IPSEC_NAT_T	# IPsec NAT traversal (NAT-T)
+#options 	IPSEC_DEBUG	# debug for IP security
+#options 	MROUTING	# IP multicast routing
+#options 	PIM		# Protocol Independent Multicast
+#options 	ISO,TPIP	# OSI
+#options 	EON		# OSI tunneling over IP
+#options 	NETATALK	# AppleTalk networking protocols
+#options 	PPP_BSDCOMP	# BSD-Compress compression support for PPP
+#options 	PPP_DEFLATE	# Deflate compression support for PPP
+#options 	PPP_FILTER	# Active filter support for PPP (requires BPF)
+#options 	PFIL_HOOKS	# pfil(9) packet filter hooks
+#options 	IPFILTER_LOG	# ipmon(8) log support
+#options 	IPFILTER_LOOKUP	# ippool(8) support
+#options 	IPFILTER_COMPAT # Compat for IP-Filter
+#options 	IPFILTER_DEFAULT_BLOCK	# block all packets by default
 #options 	TCP_DEBUG	# Record last TCP_NDEBUG packets with SO_DEBUG
 
 #options 	ALTQ		# Manipulate network interfaces' output queues



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

2011-03-20 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Mar 20 17:32:20 UTC 2011

Modified Files:
src/sys/arch/ews4800mips/conf: RAMDISK

Log Message:
Shrink more options, file-systems and device.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/ews4800mips/conf/RAMDISK

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/conf/RAMDISK
diff -u src/sys/arch/ews4800mips/conf/RAMDISK:1.14 src/sys/arch/ews4800mips/conf/RAMDISK:1.15
--- src/sys/arch/ews4800mips/conf/RAMDISK:1.14	Sun Mar  6 17:08:24 2011
+++ src/sys/arch/ews4800mips/conf/RAMDISK	Sun Mar 20 17:32:19 2011
@@ -1,4 +1,4 @@
-# 	$NetBSD: RAMDISK,v 1.14 2011/03/06 17:08:24 bouyer Exp $
+# 	$NetBSD: RAMDISK,v 1.15 2011/03/20 17:32:19 tsutsui Exp $
 #
 # kernel config file with memory disk for installation
 #
@@ -33,6 +33,9 @@
 no options	COMPAT_14
 no options	COMPAT_15
 no options	COMPAT_16
+no options	COMPAT_20
+no options	COMPAT_30
+no options	COMPAT_43
 
 no file-system	EXT2FS
 no file-system	LFS
@@ -41,9 +44,11 @@
 no file-system	NULLFS
 no file-system	OVERLAY
 no file-system	PUFFS
+no file-system	PROCFS
 no file-system	UMAPFS
 no file-system	UNION
 no file-system	PTYFS
+no file-system	TMPFS
 
 no options 	QUOTA
 no options 	QUOTA2
@@ -60,6 +65,7 @@
 no ss*	at scsibus?
 no uk*	at scsibus?
 
+no pseudo-device	ccd
 no pseudo-device	raid
 no pseudo-device	vnd
 no pseudo-device	fss



CVS commit: src/sys/dev/usb

2011-03-20 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Mar 20 17:38:11 UTC 2011

Modified Files:
src/sys/dev/usb: usb_mem.c usb_subr.c

Log Message:
Move MALLOC_DEFINE()s from usb_mem.c to usb_subr.c.
usb_mem.c provides functions for DMA memory allocation
that is required by DMA capable host controllers only,
but MALLOC_DEFINE() isn't DMA specific and could be required
by any USB drivers.

Discussed on current-users.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/dev/usb/usb_mem.c
cvs rdiff -u -r1.177 -r1.178 src/sys/dev/usb/usb_subr.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/usb/usb_mem.c
diff -u src/sys/dev/usb/usb_mem.c:1.45 src/sys/dev/usb/usb_mem.c:1.46
--- src/sys/dev/usb/usb_mem.c:1.45	Tue Jan  4 01:37:55 2011
+++ src/sys/dev/usb/usb_mem.c	Sun Mar 20 17:38:11 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_mem.c,v 1.45 2011/01/04 01:37:55 matt Exp $	*/
+/*	$NetBSD: usb_mem.c,v 1.46 2011/03/20 17:38:11 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: usb_mem.c,v 1.45 2011/01/04 01:37:55 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: usb_mem.c,v 1.46 2011/03/20 17:38:11 tsutsui Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_usb.h
@@ -75,10 +75,6 @@
 #define DPRINTFN(n,x)
 #endif
 
-MALLOC_DEFINE(M_USB, USB, USB misc. memory);
-MALLOC_DEFINE(M_USBDEV, USB device, USB device driver);
-MALLOC_DEFINE(M_USBHC, USB HC, USB host controller);
-
 #define USB_MEM_SMALL 64
 #define USB_MEM_CHUNKS 64
 #define USB_MEM_BLOCK (USB_MEM_SMALL * USB_MEM_CHUNKS)

Index: src/sys/dev/usb/usb_subr.c
diff -u src/sys/dev/usb/usb_subr.c:1.177 src/sys/dev/usb/usb_subr.c:1.178
--- src/sys/dev/usb/usb_subr.c:1.177	Wed Nov  3 22:34:24 2010
+++ src/sys/dev/usb/usb_subr.c	Sun Mar 20 17:38:11 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_subr.c,v 1.177 2010/11/03 22:34:24 dyoung Exp $	*/
+/*	$NetBSD: usb_subr.c,v 1.178 2011/03/20 17:38:11 tsutsui Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: usb_subr.c,v 1.177 2010/11/03 22:34:24 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: usb_subr.c,v 1.178 2011/03/20 17:38:11 tsutsui Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_usbverbose.h
@@ -68,6 +68,10 @@
 #define DPRINTFN(n,x)
 #endif
 
+MALLOC_DEFINE(M_USB, USB, USB misc. memory);
+MALLOC_DEFINE(M_USBDEV, USB device, USB device driver);
+MALLOC_DEFINE(M_USBHC, USB HC, USB host controller);
+
 Static usbd_status usbd_set_config(usbd_device_handle, int);
 Static void usbd_devinfo(usbd_device_handle, int, char *, size_t);
 Static void usbd_devinfo_vp(usbd_device_handle, char *, size_t, char *, size_t,



CVS commit: src/sys

2011-03-20 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Mar 20 17:54:03 UTC 2011

Modified Files:
src/sys/conf: files
src/sys/dev/usb: files.usb

Log Message:
Add usb_dma attribute for DMA capable USB host controllers
and specify that usb_dma attribute to dev/usb/usb_mem.c.

usb_mem.c uses bus_dma(9) for DMA memory allocation,
but non-DMA capable USB host controllers like slhci(4)
doesn't need them at all, and some ports don't bother to
prepare MD bus_dma(9) implementation (yet).

Discussed on current-users
 http://mail-index.NetBSD.org/current-users/2011/03/13/msg015995.html
and usb_dma attribute is suggested by bouyer@.
Tested by kiyohara@ on mmeye with slhci at pcmcia.


To generate a diff of this commit:
cvs rdiff -u -r1.1004 -r1.1005 src/sys/conf/files
cvs rdiff -u -r1.104 -r1.105 src/sys/dev/usb/files.usb

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

Modified files:

Index: src/sys/conf/files
diff -u src/sys/conf/files:1.1004 src/sys/conf/files:1.1005
--- src/sys/conf/files:1.1004	Sun Mar  6 17:08:35 2011
+++ src/sys/conf/files	Sun Mar 20 17:54:02 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files,v 1.1004 2011/03/06 17:08:35 bouyer Exp $
+#	$NetBSD: files,v 1.1005 2011/03/20 17:54:02 tsutsui Exp $
 #	@(#)files.newconf	7.5 (Berkeley) 5/10/93
 
 version 	20100430
@@ -1117,7 +1117,7 @@
 
 # STI (hp graphics)
 device	sti: wsemuldisplaydev
-file	dev/ic/sti.c		sti  (sti_pci | sti_gedoens)
+file	dev/ic/sti.c		sti
 
 include dev/wscons/files.wscons
 include dev/rasops/files.rasops
@@ -1153,17 +1153,19 @@
 define	usbroothub
 file	dev/usb/usbroothub_subr.c	usbroothub
 
-device	uhci: usbus, usbroothub
+define	usb_dma
+
+device	uhci: usbus, usbroothub, usb_dma
 file	dev/usb/uhci.c			uhci			needs-flag
 
 # OHCI USB controller
 #
-device	ohci: usbus, usbroothub
+device	ohci: usbus, usbroothub, usb_dma
 file	dev/usb/ohci.c			ohci			needs-flag
 
 # EHCI USB controller
 #
-device	ehci: usbus, usbroothub
+device	ehci: usbus, usbroothub, usb_dma
 file	dev/usb/ehci.c			ehci			needs-flag
 
 # SL811HS/T USB controller

Index: src/sys/dev/usb/files.usb
diff -u src/sys/dev/usb/files.usb:1.104 src/sys/dev/usb/files.usb:1.105
--- src/sys/dev/usb/files.usb:1.104	Mon Dec 27 20:42:51 2010
+++ src/sys/dev/usb/files.usb	Sun Mar 20 17:54:03 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files.usb,v 1.104 2010/12/27 20:42:51 jmcneill Exp $
+#	$NetBSD: files.usb,v 1.105 2011/03/20 17:54:03 tsutsui Exp $
 #
 # Config file and device description for machine-independent USB code.
 # Included by ports that need it.  Ports that use it must provide
@@ -20,7 +20,7 @@
 file	dev/usb/usb.c			usb			needs-flag
 file	dev/usb/usbdi.c			usb
 file	dev/usb/usbdi_util.c		usb
-file	dev/usb/usb_mem.c		usb
+file	dev/usb/usb_mem.c		usb  usb_dma
 file	dev/usb/usb_subr.c		usb
 file	dev/usb/usb_quirks.c		usb
 file	dev/usb/usb_verbose.c		usb  usbverbose



CVS commit: src/usr.sbin/btdevctl

2011-03-20 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Sun Mar 20 19:46:13 UTC 2011

Modified Files:
src/usr.sbin/btdevctl: btdevctl.c sdp.c

Log Message:
provide more informative error messages


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/btdevctl/btdevctl.c \
src/usr.sbin/btdevctl/sdp.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.sbin/btdevctl/btdevctl.c
diff -u src/usr.sbin/btdevctl/btdevctl.c:1.8 src/usr.sbin/btdevctl/btdevctl.c:1.9
--- src/usr.sbin/btdevctl/btdevctl.c:1.8	Tue May 12 18:39:20 2009
+++ src/usr.sbin/btdevctl/btdevctl.c	Sun Mar 20 19:46:13 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: btdevctl.c,v 1.8 2009/05/12 18:39:20 plunky Exp $	*/
+/*	$NetBSD: btdevctl.c,v 1.9 2011/03/20 19:46:13 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -35,7 +35,7 @@
 __COPYRIGHT(@(#) Copyright (c) 2006 The NetBSD Foundation, Inc.\
   @(#) Copyright (c) 2006 Itronix, Inc.\
   All rights reserved.);
-__RCSID($NetBSD: btdevctl.c,v 1.8 2009/05/12 18:39:20 plunky Exp $);
+__RCSID($NetBSD: btdevctl.c,v 1.9 2011/03/20 19:46:13 plunky Exp $);
 
 #include prop/proplib.h
 #include sys/ioctl.h
@@ -158,9 +158,6 @@
 			printf(Performing SDP query for service '%s'..\n, service);
 
 		dev = cfg_query(laddr, raddr, service);
-		if (dev == NULL)
-			errx(EXIT_FAILURE, %s/%s not found, bt_ntoa(raddr, NULL), service);
-
 		set = true;
 	}
 
Index: src/usr.sbin/btdevctl/sdp.c
diff -u src/usr.sbin/btdevctl/sdp.c:1.8 src/usr.sbin/btdevctl/sdp.c:1.9
--- src/usr.sbin/btdevctl/sdp.c:1.8	Wed Apr 28 06:18:07 2010
+++ src/usr.sbin/btdevctl/sdp.c	Sun Mar 20 19:46:13 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdp.c,v 1.8 2010/04/28 06:18:07 plunky Exp $	*/
+/*	$NetBSD: sdp.c,v 1.9 2011/03/20 19:46:13 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -56,7 +56,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: sdp.c,v 1.8 2010/04/28 06:18:07 plunky Exp $);
+__RCSID($NetBSD: sdp.c,v 1.9 2011/03/20 19:46:13 plunky Exp $);
 
 #include sys/types.h
 
@@ -180,26 +180,22 @@
 	prop_dictionary_t dict;
 	sdp_session_t ss;
 	size_t i;
-	bool rv;
 
 	dict = prop_dictionary_create();
 	if (dict == NULL)
-		return NULL;
+		err(EXIT_FAILURE, prop_dictionary_create());
 
 	for (i = 0; i  __arraycount(cfgtype); i++) {
 		if (strcasecmp(service, cfgtype[i].name) == 0) {
 			ss = sdp_open(laddr, raddr);
-			if (ss != NULL) {
-rv = cfg_search(ss, i, dict);
+			if (ss == NULL)
+err(EXIT_FAILURE, SDP connection failed);
 
-sdp_close(ss);
+			if (!cfg_search(ss, i, dict))
+errx(EXIT_FAILURE, service %s not found, service);
 
-if (rv == true)
-	return dict;
-			}
-
-			prop_object_release(dict);
-			return NULL;
+			sdp_close(ss);
+			return dict;
 		}
 	}
 



CVS commit: [netbsd-4] src/sys/kern

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 20:36:57 UTC 2011

Modified Files:
src/sys/kern [netbsd-4]: vfs_syscalls.c

Log Message:
Pull up following revision(s) (requested by dholland in ticket #1417):
sys/kern/vfs_syscalls.c: revision 1.415 via patch
Check for bogus flags to access() up front. Otherwise we end up
calling VOP_ACCESS with flags 0 and something asserts deep in the
bowels of kauth. PR 44648 from Taylor Campbell. (I moved the check
earlier relative to the suggested patch.)
Pullup candidate.


To generate a diff of this commit:
cvs rdiff -u -r1.279.2.5 -r1.279.2.6 src/sys/kern/vfs_syscalls.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/kern/vfs_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.279.2.5 src/sys/kern/vfs_syscalls.c:1.279.2.6
--- src/sys/kern/vfs_syscalls.c:1.279.2.5	Wed Feb 28 22:47:44 2007
+++ src/sys/kern/vfs_syscalls.c	Sun Mar 20 20:36:56 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls.c,v 1.279.2.5 2007/02/28 22:47:44 pavel Exp $	*/
+/*	$NetBSD: vfs_syscalls.c,v 1.279.2.6 2011/03/20 20:36:56 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: vfs_syscalls.c,v 1.279.2.5 2007/02/28 22:47:44 pavel Exp $);
+__KERNEL_RCSID(0, $NetBSD: vfs_syscalls.c,v 1.279.2.6 2011/03/20 20:36:56 bouyer Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_compat_43.h
@@ -2373,6 +2373,11 @@
 	int error, flags;
 	struct nameidata nd;
 
+	if ((SCARG(uap, flags)  ~(R_OK | W_OK | X_OK)) != 0) {
+		/* nonsense flags */
+		return EINVAL;
+	}
+
 	cred = kauth_cred_dup(l-l_cred);
 	kauth_cred_seteuid(cred, kauth_cred_getuid(l-l_cred));
 	kauth_cred_setegid(cred, kauth_cred_getgid(l-l_cred));



CVS commit: [netbsd-4-0] src/sys/kern

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 20:37:27 UTC 2011

Modified Files:
src/sys/kern [netbsd-4-0]: vfs_syscalls.c

Log Message:
Pull up following revision(s) (requested by dholland in ticket #1417):
sys/kern/vfs_syscalls.c: revision 1.415 via patch
Check for bogus flags to access() up front. Otherwise we end up
calling VOP_ACCESS with flags 0 and something asserts deep in the
bowels of kauth. PR 44648 from Taylor Campbell. (I moved the check
earlier relative to the suggested patch.)
Pullup candidate.


To generate a diff of this commit:
cvs rdiff -u -r1.279.2.5 -r1.279.2.5.6.1 src/sys/kern/vfs_syscalls.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/kern/vfs_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.279.2.5 src/sys/kern/vfs_syscalls.c:1.279.2.5.6.1
--- src/sys/kern/vfs_syscalls.c:1.279.2.5	Wed Feb 28 22:47:44 2007
+++ src/sys/kern/vfs_syscalls.c	Sun Mar 20 20:37:27 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls.c,v 1.279.2.5 2007/02/28 22:47:44 pavel Exp $	*/
+/*	$NetBSD: vfs_syscalls.c,v 1.279.2.5.6.1 2011/03/20 20:37:27 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: vfs_syscalls.c,v 1.279.2.5 2007/02/28 22:47:44 pavel Exp $);
+__KERNEL_RCSID(0, $NetBSD: vfs_syscalls.c,v 1.279.2.5.6.1 2011/03/20 20:37:27 bouyer Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_compat_43.h
@@ -2373,6 +2373,11 @@
 	int error, flags;
 	struct nameidata nd;
 
+	if ((SCARG(uap, flags)  ~(R_OK | W_OK | X_OK)) != 0) {
+		/* nonsense flags */
+		return EINVAL;
+	}
+
 	cred = kauth_cred_dup(l-l_cred);
 	kauth_cred_seteuid(cred, kauth_cred_getuid(l-l_cred));
 	kauth_cred_setegid(cred, kauth_cred_getgid(l-l_cred));



CVS commit: [netbsd-4] src/lib/libc/inet

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 20:38:19 UTC 2011

Modified Files:
src/lib/libc/inet [netbsd-4]: inet_net_pton.c

Log Message:
Pull up following revision(s) (requested by spz in ticket #1418):
lib/libc/inet/inet_net_pton.c: revision 1.2
Check bits on each loop to prevent integer oveflow.
Reported by Maksymilian Arciemowicz


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.1.10.1 src/lib/libc/inet/inet_net_pton.c

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/inet/inet_net_pton.c
diff -u src/lib/libc/inet/inet_net_pton.c:1.1 src/lib/libc/inet/inet_net_pton.c:1.1.10.1
--- src/lib/libc/inet/inet_net_pton.c:1.1	Thu May 20 23:13:02 2004
+++ src/lib/libc/inet/inet_net_pton.c	Sun Mar 20 20:38:19 2011
@@ -20,7 +20,7 @@
 #if 0
 static const char rcsid[] = Id: inet_net_pton.c,v 1.4.2.1 2002/08/02 02:17:21 marka Exp ;
 #else
-__RCSID($NetBSD: inet_net_pton.c,v 1.1 2004/05/20 23:13:02 christos Exp $);
+__RCSID($NetBSD: inet_net_pton.c,v 1.1.10.1 2011/03/20 20:38:19 bouyer Exp $);
 #endif
 #endif
 
@@ -145,12 +145,12 @@
 			INSIST(n = 0  n = 9);
 			bits *= 10;
 			bits += n;
+			if (bits  32)
+goto emsgsize;
 		} while ((ch = *src++) != '\0'  isascii((u_char)ch)
 		 isdigit((u_char)ch));
 		if (ch != '\0')
 			goto enoent;
-		if (bits  32)
-			goto emsgsize;
 	}
 
 	/* Firey death and destruction unless we prefetched EOS. */



CVS commit: [netbsd-4-0] src/lib/libc/inet

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 20:38:23 UTC 2011

Modified Files:
src/lib/libc/inet [netbsd-4-0]: inet_net_pton.c

Log Message:
Pull up following revision(s) (requested by spz in ticket #1418):
lib/libc/inet/inet_net_pton.c: revision 1.2
Check bits on each loop to prevent integer oveflow.
Reported by Maksymilian Arciemowicz


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.1.20.1 src/lib/libc/inet/inet_net_pton.c

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/inet/inet_net_pton.c
diff -u src/lib/libc/inet/inet_net_pton.c:1.1 src/lib/libc/inet/inet_net_pton.c:1.1.20.1
--- src/lib/libc/inet/inet_net_pton.c:1.1	Thu May 20 23:13:02 2004
+++ src/lib/libc/inet/inet_net_pton.c	Sun Mar 20 20:38:23 2011
@@ -20,7 +20,7 @@
 #if 0
 static const char rcsid[] = Id: inet_net_pton.c,v 1.4.2.1 2002/08/02 02:17:21 marka Exp ;
 #else
-__RCSID($NetBSD: inet_net_pton.c,v 1.1 2004/05/20 23:13:02 christos Exp $);
+__RCSID($NetBSD: inet_net_pton.c,v 1.1.20.1 2011/03/20 20:38:23 bouyer Exp $);
 #endif
 #endif
 
@@ -145,12 +145,12 @@
 			INSIST(n = 0  n = 9);
 			bits *= 10;
 			bits += n;
+			if (bits  32)
+goto emsgsize;
 		} while ((ch = *src++) != '\0'  isascii((u_char)ch)
 		 isdigit((u_char)ch));
 		if (ch != '\0')
 			goto enoent;
-		if (bits  32)
-			goto emsgsize;
 	}
 
 	/* Firey death and destruction unless we prefetched EOS. */



CVS commit: src/sys/arch/sparc64/dev

2011-03-20 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Mar 20 20:40:22 UTC 2011

Modified Files:
src/sys/arch/sparc64/dev: pci_machdep.c

Log Message:
remove unnecessary iommuvar.h and psycho{reg,var}.h includes.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/arch/sparc64/dev/pci_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/sparc64/dev/pci_machdep.c
diff -u src/sys/arch/sparc64/dev/pci_machdep.c:1.69 src/sys/arch/sparc64/dev/pci_machdep.c:1.70
--- src/sys/arch/sparc64/dev/pci_machdep.c:1.69	Wed Mar 16 03:54:51 2011
+++ src/sys/arch/sparc64/dev/pci_machdep.c	Sun Mar 20 20:40:22 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.69 2011/03/16 03:54:51 mrg Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.70 2011/03/20 20:40:22 mrg Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.69 2011/03/16 03:54:51 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.70 2011/03/20 20:40:22 mrg Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -51,9 +51,6 @@
 #include dev/ofw/ofw_pci.h
 
 #include sparc64/dev/iommureg.h
-#include sparc64/dev/iommuvar.h
-#include sparc64/dev/psychoreg.h
-#include sparc64/dev/psychovar.h
 #include sparc64/sparc64/cache.h
 
 #include locators.h



CVS commit: src/sys/arch/sparc64/dev

2011-03-20 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Mar 20 20:43:34 UTC 2011

Modified Files:
src/sys/arch/sparc64/dev: schizo.c schizoreg.h

Log Message:
enable the tomatillo iocache.
garbage collect struct iommureg_schizo and use struct iommureg2.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sparc64/dev/schizo.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sparc64/dev/schizoreg.h

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/dev/schizo.c
diff -u src/sys/arch/sparc64/dev/schizo.c:1.17 src/sys/arch/sparc64/dev/schizo.c:1.18
--- src/sys/arch/sparc64/dev/schizo.c:1.17	Sun Jan  2 10:43:18 2011
+++ src/sys/arch/sparc64/dev/schizo.c	Sun Mar 20 20:43:34 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: schizo.c,v 1.17 2011/01/02 10:43:18 mrg Exp $	*/
+/*	$NetBSD: schizo.c,v 1.18 2011/03/20 20:43:34 mrg Exp $	*/
 /*	$OpenBSD: schizo.c,v 1.55 2008/08/18 20:29:37 brad Exp $	*/
 
 /*
@@ -299,21 +299,20 @@
 	schizo_set_intr(sc, pbm, PIL_HIGH, schizo_safari_error, sc,
 	SCZ_SERR_INO, safari);
 
-#if 0
 	if (sc-sc_tomatillo) {
 		/*
-		 * We should enable the IOCACHE here.
+		 * Enable the IOCACHE.
 		 */
 		uint64_t iocache_csr;
-		char bits[128];
 
-		iocache_csr = schizo_pbm_read(pbm, SCZ_PCI_IOCACHE_CSR);
+		iocache_csr = TOM_IOCACHE_CSR_WRT_PEN |
+			  (1  TOM_IOCACHE_CSR_POFFSET_SHIFT) |
+			  TOM_IOCACHE_CSR_PEN_RDM |
+			  TOM_IOCACHE_CSR_PEN_ONE |
+			  TOM_IOCACHE_CSR_PEN_LINE;
 
-		snprintb(bits, sizeof(bits), TOM_IOCACHE_CSR_BITS, iocache_csr);
-		printf(IOCACHE_CSR=%s\n, bits);
-		printf(IOCACHE_CSR=% PRIx64 \n, iocache_csr);
+		schizo_pbm_write(pbm, SCZ_PCI_IOCACHE_CSR, iocache_csr);
 	}
-#endif
 
 	config_found(sc-sc_dv, pba, schizo_print);
 }
@@ -424,7 +423,7 @@
 	is-is_bustag = pbm-sp_regt;
 	bus_space_subregion(is-is_bustag, pbm-sp_regh,
 		offsetof(struct schizo_pbm_regs, iommu),
-		sizeof(struct schizo_iommureg),
+		sizeof(struct iommureg2),
 		is-is_iommu);
 
 	/*

Index: src/sys/arch/sparc64/dev/schizoreg.h
diff -u src/sys/arch/sparc64/dev/schizoreg.h:1.7 src/sys/arch/sparc64/dev/schizoreg.h:1.8
--- src/sys/arch/sparc64/dev/schizoreg.h:1.7	Sun Jan  2 10:43:18 2011
+++ src/sys/arch/sparc64/dev/schizoreg.h	Sun Mar 20 20:43:34 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: schizoreg.h,v 1.7 2011/01/02 10:43:18 mrg Exp $	*/
+/*	$NetBSD: schizoreg.h,v 1.8 2011/03/20 20:43:34 mrg Exp $	*/
 /*	$OpenBSD: schizoreg.h,v 1.20 2008/07/12 13:08:04 kettenis Exp $	*/
 
 /*
@@ -28,22 +28,9 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-/* XXX merge with iommureg.h */
-/* iommmu registers */
-struct schizo_iommureg {
-	volatile u_int64_t	iommu_cr;	/* IOMMU control register */
-	volatile u_int64_t	iommu_tsb;	/* IOMMU TSB base register */
-	volatile u_int64_t	iommu_flush;	/* IOMMU flush register */
-	volatile u_int64_t	iommu_ctxflush;
-	volatile u_int64_t	iommu_reserved[28];
-	volatile u_int64_t	iommu_cache_flush;
-	volatile u_int64_t	iommu_cache_invalidate;
-	volatile u_int64_t	iommu_reserved2[30];
-};
-
 struct schizo_pbm_regs {
 	volatile u_int64_t	_unused1[64];		/* 0x - 0x01ff */
-	struct schizo_iommureg	iommu;			/* 0x0200 - 0x03ff */
+	struct iommureg2	iommu;			/* 0x0200 - 0x03ff */
 	volatile u_int64_t	_unused2[384];
 	volatile u_int64_t	imap[64];
 	volatile u_int64_t	_unused3[64];
@@ -260,6 +247,7 @@
 #define	TOM_IOCACHE_CSR_NCP_RDM		(1UL  18UL)	/* memory read multiple (NC) */
 #define	TOM_IOCACHE_CSR_NCP_ONE		(1UL  17UL)	/* memory read (NC) */
 #define	TOM_IOCACHE_CSR_NCP_LINE	(1UL  16UL)	/* memory read line (NC) */
+#define	TOM_IOCACHE_CSR_POFFSET_SHIFT	(1UL  3UL)	/* prefetch offset */
 #define	TOM_IOCACHE_CSR_PEN_RDM		(1UL  2UL)	/* memory read multiple */
 #define	TOM_IOCACHE_CSR_PEN_ONE		(1UL  1UL)	/* memory read */
 #define	TOM_IOCACHE_CSR_PEN_LINE	(1UL  0UL)	/* memory read line */



CVS commit: src/sys/arch/sparc64/dev

2011-03-20 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Mar 20 20:47:10 UTC 2011

Modified Files:
src/sys/arch/sparc64/dev: iommuvar.h

Log Message:
add a new is_flags member to strut iommu_state.  add two flags:
IOMMU_FLUSH_CACHE - extra flushes needed for some pyro
IOMMU_TSBSIZE_IN_PTSB - different ptsb assignment for pyro

partly from openbsd.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sparc64/dev/iommuvar.h

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/dev/iommuvar.h
diff -u src/sys/arch/sparc64/dev/iommuvar.h:1.19 src/sys/arch/sparc64/dev/iommuvar.h:1.20
--- src/sys/arch/sparc64/dev/iommuvar.h:1.19	Wed Mar 16 05:49:43 2011
+++ src/sys/arch/sparc64/dev/iommuvar.h	Sun Mar 20 20:47:10 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: iommuvar.h,v 1.19 2011/03/16 05:49:43 mrg Exp $	*/
+/*	$NetBSD: iommuvar.h,v 1.20 2011/03/20 20:47:10 mrg Exp $	*/
 
 /*
  * Copyright (c) 1999 Matthew R. Green
@@ -55,6 +55,9 @@
 	u_int			is_dvmaend;
 	int64_t			is_cr;		/* IOMMU control regiter value */
 	struct extent		*is_dvmamap;	/* DVMA map for this instance */
+	int			is_flags;
+#define IOMMU_FLUSH_CACHE	0x0001
+#define IOMMU_TSBSIZE_IN_PTSB	0x0002	/* PCIe */
 
 	struct strbuf_ctl	*is_sb[2];	/* Streaming buffers if any */
 



CVS commit: src/sys/arch/sparc64/dev

2011-03-20 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Mar 20 20:48:36 UTC 2011

Modified Files:
src/sys/arch/sparc64/dev: pyro.c

Log Message:
remove pyro_xir().  we don't have the MD support for it (yet?).
clean up some debug code.  clean up the DPRINTF() code, and expand
the interrupt mapping debug code to match schizo and psycho.
set IOMMU_TSBSIZE_IN_PTSB, and if oberon, IOMMU_FLUSH_CACHE.
disable the STC explicitly.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc64/dev/pyro.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/dev/pyro.c
diff -u src/sys/arch/sparc64/dev/pyro.c:1.2 src/sys/arch/sparc64/dev/pyro.c:1.3
--- src/sys/arch/sparc64/dev/pyro.c:1.2	Tue Mar 15 11:42:03 2011
+++ src/sys/arch/sparc64/dev/pyro.c	Sun Mar 20 20:48:36 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pyro.c,v 1.2 2011/03/15 11:42:03 mrg Exp $	*/
+/*	$NetBSD: pyro.c,v 1.3 2011/03/20 20:48:36 mrg Exp $	*/
 /*	from: $OpenBSD: pyro.c,v 1.20 2010/12/05 15:15:14 kettenis Exp $	*/
 
 /*
@@ -118,12 +118,6 @@
 int pyro_dmamap_create(bus_dma_tag_t, bus_size_t, int,
 bus_size_t, bus_size_t, int, bus_dmamap_t *);
 
-#if 0
-#ifdef DDB
-void pyro_xir(void *, int);
-#endif
-#endif
-
 int
 pyro_match(struct device *parent, struct cfdata *match, void *aux)
 {
@@ -219,7 +213,6 @@
 
 	if (bus_space_map(pbm-pp_cfgt, 0, 0x1000, 0, pbm-pp_cfgh))
 		panic(pyro: can't map config space);
-printf(cfgh: _ptr %p _asi %x _sasi %x\n, (void *)pbm-pp_cfgh._ptr, pbm-pp_cfgh._asi, pbm-pp_cfgh._sasi);
 
 	pbm-pp_pc = pyro_alloc_chipset(pbm, sc-sc_node, _sparc_pci_chipset);
 	pbm-pp_pc-spc_busmax = busranges[1];
@@ -244,12 +237,6 @@
 
 	free(busranges, M_DEVBUF);
 
-#if 0
-#ifdef DDB 
-	db_register_xir(pyro_xir, sc);
-#endif
-#endif
-
 	config_found(sc-sc_dv, pba, pyro_print);
 }
 
@@ -269,16 +256,17 @@
 		panic(pyro: unable to create iommu handle);
 	}
 
-#if 0
-	is-is_sb[0] = pbm-pp_sb;
-	is-is_sb[0]-sb_bustag = is-is_bustag;
-#endif
+	/* We have no STC.  */
+	is-is_sb[0] = NULL;
 
 	name = (char *)malloc(32, M_DEVBUF, M_NOWAIT);
 	if (name == NULL)
 		panic(couldn't malloc iommu name);
 	snprintf(name, 32, %s dvma, sc-sc_dv.dv_xname);
 
+	/* Tell iommu how to set the TSB size.  */
+	is-is_flags = IOMMU_TSBSIZE_IN_PTSB;
+
 	/* On Oberon, we need to flush the cache. */
 	if (sc-sc_oberon)
 		is-is_flags |= IOMMU_FLUSH_CACHE;
@@ -294,14 +282,6 @@
 	return (QUIET);
 }
 
-#if 0	/* XXXMRG */
-int
-pyro_conf_size(pci_chipset_tag_t pc, pcitag_t tag)
-{
-	return PCIE_CONFIG_SPACE_SIZE;
-}
-#endif
-
 pcireg_t
 pyro_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg)
 {
@@ -347,7 +327,7 @@
 
 	if (*ihp != (pci_intr_handle_t)-1) {
 		*ihp |= sc-sc_ign;
-		DPRINTF(PDB_INTR, (%s: not -1 - ih %lx, __func__, (u_long)*ihp));
+		DPRINTF(PDB_INTR, (%s: not -1 - ih %lx\n, __func__, (u_long)*ihp));
 		return (0);
 	}
 
@@ -359,7 +339,7 @@
 	 */
 
 	if (pa-pa_intrpin == 0) {
-		DPRINTF(PDB_INTR, (%s: no intrpen, __func__));
+		DPRINTF(PDB_INTR, (%s: no intrpen\n, __func__));
 		return (-1);
 	}
 
@@ -373,7 +353,7 @@
 	*ihp |= (dev  2)  INTMAP_PCISLOT;
 	*ihp |= sc-sc_ign;
 
-	DPRINTF(PDB_INTR, (%s: weird hack - ih %lx, __func__, (u_long)*ihp));
+	DPRINTF(PDB_INTR, (%s: weird hack - ih %lx\n, __func__, (u_long)*ihp));
 	return (0);
 }
 
@@ -561,7 +541,7 @@
 	struct pyro_softc *sc = pbm-pp_sc;
 	struct intrhand *ih = NULL;
 	volatile u_int64_t *intrmapptr = NULL, *intrclrptr = NULL;
-	u_int64_t *imap, *iclr;
+	u_int64_t *imapbase, *iclrbase;
 	int ino;
 
 	ino = INTINO(ihandle);
@@ -574,11 +554,11 @@
 		level = 2;
 	}
 
-	imap = (uint64_t *)((uintptr_t)bus_space_vaddr(sc-sc_bustag, sc-sc_csrh) + 0x1000);
-	iclr = (uint64_t *)((uintptr_t)bus_space_vaddr(sc-sc_bustag, sc-sc_csrh) + 0x1400);
-	intrmapptr = imap[ino];
-	intrclrptr = iclr[ino];
-	DPRINTF(PDB_INTR, ( imap %p iclr %p mapptr %p clrptr %p, imap, iclr, intrmapptr, intrclrptr));
+	imapbase = (uint64_t *)((uintptr_t)bus_space_vaddr(sc-sc_bustag, sc-sc_csrh) + 0x1000);
+	iclrbase = (uint64_t *)((uintptr_t)bus_space_vaddr(sc-sc_bustag, sc-sc_csrh) + 0x1400);
+	intrmapptr = imapbase[ino];
+	intrclrptr = iclrbase[ino];
+	DPRINTF(PDB_INTR, ( imapbase %p iclrbase %p mapptr %p clrptr %p\n, imapbase, iclrbase, intrmapptr, intrclrptr));
 	ino |= INTVEC(ihandle);
 
 	ih = malloc(sizeof *ih, M_DEVBUF, M_NOWAIT);
@@ -597,30 +577,38 @@
 	intr_establish(ih-ih_pil, level != IPL_VM, ih);
 
 	if (intrmapptr != NULL) {
-		u_int64_t ival;
+		u_int64_t imap;
 
-		ival = *intrmapptr;
-		ival = ~FIRE_INTRMAP_INT_CNTRL_NUM_MASK;
-		ival |= FIRE_INTRMAP_INT_CNTRL_NUM0;
+		imap = *intrmapptr;
+		DPRINTF(PDB_INTR, (%s: read intrmap = %016qx, __func__,
+			(unsigned long long)imap));
+		imap = ~FIRE_INTRMAP_INT_CNTRL_NUM_MASK;
+		imap |= FIRE_INTRMAP_INT_CNTRL_NUM0;
+		DPRINTF(PDB_INTR, (; set intr group intrmap = %016qx,
+			(unsigned long long)imap));
 		if (sc-sc_oberon) {
-			ival = 

CVS commit: src/tools/compat

2011-03-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 20 20:48:57 UTC 2011

Added Files:
src/tools/compat: getline.c

Log Message:
add a stdio neutral getline/getdelim implementation.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tools/compat/getline.c

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

Added files:

Index: src/tools/compat/getline.c
diff -u /dev/null src/tools/compat/getline.c:1.1
--- /dev/null	Sun Mar 20 16:48:57 2011
+++ src/tools/compat/getline.c	Sun Mar 20 16:48:57 2011
@@ -0,0 +1,107 @@
+/*	$NetBSD: getline.c,v 1.1 2011/03/20 20:48:57 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_NBTOOL_CONFIG_H
+#include nbtool_config.h
+#endif
+
+#if !HAVE_GETLINE
+#include stdlib.h
+
+#ifndef HAVE_NBTOOL_CONFIG_H
+/* These headers are required, but included from nbtool_config.h */
+#include stdio.h
+#include unistd.h
+#include errno.h
+#include string.h
+#endif
+
+ssize_t
+getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
+{
+	char *ptr, *eptr;
+
+
+	if (*buf == NULL || *bufsiz == 0) {
+		*bufsiz = BUFSIZ;
+		if ((*buf = malloc(*bufsiz)) == NULL)
+			return -1;
+	}
+
+	for (ptr = *buf, eptr = *buf + *bufsiz;;) {
+		int c = fgetc(fp);
+		if (c == -1) {
+			if (feof(fp))
+return ptr == *buf ? -1 : ptr - *buf;
+			else
+return -1;
+		}
+		*ptr++ = c;
+		if (c == delimiter) {
+			*ptr = '\0';
+			return ptr - *buf;
+		}
+		if (ptr + 2 = eptr) {
+			char *nbuf;
+			size_t nbufsiz = *bufsiz * 2;
+			ssize_t d = ptr - *buf;
+			if ((nbuf = realloc(*buf, nbufsiz)) == NULL)
+return -1;
+			*buf = nbuf;
+			*bufsiz = nbufsiz;
+			eptr = nbuf + nbufsiz;
+			ptr = nbuf + d;
+		}
+	}
+}
+
+ssize_t
+getline(char **buf, size_t *bufsiz, FILE *fp)
+{
+	return getdelim(buf, bufsiz, '\n', fp);
+}
+
+#endif
+
+#ifdef TEST
+int
+main(int argc, char *argv[])
+{
+	char *p = NULL;
+	ssize_t len;
+	size_t n = 0;
+
+	while ((len = getline(p, n, stdin)) != -1)
+		(void)printf(%zd %s, len, p);
+	free(p);
+	return 0;
+}
+#endif



CVS commit: [netbsd-4] src/sys/kern

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 20:51:52 UTC 2011

Modified Files:
src/sys/kern [netbsd-4]: kern_exec.c

Log Message:
Pull up following revision(s) (requested by spz in ticket #1421):
sys/kern/kern_exec.c: revision 1.269 via patch
Check for number of processes resource violation in execve().


To generate a diff of this commit:
cvs rdiff -u -r1.232.2.3 -r1.232.2.4 src/sys/kern/kern_exec.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/kern/kern_exec.c
diff -u src/sys/kern/kern_exec.c:1.232.2.3 src/sys/kern/kern_exec.c:1.232.2.4
--- src/sys/kern/kern_exec.c:1.232.2.3	Sat Sep  5 13:45:43 2009
+++ src/sys/kern/kern_exec.c	Sun Mar 20 20:51:52 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exec.c,v 1.232.2.3 2009/09/05 13:45:43 bouyer Exp $	*/
+/*	$NetBSD: kern_exec.c,v 1.232.2.4 2011/03/20 20:51:52 bouyer Exp $	*/
 
 /*-
  * Copyright (C) 1993, 1994, 1996 Christopher G. Demetriou
@@ -33,7 +33,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kern_exec.c,v 1.232.2.3 2009/09/05 13:45:43 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: kern_exec.c,v 1.232.2.4 2011/03/20 20:51:52 bouyer Exp $);
 
 #include opt_ktrace.h
 #include opt_syscall_debug.h
@@ -428,18 +428,40 @@
 	int			szsigcode;
 	struct exec_vmcmd	*base_vcp;
 	int			oldlwpflags;
+	uid_t			uid;
 #ifdef SYSTRACE
 	int			wassugid = ISSET(p-p_flag, P_SUGID);
 	char			pathbuf[MAXPATHLEN];
 	size_t			pathbuflen;
 #endif /* SYSTRACE */
 
+	p = l-l_proc;
+
+	/*
+	 * Check if we have exceeded our number of processes limit.
+	 * This is so that we handle the case where a root daemon
+	 * forked, ran setuid to become the desired user and is trying
+	 * to exec. The obvious place to do the reference counting check
+	 * is setuid(), but we don't do the reference counting check there
+	 * like other OS's do because then all the programs that use setuid()
+	 * must be modified to check the return code of setuid() and exit().
+	 * It is dangerous to make setuid() fail, because it fails open and
+	 * the program will continue to run as root. If we make it succeed
+	 * and return an error code, again we are not enforcing the limit.
+	 * The best place to enforce the limit is here, when the process tries
+	 * to execute a new image, because eventually the process will need
+	 * to call exec in order to do something useful.
+	 */
+
+	if ((p-p_flag  P_SUGID)  (uid = kauth_cred_getuid(l-l_cred)) != 0
+	 chgproccnt(uid, 0)  p-p_rlimit[RLIMIT_NPROC].rlim_cur)
+		return EAGAIN;
+
 	/* Disable scheduler activation upcalls. */
 	oldlwpflags = l-l_flag  (L_SA | L_SA_UPCALL);
 	if (l-l_flag  L_SA)
 		l-l_flag = ~(L_SA | L_SA_UPCALL);
 
-	p = l-l_proc;
 	/*
 	 * Lock the process and set the P_INEXEC flag to indicate that
 	 * it should be left alone until we're done here.  This is



CVS commit: [netbsd-4-0] src/sys/kern

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 20:52:01 UTC 2011

Modified Files:
src/sys/kern [netbsd-4-0]: kern_exec.c

Log Message:
Pull up following revision(s) (requested by spz in ticket #1421):
sys/kern/kern_exec.c: revision 1.269 via patch
Check for number of processes resource violation in execve().


To generate a diff of this commit:
cvs rdiff -u -r1.232.2.2.6.1 -r1.232.2.2.6.2 src/sys/kern/kern_exec.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/kern/kern_exec.c
diff -u src/sys/kern/kern_exec.c:1.232.2.2.6.1 src/sys/kern/kern_exec.c:1.232.2.2.6.2
--- src/sys/kern/kern_exec.c:1.232.2.2.6.1	Sat Sep  5 13:45:28 2009
+++ src/sys/kern/kern_exec.c	Sun Mar 20 20:52:01 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exec.c,v 1.232.2.2.6.1 2009/09/05 13:45:28 bouyer Exp $	*/
+/*	$NetBSD: kern_exec.c,v 1.232.2.2.6.2 2011/03/20 20:52:01 bouyer Exp $	*/
 
 /*-
  * Copyright (C) 1993, 1994, 1996 Christopher G. Demetriou
@@ -33,7 +33,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kern_exec.c,v 1.232.2.2.6.1 2009/09/05 13:45:28 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: kern_exec.c,v 1.232.2.2.6.2 2011/03/20 20:52:01 bouyer Exp $);
 
 #include opt_ktrace.h
 #include opt_syscall_debug.h
@@ -428,18 +428,40 @@
 	int			szsigcode;
 	struct exec_vmcmd	*base_vcp;
 	int			oldlwpflags;
+	uid_t			uid;
 #ifdef SYSTRACE
 	int			wassugid = ISSET(p-p_flag, P_SUGID);
 	char			pathbuf[MAXPATHLEN];
 	size_t			pathbuflen;
 #endif /* SYSTRACE */
 
+	p = l-l_proc;
+
+	/*
+	 * Check if we have exceeded our number of processes limit.
+	 * This is so that we handle the case where a root daemon
+	 * forked, ran setuid to become the desired user and is trying
+	 * to exec. The obvious place to do the reference counting check
+	 * is setuid(), but we don't do the reference counting check there
+	 * like other OS's do because then all the programs that use setuid()
+	 * must be modified to check the return code of setuid() and exit().
+	 * It is dangerous to make setuid() fail, because it fails open and
+	 * the program will continue to run as root. If we make it succeed
+	 * and return an error code, again we are not enforcing the limit.
+	 * The best place to enforce the limit is here, when the process tries
+	 * to execute a new image, because eventually the process will need
+	 * to call exec in order to do something useful.
+	 */
+
+	if ((p-p_flag  P_SUGID)  (uid = kauth_cred_getuid(l-l_cred)) != 0
+	 chgproccnt(uid, 0)  p-p_rlimit[RLIMIT_NPROC].rlim_cur)
+		return EAGAIN;
+
 	/* Disable scheduler activation upcalls. */
 	oldlwpflags = l-l_flag  (L_SA | L_SA_UPCALL);
 	if (l-l_flag  L_SA)
 		l-l_flag = ~(L_SA | L_SA_UPCALL);
 
-	p = l-l_proc;
 	/*
 	 * Lock the process and set the P_INEXEC flag to indicate that
 	 * it should be left alone until we're done here.  This is



CVS commit: [netbsd-4] src/doc

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 20:52:30 UTC 2011

Modified Files:
src/doc [netbsd-4]: CHANGES-4.1

Log Message:
ticket 1417, 1418, 1420, 1421


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.217 -r1.1.2.218 src/doc/CHANGES-4.1

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

Modified files:

Index: src/doc/CHANGES-4.1
diff -u src/doc/CHANGES-4.1:1.1.2.217 src/doc/CHANGES-4.1:1.1.2.218
--- src/doc/CHANGES-4.1:1.1.2.217	Mon Mar  7 17:14:41 2011
+++ src/doc/CHANGES-4.1	Sun Mar 20 20:52:29 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: CHANGES-4.1,v 1.1.2.217 2011/03/07 17:14:41 snj Exp $
+#	$NetBSD: CHANGES-4.1,v 1.1.2.218 2011/03/20 20:52:29 bouyer Exp $
 
 A complete list of changes from the NetBSD 4.0 release to the NetBSD 4.1
 release:
@@ -4329,3 +4329,73 @@
 	Sanitize arguments before memory allocation.
 	[joerg, ticket #1419]
 
+sys/kern/vfs_syscalls.c1.415 via patch
+
+	Check for bogus flags to access() up front. Otherwise we end up
+	calling VOP_ACCESS with flags 0 and something asserts deep in the
+	bowels of kauth. PR 44648 from Taylor Campbell. (I moved the check
+	earlier relative to the suggested patch.)
+	[dholland, ticket #1417]
+
+lib/libc/inet/inet_net_pton.c			1.2
+
+	Check bits on each loop to prevent integer oveflow.
+	Reported by Maksymilian Arciemowicz
+	[spz, ticket #1418]
+
+gnu/dist/postfix/HISTORYpatch
+gnu/dist/postfix/RELEASE_NOTESpatch
+gnu/dist/postfix/makedefspatch
+gnu/dist/postfix/html/postconf.5.html			patch
+gnu/dist/postfix/man/man5/postconf.5			patch
+gnu/dist/postfix/mantools/postlink			patch
+gnu/dist/postfix/src/bounce/bounce_template.c		patch
+gnu/dist/postfix/src/cleanup/cleanup_map1n.c		patch
+gnu/dist/postfix/src/flush/flush.c			patch
+gnu/dist/postfix/src/global/cleanup_user.h		patch
+gnu/dist/postfix/src/global/db_common.c			patch
+gnu/dist/postfix/src/global/mail_params.h		patch
+gnu/dist/postfix/src/global/mail_version.h		patch
+gnu/dist/postfix/src/global/pipe_command.c		patch
+gnu/dist/postfix/src/local/recipient.c			patch
+gnu/dist/postfix/src/master/master_sig.c		patch
+gnu/dist/postfix/src/milter/milter8.c			patch
+gnu/dist/postfix/src/oqmgr/qmgr_entry.c			patch
+gnu/dist/postfix/src/pickup/pickup.c			patch
+gnu/dist/postfix/src/pipe/pipe.c			patch
+gnu/dist/postfix/src/postdrop/postdrop.c		patch
+gnu/dist/postfix/src/postsuper/postsuper.c		patch
+gnu/dist/postfix/src/qmgr/qmgr_entry.c			patch
+gnu/dist/postfix/src/smtp/smtp.c			patch
+gnu/dist/postfix/src/smtp/lmtp_params.c			patch
+gnu/dist/postfix/src/smtp/smtp_params.c			patch
+gnu/dist/postfix/src/smtp/smtp_proto.c			patch
+gnu/dist/postfix/src/smtp/smtp_reuse.c			patch
+gnu/dist/postfix/src/smtpd/smtpd.c			patch
+gnu/dist/postfix/src/smtpd/smtpd_check.c		patch
+gnu/dist/postfix/src/smtpd/smtpd_proxy.c		patch
+gnu/dist/postfix/src/tls/Makefile.in			patch
+gnu/dist/postfix/src/tls/tls_certkey.c			patch
+gnu/dist/postfix/src/trivial-rewrite/resolve.c		patch
+gnu/dist/postfix/src/util/events.c			patch
+gnu/dist/postfix/src/util/host_port.c			patch
+gnu/dist/postfix/src/util/make_dirs.c			patch
+gnu/dist/postfix/src/util/match_ops.c			patch
+gnu/dist/postfix/src/util/safe_open.c			patch
+gnu/dist/postfix/src/util/sys_defs.h			patch
+gnu/dist/postfix/src/util/valid_hostname.c		patch
+gnu/dist/postfix/src/util/vstream.c			patch
+gnu/dist/postfix/src/util/vstring.c			patch
+gnu/dist/postfix/src/util/watchdog.c			patch
+gnu/dist/postfix/src/xsasl/xsasl_dovecot_server.c	patch
+gnu/dist/postfix/proto/postconf.proto			patch
+
+	Update Postfix to version 2.4.16. This update fixes many bugs
+	including the vulnerability reported in CVE-2011-0411.
+	[tron, ticket #1420]
+
+sys/kern/kern_exec.c1.269 via patch
+
+	Check for number of processes resource violation in execve().
+	[spz, ticket #1421]
+



CVS commit: [netbsd-4-0] src/doc

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 20:52:34 UTC 2011

Modified Files:
src/doc [netbsd-4-0]: CHANGES-4.0.2

Log Message:
ticket 1417, 1418, 1420, 1421


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.81 -r1.1.2.82 src/doc/CHANGES-4.0.2

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

Modified files:

Index: src/doc/CHANGES-4.0.2
diff -u src/doc/CHANGES-4.0.2:1.1.2.81 src/doc/CHANGES-4.0.2:1.1.2.82
--- src/doc/CHANGES-4.0.2:1.1.2.81	Mon Mar  7 17:14:24 2011
+++ src/doc/CHANGES-4.0.2	Sun Mar 20 20:52:33 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: CHANGES-4.0.2,v 1.1.2.81 2011/03/07 17:14:24 snj Exp $
+#	$NetBSD: CHANGES-4.0.2,v 1.1.2.82 2011/03/20 20:52:33 bouyer Exp $
 
 A complete list of changes from the NetBSD 4.0.1 release to the NetBSD 4.0.2
 release:
@@ -1119,3 +1119,73 @@
 	Sanitize arguments before memory allocation.
 	[joerg, ticket #1419]
 
+sys/kern/vfs_syscalls.c1.415 via patch
+
+	Check for bogus flags to access() up front. Otherwise we end up
+	calling VOP_ACCESS with flags 0 and something asserts deep in the
+	bowels of kauth. PR 44648 from Taylor Campbell. (I moved the check
+	earlier relative to the suggested patch.)
+	[dholland, ticket #1417]
+
+lib/libc/inet/inet_net_pton.c			1.2
+
+	Check bits on each loop to prevent integer oveflow.
+	Reported by Maksymilian Arciemowicz
+	[spz, ticket #1418]
+
+gnu/dist/postfix/HISTORYpatch
+gnu/dist/postfix/RELEASE_NOTESpatch
+gnu/dist/postfix/makedefspatch
+gnu/dist/postfix/html/postconf.5.html			patch
+gnu/dist/postfix/man/man5/postconf.5			patch
+gnu/dist/postfix/mantools/postlink			patch
+gnu/dist/postfix/src/bounce/bounce_template.c		patch
+gnu/dist/postfix/src/cleanup/cleanup_map1n.c		patch
+gnu/dist/postfix/src/flush/flush.c			patch
+gnu/dist/postfix/src/global/cleanup_user.h		patch
+gnu/dist/postfix/src/global/db_common.c			patch
+gnu/dist/postfix/src/global/mail_params.h		patch
+gnu/dist/postfix/src/global/mail_version.h		patch
+gnu/dist/postfix/src/global/pipe_command.c		patch
+gnu/dist/postfix/src/local/recipient.c			patch
+gnu/dist/postfix/src/master/master_sig.c		patch
+gnu/dist/postfix/src/milter/milter8.c			patch
+gnu/dist/postfix/src/oqmgr/qmgr_entry.c			patch
+gnu/dist/postfix/src/pickup/pickup.c			patch
+gnu/dist/postfix/src/pipe/pipe.c			patch
+gnu/dist/postfix/src/postdrop/postdrop.c		patch
+gnu/dist/postfix/src/postsuper/postsuper.c		patch
+gnu/dist/postfix/src/qmgr/qmgr_entry.c			patch
+gnu/dist/postfix/src/smtp/smtp.c			patch
+gnu/dist/postfix/src/smtp/lmtp_params.c			patch
+gnu/dist/postfix/src/smtp/smtp_params.c			patch
+gnu/dist/postfix/src/smtp/smtp_proto.c			patch
+gnu/dist/postfix/src/smtp/smtp_reuse.c			patch
+gnu/dist/postfix/src/smtpd/smtpd.c			patch
+gnu/dist/postfix/src/smtpd/smtpd_check.c		patch
+gnu/dist/postfix/src/smtpd/smtpd_proxy.c		patch
+gnu/dist/postfix/src/tls/Makefile.in			patch
+gnu/dist/postfix/src/tls/tls_certkey.c			patch
+gnu/dist/postfix/src/trivial-rewrite/resolve.c		patch
+gnu/dist/postfix/src/util/events.c			patch
+gnu/dist/postfix/src/util/host_port.c			patch
+gnu/dist/postfix/src/util/make_dirs.c			patch
+gnu/dist/postfix/src/util/match_ops.c			patch
+gnu/dist/postfix/src/util/safe_open.c			patch
+gnu/dist/postfix/src/util/sys_defs.h			patch
+gnu/dist/postfix/src/util/valid_hostname.c		patch
+gnu/dist/postfix/src/util/vstream.c			patch
+gnu/dist/postfix/src/util/vstring.c			patch
+gnu/dist/postfix/src/util/watchdog.c			patch
+gnu/dist/postfix/src/xsasl/xsasl_dovecot_server.c	patch
+gnu/dist/postfix/proto/postconf.proto			patch
+
+	Update Postfix to version 2.4.16. This update fixes many bugs
+	including the vulnerability reported in CVE-2011-0411.
+	[tron, ticket #1420]
+
+sys/kern/kern_exec.c1.269 via patch
+
+	Check for number of processes resource violation in execve().
+	[spz, ticket #1421]
+



CVS commit: src/sys/arch/sparc64/conf

2011-03-20 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Mar 20 20:55:46 UTC 2011

Modified Files:
src/sys/arch/sparc64/conf: files.sparc64

Log Message:
add pci@pryo@mainbus and ebus@mainbus support.


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sys/arch/sparc64/conf/files.sparc64

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/conf/files.sparc64
diff -u src/sys/arch/sparc64/conf/files.sparc64:1.128 src/sys/arch/sparc64/conf/files.sparc64:1.129
--- src/sys/arch/sparc64/conf/files.sparc64:1.128	Tue Sep 21 03:26:20 2010
+++ src/sys/arch/sparc64/conf/files.sparc64	Sun Mar 20 20:55:46 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files.sparc64,v 1.128 2010/09/21 03:26:20 macallan Exp $
+#	$NetBSD: files.sparc64,v 1.129 2011/03/20 20:55:46 mrg Exp $
 
 # @(#)files.sparc64	8.1 (Berkeley) 7/19/93
 # sparc64-specific configuration info
@@ -34,19 +34,24 @@
 attach	psycho at mainbus
 device	schizo: pcibus, sysmon_power, sysmon_taskq
 attach	schizo at mainbus
+device	pyro: pcibus, sysmon_power, sysmon_taskq
+attach	pyro at mainbus
 include dev/pci/files.pci
 file	arch/sparc64/dev/psycho.c		psycho
 file	arch/sparc64/dev/schizo.c		schizo
-file	arch/sparc64/dev/pci_machdep.c		psycho | schizo
+file	arch/sparc64/dev/pyro.c			pyro
+file	arch/sparc64/dev/pci_machdep.c		psycho | schizo | pyro
 
 # IOMMU is for both
-file	arch/sparc64/dev/iommu.c		sbus | psycho | schizo
+file	arch/sparc64/dev/iommu.c		sbus | psycho | schizo | pyro
 
 include dev/ata/files.ata
 
 device ebus {[addr = -1]}: pcibus
 attach ebus at pci
 file	arch/sparc64/dev/ebus.c			ebus
+attach ebus at mainbus with ebus_mainbus
+file	arch/sparc64/dev/ebus_mainbus.c		ebus_mainbus
 
 device clock: mk48txx
 attach clock at sbus with mkclock_sbus



CVS commit: [netbsd-5] src/sys/kern

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 21:19:57 UTC 2011

Modified Files:
src/sys/kern [netbsd-5]: vfs_syscalls.c

Log Message:
Pull up following revision(s) (requested by dholland in ticket #1567):
sys/kern/vfs_syscalls.c: revision 1.415 via patch
Check for bogus flags to access() up front. Otherwise we end up
calling VOP_ACCESS with flags 0 and something asserts deep in the
bowels of kauth. PR 44648 from Taylor Campbell. (I moved the check
earlier relative to the suggested patch.)
Pullup candidate.


To generate a diff of this commit:
cvs rdiff -u -r1.376.4.5 -r1.376.4.6 src/sys/kern/vfs_syscalls.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/kern/vfs_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.376.4.5 src/sys/kern/vfs_syscalls.c:1.376.4.6
--- src/sys/kern/vfs_syscalls.c:1.376.4.5	Sun Feb 14 13:27:45 2010
+++ src/sys/kern/vfs_syscalls.c	Sun Mar 20 21:19:57 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls.c,v 1.376.4.5 2010/02/14 13:27:45 bouyer Exp $	*/
+/*	$NetBSD: vfs_syscalls.c,v 1.376.4.6 2011/03/20 21:19:57 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: vfs_syscalls.c,v 1.376.4.5 2010/02/14 13:27:45 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: vfs_syscalls.c,v 1.376.4.6 2011/03/20 21:19:57 bouyer Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_compat_43.h
@@ -2390,6 +2390,11 @@
 	int error, flags;
 	struct nameidata nd;
 
+	if ((SCARG(uap, flags)  ~(R_OK | W_OK | X_OK)) != 0) {
+		/* nonsense flags */
+		return EINVAL;
+	}
+
 	cred = kauth_cred_dup(l-l_cred);
 	kauth_cred_seteuid(cred, kauth_cred_getuid(l-l_cred));
 	kauth_cred_setegid(cred, kauth_cred_getgid(l-l_cred));



CVS commit: [netbsd-5-0] src/sys/kern

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 21:20:06 UTC 2011

Modified Files:
src/sys/kern [netbsd-5-0]: vfs_syscalls.c

Log Message:
Pull up following revision(s) (requested by dholland in ticket #1567):
sys/kern/vfs_syscalls.c: revision 1.415 via patch
Check for bogus flags to access() up front. Otherwise we end up
calling VOP_ACCESS with flags 0 and something asserts deep in the
bowels of kauth. PR 44648 from Taylor Campbell. (I moved the check
earlier relative to the suggested patch.)
Pullup candidate.


To generate a diff of this commit:
cvs rdiff -u -r1.376.4.2.2.2 -r1.376.4.2.2.3 src/sys/kern/vfs_syscalls.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/kern/vfs_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.376.4.2.2.2 src/sys/kern/vfs_syscalls.c:1.376.4.2.2.3
--- src/sys/kern/vfs_syscalls.c:1.376.4.2.2.2	Mon Dec 21 09:41:51 2009
+++ src/sys/kern/vfs_syscalls.c	Sun Mar 20 21:20:06 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls.c,v 1.376.4.2.2.2 2009/12/21 09:41:51 sborrill Exp $	*/
+/*	$NetBSD: vfs_syscalls.c,v 1.376.4.2.2.3 2011/03/20 21:20:06 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: vfs_syscalls.c,v 1.376.4.2.2.2 2009/12/21 09:41:51 sborrill Exp $);
+__KERNEL_RCSID(0, $NetBSD: vfs_syscalls.c,v 1.376.4.2.2.3 2011/03/20 21:20:06 bouyer Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_compat_43.h
@@ -2390,6 +2390,11 @@
 	int error, flags;
 	struct nameidata nd;
 
+	if ((SCARG(uap, flags)  ~(R_OK | W_OK | X_OK)) != 0) {
+		/* nonsense flags */
+		return EINVAL;
+	}
+
 	cred = kauth_cred_dup(l-l_cred);
 	kauth_cred_seteuid(cred, kauth_cred_getuid(l-l_cred));
 	kauth_cred_setegid(cred, kauth_cred_getgid(l-l_cred));



CVS commit: [netbsd-5-1] src/sys/kern

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 21:20:12 UTC 2011

Modified Files:
src/sys/kern [netbsd-5-1]: vfs_syscalls.c

Log Message:
Pull up following revision(s) (requested by dholland in ticket #1567):
sys/kern/vfs_syscalls.c: revision 1.415 via patch
Check for bogus flags to access() up front. Otherwise we end up
calling VOP_ACCESS with flags 0 and something asserts deep in the
bowels of kauth. PR 44648 from Taylor Campbell. (I moved the check
earlier relative to the suggested patch.)
Pullup candidate.


To generate a diff of this commit:
cvs rdiff -u -r1.376.4.5 -r1.376.4.5.2.1 src/sys/kern/vfs_syscalls.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/kern/vfs_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.376.4.5 src/sys/kern/vfs_syscalls.c:1.376.4.5.2.1
--- src/sys/kern/vfs_syscalls.c:1.376.4.5	Sun Feb 14 13:27:45 2010
+++ src/sys/kern/vfs_syscalls.c	Sun Mar 20 21:20:12 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls.c,v 1.376.4.5 2010/02/14 13:27:45 bouyer Exp $	*/
+/*	$NetBSD: vfs_syscalls.c,v 1.376.4.5.2.1 2011/03/20 21:20:12 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: vfs_syscalls.c,v 1.376.4.5 2010/02/14 13:27:45 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: vfs_syscalls.c,v 1.376.4.5.2.1 2011/03/20 21:20:12 bouyer Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_compat_43.h
@@ -2390,6 +2390,11 @@
 	int error, flags;
 	struct nameidata nd;
 
+	if ((SCARG(uap, flags)  ~(R_OK | W_OK | X_OK)) != 0) {
+		/* nonsense flags */
+		return EINVAL;
+	}
+
 	cred = kauth_cred_dup(l-l_cred);
 	kauth_cred_seteuid(cred, kauth_cred_getuid(l-l_cred));
 	kauth_cred_setegid(cred, kauth_cred_getgid(l-l_cred));



CVS commit: [netbsd-5] src/lib/librefuse

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 21:21:57 UTC 2011

Modified Files:
src/lib/librefuse [netbsd-5]: refuse_opt.c

Log Message:
Pull up following revision(s) (requested by soda in ticket #1568):
lib/librefuse/refuse_opt.c: revision 1.15
fuse_opt_parse() was using uninitialized struct fuse_opt_option::data,
this bug made fuse_opt_proc_t not work, if it used first ``data'' argument,
and might cause memory corruption even.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.13.12.1 src/lib/librefuse/refuse_opt.c

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

Modified files:

Index: src/lib/librefuse/refuse_opt.c
diff -u src/lib/librefuse/refuse_opt.c:1.13 src/lib/librefuse/refuse_opt.c:1.13.12.1
--- src/lib/librefuse/refuse_opt.c:1.13	Mon Nov  5 13:41:52 2007
+++ src/lib/librefuse/refuse_opt.c	Sun Mar 20 21:21:57 2011
@@ -1,4 +1,4 @@
-/* 	$NetBSD: refuse_opt.c,v 1.13 2007/11/05 13:41:52 pooka Exp $	*/
+/* 	$NetBSD: refuse_opt.c,v 1.13.12.1 2011/03/20 21:21:57 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2007 Juan Romero Pardines.
@@ -282,6 +282,7 @@
 	if (!args || !args-argv || !args-argc || !proc)
 		return 0;
 
+	foo.data = data;
 	if (args-argc == 1)
 		return proc(foo.data, *args-argv, FUSE_OPT_KEY_OPT, args);
 



CVS commit: [netbsd-5] src/sys/arch/sparc64/dev

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 21:23:32 UTC 2011

Modified Files:
src/sys/arch/sparc64/dev [netbsd-5]: lom.c

Log Message:
Pull up following revision(s) (requested by nakayama in ticket #1570):
sys/arch/sparc64/dev/lom.c: revision 1.7
lom_refresh():
Update only the sensor status specified by the edata as noted in
sysmon_envsys(9).
lom_sysctl_alarm():
Update alarm status before reading via sysctl to make it usable at
a boot time.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.6 -r1.1.2.7 src/sys/arch/sparc64/dev/lom.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/dev/lom.c
diff -u src/sys/arch/sparc64/dev/lom.c:1.1.2.6 src/sys/arch/sparc64/dev/lom.c:1.1.2.7
--- src/sys/arch/sparc64/dev/lom.c:1.1.2.6	Sun Mar 28 16:48:36 2010
+++ src/sys/arch/sparc64/dev/lom.c	Sun Mar 20 21:23:32 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: lom.c,v 1.1.2.6 2010/03/28 16:48:36 snj Exp $	*/
+/*	$NetBSD: lom.c,v 1.1.2.7 2011/03/20 21:23:32 bouyer Exp $	*/
 /*	$OpenBSD: lom.c,v 1.21 2010/02/28 20:44:39 kettenis Exp $	*/
 /*
  * Copyright (c) 2009 Mark Kettenis
@@ -17,7 +17,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: lom.c,v 1.1.2.6 2010/03/28 16:48:36 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: lom.c,v 1.1.2.7 2011/03/20 21:23:32 bouyer Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -217,6 +217,10 @@
 
 static int	lom_init_desc(struct lom_softc *);
 static void	lom_refresh(struct sysmon_envsys *, envsys_data_t *);
+static void	lom_refresh_alarm(struct lom_softc *, envsys_data_t *, uint32_t);
+static void	lom_refresh_fan(struct lom_softc *, envsys_data_t *, uint32_t);
+static void	lom_refresh_psu(struct lom_softc *, envsys_data_t *, uint32_t);
+static void	lom_refresh_temp(struct lom_softc *, envsys_data_t *, uint32_t);
 static void	lom1_write_hostname(struct lom_softc *);
 static void	lom2_write_hostname(struct lom_softc *);
 
@@ -947,88 +951,136 @@
 lom_refresh(struct sysmon_envsys *sme, envsys_data_t *edata)
 {
 	struct lom_softc *sc = sme-sme_cookie;
+	uint32_t i;
+
+	/* Sensor number */
+	i = edata-sensor;
+
+	/* Sensor type */
+	switch (edata-units) {
+	case ENVSYS_INDICATOR:
+		if (i  sc-sc_num_alarm)
+			lom_refresh_alarm(sc, edata, i);
+		else
+			lom_refresh_psu(sc, edata,
+			i - sc-sc_num_alarm - sc-sc_num_fan);
+		break;
+	case ENVSYS_SFANRPM:
+		lom_refresh_fan(sc, edata, i - sc-sc_num_alarm);
+		break;
+	case ENVSYS_STEMP:
+		lom_refresh_temp(sc, edata,
+		i - sc-sc_num_alarm - sc-sc_num_fan - sc-sc_num_psu);
+		break;
+	default:
+		edata-state = ENVSYS_SINVALID;
+		break;
+	}
+
+	/*
+	 * If our hostname is set and differs from what's stored in
+	 * the LOM, write the new hostname back to the LOM.  Note that
+	 * we include the terminating NUL when writing the hostname
+	 * back to the LOM, otherwise the LOM will print any trailing
+	 * garbage.
+	 */
+	if (i == 0  hostnamelen  0 
+	strncmp(sc-sc_hostname, hostname, sizeof(hostname)) != 0) {
+		if (sc-sc_type  LOM_LOMLITE2)
+			lom1_write_hostname(sc);
+		else
+			lom2_write_hostname(sc);
+		strlcpy(sc-sc_hostname, hostname, sizeof(hostname));
+	}
+}
+
+static void
+lom_refresh_alarm(struct lom_softc *sc, envsys_data_t *edata, uint32_t i)
+{
 	uint8_t val;
-	int i;
+
+	/* Fault LED or Alarms */
+	KASSERT(i  sc-sc_num_alarm);
 
 	if (lom_read(sc, LOM_IDX_ALARM, val)) {
-		for (i = 0; i  sc-sc_num_alarm; i++)
-			sc-sc_alarm[i].state = ENVSYS_SINVALID;
+		edata-state = ENVSYS_SINVALID;
 	} else {
-		/* Fault LED */
-		if ((val  LOM_ALARM_FAULT) == LOM_ALARM_FAULT)
-			sc-sc_alarm[0].value_cur = 0;
-		else
-			sc-sc_alarm[0].value_cur = 1;
-		sc-sc_alarm[0].state = ENVSYS_SVALID;
-
-		/* Alarms */
-		for (i = 1; i  sc-sc_num_alarm; i++) {
+		if (i == 0) {
+			/* Fault LED */
+			if ((val  LOM_ALARM_FAULT) == LOM_ALARM_FAULT)
+edata-value_cur = 0;
+			else
+edata-value_cur = 1;
+		} else {
+			/* Alarms */
 			if ((val  (LOM_ALARM_1  (i - 1))) == 0)
-sc-sc_alarm[i].value_cur = 0;
+edata-value_cur = 0;
 			else
-sc-sc_alarm[i].value_cur = 1;
-			sc-sc_alarm[i].state = ENVSYS_SVALID;
+edata-value_cur = 1;
 		}
+		edata-state = ENVSYS_SVALID;
 	}
+}
 
-	for (i = 0; i  sc-sc_num_fan; i++) {
-		if (lom_read(sc, LOM_IDX_FAN1 + i, val)) {
-			sc-sc_fan[i].state = ENVSYS_SINVALID;
-			continue;
-		}
+static void
+lom_refresh_fan(struct lom_softc *sc, envsys_data_t *edata, uint32_t i)
+{
+	uint8_t val;
+
+	/* Fan speed */
+	KASSERT(i  sc-sc_num_fan);
 
-		sc-sc_fan[i].value_cur = (60 * sc-sc_fan_cal[i] * val) / 100;
+	if (lom_read(sc, LOM_IDX_FAN1 + i, val)) {
+		edata-state = ENVSYS_SINVALID;
+	} else {
+		edata-value_cur = (60 * sc-sc_fan_cal[i] * val) / 100;
 		if (val  sc-sc_fan_low[i])
-			sc-sc_fan[i].state = ENVSYS_SCRITICAL;
+			edata-state = ENVSYS_SCRITICAL;
 		else
-			sc-sc_fan[i].state = ENVSYS_SVALID;
+			edata-state = ENVSYS_SVALID;
 	}
+}

CVS commit: src/sys/arch/sparc64/dev

2011-03-20 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Mar 20 21:26:36 UTC 2011

Modified Files:
src/sys/arch/sparc64/dev: iommu.c

Log Message:
re-add most of the pryo-supporting code, and some general clean up:
- handle setting tsb size in the ptsb via IOMMU_TSBSIZE_IN_PTSB (partly from
  openbsd)
- fix IDB_INFO for systems without a STC that fault on accesses to the
  flush register (like pyro)
- move iommu_reset() to the end of iommu_init()
- use IOMMUREG_WRITE() in a few places
- add a missing membar_lookaside() (from openbsd)
- if pmap_extract() on the flush buffer fails, disable flushing (from openbsd)
- flush the pyro-style iommu when IOMMU_FLUSH_CACHE is set (partly from openbsd)
- clear up a bit of debugging code so it spew a little less (sometimes you will
  get kernel lock spinouts due to long scrolling printfs)
- use __func__ in several places


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/arch/sparc64/dev/iommu.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/dev/iommu.c
diff -u src/sys/arch/sparc64/dev/iommu.c:1.102 src/sys/arch/sparc64/dev/iommu.c:1.103
--- src/sys/arch/sparc64/dev/iommu.c:1.102	Wed Mar 16 05:49:43 2011
+++ src/sys/arch/sparc64/dev/iommu.c	Sun Mar 20 21:26:36 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: iommu.c,v 1.102 2011/03/16 05:49:43 mrg Exp $	*/
+/*	$NetBSD: iommu.c,v 1.103 2011/03/20 21:26:36 mrg Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -59,7 +59,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: iommu.c,v 1.102 2011/03/16 05:49:43 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: iommu.c,v 1.103 2011/03/20 21:26:36 mrg Exp $);
 
 #include opt_ddb.h
 
@@ -134,7 +134,7 @@
 	 * be hard-wired, so we read the start and size from the PROM and
 	 * just use those values.
 	 */
-	is-is_cr = (tsbsize  16) | IOMMUCR_EN;
+	is-is_cr = IOMMUCR_EN;
 	is-is_tsbsize = tsbsize;
 	if (iovabase == -1) {
 		is-is_dvmabase = IOTSB_VSTART(is-is_tsbsize);
@@ -176,20 +176,13 @@
 	{
 		/* Probe the iommu */
 
-		printf(iommu regs at: cr=%lx tsb=%lx flush=%lx\n,
-			(u_long)bus_space_read_8(is-is_bustag, is-is_iommu,
-offsetof (struct iommureg, iommu_cr)),
-			(u_long)bus_space_read_8(is-is_bustag, is-is_iommu,
-offsetof (struct iommureg, iommu_tsb)),
-			(u_long)bus_space_read_8(is-is_bustag, is-is_iommu,
-offsetof (struct iommureg, iommu_flush)));
 		printf(iommu cr=%llx tsb=%llx\n,
 			(unsigned long long)bus_space_read_8(is-is_bustag,
 is-is_iommu,
-offsetof (struct iommureg, iommu_cr)),
+offsetof(struct iommureg, iommu_cr)),
 			(unsigned long long)bus_space_read_8(is-is_bustag,
 is-is_iommu,
-offsetof (struct iommureg, iommu_tsb)));
+offsetof(struct iommureg, iommu_tsb)));
 		printf(TSB base %p phys %llx\n, (void *)is-is_tsb,
 			(unsigned long long)is-is_ptsb);
 		delay(100); /* 1 s */
@@ -197,11 +190,6 @@
 #endif
 
 	/*
-	 * now actually start up the IOMMU
-	 */
-	iommu_reset(is);
-
-	/*
 	 * Now all the hardware's working we need to allocate a dvma map.
 	 */
 	aprint_debug(DVMA map: %x to %x\n,
@@ -214,6 +202,20 @@
 	is-is_dvmabase, is-is_dvmaend,
 	M_DEVBUF, 0, 0, EX_NOWAIT);
 	/* XXXMRG Check is_dvmamap is valid. */
+
+	/*
+	 * Set the TSB size.  The relevant bits were moved to the TSB
+	 * base register in the PCIe host bridges.
+	 */
+	if (is-is_flags  IOMMU_TSBSIZE_IN_PTSB)
+		is-is_ptsb |= is-is_tsbsize;
+	else
+		is-is_cr |= (is-is_tsbsize  16);
+
+	/*
+	 * now actually start up the IOMMU
+	 */
+	iommu_reset(is);
 }
 
 /*
@@ -227,13 +229,10 @@
 	int i;
 	struct strbuf_ctl *sb;
 
-	/* Need to do 64-bit stores */
-	bus_space_write_8(is-is_bustag, is-is_iommu, IOMMUREG(iommu_tsb),
-		is-is_ptsb);
+	IOMMUREG_WRITE(is, iommu_tsb, is-is_ptsb);
 
 	/* Enable IOMMU in diagnostic mode */
-	bus_space_write_8(is-is_bustag, is-is_iommu, IOMMUREG(iommu_cr),
-		is-is_cr|IOMMUCR_DE);
+	IOMMUREG_WRITE(is, iommu_cr, is-is_cr|IOMMUCR_DE);
 
 	for (i = 0; i  2; i++) {
 		if ((sb = is-is_sb[i])) {
@@ -242,6 +241,8 @@
 			bus_space_write_8(is-is_bustag, is-is_sb[i]-sb_sb,
 STRBUFREG(strbuf_ctl), STRBUF_EN);
 
+			membar_lookaside();
+
 			/* No streaming buffers? Disable them */
 			if (bus_space_read_8(is-is_bustag,
 is-is_sb[i]-sb_sb,
@@ -252,12 +253,16 @@
 /*
  * locate the pa of the flush buffer.
  */
-(void)pmap_extract(pmap_kernel(),
-	(vaddr_t)is-is_sb[i]-sb_flush,
-	is-is_sb[i]-sb_flushpa);
+if (pmap_extract(pmap_kernel(),
+ (vaddr_t)is-is_sb[i]-sb_flush,
+ is-is_sb[i]-sb_flushpa) == FALSE)
+	is-is_sb[i]-sb_flush = NULL;
 			}
 		}
 	}
+
+	if (is-is_flags  IOMMU_FLUSH_CACHE)
+		IOMMUREG_WRITE(is, iommu_cache_invalidate, -1ULL);
 }
 
 /*
@@ -288,12 +293,11 @@
 	tte |= (flags  0xff000LL)(4*8);
 #endif
 
-	DPRINTF(IDB_IOMMU, (Clearing TSB slot %d for va %p\n,
-		   (int)IOTSBSLOT(va,is-is_tsbsize), (void *)(u_long)va));
 	

CVS commit: [netbsd-5] src/sys/net

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 21:28:08 UTC 2011

Modified Files:
src/sys/net [netbsd-5]: bpf_filter.c

Log Message:
Pull up following revision(s) (requested by spz in ticket #1571):
sys/net/bpf_filter.c: revision 1.42 - 1.46 via patch
Avoid stack memory disclosure by keeping track during filter validation time
of initialized memory. Idea taken from linux.
Use __CTASSERT
Use kmem instead of malloc. Requested by rmind.
Fix userland build.
delint.


To generate a diff of this commit:
cvs rdiff -u -r1.35.4.1 -r1.35.4.2 src/sys/net/bpf_filter.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/net/bpf_filter.c
diff -u src/sys/net/bpf_filter.c:1.35.4.1 src/sys/net/bpf_filter.c:1.35.4.2
--- src/sys/net/bpf_filter.c:1.35.4.1	Thu May 20 05:13:13 2010
+++ src/sys/net/bpf_filter.c	Sun Mar 20 21:28:08 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf_filter.c,v 1.35.4.1 2010/05/20 05:13:13 snj Exp $	*/
+/*	$NetBSD: bpf_filter.c,v 1.35.4.2 2011/03/20 21:28:08 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: bpf_filter.c,v 1.35.4.1 2010/05/20 05:13:13 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: bpf_filter.c,v 1.35.4.2 2011/03/20 21:28:08 bouyer Exp $);
 
 #if 0
 #if !(defined(lint) || defined(KERNEL))
@@ -48,6 +48,7 @@
 
 #include sys/param.h
 #include sys/time.h
+#include sys/kmem.h
 #include sys/endian.h
 
 #define EXTRACT_SHORT(p)	be16dec(p)
@@ -147,8 +148,7 @@
 	A = 0;
 	X = 0;
 	--pc;
-	/* CONSTCOND */
-	while (1) {
+	for (;;) {
 		++pc;
 		switch (pc-code) {
 
@@ -157,6 +157,7 @@
 			return 0;
 #else
 			abort();
+			/*NOTREACHED*/
 #endif
 		case BPF_RET|BPF_K:
 			return (u_int)pc-k;
@@ -461,16 +462,38 @@
  * The kernel needs to be able to verify an application's filter code.
  * Otherwise, a bogus program could easily crash the system.
  */
+CTASSERT(BPF_MEMWORDS == sizeof(uint16_t) * NBBY);
+
 int
-bpf_validate(struct bpf_insn *f, int len)
+bpf_validate(struct bpf_insn *f, int signed_len)
 {
-	u_int i, from;
-	struct bpf_insn *p;
+	u_int i, from, len, ok = 0;
+	const struct bpf_insn *p;
+#if defined(KERNEL) || defined(_KERNEL)
+	uint16_t *mem, invalid;
+	size_t size;
+#endif
 
-	if (len  1 || len  BPF_MAXINSNS)
+	len = (u_int)signed_len;
+	if (len  1)
+		return 0;
+#if defined(KERNEL) || defined(_KERNEL)
+	if (len  BPF_MAXINSNS)
+		return 0;
+#endif 
+	if (BPF_CLASS(f[len - 1].code) != BPF_RET)
 		return 0;
 
+#if defined(KERNEL) || defined(_KERNEL)
+	mem = kmem_zalloc(size = sizeof(*mem) * len, KM_SLEEP);
+	invalid = ~0;   /* All is invalid on startup */
+#endif
+
 	for (i = 0; i  len; ++i) {
+#if defined(KERNEL) || defined(_KERNEL)
+		/* blend in any invalid bits for current pc */
+		invalid |= mem[i];
+#endif
 		p = f[i];
 		switch (BPF_CLASS(p-code)) {
 		/*
@@ -480,8 +503,22 @@
 		case BPF_LDX:
 			switch (BPF_MODE(p-code)) {
 			case BPF_MEM:
+/*
+ * There's no maximum packet data size
+ * in userland.  The runtime packet length
+ * check suffices.
+ */
+#if defined(KERNEL) || defined(_KERNEL)
+/*
+ * More strict check with actual packet length
+ * is done runtime.
+ */
 if (p-k = BPF_MEMWORDS)
-	return 0;
+	goto out;
+/* check for current memory invalid */
+if (invalid  (1  p-k))
+	goto out;
+#endif
 break;
 			case BPF_ABS:
 			case BPF_IND:
@@ -490,13 +527,17 @@
 			case BPF_LEN:
 break;
 			default:
-return 0;
+goto out;
 			}
 			break;
 		case BPF_ST:
 		case BPF_STX:
 			if (p-k = BPF_MEMWORDS)
-return 0;
+goto out;
+#if defined(KERNEL) || defined(_KERNEL)
+			/* validate the memory word */
+			invalid = ~(1  p-k);
+#endif
 			break;
 		case BPF_ALU:
 			switch (BPF_OP(p-code)) {
@@ -514,10 +555,10 @@
  * Check for constant division by 0.
  */
 if (BPF_SRC(p-code) == BPF_K  p-k == 0)
-	return 0;
+	goto out;
 break;
 			default:
-return 0;
+goto out;
 			}
 			break;
 		case BPF_JMP:
@@ -540,18 +581,37 @@
 			from = i + 1;
 			switch (BPF_OP(p-code)) {
 			case BPF_JA:
-if (from + p-k  from || from + p-k = len)
-	return 0;
+if (from + p-k = len)
+	goto out;
+#if defined(KERNEL) || defined(_KERNEL)
+if (from + p-k  from)
+	goto out;
+/*
+ * mark the currently invalid bits for the
+ * destination
+ */
+mem[from + p-k] |= invalid;
+invalid = 0;
+#endif
 break;
 			case BPF_JEQ:
 			case BPF_JGT:
 			case BPF_JGE:
 			case BPF_JSET:
 if (from + p-jt = len || from + p-jf = len) 
-	return 0;
+	goto out;
+#if defined(KERNEL) || defined(_KERNEL)
+/*
+ * mark the currently invalid bits for both
+ * possible jump destinations
+ */
+mem[from + p-jt] |= invalid;
+mem[from + p-jf] |= invalid;
+invalid = 0;
+#endif
 break;
 			default:
-return 0;
+

CVS commit: [netbsd-5-1] src/sys/net

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 21:28:13 UTC 2011

Modified Files:
src/sys/net [netbsd-5-1]: bpf_filter.c

Log Message:
Pull up following revision(s) (requested by spz in ticket #1571):
sys/net/bpf_filter.c: revision 1.42 - 1.46 via patch
Avoid stack memory disclosure by keeping track during filter validation time
of initialized memory. Idea taken from linux.
Use __CTASSERT
Use kmem instead of malloc. Requested by rmind.
Fix userland build.
delint.


To generate a diff of this commit:
cvs rdiff -u -r1.35.4.1 -r1.35.4.1.2.1 src/sys/net/bpf_filter.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/net/bpf_filter.c
diff -u src/sys/net/bpf_filter.c:1.35.4.1 src/sys/net/bpf_filter.c:1.35.4.1.2.1
--- src/sys/net/bpf_filter.c:1.35.4.1	Thu May 20 05:13:13 2010
+++ src/sys/net/bpf_filter.c	Sun Mar 20 21:28:13 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf_filter.c,v 1.35.4.1 2010/05/20 05:13:13 snj Exp $	*/
+/*	$NetBSD: bpf_filter.c,v 1.35.4.1.2.1 2011/03/20 21:28:13 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: bpf_filter.c,v 1.35.4.1 2010/05/20 05:13:13 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: bpf_filter.c,v 1.35.4.1.2.1 2011/03/20 21:28:13 bouyer Exp $);
 
 #if 0
 #if !(defined(lint) || defined(KERNEL))
@@ -48,6 +48,7 @@
 
 #include sys/param.h
 #include sys/time.h
+#include sys/kmem.h
 #include sys/endian.h
 
 #define EXTRACT_SHORT(p)	be16dec(p)
@@ -147,8 +148,7 @@
 	A = 0;
 	X = 0;
 	--pc;
-	/* CONSTCOND */
-	while (1) {
+	for (;;) {
 		++pc;
 		switch (pc-code) {
 
@@ -157,6 +157,7 @@
 			return 0;
 #else
 			abort();
+			/*NOTREACHED*/
 #endif
 		case BPF_RET|BPF_K:
 			return (u_int)pc-k;
@@ -461,16 +462,38 @@
  * The kernel needs to be able to verify an application's filter code.
  * Otherwise, a bogus program could easily crash the system.
  */
+CTASSERT(BPF_MEMWORDS == sizeof(uint16_t) * NBBY);
+
 int
-bpf_validate(struct bpf_insn *f, int len)
+bpf_validate(struct bpf_insn *f, int signed_len)
 {
-	u_int i, from;
-	struct bpf_insn *p;
+	u_int i, from, len, ok = 0;
+	const struct bpf_insn *p;
+#if defined(KERNEL) || defined(_KERNEL)
+	uint16_t *mem, invalid;
+	size_t size;
+#endif
 
-	if (len  1 || len  BPF_MAXINSNS)
+	len = (u_int)signed_len;
+	if (len  1)
+		return 0;
+#if defined(KERNEL) || defined(_KERNEL)
+	if (len  BPF_MAXINSNS)
+		return 0;
+#endif 
+	if (BPF_CLASS(f[len - 1].code) != BPF_RET)
 		return 0;
 
+#if defined(KERNEL) || defined(_KERNEL)
+	mem = kmem_zalloc(size = sizeof(*mem) * len, KM_SLEEP);
+	invalid = ~0;   /* All is invalid on startup */
+#endif
+
 	for (i = 0; i  len; ++i) {
+#if defined(KERNEL) || defined(_KERNEL)
+		/* blend in any invalid bits for current pc */
+		invalid |= mem[i];
+#endif
 		p = f[i];
 		switch (BPF_CLASS(p-code)) {
 		/*
@@ -480,8 +503,22 @@
 		case BPF_LDX:
 			switch (BPF_MODE(p-code)) {
 			case BPF_MEM:
+/*
+ * There's no maximum packet data size
+ * in userland.  The runtime packet length
+ * check suffices.
+ */
+#if defined(KERNEL) || defined(_KERNEL)
+/*
+ * More strict check with actual packet length
+ * is done runtime.
+ */
 if (p-k = BPF_MEMWORDS)
-	return 0;
+	goto out;
+/* check for current memory invalid */
+if (invalid  (1  p-k))
+	goto out;
+#endif
 break;
 			case BPF_ABS:
 			case BPF_IND:
@@ -490,13 +527,17 @@
 			case BPF_LEN:
 break;
 			default:
-return 0;
+goto out;
 			}
 			break;
 		case BPF_ST:
 		case BPF_STX:
 			if (p-k = BPF_MEMWORDS)
-return 0;
+goto out;
+#if defined(KERNEL) || defined(_KERNEL)
+			/* validate the memory word */
+			invalid = ~(1  p-k);
+#endif
 			break;
 		case BPF_ALU:
 			switch (BPF_OP(p-code)) {
@@ -514,10 +555,10 @@
  * Check for constant division by 0.
  */
 if (BPF_SRC(p-code) == BPF_K  p-k == 0)
-	return 0;
+	goto out;
 break;
 			default:
-return 0;
+goto out;
 			}
 			break;
 		case BPF_JMP:
@@ -540,18 +581,37 @@
 			from = i + 1;
 			switch (BPF_OP(p-code)) {
 			case BPF_JA:
-if (from + p-k  from || from + p-k = len)
-	return 0;
+if (from + p-k = len)
+	goto out;
+#if defined(KERNEL) || defined(_KERNEL)
+if (from + p-k  from)
+	goto out;
+/*
+ * mark the currently invalid bits for the
+ * destination
+ */
+mem[from + p-k] |= invalid;
+invalid = 0;
+#endif
 break;
 			case BPF_JEQ:
 			case BPF_JGT:
 			case BPF_JGE:
 			case BPF_JSET:
 if (from + p-jt = len || from + p-jf = len) 
-	return 0;
+	goto out;
+#if defined(KERNEL) || defined(_KERNEL)
+/*
+ * mark the currently invalid bits for both
+ * possible jump destinations
+ */
+mem[from + p-jt] |= invalid;
+mem[from + p-jf] |= invalid;
+invalid = 0;
+#endif
 break;
 			default:
-

CVS commit: [netbsd-5] src/sys/arch/mips/mips

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 21:31:33 UTC 2011

Modified Files:
src/sys/arch/mips/mips [netbsd-5]: fp.S

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1572):
sys/arch/mips/mips/fp.S: revision 1.40 via patch
Fix cvt.d.s per analysis by Marcus Comstedt in PR port-mips/36251.
Confirmed on ews4800mips.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.33.30.1 src/sys/arch/mips/mips/fp.S

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/mips/mips/fp.S
diff -u src/sys/arch/mips/mips/fp.S:1.33 src/sys/arch/mips/mips/fp.S:1.33.30.1
--- src/sys/arch/mips/mips/fp.S:1.33	Wed Oct 17 19:55:37 2007
+++ src/sys/arch/mips/mips/fp.S	Sun Mar 20 21:31:32 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: fp.S,v 1.33 2007/10/17 19:55:37 garbled Exp $	*/
+/*	$NetBSD: fp.S,v 1.33.30.1 2011/03/20 21:31:32 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -1619,6 +1619,8 @@
 	beq	t2, zero, result_fs_d		# is FS zero?
 	jal	_C_LABEL(renorm_fs_s)
 	move	t8, zero
+	sll	t3, t2, 32 - 3			# convert S fraction to D
+	srl	t2, t2, 3
 	b	norm_d
 2:
 	addu	t1, t1, DEXP_BIAS - SEXP_BIAS	# bias exponent correctly



CVS commit: [netbsd-5] src/lib/libc/inet

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 21:32:32 UTC 2011

Modified Files:
src/lib/libc/inet [netbsd-5]: inet_net_pton.c

Log Message:
Pull up following revision(s) (requested by spz in ticket #1574):
lib/libc/inet/inet_net_pton.c: revision 1.2
Check bits on each loop to prevent integer oveflow.
Reported by Maksymilian Arciemowicz


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.1.32.1 src/lib/libc/inet/inet_net_pton.c

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/inet/inet_net_pton.c
diff -u src/lib/libc/inet/inet_net_pton.c:1.1 src/lib/libc/inet/inet_net_pton.c:1.1.32.1
--- src/lib/libc/inet/inet_net_pton.c:1.1	Thu May 20 23:13:02 2004
+++ src/lib/libc/inet/inet_net_pton.c	Sun Mar 20 21:32:32 2011
@@ -20,7 +20,7 @@
 #if 0
 static const char rcsid[] = Id: inet_net_pton.c,v 1.4.2.1 2002/08/02 02:17:21 marka Exp ;
 #else
-__RCSID($NetBSD: inet_net_pton.c,v 1.1 2004/05/20 23:13:02 christos Exp $);
+__RCSID($NetBSD: inet_net_pton.c,v 1.1.32.1 2011/03/20 21:32:32 bouyer Exp $);
 #endif
 #endif
 
@@ -145,12 +145,12 @@
 			INSIST(n = 0  n = 9);
 			bits *= 10;
 			bits += n;
+			if (bits  32)
+goto emsgsize;
 		} while ((ch = *src++) != '\0'  isascii((u_char)ch)
 		 isdigit((u_char)ch));
 		if (ch != '\0')
 			goto enoent;
-		if (bits  32)
-			goto emsgsize;
 	}
 
 	/* Firey death and destruction unless we prefetched EOS. */



CVS commit: [netbsd-5-0] src/lib/libc/inet

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 21:32:39 UTC 2011

Modified Files:
src/lib/libc/inet [netbsd-5-0]: inet_net_pton.c

Log Message:
Pull up following revision(s) (requested by spz in ticket #1574):
lib/libc/inet/inet_net_pton.c: revision 1.2
Check bits on each loop to prevent integer oveflow.
Reported by Maksymilian Arciemowicz


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.1.38.1 src/lib/libc/inet/inet_net_pton.c

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/inet/inet_net_pton.c
diff -u src/lib/libc/inet/inet_net_pton.c:1.1 src/lib/libc/inet/inet_net_pton.c:1.1.38.1
--- src/lib/libc/inet/inet_net_pton.c:1.1	Thu May 20 23:13:02 2004
+++ src/lib/libc/inet/inet_net_pton.c	Sun Mar 20 21:32:38 2011
@@ -20,7 +20,7 @@
 #if 0
 static const char rcsid[] = Id: inet_net_pton.c,v 1.4.2.1 2002/08/02 02:17:21 marka Exp ;
 #else
-__RCSID($NetBSD: inet_net_pton.c,v 1.1 2004/05/20 23:13:02 christos Exp $);
+__RCSID($NetBSD: inet_net_pton.c,v 1.1.38.1 2011/03/20 21:32:38 bouyer Exp $);
 #endif
 #endif
 
@@ -145,12 +145,12 @@
 			INSIST(n = 0  n = 9);
 			bits *= 10;
 			bits += n;
+			if (bits  32)
+goto emsgsize;
 		} while ((ch = *src++) != '\0'  isascii((u_char)ch)
 		 isdigit((u_char)ch));
 		if (ch != '\0')
 			goto enoent;
-		if (bits  32)
-			goto emsgsize;
 	}
 
 	/* Firey death and destruction unless we prefetched EOS. */



CVS commit: [netbsd-5-1] src/lib/libc/inet

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 21:32:48 UTC 2011

Modified Files:
src/lib/libc/inet [netbsd-5-1]: inet_net_pton.c

Log Message:
Pull up following revision(s) (requested by spz in ticket #1574):
lib/libc/inet/inet_net_pton.c: revision 1.2
Check bits on each loop to prevent integer oveflow.
Reported by Maksymilian Arciemowicz


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.1.42.1 src/lib/libc/inet/inet_net_pton.c

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/inet/inet_net_pton.c
diff -u src/lib/libc/inet/inet_net_pton.c:1.1 src/lib/libc/inet/inet_net_pton.c:1.1.42.1
--- src/lib/libc/inet/inet_net_pton.c:1.1	Thu May 20 23:13:02 2004
+++ src/lib/libc/inet/inet_net_pton.c	Sun Mar 20 21:32:48 2011
@@ -20,7 +20,7 @@
 #if 0
 static const char rcsid[] = Id: inet_net_pton.c,v 1.4.2.1 2002/08/02 02:17:21 marka Exp ;
 #else
-__RCSID($NetBSD: inet_net_pton.c,v 1.1 2004/05/20 23:13:02 christos Exp $);
+__RCSID($NetBSD: inet_net_pton.c,v 1.1.42.1 2011/03/20 21:32:48 bouyer Exp $);
 #endif
 #endif
 
@@ -145,12 +145,12 @@
 			INSIST(n = 0  n = 9);
 			bits *= 10;
 			bits += n;
+			if (bits  32)
+goto emsgsize;
 		} while ((ch = *src++) != '\0'  isascii((u_char)ch)
 		 isdigit((u_char)ch));
 		if (ch != '\0')
 			goto enoent;
-		if (bits  32)
-			goto emsgsize;
 	}
 
 	/* Firey death and destruction unless we prefetched EOS. */



CVS commit: [netbsd-5] src/doc

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 21:33:13 UTC 2011

Modified Files:
src/doc [netbsd-5]: CHANGES-5.2

Log Message:
Tickets 1567 1568 1570 1571 1572 1574


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.66 -r1.1.2.67 src/doc/CHANGES-5.2

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

Modified files:

Index: src/doc/CHANGES-5.2
diff -u src/doc/CHANGES-5.2:1.1.2.66 src/doc/CHANGES-5.2:1.1.2.67
--- src/doc/CHANGES-5.2:1.1.2.66	Tue Mar  8 17:49:22 2011
+++ src/doc/CHANGES-5.2	Sun Mar 20 21:33:13 2011
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-5.2,v 1.1.2.66 2011/03/08 17:49:22 riz Exp $
+# $NetBSD: CHANGES-5.2,v 1.1.2.67 2011/03/20 21:33:13 bouyer Exp $
 
 A complete list of changes from the NetBSD 5.1 release to the NetBSD 5.2
 release:
@@ -4836,3 +4836,47 @@
 	Pass down INSTALLSETS variable to installsets target.
 	[jym, ticket #1565]
 
+sys/kern/vfs_syscalls.c1.415 via patch
+
+	Check for bogus flags to access() up front. Otherwise we end up
+	calling VOP_ACCESS with flags 0 and something asserts deep in the
+	bowels of kauth. PR 44648 from Taylor Campbell. (I moved the check
+	earlier relative to the suggested patch.)
+	[dholland, ticket #1567]
+
+lib/librefuse/refuse_opt.c			1.15
+
+	fuse_opt_parse() was using uninitialized struct fuse_opt_option::data,
+	this bug made fuse_opt_proc_t not work, if it used first ``data''
+	argument, and might cause memory corruption even.
+	[soda, ticket #1568]
+
+sys/arch/sparc64/dev/lom.c			1.7
+
+	lom_refresh():
+	Update only the sensor status specified by the edata as noted in
+	sysmon_envsys(9).
+	lom_sysctl_alarm():
+	Update alarm status before reading via sysctl to make it usable at
+	a boot time.
+	[nakayama, ticket #1570]
+
+sys/net/bpf_filter.c1.42 - 1.46 via patch
+
+	Avoid stack memory disclosure by keeping track during filter
+	validation time of initialized memory. Idea taken from linux.
+	Use kmem instead of malloc. Requested by rmind.
+	[spz, ticket #1571]
+
+sys/arch/mips/mips/fp.S1.40 via patch
+
+	Fix cvt.d.s per analysis by Marcus Comstedt in PR port-mips/36251.
+	Confirmed on ews4800mips.
+	[tsutsui, ticket #1572]
+
+lib/libc/inet/inet_net_pton.c			1.2
+
+	Check bits on each loop to prevent integer oveflow.
+	Reported by Maksymilian Arciemowicz
+	[spz, ticket #1574]
+



CVS commit: [netbsd-5-0] src/doc

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 21:33:41 UTC 2011

Modified Files:
src/doc [netbsd-5-0]: CHANGES-5.0.3

Log Message:
tickets 1567, 1574


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.29 -r1.1.2.30 src/doc/CHANGES-5.0.3

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

Modified files:

Index: src/doc/CHANGES-5.0.3
diff -u src/doc/CHANGES-5.0.3:1.1.2.29 src/doc/CHANGES-5.0.3:1.1.2.30
--- src/doc/CHANGES-5.0.3:1.1.2.29	Tue Mar  8 17:44:16 2011
+++ src/doc/CHANGES-5.0.3	Sun Mar 20 21:33:41 2011
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-5.0.3,v 1.1.2.29 2011/03/08 17:44:16 riz Exp $
+# $NetBSD: CHANGES-5.0.3,v 1.1.2.30 2011/03/20 21:33:41 bouyer Exp $
 
 A complete list of changes from the NetBSD 5.0.2 release to the NetBSD 5.0.3
 release:
@@ -2588,3 +2588,17 @@
 	Add keys directory for recently updated BIND.
 	[spz, ticket #1566]
 
+sys/kern/vfs_syscalls.c1.415 via patch
+
+	Check for bogus flags to access() up front. Otherwise we end up
+	calling VOP_ACCESS with flags 0 and something asserts deep in the
+	bowels of kauth. PR 44648 from Taylor Campbell. (I moved the check
+	earlier relative to the suggested patch.)
+	[dholland, ticket #1567]
+
+lib/libc/inet/inet_net_pton.c			1.2
+
+	Check bits on each loop to prevent integer oveflow.
+	Reported by Maksymilian Arciemowicz
+	[spz, ticket #1574]
+



CVS commit: [netbsd-5-1] src/doc

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 21:33:56 UTC 2011

Modified Files:
src/doc [netbsd-5-1]: CHANGES-5.1.1

Log Message:
tickets 1567, 1571, 1574


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.15 -r1.1.2.16 src/doc/CHANGES-5.1.1

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

Modified files:

Index: src/doc/CHANGES-5.1.1
diff -u src/doc/CHANGES-5.1.1:1.1.2.15 src/doc/CHANGES-5.1.1:1.1.2.16
--- src/doc/CHANGES-5.1.1:1.1.2.15	Tue Mar  8 17:43:34 2011
+++ src/doc/CHANGES-5.1.1	Sun Mar 20 21:33:56 2011
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-5.1.1,v 1.1.2.15 2011/03/08 17:43:34 riz Exp $
+# $NetBSD: CHANGES-5.1.1,v 1.1.2.16 2011/03/20 21:33:56 bouyer Exp $
 
 A complete list of changes from the NetBSD 5.1 release to the NetBSD 5.1.1
 release:
@@ -2280,3 +2280,24 @@
 	Add keys directory for recently updated BIND.
 	[spz, ticket #1566]
 
+sys/kern/vfs_syscalls.c1.415 via patch
+
+	Check for bogus flags to access() up front. Otherwise we end up
+	calling VOP_ACCESS with flags 0 and something asserts deep in the
+	bowels of kauth. PR 44648 from Taylor Campbell. (I moved the check
+	earlier relative to the suggested patch.)
+	[dholland, ticket #1567]
+
+sys/net/bpf_filter.c1.42 - 1.46 via patch
+
+	Avoid stack memory disclosure by keeping track during filter
+	validation time of initialized memory. Idea taken from linux.
+	Use kmem instead of malloc. Requested by rmind.
+	[spz, ticket #1571]
+
+lib/libc/inet/inet_net_pton.c			1.2
+
+	Check bits on each loop to prevent integer oveflow.
+	Reported by Maksymilian Arciemowicz
+	[spz, ticket #1574]
+



CVS commit: src/lib/libc/arch/x86_64/gdtoa

2011-03-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 20 23:16:07 UTC 2011

Modified Files:
src/lib/libc/arch/x86_64/gdtoa: gd_qnan.h

Log Message:
Add ld formats for the unit-tests.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libc/arch/x86_64/gdtoa/gd_qnan.h

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/arch/x86_64/gdtoa/gd_qnan.h
diff -u src/lib/libc/arch/x86_64/gdtoa/gd_qnan.h:1.1 src/lib/libc/arch/x86_64/gdtoa/gd_qnan.h:1.2
--- src/lib/libc/arch/x86_64/gdtoa/gd_qnan.h:1.1	Wed Jan 25 10:33:28 2006
+++ src/lib/libc/arch/x86_64/gdtoa/gd_qnan.h	Sun Mar 20 19:16:07 2011
@@ -1,8 +1,12 @@
-/* $NetBSD: gd_qnan.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */
+/* $NetBSD: gd_qnan.h,v 1.2 2011/03/20 23:16:07 christos Exp $ */
 
 #define f_QNAN 0x7fc0
 #define d_QNAN0 0x0
 #define d_QNAN1 0x7ff8
+#define ld_QNAN0 0x0
+#define ld_QNAN1 0xc000
+#define ld_QNAN2 0x7fff
+#define ld_QNAN3 0x0
 #define ldus_QNAN0 0x0
 #define ldus_QNAN1 0x0
 #define ldus_QNAN2 0x0



CVS commit: src/sys/kern

2011-03-20 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sun Mar 20 23:19:16 UTC 2011

Modified Files:
src/sys/kern: kern_lwp.c kern_mutex.c kern_rwlock.c

Log Message:
Optimise mutex_onproc() and rw_onproc() by making them O(1), instead
of O(ncpu) for adaptive paths.  Add an LWP destructor, lwp_dtor() with
a comment describing the principle of this barrier.

Reviewed by yamt@ and ad@.


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/sys/kern/kern_lwp.c
cvs rdiff -u -r1.49 -r1.50 src/sys/kern/kern_mutex.c
cvs rdiff -u -r1.36 -r1.37 src/sys/kern/kern_rwlock.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/kern/kern_lwp.c
diff -u src/sys/kern/kern_lwp.c:1.156 src/sys/kern/kern_lwp.c:1.157
--- src/sys/kern/kern_lwp.c:1.156	Mon Feb 21 20:23:28 2011
+++ src/sys/kern/kern_lwp.c	Sun Mar 20 23:19:16 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_lwp.c,v 1.156 2011/02/21 20:23:28 pooka Exp $	*/
+/*	$NetBSD: kern_lwp.c,v 1.157 2011/03/20 23:19:16 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -211,7 +211,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kern_lwp.c,v 1.156 2011/02/21 20:23:28 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: kern_lwp.c,v 1.157 2011/03/20 23:19:16 rmind Exp $);
 
 #include opt_ddb.h
 #include opt_lockdebug.h
@@ -240,6 +240,7 @@
 #include sys/filedesc.h
 #include sys/dtrace_bsd.h
 #include sys/sdt.h
+#include sys/xcall.h
 
 #include uvm/uvm_extern.h
 #include uvm/uvm_object.h
@@ -247,6 +248,8 @@
 static pool_cache_t	lwp_cache	__read_mostly;
 struct lwplist		alllwp		__cacheline_aligned;
 
+static void		lwp_dtor(void *, void *);
+
 /* DTrace proc provider probes */
 SDT_PROBE_DEFINE(proc,,,lwp_create,
 	struct lwp *, NULL,
@@ -293,7 +296,7 @@
 	lwpinit_specificdata();
 	lwp_sys_init();
 	lwp_cache = pool_cache_init(sizeof(lwp_t), MIN_LWP_ALIGNMENT, 0, 0,
-	lwppl, NULL, IPL_NONE, NULL, NULL, NULL);
+	lwppl, NULL, IPL_NONE, NULL, lwp_dtor, NULL);
 }
 
 void
@@ -318,6 +321,26 @@
 	SYSCALL_TIME_LWP_INIT(l);
 }
 
+static void
+lwp_dtor(void *arg, void *obj)
+{
+	lwp_t *l = obj;
+	uint64_t where;
+	(void)l;
+
+	/*
+	 * Provide a barrier to ensure that all mutex_oncpu() and rw_oncpu()
+	 * calls will exit before memory of LWP is returned to the pool, where
+	 * KVA of LWP structure might be freed and re-used for other purposes.
+	 * Kernel preemption is disabled around mutex_oncpu() and rw_oncpu()
+	 * callers, therefore cross-call to all CPUs will do the job.  Also,
+	 * the value of l-l_cpu must be still valid at this point.
+	 */
+	KASSERT(l-l_cpu != NULL);
+	where = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
+	xc_wait(where);
+}
+
 /*
  * Set an suspended.
  *

Index: src/sys/kern/kern_mutex.c
diff -u src/sys/kern/kern_mutex.c:1.49 src/sys/kern/kern_mutex.c:1.50
--- src/sys/kern/kern_mutex.c:1.49	Mon Feb  8 09:54:27 2010
+++ src/sys/kern/kern_mutex.c	Sun Mar 20 23:19:16 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_mutex.c,v 1.49 2010/02/08 09:54:27 skrll Exp $	*/
+/*	$NetBSD: kern_mutex.c,v 1.50 2011/03/20 23:19:16 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
 #define	__MUTEX_PRIVATE
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kern_mutex.c,v 1.49 2010/02/08 09:54:27 skrll Exp $);
+__KERNEL_RCSID(0, $NetBSD: kern_mutex.c,v 1.50 2011/03/20 23:19:16 rmind Exp $);
 
 #include sys/param.h
 #include sys/atomic.h
@@ -53,6 +53,7 @@
 #include sys/kernel.h
 #include sys/intr.h
 #include sys/lock.h
+#include sys/types.h
 
 #include dev/lockstat.h
 
@@ -249,9 +250,8 @@
 __strong_alias(mutex_spin_exit,mutex_vector_exit);
 #endif
 
-void	mutex_abort(kmutex_t *, const char *, const char *);
-void	mutex_dump(volatile void *);
-int	mutex_onproc(uintptr_t, struct cpu_info **);
+static void		mutex_abort(kmutex_t *, const char *, const char *);
+static void		mutex_dump(volatile void *);
 
 lockops_t mutex_spin_lockops = {
 	Mutex,
@@ -379,44 +379,40 @@
 	MUTEX_DESTROY(mtx);
 }
 
+#ifdef MULTIPROCESSOR
 /*
- * mutex_onproc:
+ * mutex_oncpu:
  *
  *	Return true if an adaptive mutex owner is running on a CPU in the
  *	system.  If the target is waiting on the kernel big lock, then we
  *	must release it.  This is necessary to avoid deadlock.
- *
- *	Note that we can't use the mutex owner field as an LWP pointer.  We
- *	don't have full control over the timing of our execution, and so the
- *	pointer could be completely invalid by the time we dereference it.
  */
-#ifdef MULTIPROCESSOR
-int
-mutex_onproc(uintptr_t owner, struct cpu_info **cip)
+static bool
+mutex_oncpu(uintptr_t owner)
 {
-	CPU_INFO_ITERATOR cii;
 	struct cpu_info *ci;
-	struct lwp *l;
+	lwp_t *l;
 
-	if (!MUTEX_OWNED(owner))
-		return 0;
-	l = (struct lwp *)MUTEX_OWNER(owner);
+	KASSERT(kpreempt_disabled());
 
-	/* See if the target is running on a CPU somewhere. */
-	if ((ci = *cip) != NULL  

CVS commit: src/doc

2011-03-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 20 23:19:35 UTC 2011

Modified Files:
src/doc: 3RDPARTY CHANGES

Log Message:
import latest


To generate a diff of this commit:
cvs rdiff -u -r1.823 -r1.824 src/doc/3RDPARTY
cvs rdiff -u -r1.1523 -r1.1524 src/doc/CHANGES

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

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.823 src/doc/3RDPARTY:1.824
--- src/doc/3RDPARTY:1.823	Sat Mar 19 13:12:12 2011
+++ src/doc/3RDPARTY	Sun Mar 20 19:19:35 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.823 2011/03/19 17:12:12 jakllsch Exp $
+#	$NetBSD: 3RDPARTY,v 1.824 2011/03/20 23:19:35 christos Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -293,8 +293,8 @@
 for the import.
 
 Package:	gdtoa
-Version:	2005-09-23
-Current Vers:	2005-09-23
+Version:	2011-03-19
+Current Vers:	$(date)
 Maintainer:	David M. Gay d...@acm.org
 Archive Site:	http://www.netlib.org/fp/
 Home Page:	http://www.netlib.org/fp/
@@ -302,7 +302,7 @@
 Responsible:	kleink
 License:	BSD-like
 Notes:
-Test suite not integrated at this time.
+Test suite integrated at this time, but not built (and fails to run).
 No hexadecimal floating-point string conversion for VAX FP yet.
 Only double-precision addressed at this time.
 

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.1523 src/doc/CHANGES:1.1524
--- src/doc/CHANGES:1.1523	Thu Mar 17 18:15:56 2011
+++ src/doc/CHANGES	Sun Mar 20 19:19:35 2011
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			$Revision: 1.1523 $
+# LIST OF CHANGES FROM LAST RELEASE:			$Revision: 1.1524 $
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -891,3 +891,4 @@
 	mips: add TLS (thread local storage) support.  [matt 20110314]
 	mips: add MIPS32R2 and MIPS64R2 support.  [matt 20110314]
 	hppa: add TLS support.  [skrll 20110317]
+	gdtoa: Import the latest [christos 20110319]



CVS commit: src/sys/arch/sparc64/conf

2011-03-20 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Mar 20 23:31:36 UTC 2011

Modified Files:
src/sys/arch/sparc64/conf: GENERIC

Log Message:
enable pci@pryo@mainbus and ebus@mainbus attachments.

pryo still isn't fully working, but i'm able to talk to disk and com
properly.  bge, ohci/ehci, aceride and wm (pcie card) interrupts
are not working yet.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/sys/arch/sparc64/conf/GENERIC

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/conf/GENERIC
diff -u src/sys/arch/sparc64/conf/GENERIC:1.134 src/sys/arch/sparc64/conf/GENERIC:1.135
--- src/sys/arch/sparc64/conf/GENERIC:1.134	Sun Mar  6 17:08:31 2011
+++ src/sys/arch/sparc64/conf/GENERIC	Sun Mar 20 23:31:36 2011
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.134 2011/03/06 17:08:31 bouyer Exp $
+# $NetBSD: GENERIC,v 1.135 2011/03/20 23:31:36 mrg Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		GENERIC-$Revision: 1.134 $
+#ident 		GENERIC-$Revision: 1.135 $
 
 maxusers	64
 
@@ -240,10 +240,13 @@
 sbus*	at mainbus0# SBus-based systems
 psycho*	at mainbus0# PCI-based systems
 schizo*	at mainbus?
+pyro*	at mainbus?
 pci*	at psycho?
 pci*	at schizo?
+pci*	at pyro?
 pci*	at ppb?
 ppb*	at pci?	# `APB' support.
+ebus*	at mainbus0# ebus devices
 ebus*	at pci?	# ebus devices
 # XXX 'puc's aren't really bridges, but there's no better place for them here
 puc*	at pci? dev ? function ?		# PCI universal comm. cards



CVS commit: src/tools/llvm

2011-03-20 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Mar 21 02:10:10 UTC 2011

Modified Files:
src/tools/llvm: Makefile

Log Message:
--with-clang-resource-dir is no longer needed


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tools/llvm/Makefile

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

Modified files:

Index: src/tools/llvm/Makefile
diff -u src/tools/llvm/Makefile:1.2 src/tools/llvm/Makefile:1.3
--- src/tools/llvm/Makefile:1.2	Fri Mar 18 23:32:04 2011
+++ src/tools/llvm/Makefile	Mon Mar 21 02:10:10 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.2 2011/03/18 23:32:04 joerg Exp $
+#	$NetBSD: Makefile,v 1.3 2011/03/21 02:10:10 joerg Exp $
 
 .include bsd.init.mk
 
@@ -21,7 +21,6 @@
 	mkdir -p config
 	cd config  ${LLVM_SRCDIR}/configure --prefix=/usr \
 	--enable-targets=x86 --host=x86_64--netbsd \
-	--with-clang-resource-dir=${DESTDIR}/usr/lib \
 	--enable-optimized --disable--assertions
 need-dl:
 	printf '#include dlfcn.h\nint main(void){void *p; return dladdr(p, p);}'  need-dl.c



CVS commit: src/lib/libc

2011-03-20 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Mon Mar 21 04:42:51 UTC 2011

Modified Files:
src/lib/libc/ssp: ssp.3
src/lib/libc/stdlib: alloca.3

Log Message:
Fix xref; security(8) - security(7).


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libc/ssp/ssp.3
cvs rdiff -u -r1.13 -r1.14 src/lib/libc/stdlib/alloca.3

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/ssp/ssp.3
diff -u src/lib/libc/ssp/ssp.3:1.5 src/lib/libc/ssp/ssp.3:1.6
--- src/lib/libc/ssp/ssp.3:1.5	Sun Dec 19 08:28:40 2010
+++ src/lib/libc/ssp/ssp.3	Mon Mar 21 04:42:50 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: ssp.3,v 1.5 2010/12/19 08:28:40 jruoho Exp $
+.\	$NetBSD: ssp.3,v 1.6 2011/03/21 04:42:50 jruoho Exp $
 .\
 .\ Copyright (c) 2007 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -28,7 +28,7 @@
 .\ POSSIBILITY OF SUCH DAMAGE.
 .\
 .\
-.Dd December 19, 2010
+.Dd March 21, 2011
 .Dt SSP 3
 .Os
 .Sh NAME
@@ -113,7 +113,7 @@
 .Xr __builtin_object_size 3 ,
 .Xr stdio 3 ,
 .Xr string 3 ,
-.Xr security 8
+.Xr security 7
 .Sh HISTORY
 The
 .Nm ssp

Index: src/lib/libc/stdlib/alloca.3
diff -u src/lib/libc/stdlib/alloca.3:1.13 src/lib/libc/stdlib/alloca.3:1.14
--- src/lib/libc/stdlib/alloca.3:1.13	Mon May  3 06:11:38 2010
+++ src/lib/libc/stdlib/alloca.3	Mon Mar 21 04:42:50 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: alloca.3,v 1.13 2010/05/03 06:11:38 jruoho Exp $
+.\	$NetBSD: alloca.3,v 1.14 2011/03/21 04:42:50 jruoho Exp $
 .\
 .\ Copyright (c) 1980, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ from: @(#)alloca.3	8.1 (Berkeley) 6/4/93
 .\
-.Dd May 3, 2010
+.Dd March 21, 2011
 .Dt ALLOCA 3
 .Os
 .Sh NAME
@@ -89,7 +89,7 @@
 modifies the stack at runtime,
 it causes problems to certain security features.
 See
-.Xr security 8
+.Xr security 7
 for a discussion.
 .El
 .\ .Sh HISTORY



CVS commit: src/lib/libc/gdtoa

2011-03-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar 21 04:52:09 UTC 2011

Modified Files:
src/lib/libc/gdtoa: gdtoaimp.h hexnan.c misc.c

Log Message:
fix some lint on i386


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/gdtoa/gdtoaimp.h
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/gdtoa/hexnan.c
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/gdtoa/misc.c

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/gdtoa/gdtoaimp.h
diff -u src/lib/libc/gdtoa/gdtoaimp.h:1.9 src/lib/libc/gdtoa/gdtoaimp.h:1.10
--- src/lib/libc/gdtoa/gdtoaimp.h:1.9	Sun Mar 20 19:15:35 2011
+++ src/lib/libc/gdtoa/gdtoaimp.h	Mon Mar 21 00:52:09 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: gdtoaimp.h,v 1.9 2011/03/20 23:15:35 christos Exp $ */
+/* $NetBSD: gdtoaimp.h,v 1.10 2011/03/21 04:52:09 christos Exp $ */
 
 /
 
@@ -581,7 +581,7 @@
  extern CONST double bigtens[], tens[], tinytens[];
  extern unsigned char hexdig[];
 
- extern Bigint *Balloc ANSI((size_t));
+ extern Bigint *Balloc ANSI((int));
  extern void Bfree ANSI((Bigint*));
  extern void ULtof ANSI((ULong*, ULong*, Long, int));
  extern void ULtod ANSI((ULong*, ULong*, Long, int));

Index: src/lib/libc/gdtoa/hexnan.c
diff -u src/lib/libc/gdtoa/hexnan.c:1.4 src/lib/libc/gdtoa/hexnan.c:1.5
--- src/lib/libc/gdtoa/hexnan.c:1.4	Sun Mar 20 19:15:35 2011
+++ src/lib/libc/gdtoa/hexnan.c	Mon Mar 21 00:52:09 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: hexnan.c,v 1.4 2011/03/20 23:15:35 christos Exp $ */
+/* $NetBSD: hexnan.c,v 1.5 2011/03/21 04:52:09 christos Exp $ */
 
 /
 
@@ -79,7 +79,7 @@
 	if (s[1] == '0'  (s[2] == 'x' || s[2] == 'X')
 	  *(CONST unsigned char*)(s+3)  ' ')
 		s += 2;
-	while((c = *(CONST unsigned char*)++s)) {
+	while((c = *(CONST unsigned char*)++s) != '\0') {
 		if (!(h = hexdig[c])) {
 			if (c = ' ') {
 if (hd0  havedig) {
@@ -111,7 +111,7 @@
 	*sp = s + 1;
 	break;
 	}
-} while((c = *++s));
+} while((c = *++s) != '\0');
 #endif
 			return STRTOG_NaN;
 			}

Index: src/lib/libc/gdtoa/misc.c
diff -u src/lib/libc/gdtoa/misc.c:1.6 src/lib/libc/gdtoa/misc.c:1.7
--- src/lib/libc/gdtoa/misc.c:1.6	Sun Mar 20 19:15:35 2011
+++ src/lib/libc/gdtoa/misc.c	Mon Mar 21 00:52:09 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: misc.c,v 1.6 2011/03/20 23:15:35 christos Exp $ */
+/* $NetBSD: misc.c,v 1.7 2011/03/21 04:52:09 christos Exp $ */
 
 /
 
@@ -45,9 +45,9 @@
  Bigint *
 Balloc
 #ifdef KR_headers
-	(k) size_t k;
+	(k) int k;
 #else
-	(size_t k)
+	(int k)
 #endif
 {
 	int x;
@@ -59,17 +59,17 @@
 	ACQUIRE_DTOA_LOCK(0);
 	/* The k  Kmax case does not need ACQUIRE_DTOA_LOCK(0), */
 	/* but this case seems very unlikely. */
-	if (k = Kmax  (rv = freelist[k]) !=0) {
+	if ((size_t)k = Kmax  (rv = freelist[k]) !=0) {
 		freelist[k] = rv-next;
 		}
 	else {
-		x = 1  (int)k;
+		x = 1  k;
 #ifdef Omit_Private_Memory
 		rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong));
 #else
 		len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1)
 			/sizeof(double);
-		if (k = Kmax  pmem_next - private_mem + len = PRIVATE_mem) {
+		if ((size_t)k = Kmax  pmem_next - private_mem + len = PRIVATE_mem) {
 			rv = (Bigint*)(void *)pmem_next;
 			pmem_next += len;
 			}
@@ -78,7 +78,7 @@
 #endif
 		if (rv == NULL)
 			return NULL;
-		rv-k = (int)k;
+		rv-k = k;
 		rv-maxwds = x;
 		}
 	FREE_DTOA_LOCK(0);



CVS commit: src/usr.sbin/crash

2011-03-20 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Mar 21 05:09:34 UTC 2011

Modified Files:
src/usr.sbin/crash: Makefile

Log Message:
Create vers.c with -r, there is no point in embedding an ever changing
token that isn't even used.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/crash/Makefile

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

Modified files:

Index: src/usr.sbin/crash/Makefile
diff -u src/usr.sbin/crash/Makefile:1.5 src/usr.sbin/crash/Makefile:1.6
--- src/usr.sbin/crash/Makefile:1.5	Fri Apr 23 02:10:01 2010
+++ src/usr.sbin/crash/Makefile	Mon Mar 21 05:09:33 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.5 2010/04/23 02:10:01 christos Exp $
+#	$NetBSD: Makefile,v 1.6 2011/03/21 05:09:33 joerg Exp $
 
 PROG=	crash
 MAN=	crash.8
@@ -49,7 +49,7 @@
 # vers.c
 SRCS+=	vers.c
 vers.c:	${S}/conf/newvers.sh
-	${HOST_SH} ${S}/conf/newvers.sh
+	${HOST_SH} ${S}/conf/newvers.sh -r
 CLEANFILES+=	vers.c version
 
 .endif



CVS commit: src/sys/rump/librump/rumpkern

2011-03-20 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Mar 21 05:15:18 UTC 2011

Modified Files:
src/sys/rump/librump/rumpkern: Makefile.rumpkern

Log Message:
Include bsd.own.mk before making decisions based on mk.conf.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/rump/librump/rumpkern/Makefile.rumpkern

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/librump/rumpkern/Makefile.rumpkern
diff -u src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.107 src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.108
--- src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.107	Mon Jan 17 16:20:20 2011
+++ src/sys/rump/librump/rumpkern/Makefile.rumpkern	Mon Mar 21 05:15:18 2011
@@ -1,8 +1,10 @@
-#	$NetBSD: Makefile.rumpkern,v 1.107 2011/01/17 16:20:20 pooka Exp $
+#	$NetBSD: Makefile.rumpkern,v 1.108 2011/03/21 05:15:18 joerg Exp $
 #
 
 .include ${RUMPTOP}/Makefile.rump
 
+.include bsd.own.mk
+
 LIB=		rump
 
 .PATH:	${RUMPTOP}/librump/rumpkern\



CVS commit: othersrc/crypto/external/bsd/ssss

2011-03-20 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Mon Mar 21 05:43:38 UTC 2011

Update of /cvsroot/othersrc/crypto/external/bsd/
In directory ivanova.netbsd.org:/tmp/cvs-serv27364

Log Message:
Initial import of alternative threshold code to othersrc/crypto to
perform Shamir's Secret Sharing Scheme.

For more information on Sharmir's Secret Sharing Scheme ( or S4),
please see:

http://en.wikipedia.org/wiki/Shamir's_Secret_Sharing

To re-iterate: this is a threshold scheme where an original secret is
split into shares. When a threshold of shares is presented, the original
secret can be reconstructed.

This is closely related to the threshold routines previously imported
into othersrc; the difference is that this code does not reveal any of
the information in the original secret until a threshold of shares is
presented. Compared to IDA, for example, an  share is the same size
as the original data (compared to originalsize / threshold for IDA), but
provides privacy which IDA does not do.

This implementation of  keeps the same interface as the threshold(1)
and libthreshold(3), for convenience sake.


Status:

Vendor Tag: CROOKS
Release Tags:   -base

N othersrc/crypto/external/bsd//Makefile
N othersrc/crypto/external/bsd//mkdist
N othersrc/crypto/external/bsd//Makefile.inc
N othersrc/crypto/external/bsd//dist/Makefile.am
N othersrc/crypto/external/bsd//dist/TODO
N othersrc/crypto/external/bsd//dist/aclocal.m4
N othersrc/crypto/external/bsd//dist/configure
N othersrc/crypto/external/bsd//dist/configure.ac
N othersrc/crypto/external/bsd//dist/libtool
N othersrc/crypto/external/bsd//dist/tst
N othersrc/crypto/external/bsd//dist/buildaux/config.guess
N othersrc/crypto/external/bsd//dist/buildaux/config.sub
N othersrc/crypto/external/bsd//dist/buildaux/depcomp
N othersrc/crypto/external/bsd//dist/buildaux/install-sh
N othersrc/crypto/external/bsd//dist/buildaux/ltmain.sh
N othersrc/crypto/external/bsd//dist/buildaux/missing
N othersrc/crypto/external/bsd//dist/include/.h
N othersrc/crypto/external/bsd//dist/include/Makefile.am
N othersrc/crypto/external/bsd//dist/src/Makefile.am
N othersrc/crypto/external/bsd//dist/src/Makefile.in
N othersrc/crypto/external/bsd//dist/src//.1
N othersrc/crypto/external/bsd//dist/src//Makefile.am
N othersrc/crypto/external/bsd//dist/src//Makefile.in
N othersrc/crypto/external/bsd//dist/src//main.c
N othersrc/crypto/external/bsd//dist/src/lib/Makefile.am
N othersrc/crypto/external/bsd//dist/src/lib/Makefile.in
N othersrc/crypto/external/bsd//dist/src/lib/config.h.in
N othersrc/crypto/external/bsd//dist/src/lib/internal.h
N othersrc/crypto/external/bsd//dist/src/lib/lib.3
N othersrc/crypto/external/bsd//dist/src/lib/secsplit.c
N othersrc/crypto/external/bsd//dist/src/lib/threshold.c
N othersrc/crypto/external/bsd//dist/autom4te.cache/requests
N othersrc/crypto/external/bsd//dist/autom4te.cache/output.0
N othersrc/crypto/external/bsd//dist/autom4te.cache/traces.0
N othersrc/crypto/external/bsd///Makefile
N othersrc/crypto/external/bsd//lib/shlib_version
N othersrc/crypto/external/bsd//lib/Makefile
N othersrc/crypto/external/bsd//lib/config.h

No conflicts created by this import