CVS commit: src/compat

2021-05-30 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon May 31 02:10:37 UTC 2021

Modified Files:
src/compat: exec.mk

Log Message:
MIPS n64 dynamic binaries have worked for a while now, remove -static
for these.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/compat/exec.mk

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

Modified files:

Index: src/compat/exec.mk
diff -u src/compat/exec.mk:1.5 src/compat/exec.mk:1.6
--- src/compat/exec.mk:1.5	Tue Jan  5 11:08:00 2021
+++ src/compat/exec.mk	Mon May 31 02:10:37 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: exec.mk,v 1.5 2021/01/05 11:08:00 simonb Exp $
+#	$NetBSD: exec.mk,v 1.6 2021/05/31 02:10:37 simonb Exp $
 
 # this makefile fragment can be included to modify the default
 # ABI a program is compiled with.  this is designed to be used
@@ -34,8 +34,6 @@
 
 # XXX -pie makes n64 crash
 NOPIE=1
-# XXX interesting dynamic binaries crash (hello.c works.)
-LDSTATIC=-static
 
 . include 
 



CVS commit: src/external/mit/xorg/server/drivers/xf86-video-geode

2021-05-30 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon May 31 00:04:15 UTC 2021

Modified Files:
src/external/mit/xorg/server/drivers/xf86-video-geode: Makefile

Log Message:
Use -fcommon


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/external/mit/xorg/server/drivers/xf86-video-geode/Makefile

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

Modified files:

Index: src/external/mit/xorg/server/drivers/xf86-video-geode/Makefile
diff -u src/external/mit/xorg/server/drivers/xf86-video-geode/Makefile:1.6 src/external/mit/xorg/server/drivers/xf86-video-geode/Makefile:1.7
--- src/external/mit/xorg/server/drivers/xf86-video-geode/Makefile:1.6	Tue Jan  1 00:37:06 2019
+++ src/external/mit/xorg/server/drivers/xf86-video-geode/Makefile	Mon May 31 00:04:15 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.6 2019/01/01 00:37:06 mrg Exp $
+#	$NetBSD: Makefile,v 1.7 2021/05/31 00:04:15 joerg Exp $
 
 DRIVER=		xf86-video-geode
 DRIVER_NAME=	geode_drv
@@ -54,6 +54,8 @@ COPTS.lx_panel.c+=	-Wno-error	# XXX
 
 CWARNFLAGS.clang+=	-Wno-empty-body
 
+COPTS+=		-fcommon
+
 .include "../Makefile.xf86-driver"
 
 XORG_PKG_VER_PROG=	${DRIVER}



CVS commit: src/external/mit/xorg/server/drivers

2021-05-30 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun May 30 22:24:36 UTC 2021

Modified Files:
src/external/mit/xorg/server/drivers/xf86-video-amdgpu: Makefile
src/external/mit/xorg/server/drivers/xf86-video-intel: Makefile
src/external/mit/xorg/server/drivers/xf86-video-openchrome: Makefile
src/external/mit/xorg/server/drivers/xf86-video-radeon-kms: Makefile

Log Message:
Various X drivers still need -fcommon, so add it.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/external/mit/xorg/server/drivers/xf86-video-amdgpu/Makefile
cvs rdiff -u -r1.33 -r1.34 \
src/external/mit/xorg/server/drivers/xf86-video-intel/Makefile
cvs rdiff -u -r1.16 -r1.17 \
src/external/mit/xorg/server/drivers/xf86-video-openchrome/Makefile
cvs rdiff -u -r1.12 -r1.13 \
src/external/mit/xorg/server/drivers/xf86-video-radeon-kms/Makefile

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

Modified files:

Index: src/external/mit/xorg/server/drivers/xf86-video-amdgpu/Makefile
diff -u src/external/mit/xorg/server/drivers/xf86-video-amdgpu/Makefile:1.1 src/external/mit/xorg/server/drivers/xf86-video-amdgpu/Makefile:1.2
--- src/external/mit/xorg/server/drivers/xf86-video-amdgpu/Makefile:1.1	Thu Aug 18 07:49:09 2016
+++ src/external/mit/xorg/server/drivers/xf86-video-amdgpu/Makefile	Sun May 30 22:24:35 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1 2016/08/18 07:49:09 mrg Exp $
+#	$NetBSD: Makefile,v 1.2 2021/05/30 22:24:35 joerg Exp $
 
 .include 
 
@@ -25,6 +25,7 @@ CPPFLAGS+=	-I${DESTDIR}${X11INCDIR}/X11 
 		-I${X11SRCDIR.${DRIVER}}/../include
 
 # XXX
-COPTS+=	-Wno-error
+COPTS+=		-Wno-error
+COPTS+=		-fcommon
 
 .include "../Makefile.xf86-driver"

Index: src/external/mit/xorg/server/drivers/xf86-video-intel/Makefile
diff -u src/external/mit/xorg/server/drivers/xf86-video-intel/Makefile:1.33 src/external/mit/xorg/server/drivers/xf86-video-intel/Makefile:1.34
--- src/external/mit/xorg/server/drivers/xf86-video-intel/Makefile:1.33	Mon Sep  7 00:24:37 2020
+++ src/external/mit/xorg/server/drivers/xf86-video-intel/Makefile	Sun May 30 22:24:35 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.33 2020/09/07 00:24:37 mrg Exp $
+#	$NetBSD: Makefile,v 1.34 2021/05/30 22:24:35 joerg Exp $
 
 .include 
 
@@ -218,6 +218,8 @@ SRCS+=		i810_xaa.c
 CWARNFLAGS.clang+=	-Wno-parentheses -Wno-tautological-compare \
 			-Wno-empty-body -Wno-error
 
+COPTS+=	-fcommon
+
 COPTS.sna_display.c+=	-Wno-stack-protector
 COPTS.sna_threads.c+=	-Wno-stack-protector
 COPTS.sna_trapezoids.c+=	-Wno-stack-protector

Index: src/external/mit/xorg/server/drivers/xf86-video-openchrome/Makefile
diff -u src/external/mit/xorg/server/drivers/xf86-video-openchrome/Makefile:1.16 src/external/mit/xorg/server/drivers/xf86-video-openchrome/Makefile:1.17
--- src/external/mit/xorg/server/drivers/xf86-video-openchrome/Makefile:1.16	Tue Jan  1 00:37:06 2019
+++ src/external/mit/xorg/server/drivers/xf86-video-openchrome/Makefile	Sun May 30 22:24:36 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.16 2019/01/01 00:37:06 mrg Exp $
+#	$NetBSD: Makefile,v 1.17 2021/05/30 22:24:36 joerg Exp $
 
 DRIVER=		xf86-video-openchrome
 DRIVER_NAME=	openchrome_drv
@@ -43,6 +43,8 @@ CPPFLAGS+=	-I${X11SRCDIR.${DRIVER}}/src
 CPPFLAGS+=	-DHAVE_CONFIG_H -I${X11SRCDIR.${DRIVER}}/../include
 CPPFLAGS+=	-DHAVE_XF86_CURSOR_RESET_CURSOR
 
+COPTS+=	-fcommon
+
 .include "../Makefile.xf86-driver"
 
 # XXX

Index: src/external/mit/xorg/server/drivers/xf86-video-radeon-kms/Makefile
diff -u src/external/mit/xorg/server/drivers/xf86-video-radeon-kms/Makefile:1.12 src/external/mit/xorg/server/drivers/xf86-video-radeon-kms/Makefile:1.13
--- src/external/mit/xorg/server/drivers/xf86-video-radeon-kms/Makefile:1.12	Sun Feb  9 12:28:28 2020
+++ src/external/mit/xorg/server/drivers/xf86-video-radeon-kms/Makefile	Sun May 30 22:24:36 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.12 2020/02/09 12:28:28 jmcneill Exp $
+#	$NetBSD: Makefile,v 1.13 2021/05/30 22:24:36 joerg Exp $
 
 .include 
 
@@ -61,4 +61,6 @@ CPPFLAGS+=	-I${DESTDIR}${X11INCDIR}/X11 
 
 LIBDPLIBS+=	gbm ${.CURDIR}/../../../lib/libgbm${OLD_PREFIX}
 
+COPTS+=		-fcommon
+
 .include "../Makefile.xf86-driver"



CVS commit: src/external/bsd/tcpdump/dist

2021-05-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 30 21:48:42 UTC 2021

Modified Files:
src/external/bsd/tcpdump/dist: print-icmp6.c

Log Message:
Minimal change to suppress unaligned access errors on NetBSD/alpha; add
the UNALIGNED decoration to icmp6 related structures.

PR bin/56199.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/external/bsd/tcpdump/dist/print-icmp6.c

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

Modified files:

Index: src/external/bsd/tcpdump/dist/print-icmp6.c
diff -u src/external/bsd/tcpdump/dist/print-icmp6.c:1.13 src/external/bsd/tcpdump/dist/print-icmp6.c:1.14
--- src/external/bsd/tcpdump/dist/print-icmp6.c:1.13	Mon Feb 24 18:39:47 2020
+++ src/external/bsd/tcpdump/dist/print-icmp6.c	Sun May 30 21:48:42 2021
@@ -21,7 +21,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: print-icmp6.c,v 1.13 2020/02/24 18:39:47 kamil Exp $");
+__RCSID("$NetBSD: print-icmp6.c,v 1.14 2021/05/30 21:48:42 thorpej Exp $");
 #endif
 
 /* \summary: IPv6 Internet Control Message Protocol (ICMPv6) printer */
@@ -91,7 +91,7 @@ struct icmp6_hdr {
 		uint16_t	icmp6_un_data16[2]; /* type-specific field */
 		uint8_t		icmp6_un_data8[4];  /* type-specific field */
 	} icmp6_dataun;
-};
+} UNALIGNED;
 
 #define icmp6_data32	icmp6_dataun.icmp6_un_data32
 #define icmp6_data16	icmp6_dataun.icmp6_un_data16
@@ -183,7 +183,7 @@ struct icmp6_hdr {
 struct mld6_hdr {
 	struct icmp6_hdr	mld6_hdr;
 	struct in6_addr		mld6_addr; /* multicast address */
-};
+} UNALIGNED;
 
 #define mld6_type	mld6_hdr.icmp6_type
 #define mld6_code	mld6_hdr.icmp6_code
@@ -201,7 +201,7 @@ struct mld6_hdr {
 struct nd_router_solicit {	/* router solicitation */
 	struct icmp6_hdr 	nd_rs_hdr;
 	/* could be followed by options */
-};
+} UNALIGNED;
 
 #define nd_rs_type	nd_rs_hdr.icmp6_type
 #define nd_rs_code	nd_rs_hdr.icmp6_code
@@ -213,7 +213,7 @@ struct nd_router_advert {	/* router adve
 	uint32_t		nd_ra_reachable;	/* reachable time */
 	uint32_t		nd_ra_retransmit;	/* retransmit timer */
 	/* could be followed by options */
-};
+} UNALIGNED;
 
 #define nd_ra_type		nd_ra_hdr.icmp6_type
 #define nd_ra_code		nd_ra_hdr.icmp6_code
@@ -241,7 +241,7 @@ struct nd_neighbor_solicit {	/* neighbor
 	struct icmp6_hdr	nd_ns_hdr;
 	struct in6_addr		nd_ns_target;	/*target address */
 	/* could be followed by options */
-};
+} UNALIGNED;
 
 #define nd_ns_type		nd_ns_hdr.icmp6_type
 #define nd_ns_code		nd_ns_hdr.icmp6_code
@@ -252,7 +252,7 @@ struct nd_neighbor_advert {	/* neighbor 
 	struct icmp6_hdr	nd_na_hdr;
 	struct in6_addr		nd_na_target;	/* target address */
 	/* could be followed by options */
-};
+} UNALIGNED;
 
 #define nd_na_type		nd_na_hdr.icmp6_type
 #define nd_na_code		nd_na_hdr.icmp6_code
@@ -268,7 +268,7 @@ struct nd_redirect {		/* redirect */
 	struct in6_addr		nd_rd_target;	/* target address */
 	struct in6_addr		nd_rd_dst;	/* destination address */
 	/* could be followed by options */
-};
+} UNALIGNED;
 
 #define nd_rd_type		nd_rd_hdr.icmp6_type
 #define nd_rd_code		nd_rd_hdr.icmp6_code
@@ -301,7 +301,7 @@ struct nd_opt_prefix_info {	/* prefix in
 	nd_uint32_t		nd_opt_pi_preferred_time;
 	nd_uint32_t		nd_opt_pi_reserved2;
 	struct in6_addr	nd_opt_pi_prefix;
-};
+} UNALIGNED;
 
 #define ND_OPT_PI_FLAG_ONLINK		0x80
 #define ND_OPT_PI_FLAG_AUTO		0x40
@@ -313,14 +313,14 @@ struct nd_opt_rd_hdr { /* redire
 	uint16_t	nd_opt_rh_reserved1;
 	uint32_t	nd_opt_rh_reserved2;
 	/* followed by IP header and data */
-};
+} UNALIGNED;
 
 struct nd_opt_mtu {		/* MTU option */
 	uint8_t		nd_opt_mtu_type;
 	uint8_t		nd_opt_mtu_len;
 	uint16_t	nd_opt_mtu_reserved;
 	uint32_t	nd_opt_mtu_mtu;
-};
+} UNALIGNED;
 
 struct nd_opt_rdnss {		/* RDNSS RFC 6106 5.1 */
 	uint8_t		nd_opt_rdnss_type;
@@ -328,7 +328,7 @@ struct nd_opt_rdnss {		/* RDNSS RFC 6106
 	uint16_t	nd_opt_rdnss_reserved;
 	uint32_t	nd_opt_rdnss_lifetime;
 	struct in6_addr nd_opt_rdnss_addr[1];	/* variable-length */
-};
+} UNALIGNED;
 
 struct nd_opt_dnssl {		/* DNSSL RFC 6106 5.2 */
 	uint8_t  nd_opt_dnssl_type;
@@ -336,14 +336,14 @@ struct nd_opt_dnssl {		/* DNSSL RFC 6106
 	uint16_t nd_opt_dnssl_reserved;
 	uint32_t nd_opt_dnssl_lifetime;
 	/* followed by list of DNS search domains, variable-length */
-};
+} UNALIGNED;
 
 struct nd_opt_advinterval {	/* Advertisement interval option */
 	uint8_t		nd_opt_adv_type;
 	uint8_t		nd_opt_adv_len;
 	uint16_t	nd_opt_adv_reserved;
 	uint32_t	nd_opt_adv_interval;
-};
+} UNALIGNED;
 
 struct nd_opt_homeagent_info {	/* Home Agent info */
 	uint8_t		nd_opt_hai_type;
@@ -351,7 +351,7 @@ struct nd_opt_homeagent_info {	/* Home A
 	uint16_t	nd_opt_hai_reserved;
 	int16_t		nd_opt_hai_preference;
 	uint16_t	nd_opt_hai_lifetime;
-};
+} UNALIGNED;
 
 struct nd_opt_route_info {	/* route info */
 	uint8_t		nd_opt_rti_type;
@@ -360,7 +360,7 @@ struct nd_opt_route_info {	/* route info
 	uint8_t		nd_opt_rti_flags;
 	uint32_t	nd_opt_rti_lifetime;
 	/* prefix 

CVS commit: src/usr.bin/make

2021-05-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 30 21:16:54 UTC 2021

Modified Files:
src/usr.bin/make: arch.c str.c str.h

Log Message:
make: inline str_concat4

This function is only ever used for forming strings of the form
"archive(member)".

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.199 -r1.200 src/usr.bin/make/arch.c
cvs rdiff -u -r1.84 -r1.85 src/usr.bin/make/str.c
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/str.h

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

Modified files:

Index: src/usr.bin/make/arch.c
diff -u src/usr.bin/make/arch.c:1.199 src/usr.bin/make/arch.c:1.200
--- src/usr.bin/make/arch.c:1.199	Sat Apr  3 11:08:40 2021
+++ src/usr.bin/make/arch.c	Sun May 30 21:16:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.199 2021/04/03 11:08:40 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.200 2021/05/30 21:16:54 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #include "config.h"
 
 /*	"@(#)arch.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: arch.c,v 1.199 2021/04/03 11:08:40 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.200 2021/05/30 21:16:54 rillig Exp $");
 
 typedef struct List ArchList;
 typedef struct ListNode ArchListNode;
@@ -148,6 +148,7 @@ static FILE *ArchFindMember(const char *
 static int ArchSVR4Entry(Arch *, char *, size_t, FILE *);
 #endif
 
+
 #ifdef CLEANUP
 static void
 ArchFree(void *ap)
@@ -167,6 +168,19 @@ ArchFree(void *ap)
 }
 #endif
 
+/* Return "archive(member)". */
+static char *
+FullName(const char *archive, const char *member)
+{
+	size_t len1 = strlen(archive);
+	size_t len3 = strlen(member);
+	char *result = bmake_malloc(len1 + 1 + len3 + 1 + 1);
+	memcpy(result, archive, len1);
+	memcpy(result + len1, "(", 1);
+	memcpy(result + len1 + 1, member, len3);
+	memcpy(result + len1 + 1 + len3, ")", 1 + 1);
+	return result;
+}
 
 /*
  * Parse an archive specification such as "archive.a(member1 member2.${EXT})",
@@ -312,7 +326,7 @@ Arch_ParseArchive(char **pp, GNodeList *
 			 * Now form an archive spec and recurse to deal with
 			 * nested variables and multi-word variable values.
 			 */
-			fullName = str_concat4(libName.str, "(", memName, ")");
+			fullName = FullName(libName.str, memName);
 			p = fullName;
 
 			if (strchr(memName, '$') != NULL &&
@@ -342,8 +356,7 @@ Arch_ParseArchive(char **pp, GNodeList *
 
 			while (!Lst_IsEmpty(&members)) {
 char *member = Lst_Dequeue(&members);
-char *fullname = str_concat4(libName.str, "(",
-			 member, ")");
+char *fullname = FullName(libName.str, member);
 free(member);
 
 gn = Targ_GetNode(fullname);
@@ -355,8 +368,7 @@ Arch_ParseArchive(char **pp, GNodeList *
 			Lst_Done(&members);
 
 		} else {
-			char *fullname = str_concat4(libName.str, "(", memName,
-		 ")");
+			char *fullname = FullName(libName.str, memName);
 			gn = Targ_GetNode(fullname);
 			free(fullname);
 

Index: src/usr.bin/make/str.c
diff -u src/usr.bin/make/str.c:1.84 src/usr.bin/make/str.c:1.85
--- src/usr.bin/make/str.c:1.84	Sun Apr 11 19:05:06 2021
+++ src/usr.bin/make/str.c	Sun May 30 21:16:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: str.c,v 1.84 2021/04/11 19:05:06 rillig Exp $	*/
+/*	$NetBSD: str.c,v 1.85 2021/05/30 21:16:54 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -71,7 +71,7 @@
 #include "make.h"
 
 /*	"@(#)str.c	5.8 (Berkeley) 6/1/90"	*/
-MAKE_RCSID("$NetBSD: str.c,v 1.84 2021/04/11 19:05:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: str.c,v 1.85 2021/05/30 21:16:54 rillig Exp $");
 
 /* Return the concatenation of s1 and s2, freshly allocated. */
 char *
@@ -99,22 +99,6 @@ str_concat3(const char *s1, const char *
 	return result;
 }
 
-/* Return the concatenation of s1, s2, s3 and s4, freshly allocated. */
-char *
-str_concat4(const char *s1, const char *s2, const char *s3, const char *s4)
-{
-	size_t len1 = strlen(s1);
-	size_t len2 = strlen(s2);
-	size_t len3 = strlen(s3);
-	size_t len4 = strlen(s4);
-	char *result = bmake_malloc(len1 + len2 + len3 + len4 + 1);
-	memcpy(result, s1, len1);
-	memcpy(result + len1, s2, len2);
-	memcpy(result + len1 + len2, s3, len3);
-	memcpy(result + len1 + len2 + len3, s4, len4 + 1);
-	return result;
-}
-
 /*
  * Fracture a string into an array of words (as delineated by tabs or spaces)
  * taking quotation marks into account.

Index: src/usr.bin/make/str.h
diff -u src/usr.bin/make/str.h:1.8 src/usr.bin/make/str.h:1.9
--- src/usr.bin/make/str.h:1.8	Wed Apr 14 17:39:11 2021
+++ src/usr.bin/make/str.h	Sun May 30 21:16:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: str.h,v 1.8 2021/04/14 17:39:11 rillig Exp $	*/
+/*	$NetBSD: str.h,v 1.9 2021/05/30 21:16:54 rillig Exp $	*/
 
 /*
  Copyright (c) 2021 Roland Illig 
@@ -362,6 +362,5 @@ SubstringWords_Free(SubstringWords w)
 
 char *str_concat2(const char *, const char *);
 char *str_concat3(const char *, const char *, const char *);
-char *str_concat4(const char *, cons

CVS commit: src/usr.bin/make

2021-05-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 30 21:03:09 UTC 2021

Modified Files:
src/usr.bin/make: Makefile

Log Message:
make: fix reported code coverage for *.h

In 'make test-coverage', the number of uncovered lines for inline
functions in headers was reported too high.  The cause for this is that
gcov reports the coverage for these functions multiple times, once per
translation unit.  If some of the translation units don't use these
inline functions, summing the lines containing '#' quickly leads to
numbers that are obviously too high.


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/usr.bin/make/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.bin/make/Makefile
diff -u src/usr.bin/make/Makefile:1.114 src/usr.bin/make/Makefile:1.115
--- src/usr.bin/make/Makefile:1.114	Sun Apr 11 11:41:27 2021
+++ src/usr.bin/make/Makefile	Sun May 30 21:03:08 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.114 2021/04/11 11:41:27 rillig Exp $
+#	$NetBSD: Makefile,v 1.115 2021/05/30 21:03:08 rillig Exp $
 #	@(#)Makefile	5.2 (Berkeley) 12/28/90
 
 PROG=	make
@@ -35,8 +35,11 @@ GCOV_PERL+=	} elsif (/^Function '(\S+)'/
 GCOV_PERL+=		$$func = $$1;
 GCOV_PERL+=	} elsif (/^Lines executed:(\d+\.\d+)% of (\d+)/ && defined($$file)) {
 GCOV_PERL+=		my ($$percent, $$lines) = ($$1, $$2);
-GCOV_PERL+=		my $$uncovered = `grep -c '\#\#\#\#\#:' < \$$(basename $$file.gcov)`;
-GCOV_PERL+=		printf("%7.2f  %4d/%4d  %s%s\n",
+GCOV_PERL+=		my $$uncovered = $$file =~ /\.h$$/
+GCOV_PERL+=		? '?'
+GCOV_PERL+=		: `grep -c '\#\#\#\#\#:' < \$$(basename $$file.gcov)`;
+GCOV_PERL+=		chomp($$uncovered);
+GCOV_PERL+=		printf("%7.2f  %4s/%4d  %s%s\n",
 GCOV_PERL+=		$$percent, $$uncovered, $$lines, $$file, $$func);
 GCOV_PERL+=		$$file = undef;
 GCOV_PERL+=	}



CVS commit: src/external/bsd/tcpdump/dist

2021-05-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 30 21:01:43 UTC 2021

Modified Files:
src/external/bsd/tcpdump/dist: print-icmp.c

Log Message:
Minimal change to suppress unaligned access errors on NetBSD/alpha; add
the UNALIGNED decoration to struct icmp.

PR bin/56199.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/tcpdump/dist/print-icmp.c

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

Modified files:

Index: src/external/bsd/tcpdump/dist/print-icmp.c
diff -u src/external/bsd/tcpdump/dist/print-icmp.c:1.11 src/external/bsd/tcpdump/dist/print-icmp.c:1.12
--- src/external/bsd/tcpdump/dist/print-icmp.c:1.11	Mon Feb 24 18:39:47 2020
+++ src/external/bsd/tcpdump/dist/print-icmp.c	Sun May 30 21:01:43 2021
@@ -21,7 +21,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: print-icmp.c,v 1.11 2020/02/24 18:39:47 kamil Exp $");
+__RCSID("$NetBSD: print-icmp.c,v 1.12 2021/05/30 21:01:43 thorpej Exp $");
 #endif
 
 /* \summary: Internet Control Message Protocol (ICMP) printer */
@@ -89,7 +89,7 @@ struct icmp {
 #define	icmp_ip		icmp_dun.id_ip.idi_ip
 #define	icmp_mask	icmp_dun.id_mask
 #define	icmp_data	icmp_dun.id_data
-};
+} UNALIGNED;
 
 #define ICMP_MPLS_EXT_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
 #define ICMP_MPLS_EXT_VERSION 2



CVS commit: src/usr.bin/make

2021-05-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 30 20:41:34 UTC 2021

Modified Files:
src/usr.bin/make: var.c

Log Message:
make: uncompress code in ApplyModifier_Unique

The algorithm is easier to understand when each line of code only
focuses on a single topic.

No change to the resulting binary, except for line numbers in assertion
messages.


To generate a diff of this commit:
cvs rdiff -u -r1.931 -r1.932 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.931 src/usr.bin/make/var.c:1.932
--- src/usr.bin/make/var.c:1.931	Sun May 30 20:31:03 2021
+++ src/usr.bin/make/var.c	Sun May 30 20:41:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.931 2021/05/30 20:31:03 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.932 2021/05/30 20:41:34 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.931 2021/05/30 20:31:03 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.932 2021/05/30 20:41:34 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -3559,12 +3559,17 @@ ApplyModifier_Unique(const char **pp, Mo
 	words = Str_Words(ch->expr->value.str, false);
 
 	if (words.len > 1) {
-		size_t i, j;
-		for (j = 0, i = 1; i < words.len; i++)
-			if (strcmp(words.words[i], words.words[j]) != 0 &&
-			(++j != i))
-words.words[j] = words.words[i];
-		words.len = j + 1;
+		size_t si, di;
+
+		di = 0;
+		for (si = 1; si < words.len; si++) {
+			if (strcmp(words.words[si], words.words[di]) != 0) {
+di++;
+if (di != si)
+	words.words[di] = words.words[si];
+			}
+		}
+		words.len = di + 1;
 	}
 
 	Expr_SetValueOwn(ch->expr, Words_JoinFree(words));



CVS commit: src/usr.bin/make

2021-05-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 30 20:31:03 UTC 2021

Modified Files:
src/usr.bin/make: var.c

Log Message:
make: inline VarUniq into ApplyModifier_Unique

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.930 -r1.931 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.930 src/usr.bin/make/var.c:1.931
--- src/usr.bin/make/var.c:1.930	Mon Apr 19 22:22:27 2021
+++ src/usr.bin/make/var.c	Sun May 30 20:31:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.930 2021/04/19 22:22:27 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.931 2021/05/30 20:31:03 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.930 2021/04/19 22:22:27 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.931 2021/05/30 20:31:03 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -1824,24 +1824,6 @@ Words_JoinFree(Words words)
 	return Buf_DoneData(&buf);
 }
 
-/* Remove adjacent duplicate words. */
-static char *
-VarUniq(const char *str)
-{
-	Words words = Str_Words(str, false);
-
-	if (words.len > 1) {
-		size_t i, j;
-		for (j = 0, i = 1; i < words.len; i++)
-			if (strcmp(words.words[i], words.words[j]) != 0 &&
-			(++j != i))
-words.words[j] = words.words[i];
-		words.len = j + 1;
-	}
-
-	return Words_JoinFree(words);
-}
-
 
 /*
  * Quote shell meta-characters and space characters in the string.
@@ -3561,15 +3543,31 @@ ApplyModifier_WordFunc(const char **pp, 
 	return AMR_OK;
 }
 
+/* Remove adjacent duplicate words. */
 static ApplyModifierResult
 ApplyModifier_Unique(const char **pp, ModChain *ch)
 {
+	Words words;
+
 	if (!IsDelimiter((*pp)[1], ch))
 		return AMR_UNKNOWN;
 	(*pp)++;
 
-	if (ModChain_ShouldEval(ch))
-		Expr_SetValueOwn(ch->expr, VarUniq(ch->expr->value.str));
+	if (!ModChain_ShouldEval(ch))
+		return AMR_OK;
+
+	words = Str_Words(ch->expr->value.str, false);
+
+	if (words.len > 1) {
+		size_t i, j;
+		for (j = 0, i = 1; i < words.len; i++)
+			if (strcmp(words.words[i], words.words[j]) != 0 &&
+			(++j != i))
+words.words[j] = words.words[i];
+		words.len = j + 1;
+	}
+
+	Expr_SetValueOwn(ch->expr, Words_JoinFree(words));
 
 	return AMR_OK;
 }



CVS commit: src/usr.bin/make/unit-tests

2021-05-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 30 20:26:42 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-unique.mk

Log Message:
tests/make: test whitespace normalization for modifier ':u'


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-unique.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-unique.mk
diff -u src/usr.bin/make/unit-tests/varmod-unique.mk:1.4 src/usr.bin/make/unit-tests/varmod-unique.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-unique.mk:1.4	Mon Aug 31 17:41:38 2020
+++ src/usr.bin/make/unit-tests/varmod-unique.mk	Sun May 30 20:26:41 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-unique.mk,v 1.4 2020/08/31 17:41:38 rillig Exp $
+# $NetBSD: varmod-unique.mk,v 1.5 2021/05/30 20:26:41 rillig Exp $
 #
 # Tests for the :u variable modifier, which discards adjacent duplicate
 # words.
@@ -15,10 +15,18 @@
 .  warning The :u modifier must do nothing with an empty word list.
 .endif
 
-.if ${:U1:u} != "1"
+.if ${:U   :u} != ""
+.  warning The modifier ':u' must normalize the whitespace.
+.endif
+
+.if ${:Uword:u} != "word"
 .  warning The :u modifier must do nothing with a single-element word list.
 .endif
 
+.if ${:U   word   :u} != "word"
+.  warning The modifier ':u' must normalize the whitespace.
+.endif
+
 .if ${:U1 1 1 1 1 1 1 1:u} != "1"
 .  warning The :u modifier must merge _all_ adjacent duplicate words.
 .endif



CVS commit: src/sys/arch/alpha/alpha

2021-05-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 30 19:50:23 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: pmap.c

Log Message:
Fix DEBUG build.


To generate a diff of this commit:
cvs rdiff -u -r1.291 -r1.292 src/sys/arch/alpha/alpha/pmap.c

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

Modified files:

Index: src/sys/arch/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.291 src/sys/arch/alpha/alpha/pmap.c:1.292
--- src/sys/arch/alpha/alpha/pmap.c:1.291	Sun May 30 19:46:21 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sun May 30 19:50:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.291 2021/05/30 19:46:21 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.292 2021/05/30 19:50:23 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.291 2021/05/30 19:46:21 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.292 2021/05/30 19:50:23 thorpej Exp $");
 
 #include 
 #include 
@@ -1933,9 +1933,6 @@ pmap_page_protect(struct vm_page *pg, vm
 	struct pmap_tlb_context tlbctx;
 
 #ifdef DEBUG
-	paddr_t pa = VM_PAGE_TO_PHYS(pg);
-
-
 	if ((pmapdebug & (PDB_FOLLOW|PDB_PROTECT)) ||
 	(prot == VM_PROT_NONE && (pmapdebug & PDB_REMOVE)))
 		printf("pmap_page_protect(%p, %x)\n", pg, prot);
@@ -2576,7 +2573,7 @@ pmap_extract(pmap_t pmap, vaddr_t va, pa
 		if (__predict_true(vtophys_internal(va, pap))) {
 #ifdef DEBUG
 			if (pmapdebug & PDB_FOLLOW)
-printf("0x%lx (kernel vtophys)\n", pa);
+printf("0x%lx (kernel vtophys)\n", *pap);
 #endif
 			return true;
 		}
@@ -3278,7 +3275,7 @@ pmap_pv_dump(paddr_t pa)
 	lock = pmap_pvh_lock(pg);
 	mutex_enter(lock);
 
-	printf("pa 0x%lx (attrs = 0x%x):\n", pa, md->pvh_listx & PGA_ATTRS);
+	printf("pa 0x%lx (attrs = 0x%lx):\n", pa, md->pvh_listx & PGA_ATTRS);
 	for (pv = VM_MDPAGE_PVS(pg); pv != NULL; pv = pv->pv_next)
 		printf(" pmap %p, va 0x%lx\n",
 		pv->pv_pmap, pv->pv_va);
@@ -4004,7 +4001,7 @@ pmap_asn_alloc(pmap_t const pmap, struct
 #ifdef DEBUG
 		if (pmapdebug & PDB_ASN)
 			printf("pmap_asn_alloc: generation bumped to %lu\n",
-			ci->ci_asn_ge);
+			ci->ci_asn_gen);
 #endif
 	}
 



CVS commit: src/sys/arch/alpha/alpha

2021-05-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 30 19:46:21 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: pmap.c

Log Message:
Fix unused variable warning when DIAGNOSTIC is disabled.  Pointed out
by jklos.


To generate a diff of this commit:
cvs rdiff -u -r1.290 -r1.291 src/sys/arch/alpha/alpha/pmap.c

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

Modified files:

Index: src/sys/arch/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.290 src/sys/arch/alpha/alpha/pmap.c:1.291
--- src/sys/arch/alpha/alpha/pmap.c:1.290	Sun May 30 19:41:59 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sun May 30 19:46:21 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.290 2021/05/30 19:41:59 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.291 2021/05/30 19:46:21 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.290 2021/05/30 19:41:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.291 2021/05/30 19:46:21 thorpej Exp $");
 
 #include 
 #include 
@@ -1657,7 +1657,6 @@ pmap_destroy(pmap_t pmap)
 		return;
 
 	pt_entry_t *lev1map = pmap_lev1map(pmap);
-	int i;
 
 	rw_enter(&pmap_growkernel_lock, RW_READER);
 
@@ -1670,6 +1669,7 @@ pmap_destroy(pmap_t pmap)
 
 	pool_cache_put(&pmap_l1pt_cache, lev1map);
 #ifdef DIAGNOSTIC
+	int i;
 	for (i = 0; i < pmap_ncpuids; i++) {
 		pmap->pm_percpu[i].pmc_lev1map = (pt_entry_t *)0xdeadbeefUL;
 	}



CVS commit: src/sys/arch/alpha

2021-05-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 30 19:41:59 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: pmap.c
src/sys/arch/alpha/include: pmap.h

Log Message:
Implement pmap_remove_all().


To generate a diff of this commit:
cvs rdiff -u -r1.289 -r1.290 src/sys/arch/alpha/alpha/pmap.c
cvs rdiff -u -r1.95 -r1.96 src/sys/arch/alpha/include/pmap.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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.289 src/sys/arch/alpha/alpha/pmap.c:1.290
--- src/sys/arch/alpha/alpha/pmap.c:1.289	Sun May 30 14:06:37 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sun May 30 19:41:59 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.289 2021/05/30 14:06:37 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.290 2021/05/30 19:41:59 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.289 2021/05/30 14:06:37 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.290 2021/05/30 19:41:59 thorpej Exp $");
 
 #include 
 #include 
@@ -507,6 +507,8 @@ pmap_pagelist_free(struct pmap_pagelist 
 
 	while ((pg = LIST_FIRST(list)) != NULL) {
 		LIST_REMOVE(pg, pageq.list);
+		/* Zap any fields we used internally. */
+		atomic_store_relaxed(&pg->loan_count, 0);
 		uvm_pagefree(pg);
 	}
 }
@@ -663,6 +665,7 @@ TLB_COUNT_DECL(shootnow_remote);
 
 TLB_COUNT_DECL(reason_remove_kernel);
 TLB_COUNT_DECL(reason_remove_user);
+TLB_COUNT_DECL(reason_remove_all_user);
 TLB_COUNT_DECL(reason_page_protect_read);
 TLB_COUNT_DECL(reason_page_protect_none);
 TLB_COUNT_DECL(reason_protect);
@@ -729,6 +732,7 @@ pmap_tlb_init(void)
 
 	TLB_COUNT_ATTACH(reason_remove_kernel);
 	TLB_COUNT_ATTACH(reason_remove_user);
+	TLB_COUNT_ATTACH(reason_remove_all_user);
 	TLB_COUNT_ATTACH(reason_page_protect_read);
 	TLB_COUNT_ATTACH(reason_page_protect_none);
 	TLB_COUNT_ATTACH(reason_protect);
@@ -1844,6 +1848,77 @@ pmap_remove(pmap_t pmap, vaddr_t sva, va
 }
 
 /*
+ * pmap_remove_all:		[ INTERFACE ]
+ *
+ *	Remove all mappings from a pmap in bulk.  This is only called
+ *	when it's known that the address space is no longer visible to
+ *	any user process (e.g. during exit or exec).
+ */
+bool
+pmap_remove_all(pmap_t pmap)
+{
+	struct pmap_tlb_context tlbctx;
+	struct vm_page *pg;
+	pv_entry_t pv;
+
+	KASSERT(pmap != pmap_kernel());
+
+	/*
+	 * This process is pretty simple:
+	 *
+	 * ==> (1) Zero out the user-space portion of the lev1map.
+	 *
+	 * ==> (2) Copy the PT page list to the tlbctx and re-init.
+	 *
+	 * ==> (3) Walk the PV entry list and remove each entry.
+	 *
+	 * ==> (4) Zero the wired and resident count.
+	 *
+	 * Once we've done that, we just need to free everything
+	 * back to the system.
+	 */
+
+	pmap_tlb_context_init(&tlbctx, 0);
+
+	PMAP_MAP_TO_HEAD_LOCK();
+	PMAP_LOCK(pmap);
+
+	/* Step 1 */
+	pt_entry_t * const lev1map = pmap_lev1map(pmap);
+	memset(lev1map, 0,
+	   l1pte_index(VM_MAXUSER_ADDRESS) * sizeof(pt_entry_t));
+
+	/* Step 2 */
+	LIST_MOVE(&pmap->pm_ptpages, &tlbctx.t_freeptq, pageq.list);
+
+	/* Fix up the reference count on the lev1map page. */
+	pg = PHYS_TO_VM_PAGE(ALPHA_K0SEG_TO_PHYS((vaddr_t)lev1map));
+	atomic_store_relaxed(&pg->loan_count, 0);
+
+	/* Step 3 */
+	while ((pv = LIST_FIRST(&pmap->pm_pvents)) != NULL) {
+		KASSERT(pv->pv_pmap == pmap);
+		pmap_pv_remove(pmap, PHYS_TO_VM_PAGE(pmap_pte_pa(pv->pv_pte)),
+		pv->pv_va, true, NULL, &tlbctx);
+	}
+
+	/* Step 4 */
+	atomic_store_relaxed(&pmap->pm_stats.wired_count, 0);
+	atomic_store_relaxed(&pmap->pm_stats.resident_count, 0);
+
+	pmap_tlb_shootdown_all_user(pmap, PG_EXEC, &tlbctx);
+
+	PMAP_UNLOCK(pmap);
+	PMAP_MAP_TO_HEAD_UNLOCK();
+
+	pmap_tlb_shootnow(&tlbctx);
+	pmap_tlb_context_drain(&tlbctx);
+	TLB_COUNT(reason_remove_all_user);
+
+	return true;
+}
+
+/*
  * pmap_page_protect:		[ INTERFACE ]
  *
  *	Lower the permission for all mappings to a given page to

Index: src/sys/arch/alpha/include/pmap.h
diff -u src/sys/arch/alpha/include/pmap.h:1.95 src/sys/arch/alpha/include/pmap.h:1.96
--- src/sys/arch/alpha/include/pmap.h:1.95	Sun May 30 14:06:37 2021
+++ src/sys/arch/alpha/include/pmap.h	Sun May 30 19:41:59 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.95 2021/05/30 14:06:37 thorpej Exp $ */
+/* $NetBSD: pmap.h,v 1.96 2021/05/30 19:41:59 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -209,13 +209,6 @@ void	pmap_tlb_shootdown_ipi(struct cpu_i
 #define	pmap_copy(dp, sp, da, l, sa)	/* nothing */
 #define	pmap_update(pmap)		/* nothing (yet) */
 
-static __inline bool
-pmap_remove_all(struct pmap *pmap)
-{
-	/* Nothing. */
-	return false;
-}
-
 #define	pmap_is_referenced(pg)		\
 	(((pg)->mdpage.pvh_listx & PGA_REFERENCED) != 0)
 #define	pmap_is_modified(pg)		\



CVS commit: src/sys/external/bsd/acpica/dist/namespace

2021-05-30 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun May 30 16:25:35 UTC 2021

Modified Files:
src/sys/external/bsd/acpica/dist/namespace: nsaccess.c

Log Message:
avoid dereferencing a constant string address as a UINT32 pointer,
KUBSAN complains about bad alignment.

Reported-by: syzbot+91187f4e33436ce83...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 \
src/sys/external/bsd/acpica/dist/namespace/nsaccess.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/external/bsd/acpica/dist/namespace/nsaccess.c
diff -u src/sys/external/bsd/acpica/dist/namespace/nsaccess.c:1.20 src/sys/external/bsd/acpica/dist/namespace/nsaccess.c:1.21
--- src/sys/external/bsd/acpica/dist/namespace/nsaccess.c:1.20	Sat Apr  3 17:45:03 2021
+++ src/sys/external/bsd/acpica/dist/namespace/nsaccess.c	Sun May 30 16:25:35 2021
@@ -79,6 +79,7 @@ AcpiNsRootInitialize (
 ACPI_NAMESPACE_NODE *PrevNode = NULL;
 ACPI_OPERAND_OBJECT *ObjDesc;
 ACPI_STRING Val = NULL;
+UINT32  Name;
 
 
 ACPI_FUNCTION_TRACE (NsRootInitialize);
@@ -143,7 +144,8 @@ AcpiNsRootInitialize (
  * predefined names are at the root level. It is much easier to
  * just create and link the new node(s) here.
  */
-NewNode = AcpiNsCreateNode (*ACPI_CAST_PTR (UINT32, InitVal->Name));
+memcpy(&Name, InitVal->Name, sizeof(Name));
+NewNode = AcpiNsCreateNode (Name);
 if (!NewNode)
 {
 Status = AE_NO_MEMORY;



CVS commit: src/sys/arch/alpha

2021-05-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 30 14:06:37 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: pmap.c
src/sys/arch/alpha/include: pmap.h

Log Message:
When removing mappings, hang PV entries to be freed off of the
pmap_tlb_context structure, and free them back in bulk after we
release all of our locks (as we do with PT pages that are freed).


To generate a diff of this commit:
cvs rdiff -u -r1.288 -r1.289 src/sys/arch/alpha/alpha/pmap.c
cvs rdiff -u -r1.94 -r1.95 src/sys/arch/alpha/include/pmap.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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.288 src/sys/arch/alpha/alpha/pmap.c:1.289
--- src/sys/arch/alpha/alpha/pmap.c:1.288	Sun May 30 13:34:21 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sun May 30 14:06:37 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.288 2021/05/30 13:34:21 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.289 2021/05/30 14:06:37 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.288 2021/05/30 13:34:21 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.289 2021/05/30 14:06:37 thorpej Exp $");
 
 #include 
 #include 
@@ -432,6 +432,71 @@ pmap_activation_lock(pmap_t const pmap)
 #endif /* MULTIPROCESSOR */
 
 /*
+ * TLB context structure; see description in "TLB management" section
+ * below.
+ */
+#define	TLB_CTX_MAXVA		8
+#define	TLB_CTX_ALLVA		PAGE_MASK
+struct pmap_tlb_context {
+	uintptr_t		t_addrdata[TLB_CTX_MAXVA];
+	pmap_t			t_pmap;
+	struct pmap_pagelist	t_freeptq;
+	struct pmap_pvlist	t_freepvq;
+};
+
+/*
+ * Internal routines
+ */
+static void	alpha_protection_init(void);
+static pt_entry_t pmap_remove_mapping(pmap_t, vaddr_t, pt_entry_t *, bool,
+  pv_entry_t *,
+  struct pmap_tlb_context *);
+static void	pmap_changebit(struct vm_page *, pt_entry_t, pt_entry_t,
+			   struct pmap_tlb_context *);
+
+/*
+ * PT page management functions.
+ */
+static int	pmap_ptpage_alloc(pmap_t, pt_entry_t *, int);
+static void	pmap_ptpage_free(pmap_t, pt_entry_t *,
+ struct pmap_tlb_context *);
+static void	pmap_l3pt_delref(pmap_t, vaddr_t, pt_entry_t *,
+		 struct pmap_tlb_context *);
+static void	pmap_l2pt_delref(pmap_t, pt_entry_t *, pt_entry_t *,
+		 struct pmap_tlb_context *);
+static void	pmap_l1pt_delref(pmap_t, pt_entry_t *);
+
+static void	*pmap_l1pt_alloc(struct pool *, int);
+static void	pmap_l1pt_free(struct pool *, void *);
+
+static struct pool_allocator pmap_l1pt_allocator = {
+	pmap_l1pt_alloc, pmap_l1pt_free, 0,
+};
+
+static int	pmap_l1pt_ctor(void *, void *, int);
+
+/*
+ * PV table management functions.
+ */
+static int	pmap_pv_enter(pmap_t, struct vm_page *, vaddr_t, pt_entry_t *,
+			  bool, pv_entry_t);
+static void	pmap_pv_remove(pmap_t, struct vm_page *, vaddr_t, bool,
+			   pv_entry_t *, struct pmap_tlb_context *);
+static void	*pmap_pv_page_alloc(struct pool *, int);
+static void	pmap_pv_page_free(struct pool *, void *);
+
+static struct pool_allocator pmap_pv_page_allocator = {
+	pmap_pv_page_alloc, pmap_pv_page_free, 0,
+};
+
+#ifdef DEBUG
+void	pmap_pv_dump(paddr_t);
+#endif
+
+#define	pmap_pv_alloc()		pool_cache_get(&pmap_pv_cache, PR_NOWAIT)
+#define	pmap_pv_free(pv)	pool_cache_put(&pmap_pv_cache, (pv))
+
+/*
  * Generic routine for freeing pages on a pmap_pagelist back to
  * the system.
  */
@@ -447,6 +512,21 @@ pmap_pagelist_free(struct pmap_pagelist 
 }
 
 /*
+ * Generic routine for freeing a list of PV entries back to the
+ * system.
+ */
+static void
+pmap_pvlist_free(struct pmap_pvlist * const list)
+{
+	pv_entry_t pv;
+
+	while ((pv = LIST_FIRST(list)) != NULL) {
+		LIST_REMOVE(pv, pv_link);
+		pmap_pv_free(pv);
+	}
+}
+
+/*
  * TLB management.
  *
  * TLB invalidations need to be performed on local and remote CPUs
@@ -518,9 +598,6 @@ pmap_pagelist_free(struct pmap_pagelist 
  * window size (defined as 64KB on alpha in ).
  */
 
-#define	TLB_CTX_MAXVA		8
-#define	TLB_CTX_ALLVA		PAGE_MASK
-
 #define	TLB_CTX_F_ASM		__BIT(0)
 #define	TLB_CTX_F_IMB		__BIT(1)
 #define	TLB_CTX_F_KIMB		__BIT(2)
@@ -538,12 +615,6 @@ pmap_pagelist_free(struct pmap_pagelist 
 #define	TLB_CTX_SETVA(ctx, i, va)	\
 	(ctx)->t_addrdata[(i)] = (va) | ((ctx)->t_addrdata[(i)] & PAGE_MASK)
 
-struct pmap_tlb_context {
-	uintptr_t	t_addrdata[TLB_CTX_MAXVA];
-	pmap_t		t_pmap;
-	struct pmap_pagelist t_freeptq;
-};
-
 static struct {
 	kmutex_t	lock;
 	struct evcnt	events;
@@ -689,6 +760,7 @@ pmap_tlb_context_init(struct pmap_tlb_co
 	tlbctx->t_addrdata[1] = flags;
 	tlbctx->t_pmap = NULL;
 	LIST_INIT(&tlbctx->t_freeptq);
+	LIST_INIT(&tlbctx->t_freepvq);
 }
 
 static void
@@ -1081,65 +1153,18 @@ pmap_tlb_shootdown_ipi(struct cpu_info *
 }
 #endif /* MULTIPROCESSOR */
 
-static __inline void
-pmap_tlb

CVS commit: src/sys/arch/alpha

2021-05-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 30 13:34:21 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: pmap.c
src/sys/arch/alpha/include: pmap.h

Log Message:
Keep track of a pmap's PV entries with a list hanging off the pmap.


To generate a diff of this commit:
cvs rdiff -u -r1.287 -r1.288 src/sys/arch/alpha/alpha/pmap.c
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/alpha/include/pmap.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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.287 src/sys/arch/alpha/alpha/pmap.c:1.288
--- src/sys/arch/alpha/alpha/pmap.c:1.287	Sun May 30 06:41:19 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sun May 30 13:34:21 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.287 2021/05/30 06:41:19 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.288 2021/05/30 13:34:21 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.287 2021/05/30 06:41:19 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.288 2021/05/30 13:34:21 thorpej Exp $");
 
 #include 
 #include 
@@ -1384,6 +1384,7 @@ pmap_bootstrap(paddr_t ptaddr, u_int max
 	 */
 	memset(pmap_kernel(), 0, sizeof(struct pmap));
 	LIST_INIT(&pmap_kernel()->pm_ptpages);
+	LIST_INIT(&pmap_kernel()->pm_pvents);
 	atomic_store_relaxed(&pmap_kernel()->pm_count, 1);
 	/* Kernel pmap does not have per-CPU info. */
 	TAILQ_INSERT_TAIL(&pmap_all_pmaps, pmap_kernel(), pm_list);
@@ -1568,6 +1569,7 @@ pmap_create(void)
 	pmap = pool_cache_get(&pmap_pmap_cache, PR_WAITOK);
 	memset(pmap, 0, sizeof(*pmap));
 	LIST_INIT(&pmap->pm_ptpages);
+	LIST_INIT(&pmap->pm_pvents);
 
 	atomic_store_relaxed(&pmap->pm_count, 1);
 
@@ -3278,6 +3280,7 @@ pmap_pv_enter(pmap_t pmap, struct vm_pag
 	uintptr_t const attrs = md->pvh_listx & PGA_ATTRS;
 	newpv->pv_next = (struct pv_entry *)(md->pvh_listx & ~PGA_ATTRS);
 	md->pvh_listx = (uintptr_t)newpv | attrs;
+	LIST_INSERT_HEAD(&pmap->pm_pvents, newpv, pv_link);
 
 	if (dolock) {
 		mutex_exit(lock);
@@ -3316,8 +3319,15 @@ pmap_pv_remove(pmap_t pmap, struct vm_pa
 
 	KASSERT(pv != NULL);
 
+	/*
+	 * The page attributes are in the lower 2 bits of the first
+	 * PV entry pointer.  Rather than comparing the pointer address
+	 * and branching, we just always preserve what might be there
+	 * (either attribute bits or zero bits).
+	 */
 	*pvp = (pv_entry_t)((uintptr_t)pv->pv_next |
 			(((uintptr_t)*pvp) & PGA_ATTRS));
+	LIST_REMOVE(pv, pv_link);
 
 	if (dolock) {
 		mutex_exit(lock);

Index: src/sys/arch/alpha/include/pmap.h
diff -u src/sys/arch/alpha/include/pmap.h:1.93 src/sys/arch/alpha/include/pmap.h:1.94
--- src/sys/arch/alpha/include/pmap.h:1.93	Sun May 30 06:41:19 2021
+++ src/sys/arch/alpha/include/pmap.h	Sun May 30 13:34:21 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.93 2021/05/30 06:41:19 thorpej Exp $ */
+/* $NetBSD: pmap.h,v 1.94 2021/05/30 13:34:21 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -151,7 +151,7 @@ struct pmap {	/* pmaps are aligned to CO
 	unsigned int		pm_count;	/* [24] reference count */
 	unsigned int		__pm_spare0;	/* [28] spare field */
 	struct pmap_pagelist	pm_ptpages;	/* [32] list of PT pages */
-	unsigned long		__pm_spare1;	/* [40] spare field */
+	LIST_HEAD(, pv_entry)	pm_pvents;	/* [40] list of PV entries */
 	TAILQ_ENTRY(pmap)	pm_list;	/* [48] list of all pmaps */
 	/* -- COHERENCY_UNIT boundary -- */
 	struct pmap_percpu	pm_percpu[];	/* [64] per-CPU data */
@@ -171,7 +171,8 @@ struct pmap {	/* pmaps are aligned to CO
  * mappings of that page.  An entry is a pv_entry_t, the list is pv_table.
  */
 typedef struct pv_entry {
-	struct pv_entry	*pv_next;	/* next pv_entry on list */
+	struct pv_entry	*pv_next;	/* next pv_entry on page list */
+	LIST_ENTRY(pv_entry) pv_link;	/* link on owning pmap's list */
 	struct pmap	*pv_pmap;	/* pmap where mapping lies */
 	vaddr_t		pv_va;		/* virtual address for mapping */
 	pt_entry_t	*pv_pte;	/* PTE that maps the VA */



CVS commit: src/sys/dev/pckbport

2021-05-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 30 13:20:01 UTC 2021

Modified Files:
src/sys/dev/pckbport: synaptics.c

Log Message:
synaptics(4): New sysctl knob for debug output.

Set hw.synaptics.debug=1 to re-enable it; the compile-time DIAGNOSTIC
option was inappropriate for this.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/dev/pckbport/synaptics.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/pckbport/synaptics.c
diff -u src/sys/dev/pckbport/synaptics.c:1.70 src/sys/dev/pckbport/synaptics.c:1.71
--- src/sys/dev/pckbport/synaptics.c:1.70	Thu Oct  1 17:13:19 2020
+++ src/sys/dev/pckbport/synaptics.c	Sun May 30 13:20:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.70 2020/10/01 17:13:19 nia Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.71 2021/05/30 13:20:01 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.70 2020/10/01 17:13:19 nia Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.71 2021/05/30 13:20:01 riastradh Exp $");
 
 #include 
 #include 
@@ -125,6 +125,16 @@ static int synaptics_fscroll_max = 14;
 static int synaptics_dz_hold = 30;
 static int synaptics_movement_enable = 1;
 static bool synaptics_aux_mid_button_scroll = TRUE;
+static int synaptics_debug = 0;
+
+#define	DPRINTF(SC, FMT, ARGS...) do	  \
+{	  \
+	if (synaptics_debug) {		  \
+		struct pms_softc *_dprintf_psc =			  \
+		container_of((SC), struct pms_softc, u.synaptics);	  \
+		device_printf(_dprintf_psc->sc_dev, FMT, ##ARGS);	  \
+	}  \
+} while (0)
 
 /* Sysctl nodes. */
 static int synaptics_button_boundary_nodenum;
@@ -844,6 +854,17 @@ pms_sysctl_synaptics(struct sysctllog **
 		goto err;
 
 	synaptics_aux_mid_button_scroll_nodenum = node->sysctl_num;
+
+	if ((rc = sysctl_createv(clog, 0, NULL, &node,
+	CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+	CTLTYPE_INT, "debug",
+	SYSCTL_DESCR("Enable debug output"),
+	NULL, 0,
+	&synaptics_debug,
+	0, CTL_HW, root_num, CTL_CREATE,
+	CTL_EOL)) != 0)
+		goto err;
+
 	return;
 
 err:
@@ -1394,10 +1415,10 @@ synaptics_gesture_detect(struct synaptic
 		sc->gesture_move_y = 0;
 		sc->gesture_start_packet = sc->total_packets[0];
 
-#ifdef DIAGNOSTIC
-		aprint_debug("Finger applied: gesture_start_x: %d gesture_start_y: %d\n",
-			sc->gesture_start_x, sc->gesture_start_y);
-#endif
+		DPRINTF(sc, "Finger applied:"
+		" gesture_start_x: %d"
+		" gesture_start_y: %d\n",
+		sc->gesture_start_x, sc->gesture_start_y);
 	} else
 	if (fingers == 0 && sc->prev_fingers != 0) {
 		/*
@@ -1409,14 +1430,12 @@ synaptics_gesture_detect(struct synaptic
 		 * of the fingers).
 		 */
 
-#ifdef DIAGNOSTIC
-		aprint_debug("Finger removed: gesture_len: %d (%d)\n",
-			gesture_len, synaptics_gesture_length);
-		aprint_debug("gesture_move_x: %d (%d) sp_x: %d\n",
-			sc->gesture_move_x, synaptics_gesture_move, abs(sp->sp_x));
-		aprint_debug("gesture_move_y: %d (%d) sp_y: %d\n",
-			sc->gesture_move_y, synaptics_gesture_move, abs(sp->sp_y));
-#endif
+		DPRINTF(sc, "Finger removed: gesture_len: %d (%d)\n",
+		gesture_len, synaptics_gesture_length);
+		DPRINTF(sc, "gesture_move_x: %d (%d) sp_x: %d\n",
+		sc->gesture_move_x, synaptics_gesture_move, abs(sp->sp_x));
+		DPRINTF(sc, "gesture_move_y: %d (%d) sp_y: %d\n",
+		sc->gesture_move_y, synaptics_gesture_move, abs(sp->sp_y));
 
 		if (gesture_len < synaptics_gesture_length &&
 		((sc->gesture_move_x < synaptics_gesture_move &&



CVS commit: src/sys/dev/acpi

2021-05-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 30 11:24:11 UTC 2021

Modified Files:
src/sys/dev/acpi: thinkpad_acpi.c

Log Message:
thinkpad(4): Fix evaluation of MHKA on version 2 devices.

Need to pass an argument.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/dev/acpi/thinkpad_acpi.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/acpi/thinkpad_acpi.c
diff -u src/sys/dev/acpi/thinkpad_acpi.c:1.52 src/sys/dev/acpi/thinkpad_acpi.c:1.53
--- src/sys/dev/acpi/thinkpad_acpi.c:1.52	Sat May 29 16:49:57 2021
+++ src/sys/dev/acpi/thinkpad_acpi.c	Sun May 30 11:24:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: thinkpad_acpi.c,v 1.52 2021/05/29 16:49:57 riastradh Exp $ */
+/* $NetBSD: thinkpad_acpi.c,v 1.53 2021/05/30 11:24:10 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: thinkpad_acpi.c,v 1.52 2021/05/29 16:49:57 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: thinkpad_acpi.c,v 1.53 2021/05/30 11:24:10 riastradh Exp $");
 
 #include 
 #include 
@@ -55,6 +55,7 @@ typedef struct thinkpad_softc {
 	struct acpi_devnode	*sc_node;
 	ACPI_HANDLE		sc_powhdl;
 	ACPI_HANDLE		sc_cmoshdl;
+	ACPI_INTEGER		sc_ver;
 
 #define	TP_PSW_SLEEP		0	/* FnF4 */
 #define	TP_PSW_HIBERNATE	1	/* FnF12 */
@@ -241,13 +242,58 @@ thinkpad_attach(device_t parent, device_
 		aprint_debug_dev(self, "using EC at %s\n",
 		device_xname(sc->sc_ecdev));
 
-	/* Get the supported event mask */
-	rv = acpi_eval_integer(sc->sc_node->ad_handle, "MHKA", &val);
+	/* Query the version number */
+	rv = acpi_eval_integer(aa->aa_node->ad_handle, "MHKV", &sc->sc_ver);
 	if (ACPI_FAILURE(rv)) {
-		aprint_error_dev(self, "couldn't evaluate MHKA: %s\n",
+		aprint_error_dev(self, "couldn't evaluate MHKV: %s\n",
 		AcpiFormatException(rv));
 		goto fail;
 	}
+	aprint_normal_dev(self, "version %04x\n", (unsigned)sc->sc_ver);
+
+	/* Get the supported event mask */
+	switch (sc->sc_ver) {
+	case THINKPAD_HKEY_VERSION_1:
+		rv = acpi_eval_integer(sc->sc_node->ad_handle, "MHKA", &val);
+		if (ACPI_FAILURE(rv)) {
+			aprint_error_dev(self, "couldn't evaluate MHKA: %s\n",
+			AcpiFormatException(rv));
+			goto fail;
+		}
+		break;
+	case THINKPAD_HKEY_VERSION_2: {
+		ACPI_OBJECT args[1] = {
+			[0] = { .Integer = {
+.Type = ACPI_TYPE_INTEGER,
+.Value = 1, /* hotkey events */
+			} },
+		};
+		ACPI_OBJECT_LIST arglist = {
+			.Count = __arraycount(args),
+			.Pointer = args,
+		};
+		ACPI_OBJECT ret;
+		ACPI_BUFFER buf = { .Pointer = &ret, .Length = sizeof(ret) };
+
+		rv = AcpiEvaluateObject(sc->sc_node->ad_handle, "MHKA",
+		&arglist, &buf);
+		if (ACPI_FAILURE(rv)) {
+			aprint_error_dev(self, "couldn't evaluate MHKA(1):"
+			" %s\n",
+			AcpiFormatException(rv));
+			goto fail;
+		}
+		if (buf.Length == 0 || ret.Type != ACPI_TYPE_INTEGER) {
+			aprint_error_dev(self, "failed to evaluate MHKA(1)\n");
+			goto fail;
+		}
+		val = ret.Integer.Value;
+		break;
+	}
+	default:
+		panic("%s: invalid version %jd", device_xname(self),
+		(intmax_t)sc->sc_ver);
+	}
 
 	/* Enable all supported events */
 	rv = thinkpad_mask_init(sc, val);



CVS commit: src/sys/dev

2021-05-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 30 11:24:02 UTC 2021

Modified Files:
src/sys/dev: ld.c ldvar.h

Log Message:
ld(4): Block requests while suspended until resumed.

Otherwise nothing stops us from continuing to feed I/O to the disk
controller when it expects that the queues are quiesced as it pokes
registers to change its power states.  Fixes resume during disk
activity on my T480 with nvme.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sys/dev/ld.c
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/ldvar.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/dev/ld.c
diff -u src/sys/dev/ld.c:1.111 src/sys/dev/ld.c:1.112
--- src/sys/dev/ld.c:1.111	Sun Aug  2 01:17:56 2020
+++ src/sys/dev/ld.c	Sun May 30 11:24:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld.c,v 1.111 2020/08/02 01:17:56 riastradh Exp $	*/
+/*	$NetBSD: ld.c,v 1.112 2021/05/30 11:24:02 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.111 2020/08/02 01:17:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.112 2021/05/30 11:24:02 riastradh Exp $");
 
 #include 
 #include 
@@ -63,6 +63,7 @@ __KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.111
 
 static void	ldminphys(struct buf *bp);
 static bool	ld_suspend(device_t, const pmf_qual_t *);
+static bool	ld_resume(device_t, const pmf_qual_t *);
 static bool	ld_shutdown(device_t, int);
 static int	ld_diskstart(device_t, struct buf *bp);
 static void	ld_iosize(device_t, int *);
@@ -166,7 +167,8 @@ ldattach(struct ld_softc *sc, const char
 	bufq_alloc(&dksc->sc_bufq, default_strategy, BUFQ_SORT_RAWBLOCK);
 
 	/* Register with PMF */
-	if (!pmf_device_register1(dksc->sc_dev, ld_suspend, NULL, ld_shutdown))
+	if (!pmf_device_register1(dksc->sc_dev, ld_suspend, ld_resume,
+		ld_shutdown))
 		aprint_error_dev(dksc->sc_dev,
 		"couldn't establish power handler\n");
 
@@ -276,7 +278,55 @@ ldenddetach(struct ld_softc *sc)
 static bool
 ld_suspend(device_t dev, const pmf_qual_t *qual)
 {
-	return ld_shutdown(dev, 0);
+	struct ld_softc *sc = device_private(dev);
+	int queuecnt;
+	bool ok = false;
+
+	/* Block new requests and wait for outstanding requests to drain.  */
+	mutex_enter(&sc->sc_mutex);
+	KASSERT((sc->sc_flags & LDF_SUSPEND) == 0);
+	sc->sc_flags |= LDF_SUSPEND;
+	while ((queuecnt = sc->sc_queuecnt) > 0) {
+		if (cv_timedwait(&sc->sc_drain, &sc->sc_mutex, 30 * hz))
+			break;
+	}
+	mutex_exit(&sc->sc_mutex);
+
+	/* Block suspend if we couldn't drain everything in 30sec.  */
+	if (queuecnt > 0) {
+		device_printf(dev, "timeout draining buffers\n");
+		goto out;
+	}
+
+	/* Flush cache before we lose power.  If we can't, block suspend.  */
+	if (ld_flush(dev, /*poll*/false) != 0) {
+		device_printf(dev, "failed to flush cache\n");
+		goto out;
+	}
+
+	/* Success!  */
+	ok = true;
+
+out:	if (!ok)
+		(void)ld_resume(dev, qual);
+	return ok;
+}
+
+static bool
+ld_resume(device_t dev, const pmf_qual_t *qual)
+{
+	struct ld_softc *sc = device_private(dev);
+
+	/* Allow new requests to come in.  */
+	mutex_enter(&sc->sc_mutex);
+	KASSERT(sc->sc_flags & LDF_SUSPEND);
+	sc->sc_flags &= ~LDF_SUSPEND;
+	mutex_exit(&sc->sc_mutex);
+
+	/* Restart any pending queued requests.  */
+	dk_start(&sc->sc_dksc, NULL);
+
+	return true;
 }
 
 /* ARGSUSED */
@@ -438,17 +488,24 @@ ld_diskstart(device_t dev, struct buf *b
 	struct ld_softc *sc = device_private(dev);
 	int error;
 
-	if (sc->sc_queuecnt >= sc->sc_maxqueuecnt)
+	if (sc->sc_queuecnt >= sc->sc_maxqueuecnt ||
+	sc->sc_flags & LDF_SUSPEND) {
+		if (sc->sc_flags & LDF_SUSPEND)
+			aprint_debug_dev(dev, "i/o blocked while suspended\n");
 		return EAGAIN;
+	}
 
 	if ((sc->sc_flags & LDF_MPSAFE) == 0)
 		KERNEL_LOCK(1, curlwp);
 
 	mutex_enter(&sc->sc_mutex);
 
-	if (sc->sc_queuecnt >= sc->sc_maxqueuecnt)
+	if (sc->sc_queuecnt >= sc->sc_maxqueuecnt ||
+	sc->sc_flags & LDF_SUSPEND) {
+		if (sc->sc_flags & LDF_SUSPEND)
+			aprint_debug_dev(dev, "i/o blocked while suspended\n");
 		error = EAGAIN;
-	else {
+	} else {
 		error = (*sc->sc_start)(sc, bp);
 		if (error == 0)
 			sc->sc_queuecnt++;

Index: src/sys/dev/ldvar.h
diff -u src/sys/dev/ldvar.h:1.34 src/sys/dev/ldvar.h:1.35
--- src/sys/dev/ldvar.h:1.34	Sun Aug  2 01:17:56 2020
+++ src/sys/dev/ldvar.h	Sun May 30 11:24:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ldvar.h,v 1.34 2020/08/02 01:17:56 riastradh Exp $	*/
+/*	$NetBSD: ldvar.h,v 1.35 2021/05/30 11:24:02 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -70,6 +70,7 @@ struct ld_softc {
 #define	LDF_UNUSED0	0x020		/* was LDF_DRAIN */
 #define	LDF_NO_RND	0x040		/* do not attach rnd source */
 #define	LDF_MPSAFE	0x080		/* backend is MPSAFE */
+#define	LDF_SUSPEND	0x100		/* disk is suspended until resume */
 
 int	ldadjqparam(struct ld_softc *, int);
 void	ldattach(struct ld_softc *, const 

CVS commit: src/tools/compat

2021-05-30 Thread Chris Pinnock
Module Name:src
Committed By:   cjep
Date:   Sun May 30 10:39:41 UTC 2021

Modified Files:
src/tools/compat: compat_defs.h

Log Message:
PR port-amiga/56188

Include a prototype for __nbcompat_heapsort. The tools for amiga now
build on Darwin where one Amiga specific tool uses heapsort.

Despite being a one-liner, ./build.sh -m amiga tools was tested on
NetBSD, Darwin, FreeBSD & Linux with the change.

Discussed various options with jdc & thorpej. Perhaps in the future
we could look at using qsort instead of heapsort as qsort is
standardised and more likely to be available. We could then remove
heapsort from the compatibility library.


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/tools/compat/compat_defs.h

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

Modified files:

Index: src/tools/compat/compat_defs.h
diff -u src/tools/compat/compat_defs.h:1.119 src/tools/compat/compat_defs.h:1.120
--- src/tools/compat/compat_defs.h:1.119	Mon May 24 23:07:40 2021
+++ src/tools/compat/compat_defs.h	Sun May 30 10:39:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_defs.h,v 1.119 2021/05/24 23:07:40 uwe Exp $	*/
+/*	$NetBSD: compat_defs.h,v 1.120 2021/05/30 10:39:41 cjep Exp $	*/
 
 #ifndef	__NETBSD_COMPAT_DEFS_H__
 #define	__NETBSD_COMPAT_DEFS_H__
@@ -462,7 +462,9 @@ int __nbcompat_gettemp(char *, int *, in
 ssize_t pread(int, void *, size_t, off_t);
 #endif
 
+int __nbcompat_heapsort (void *, size_t, size_t, int (*)(const void *, const void *));
 #define heapsort __nbcompat_heapsort
+
 #if !HAVE_DECL_HEAPSORT
 int heapsort (void *, size_t, size_t, int (*)(const void *, const void *));
 #endif



CVS commit: src/distrib/i386/installimage

2021-05-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun May 30 09:54:56 UTC 2021

Modified Files:
src/distrib/i386/installimage: Makefile

Log Message:
Bump image size slightly (for gcc 10)


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/distrib/i386/installimage/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/i386/installimage/Makefile
diff -u src/distrib/i386/installimage/Makefile:1.19 src/distrib/i386/installimage/Makefile:1.20
--- src/distrib/i386/installimage/Makefile:1.19	Wed May  6 09:18:10 2020
+++ src/distrib/i386/installimage/Makefile	Sun May 30 09:54:56 2021
@@ -1,10 +1,10 @@
-#	$NetBSD: Makefile,v 1.19 2020/05/06 09:18:10 bouyer Exp $
+#	$NetBSD: Makefile,v 1.20 2021/05/30 09:54:56 martin Exp $
 
 .include 
 
 INSTIMGBASE=	NetBSD-${DISTRIBVER}-i386-install	# gives ${IMGBASE}.img
 
-INSTIMAGEMB?=	1900			# for all installation binaries
+INSTIMAGEMB?=	2000			# for all installation binaries
 
 PRIMARY_BOOT=		bootxx_ffsv1
 SECONDARY_BOOT=		boot



CVS commit: src/sys/arch/arm/include/arm32

2021-05-30 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun May 30 07:20:00 UTC 2021

Modified Files:
src/sys/arch/arm/include/arm32: param.h

Log Message:
Include opt_param.h for MSGBUFSIZE ifdef _KERNEL_OPT.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/arm/include/arm32/param.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/arm/include/arm32/param.h
diff -u src/sys/arch/arm/include/arm32/param.h:1.33 src/sys/arch/arm/include/arm32/param.h:1.34
--- src/sys/arch/arm/include/arm32/param.h:1.33	Fri Jul 10 12:25:09 2020
+++ src/sys/arch/arm/include/arm32/param.h	Sun May 30 07:20:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.33 2020/07/10 12:25:09 skrll Exp $	*/
+/*	$NetBSD: param.h,v 1.34 2021/05/30 07:20:00 rin Exp $	*/
 
 /*
  * Copyright (c) 1994,1995 Mark Brinicombe.
@@ -38,6 +38,7 @@
 #ifdef _KERNEL_OPT
 #include "opt_arm32_pmap.h"
 #include "opt_kasan.h"
+#include "opt_param.h"
 #endif
 
 /*



CVS commit: src/share/man/man7

2021-05-30 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun May 30 07:17:01 UTC 2021

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

Log Message:
signal.7: minor clarification. Bump date (to when I wrote the change)


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/share/man/man7/signal.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/signal.7
diff -u src/share/man/man7/signal.7:1.25 src/share/man/man7/signal.7:1.26
--- src/share/man/man7/signal.7:1.25	Wed May 30 23:41:44 2018
+++ src/share/man/man7/signal.7	Sun May 30 07:17:01 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: signal.7,v 1.25 2018/05/30 23:41:44 uwe Exp $
+.\"	$NetBSD: signal.7,v 1.26 2021/05/30 07:17:01 dholland Exp $
 .\"
 .\" Copyright (c) 1999, 2016 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd May 28, 2018
+.Dd August 24, 2018
 .Dt SIGNAL 7
 .Os
 .Sh NAME
@@ -81,7 +81,8 @@ This is always done in a way that allows
 desired.
 (Note, however, that some signals may not be caught.)
 Otherwise, the default action for the signal is taken.
-For most signals the default action is a core dump.
+For most signals the default action is to terminate the process and
+generate a core dump.
 See the table below.
 Note that the term
 .Em delivery