svn commit: r368384 - in head/sys: compat/linux conf

2020-12-06 Thread Tijl Coosemans
Author: tijl
Date: Sun Dec  6 10:58:55 2020
New Revision: 368384
URL: https://svnweb.freebsd.org/changeset/base/368384

Log:
  Move V4L feature declarations and DTrace provider definitions from
  linux_common.c to linux_util.c so they become available on i386.
  
  linux_common.c defines the linux_common kernel module but this module does
  not exist on i386 and linux_common.c is not included in the linux module.
  linux_util.c is included in the linux_common module on amd64 and the linux
  module on i386.
  
  Remove linux_common.c from files.i386 again.  It was added recently in
  r367433 when the DTrace provider definitions were moved.
  
  The V4L feature declarations were moved to linux_common in r283423.

Modified:
  head/sys/compat/linux/linux_common.c
  head/sys/compat/linux/linux_util.c
  head/sys/conf/files.i386

Modified: head/sys/compat/linux/linux_common.c
==
--- head/sys/compat/linux/linux_common.cSun Dec  6 08:01:27 2020
(r368383)
+++ head/sys/compat/linux/linux_common.cSun Dec  6 10:58:55 2020
(r368384)
@@ -36,33 +36,14 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 
-FEATURE(linuxulator_v4l, "V4L ioctl wrapper support in the linuxulator");
-FEATURE(linuxulator_v4l2, "V4L2 ioctl wrapper support in the linuxulator");
-
 MODULE_VERSION(linux_common, 1);
-
-/**
- * Special DTrace provider for the linuxulator.
- *
- * In this file we define the provider for the entire linuxulator. All
- * modules (= files of the linuxulator) use it.
- *
- * We define a different name depending on the emulated bitsize, see
- * ../..//linux{,32}/linux.h, e.g.:
- *  native bitsize  = linuxulator
- *  amd64, 32bit emulation  = linuxulator32
- */
-LIN_SDT_PROVIDER_DEFINE(linuxulator);
-LIN_SDT_PROVIDER_DEFINE(linuxulator32);
 
 SET_DECLARE(linux_device_handler_set, struct linux_device_handler);
 

Modified: head/sys/compat/linux/linux_util.c
==
--- head/sys/compat/linux/linux_util.c  Sun Dec  6 08:01:27 2020
(r368383)
+++ head/sys/compat/linux/linux_util.c  Sun Dec  6 10:58:55 2020
(r368384)
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+#include 
 #include 
 #include 
 
@@ -61,6 +62,23 @@ MALLOC_DEFINE(M_LINUX, "linux", "Linux mode structures
 MALLOC_DEFINE(M_EPOLL, "lepoll", "Linux events structures");
 MALLOC_DEFINE(M_FUTEX, "futex", "Linux futexes");
 MALLOC_DEFINE(M_FUTEX_WP, "futex wp", "Linux futex waiting proc");
+
+FEATURE(linuxulator_v4l, "V4L ioctl wrapper support in the linuxulator");
+FEATURE(linuxulator_v4l2, "V4L2 ioctl wrapper support in the linuxulator");
+
+/**
+ * Special DTrace provider for the linuxulator.
+ *
+ * In this file we define the provider for the entire linuxulator. All
+ * modules (= files of the linuxulator) use it.
+ *
+ * We define a different name depending on the emulated bitsize, see
+ * ../..//linux{,32}/linux.h, e.g.:
+ *  native bitsize  = linuxulator
+ *  amd64, 32bit emulation  = linuxulator32
+ */
+LIN_SDT_PROVIDER_DEFINE(linuxulator);
+LIN_SDT_PROVIDER_DEFINE(linuxulator32);
 
 char linux_emul_path[MAXPATHLEN] = "/compat/linux";
 

Modified: head/sys/conf/files.i386
==
--- head/sys/conf/files.i386Sun Dec  6 08:01:27 2020(r368383)
+++ head/sys/conf/files.i386Sun Dec  6 10:58:55 2020(r368384)
@@ -52,7 +52,6 @@ cddl/dev/dtrace/i386/dtrace_asm.S 
optional dtrace co
 cddl/dev/dtrace/i386/dtrace_subr.c optional dtrace 
compile-with "${DTRACE_C}"
 compat/linprocfs/linprocfs.c   optional linprocfs
 compat/linsysfs/linsysfs.c optional linsysfs
-compat/linux/linux_common.coptional compat_linux
 compat/linux/linux_dummy.c optional compat_linux
 compat/linux/linux_event.c optional compat_linux
 compat/linux/linux_emul.c  optional compat_linux
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r368372 - in head/sys: amd64/linux32 conf modules/linux

2020-12-05 Thread Tijl Coosemans
Author: tijl
Date: Sat Dec  5 14:53:24 2020
New Revision: 368372
URL: https://svnweb.freebsd.org/changeset/base/368372

Log:
  Fix i386 linux module after r367395.
  
  In r367395 parts of machine dependent linux_dummy.c were moved to a new
  machine independent file sys/compat/linux/linux_dummy.c and the existing
  linux_dummy.c was renamed to linux_dummy_machdep.c.
  
  Add linux_dummy_machdep.c to the linux module for i386.
  Rename sys/amd64/linux32/linux_dummy.c for consistency.
  Add the new linux_dummy.c to the linux module for i386.

Added:
  head/sys/amd64/linux32/linux32_dummy_machdep.c
 - copied unchanged from r368371, head/sys/amd64/linux32/linux32_dummy.c
Deleted:
  head/sys/amd64/linux32/linux32_dummy.c
Modified:
  head/sys/conf/files.amd64
  head/sys/modules/linux/Makefile

Copied: head/sys/amd64/linux32/linux32_dummy_machdep.c (from r368371, 
head/sys/amd64/linux32/linux32_dummy.c)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/amd64/linux32/linux32_dummy_machdep.c  Sat Dec  5 14:53:24 
2020(r368372, copy of r368371, head/sys/amd64/linux32/linux32_dummy.c)
@@ -0,0 +1,89 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 1994-1995 Søren Schmidt
+ * All rights reserved.
+ *
+ * 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 AUTHOR 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 AUTHOR 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.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+/* DTrace init */
+LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE);
+
+UNIMPLEMENTED(break);
+UNIMPLEMENTED(ftime);
+UNIMPLEMENTED(gtty);
+UNIMPLEMENTED(stty);
+UNIMPLEMENTED(lock);
+UNIMPLEMENTED(mpx);
+UNIMPLEMENTED(prof);
+UNIMPLEMENTED(profil);
+UNIMPLEMENTED(ulimit);
+
+DUMMY(stime);
+DUMMY(olduname);
+DUMMY(uname);
+DUMMY(bdflush);
+DUMMY(ptrace);
+DUMMY(mq_open);
+DUMMY(mq_unlink);
+DUMMY(mq_timedsend);
+DUMMY(mq_timedreceive);
+DUMMY(mq_notify);
+DUMMY(mq_getsetattr);
+/* Linux 4.11: */
+DUMMY(arch_prctl);
+/* Linux 5.0: */
+DUMMY(clock_gettime64);
+DUMMY(clock_settime64);
+DUMMY(clock_adjtime64);
+DUMMY(clock_getres_time64);
+DUMMY(clock_nanosleep_time64);
+DUMMY(timer_gettime64);
+DUMMY(timer_settime64);
+DUMMY(timerfd_gettime64);
+DUMMY(timerfd_settime64);
+DUMMY(utimensat_time64);
+DUMMY(pselect6_time64);
+DUMMY(ppoll_time64);
+DUMMY(io_pgetevents_time64);
+DUMMY(recvmmsg_time64);
+DUMMY(mq_timedsend_time64);
+DUMMY(mq_timedreceive_time64);
+DUMMY(semtimedop_time64);
+DUMMY(rt_sigtimedwait_time64);
+DUMMY(futex_time64);
+DUMMY(sched_rr_get_interval_time64);

Modified: head/sys/conf/files.amd64
==
--- head/sys/conf/files.amd64   Sat Dec  5 14:38:46 2020(r368371)
+++ head/sys/conf/files.amd64   Sat Dec  5 14:53:24 2020(r368372)
@@ -405,7 +405,7 @@ compat/linsysfs/linsysfs.c  optionallinsysfs
 #
 # Linux/i386 binary support
 #
-amd64/linux32/linux32_dummy.c  optionalcompat_linux32
+amd64/linux32/linux32_dummy_machdep.c  optionalcompat_linux32
 amd64/linux32/linux32_machdep.coptionalcompat_linux32
 amd64/linux32/linux32_support.soptionalcompat_linux32  
\
dependency  "linux32_assym.h"

Modified: head/sys/modules/linux/Makefile
==
--- head/sys/modules/linux/Makefile Sat Dec  5 14:38:46 2020
(r368371)
+++ head/sys/modules/linux/Makefile Sat Dec  5 14:53:24 2020
(r368372)
@@ -13,7 +13,7 @@ CFLAGS+=-DCOMPAT_FREEBSD32 -DCOMPAT_LINUX32
 VDSO=  linux${SFX}_vdso
 
 KMOD=  linux
-SRCS=  

svn commit: r361700 - in head: etc/mtree secure/lib/libcrypto secure/lib/libcrypto/engines

2020-06-01 Thread Tijl Coosemans
Author: tijl
Date: Mon Jun  1 18:58:09 2020
New Revision: 361700
URL: https://svnweb.freebsd.org/changeset/base/361700

Log:
  Install 32-bit libcrypto engines in /usr/lib32/engines instead of
  /usr/lib32 and let 32-bit libcrypto search that location instead of
  /usr/lib/engines.
  
  Reviewed by:  jkim

Modified:
  head/etc/mtree/BSD.lib32.dist
  head/secure/lib/libcrypto/Makefile.inc
  head/secure/lib/libcrypto/engines/Makefile.inc

Modified: head/etc/mtree/BSD.lib32.dist
==
--- head/etc/mtree/BSD.lib32.dist   Mon Jun  1 18:43:51 2020
(r361699)
+++ head/etc/mtree/BSD.lib32.dist   Mon Jun  1 18:58:09 2020
(r361700)
@@ -8,6 +8,8 @@
 lib32
 dtrace
 ..
+engines
+..
 geom
 ..
 i18n

Modified: head/secure/lib/libcrypto/Makefile.inc
==
--- head/secure/lib/libcrypto/Makefile.inc  Mon Jun  1 18:43:51 2020
(r361699)
+++ head/secure/lib/libcrypto/Makefile.inc  Mon Jun  1 18:58:09 2020
(r361700)
@@ -75,7 +75,7 @@ CFLAGS+=  -DPOLY1305_ASM
 
 .if defined(LIB)
 CFLAGS+=   -DOPENSSLDIR="\"/etc/ssl\""
-CFLAGS+=   -DENGINESDIR="\"/usr/lib/engines\""
+CFLAGS+=   -DENGINESDIR="\"${LIBDIR}/engines\""
 .endif
 
 CFLAGS+=   -DNDEBUG

Modified: head/secure/lib/libcrypto/engines/Makefile.inc
==
--- head/secure/lib/libcrypto/engines/Makefile.inc  Mon Jun  1 18:43:51 
2020(r361699)
+++ head/secure/lib/libcrypto/engines/Makefile.inc  Mon Jun  1 18:58:09 
2020(r361700)
@@ -1,6 +1,6 @@
 # $FreeBSD$
 
-SHLIBDIR?= /usr/lib/engines
+SHLIBDIR=  ${LIBDIR}/engines
 
 LCRYPTO_SRC=   ${SRCTOP}/crypto/openssl
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r361663 - in head: etc/mtree lib/libxo/encoder/csv lib/libxo/libxo

2020-05-31 Thread Tijl Coosemans
Author: tijl
Date: Sun May 31 17:20:17 2020
New Revision: 361663
URL: https://svnweb.freebsd.org/changeset/base/361663

Log:
  Fix installation of libxo encoder modules.
  
  Because the install location was hardcoded in the Makefile as
  /usr/lib/libxo/encoder, the lib32 version was installed over the native
  version.  Replace /usr/lib with ${LIBDIR}.
  
  Also define SHLIB_NAME instead of LIB + FILES.  This prevents building a
  static library.
  
  MFC after:2 weeks

Modified:
  head/etc/mtree/BSD.lib32.dist
  head/lib/libxo/encoder/csv/Makefile
  head/lib/libxo/libxo/Makefile

Modified: head/etc/mtree/BSD.lib32.dist
==
--- head/etc/mtree/BSD.lib32.dist   Sun May 31 15:31:47 2020
(r361662)
+++ head/etc/mtree/BSD.lib32.dist   Sun May 31 17:20:17 2020
(r361663)
@@ -12,5 +12,9 @@
 ..
 i18n
 ..
+libxo
+encoder
+..
+..
 ..
 ..

Modified: head/lib/libxo/encoder/csv/Makefile
==
--- head/lib/libxo/encoder/csv/Makefile Sun May 31 15:31:47 2020
(r361662)
+++ head/lib/libxo/encoder/csv/Makefile Sun May 31 17:20:17 2020
(r361663)
@@ -8,30 +8,17 @@ LIBXOSRC= ${SRCTOP}/contrib/libxo
 
 .PATH: ${LIBXOSRC}/encoder/csv
 
-# We use FILES to install the encoder library under the proper/magic
-# name, in the proper/magic directory.  libxo looks for encoders from
-# "--libxo encoder=name" as "${prefix}/lib/libxo/encoder/${name}.enc"
-FILES = libenc_csv.so
-FILESNAME_libenc_csv.so= csv.enc
-FILESDIR = /usr/lib/libxo/encoder
+SHLIBDIR=  ${LIBDIR}/libxo/encoder
+SHLIB_NAME=csv.enc
 
-LIB=   enc_csv
-SHLIB_MAJOR=0
-SHLIB_NAME= lib${LIB}.so
-
 SRCS=  enc_csv.c
 
 CFLAGS+=-I${LIBXOSRC}/libxo -I${.CURDIR}
-CFLAGS+=-DXO_ENCODERDIR=\"/usr/lib/libxo/encoder\"
+CFLAGS+=-DXO_ENCODERDIR=\"${LIBDIR}/libxo/encoder\"
 
 LIBADD=util xo
 LDFLAGS += -L${.OBJDIR:H:H}/libxo
 
 WARNS?= 5
 
-# Need to define a fake "install" target to block the one in bsd.lib.mk,
-# since that one will install our lib in the wrong place (/usr/lib/).
-install: realinstall
-
 .include 
-.include 

Modified: head/lib/libxo/libxo/Makefile
==
--- head/lib/libxo/libxo/Makefile   Sun May 31 15:31:47 2020
(r361662)
+++ head/lib/libxo/libxo/Makefile   Sun May 31 17:20:17 2020
(r361663)
@@ -16,7 +16,7 @@ SHLIB_MAJOR=0
 SRCS=  libxo.c xo_encoder.c xo_syslog.c
 
 CFLAGS+=-I${LIBXOSRC}/libxo -I${.CURDIR}
-CFLAGS+=-DXO_ENCODERDIR=\"/usr/lib/libxo/encoder\"
+CFLAGS+=-DXO_ENCODERDIR=\"${LIBDIR}/libxo/encoder\"
 
 INCS=  xo.h xo_encoder.h
 INCSDIR=${INCLUDEDIR}/libxo
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r358673 - head/sys/compat/linux

2020-03-05 Thread Tijl Coosemans
Author: tijl
Date: Thu Mar  5 14:41:27 2020
New Revision: 358673
URL: https://svnweb.freebsd.org/changeset/base/358673

Log:
  Move compat.linux.map_sched_prio sysctl definition to linux_mib.c so it is
  only defined by linux_common kernel module and not both linux and linux64
  modules.
  
  Reported by:  Yuri Pankov 

Modified:
  head/sys/compat/linux/linux_mib.c
  head/sys/compat/linux/linux_mib.h
  head/sys/compat/linux/linux_misc.c

Modified: head/sys/compat/linux/linux_mib.c
==
--- head/sys/compat/linux/linux_mib.c   Thu Mar  5 14:13:22 2020
(r358672)
+++ head/sys/compat/linux/linux_mib.c   Thu Mar  5 14:41:27 2020
(r358673)
@@ -71,6 +71,11 @@ int linux_preserve_vstatus = 0;
 SYSCTL_INT(_compat_linux, OID_AUTO, preserve_vstatus, CTLFLAG_RWTUN,
 _preserve_vstatus, 0, "Preserve VSTATUS termios(4) flag");
 
+bool linux_map_sched_prio = true;
+SYSCTL_BOOL(_compat_linux, OID_AUTO, map_sched_prio, CTLFLAG_RDTUN,
+_map_sched_prio, 0, "Map scheduler priorities to Linux priorities "
+"(not POSIX compliant)");
+
 static int linux_set_osname(struct thread *td, char *osname);
 static int linux_set_osrelease(struct thread *td, char *osrelease);
 static int linux_set_oss_version(struct thread *td, int oss_version);

Modified: head/sys/compat/linux/linux_mib.h
==
--- head/sys/compat/linux/linux_mib.h   Thu Mar  5 14:13:22 2020
(r358672)
+++ head/sys/compat/linux/linux_mib.h   Thu Mar  5 14:41:27 2020
(r358673)
@@ -64,5 +64,6 @@ int   linux_kernver(struct thread *td);
 
 extern int linux_ignore_ip_recverr;
 extern int linux_preserve_vstatus;
+extern bool linux_map_sched_prio;
 
 #endif /* _LINUX_MIB_H_ */

Modified: head/sys/compat/linux/linux_misc.c
==
--- head/sys/compat/linux/linux_misc.c  Thu Mar  5 14:13:22 2020
(r358672)
+++ head/sys/compat/linux/linux_misc.c  Thu Mar  5 14:41:27 2020
(r358673)
@@ -144,11 +144,6 @@ struct l_pselect6arg {
l_size_tss_len;
 };
 
-static bool map_sched_prio = true;
-SYSCTL_BOOL(_compat_linux, OID_AUTO, map_sched_prio, CTLFLAG_RDTUN,
-_sched_prio, 0, "Map scheduler priorities to Linux priorities "
-"(not POSIX compliant)");
-
 static int linux_utimensat_nsec_valid(l_long);
 
 
@@ -1424,7 +1419,7 @@ linux_sched_setscheduler(struct thread *td,
if (error)
return (error);
 
-   if (map_sched_prio) {
+   if (linux_map_sched_prio) {
switch (policy) {
case SCHED_OTHER:
if (sched_param.sched_priority != 0)
@@ -1494,7 +1489,7 @@ linux_sched_get_priority_max(struct thread *td,
 {
struct sched_get_priority_max_args bsd;
 
-   if (map_sched_prio) {
+   if (linux_map_sched_prio) {
switch (args->policy) {
case LINUX_SCHED_OTHER:
td->td_retval[0] = 0;
@@ -1530,7 +1525,7 @@ linux_sched_get_priority_min(struct thread *td,
 {
struct sched_get_priority_min_args bsd;
 
-   if (map_sched_prio) {
+   if (linux_map_sched_prio) {
switch (args->policy) {
case LINUX_SCHED_OTHER:
td->td_retval[0] = 0;
@@ -1934,7 +1929,7 @@ linux_sched_setparam(struct thread *td,
if (tdt == NULL)
return (ESRCH);
 
-   if( map_sched_prio ) {
+   if (linux_map_sched_prio) {
error = kern_sched_getscheduler(td, tdt, );
if (error)
goto out;
@@ -1990,7 +1985,7 @@ linux_sched_getparam(struct thread *td,
return (error);
}
 
-   if (map_sched_prio) {
+   if (linux_map_sched_prio) {
error = kern_sched_getscheduler(td, tdt, );
PROC_UNLOCK(tdt->td_proc);
if (error)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r358483 - head/sys/compat/linux

2020-03-01 Thread Tijl Coosemans
Author: tijl
Date: Sun Mar  1 13:12:04 2020
New Revision: 358483
URL: https://svnweb.freebsd.org/changeset/base/358483

Log:
  linuxulator: Map scheduler priorities to Linux priorities.
  
  On Linux the valid range of priorities for the SCHED_FIFO and SCHED_RR
  scheduling policies is [1,99].  For SCHED_OTHER the single valid priority is
  0.  On FreeBSD it is [0,31] for all policies.  Programs are supposed to
  query the valid range using sched_get_priority_(min|max), but of course some
  programs assume the Linux values are valid.
  
  This commit adds a tunable compat.linux.map_sched_prio.  When enabled
  sched_get_priority_(min|max) return the Linux values and sched_setscheduler
  and sched_(get|set)param translate between FreeBSD and Linux values.
  
  Because there are more Linux levels than FreeBSD levels, multiple Linux
  levels map to a single FreeBSD level, which means pre-emption might not
  happen as it does on Linux, so the tunable allows to disable this behaviour.
  It is enabled by default because I think it is unlikely that anyone runs
  real-time software under Linux emulation on FreeBSD that critically relies
  on correct pre-emption.
  
  This fixes FMOD, a commercial sound library used by several games.
  
  PR:   240043
  Tested by:Alex S 
  Reviewed by:  dchagin
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D23790

Modified:
  head/sys/compat/linux/linux_misc.c
  head/sys/compat/linux/linux_misc.h

Modified: head/sys/compat/linux/linux_misc.c
==
--- head/sys/compat/linux/linux_misc.c  Sun Mar  1 12:34:27 2020
(r358482)
+++ head/sys/compat/linux/linux_misc.c  Sun Mar  1 13:12:04 2020
(r358483)
@@ -144,6 +144,11 @@ struct l_pselect6arg {
l_size_tss_len;
 };
 
+static bool map_sched_prio = true;
+SYSCTL_BOOL(_compat_linux, OID_AUTO, map_sched_prio, CTLFLAG_RDTUN,
+_sched_prio, 0, "Map scheduler priorities to Linux priorities "
+"(not POSIX compliant)");
+
 static int linux_utimensat_nsec_valid(l_long);
 
 
@@ -1419,6 +1424,33 @@ linux_sched_setscheduler(struct thread *td,
if (error)
return (error);
 
+   if (map_sched_prio) {
+   switch (policy) {
+   case SCHED_OTHER:
+   if (sched_param.sched_priority != 0)
+   return (EINVAL);
+
+   sched_param.sched_priority =
+   PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE;
+   break;
+   case SCHED_FIFO:
+   case SCHED_RR:
+   if (sched_param.sched_priority < 1 ||
+   sched_param.sched_priority >= LINUX_MAX_RT_PRIO)
+   return (EINVAL);
+
+   /*
+* Map [1, LINUX_MAX_RT_PRIO - 1] to
+* [0, RTP_PRIO_MAX - RTP_PRIO_MIN] (rounding down).
+*/
+   sched_param.sched_priority =
+   (sched_param.sched_priority - 1) *
+   (RTP_PRIO_MAX - RTP_PRIO_MIN + 1) /
+   (LINUX_MAX_RT_PRIO - 1);
+   break;
+   }
+   }
+
tdt = linux_tdfind(td, args->pid, -1);
if (tdt == NULL)
return (ESRCH);
@@ -1462,6 +1494,20 @@ linux_sched_get_priority_max(struct thread *td,
 {
struct sched_get_priority_max_args bsd;
 
+   if (map_sched_prio) {
+   switch (args->policy) {
+   case LINUX_SCHED_OTHER:
+   td->td_retval[0] = 0;
+   return (0);
+   case LINUX_SCHED_FIFO:
+   case LINUX_SCHED_RR:
+   td->td_retval[0] = LINUX_MAX_RT_PRIO - 1;
+   return (0);
+   default:
+   return (EINVAL);
+   }
+   }
+
switch (args->policy) {
case LINUX_SCHED_OTHER:
bsd.policy = SCHED_OTHER;
@@ -1484,6 +1530,20 @@ linux_sched_get_priority_min(struct thread *td,
 {
struct sched_get_priority_min_args bsd;
 
+   if (map_sched_prio) {
+   switch (args->policy) {
+   case LINUX_SCHED_OTHER:
+   td->td_retval[0] = 0;
+   return (0);
+   case LINUX_SCHED_FIFO:
+   case LINUX_SCHED_RR:
+   td->td_retval[0] = 1;
+   return (0);
+   default:
+   return (EINVAL);
+   }
+   }
+
switch (args->policy) {
case LINUX_SCHED_OTHER:
bsd.policy = SCHED_OTHER;
@@ -1864,7 +1924,7 @@ linux_sched_setparam(struct thread *td,
 {
struct sched_param sched_param;
struct thread *tdt;
-   int error;
+   int error, 

svn commit: r352618 - head/sys/compat/linsysfs

2019-09-23 Thread Tijl Coosemans
Author: tijl
Date: Mon Sep 23 12:27:55 2019
New Revision: 352618
URL: https://svnweb.freebsd.org/changeset/base/352618

Log:
  Create a "drm" subdirectory for drm devices in linsysfs.  Recent versions of
  linux libdrm check for the existence of this directory:
  
  
https://cgit.freedesktop.org/mesa/drm/commit/?id=f8392583418aef5e27bfed9989aeb601e20cc96d
  
  MFC after:2 weeks

Modified:
  head/sys/compat/linsysfs/linsysfs.c

Modified: head/sys/compat/linsysfs/linsysfs.c
==
--- head/sys/compat/linsysfs/linsysfs.c Mon Sep 23 08:53:14 2019
(r352617)
+++ head/sys/compat/linsysfs/linsysfs.c Mon Sep 23 12:27:55 2019
(r352618)
@@ -520,6 +520,7 @@ linsysfs_run_bus(device_t dev, struct pfs_node *dir, s
device_get_unit(dev) >= 0) {
dinfo = device_get_ivars(parent);
if (dinfo != NULL && dinfo->cfg.baseclass == 
PCIC_DISPLAY) {
+   pfs_create_dir(dir, "drm", NULL, NULL, NULL, 0);
sprintf(devname, "226:%d",
device_get_unit(dev));
sub_dir = pfs_create_dir(chardev,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349957 - head/usr.bin/top

2019-07-12 Thread Tijl Coosemans
Author: tijl
Date: Fri Jul 12 21:19:47 2019
New Revision: 349957
URL: https://svnweb.freebsd.org/changeset/base/349957

Log:
  Fix layout.  -C needs to be styled as a flag here, not as a new list item.
  
  MFC after:2 weeks

Modified:
  head/usr.bin/top/top.1

Modified: head/usr.bin/top/top.1
==
--- head/usr.bin/top/top.1  Fri Jul 12 20:59:10 2019(r349956)
+++ head/usr.bin/top/top.1  Fri Jul 12 21:19:47 2019(r349957)
@@ -51,7 +51,7 @@ By default top displays the weighted CPU percentage in
 .Xr ps 1
 displays as CPU).
 Each time
-.It Fl C
+.Fl C
 flag is passed it toggles between \*(lqraw cpu\*(rq mode
 and \*(lqweighted cpu\*(rq mode, showing the \*(lqCPU\*(rq or
 the \*(lqWCPU\*(rq column respectively.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349880 - head/sys/compat/linux

2019-07-10 Thread Tijl Coosemans
Author: tijl
Date: Wed Jul 10 08:19:33 2019
New Revision: 349880
URL: https://svnweb.freebsd.org/changeset/base/349880

Log:
  Let linuxulator mprotect mask unsupported bits before calling kern_mprotect.
  
  After r349240 kern_mprotect returns EINVAL for unsupported bits in the prot
  argument.  Linux rtld uses PROT_GROWSDOWN and PROT_GROWS_UP when marking the
  stack executable.  Mask these bits like kern_mprotect used to do.  For other
  unsupported bits EINVAL is returned like Linux does.
  
  Reviewed by:  trasz, brooks
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D20864

Modified:
  head/sys/compat/linux/linux_mmap.c
  head/sys/compat/linux/linux_mmap.h

Modified: head/sys/compat/linux/linux_mmap.c
==
--- head/sys/compat/linux/linux_mmap.c  Wed Jul 10 08:08:14 2019
(r349879)
+++ head/sys/compat/linux/linux_mmap.c  Wed Jul 10 08:19:33 2019
(r349880)
@@ -228,6 +228,11 @@ int
 linux_mprotect_common(struct thread *td, uintptr_t addr, size_t len, int prot)
 {
 
+   /* XXX Ignore PROT_GROWSDOWN and PROT_GROWSUP for now. */
+   prot &= ~(LINUX_PROT_GROWSDOWN | LINUX_PROT_GROWSUP);
+   if ((prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC)) != 0)
+   return (EINVAL);
+
 #if defined(__amd64__)
linux_fixup_prot(td, );
 #endif

Modified: head/sys/compat/linux/linux_mmap.h
==
--- head/sys/compat/linux/linux_mmap.h  Wed Jul 10 08:08:14 2019
(r349879)
+++ head/sys/compat/linux/linux_mmap.h  Wed Jul 10 08:19:33 2019
(r349880)
@@ -41,6 +41,8 @@
 #defineLINUX_MAP_ANON  0x0020
 #defineLINUX_MAP_GROWSDOWN 0x0100
 
+#defineLINUX_PROT_GROWSDOWN0x0100
+#defineLINUX_PROT_GROWSUP  0x0200
 
 int linux_mmap_common(struct thread *, uintptr_t, size_t, int, int,
int, off_t);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349706 - head

2019-07-03 Thread Tijl Coosemans
Author: tijl
Date: Wed Jul  3 20:52:10 2019
New Revision: 349706
URL: https://svnweb.freebsd.org/changeset/base/349706

Log:
  Fix path of lib32 libcasper.
  
  Reported by:  jhb
  MFC after:1 week

Modified:
  head/ObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Wed Jul  3 20:52:07 2019(r349705)
+++ head/ObsoleteFiles.inc  Wed Jul  3 20:52:10 2019(r349706)
@@ -825,7 +825,7 @@ OLD_FILES+=usr/share/man/man3/arc4random_stir.3.gz
 OLD_FILES+=usr/bin/send-pr
 # 20180725: Cleanup old libcasper.so.0
 OLD_LIBS+=lib/libcasper.so.0
-OLD_LIBS+=lib32/libcasper.so.0
+OLD_LIBS+=usr/lib32/libcasper.so.0
 # 20180722: indent(1) option renamed, test files follow
 OLD_FILES+=usr/bin/indent/tests/nsac.0
 OLD_FILES+=usr/bin/indent/tests/nsac.0.pro
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349641 - head/tools/build/mk

2019-07-03 Thread Tijl Coosemans
Author: tijl
Date: Wed Jul  3 09:14:39 2019
New Revision: 349641
URL: https://svnweb.freebsd.org/changeset/base/349641

Log:
  Also remove lib32 versions of libradius.
  
  MFC after:1 week

Modified:
  head/tools/build/mk/OptionalObsoleteFiles.inc

Modified: head/tools/build/mk/OptionalObsoleteFiles.inc
==
--- head/tools/build/mk/OptionalObsoleteFiles.inc   Wed Jul  3 09:08:17 
2019(r349640)
+++ head/tools/build/mk/OptionalObsoleteFiles.inc   Wed Jul  3 09:14:39 
2019(r349641)
@@ -8321,6 +8321,12 @@ OLD_LIBS+=usr/lib/libradius.so.4
 OLD_FILES+=usr/lib/libradius_p.a
 OLD_FILES+=usr/lib/pam_radius.so
 OLD_LIBS+=usr/lib/pam_radius.so.6
+OLD_FILES+=usr/lib32/libradius.a
+OLD_FILES+=usr/lib32/libradius.so
+OLD_LIBS+=usr/lib32/libradius.so.4
+OLD_FILES+=usr/lib32/libradius_p.a
+OLD_FILES+=usr/lib32/pam_radius.so
+OLD_LIBS+=usr/lib32/pam_radius.so.6
 OLD_FILES+=usr/include/radlib.h
 OLD_FILES+=usr/include/radlib_vs.h
 OLD_FILES+=usr/share/man/man3/libradius.3.gz
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349640 - head

2019-07-03 Thread Tijl Coosemans
Author: tijl
Date: Wed Jul  3 09:08:17 2019
New Revision: 349640
URL: https://svnweb.freebsd.org/changeset/base/349640

Log:
  Also remove lib32 version of libcasper.so.0.

Modified:
  head/ObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Wed Jul  3 09:06:39 2019(r349639)
+++ head/ObsoleteFiles.inc  Wed Jul  3 09:08:17 2019(r349640)
@@ -825,6 +825,7 @@ OLD_FILES+=usr/share/man/man3/arc4random_stir.3.gz
 OLD_FILES+=usr/bin/send-pr
 # 20180725: Cleanup old libcasper.so.0
 OLD_LIBS+=lib/libcasper.so.0
+OLD_LIBS+=lib32/libcasper.so.0
 # 20180722: indent(1) option renamed, test files follow
 OLD_FILES+=usr/bin/indent/tests/nsac.0
 OLD_FILES+=usr/bin/indent/tests/nsac.0.pro
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349639 - head

2019-07-03 Thread Tijl Coosemans
Author: tijl
Date: Wed Jul  3 09:06:39 2019
New Revision: 349639
URL: https://svnweb.freebsd.org/changeset/base/349639

Log:
  Also remove lib32 version of libprivateifconfig after r344530.

Modified:
  head/ObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Wed Jul  3 03:42:51 2019(r349638)
+++ head/ObsoleteFiles.inc  Wed Jul  3 09:06:39 2019(r349639)
@@ -388,6 +388,8 @@ OLD_FILES+=usr/include/sys/seq.h
 # 20190222: libifconfig made INTERNALLIB
 OLD_FILES+=usr/lib/libprivateifconfig.a
 OLD_FILES+=usr/lib/libprivateifconfig_p.a
+OLD_FILES+=usr/lib32/libprivateifconfig.a
+OLD_FILES+=usr/lib32/libprivateifconfig_p.a
 # 20190131: pfil(9) changed
 OLD_FILES+=usr/share/man/man9/pfil_hook_get.9.gz
 OLD_FILES+=usr/share/man/man9/pfil_rlock.9.gz
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349548 - head

2019-06-29 Thread Tijl Coosemans
Author: tijl
Date: Sat Jun 29 17:01:56 2019
New Revision: 349548
URL: https://svnweb.freebsd.org/changeset/base/349548

Log:
  Build lib32 libl.  The library is built from usr.bin/lex/lib.  It would be
  better to move this directory to lib/libl, but this requires more extensive
  changes to Makefile.inc1.  This simple fix can be MFCed quickly.
  
  PR:   238874
  Reviewed by:  imp
  MFC after:3 days

Modified:
  head/Makefile.libcompat

Modified: head/Makefile.libcompat
==
--- head/Makefile.libcompat Sat Jun 29 16:11:09 2019(r349547)
+++ head/Makefile.libcompat Sat Jun 29 17:01:56 2019(r349548)
@@ -136,6 +136,7 @@ LIBCOMPATIMAKE+=${LIBCOMPATWMAKE:NINSTALL=*:NDESTDIR=
 
 _LC_LIBDIRS.yes=   lib
 _LC_LIBDIRS.yes+=  gnu/lib
+_LC_LIBDIRS.yes+=  usr.bin/lex/lib
 _LC_LIBDIRS.${MK_CDDL:tl}+=cddl/lib
 _LC_LIBDIRS.${MK_CRYPT:tl}+=   secure/lib
 _LC_LIBDIRS.${MK_KERBEROS:tl}+=kerberos5/lib
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r340674 - head/sys/compat/linux

2018-11-20 Thread Tijl Coosemans
Author: tijl
Date: Tue Nov 20 14:18:57 2018
New Revision: 340674
URL: https://svnweb.freebsd.org/changeset/base/340674

Log:
  Fix another user address dereference in linux_sendmsg syscall.
  
  This was hidden behind the LINUX_CMSG_NXTHDR macro which dereferences its
  second argument.  Stop using the macro as well as LINUX_CMSG_FIRSTHDR.  Use
  the size field of the kernel copy of the control message header to obtain
  the next control message.
  
  PR:   217901
  MFC after:2 days
  X-MFC-With:   r340631

Modified:
  head/sys/compat/linux/linux_socket.c

Modified: head/sys/compat/linux/linux_socket.c
==
--- head/sys/compat/linux/linux_socket.cTue Nov 20 11:23:33 2018
(r340673)
+++ head/sys/compat/linux/linux_socket.cTue Nov 20 14:18:57 2018
(r340674)
@@ -1096,6 +1096,7 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
sa_family_t sa_family;
void *data;
l_size_t len;
+   l_size_t clen;
int error;
 
error = copyin(msghdr, _msg, sizeof(linux_msg));
@@ -1127,7 +1128,7 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
 
control = NULL;
 
-   if ((ptr_cmsg = LINUX_CMSG_FIRSTHDR(_msg)) != NULL) {
+   if (linux_msg.msg_controllen >= sizeof(struct l_cmsghdr)) {
error = kern_getsockname(td, s, , );
if (error != 0)
goto bad;
@@ -1140,6 +1141,8 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
data = mtod(control, void *);
datalen = 0;
 
+   ptr_cmsg = PTRIN(linux_msg.msg_control);
+   clen = linux_msg.msg_controllen;
do {
error = copyin(ptr_cmsg, _cmsg,
sizeof(struct l_cmsghdr));
@@ -1147,7 +1150,8 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
goto bad;
 
error = EINVAL;
-   if (linux_cmsg.cmsg_len < sizeof(struct l_cmsghdr))
+   if (linux_cmsg.cmsg_len < sizeof(struct l_cmsghdr) ||
+   linux_cmsg.cmsg_len > clen)
goto bad;
 
if (datalen + CMSG_HDRSZ > MCLBYTES)
@@ -1199,7 +1203,14 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
cmsg->cmsg_len = CMSG_LEN(len);
data = (char *)data + CMSG_SPACE(len);
datalen += CMSG_SPACE(len);
-   } while ((ptr_cmsg = LINUX_CMSG_NXTHDR(_msg, ptr_cmsg)));
+
+   if (clen <= LINUX_CMSG_ALIGN(linux_cmsg.cmsg_len))
+   break;
+
+   clen -= LINUX_CMSG_ALIGN(linux_cmsg.cmsg_len);
+   ptr_cmsg = (struct l_cmsghdr *)((char *)ptr_cmsg +
+   LINUX_CMSG_ALIGN(linux_cmsg.cmsg_len));
+   } while(clen >= sizeof(struct l_cmsghdr));
 
control->m_len = datalen;
if (datalen == 0) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r340631 - head/sys/compat/linux

2018-11-19 Thread Tijl Coosemans
Author: tijl
Date: Mon Nov 19 15:31:54 2018
New Revision: 340631
URL: https://svnweb.freebsd.org/changeset/base/340631

Log:
  Do proper copyin of control message data in the Linux sendmsg syscall.
  
  Instead of calling m_append with a user address, allocate an mbuf cluster
  and copy data into it using copyin.  For the SCM_CREDS case, instead of
  zeroing a stack variable and appending that to the mbuf, zero part of the
  mbuf cluster directly.  One mbuf cluster is also the size limit used by
  the FreeBSD sendmsg syscall (uipc_syscalls.c:sockargs()).
  
  PR:   217901
  Reviewed by:  kib
  MFC after:3 days

Modified:
  head/sys/compat/linux/linux_socket.c

Modified: head/sys/compat/linux/linux_socket.c
==
--- head/sys/compat/linux/linux_socket.cMon Nov 19 15:29:40 2018
(r340630)
+++ head/sys/compat/linux/linux_socket.cMon Nov 19 15:31:54 2018
(r340631)
@@ -1085,7 +1085,6 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
 l_uint flags)
 {
struct cmsghdr *cmsg;
-   struct cmsgcred cmcred;
struct mbuf *control;
struct msghdr msg;
struct l_cmsghdr linux_cmsg;
@@ -1096,6 +1095,7 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
struct sockaddr *sa;
sa_family_t sa_family;
void *data;
+   l_size_t len;
int error;
 
error = copyin(msghdr, _msg, sizeof(linux_msg));
@@ -1126,7 +1126,6 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
return (error);
 
control = NULL;
-   cmsg = NULL;
 
if ((ptr_cmsg = LINUX_CMSG_FIRSTHDR(_msg)) != NULL) {
error = kern_getsockname(td, s, , );
@@ -1136,8 +1135,10 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
free(sa, M_SONAME);
 
error = ENOBUFS;
-   cmsg = malloc(CMSG_HDRSZ, M_LINUX, M_WAITOK|M_ZERO);
control = m_get(M_WAITOK, MT_CONTROL);
+   MCLGET(control, M_WAITOK);
+   data = mtod(control, void *);
+   datalen = 0;
 
do {
error = copyin(ptr_cmsg, _cmsg,
@@ -1149,10 +1150,14 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
if (linux_cmsg.cmsg_len < sizeof(struct l_cmsghdr))
goto bad;
 
+   if (datalen + CMSG_HDRSZ > MCLBYTES)
+   goto bad;
+
/*
 * Now we support only SCM_RIGHTS and SCM_CRED,
 * so return EINVAL in any other cmsg_type
 */
+   cmsg = data;
cmsg->cmsg_type =
linux_to_bsd_cmsg_type(linux_cmsg.cmsg_type);
cmsg->cmsg_level =
@@ -1170,35 +1175,34 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
if (sa_family != AF_UNIX)
continue;
 
-   data = LINUX_CMSG_DATA(ptr_cmsg);
-   datalen = linux_cmsg.cmsg_len - L_CMSG_HDRSZ;
+   if (cmsg->cmsg_type == SCM_CREDS) {
+   len = sizeof(struct cmsgcred);
+   if (datalen + CMSG_SPACE(len) > MCLBYTES)
+   goto bad;
 
-   switch (cmsg->cmsg_type)
-   {
-   case SCM_RIGHTS:
-   break;
-
-   case SCM_CREDS:
-   data = 
-   datalen = sizeof(cmcred);
-
/*
 * The lower levels will fill in the structure
 */
-   bzero(data, datalen);
-   break;
+   memset(CMSG_DATA(data), 0, len);
+   } else {
+   len = linux_cmsg.cmsg_len - L_CMSG_HDRSZ;
+   if (datalen + CMSG_SPACE(len) < datalen ||
+   datalen + CMSG_SPACE(len) > MCLBYTES)
+   goto bad;
+
+   error = copyin(LINUX_CMSG_DATA(ptr_cmsg),
+   CMSG_DATA(data), len);
+   if (error != 0)
+   goto bad;
}
 
-   cmsg->cmsg_len = CMSG_LEN(datalen);
-
-   error = ENOBUFS;
-   if (!m_append(control, CMSG_HDRSZ, (c_caddr_t)cmsg))
-   goto bad;
-   if (!m_append(control, datalen, (c_caddr_t)data))
-   goto bad;

svn commit: r340185 - head/sys/amd64/linux32

2018-11-06 Thread Tijl Coosemans
Author: tijl
Date: Tue Nov  6 15:29:44 2018
New Revision: 340185
URL: https://svnweb.freebsd.org/changeset/base/340185

Log:
  Fix builds with COMPAT_LINUX32 in the kernel config.
  
  MFC after:3 days

Modified:
  head/sys/amd64/linux32/linux32_sysvec.c

Modified: head/sys/amd64/linux32/linux32_sysvec.c
==
--- head/sys/amd64/linux32/linux32_sysvec.c Tue Nov  6 14:22:44 2018
(r340184)
+++ head/sys/amd64/linux32/linux32_sysvec.c Tue Nov  6 15:29:44 2018
(r340185)
@@ -32,6 +32,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "opt_compat.h"
+
 #include 
 __FBSDID("$FreeBSD$");
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r340181 - in head/sys: amd64/linux32 compat/linux

2018-11-06 Thread Tijl Coosemans
Author: tijl
Date: Tue Nov  6 13:51:08 2018
New Revision: 340181
URL: https://svnweb.freebsd.org/changeset/base/340181

Log:
  On amd64 both Linux compat modules, linux.ko and linux64.ko, provide
  linux_ioctl_(un)register_handler that allows other driver modules to
  register ioctl handlers.  The ioctl syscall implementation in each Linux
  compat module iterates over the list of handlers and forwards the call to
  the appropriate driver.  Because the registration functions have the same
  name in each module it is not possible for a driver to support both 32 and
  64 bit linux compatibility.
  
  Move the list of ioctl handlers to linux_common.ko so it is shared by
  both Linux modules and all drivers receive both 32 and 64 bit ioctl calls
  with one registration.  These ioctl handlers normally forward the call
  to the FreeBSD ioctl handler which can handle both 32 and 64 bit.
  
  Keep the special COMPAT_LINUX32 ioctl handlers in linux.ko in a separate
  list for now and let the ioctl syscall iterate over that list first.
  Later, COMPAT_LINUX32 support can be added to the 64 bit ioctl handlers
  via a runtime check for ILP32 like is done for COMPAT_FREEBSD32 and then
  this separate list would disappear again.  That is a much bigger effort
  however and this commit is meant to be MFCable.
  
  This enables linux64 support in x11/nvidia-driver*.
  
  PR:   206711
  Reviewed by:  kib
  MFC after:3 days

Modified:
  head/sys/amd64/linux32/linux32_sysvec.c
  head/sys/compat/linux/linux_common.c
  head/sys/compat/linux/linux_ioctl.c
  head/sys/compat/linux/linux_ioctl.h

Modified: head/sys/amd64/linux32/linux32_sysvec.c
==
--- head/sys/amd64/linux32/linux32_sysvec.c Tue Nov  6 12:57:38 2018
(r340180)
+++ head/sys/amd64/linux32/linux32_sysvec.c Tue Nov  6 13:51:08 2018
(r340181)
@@ -1071,7 +1071,7 @@ linux_elf_modevent(module_t mod, int type, void *data)
error = EINVAL;
if (error == 0) {
SET_FOREACH(lihp, linux_ioctl_handler_set)
-   linux_ioctl_register_handler(*lihp);
+   linux32_ioctl_register_handler(*lihp);
LIST_INIT(_list);
mtx_init(_mtx, "ftllk", NULL, MTX_DEF);
stclohz = (stathz ? stathz : hz);
@@ -1093,7 +1093,7 @@ linux_elf_modevent(module_t mod, int type, void *data)
}
if (error == 0) {
SET_FOREACH(lihp, linux_ioctl_handler_set)
-   linux_ioctl_unregister_handler(*lihp);
+   linux32_ioctl_unregister_handler(*lihp);
mtx_destroy(_mtx);
if (bootverbose)
printf("Linux ELF exec handler removed\n");

Modified: head/sys/compat/linux/linux_common.c
==
--- head/sys/compat/linux/linux_common.cTue Nov  6 12:57:38 2018
(r340180)
+++ head/sys/compat/linux/linux_common.cTue Nov  6 13:51:08 2018
(r340181)
@@ -35,9 +35,11 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
+#include 
 #include 
 #include 
 
@@ -47,6 +49,11 @@ FEATURE(linuxulator_v4l2, "V4L2 ioctl wrapper support 
 MODULE_VERSION(linux_common, 1);
 
 SET_DECLARE(linux_device_handler_set, struct linux_device_handler);
+
+TAILQ_HEAD(, linux_ioctl_handler_element) linux_ioctl_handlers =
+TAILQ_HEAD_INITIALIZER(linux_ioctl_handlers);
+struct sx linux_ioctl_sx;
+SX_SYSINIT(linux_ioctl, _ioctl_sx, "Linux ioctl handlers");
 
 static eventhandler_tag linux_exec_tag;
 static eventhandler_tag linux_thread_dtor_tag;

Modified: head/sys/compat/linux/linux_ioctl.c
==
--- head/sys/compat/linux/linux_ioctl.c Tue Nov  6 12:57:38 2018
(r340180)
+++ head/sys/compat/linux/linux_ioctl.c Tue Nov  6 13:51:08 2018
(r340181)
@@ -161,17 +161,19 @@ DATA_SET(linux_ioctl_handler_set, video2_handler);
 DATA_SET(linux_ioctl_handler_set, fbsd_usb);
 DATA_SET(linux_ioctl_handler_set, evdev_handler);
 
-struct handler_element
-{
-   TAILQ_ENTRY(handler_element) list;
-   int (*func)(struct thread *, struct linux_ioctl_args *);
-   int low, high, span;
-};
-
-static TAILQ_HEAD(, handler_element) handlers =
-TAILQ_HEAD_INITIALIZER(handlers);
+#ifdef __i386__
+static TAILQ_HEAD(, linux_ioctl_handler_element) linux_ioctl_handlers =
+TAILQ_HEAD_INITIALIZER(linux_ioctl_handlers);
 static struct sx linux_ioctl_sx;
 SX_SYSINIT(linux_ioctl, _ioctl_sx, "Linux ioctl handlers");
+#else
+extern TAILQ_HEAD(, linux_ioctl_handler_element) linux_ioctl_handlers;
+extern struct sx linux_ioctl_sx;
+#endif
+#ifdef COMPAT_LINUX32

svn commit: r339618 - head/sys/compat/linuxkpi/common/include/linux

2018-10-22 Thread Tijl Coosemans
Author: tijl
Date: Mon Oct 22 20:55:35 2018
New Revision: 339618
URL: https://svnweb.freebsd.org/changeset/base/339618

Log:
  Define linuxkpi readq for 64-bit architectures.  It is used by drm-kmod.
  Currently the compiler picks up the definition in machine/cpufunc.h.
  
  Add compiler memory barriers to read* and write*.  The Linux x86
  implementation of these functions uses inline asm with "memory" clobber.
  The Linux x86 implementation of read_relaxed* and write_relaxed* uses the
  same inline asm without "memory" clobber.
  
  Implement ioread* and iowrite* in terms of read* and write* so they also
  have memory barriers.
  
  Qualify the addr parameter in write* as volatile.
  
  Like Linux, define macros with the same name as the inline functions.
  
  Only define 64-bit versions on 64-bit architectures because generally
  32-bit architectures can't do atomic 64-bit loads and stores.
  
  Regroup the functions a bit and add brief comments explaining what they do:
  - __raw_read*, __raw_write*: atomic, no barriers, no byte swapping
  - read_relaxed*, write_relaxed*: atomic, no barriers, little-endian
  - read*, write*: atomic, with barriers, little-endian
  
  Add a comment that says our implementation of ioread* and iowrite*
  only handles MMIO and does not support port IO.
  
  Reviewed by:  hselasky
  MFC after:3 days

Modified:
  head/sys/compat/linuxkpi/common/include/linux/io.h

Modified: head/sys/compat/linuxkpi/common/include/linux/io.h
==
--- head/sys/compat/linuxkpi/common/include/linux/io.h  Mon Oct 22 20:22:33 
2018(r339617)
+++ head/sys/compat/linuxkpi/common/include/linux/io.h  Mon Oct 22 20:55:35 
2018(r339618)
@@ -38,153 +38,309 @@
 #include 
 #include 
 
+/*
+ * XXX This is all x86 specific.  It should be bus space access.
+ */
+
+/* Access MMIO registers atomically without barriers and byte swapping. */
+
+static inline uint8_t
+__raw_readb(const volatile void *addr)
+{
+   return (*(const volatile uint8_t *)addr);
+}
+#define__raw_readb(addr)   __raw_readb(addr)
+
+static inline void
+__raw_writeb(uint8_t v, volatile void *addr)
+{
+   *(volatile uint8_t *)addr = v;
+}
+#define__raw_writeb(v, addr)   __raw_writeb(v, addr)
+
+static inline uint16_t
+__raw_readw(const volatile void *addr)
+{
+   return (*(const volatile uint16_t *)addr);
+}
+#define__raw_readw(addr)   __raw_readw(addr)
+
+static inline void
+__raw_writew(uint16_t v, volatile void *addr)
+{
+   *(volatile uint16_t *)addr = v;
+}
+#define__raw_writew(v, addr)   __raw_writew(v, addr)
+
 static inline uint32_t
 __raw_readl(const volatile void *addr)
 {
-   return *(const volatile uint32_t *)addr;
+   return (*(const volatile uint32_t *)addr);
 }
+#define__raw_readl(addr)   __raw_readl(addr)
 
 static inline void
-__raw_writel(uint32_t b, volatile void *addr)
+__raw_writel(uint32_t v, volatile void *addr)
 {
-   *(volatile uint32_t *)addr = b;
+   *(volatile uint32_t *)addr = v;
 }
+#define__raw_writel(v, addr)   __raw_writel(v, addr)
 
+#ifdef __LP64__
 static inline uint64_t
 __raw_readq(const volatile void *addr)
 {
-   return *(const volatile uint64_t *)addr;
+   return (*(const volatile uint64_t *)addr);
 }
+#define__raw_readq(addr)   __raw_readq(addr)
 
 static inline void
-__raw_writeq(uint64_t b, volatile void *addr)
+__raw_writeq(uint64_t v, volatile void *addr)
 {
-   *(volatile uint64_t *)addr = b;
+   *(volatile uint64_t *)addr = v;
 }
+#define__raw_writeq(v, addr)   __raw_writeq(v, addr)
+#endif
 
-/*
- * XXX This is all x86 specific.  It should be bus space access.
- */
 #definemmiowb()barrier()
 
-#undef writel
+/* Access little-endian MMIO registers atomically with memory barriers. */
+
+#undef readb
+static inline uint8_t
+readb(const volatile void *addr)
+{
+   uint8_t v;
+
+   __compiler_membar();
+   v = *(const volatile uint8_t *)addr;
+   __compiler_membar();
+   return (v);
+}
+#definereadb(addr) readb(addr)
+
+#undef writeb
 static inline void
-writel(uint32_t b, void *addr)
+writeb(uint8_t v, volatile void *addr)
 {
-   *(volatile uint32_t *)addr = b;
+   __compiler_membar();
+   *(volatile uint8_t *)addr = v;
+   __compiler_membar();
 }
+#definewriteb(v, addr) writeb(v, addr)
 
-#undef writel_relaxed
+#undef readw
+static inline uint16_t
+readw(const volatile void *addr)
+{
+   uint16_t v;
+
+   __compiler_membar();
+   v = *(const volatile uint16_t *)addr;
+   __compiler_membar();
+   return (v);
+}
+#definereadw(addr) readw(addr)
+
+#undef writew
 static inline void
-writel_relaxed(uint32_t b, void *addr)
+writew(uint16_t v, volatile void *addr)
 {
-   *(volatile uint32_t *)addr = b;
+   __compiler_membar();
+   *(volatile uint16_t 

Re: svn commit: r333919 - in head/contrib/file: . doc magic magic/Magdir python src tests

2018-05-22 Thread Tijl Coosemans
On Mon, 21 May 2018 00:10:23 +0200 Antoine Brodin  wrote:
> On Sun, May 20, 2018 at 10:39 PM, Antoine Brodin  wrote:
>> On Sun, May 20, 2018 at 10:30 PM, Antoine Brodin  
>> wrote:  
>>> On Sun, May 20, 2018 at 7:06 AM, Eitan Adler  wrote:  
 Author: eadler
 Date: Sun May 20 05:06:42 2018
 New Revision: 333919
 URL: https://svnweb.freebsd.org/changeset/base/333919

 Log:
   MFV: file 5.33

   Merge the latest file(1) in.

   Relevent Changelog:
   - extend the support for ${x?:} expansions for magic descriptions
   - add support for ${x?:} in mime types to handle pie binaries.
   - add support for negative offsets (offsets from the end of file)
   - close the file on error when writing magic

   Relnotes: yes  
>>>
>>> This breaks the ports tree,  please revert and request an exp-run.  
>>
>> At least revert the changes to contrib/file/magic/Magdir/elf  
> 
> The problematic part was reverted in r333944

Seems to affect libraries that are installed +x.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r332489 - in head: gnu/usr.bin/gdb/kgdb sys/conf sys/dev/dcons sys/dev/hyperv/vmbus/i386 sys/dev/ppc sys/dev/syscons sys/i386/conf sys/i386/i386 sys/i386/include sys/i386/include/pc sy

2018-04-23 Thread Tijl Coosemans
On Sun, 22 Apr 2018 23:51:03 +0300 Konstantin Belousov <kostik...@gmail.com> 
wrote:
> On Sun, Apr 22, 2018 at 10:26:14PM +0300, Konstantin Belousov wrote:
>> On Sun, Apr 22, 2018 at 09:06:56PM +0200, Tijl Coosemans wrote:  
>>> Could this have broken the linux futex syscall?  I have a linux program
>>> that gets stuck in linux_sys_futex and becomes unkillable.  Note that the
>>> routines in sys/i386/linux/linux_support.s try to do atomic operations on
>>> user space addresses.  
>> 
>> Yes, it is quite possible.  I will try to look next week.  
> 
> Try this.  I only compile-tested it as a module.

Yes, this fixes it.  That was quick, thanks!
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r332489 - in head: gnu/usr.bin/gdb/kgdb sys/conf sys/dev/dcons sys/dev/hyperv/vmbus/i386 sys/dev/ppc sys/dev/syscons sys/i386/conf sys/i386/i386 sys/i386/include sys/i386/include/pc sy

2018-04-22 Thread Tijl Coosemans
On Fri, 13 Apr 2018 20:30:49 + (UTC) Konstantin Belousov  
wrote:
> Author: kib
> Date: Fri Apr 13 20:30:49 2018
> New Revision: 332489
> URL: https://svnweb.freebsd.org/changeset/base/332489
> 
> Log:
>   i386 4/4G split.
>   
>   The change makes the user and kernel address spaces on i386
>   independent, giving each almost the full 4G of usable virtual addresses
>   except for one PDE at top used for trampoline and per-CPU trampoline
>   stacks, and system structures that must be always mapped, namely IDT,
>   GDT, common TSS and LDT, and process-private TSS and LDT if allocated.

Could this have broken the linux futex syscall?  I have a linux program
that gets stuck in linux_sys_futex and becomes unkillable.  Note that the
routines in sys/i386/linux/linux_support.s try to do atomic operations on
user space addresses.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332871 - head/sys/kern

2018-04-22 Thread Tijl Coosemans
Author: tijl
Date: Sun Apr 22 16:05:29 2018
New Revision: 332871
URL: https://svnweb.freebsd.org/changeset/base/332871

Log:
  Make bufdaemon and bufspacedaemon use kthread_suspend_check instead of
  kproc_suspend_check.  In r329612 bufspacedaemon was turned into a thread
  of the bufdaemon process causing both to call kproc_suspend_check with the
  same proc argument and that function contains the following while loop:
  
  while (SIGISMEMBER(p->p_siglist, SIGSTOP)) {
wakeup(>p_siglist);
msleep(>p_siglist, >p_mtx, PPAUSE, "kpsusp", 0);
  }
  
  So one thread wakes up the other and the other wakes up the first again,
  locking up UP machines on shutdown.
  
  Also register the shutdown handlers with SHUTDOWN_PRI_LAST + 100 so they
  run after the syncer has shutdown, because the syncer can cause a
  situation where bufdaemon help is needed to proceed.
  
  PR:   227404
  Reviewed by:  kib
  Tested by:cy, rmacklem

Modified:
  head/sys/kern/vfs_bio.c

Modified: head/sys/kern/vfs_bio.c
==
--- head/sys/kern/vfs_bio.c Sun Apr 22 09:30:07 2018(r332870)
+++ head/sys/kern/vfs_bio.c Sun Apr 22 16:05:29 2018(r332871)
@@ -791,9 +791,12 @@ bufspace_daemon(void *arg)
 {
struct bufdomain *bd;
 
+   EVENTHANDLER_REGISTER(shutdown_pre_sync, kthread_shutdown, curthread,
+   SHUTDOWN_PRI_LAST + 100);
+
bd = arg;
for (;;) {
-   kproc_suspend_check(curproc);
+   kthread_suspend_check();
 
/*
 * Free buffers from the clean queue until we meet our
@@ -3357,8 +3360,8 @@ buf_daemon()
/*
 * This process needs to be suspended prior to shutdown sync.
 */
-   EVENTHANDLER_REGISTER(shutdown_pre_sync, kproc_shutdown, bufdaemonproc,
-   SHUTDOWN_PRI_LAST);
+   EVENTHANDLER_REGISTER(shutdown_pre_sync, kthread_shutdown, curthread,
+   SHUTDOWN_PRI_LAST + 100);
 
/*
 * Start the buf clean daemons as children threads.
@@ -3381,7 +3384,7 @@ buf_daemon()
bd_request = 0;
mtx_unlock();
 
-   kproc_suspend_check(bufdaemonproc);
+   kthread_suspend_check();
 
/*
 * Save speedupreq for this pass and reset to capture new
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331732 - head/sys/vm

2018-04-01 Thread Tijl Coosemans
On Sun, 1 Apr 2018 12:27:03 -0400 Mark Johnston <ma...@freebsd.org> wrote:
> On Sun, Apr 01, 2018 at 05:20:21PM +0200, Tijl Coosemans wrote:
>> On Sat, 31 Mar 2018 18:54:32 -0400 Mark Johnston <ma...@freebsd.org> wrote:  
>>> On Sat, Mar 31, 2018 at 08:21:18PM +0200, Tijl Coosemans wrote:  
>>>> On Thu, 29 Mar 2018 14:27:40 + (UTC) Mark Johnston <ma...@freebsd.org> 
>>>> wrote:
>>>>> Author: markj
>>>>> Date: Thu Mar 29 14:27:40 2018
>>>>> New Revision: 331732
>>>>> URL: https://svnweb.freebsd.org/changeset/base/331732
>>>>> 
>>>>> Log:
>>>>>   Fix the background laundering mechanism after r329882.
>>>>>   
>>>>>   Rather than using the number of inactive queue scans as a metric for
>>>>>   how many clean pages are being freed by the page daemon, have the
>>>>>   page daemon keep a running counter of the number of pages it has freed,
>>>>>   and have the laundry thread use that when computing the background
>>>>>   laundering threshold.
>>>>> [...]
>>>> 
>>>> I'm seeing big processes being killed with an "out of swap space" message
>>>> even though there's still plenty of swap available.  It seems to be fixed
>>>> by making this division round upwards:
>>>> 
>>>>if (target == 0 && ndirty * isqrt((nfreed +
>>>>(vmd->vmd_free_target - vmd->vmd_free_min) - 1) /
>>>>(vmd->vmd_free_target - vmd->vmd_free_min)) >= nclean) {
>>>> 
>>>> I don't know where this formula comes from, so I don't know if this
>>>> change is correct.
>>> 
>>> Hm, that's somewhat surprising. This code shouldn't be executing in
>>> situations where the OOM kill logic is invoked (i.e., memory pressure
>>> plus a shortage of clean pages in the inactive queue).
>>> 
>>> How much RAM does the system have? Could you collect "sysctl vm" output
>>> around the time of an OOM kill?  
>> 
>> 1GiB RAM.  I've sampled sysctl vm every 5s from the moment the process
>> starts swapping until it is killed and uploaded that to
>> https://people.freebsd.org/~tijl/sysctl/  
> 
> Thank you. Now I agree with your change. Would you like to commit it?
> I can take care of it if you prefer.

Please go ahead.  You can probably write a better commit log.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331732 - head/sys/vm

2018-04-01 Thread Tijl Coosemans
On Sat, 31 Mar 2018 18:54:32 -0400 Mark Johnston <ma...@freebsd.org> wrote:
> On Sat, Mar 31, 2018 at 08:21:18PM +0200, Tijl Coosemans wrote:
> > On Thu, 29 Mar 2018 14:27:40 + (UTC) Mark Johnston <ma...@freebsd.org> 
> > wrote:  
> > > Author: markj
> > > Date: Thu Mar 29 14:27:40 2018
> > > New Revision: 331732
> > > URL: https://svnweb.freebsd.org/changeset/base/331732
> > > 
> > > Log:
> > >   Fix the background laundering mechanism after r329882.
> > >   
> > >   Rather than using the number of inactive queue scans as a metric for
> > >   how many clean pages are being freed by the page daemon, have the
> > >   page daemon keep a running counter of the number of pages it has freed,
> > >   and have the laundry thread use that when computing the background
> > >   laundering threshold.
> > > [...]  
> > 
> > I'm seeing big processes being killed with an "out of swap space" message
> > even though there's still plenty of swap available.  It seems to be fixed
> > by making this division round upwards:
> > 
> > if (target == 0 && ndirty * isqrt((nfreed +
> > (vmd->vmd_free_target - vmd->vmd_free_min) - 1) /
> > (vmd->vmd_free_target - vmd->vmd_free_min)) >= nclean) {
> > 
> > I don't know where this formula comes from, so I don't know if this
> > change is correct.  
> 
> Hm, that's somewhat surprising. This code shouldn't be executing in
> situations where the OOM kill logic is invoked (i.e., memory pressure
> plus a shortage of clean pages in the inactive queue).
> 
> How much RAM does the system have? Could you collect "sysctl vm" output
> around the time of an OOM kill?

1GiB RAM.  I've sampled sysctl vm every 5s from the moment the process
starts swapping until it is killed and uploaded that to
https://people.freebsd.org/~tijl/sysctl/

> I'm wondering if the higher inactive queue scan frequency after r329882
> might be responsible: OOM kills are performed after vm.pageout_oom_seq
> back-to-back scans fail to reclaim any pages. Does your problem persist
> if you increase the value of that sysctl, say to 60?

This didn't help.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331732 - head/sys/vm

2018-03-31 Thread Tijl Coosemans
On Thu, 29 Mar 2018 14:27:40 + (UTC) Mark Johnston  
wrote:
> Author: markj
> Date: Thu Mar 29 14:27:40 2018
> New Revision: 331732
> URL: https://svnweb.freebsd.org/changeset/base/331732
> 
> Log:
>   Fix the background laundering mechanism after r329882.
>   
>   Rather than using the number of inactive queue scans as a metric for
>   how many clean pages are being freed by the page daemon, have the
>   page daemon keep a running counter of the number of pages it has freed,
>   and have the laundry thread use that when computing the background
>   laundering threshold.
>   
>   Reviewed by:kib
>   Differential Revision:  https://reviews.freebsd.org/D14884
> 
> Modified:
>   head/sys/vm/vm_pageout.c
>   head/sys/vm/vm_pagequeue.h
> 
> Modified: head/sys/vm/vm_pageout.c
> ==
> --- head/sys/vm/vm_pageout.c  Thu Mar 29 13:55:23 2018(r331731)
> +++ head/sys/vm/vm_pageout.c  Thu Mar 29 14:27:40 2018(r331732)
> @@ -943,8 +943,7 @@ vm_pageout_laundry_worker(void *arg)
>  {
>   struct vm_domain *vmd;
>   struct vm_pagequeue *pq;
> - uint64_t nclean, ndirty;
> - u_int inactq_scans, last_launder;
> + uint64_t nclean, ndirty, nfreed;
>   int domain, last_target, launder, shortfall, shortfall_cycle, target;
>   bool in_shortfall;
>  
> @@ -958,8 +957,7 @@ vm_pageout_laundry_worker(void *arg)
>   in_shortfall = false;
>   shortfall_cycle = 0;
>   target = 0;
> - inactq_scans = 0;
> - last_launder = 0;
> + nfreed = 0;
>  
>   /*
>* Calls to these handlers are serialized by the swap syscall lock.
> @@ -1000,7 +998,6 @@ vm_pageout_laundry_worker(void *arg)
>   target = 0;
>   goto trybackground;
>   }
> - last_launder = inactq_scans;
>   launder = target / shortfall_cycle--;
>   goto dolaundry;
>  
> @@ -1009,24 +1006,23 @@ vm_pageout_laundry_worker(void *arg)
>* meet the conditions to perform background laundering:
>*
>* 1. The ratio of dirty to clean inactive pages exceeds the
> -  *background laundering threshold and the pagedaemon has
> -  *been woken up to reclaim pages since our last
> -  *laundering, or
> +  *background laundering threshold, or
>* 2. we haven't yet reached the target of the current
>*background laundering run.
>*
>* The background laundering threshold is not a constant.
>* Instead, it is a slowly growing function of the number of
> -  * page daemon scans since the last laundering.  Thus, as the
> -  * ratio of dirty to clean inactive pages grows, the amount of
> -  * memory pressure required to trigger laundering decreases.
> +  * clean pages freed by the page daemon since the last
> +  * background laundering.  Thus, as the ratio of dirty to
> +  * clean inactive pages grows, the amount of memory pressure
> +  * required to trigger laundering decreases.
>*/
>  trybackground:
>   nclean = vmd->vmd_free_count +
>   vmd->vmd_pagequeues[PQ_INACTIVE].pq_cnt;
>   ndirty = vmd->vmd_pagequeues[PQ_LAUNDRY].pq_cnt;
> - if (target == 0 && inactq_scans != last_launder &&
> - ndirty * isqrt(inactq_scans - last_launder) >= nclean) {
> + if (target == 0 && ndirty * isqrt(nfreed /
> + (vmd->vmd_free_target - vmd->vmd_free_min)) >= nclean) {

I'm seeing big processes being killed with an "out of swap space" message
even though there's still plenty of swap available.  It seems to be fixed
by making this division round upwards:

if (target == 0 && ndirty * isqrt((nfreed +
(vmd->vmd_free_target - vmd->vmd_free_min) - 1) /
(vmd->vmd_free_target - vmd->vmd_free_min)) >= nclean) {

I don't know where this formula comes from, so I don't know if this
change is correct.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r324938 - head/contrib/jemalloc/include/jemalloc/internal

2017-11-17 Thread Tijl Coosemans
On Mon, 23 Oct 2017 21:31:04 + (UTC) Dimitry Andric  
wrote:
> Author: dim
> Date: Mon Oct 23 21:31:04 2017
> New Revision: 324938
> URL: https://svnweb.freebsd.org/changeset/base/324938
> 
> Log:
>   After jemalloc was updated to version 5.0.0 in r319971, i386 executables
>   linked with AddressSanitizer (even those linked on earlier versions of
>   FreeBSD, or with external versions of clang) started failing with errors
>   similar to:
>   
> ==14688==AddressSanitizer CHECK failed:
> /usr/src/contrib/compiler-rt/lib/asan/asan_poisoning.cc:36
> "((AddrIsAlignedByGranularity(addr))) != (0)" (0x0, 0x0)
>   
>   This is because AddressSanitizer expects all the TLS data in the program
>   to be aligned to at least 8 bytes.
>   
>   Before the jemalloc 5.0.0 update, all the TLS data in the i386 version
>   of libc.so added up to 80 bytes (a multiple of 8), but 5.0.0 made this
>   grow to 2404 bytes (not a multiple of 8).  This is due to added caching
>   data in jemalloc's internal struct tsd_s.
>   
>   To fix AddressSanitizer, ensure this struct is aligned to at least 16
>   bytes, which can be done unconditionally for all architectures.  (An
>   earlier version of the fix aligned the struct to 8 bytes, but only for
>   ILP32 architectures.  This was deemed unnecessarily complicated.)
>   
>   PR: 221337
>   X-MFC-With: r319971
> 
> Modified:
>   head/contrib/jemalloc/include/jemalloc/internal/tsd.h
> 
> Modified: head/contrib/jemalloc/include/jemalloc/internal/tsd.h
> ==
> --- head/contrib/jemalloc/include/jemalloc/internal/tsd.h Mon Oct 23 
> 20:50:08 2017(r324937)
> +++ head/contrib/jemalloc/include/jemalloc/internal/tsd.h Mon Oct 23 
> 21:31:04 2017(r324938)
> @@ -120,7 +120,8 @@ struct tsd_s {
>   t use_a_getter_or_setter_instead_##n;
>  MALLOC_TSD
>  #undef O
> -};
> +/* AddressSanitizer requires TLS data to be aligned to at least 8 bytes. */
> +} JEMALLOC_ALIGNED(16);
>  
>  /*
>   * Wrapper around tsd_t that makes it possible to avoid implicit conversion
> 

On amd64 this commit causes kded4 to crash in libnvidia-tls.so.1 (from
x11/nvidia-driver-304) during KDE startup.  Lowering to 8 byte alignment
fixes the crash.  Note that in libc the TLS segment alignment is 16 now
but the memory size isn't a multiple of 16.  Does rtld handle this
correctly?

Application: KDE Daemon (kded4), signal: Segmentation fault
[KCrash Handler]
#8  0x00081cea3761 in _nv024tls () from /usr/local/lib/libnvidia-tls.so.1
#9  0x00081c7a698c in ?? () from /usr/local/lib/libGL-NVIDIA.so.1
#10 0x00081c78915d in ?? () from /usr/local/lib/libGL-NVIDIA.so.1
#11 0x00081c78966a in ?? () from /usr/local/lib/libGL-NVIDIA.so.1
#12 0x000800616c08 in objlist_call_init (list=0x7fffd100, 
lockstate=0x7fffd098) at /usr/src/libexec/rtld-elf/rtld.c:2670
#13 0x00080061cae2 in dlopen_object (name=0x801fd0c98 
"/usr/local/lib/kde4/kded_powerdevil.so", fd=-1, refobj=0x80063b000, 
lo_flags=2, mode=1, lockstate=0x7fffd098) at 
/usr/src/libexec/rtld-elf/rtld.c:3389
#14 0x000800617fba in rtld_dlopen (name=0x801fd0c98 
"/usr/local/lib/kde4/kded_powerdevil.so", fd=-1, mode=1) at 
/usr/src/libexec/rtld-elf/rtld.c:3264
#15 0x000800617e52 in dlopen (name=0x801fd0c98 
"/usr/local/lib/kde4/kded_powerdevil.so", mode=1) at 
/usr/src/libexec/rtld-elf/rtld.c:3231
#16 0x000802190ddf in ?? () from /usr/local/lib/qt4/libQtCore.so.4
#17 0x00080218959b in ?? () from /usr/local/lib/qt4/libQtCore.so.4
#18 0x000801898d47 in KPluginLoader::load() () from 
/usr/local/lib/libkdecore.so.5
#19 0x000801898b37 in KPluginLoader::factory() () from 
/usr/local/lib/libkdecore.so.5
#20 0x00080c31b473 in ?? () from /usr/local/lib/libkdeinit4_kded4.so
#21 0x00080c31ab29 in ?? () from /usr/local/lib/libkdeinit4_kded4.so
.

% readelf -l /usr/local/lib/libnvidia-tls.so

Elf file type is DYN (Shared object file)
Entry point 0x640
There are 6 program headers, starting at offset 64

Program Headers:
  Type   Offset VirtAddr   PhysAddr
 FileSizMemSiz  FlgAlign
  LOAD   0x 0x 0x
 0x0af0 0x0af0  R E0x20
  LOAD   0x0af0 0x00200af0 0x00200af0
 0x01fc 0x0260  RW 0x20
  DYNAMIC0x0af8 0x00200af8 0x00200af8
 0x0190 0x0190  RW 0x8
  NOTE   0x0ad0 0x0ad0 0x0ad0
 0x0020 0x0020  R  0x4
  TLS0x0af0 0x00200af0 0x00200af0
 0x 0x0030  R  0x8
  GNU_STACK  0x 

svn commit: r325640 - head/share/man/man7

2017-11-10 Thread Tijl Coosemans
Author: tijl
Date: Fri Nov 10 11:19:47 2017
New Revision: 325640
URL: https://svnweb.freebsd.org/changeset/base/325640

Log:
  Remove deprecated OVERRIDE_LINUX_BASE_PORT.  It can be set via
  DEFAULT_VERSIONS now (e.g. DEFAULT_VERSIONS+=linux=c7).
  
  Noticed by:   xmj
  MFC after:2 weeks

Modified:
  head/share/man/man7/ports.7

Modified: head/share/man/man7/ports.7
==
--- head/share/man/man7/ports.7 Fri Nov 10 11:19:33 2017(r325639)
+++ head/share/man/man7/ports.7 Fri Nov 10 11:19:47 2017(r325640)
@@ -494,7 +494,7 @@ More information on these and other related variables 
 and the
 .Fx
 Porter's Handbook.
-.Bl -tag -width ".Va OVERRIDE_LINUX_BASE_PORT"
+.Bl -tag -width ".Va WITH_GHOSTSCRIPT_VER"
 .It Va WITH_OPENSSL_PORT
 .Pq Vt bool
 If set, causes ports that make use of OpenSSL to use the OpenSSL from
@@ -514,8 +514,6 @@ If set, enables
 for most ports.
 .It Va WITH_GHOSTSCRIPT_VER
 If set, the version of ghostscript to be used by ports.
-.It Va OVERRIDE_LINUX_BASE_PORT
-The default linux base to use.
 .It Va WITH_CCACHE_BUILD
 .Pq Vt bool
 If set, enables the use of
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325232 - in head/sys: amd64/amd64 i386/i386

2017-10-31 Thread Tijl Coosemans
Author: tijl
Date: Tue Oct 31 11:51:34 2017
New Revision: 325232
URL: https://svnweb.freebsd.org/changeset/base/325232

Log:
  Set the return address for stack entry points to zero.
  
  Stack unwinders treat zero as a stop condition.  The value on the stack can
  be non-zero because thread stacks may be arbitrary memory provided via
  pthread_attr_setstack(3) or may be recycled from previous threads.
  
  Reference:
  https://lists.freebsd.org/pipermail/freebsd-current/2017-August/066855.html
  https://lists.freebsd.org/pipermail/freebsd-current/2017-October/067254.html
  
  Discussed with:   kib
  MFC after:1 week

Modified:
  head/sys/amd64/amd64/vm_machdep.c
  head/sys/i386/i386/vm_machdep.c

Modified: head/sys/amd64/amd64/vm_machdep.c
==
--- head/sys/amd64/amd64/vm_machdep.c   Tue Oct 31 11:29:16 2017
(r325231)
+++ head/sys/amd64/amd64/vm_machdep.c   Tue Oct 31 11:51:34 2017
(r325232)
@@ -508,6 +508,9 @@ cpu_set_upcall(struct thread *td, void (*entry)(void *
   (((uintptr_t)stack->ss_sp + stack->ss_size - 4) & ~0x0f) - 4;
td->td_frame->tf_rip = (uintptr_t)entry;
 
+   /* Return address sentinel value to stop stack unwinding. */
+   suword32((void *)td->td_frame->tf_rsp, 0);
+
/* Pass the argument to the entry point. */
suword32((void *)(td->td_frame->tf_rsp + sizeof(int32_t)),
(uint32_t)(uintptr_t)arg);
@@ -530,6 +533,9 @@ cpu_set_upcall(struct thread *td, void (*entry)(void *
td->td_frame->tf_fs = _ufssel;
td->td_frame->tf_gs = _ugssel;
td->td_frame->tf_flags = TF_HASSEGS;
+
+   /* Return address sentinel value to stop stack unwinding. */
+   suword((void *)td->td_frame->tf_rsp, 0);
 
/* Pass the argument to the entry point. */
td->td_frame->tf_rdi = (register_t)arg;

Modified: head/sys/i386/i386/vm_machdep.c
==
--- head/sys/i386/i386/vm_machdep.c Tue Oct 31 11:29:16 2017
(r325231)
+++ head/sys/i386/i386/vm_machdep.c Tue Oct 31 11:51:34 2017
(r325232)
@@ -524,6 +524,9 @@ cpu_set_upcall(struct thread *td, void (*entry)(void *
(((int)stack->ss_sp + stack->ss_size - 4) & ~0x0f) - 4;
td->td_frame->tf_eip = (int)entry;
 
+   /* Return address sentinel value to stop stack unwinding. */
+   suword((void *)td->td_frame->tf_esp, 0);
+
/* Pass the argument to the entry point. */
suword((void *)(td->td_frame->tf_esp + sizeof(void *)),
(int)arg);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r324637 - head/sys/compat/linsysfs

2017-10-15 Thread Tijl Coosemans
Author: tijl
Date: Sun Oct 15 19:28:14 2017
New Revision: 324637
URL: https://svnweb.freebsd.org/changeset/base/324637

Log:
  Add information needed by Linux libdrm 2.4.74 (shipped with CentOS 7.4).
  
  Create a config file for PCI devices that exposes their configuration
  space.  Only fields needed by libdrm are filled in (vendor, device,
  revision, subvendor and subdevice).
  
  Link /sys/class/drm/card%d/device to the PCI device directory.

Modified:
  head/sys/compat/linsysfs/linsysfs.c

Modified: head/sys/compat/linsysfs/linsysfs.c
==
--- head/sys/compat/linsysfs/linsysfs.c Sun Oct 15 19:21:15 2017
(r324636)
+++ head/sys/compat/linsysfs/linsysfs.c Sun Oct 15 19:28:14 2017
(r324637)
@@ -175,6 +175,33 @@ linsysfs_fill_revid(PFS_FILL_ARGS)
return (0);
 }
 
+static int
+linsysfs_fill_config(PFS_FILL_ARGS)
+{
+   uint8_t config[48];
+   device_t dev;
+   uint32_t reg;
+
+   dev = (device_t)pn->pn_data;
+   bzero(config, sizeof(config));
+   reg = pci_get_vendor(dev);
+   config[0] = reg;
+   config[1] = reg >> 8;
+   reg = pci_get_device(dev);
+   config[2] = reg;
+   config[3] = reg >> 8;
+   reg = pci_get_revid(dev);
+   config[8] = reg;
+   reg = pci_get_subvendor(dev);
+   config[44] = reg;
+   config[45] = reg >> 8;
+   reg = pci_get_subdevice(dev);
+   config[46] = reg;
+   config[47] = reg >> 8;
+   sbuf_bcat(sb, config, sizeof(config));
+   return (0);
+}
+
 /*
  * Filler function for PCI uevent file
  */
@@ -247,20 +274,20 @@ linsysfs_fill_vgapci(PFS_FILL_ARGS)
 #define PCI_DEV "pci"
 #define DRMN_DEV "drmn"
 static int
-linsysfs_run_bus(device_t dev, struct pfs_node *dir, struct pfs_node *scsi, 
struct pfs_node *chardev,
-  char *path, char *prefix)
+linsysfs_run_bus(device_t dev, struct pfs_node *dir, struct pfs_node *scsi,
+struct pfs_node *chardev, struct pfs_node *drm, char *path, char *prefix)
 {
struct scsi_host_queue *scsi_host;
-   struct pfs_node *sub_dir, *cur_file, *cur_chardev;
+   struct pfs_node *sub_dir, *cur_file;
int i, nchildren, error;
device_t *children, parent;
devclass_t devclass;
const char *name = NULL;
struct pci_devinfo *dinfo;
-   char *device, *host, *new_path, *chardevname;
+   char *device, *host, *new_path, *devname;
 
new_path = path;
-   chardevname = malloc(16, M_TEMP, M_WAITOK);
+   devname = malloc(16, M_TEMP, M_WAITOK);
 
parent = device_get_parent(dev);
if (parent) {
@@ -308,6 +335,10 @@ linsysfs_run_bus(device_t dev, struct pfs_node *dir, s
_fill_revid, NULL, NULL, NULL,
PFS_RD);
cur_file->pn_data = (void*)dev;
+   cur_file = pfs_create_file(dir, "config",
+   _fill_config, NULL, NULL, NULL,
+   PFS_RD);
+   cur_file->pn_data = (void*)dev;
cur_file = pfs_create_file(dir, "uevent",
_fill_uevent_pci, NULL, NULL,
NULL, PFS_RD);
@@ -362,18 +393,26 @@ linsysfs_run_bus(device_t dev, struct pfs_node *dir, s
device_get_unit(dev) >= 0) {
dinfo = device_get_ivars(parent);
if (dinfo != NULL && dinfo->cfg.baseclass == 
PCIC_DISPLAY) {
-   sprintf(chardevname, "226:%d",
+   sprintf(devname, "226:%d",
device_get_unit(dev));
-   cur_chardev = pfs_create_dir(chardev,
-   chardevname, NULL, NULL, NULL, 0);
-   cur_file = pfs_create_link(cur_chardev,
+   sub_dir = pfs_create_dir(chardev,
+   devname, NULL, NULL, NULL, 0);
+   cur_file = pfs_create_link(sub_dir,
"device", _fill_vgapci, NULL,
NULL, NULL, PFS_RD);
cur_file->pn_data = (void*)dir;
-   cur_file = pfs_create_file(cur_chardev,
+   cur_file = pfs_create_file(sub_dir,
"uevent", _fill_uevent_drm, NULL,
NULL, NULL, PFS_RD);
cur_file->pn_data = (void*)dev;
+   sprintf(devname, "card%d",
+   device_get_unit(dev));
+   sub_dir = pfs_create_dir(drm,
+   devname, NULL, NULL, NULL, 0);
+  

svn commit: r324636 - head/sys/compat/linsysfs

2017-10-15 Thread Tijl Coosemans
Author: tijl
Date: Sun Oct 15 19:21:15 2017
New Revision: 324636
URL: https://svnweb.freebsd.org/changeset/base/324636

Log:
  Set DEVNAME to dri/card%d.  This works with both in-tree drm and drm-next
  and is also the value used on Linux.
  
  Tested by:Greg V 

Modified:
  head/sys/compat/linsysfs/linsysfs.c

Modified: head/sys/compat/linsysfs/linsysfs.c
==
--- head/sys/compat/linsysfs/linsysfs.c Sun Oct 15 18:53:21 2017
(r324635)
+++ head/sys/compat/linsysfs/linsysfs.c Sun Oct 15 19:21:15 2017
(r324636)
@@ -205,8 +205,8 @@ linsysfs_fill_uevent_drm(PFS_FILL_ARGS)
dev = (device_t)pn->pn_data;
unit = device_get_unit(dev);
sbuf_printf(sb,
-   "MAJOR=226\nMINOR=%d\nDEVNAME=drm/%d\nDEVTYPE=dri_minor\n", unit,
-   unit);
+   "MAJOR=226\nMINOR=%d\nDEVNAME=dri/card%d\nDEVTYPE=dri_minor\n",
+   unit, unit);
return (0);
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r324635 - head/sys/kern

2017-10-15 Thread Tijl Coosemans
Author: tijl
Date: Sun Oct 15 18:53:21 2017
New Revision: 324635
URL: https://svnweb.freebsd.org/changeset/base/324635

Log:
  When a Linux program tries to access a /path the kernel tries
  /compat/linux/path before /path.  Stop following symbolic links when
  looking up /compat/linux/path so dead symbolic links aren't ignored.
  This allows syscalls like readlink(2) and lstat(2) to work on such links.
  And open(2) will return an error now instead of trying /path.

Modified:
  head/sys/kern/vfs_lookup.c

Modified: head/sys/kern/vfs_lookup.c
==
--- head/sys/kern/vfs_lookup.c  Sun Oct 15 16:19:09 2017(r324634)
+++ head/sys/kern/vfs_lookup.c  Sun Oct 15 18:53:21 2017(r324635)
@@ -1390,13 +1390,13 @@ kern_alternate_path(struct thread *td, const char *pre
for (cp = [len] - 1; *cp != '/'; cp--);
*cp = '\0';
 
-   NDINIT(, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, td);
+   NDINIT(, LOOKUP, NOFOLLOW, UIO_SYSSPACE, buf, td);
error = namei();
*cp = '/';
if (error != 0)
goto keeporig;
} else {
-   NDINIT(, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, td);
+   NDINIT(, LOOKUP, NOFOLLOW, UIO_SYSSPACE, buf, td);
 
error = namei();
if (error != 0)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r324629 - head/sys/compat/linux

2017-10-15 Thread Tijl Coosemans
Author: tijl
Date: Sun Oct 15 16:08:22 2017
New Revision: 324629
URL: https://svnweb.freebsd.org/changeset/base/324629

Log:
  Add special handling for current in-tree drm devices, like r323692 added
  for drm-next.

Modified:
  head/sys/compat/linux/linux_util.c

Modified: head/sys/compat/linux/linux_util.c
==
--- head/sys/compat/linux/linux_util.c  Sun Oct 15 16:03:45 2017
(r324628)
+++ head/sys/compat/linux/linux_util.c  Sun Oct 15 16:08:22 2017
(r324629)
@@ -146,6 +146,27 @@ linux_driver_get_major_minor(const char *node, int *ma
return (0);
}
 
+   sz = sizeof("dri/card") - 1;
+   if (strncmp(node, "dri/card", sz) == 0 && node[sz] != '\0') {
+   devno = strtoul(node + sz, NULL, 10);
+   *major = 226 + (devno / 256);
+   *minor = devno % 256;
+   return (0);
+   }
+   sz = sizeof("dri/controlD") - 1;
+   if (strncmp(node, "dri/controlD", sz) == 0 && node[sz] != '\0') {
+   devno = strtoul(node + sz, NULL, 10);
+   *major = 226 + (devno / 256);
+   *minor = devno % 256;
+   return (0);
+   }
+   sz = sizeof("dri/renderD") - 1;
+   if (strncmp(node, "dri/renderD", sz) == 0 && node[sz] != '\0') {
+   devno = strtoul(node + sz, NULL, 10);
+   *major = 226 + (devno / 256);
+   *minor = devno % 256;
+   return (0);
+   }
sz = sizeof("drm/") - 1;
if (strncmp(node, "drm/", sz) == 0 && node[sz] != '\0') {
devno = strtoul(node + sz, NULL, 10);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r324628 - head/sys/compat/linux

2017-10-15 Thread Tijl Coosemans
Author: tijl
Date: Sun Oct 15 16:03:45 2017
New Revision: 324628
URL: https://svnweb.freebsd.org/changeset/base/324628

Log:
  Use sizeof instead of strlen on string constants.  The compiler doesn't
  optimise the strlen calls away with -ffreestanding.

Modified:
  head/sys/compat/linux/linux_util.c

Modified: head/sys/compat/linux/linux_util.c
==
--- head/sys/compat/linux/linux_util.c  Sun Oct 15 14:03:53 2017
(r324627)
+++ head/sys/compat/linux/linux_util.c  Sun Oct 15 16:03:45 2017
(r324628)
@@ -128,32 +128,31 @@ linux_driver_get_major_minor(const char *node, int *ma
 {
struct device_element *de;
unsigned long devno;
+   size_t sz;
 
if (node == NULL || major == NULL || minor == NULL)
return 1;
 
-   if (strlen(node) > strlen("pts/") &&
-   strncmp(node, "pts/", strlen("pts/")) == 0) {
+   sz = sizeof("pts/") - 1;
+   if (strncmp(node, "pts/", sz) == 0 && node[sz] != '\0') {
/*
 * Linux checks major and minors of the slave device
 * to make sure it's a pty device, so let's make him
 * believe it is.
 */
-   devno = strtoul(node + strlen("pts/"), NULL, 10);
+   devno = strtoul(node + sz, NULL, 10);
*major = 136 + (devno / 256);
*minor = devno % 256;
-
return (0);
}
 
-   if ((strlen(node) > strlen("drm/") &&
-   strncmp(node, "drm/", strlen("drm/")) == 0) ) {
-   devno = strtoul(node + strlen("drm/"), NULL, 10);
+   sz = sizeof("drm/") - 1;
+   if (strncmp(node, "drm/", sz) == 0 && node[sz] != '\0') {
+   devno = strtoul(node + sz, NULL, 10);
*major = 226 + (devno / 256);
*minor = devno % 256;
return (0);
}
-
 
TAILQ_FOREACH(de, , list) {
if (strcmp(node, de->entry.bsd_device_name) == 0) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r315522 - in head: contrib/binutils/ld/emulparams sys/conf

2017-03-19 Thread Tijl Coosemans
On Sun, 19 Mar 2017 13:04:50 +1100 (EST) Bruce Evans  
wrote:
> On Sun, 19 Mar 2017, Ed Maste wrote:
>> Log:
>>  use INT3 instead of NOP for x86 binary padding
>>
>>  We should never end up executing the inter-function padding, so we
>>  are better off faulting than silently carrying on to whatever function
>>  happens to be next.
>>
>>  Note that LLD will soon do this by default (although it currently pads
>>  with zeros).
>>
>>  Reviewed by:dim, kib
>>  MFC after:  1 month
>>  Sponsored by:   The FreeBSD Foundation
>>  Differential Revision:  https://reviews.freebsd.org/D10047  
> 
> Is this a pessimization?  Instruction prefetch near the end of almost
> every function now fetches INT3 instead of NOP.  Both have to be
> decoded to decoded whether to speculatively execute them.  INT3 is
> unlikely to be speculatively executed, but it takes extra work to
> decide not to do so.

I seem to vaguely remember that ud2 should be used to stop speculative
execution (and the instruction fetching and possible cache invalidation
because of it).
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315142 - head/usr.bin/man

2017-03-12 Thread Tijl Coosemans
Author: tijl
Date: Sun Mar 12 10:56:19 2017
New Revision: 315142
URL: https://svnweb.freebsd.org/changeset/base/315142

Log:
  - Remove separate handling of /bin and /usr/bin in manpath.  They are no
longer a special case.
  - Prefer PREFIX/share/man over PREFIX/man.
  - Add /usr/local/share/man to man_default_path.
  - Update manpath man page.
  
  Reviewed by:  bapt

Modified:
  head/usr.bin/man/man.sh
  head/usr.bin/man/manpath.1

Modified: head/usr.bin/man/man.sh
==
--- head/usr.bin/man/man.sh Sun Mar 12 07:09:50 2017(r315141)
+++ head/usr.bin/man/man.sh Sun Mar 12 10:56:19 2017(r315142)
@@ -778,26 +778,19 @@ search_path() {
 
IFS=:
for path in $PATH; do
-   # Do a little special casing since the base manpages
-   # are in /usr/share/man instead of /usr/man or /man.
-   case "$path" in
-   /bin|/usr/bin)  add_to_manpath "/usr/share/man" ;;
-   *)  if add_to_manpath "$path/man"; then
-   :
-   elif add_to_manpath "$path/MAN"; then
-   :
-   else
-   case "$path" in
-   */bin)  p="${path%/bin}/man"
-   add_to_manpath "$p"
-   p="${path%/bin}/share/man"
-   add_to_manpath "$p"
-   ;;
-   *)  ;;
-   esac
-   fi
-   ;;
-   esac
+   if add_to_manpath "$path/man"; then
+   :
+   elif add_to_manpath "$path/MAN"; then
+   :
+   else
+   case "$path" in
+   */bin)  p="${path%/bin}/share/man"
+   add_to_manpath "$p"
+   p="${path%/bin}/man"
+   add_to_manpath "$p"
+   ;;
+   esac
+   fi
done
unset IFS
 
@@ -1007,7 +1000,7 @@ SYSCTL=/sbin/sysctl
 
 debug=0
 man_default_sections='1:8:2:3:n:4:5:6:7:9:l'
-man_default_path='/usr/share/man:/usr/share/openssl/man:/usr/local/man'
+man_default_path='/usr/share/man:/usr/share/openssl/man:/usr/local/share/man:/usr/local/man'
 cattool='/usr/bin/zcat -f'
 
 config_global='/etc/man.conf'

Modified: head/usr.bin/man/manpath.1
==
--- head/usr.bin/man/manpath.1  Sun Mar 12 07:09:50 2017(r315141)
+++ head/usr.bin/man/manpath.1  Sun Mar 12 10:56:19 2017(r315142)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 1, 2010
+.Dd March 11, 2017
 .Dt MANPATH 1
 .Os
 .Sh NAME
@@ -66,15 +66,10 @@ for the first of:
 .Pa pathname/MAN
 .It
 If pathname ends with /bin:
+.Pa pathname/../share/man
+and
 .Pa pathname/../man
 .El
-Note: Special logic exists to make
-.Pa /bin
-and
-.Pa /usr/bin
-look in
-.Pa /usr/share/man
-for manual files.
 .It
 The configuration files listed in the
 .Sx FILES
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r312699 - head/sys/amd64/linux

2017-01-24 Thread Tijl Coosemans
Author: tijl
Date: Tue Jan 24 16:13:59 2017
New Revision: 312699
URL: https://svnweb.freebsd.org/changeset/base/312699

Log:
  Apply r210555 to 64 bit linux support:
  
  The interpreter name should no longer be treated as a buffer that can be
  overwritten.
  
  PR:   216346
  MFC after:3 days

Modified:
  head/sys/amd64/linux/linux_sysvec.c

Modified: head/sys/amd64/linux/linux_sysvec.c
==
--- head/sys/amd64/linux/linux_sysvec.c Tue Jan 24 16:05:42 2017
(r312698)
+++ head/sys/amd64/linux/linux_sysvec.c Tue Jan 24 16:13:59 2017
(r312699)
@@ -718,7 +718,7 @@ exec_linux_imgact_try(struct image_param
 {
const char *head = (const char *)imgp->image_header;
char *rpath;
-   int error = -1, len;
+   int error = -1;
 
/*
 * The interpreter for shell scripts run from a linux binary needs
@@ -736,17 +736,12 @@ exec_linux_imgact_try(struct image_param
linux_emul_convpath(FIRST_THREAD_IN_PROC(imgp->proc),
imgp->interpreter_name, UIO_SYSSPACE,
, 0, AT_FDCWD);
-   if (rpath != NULL) {
-   len = strlen(rpath) + 1;
-
-   if (len <= MAXSHELLCMDLEN)
-   memcpy(imgp->interpreter_name,
-   rpath, len);
-   free(rpath, M_TEMP);
-   }
+   if (rpath != NULL)
+   imgp->args->fname_buf =
+   imgp->interpreter_name = rpath;
}
}
-   return(error);
+   return (error);
 }
 
 #defineLINUX_VSYSCALL_START(-10UL << 20)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r307936 - head/sys/amd64/amd64

2016-10-27 Thread Tijl Coosemans
On Wed, 26 Oct 2016 16:25:50 +0300 Konstantin Belousov <kostik...@gmail.com> 
wrote:
> On Tue, Oct 25, 2016 at 09:26:00PM +0200, Tijl Coosemans wrote:
>> On Tue, 25 Oct 2016 17:13:46 + (UTC) Gleb Smirnoff <gleb...@freebsd.org> 
>> wrote:  
>>> Author: glebius
>>> Date: Tue Oct 25 17:13:46 2016
>>> New Revision: 307936
>>> URL: https://svnweb.freebsd.org/changeset/base/307936
>>> 
>>> Log:
>>>   The argument validation in r296956 was not enough to close all possible
>>>   overflows in sysarch(2).
>>>   
>>>   Submitted by: Kun Yang 
>>>   Patch by: kib
>>>   Security: SA-16:15
>>> 
>>> Modified:
>>>   head/sys/amd64/amd64/sys_machdep.c  
>> 
>> This patch and r296956 need to be applied to i386 too, don't they?  
> I do not think so.  The amd64 bug is that I thought that the overflow
> checks were not needed, which appeared to be not true.
> 
> i386_set_ldt(), which is the i386 version of amd64_set_ldt(), already
> contained the comparisions of largest_ld with pldt->ldt_len etc.
> 
> Still, independend look at the i386 (and amd64 version as well) is more
> than welcomed, so please read the code yourself.

It looks ok to me.  i386 checks kargs.largs.num > MAX_LD early in sysarch
so start + num cannot overflow.  On amd64 this check was removed in
https://svnweb.freebsd.org/base?view=revision=217543
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r307936 - head/sys/amd64/amd64

2016-10-25 Thread Tijl Coosemans
On Tue, 25 Oct 2016 17:13:46 + (UTC) Gleb Smirnoff  
wrote:
> Author: glebius
> Date: Tue Oct 25 17:13:46 2016
> New Revision: 307936
> URL: https://svnweb.freebsd.org/changeset/base/307936
> 
> Log:
>   The argument validation in r296956 was not enough to close all possible
>   overflows in sysarch(2).
>   
>   Submitted by:   Kun Yang 
>   Patch by:   kib
>   Security:   SA-16:15
> 
> Modified:
>   head/sys/amd64/amd64/sys_machdep.c

This patch and r296956 need to be applied to i386 too, don't they?
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r307231 - head/lib/libgcc_s

2016-10-14 Thread Tijl Coosemans
On Fri, 14 Oct 2016 20:55:30 +0200 Dimitry Andric  wrote:
> On 14 Oct 2016, at 04:06, Ed Maste  wrote:
>> On 14 October 2016 at 01:53, Bruce Evans  wrote:  
 compiler-rt's complex division support routines contain calls to
 compiler builtins such as `__builtin_scalbnl`.  Unfortunately Clang
 turns these back into a call to `scalbnl`.  
>>> 
>>> gcc-4.2 has the same bug.  
>> 
>> Oh, interesting. Do you know off hand if it's resolved in later GCC?  
> 
> Not for x86, in any case (I think I talked about this with you on IRC
> before).  For example, using the latest gcc 7.0.0 20160911 on this
> program:
> 
> float f1(float x, int n)
> {
>   return __builtin_scalbnf(x, n);
> }
> 
> double f2(double x, int n)
> {
>   return __builtin_scalbn(x, n);
> }
> 
> long double f3(long double x, long n)
> {
>   return __builtin_scalbnl(x, n);
> }
> 
> gives this assembly:
> 
>   .p2align 4,,15
>   .globl  f1
>   .type   f1, @function
> f1:
> .LFB0:
>   .cfi_startproc
>   jmp scalbnf
>   .cfi_endproc
> .LFE0:
>   .size   f1, .-f1
>   .p2align 4,,15
>   .globl  f2
>   .type   f2, @function
> f2:
> .LFB1:
>   .cfi_startproc
>   jmp scalbn
>   .cfi_endproc
> .LFE1:
>   .size   f2, .-f2
>   .p2align 4,,15
>   .globl  f3
>   .type   f3, @function
> f3:
> .LFB2:
>   .cfi_startproc
>   jmp scalbnl
>   .cfi_endproc
> .LFE2:
>   .size   f3, .-f3
> 
> E.g., it looks like the __builtin_scalbn functions were always a red
> herring. :-)

>From https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html:

GCC includes built-in versions of many of the functions in the standard C
library. These functions come in two forms: one whose names start with
the __builtin_ prefix, and the other without. Both forms have the same
type (including prototype), the same address (when their address is
taken), and the same meaning as the C library functions even if you
specify the -fno-builtin option see C Dialect Options). Many of these
functions are only optimized in certain cases; if they are not optimized
in a particular case, a call to the library function is emitted.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r306318 - head/sys/i386/i386

2016-09-25 Thread Tijl Coosemans
Author: tijl
Date: Sun Sep 25 18:29:02 2016
New Revision: 306318
URL: https://svnweb.freebsd.org/changeset/base/306318

Log:
  MFamd64: r266901
  
  Allocate a zeroed LDT.
  
  Failing to do this might result in the LDT appearing to run out of free
  descriptors because of random junk in the descriptor's 'sd_type' field.
  
  http://lists.freebsd.org/pipermail/freebsd-amd64/2014-May/016088.html
  
  PR:   212639
  Submitted by: wheelcomp...@gmail.com
  MFC after:2 weeks

Modified:
  head/sys/i386/i386/sys_machdep.c

Modified: head/sys/i386/i386/sys_machdep.c
==
--- head/sys/i386/i386/sys_machdep.cSun Sep 25 17:58:55 2016
(r306317)
+++ head/sys/i386/i386/sys_machdep.cSun Sep 25 18:29:02 2016
(r306318)
@@ -438,7 +438,7 @@ user_ldt_alloc(struct mdproc *mdp, int l
 
new_ldt->ldt_len = len = NEW_MAX_LD(len);
new_ldt->ldt_base = (caddr_t)kmem_malloc(kernel_arena,
-   len * sizeof(union descriptor), M_WAITOK);
+   len * sizeof(union descriptor), M_WAITOK | M_ZERO);
new_ldt->ldt_refcnt = 1;
new_ldt->ldt_active = 0;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r290621 - head/sys/arm/qemu

2015-11-09 Thread Tijl Coosemans
Author: tijl
Date: Mon Nov  9 22:12:29 2015
New Revision: 290621
URL: https://svnweb.freebsd.org/changeset/base/290621

Log:
  Fix typo (s/ncpus/mp_ncpus/)
  
  Reported by:  bz

Modified:
  head/sys/arm/qemu/virt_mp.c

Modified: head/sys/arm/qemu/virt_mp.c
==
--- head/sys/arm/qemu/virt_mp.c Mon Nov  9 22:11:37 2015(r290620)
+++ head/sys/arm/qemu/virt_mp.c Mon Nov  9 22:12:29 2015(r290621)
@@ -71,7 +71,7 @@ platform_mp_setmaxid(void)
mp_ncpus = ofw_cpu_early_foreach(virt_maxid, true);
if (mp_ncpus < 1)
mp_ncpus = 1;
-   mp_ncpus = MIN(ncpus, MAXCPU);
+   mp_ncpus = MIN(mp_ncpus, MAXCPU);
 }
 
 static boolean_t
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r290547 - in head/sys: arm/annapurna/alpine arm/mv/armadaxp arm/qemu arm/ti/omap4 arm/xilinx kern x86/x86

2015-11-09 Thread Tijl Coosemans
On Mon, 9 Nov 2015 17:45:46 + "Bjoern A. Zeeb" <b...@freebsd.org> wrote:
>> On 08 Nov 2015, at 14:26 , Tijl Coosemans <t...@freebsd.org> wrote:
>> 
>> Author: tijl
>> Date: Sun Nov  8 14:26:50 2015
>> New Revision: 290547
>> URL: https://svnweb.freebsd.org/changeset/base/290547
>> 
>> Log:
>>  Since r289279 bufinit() uses mp_ncpus, but some architectures set this
>>  variable during mp_start() which is too late.  Move this to mp_setmaxid()
>>  where other architectures set it and move x86 assertions to MI code.
>> 
>>  Reviewed by:kib (x86 part)
>> 
>> Modified:
>>  head/sys/arm/annapurna/alpine/alpine_machdep_mp.c
>>  head/sys/arm/mv/armadaxp/armadaxp_mp.c
>>  head/sys/arm/qemu/virt_mp.c  
> 
> Seems copy and paste from the old to the new function brought some
> confusion n variable naming;  can you please fix?
> 
> 
> /home/baz21/SVN/head-ipv6-fix.svn/sys/arm/qemu/virt_mp.c:74:17: error: use of 
> undeclared identifier 'ncpus'; did you mean 'pcpup'?
> mp_ncpus = MIN(ncpus, MAXCPU);
>^
>pcpup
> /home/baz21/SVN/head-ipv6-fix.svn/sys/sys/param.h:301:21: note: expanded from 
> macro 'MIN'
> #define MIN(a,b) (((a)<(b))?(a):(b))
> ^
> ./machine/pcpu.h:65:21: note: 'pcpup' declared here
> extern struct pcpu *pcpup;
> ^
> /home/baz21/SVN/head-ipv6-fix.svn/sys/arm/qemu/virt_mp.c:74:13: error: 
> ordered comparison between pointer and integer ('struct pcpu *' and 'int') 
> [-Werror]
> mp_ncpus = MIN(ncpus, MAXCPU);
>^~
> /home/baz21/SVN/head-ipv6-fix.svn/sys/sys/param.h:301:23: note: expanded from 
> macro 'MIN'
> #define MIN(a,b) (((a)<(b))?(a):(b))
>~~~^~~~
> /home/baz21/SVN/head-ipv6-fix.svn/sys/arm/qemu/virt_mp.c:74:17: error: use of 
> undeclared identifier 'ncpus'; did you mean 'pcpup'?
> mp_ncpus = MIN(ncpus, MAXCPU);
>^
>pcpup
> /home/baz21/SVN/head-ipv6-fix.svn/sys/sys/param.h:301:30: note: expanded from 
> macro 'MIN'
> #define MIN(a,b) (((a)<(b))?(a):(b))
>  ^
> ./machine/pcpu.h:65:21: note: 'pcpup' declared here
> extern struct pcpu *pcpup;
> ^
> /home/baz21/SVN/head-ipv6-fix.svn/sys/arm/qemu/virt_mp.c:74:13: error: 
> pointer/integer type mismatch in conditional expression ('struct pcpu *' and 
> 'int') [-Werror,-Wconditional-type-mismatch]
> mp_ncpus = MIN(ncpus, MAXCPU);
>^~
> /home/baz21/SVN/head-ipv6-fix.svn/sys/sys/param.h:301:28: note: expanded from 
> macro 'MIN'
> #define MIN(a,b) (((a)<(b))?(a):(b))
>^~~~ ~~~
> /home/baz21/SVN/head-ipv6-fix.svn/sys/arm/qemu/virt_mp.c:74:11: error: 
> incompatible pointer to integer conversion assigning to 'int' from 'struct 
> pcpu *' [-Werror,-Wint-conversion]
> mp_ncpus = MIN(ncpus, MAXCPU);
>  ^ ~~
> 5 errors generated.
> --- virt_mp.o ---
> *** [virt_mp.o] Error code 1

Fixed in r290621.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r290547 - in head/sys: arm/annapurna/alpine arm/mv/armadaxp arm/qemu arm/ti/omap4 arm/xilinx kern x86/x86

2015-11-08 Thread Tijl Coosemans
Author: tijl
Date: Sun Nov  8 14:26:50 2015
New Revision: 290547
URL: https://svnweb.freebsd.org/changeset/base/290547

Log:
  Since r289279 bufinit() uses mp_ncpus, but some architectures set this
  variable during mp_start() which is too late.  Move this to mp_setmaxid()
  where other architectures set it and move x86 assertions to MI code.
  
  Reviewed by:  kib (x86 part)

Modified:
  head/sys/arm/annapurna/alpine/alpine_machdep_mp.c
  head/sys/arm/mv/armadaxp/armadaxp_mp.c
  head/sys/arm/qemu/virt_mp.c
  head/sys/arm/ti/omap4/omap4_mp.c
  head/sys/arm/xilinx/zy7_mp.c
  head/sys/kern/subr_smp.c
  head/sys/x86/x86/mp_x86.c

Modified: head/sys/arm/annapurna/alpine/alpine_machdep_mp.c
==
--- head/sys/arm/annapurna/alpine/alpine_machdep_mp.c   Sun Nov  8 14:22:57 
2015(r290546)
+++ head/sys/arm/annapurna/alpine/alpine_machdep_mp.c   Sun Nov  8 14:26:50 
2015(r290547)
@@ -128,16 +128,14 @@ platform_mp_init_secondary(void)
 void
 platform_mp_setmaxid(void)
 {
-   int core_cnt;
 
-   core_cnt = platform_mp_get_core_cnt();
-   mp_maxid = core_cnt - 1;
+   mp_ncpus = platform_mp_get_core_cnt();
+   mp_maxid = mp_ncpus - 1;
 }
 
 int
 platform_mp_probe(void)
 {
-   mp_ncpus = platform_mp_get_core_cnt();
return (1);
 }
 

Modified: head/sys/arm/mv/armadaxp/armadaxp_mp.c
==
--- head/sys/arm/mv/armadaxp/armadaxp_mp.c  Sun Nov  8 14:22:57 2015
(r290546)
+++ head/sys/arm/mv/armadaxp/armadaxp_mp.c  Sun Nov  8 14:26:50 2015
(r290547)
@@ -82,15 +82,14 @@ void
 platform_mp_setmaxid(void)
 {
 
-   mp_maxid = 3;
+   mp_ncpus = platform_get_ncpus();
+   mp_maxid = mp_ncpus - 1;
 }
 
 int
 platform_mp_probe(void)
 {
 
-   mp_ncpus = platform_get_ncpus();
-
return (mp_ncpus > 1);
 }
 

Modified: head/sys/arm/qemu/virt_mp.c
==
--- head/sys/arm/qemu/virt_mp.c Sun Nov  8 14:22:57 2015(r290546)
+++ head/sys/arm/qemu/virt_mp.c Sun Nov  8 14:26:50 2015(r290547)
@@ -49,17 +49,8 @@ static int running_cpus;
 int
 platform_mp_probe(void)
 {
-   int ncpus;
 
-   ncpus = ofw_cpu_early_foreach(NULL, true);
-   if (ncpus <= 1) {
-   mp_ncpus = 1;
-   return (0);
-   }
-
-   mp_ncpus = MIN(ncpus, MAXCPU);
-
-   return (1);
+   return (mp_ncpus > 1);
 }
 
 static boolean_t
@@ -77,7 +68,10 @@ platform_mp_setmaxid(void)
 {
 
mp_maxid = PCPU_GET(cpuid);
-   ofw_cpu_early_foreach(virt_maxid, true);
+   mp_ncpus = ofw_cpu_early_foreach(virt_maxid, true);
+   if (mp_ncpus < 1)
+   mp_ncpus = 1;
+   mp_ncpus = MIN(ncpus, MAXCPU);
 }
 
 static boolean_t

Modified: head/sys/arm/ti/omap4/omap4_mp.c
==
--- head/sys/arm/ti/omap4/omap4_mp.cSun Nov  8 14:22:57 2015
(r290546)
+++ head/sys/arm/ti/omap4/omap4_mp.cSun Nov  8 14:26:50 2015
(r290547)
@@ -51,14 +51,14 @@ void
 platform_mp_setmaxid(void)
 {
 
-mp_maxid = 1;
+   mp_maxid = 1;
+   mp_ncpus = 2;
 }
 
 int
 platform_mp_probe(void)
 {
 
-   mp_ncpus = 2;
return (1);
 }
 

Modified: head/sys/arm/xilinx/zy7_mp.c
==
--- head/sys/arm/xilinx/zy7_mp.cSun Nov  8 14:22:57 2015
(r290546)
+++ head/sys/arm/xilinx/zy7_mp.cSun Nov  8 14:26:50 2015
(r290547)
@@ -57,13 +57,13 @@ platform_mp_setmaxid(void)
 {
 
mp_maxid = 1;
+   mp_ncpus = 2;
 }
 
 int
 platform_mp_probe(void)
 {
 
-   mp_ncpus = 2;
return (1);
 }
 

Modified: head/sys/kern/subr_smp.c
==
--- head/sys/kern/subr_smp.cSun Nov  8 14:22:57 2015(r290546)
+++ head/sys/kern/subr_smp.cSun Nov  8 14:26:50 2015(r290547)
@@ -125,7 +125,15 @@ struct mtx smp_ipi_mtx;
 static void
 mp_setmaxid(void *dummy)
 {
+
cpu_mp_setmaxid();
+
+   KASSERT(mp_ncpus >= 1, ("%s: CPU count < 1", __func__));
+   KASSERT(mp_ncpus > 1 || mp_maxid == 0,
+   ("%s: one CPU but mp_maxid is not zero", __func__));
+   KASSERT(mp_maxid >= mp_ncpus - 1,
+   ("%s: counters out of sync: max %d, count %d", __func__,
+   mp_maxid, mp_ncpus));
 }
 SYSINIT(cpu_mp_setmaxid, SI_SUB_TUNABLES, SI_ORDER_FIRST, mp_setmaxid, NULL);
 

Modified: head/sys/x86/x86/mp_x86.c
==
--- head/sys/x86/x86/mp_x86.c   Sun Nov  8 14:22:57 2015(r290546)
+++ head/sys/x86/x86/mp_x86.c   Sun Nov  8 14:26:50 2015(r290547)
@@ -425,18 +425,11 @@ cpu_mp_setmaxid(void)
 {
 
/*
-* mp_maxid should be 

Re: svn commit: r289279 - in head/sys: kern vm

2015-10-30 Thread Tijl Coosemans
On Thu, 29 Oct 2015 22:33:34 +0200 Konstantin Belousov <kostik...@gmail.com> 
wrote:
> On Thu, Oct 29, 2015 at 09:25:54PM +0100, Tijl Coosemans wrote:
>> On Wed, 14 Oct 2015 02:10:07 + (UTC) Jeff Roberson <j...@freebsd.org> 
>> wrote:  
>>> Author: jeff
>>> Date: Wed Oct 14 02:10:07 2015
>>> New Revision: 289279
>>> URL: https://svnweb.freebsd.org/changeset/base/289279
>>> 
>>> Log:
>>>   Parallelize the buffer cache and rewrite getnewbuf().  This results in a
>>>   8x performance improvement in a micro benchmark on a 4 socket machine.
>>>   
>>>- Get buffer headers from a per-cpu uma cache that sits in from of the
>>>  free queue.
>>>- Use a per-cpu quantum cache in vmem to eliminate contention for kva.
>>>- Use multiple clean queues according to buffer cache size to eliminate
>>>  clean queue lock contention.
>>>- Introduce a bufspace daemon that attempts to prevent getnewbuf() 
>>> callers
>>>  from blocking or doing direct recycling.
>>>- Close some bufspace allocation races that could lead to endless
>>>  recycling.
>>>- Further the transition to a more modern style of small functions 
>>> grouped
>>>  by prefix in order to improve growing complexity.  
>> 
>> I have an i386 system that locks up easily after this commit.  Booting
>> into single user and running make installkernel triggers it consistently.
>> I haven't been able to reproduce it on amd64.  Examining threads with
>> DDB shows that they are all at sched_switch (a few at fork_trampoline).
>> The only lock being held is Giant (by the interrupt handler for
>> ctrl+alt+esc I think).  So it doesn't look like a dead lock.  It's more
>> a sleeping beauty situation.  All threads in the castle are sleeping and
>> there's no prince to wake them up.
>> 
>> (kgdb) info thread
>>   Id   Target Id Frame
>> 
>> These are from make installkernel:
>> 
>>   72   Thread 100071 (PID=107: install) sched_switch (td=0xc667d000, 
>> newtd=0xc6407000, flags=)
>> at /usr/src/sys/kern/sched_ule.c:1969
>>   71   Thread 100070 (PID=81: make) sched_switch (td=0xc667d340, 
>> newtd=0xc667d000, flags=)
>> at /usr/src/sys/kern/sched_ule.c:1969
>>   70   Thread 100067 (PID=30: make) sched_switch (td=0xc667e000, 
>> newtd=0xc667d340, flags=)
>> at /usr/src/sys/kern/sched_ule.c:1969
>>   69   Thread 100066 (PID=25: make) sched_switch (td=0xc667e340, 
>> newtd=0xc667e000, flags=)
>> at /usr/src/sys/kern/sched_ule.c:1969
>> 
>> Single user shell:
>> 
>>   68   Thread 100065 (PID=17: sh) sched_switch (td=0xc6406000, 
>> newtd=0xc667e340, flags=)
>> at /usr/src/sys/kern/sched_ule.c:1969
>> 
>> Kernel threads:
>> 
>>   67   Thread 100063 (PID=16: vnlru) sched_switch (td=0xc6406680, 
>> newtd=0xc6407340, flags=)
>> at /usr/src/sys/kern/sched_ule.c:1969
>>   66   Thread 100062 (PID=9: syncer) sched_switch (td=0xc64069c0, 
>> newtd=0xc667d000, flags=)
>> at /usr/src/sys/kern/sched_ule.c:1969
>>   65   Thread 100061 (PID=8: bufspacedaemon) sched_switch (td=0xc6407000, 
>> newtd=0xc62dc000, flags=)
>> at /usr/src/sys/kern/sched_ule.c:1969
>>   64   Thread 100060 (PID=7: bufdaemon) sched_switch (td=0xc6407340, 
>> newtd=0xc6408000, flags=)
>> at /usr/src/sys/kern/sched_ule.c:1969
>>   63   Thread 100068 (PID=7: bufdaemon//var worker) sched_switch (
>> td=0xc667d9c0, newtd=0xc6407000, flags=)
>> at /usr/src/sys/kern/sched_ule.c:1969
>>   62   Thread 100069 (PID=7: bufdaemon//usr worker) sched_switch (
>> td=0xc667d680, newtd=0xc667d000, flags=)
>> at /usr/src/sys/kern/sched_ule.c:1969
>>   61   Thread 100059 (PID=6: pagezero) sched_switch (td=0xc6407680, 
>> newtd=0xc55ba680, flags=)
>> at /usr/src/sys/kern/sched_ule.c:1969
>>   60   Thread 100058 (PID=5: vmdaemon) sched_switch (td=0xc64079c0, 
>> newtd=0xc6407340, flags=)
>> at /usr/src/sys/kern/sched_ule.c:1969
>>   59   Thread 100057 (PID=4: pagedaemon) sched_switch (td=0xc6408000, 
>> newtd=0xc6407000, flags=)
>> at /usr/src/sys/kern/sched_ule.c:1969
>>   58   Thread 100064 (PID=4: pagedaemon/uma) sched_switch (td=0xc6406340, 
>> newtd=0xc55b9340, flags=)
>> at /usr/src/sys/kern/sched_ule.c:1969
>>   57   Thread 100050 (PID=15: acpi_cooling0) sched_switch (td=0xc62dc340, 
>> newtd=0xc6407000, flags=)
>> at /usr/src/sys/kern/sched_ule.c:1969
>> 
>> 
>> Anything else you need to debug this?  
> 
> Start with gathering the information listed in
> https://www.freebsd.org/doc/en_US.ISO8859-1/books/developers-handbook/kerneldebug-deadlocks.html

https://people.freebsd.org/~tijl/r289279-dead.txt

r290155 doesn't fix it by the way.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r289279 - in head/sys: kern vm

2015-10-29 Thread Tijl Coosemans
On Wed, 14 Oct 2015 02:10:07 + (UTC) Jeff Roberson  wrote:
> Author: jeff
> Date: Wed Oct 14 02:10:07 2015
> New Revision: 289279
> URL: https://svnweb.freebsd.org/changeset/base/289279
> 
> Log:
>   Parallelize the buffer cache and rewrite getnewbuf().  This results in a
>   8x performance improvement in a micro benchmark on a 4 socket machine.
>   
>- Get buffer headers from a per-cpu uma cache that sits in from of the
>  free queue.
>- Use a per-cpu quantum cache in vmem to eliminate contention for kva.
>- Use multiple clean queues according to buffer cache size to eliminate
>  clean queue lock contention.
>- Introduce a bufspace daemon that attempts to prevent getnewbuf() callers
>  from blocking or doing direct recycling.
>- Close some bufspace allocation races that could lead to endless
>  recycling.
>- Further the transition to a more modern style of small functions grouped
>  by prefix in order to improve growing complexity.

I have an i386 system that locks up easily after this commit.  Booting
into single user and running make installkernel triggers it consistently.
I haven't been able to reproduce it on amd64.  Examining threads with
DDB shows that they are all at sched_switch (a few at fork_trampoline).
The only lock being held is Giant (by the interrupt handler for
ctrl+alt+esc I think).  So it doesn't look like a dead lock.  It's more
a sleeping beauty situation.  All threads in the castle are sleeping and
there's no prince to wake them up.

(kgdb) info thread
  Id   Target Id Frame

These are from make installkernel:

  72   Thread 100071 (PID=107: install) sched_switch (td=0xc667d000, 
newtd=0xc6407000, flags=)
at /usr/src/sys/kern/sched_ule.c:1969
  71   Thread 100070 (PID=81: make) sched_switch (td=0xc667d340, 
newtd=0xc667d000, flags=)
at /usr/src/sys/kern/sched_ule.c:1969
  70   Thread 100067 (PID=30: make) sched_switch (td=0xc667e000, 
newtd=0xc667d340, flags=)
at /usr/src/sys/kern/sched_ule.c:1969
  69   Thread 100066 (PID=25: make) sched_switch (td=0xc667e340, 
newtd=0xc667e000, flags=)
at /usr/src/sys/kern/sched_ule.c:1969

Single user shell:

  68   Thread 100065 (PID=17: sh) sched_switch (td=0xc6406000, 
newtd=0xc667e340, flags=)
at /usr/src/sys/kern/sched_ule.c:1969

Kernel threads:

  67   Thread 100063 (PID=16: vnlru) sched_switch (td=0xc6406680, 
newtd=0xc6407340, flags=)
at /usr/src/sys/kern/sched_ule.c:1969
  66   Thread 100062 (PID=9: syncer) sched_switch (td=0xc64069c0, 
newtd=0xc667d000, flags=)
at /usr/src/sys/kern/sched_ule.c:1969
  65   Thread 100061 (PID=8: bufspacedaemon) sched_switch (td=0xc6407000, 
newtd=0xc62dc000, flags=)
at /usr/src/sys/kern/sched_ule.c:1969
  64   Thread 100060 (PID=7: bufdaemon) sched_switch (td=0xc6407340, 
newtd=0xc6408000, flags=)
at /usr/src/sys/kern/sched_ule.c:1969
  63   Thread 100068 (PID=7: bufdaemon//var worker) sched_switch (
td=0xc667d9c0, newtd=0xc6407000, flags=)
at /usr/src/sys/kern/sched_ule.c:1969
  62   Thread 100069 (PID=7: bufdaemon//usr worker) sched_switch (
td=0xc667d680, newtd=0xc667d000, flags=)
at /usr/src/sys/kern/sched_ule.c:1969
  61   Thread 100059 (PID=6: pagezero) sched_switch (td=0xc6407680, 
newtd=0xc55ba680, flags=)
at /usr/src/sys/kern/sched_ule.c:1969
  60   Thread 100058 (PID=5: vmdaemon) sched_switch (td=0xc64079c0, 
newtd=0xc6407340, flags=)
at /usr/src/sys/kern/sched_ule.c:1969
  59   Thread 100057 (PID=4: pagedaemon) sched_switch (td=0xc6408000, 
newtd=0xc6407000, flags=)
at /usr/src/sys/kern/sched_ule.c:1969
  58   Thread 100064 (PID=4: pagedaemon/uma) sched_switch (td=0xc6406340, 
newtd=0xc55b9340, flags=)
at /usr/src/sys/kern/sched_ule.c:1969
  57   Thread 100050 (PID=15: acpi_cooling0) sched_switch (td=0xc62dc340, 
newtd=0xc6407000, flags=)
at /usr/src/sys/kern/sched_ule.c:1969


Anything else you need to debug this?
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r287467 - head/sys/dev/e1000

2015-09-05 Thread Tijl Coosemans
On Fri, 4 Sep 2015 16:30:49 + (UTC) Sean Bruno  wrote:
> Author: sbruno
> Date: Fri Sep  4 16:30:48 2015
> New Revision: 287467
> URL: https://svnweb.freebsd.org/changeset/base/287467
> 
> Log:
>   e1000: Shared code updates
>   -Fix compiler warning in 80003es2lan.c
>   -Add return value handler for e1000_*_kmrn_reg_80003es2lan
>   -Fix usage of DEBUGOUT
>   -Remove unnecessary variable initializations.
>   -Removed unused variables (complaints from gcc).
>   -Edit defines in 82571.h.
>   -Add workaround for igb hw errata.
>   -Shared code changes for Skylake/I219 support.
>   -Remove unused OBFF and LTR functions.
>   
>   Differential Revision:  https://reviews.freebsd.org/D3162
>   Submitted by:   erj
>   MFC after:  1 month
>   Sponsored by:   Intel Corporation
> 
> Modified:
>   head/sys/dev/e1000/e1000_80003es2lan.c
>   head/sys/dev/e1000/e1000_82540.c
>   head/sys/dev/e1000/e1000_82541.c
>   head/sys/dev/e1000/e1000_82542.c
>   head/sys/dev/e1000/e1000_82543.c
>   head/sys/dev/e1000/e1000_82571.h
>   head/sys/dev/e1000/e1000_82575.c
>   head/sys/dev/e1000/e1000_82575.h
>   head/sys/dev/e1000/e1000_api.c
>   head/sys/dev/e1000/e1000_api.h
>   head/sys/dev/e1000/e1000_defines.h
>   head/sys/dev/e1000/e1000_hw.h
>   head/sys/dev/e1000/e1000_i210.c
>   head/sys/dev/e1000/e1000_i210.h
>   head/sys/dev/e1000/e1000_ich8lan.c
>   head/sys/dev/e1000/e1000_ich8lan.h
>   head/sys/dev/e1000/e1000_mac.c
>   head/sys/dev/e1000/e1000_mac.h
>   head/sys/dev/e1000/e1000_nvm.c
>   head/sys/dev/e1000/e1000_nvm.h
>   head/sys/dev/e1000/e1000_osdep.h
>   head/sys/dev/e1000/e1000_phy.c
>   head/sys/dev/e1000/e1000_regs.h
>   head/sys/dev/e1000/if_igb.c

I have an em device that fails to attach after this commit:

em0@pci0:0:25:0: class=0x02 card=0x00018086 chip=0x294c8086 rev=0x02 
hdr=0x00
vendor = 'Intel Corporation'
device = '82566DC-2 Gigabit Network Connection'
class  = network
subclass   = ethernet

em0:  port 0x3400-0x341f mem
0x9220-0x9221,0x92224000-0x92224fff irq 20 at device 25.0 on pci0
em0: Using an MSI interrupt

At this point the machine waits for about half a minute and then continues
with this:

em0: The EEPROM Checksum Is Not Valid
device_attach: em0 attach returned 5
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r287442 - in head: lib/libprocstat lib/libutil share/man/man5 sys/kern sys/sys

2015-09-05 Thread Tijl Coosemans
On Thu, 3 Sep 2015 20:32:10 + (UTC) "Conrad E. Meyer"  
wrote:
> Author: cem
> Date: Thu Sep  3 20:32:10 2015
> New Revision: 287442
> URL: https://svnweb.freebsd.org/changeset/base/287442
> 
> Log:
>   Detect badly behaved coredump note helpers
>   
>   Coredump notes depend on being able to invoke dump routines twice; once
>   in a dry-run mode to get the size of the note, and another to actually
>   emit the note to the corefile.
>   
>   When a note helper emits a different length section the second time
>   around than the length it requested the first time, the kernel produces
>   a corrupt coredump.
>   
>   NT_PROCSTAT_FILES output length, when packing kinfo structs, is tied to
>   the length of filenames corresponding to vnodes in the process' fd table
>   via vn_fullpath.  As vnodes may move around during dump, this is racy.
>   
>   So:
>   
>- Detect badly behaved notes in putnote() and pad underfilled notes.
>   
>- Add a fail point, debug.fail_point.fill_kinfo_vnode__random_path to
>  exercise the NT_PROCSTAT_FILES corruption.  It simply picks random
>  lengths to expand or truncate paths to in fo_fill_kinfo_vnode().
>   
>- Add a sysctl, kern.coredump_pack_fileinfo, to allow users to
>  disable kinfo packing for PROCSTAT_FILES notes.  This should avoid
>  both FILES note corruption and truncation, even if filenames change,
>  at the cost of about 1 kiB in padding bloat per open fd.  Document
>  the new sysctl in core.5.
>   
>- Fix note_procstat_files to self-limit in the 2nd pass.  Since
>  sometimes this will result in a short write, pad up to our advertised
>  size.  This addresses note corruption, at the risk of sometimes
>  truncating the last several fd info entries.
>   
>- Fix NT_PROCSTAT_FILES consumers libutil and libprocstat to grok the
>  zero padding.
>   
>   With suggestions from:  bjk, jhb, kib, wblock
>   Approved by:markj (mentor)
>   Relnotes:   yes
>   Sponsored by:   EMC / Isilon Storage Division
>   Differential Revision:  https://reviews.freebsd.org/D3548
> 
> Modified:
>   head/lib/libprocstat/libprocstat.c
>   head/lib/libutil/kinfo_getfile.c
>   head/share/man/man5/core.5
>   head/sys/kern/imgact_elf.c
>   head/sys/kern/kern_descrip.c
>   head/sys/kern/vfs_vnops.c
>   head/sys/sys/user.h
> 
> Modified: head/sys/kern/imgact_elf.c
> ==
> --- head/sys/kern/imgact_elf.cThu Sep  3 19:42:56 2015
> (r287441)
> +++ head/sys/kern/imgact_elf.cThu Sep  3 20:32:10 2015
> (r287442)
> @@ -1875,29 +1902,56 @@ __elfN(note_procstat_proc)(void *arg, st
>  CTASSERT(sizeof(struct kinfo_file) == KINFO_FILE_SIZE);
>  #endif
>  
> +static int pack_fileinfo = 1;
> +SYSCTL_INT(_kern, OID_AUTO, coredump_pack_fileinfo, CTLFLAG_RWTUN,
> +_fileinfo, 0,
> +"Enable file path packing in 'procstat -f' coredump notes");

This file can be compiled twice (included by both imgact_elf32.c and
imgact_elf64.c) so this sysctl can be added twice and the second time
results in an error message in dmesg: "can't re-use a leaf".
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r287254 - head/sys/sys

2015-08-28 Thread Tijl Coosemans
On Fri, 28 Aug 2015 14:06:29 + (UTC) Pedro F. Giffuni p...@freebsd.org 
wrote:
 Author: pfg
 Date: Fri Aug 28 14:06:28 2015
 New Revision: 287254
 URL: https://svnweb.freebsd.org/changeset/base/287254
 
 Log:
   Be more GCC-friendly with attributes
   
   Being clang the default compiler, we were always giving precedence to
   the __has_attribute check. Unfortunately clang generally doesn't support
   the new attributes (alloc_size was briefly supported and then reverted)
   so we were always doing both checks. Give the precedence to GCC as that is
   the working case now.
   
   Do the same for  __has_builtin() for consistency.
 
 Modified:
   head/sys/sys/cdefs.h
 
 Modified: head/sys/sys/cdefs.h
 ==
 --- head/sys/sys/cdefs.h  Fri Aug 28 13:57:30 2015(r287253)
 +++ head/sys/sys/cdefs.h  Fri Aug 28 14:06:28 2015(r287254)
 @@ -237,12 +237,12 @@
  #define  __aligned(x)__attribute__((__aligned__(x)))
  #define  __section(x)__attribute__((__section__(x)))
  #endif
 -#if __has_attribute(alloc_size) || __GNUC_PREREQ__(4, 3)
 +#if __GNUC_PREREQ__(4, 3) || __has_attribute(alloc_size)

I think you have to add underscores to the __has_attribute argument,
like __alloc_size__ here, because user code is allowed to use
alloc_size.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r285140 - in head: include lib/libc/stdio

2015-07-04 Thread Tijl Coosemans
On Sat, 4 Jul 2015 16:42:15 + (UTC) Mariusz Zaborski osho...@freebsd.org 
wrote:
 Author: oshogbo
 Date: Sat Jul  4 16:42:14 2015
 New Revision: 285140
 URL: https://svnweb.freebsd.org/changeset/base/285140
 
 Log:
   Add fdclose(3) function.
   
   This function is equivalent to fclose(3) function except that it
   does not close the underlying file descriptor.
   fdclose(3) is step forward to make FILE structure private.

You can probably close this bug now:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=75767
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r284858 - head/sys/sys

2015-06-25 Thread Tijl Coosemans
Author: tijl
Date: Thu Jun 25 19:39:07 2015
New Revision: 284858
URL: https://svnweb.freebsd.org/changeset/base/284858

Log:
  Enable the use of __builtin_va_* for ICC.
  
  PR:   198822
  Submitted by: Sergey Melnikov sergey.melni...@intel.com
  MFC after:5 days

Modified:
  head/sys/sys/cdefs.h

Modified: head/sys/sys/cdefs.h
==
--- head/sys/sys/cdefs.hThu Jun 25 18:45:37 2015(r284857)
+++ head/sys/sys/cdefs.hThu Jun 25 19:39:07 2015(r284858)
@@ -92,7 +92,7 @@
 #undef __GNUCLIKE_BUILTIN_CONSTANT_P
 #endif
 
-#if (__GNUC_MINOR__  95 || __GNUC__ = 3)  !defined(__INTEL_COMPILER)
+#if (__GNUC_MINOR__  95 || __GNUC__ = 3)
 #define__GNUCLIKE_BUILTIN_VARARGS 1
 #define__GNUCLIKE_BUILTIN_STDARG 1
 #define__GNUCLIKE_BUILTIN_VAALIST 1
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r284426 - head/lib/msun/src

2015-06-15 Thread Tijl Coosemans
Author: tijl
Date: Mon Jun 15 20:16:53 2015
New Revision: 284426
URL: https://svnweb.freebsd.org/changeset/base/284426

Log:
  Fix some exceptional cases where the sign of the result is unspecified
  but must still satisfy csinh(conj(z)) == conj(csinh(z)) and csinh(-z) ==
  -csinh(z).  This allows eliminating two negations from csin(z).
  
  In collaboration with:bde

Modified:
  head/lib/msun/src/s_csinh.c
  head/lib/msun/src/s_csinhf.c

Modified: head/lib/msun/src/s_csinh.c
==
--- head/lib/msun/src/s_csinh.c Mon Jun 15 20:12:15 2015(r284425)
+++ head/lib/msun/src/s_csinh.c Mon Jun 15 20:16:53 2015(r284426)
@@ -32,6 +32,8 @@
  *
  * Exceptional values are noted in the comments within the source code.
  * These values and the return value were taken from n1124.pdf.
+ * The sign of the result for some exceptional values is unspecified but
+ * must satisfy both sinh(conj(z)) == conj(sinh(z)) and sinh(-z) == -sinh(z).
  */
 
 #include sys/cdefs.h
@@ -63,7 +65,7 @@ csinh(double complex z)
if (ix  0x7ff0  iy  0x7ff0) {
if ((iy | ly) == 0)
return (CMPLX(sinh(x), y));
-   if (ix  0x4036)/* small x: normal case */
+   if (ix  0x4036)/* |x|  22: normal case */
return (CMPLX(sinh(x) * cos(y), cosh(x) * sin(y)));
 
/* |x| = 22, so cosh(x) ~= exp(|x|) */
@@ -83,27 +85,24 @@ csinh(double complex z)
}
 
/*
-* sinh(+-0 +- I Inf) = sign(d(+-0, dNaN))0 + I dNaN.
-* The sign of 0 in the result is unspecified.  Choice = normally
-* the same as dNaN.  Raise the invalid floating-point exception.
-*
-* sinh(+-0 +- I NaN) = sign(d(+-0, NaN))0 + I d(NaN).
-* The sign of 0 in the result is unspecified.  Choice = normally
-* the same as d(NaN).
+* sinh(+-0 +- I Inf) = +-0 + I dNaN.
+* The sign of 0 in the result is unspecified.  Choice = same sign
+* as the argument.  Raise the invalid floating-point exception.
+*
+* sinh(+-0 +- I NaN) = +-0 + I d(NaN).
+* The sign of 0 in the result is unspecified.  Choice = same sign
+* as the argument.
 */
-   if ((ix | lx) == 0  iy = 0x7ff0)
-   return (CMPLX(copysign(0, x * (y - y)), y - y));
+   if ((ix | lx) == 0) /*  iy = 0x7ff0 */
+   return (CMPLX(x, y - y));
 
/*
 * sinh(+-Inf +- I 0) = +-Inf + I +-0.
 *
 * sinh(NaN +- I 0)   = d(NaN) + I +-0.
 */
-   if ((iy | ly) == 0  ix = 0x7ff0) {
-   if (((hx  0xf) | lx) == 0)
-   return (CMPLX(x, y));
-   return (CMPLX(x, copysign(0, y)));
-   }
+   if ((iy | ly) == 0) /*  ix = 0x7ff0 */
+   return (CMPLX(x + x, y));
 
/*
 * sinh(x +- I Inf) = dNaN + I dNaN.
@@ -113,45 +112,45 @@ csinh(double complex z)
 * Optionally raises the invalid floating-point exception for finite
 * nonzero x.  Choice = don't raise (except for signaling NaNs).
 */
-   if (ix  0x7ff0  iy = 0x7ff0)
-   return (CMPLX(y - y, x * (y - y)));
+   if (ix  0x7ff0)/*  iy = 0x7ff0 */
+   return (CMPLX(y - y, y - y));
 
/*
 * sinh(+-Inf + I NaN)  = +-Inf + I d(NaN).
-* The sign of Inf in the result is unspecified.  Choice = normally
-* the same as d(NaN).
+* The sign of Inf in the result is unspecified.  Choice = same sign
+* as the argument.
 *
-* sinh(+-Inf +- I Inf) = +Inf + I dNaN.
-* The sign of Inf in the result is unspecified.  Choice = always +.
-* Raise the invalid floating-point exception.
+* sinh(+-Inf +- I Inf) = +-Inf + I dNaN.
+* The sign of Inf in the result is unspecified.  Choice = same sign
+* as the argument.  Raise the invalid floating-point exception.
 *
 * sinh(+-Inf + I y)   = +-Inf cos(y) + I Inf sin(y)
 */
-   if (ix = 0x7ff0  ((hx  0xf) | lx) == 0) {
+   if (ix == 0x7ff0  lx == 0) {
if (iy = 0x7ff0)
-   return (CMPLX(x * x, x * (y - y)));
+   return (CMPLX(x, y - y));
return (CMPLX(x * cos(y), INFINITY * sin(y)));
}
 
/*
-* sinh(NaN + I NaN)  = d(NaN) + I d(NaN).
+* sinh(NaN1 + I NaN2) = d(NaN1, NaN2) + I d(NaN1, NaN2).
 *
-* sinh(NaN +- I Inf) = d(NaN) + I d(NaN).
+* sinh(NaN +- I Inf)  = d(NaN, dNaN) + I d(NaN, dNaN).
 * Optionally raises the invalid floating-point exception.
 * Choice = raise.
 *
-* sinh(NaN + I y)= d(NaN) + I d(NaN).
+* sinh(NaN + I y) = d(NaN) + I d(NaN).
 * 

svn commit: r284428 - head/lib/msun/src

2015-06-15 Thread Tijl Coosemans
Author: tijl
Date: Mon Jun 15 20:47:26 2015
New Revision: 284428
URL: https://svnweb.freebsd.org/changeset/base/284428

Log:
  Follow up to r284427: fix NaN mixing for ctanhf too.

Modified:
  head/lib/msun/src/s_ctanhf.c

Modified: head/lib/msun/src/s_ctanhf.c
==
--- head/lib/msun/src/s_ctanhf.cMon Jun 15 20:40:44 2015
(r284427)
+++ head/lib/msun/src/s_ctanhf.cMon Jun 15 20:47:26 2015
(r284428)
@@ -51,7 +51,8 @@ ctanhf(float complex z)
 
if (ix = 0x7f80) {
if (ix  0x7f)
-   return (CMPLXF(x, (y == 0 ? y : x * y)));
+   return (CMPLXF((x + 0) * (y + 0),
+   y == 0 ? y : (x + 0) * (y + 0)));
SET_FLOAT_WORD(x, hx - 0x4000);
return (CMPLXF(x,
copysignf(0, isinf(y) ? y : sinf(y) * cosf(y;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r284427 - head/lib/msun/src

2015-06-15 Thread Tijl Coosemans
Author: tijl
Date: Mon Jun 15 20:40:44 2015
New Revision: 284427
URL: https://svnweb.freebsd.org/changeset/base/284427

Log:
  - Change comments to be more consistent with s_ccosh.c and s_csinh.c.
  - Fix a case where NaNs were not mixed correctly and signalling NaNs were
not converted to quiet NaNs.
  - Eliminate two negations from ctan(z).
  
  In collaboration with:bde

Modified:
  head/lib/msun/src/s_ctanh.c
  head/lib/msun/src/s_ctanhf.c

Modified: head/lib/msun/src/s_ctanh.c
==
--- head/lib/msun/src/s_ctanh.c Mon Jun 15 20:16:53 2015(r284426)
+++ head/lib/msun/src/s_ctanh.c Mon Jun 15 20:40:44 2015(r284427)
@@ -25,7 +25,7 @@
  */
 
 /*
- * Hyperbolic tangent of a complex argument z = x + i y.
+ * Hyperbolic tangent of a complex argument z = x + I y.
  *
  * The algorithm is from:
  *
@@ -44,15 +44,15 @@
  *
  *   tanh(z) = sinh(z) / cosh(z)
  *
- * sinh(x) cos(y) + i cosh(x) sin(y)
+ * sinh(x) cos(y) + I cosh(x) sin(y)
  *   = -
- * cosh(x) cos(y) + i sinh(x) sin(y)
+ * cosh(x) cos(y) + I sinh(x) sin(y)
  *
- * cosh(x) sinh(x) / cos^2(y) + i tan(y)
+ * cosh(x) sinh(x) / cos^2(y) + I tan(y)
  *   = -
  *1 + sinh^2(x) / cos^2(y)
  *
- * beta rho s + i t
+ * beta rho s + I t
  *   = 
  *   1 + beta s^2
  *
@@ -85,16 +85,16 @@ ctanh(double complex z)
ix = hx  0x7fff;
 
/*
-* ctanh(NaN + i 0) = NaN + i 0
+* ctanh(NaN +- I 0) = d(NaN) +- I 0
 *
-* ctanh(NaN + i y) = NaN + i NaN   for y != 0
+* ctanh(NaN + I y) = d(NaN,y) + I d(NaN,y) for y != 0
 *
 * The imaginary part has the sign of x*sin(2*y), but there's no
 * special effort to get this right.
 *
-* ctanh(+-Inf +- i Inf) = +-1 +- 0
+* ctanh(+-Inf +- I Inf) = +-1 +- I 0
 *
-* ctanh(+-Inf + i y) = +-1 + 0 sin(2y) for y finite
+* ctanh(+-Inf + I y) = +-1 + I 0 sin(2y)   for y finite
 *
 * The imaginary part of the sign is unspecified.  This special
 * case is only needed to avoid a spurious invalid exception when
@@ -102,24 +102,25 @@ ctanh(double complex z)
 */
if (ix = 0x7ff0) {
if ((ix  0xf) | lx)/* x is NaN */
-   return (CMPLX(x, (y == 0 ? y : x * y)));
+   return (CMPLX((x + 0) * (y + 0),
+   y == 0 ? y : (x + 0) * (y + 0)));
SET_HIGH_WORD(x, hx - 0x4000);  /* x = copysign(1, x) */
return (CMPLX(x, copysign(0, isinf(y) ? y : sin(y) * cos(y;
}
 
/*
-* ctanh(x + i NAN) = NaN + i NaN
-* ctanh(x +- i Inf) = NaN + i NaN
+* ctanh(x + I NaN) = d(NaN) + I d(NaN)
+* ctanh(x +- I Inf) = dNaN + I dNaN
 */
if (!isfinite(y))
return (CMPLX(y - y, y - y));
 
/*
-* ctanh(+-huge + i +-y) ~= +-1 +- i 2sin(2y)/exp(2x), using the
+* ctanh(+-huge +- I y) ~= +-1 +- I 2sin(2y)/exp(2x), using the
 * approximation sinh^2(huge) ~= exp(2*huge) / 4.
 * We use a modified formula to avoid spurious overflow.
 */
-   if (ix = 0x4036) { /* x = 22 */
+   if (ix = 0x4036) { /* |x| = 22 */
double exp_mx = exp(-fabs(x));
return (CMPLX(copysign(1, x),
4 * sin(y) * cos(y) * exp_mx * exp_mx));
@@ -138,7 +139,7 @@ double complex
 ctan(double complex z)
 {
 
-   /* ctan(z) = -I * ctanh(I * z) */
-   z = ctanh(CMPLX(-cimag(z), creal(z)));
-   return (CMPLX(cimag(z), -creal(z)));
+   /* ctan(z) = -I * ctanh(I * z) = I * conj(ctanh(I * conj(z))) */
+   z = ctanh(CMPLX(cimag(z), creal(z)));
+   return (CMPLX(cimag(z), creal(z)));
 }

Modified: head/lib/msun/src/s_ctanhf.c
==
--- head/lib/msun/src/s_ctanhf.cMon Jun 15 20:16:53 2015
(r284426)
+++ head/lib/msun/src/s_ctanhf.cMon Jun 15 20:40:44 2015
(r284427)
@@ -60,7 +60,7 @@ ctanhf(float complex z)
if (!isfinite(y))
return (CMPLXF(y - y, y - y));
 
-   if (ix = 0x4130) { /* x = 11 */
+   if (ix = 0x4130) { /* |x| = 11 */
float exp_mx = expf(-fabsf(x));
return (CMPLXF(copysignf(1, x),
4 * sinf(y) * cosf(y) * exp_mx * exp_mx));
@@ -78,7 +78,7 @@ float complex
 ctanf(float complex z)
 {
 
-   z = ctanhf(CMPLXF(-cimagf(z), crealf(z)));
-   return (CMPLXF(cimagf(z), -crealf(z)));
+   z = ctanhf(CMPLXF(cimagf(z), crealf(z)));
+   return (CMPLXF(cimagf(z), 

svn commit: r284422 - head/usr.sbin/crunch/crunchgen

2015-06-15 Thread Tijl Coosemans
Author: tijl
Date: Mon Jun 15 19:48:28 2015
New Revision: 284422
URL: https://svnweb.freebsd.org/changeset/base/284422

Log:
  Change -Wl,-r back to -r so gcc doesn't pass --relax to the linker on some
  architectures.
  
  PR:   200881

Modified:
  head/usr.sbin/crunch/crunchgen/crunchgen.c

Modified: head/usr.sbin/crunch/crunchgen/crunchgen.c
==
--- head/usr.sbin/crunch/crunchgen/crunchgen.c  Mon Jun 15 19:28:07 2015
(r284421)
+++ head/usr.sbin/crunch/crunchgen/crunchgen.c  Mon Jun 15 19:48:28 2015
(r284422)
@@ -1110,7 +1110,7 @@ prog_makefile_rules(FILE *outmk, prog_t 
fprintf(outmk,  $(%s_LIBS), p-ident);
 
fprintf(outmk, \n);
-   fprintf(outmk, \t$(CC) -nostdlib -Wl,-dc -Wl,-r -o %s.lo %s_stub.o 
$(%s_OBJPATHS),
+   fprintf(outmk, \t$(CC) -nostdlib -Wl,-dc -r -o %s.lo %s_stub.o 
$(%s_OBJPATHS),
p-name, p-name, p-ident);
if (p-libs)
fprintf(outmk,  $(%s_LIBS), p-ident);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r284423 - head/lib/msun/src

2015-06-15 Thread Tijl Coosemans
Author: tijl
Date: Mon Jun 15 20:11:06 2015
New Revision: 284423
URL: https://svnweb.freebsd.org/changeset/base/284423

Log:
  Fix some exceptional cases where the sign of the result is unspecified
  but must still satisfy ccosh(conj(z)) == conj(ccosh(z)) and ccosh(-z) ==
  ccosh(z).
  
  In collaboration with:bde

Modified:
  head/lib/msun/src/s_ccosh.c
  head/lib/msun/src/s_ccoshf.c

Modified: head/lib/msun/src/s_ccosh.c
==
--- head/lib/msun/src/s_ccosh.c Mon Jun 15 19:48:28 2015(r284422)
+++ head/lib/msun/src/s_ccosh.c Mon Jun 15 20:11:06 2015(r284423)
@@ -32,6 +32,8 @@
  *
  * Exceptional values are noted in the comments within the source code.
  * These values and the return value were taken from n1124.pdf.
+ * The sign of the result for some exceptional values is unspecified but
+ * must satisfy both cosh(conj(z)) == conj(cosh(z)) and cosh(-z) == cosh(z).
  */
 
 #include sys/cdefs.h
@@ -63,7 +65,7 @@ ccosh(double complex z)
if (ix  0x7ff0  iy  0x7ff0) {
if ((iy | ly) == 0)
return (CMPLX(cosh(x), x * y));
-   if (ix  0x4036)/* small x: normal case */
+   if (ix  0x4036)/* |x|  22: normal case */
return (CMPLX(cosh(x) * cos(y), sinh(x) * sin(y)));
 
/* |x| = 22, so cosh(x) ~= exp(|x|) */
@@ -83,28 +85,27 @@ ccosh(double complex z)
}
 
/*
-* cosh(+-0 +- I Inf) = dNaN + I sign(d(+-0, dNaN))0.
-* The sign of 0 in the result is unspecified.  Choice = normally
-* the same as dNaN.  Raise the invalid floating-point exception.
-*
-* cosh(+-0 +- I NaN) = d(NaN) + I sign(d(+-0, NaN))0.
-* The sign of 0 in the result is unspecified.  Choice = normally
-* the same as d(NaN).
+* cosh(+-0 +- I Inf) = dNaN + I (+-)(+-)0.
+* The sign of 0 in the result is unspecified.  Choice = product
+* of the signs of the argument.  Raise the invalid floating-point
+* exception.
+*
+* cosh(+-0 +- I NaN) = d(NaN) + I (+-)(+-)0.
+* The sign of 0 in the result is unspecified.  Choice = product
+* of the signs of the argument.
 */
-   if ((ix | lx) == 0  iy = 0x7ff0)
-   return (CMPLX(y - y, copysign(0, x * (y - y;
+   if ((ix | lx) == 0) /*  iy = 0x7ff0 */
+   return (CMPLX(y - y, x * copysign(0, y)));
 
/*
 * cosh(+-Inf +- I 0) = +Inf + I (+-)(+-)0.
 *
-* cosh(NaN +- I 0)   = d(NaN) + I sign(d(NaN, +-0))0.
-* The sign of 0 in the result is unspecified.
+* cosh(NaN +- I 0)   = d(NaN) + I (+-)(+-)0.
+* The sign of 0 in the result is unspecified.  Choice = product
+* of the signs of the argument.
 */
-   if ((iy | ly) == 0  ix = 0x7ff0) {
-   if (((hx  0xf) | lx) == 0)
-   return (CMPLX(x * x, copysign(0, x) * y));
-   return (CMPLX(x * x, copysign(0, (x + x) * y)));
-   }
+   if ((iy | ly) == 0) /*  ix = 0x7ff0 */
+   return (CMPLX(x * x, copysign(0, x) * y));
 
/*
 * cosh(x +- I Inf) = dNaN + I dNaN.
@@ -114,7 +115,7 @@ ccosh(double complex z)
 * Optionally raises the invalid floating-point exception for finite
 * nonzero x.  Choice = don't raise (except for signaling NaNs).
 */
-   if (ix  0x7ff0  iy = 0x7ff0)
+   if (ix  0x7ff0)/*  iy = 0x7ff0 */
return (CMPLX(y - y, x * (y - y)));
 
/*
@@ -126,10 +127,10 @@ ccosh(double complex z)
 *
 * cosh(+-Inf + I y)   = +Inf cos(y) +- I Inf sin(y)
 */
-   if (ix = 0x7ff0  ((hx  0xf) | lx) == 0) {
+   if (ix == 0x7ff0  lx == 0) {
if (iy = 0x7ff0)
-   return (CMPLX(x * x, x * (y - y)));
-   return (CMPLX((x * x) * cos(y), x * sin(y)));
+   return (CMPLX(INFINITY, x * (y - y)));
+   return (CMPLX(INFINITY * cos(y), x * sin(y)));
}
 
/*

Modified: head/lib/msun/src/s_ccoshf.c
==
--- head/lib/msun/src/s_ccoshf.cMon Jun 15 19:48:28 2015
(r284422)
+++ head/lib/msun/src/s_ccoshf.cMon Jun 15 20:11:06 2015
(r284423)
@@ -25,7 +25,7 @@
  */
 
 /*
- * Hyperbolic cosine of a complex argument.  See s_ccosh.c for details.
+ * Float version of ccosh().  See s_ccosh.c for details.
  */
 
 #include sys/cdefs.h
@@ -56,13 +56,13 @@ ccoshf(float complex z)
if (ix  0x7f80  iy  0x7f80) {
if (iy == 0)
return (CMPLXF(coshf(x), x * y));
-   if (ix  0x4110)/* small x: normal case */
+   if (ix  

Re: svn commit: r284356 - head/usr.sbin/crunch/crunchgen

2015-06-14 Thread Tijl Coosemans
On Sat, 13 Jun 2015 22:01:21 + (UTC) Adrian Chadd adr...@freebsd.org 
wrote:
 Author: adrian
 Date: Sat Jun 13 22:01:21 2015
 New Revision: 284356
 URL: https://svnweb.freebsd.org/changeset/base/284356
 
 Log:
   Fix up crunchgen binary generation to work with external cross-build
   tools.
   
   * Allow STRIP to be overridden by the environment
   * Use CC to tie things together, not LD
   
   Tested:
   
   * i386, mips32
   
   Submitted by:   kan
 
 Modified:
   head/usr.sbin/crunch/crunchgen/crunchgen.c
 
 Modified: head/usr.sbin/crunch/crunchgen/crunchgen.c
 ==
 --- head/usr.sbin/crunch/crunchgen/crunchgen.cSat Jun 13 20:15:44 
 2015(r284355)
 +++ head/usr.sbin/crunch/crunchgen/crunchgen.cSat Jun 13 22:01:21 
 2015(r284356)
 @@ -980,6 +980,7 @@ top_makefile_rules(FILE *outmk)
   prog_t *p;
  
   fprintf(outmk, LD?= ld\n);
 + fprintf(outmk, STRIP?= strip\n);
   if ( subtract_strlst(libs, libs_so) )
   fprintf(outmk, # NOTE: Some LIBS declarations below overridden 
 by LIBS_SO\n);
  
 @@ -1027,7 +1028,7 @@ top_makefile_rules(FILE *outmk)
   fprintf(outmk, \t$(CC) -static -o %s %s.o $(CRUNCHED_OBJS) $(LIBS)\n,
   execfname, execfname);
   fprintf(outmk, .endif\n);
 - fprintf(outmk, \tstrip %s\n, execfname);
 + fprintf(outmk, \t$(STRIP) %s\n, execfname);
   fprintf(outmk, realclean: clean subclean\n);
   fprintf(outmk, clean:\n\trm -f %s *.lo *.o *_stub.c\n, execfname);
   fprintf(outmk, subclean: $(SUBCLEAN_TARGETS)\n);
 @@ -1109,7 +1110,7 @@ prog_makefile_rules(FILE *outmk, prog_t 
   fprintf(outmk,  $(%s_LIBS), p-ident);
  
   fprintf(outmk, \n);
 - fprintf(outmk, \t$(LD) -dc -r -o %s.lo %s_stub.o $(%s_OBJPATHS),
 + fprintf(outmk, \t$(CC) -nostdlibs -dc -r -o %s.lo %s_stub.o 
 $(%s_OBJPATHS),

Does CC understand -dc and -r?
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r284356 - head/usr.sbin/crunch/crunchgen

2015-06-14 Thread Tijl Coosemans
On Sun, 14 Jun 2015 08:07:17 -0700 Adrian Chadd adr...@freebsd.org wrote:
 On 14 June 2015 at 02:41, Tijl Coosemans t...@freebsd.org wrote:
 On Sat, 13 Jun 2015 22:01:21 + (UTC) Adrian Chadd adr...@freebsd.org 
 wrote:
 Author: adrian
 Date: Sat Jun 13 22:01:21 2015
 New Revision: 284356
 URL: https://svnweb.freebsd.org/changeset/base/284356

 Log:
   Fix up crunchgen binary generation to work with external cross-build
   tools.

   * Allow STRIP to be overridden by the environment
   * Use CC to tie things together, not LD

   Tested:

   * i386, mips32

   Submitted by:   kan

 Modified:
   head/usr.sbin/crunch/crunchgen/crunchgen.c

 Modified: head/usr.sbin/crunch/crunchgen/crunchgen.c
 ==
 --- head/usr.sbin/crunch/crunchgen/crunchgen.cSat Jun 13 20:15:44 
 2015(r284355)
 +++ head/usr.sbin/crunch/crunchgen/crunchgen.cSat Jun 13 22:01:21 
 2015(r284356)
 @@ -1109,7 +1110,7 @@ prog_makefile_rules(FILE *outmk, prog_t
   fprintf(outmk,  $(%s_LIBS), p-ident);

   fprintf(outmk, \n);
 - fprintf(outmk, \t$(LD) -dc -r -o %s.lo %s_stub.o $(%s_OBJPATHS),
 + fprintf(outmk, \t$(CC) -nostdlibs -dc -r -o %s.lo %s_stub.o 
 $(%s_OBJPATHS),

 Does CC understand -dc and -r?
 
 Apparently?

Hmm, it's undocumented but it seems to recognise -r and pass it on to
the linker.  Not -dc though.  It's safer to use: -Wl,-dc -Wl,-r
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r284382 - head/usr.sbin/crunch/crunchgen

2015-06-14 Thread Tijl Coosemans
Author: tijl
Date: Sun Jun 14 15:40:17 2015
New Revision: 284382
URL: https://svnweb.freebsd.org/changeset/base/284382

Log:
  Tell the compiler that -dc and -r are linker flags.
  
  Reviewed by:  adrian

Modified:
  head/usr.sbin/crunch/crunchgen/crunchgen.c

Modified: head/usr.sbin/crunch/crunchgen/crunchgen.c
==
--- head/usr.sbin/crunch/crunchgen/crunchgen.c  Sun Jun 14 14:10:05 2015
(r284381)
+++ head/usr.sbin/crunch/crunchgen/crunchgen.c  Sun Jun 14 15:40:17 2015
(r284382)
@@ -1110,7 +1110,7 @@ prog_makefile_rules(FILE *outmk, prog_t 
fprintf(outmk,  $(%s_LIBS), p-ident);
 
fprintf(outmk, \n);
-   fprintf(outmk, \t$(CC) -nostdlib -dc -r -o %s.lo %s_stub.o 
$(%s_OBJPATHS),
+   fprintf(outmk, \t$(CC) -nostdlib -Wl,-dc -Wl,-r -o %s.lo %s_stub.o 
$(%s_OBJPATHS),
p-name, p-name, p-ident);
if (p-libs)
fprintf(outmk,  $(%s_LIBS), p-ident);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r284356 - head/usr.sbin/crunch/crunchgen

2015-06-14 Thread Tijl Coosemans
On Sun, 14 Jun 2015 08:31:32 -0700 Adrian Chadd adr...@freebsd.org wrote:
 On 14 June 2015 at 08:28, Tijl Coosemans t...@freebsd.org wrote:
 On Sun, 14 Jun 2015 08:07:17 -0700 Adrian Chadd adr...@freebsd.org wrote:
 On 14 June 2015 at 02:41, Tijl Coosemans t...@freebsd.org wrote:
 On Sat, 13 Jun 2015 22:01:21 + (UTC) Adrian Chadd adr...@freebsd.org 
 wrote:
 Author: adrian
 Date: Sat Jun 13 22:01:21 2015
 New Revision: 284356
 URL: https://svnweb.freebsd.org/changeset/base/284356

 Log:
   Fix up crunchgen binary generation to work with external cross-build
   tools.

   * Allow STRIP to be overridden by the environment
   * Use CC to tie things together, not LD

   Tested:

   * i386, mips32

   Submitted by:   kan

 Modified:
   head/usr.sbin/crunch/crunchgen/crunchgen.c

 Modified: head/usr.sbin/crunch/crunchgen/crunchgen.c
 ==
 --- head/usr.sbin/crunch/crunchgen/crunchgen.cSat Jun 13 20:15:44 
 2015(r284355)
 +++ head/usr.sbin/crunch/crunchgen/crunchgen.cSat Jun 13 22:01:21 
 2015(r284356)
 @@ -1109,7 +1110,7 @@ prog_makefile_rules(FILE *outmk, prog_t
   fprintf(outmk,  $(%s_LIBS), p-ident);

   fprintf(outmk, \n);
 - fprintf(outmk, \t$(LD) -dc -r -o %s.lo %s_stub.o $(%s_OBJPATHS),
 + fprintf(outmk, \t$(CC) -nostdlibs -dc -r -o %s.lo %s_stub.o 
 $(%s_OBJPATHS),

 Does CC understand -dc and -r?

 Apparently?

 Hmm, it's undocumented but it seems to recognise -r and pass it on to
 the linker.  Not -dc though.  It's safer to use: -Wl,-dc -Wl,-r
 
 Ok. Would you mind committing it? I'm not near a FreeBSD machine at the 
 moment.

Done in r284382.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r283418 - head/lib/libiconv_modules/UTF7

2015-05-24 Thread Tijl Coosemans
Author: tijl
Date: Sun May 24 15:47:06 2015
New Revision: 283418
URL: https://svnweb.freebsd.org/changeset/base/283418

Log:
  When only 2 bytes can be read from a 4 byte UTF-16 character in a base64
  encoded chunk of a UTF-7 string, treat that as an incomplete character and
  return an error instead of a shift sequence and no error.
  
  Also check that the low 2 bytes have a valid value.
  
  MFC after:1 week

Modified:
  head/lib/libiconv_modules/UTF7/citrus_utf7.c

Modified: head/lib/libiconv_modules/UTF7/citrus_utf7.c
==
--- head/lib/libiconv_modules/UTF7/citrus_utf7.cSun May 24 15:45:36 
2015(r283417)
+++ head/lib/libiconv_modules/UTF7/citrus_utf7.cSun May 24 15:47:06 
2015(r283418)
@@ -62,8 +62,7 @@ typedef struct {
unsigned int
mode: 1,/* whether base64 mode */
bits: 4,/* need to hold 0 - 15 */
-   cache: 22,  /* 22 = BASE64_BIT + UTF16_BIT */
-   surrogate: 1;   /* whether surrogate pair or not */
+   cache: 22;  /* 22 = BASE64_BIT + UTF16_BIT */
int chlen;
char ch[4]; /* BASE64_IN, 3 * 6 = 18, most closed to UTF16_BIT */
 } _UTF7State;
@@ -253,34 +252,31 @@ _citrus_UTF7_mbrtowc_priv(_UTF7EncodingI
*nresult = (size_t)_ENCODING_IS_STATE_DEPENDENT;
return (0);
}
-   if (psenc-surrogate) {
-   hi = (psenc-cache  psenc-bits)  UTF16_MAX;
-   if (hi  HISRG_MIN || hi  HISRG_MAX)
-   return (EINVAL);
-   siz = 0;
-   } else {
-   err = _citrus_UTF7_mbtoutf16(ei, hi, s, n, psenc, nr);
-   if (nr == (size_t)-1 || nr == (size_t)-2) {
-   *nresult = nr;
-   return (err);
-   }
-   if (err != 0)
-   return (err);
-   n -= nr;
-   siz = nr;
-   if (hi  HISRG_MIN || hi  HISRG_MAX) {
-   u32 = (uint32_t)hi;
-   goto done;
-   }
-   psenc-surrogate = 1;
+   err = _citrus_UTF7_mbtoutf16(ei, hi, s, n, psenc, nr);
+   if (nr == (size_t)-1 || nr == (size_t)-2) {
+   *nresult = nr;
+   return (err);
+   }
+   if (err != 0)
+   return (err);
+   n -= nr;
+   siz = nr;
+   if (hi  HISRG_MIN || hi  HISRG_MAX) {
+   u32 = (uint32_t)hi;
+   goto done;
}
err = _citrus_UTF7_mbtoutf16(ei, lo, s, n, psenc, nr);
if (nr == (size_t)-1 || nr == (size_t)-2) {
+   psenc-chlen = 1; /* make get_state_desc return incomplete */
*nresult = nr;
return (err);
}
if (err != 0)
return (err);
+   if (lo  LOSRG_MIN || lo  LOSRG_MAX) {
+   *nresult = (size_t)-1;
+   return (EILSEQ);
+   }
hi -= HISRG_MIN;
lo -= LOSRG_MIN;
u32 = (hi  10 | lo) + SRG_BASE;
@@ -293,7 +289,6 @@ done:
_citrus_UTF7_init_state(ei, psenc);
} else {
*nresult = siz;
-   psenc-surrogate = 0;
}
return (err);
 }
@@ -392,7 +387,7 @@ _citrus_UTF7_put_state_reset(_UTF7Encodi
 {
int bits, pos;
 
-   if (psenc-chlen != 0 || psenc-bits  BASE64_BIT || psenc-surrogate)
+   if (psenc-chlen != 0 || psenc-bits  BASE64_BIT)
return (EINVAL);
 
if (psenc-mode) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r283406 - head/lib/libiconv_modules/UTF7

2015-05-24 Thread Tijl Coosemans
Author: tijl
Date: Sun May 24 15:27:31 2015
New Revision: 283406
URL: https://svnweb.freebsd.org/changeset/base/283406

Log:
  Fix decoding of UTF-7 when a base64 encoded chunk appears at the end of
  the input buffer.
  
  _citrus_UTF7_mbtoutf16 stored the decoder state at the beginning so it
  could restore this state on an incomplete character such that the next
  call would restart the decoding.  The problem was that - (end of base64
  mode) at the end of a string was also treated as an incomplete character
  but was also removed from the state buffer.  So the initial state would be
  restored (with base64 mode) and the next call would no longer see the -
  so it continued in base64 mode.
  
  This state saving/restoring isn't needed here.  It's already handled
  elsewhere (citrus_iconv_std.c:_citrus_iconv_std_iconv_convert) so just
  remove it.
  
  Also initialise *nresult.
  
  PR:   200398
  Tested by:delphij
  MFC after:1 week

Modified:
  head/lib/libiconv_modules/UTF7/citrus_utf7.c

Modified: head/lib/libiconv_modules/UTF7/citrus_utf7.c
==
--- head/lib/libiconv_modules/UTF7/citrus_utf7.cSun May 24 15:22:33 
2015(r283405)
+++ head/lib/libiconv_modules/UTF7/citrus_utf7.cSun May 24 15:27:31 
2015(r283406)
@@ -154,21 +154,17 @@ _citrus_UTF7_mbtoutf16(_UTF7EncodingInfo
 uint16_t * __restrict u16, char ** __restrict s, size_t n,
 _UTF7State * __restrict psenc, size_t * __restrict nresult)
 {
-   _UTF7State sv;
char *s0;
int done, i, len;
 
+   *nresult = 0;
s0 = *s;
-   sv = *psenc;
 
for (i = 0, done = 0; done == 0; i++) {
if (i == psenc-chlen) {
if (n--  1) {
*nresult = (size_t)-2;
*s = s0;
-   sv.chlen = psenc-chlen;
-   memcpy(sv.ch, psenc-ch, sizeof(sv.ch));
-   *psenc = sv;
return (0);
}
psenc-ch[psenc-chlen++] = *s0++;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r282907 - head/sys/sys

2015-05-15 Thread Tijl Coosemans
On Thu, 14 May 2015 15:49:49 + (UTC) Pedro F. Giffuni p...@freebsd.org 
wrote:
 Author: pfg
 Date: Thu May 14 15:49:48 2015
 New Revision: 282907
 URL: https://svnweb.freebsd.org/changeset/base/282907
 
 Log:
   Add new __unreachable() builtin
   
   This is one of the few post gcc4.2 builtins that has been implemented by
   clang:
   
   __builtin_unreachable is used to indicate that a specific point in the
   program cannot be reached, even if the compiler might otherwise think it
   can. This is useful to improve optimization and eliminates certain
   warnings.
   
   Hinted by:  NetBSD
   Differential Revision:  https://reviews.freebsd.org/D2536
 
 Modified:
   head/sys/sys/cdefs.h
 
 Modified: head/sys/sys/cdefs.h
 ==
 --- head/sys/sys/cdefs.h  Thu May 14 15:14:03 2015(r282906)
 +++ head/sys/sys/cdefs.h  Thu May 14 15:49:48 2015(r282907)
 @@ -388,6 +388,12 @@
  #define  __alloc_size(x)
  #endif
  
 +#if __has_builtin(__builtin_unreachable) || __GNUC_PREREQ__(4, 6)
 +#define  __unreachable() __builtin_unreachable()
 +#else
 +#define  __unreachable() do {} while (/*CONSTCOND*/0)

__builtin_unreachable() can be used in expressions so I think it's better
to replace do-while with ((void)0).  You can then do things like this:

#define assume(e)  ((e) ? (void)0 : __unreachable())
(like assert(e) but without error)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r281591 - head/bin/csh

2015-04-16 Thread Tijl Coosemans
Author: tijl
Date: Thu Apr 16 07:17:00 2015
New Revision: 281591
URL: https://svnweb.freebsd.org/changeset/base/281591

Log:
  Fix build after r281550 when WITHOUT_ICONV is defined.
  
  Reported by:  adrian
  MFC after:2 weeks

Modified:
  head/bin/csh/iconv_stub.h

Modified: head/bin/csh/iconv_stub.h
==
--- head/bin/csh/iconv_stub.h   Thu Apr 16 06:23:58 2015(r281590)
+++ head/bin/csh/iconv_stub.h   Thu Apr 16 07:17:00 2015(r281591)
@@ -30,7 +30,7 @@
 #define _ICONV_H_
 
 typedef void *iconv_t;
-typedef size_t dl_iconv_t(iconv_t, const char **, size_t *, char **, size_t *);
+typedef size_t dl_iconv_t(iconv_t, char **, size_t *, char **, size_t *);
 typedef int dl_iconv_close_t(iconv_t);
 
 extern iconv_t dl_iconv_open(const char *, const char *);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r281550 - in head: . bin/csh contrib/smbfs/include/netsmb contrib/smbfs/lib/smb include lib/libarchive lib/libc/iconv lib/libc/locale lib/libiconv_modules/BIG5 lib/libiconv_modules/DEC

2015-04-15 Thread Tijl Coosemans
On Wed, 15 Apr 2015 11:29:19 -0700 Adrian Chadd adr...@freebsd.org wrote:
 cc1: warnings being treated as errors
 /usr/home/adrian/work/freebsd/embedded/head/src/bin/csh/../../contrib/tcsh/sh.func.c:
 In function 'iconv_catgets':
 /usr/home/adrian/work/freebsd/embedded/head/src/bin/csh/../../contrib/tcsh/sh.func.c:2599:
 warning: passing argument 2 of 'dl_iconv' from incompatible pointer
 type

Does embedded mean that WITHOUT_ICONV is defined?
Can you try the attached patch?Index: bin/csh/iconv_stub.h
===
--- bin/csh/iconv_stub.h	(revision 281561)
+++ bin/csh/iconv_stub.h	(working copy)
@@ -30,7 +30,7 @@
 #define _ICONV_H_
 
 typedef void *iconv_t;
-typedef size_t dl_iconv_t(iconv_t, const char **, size_t *, char **, size_t *);
+typedef size_t dl_iconv_t(iconv_t, char **, size_t *, char **, size_t *);
 typedef int dl_iconv_close_t(iconv_t);
 
 extern iconv_t dl_iconv_open(const char *, const char *);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org

svn commit: r281550 - in head: . bin/csh contrib/smbfs/include/netsmb contrib/smbfs/lib/smb include lib/libarchive lib/libc/iconv lib/libc/locale lib/libiconv_modules/BIG5 lib/libiconv_modules/DECH...

2015-04-15 Thread Tijl Coosemans
Author: tijl
Date: Wed Apr 15 09:09:20 2015
New Revision: 281550
URL: https://svnweb.freebsd.org/changeset/base/281550

Log:
  Remove the const qualifier from iconv(3) to comply with POSIX:
  http://pubs.opengroup.org/onlinepubs/9699919799/functions/iconv.html
  
  Adjust all code that calls iconv.
  
  PR:   199099
  Exp-run by:   antoine
  MFC after:2 weeks

Modified:
  head/UPDATING
  head/bin/csh/config.h
  head/contrib/smbfs/include/netsmb/smb_lib.h
  head/contrib/smbfs/lib/smb/nls.c
  head/contrib/smbfs/lib/smb/print.c
  head/contrib/smbfs/lib/smb/rq.c
  head/include/iconv.h
  head/lib/libarchive/Makefile
  head/lib/libc/iconv/__iconv.c
  head/lib/libc/iconv/bsd_iconv.c
  head/lib/libc/iconv/citrus_iconv.h
  head/lib/libc/iconv/citrus_iconv_local.h
  head/lib/libc/iconv/citrus_none.c
  head/lib/libc/iconv/citrus_stdenc.h
  head/lib/libc/iconv/citrus_stdenc_local.h
  head/lib/libc/iconv/citrus_stdenc_template.h
  head/lib/libc/iconv/iconv-internal.h
  head/lib/libc/iconv/iconv.3
  head/lib/libc/iconv/iconv.c
  head/lib/libc/iconv/iconv_compat.c
  head/lib/libc/locale/cXXrtomb_iconv.h
  head/lib/libc/locale/mbrtocXX_iconv.h
  head/lib/libiconv_modules/BIG5/citrus_big5.c
  head/lib/libiconv_modules/DECHanyu/citrus_dechanyu.c
  head/lib/libiconv_modules/EUC/citrus_euc.c
  head/lib/libiconv_modules/EUCTW/citrus_euctw.c
  head/lib/libiconv_modules/GBK2K/citrus_gbk2k.c
  head/lib/libiconv_modules/HZ/citrus_hz.c
  head/lib/libiconv_modules/ISO2022/citrus_iso2022.c
  head/lib/libiconv_modules/JOHAB/citrus_johab.c
  head/lib/libiconv_modules/MSKanji/citrus_mskanji.c
  head/lib/libiconv_modules/UES/citrus_ues.c
  head/lib/libiconv_modules/UTF1632/citrus_utf1632.c
  head/lib/libiconv_modules/UTF7/citrus_utf7.c
  head/lib/libiconv_modules/UTF8/citrus_utf8.c
  head/lib/libiconv_modules/VIQR/citrus_viqr.c
  head/lib/libiconv_modules/ZW/citrus_zw.c
  head/lib/libiconv_modules/iconv_none/citrus_iconv_none.c
  head/lib/libiconv_modules/iconv_std/citrus_iconv_std.c
  head/lib/libkiconv/xlat16_iconv.c
  head/sys/sys/param.h
  head/usr.bin/iconv/iconv.c

Modified: head/UPDATING
==
--- head/UPDATING   Wed Apr 15 08:16:34 2015(r281549)
+++ head/UPDATING   Wed Apr 15 09:09:20 2015(r281550)
@@ -31,6 +31,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11
disable the most expensive debugging functionality run
ln -s 'abort:false,junk:false' /etc/malloc.conf.)
 
+20150415:
+   The const qualifier has been removed from iconv(3) to comply with
+   POSIX.  The ports tree is aware of this from r384038 onwards.
+
 20150324:
From legacy ata(4) driver was removed support for SATA controllers
supported by more functional drivers ahci(4), siis(4) and mvs(4).

Modified: head/bin/csh/config.h
==
--- head/bin/csh/config.h   Wed Apr 15 08:16:34 2015(r281549)
+++ head/bin/csh/config.h   Wed Apr 15 09:09:20 2015(r281550)
@@ -198,7 +198,7 @@
 #define HAVE_WCWIDTH 1
 
 /* Define as const if the declaration of iconv() needs const. */
-#define ICONV_CONST const
+#define ICONV_CONST
 
 /* Support NLS. */
 #define NLS 1

Modified: head/contrib/smbfs/include/netsmb/smb_lib.h
==
--- head/contrib/smbfs/include/netsmb/smb_lib.h Wed Apr 15 08:16:34 2015
(r281549)
+++ head/contrib/smbfs/include/netsmb/smb_lib.h Wed Apr 15 09:09:20 2015
(r281550)
@@ -191,7 +191,7 @@ int  smb_ctx_readrc(struct smb_ctx *);
 int  smb_ctx_resolve(struct smb_ctx *);
 int  smb_ctx_setflags(struct smb_ctx *, int, int, int);
 
-int  smb_smb_open_print_file(struct smb_ctx *, int, int, const char *, smbfh*);
+int  smb_smb_open_print_file(struct smb_ctx *, int, int, char *, smbfh*);
 int  smb_smb_close_print_file(struct smb_ctx *, smbfh);
 
 int  smb_read(struct smb_ctx *, smbfh, off_t, size_t, char *);
@@ -204,8 +204,8 @@ int  smb_rq_init(struct smb_ctx *, u_cha
 void smb_rq_done(struct smb_rq *);
 void smb_rq_wend(struct smb_rq *);
 int  smb_rq_simple(struct smb_rq *);
-int  smb_rq_dmem(struct mbdata *, const char *, size_t);
-int  smb_rq_dstring(struct mbdata *, const char *);
+int  smb_rq_dmem(struct mbdata *, char *, size_t);
+int  smb_rq_dstring(struct mbdata *, char *);
 
 int  smb_t2_request(struct smb_ctx *, int, int, const char *,
int, void *, int, void *, int *, void *, int *, void *);
@@ -246,10 +246,10 @@ extern u_char nls_lower[256], nls_upper[
 
 int   nls_setrecode(const char *, const char *);
 int   nls_setlocale(const char *);
-char* nls_str_toext(char *, const char *);
-char* nls_str_toloc(char *, const char *);
-void* nls_mem_toext(void *, const void *, int);
-void* nls_mem_toloc(void *, const void *, int);
+char* nls_str_toext(char *, char *);
+char* nls_str_toloc(char *, char *);
+void* nls_mem_toext(void *, void *, 

svn commit: r281552 - head/sys/sys

2015-04-15 Thread Tijl Coosemans
Author: tijl
Date: Wed Apr 15 09:39:52 2015
New Revision: 281552
URL: https://svnweb.freebsd.org/changeset/base/281552

Log:
  Point to the right location where __FreeBSD_version numbers are documented.

Modified:
  head/sys/sys/param.h

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hWed Apr 15 09:13:11 2015(r281551)
+++ head/sys/sys/param.hWed Apr 15 09:39:52 2015(r281552)
@@ -50,7 +50,7 @@
  * there.
  * Currently this lives here in the doc/ repository:
  *
- * head/en_US.ISO8859-1/books/porters-handbook/book.xml
+ * head/en_US.ISO8859-1/books/porters-handbook/versions/chapter.xml
  *
  * scheme is:  majortwo digit minorRxx
  * 'R' is in the range 0 to 4 if this is a release branch or
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r280636 - head/include

2015-03-26 Thread Tijl Coosemans
On Thu, 26 Mar 2015 17:37:53 +1100 (EST) Bruce Evans b...@optusnet.com.au 
wrote:
 On Wed, 25 Mar 2015, Pedro Giffuni wrote:
 On 03/25/15 21:14, Bruce Evans wrote:
 On Wed, 25 Mar 2015, Pedro F. Giffuni wrote:
 Log:
  Temporarily revert 280458.
 
  GCC is still carries an old version of cdefs.h which doesn't
  accept multiple parameters for the nonnull attribute.
  Since this issue probably affects many ports in the tree
  we will revert it for now until gcc gets fixed.
 
 Note that sys/cdefs.h is supposed to work with any version of
 gcc back to gcc-1, and does mostly work back to at least gcc-2.95.
 The whole point of sys/cdefs.h is to provide compatibity macros
 for old and other non-default compilers.  Standard compilers don't
 even have __attribute__(()).  So no changes in future versions
 of gcc will fix the previous commit.
 
 cdefs.h still works for all versions of gcc back to gcc-1 AFAICT.
 
 I now remember other bugs in it.  I think you put the varargs stuff
 in the non-gcc version.  That won't work compilers that don't support
 varargs for macros.  Neither will not changing the non-gcc version.
 
 glibc (2.6 at least) avoids using varargs in its __nonnull() macro
 by using the same portable method that is used in many optional
 debugging statements including FreeBSD's KASSERT().  (KASSERT() is
 broken as designed.  It never needed this since it wasn't implmented
 until several years after C99 standardized  varargs for macros.)
 The macro takes a single arg consisting of a normal list of args
 enclosed in parentheses.  The extra parentheses are not passed to
 the __attribute__() list.  All invocations of the macro must be
 ugly to supply the parantheses.  The parentheses give a large
 syntactic difference, so the ugliness cannot be fixed easily by
 switching to varargs macros.  For KASSERT(), there would be about
 7500 in /usr/src lines to clean up.  For __nonnull(), there would
 be only about lines 160 in /usr/src to change.  Mostly
 __nonnull(1) - __nonnull((1)).  But __nonnull() is more likely to
 be (mis)used in ports.

Maybe introduce a __nonnull_all macro and leave __nonnull varargs-free:

#define __nonnull(x)__attribute__((__nonnull__(x)))
#define __nonnull_all   __attribute__((__nonnull__))

Then in the rare cases where multiple arguments must be nonnull but
__nonnull_all doesn't apply you can use multiple __nonnull: 

int f(void *, void *, void *) __nonnull(1) __nonnull(2);

 The reason why I had to revert the change is actually a systematic
 bug in gcc: during it's build process gcc generates a new cdefs.h
 from our headers. Attempting to use an older gcc from ports
 that was build with the broken mono-parameter __nonnull() ended
 up causing breakage in any code using signal.h or pthreads.h.
 
 I see.  gcc's fixed headers cause lots of problems.

I've complained about this multiple times in the past.  The gcc ports
should not install these fixed headers.

Pedro, by reverting this commit you only allow this problem to persist,
so please reapply it.  You also shouldn't wait weeks before applying
the next commit.  No amount of waiting is enough.  There will always be
users bitten by it.  The problem is in the ports.  It needs to be fixed
there.  If you receive any problem reports that are caused by this gcc
problem, forward them to the gcc port maintainer.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r279079 - head/sys/x86/acpica

2015-02-20 Thread Tijl Coosemans
Author: tijl
Date: Fri Feb 20 19:42:26 2015
New Revision: 279079
URL: https://svnweb.freebsd.org/changeset/base/279079

Log:
  Fix build on i386 without device apic
  
  Reviewed by:  kib

Modified:
  head/sys/x86/acpica/acpi_wakeup.c

Modified: head/sys/x86/acpica/acpi_wakeup.c
==
--- head/sys/x86/acpica/acpi_wakeup.c   Fri Feb 20 19:42:05 2015
(r279078)
+++ head/sys/x86/acpica/acpi_wakeup.c   Fri Feb 20 19:42:26 2015
(r279079)
@@ -30,6 +30,11 @@
 #include sys/cdefs.h
 __FBSDID($FreeBSD$);
 
+#if defined(__amd64__)
+#define DEV_APIC
+#else
+#include opt_apic.h
+#endif
 #ifdef __i386__
 #include opt_npx.h
 #endif
@@ -55,8 +60,10 @@ __FBSDID($FreeBSD$);
 #include machine/specialreg.h
 #include machine/md_var.h
 
+#ifdef DEV_APIC
 #include x86/apicreg.h
 #include x86/apicvar.h
+#endif
 #ifdef SMP
 #include machine/smp.h
 #include machine/vmparam.h
@@ -271,7 +278,9 @@ acpi_wakeup_machdep(struct acpi_softc *s
initializecpu();
PCPU_SET(switchtime, 0);
PCPU_SET(switchticks, ticks);
+#ifdef DEV_APIC
lapic_xapic_mode();
+#endif
 #ifdef SMP
if (!CPU_EMPTY(suspcpus))
acpi_wakeup_cpus(sc);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r278758 - head/lib/libc/gen

2015-02-14 Thread Tijl Coosemans
Author: tijl
Date: Sat Feb 14 15:14:41 2015
New Revision: 278758
URL: https://svnweb.freebsd.org/changeset/base/278758

Log:
  The ld(1) flag is -Bsymbolic not -Wsymbolic.

Modified:
  head/lib/libc/gen/dlopen.3

Modified: head/lib/libc/gen/dlopen.3
==
--- head/lib/libc/gen/dlopen.3  Sat Feb 14 14:13:00 2015(r278757)
+++ head/lib/libc/gen/dlopen.3  Sat Feb 14 15:14:41 2015(r278758)
@@ -32,7 +32,7 @@
 .\ @(#) dlopen.3 1.6 90/01/31 SMI
 .\ $FreeBSD$
 .\
-.Dd December 21, 2011
+.Dd February 14, 2015
 .Dt DLOPEN 3
 .Os
 .Sh NAME
@@ -236,7 +236,7 @@ as follows, in the given order:
 The referencing object itself (or the object from which the call to
 .Fn dlsym
 is made), if that object was linked using the
-.Fl Wsymbolic
+.Fl Bsymbolic
 option to
 .Xr ld 1 .
 .It
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r278586 - head/contrib/binutils/ld/scripttempl

2015-02-11 Thread Tijl Coosemans
Author: tijl
Date: Wed Feb 11 17:25:23 2015
New Revision: 278586
URL: https://svnweb.freebsd.org/changeset/base/278586

Log:
  Fix ldscripts such that ld(1) collects the .fini_array section in the same
  order as the .init_array section.  Finalisation routines need to be called
  in the opposite order as their corresponding initialisation routines but
  rtld(1) handles that by calling the function pointers in .fini_array in
  reverse order.
  
  Reviewed by:  kib
  MFC after:2 weeks

Modified:
  head/contrib/binutils/ld/scripttempl/elf.sc

Modified: head/contrib/binutils/ld/scripttempl/elf.sc
==
--- head/contrib/binutils/ld/scripttempl/elf.sc Wed Feb 11 17:00:32 2015
(r278585)
+++ head/contrib/binutils/ld/scripttempl/elf.sc Wed Feb 11 17:25:23 2015
(r278586)
@@ -402,8 +402,8 @@ cat EOF
   .fini_array   ${RELOCATING-0} :
   {
 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN 
(${USER_LABEL_PREFIX}__fini_array_start = .);}}
-KEEP (*(.fini_array))
 KEEP (*(SORT(.fini_array.*)))
+KEEP (*(.fini_array))
 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN 
(${USER_LABEL_PREFIX}__fini_array_end = .);}}
   }
   ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r274489 - in head/sys/amd64: amd64 include

2014-11-23 Thread Tijl Coosemans
On Fri, 21 Nov 2014 16:26:47 -0700 Scott Long scott4l...@yahoo.com wrote:
 On Nov 20, 2014, at 11:33 PM, Rui Paulo rpa...@me.com wrote:
 On Nov 13, 2014, at 14:11, Scott Long sco...@freebsd.org wrote:
 
 Author: scottl
 Date: Thu Nov 13 22:11:44 2014
 New Revision: 274489
 URL: https://svnweb.freebsd.org/changeset/base/274489
 
 Log:
 Extend earlier addition of stack frames to most of support.S.  This makes
 stack traces in KDB, HWPMC, and DTrace much more reliable and useful.
 
 No performance differences?  The kernel enables/disables the compiler
 option to omit the frame pointer based on the kernel config file.  If
 DDB, DTrace, or HWPMC is enabled, the frame pointer is always saved in
 C functions.
 
 Some of these functions are in the hot path, so if you didn't see any
 performance problem, I wonder if we should disable -fomit-frame-pointer
 always.
 
 That’s a good question to look further into.  I didn’t see any measurable
 differences with this change.  I think that the cost of the function call
 itself masks the cost of a few extra instructions, but I didn’t test with
 switching it on/off for the entire kernel.  That said, I purposely
 implemented this as macros so it could be easily changed in the future.
 If someone finds that this measurably impacts a certain workload, I
 wouldn’t object to making it conditional, though it does complicate any
 hand-written ASM code that tries to access the stack via %esp offsets.
 We don’t have anything like that now, but Kip was concerned enough about
 it in the future that I left it enabled unconditionally.

An alternative is to annotate the functions with .cfi directives.
Stack unwinding doesn't need frame pointers then.
http://www.logix.cz/michal/devel/gas-cfi/
https://sourceware.org/binutils/docs-2.24/as/CFI-directives.html
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org

Re: svn commit: r274040 - in head/sys: conf dev/agp

2014-11-03 Thread Tijl Coosemans
On Mon, 3 Nov 2014 11:49:36 + (UTC) Konstantin Belousov k...@freebsd.org 
wrote:
 Author: kib
 Date: Mon Nov  3 11:49:35 2014
 New Revision: 274040
 URL: https://svnweb.freebsd.org/changeset/base/274040
 
 Log:
   agp_intel.c provides support for AGP on Intel chipsets from 440/BX to
   875.  This intersects with the agp_i810.c, which supports all Intels
   from i810 to Core i5/7.  Both agp_intel.c and agp_i810.c are compiled
   into kernel when device agp is specified in config, and agp_i810
   attach seems to be selected by chance due to linking order.

I think agp_intel are the plain AGP chipsets while agp_i810 are the
integrated graphics.  None of the device IDs you deleted from agp_intel
appear in agp_i810.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273963 - head/sys/dev/agp

2014-11-02 Thread Tijl Coosemans
Author: tijl
Date: Sun Nov  2 11:26:37 2014
New Revision: 273963
URL: https://svnweb.freebsd.org/changeset/base/273963

Log:
  In agp(4) avoid the need to flush all cpu caches with wbinvd between
  updating the GTT and flushing the AGP TLB by storing the GTT in
  write-combining memory.
  
  On x86 flushing the AGP TLB is done by an I/O operation or a store to a
  MMIO register in uncacheable memory.  Both cases imply that WC buffers are
  flushed so no memory barriers are needed.
  
  On powerpc there is no WC memory type.  It maps to uncacheable memory and
  two stores to uncacheable memory, such as to the GTT and then to an MMIO
  register, are strongly ordered, so no memory barriers are needed either.
  
  MFC after:1 month

Modified:
  head/sys/dev/agp/agp.c
  head/sys/dev/agp/agp_amd.c
  head/sys/dev/agp/agp_amd64.c
  head/sys/dev/agp/agp_apple.c
  head/sys/dev/agp/agp_ati.c
  head/sys/dev/agp/agp_i810.c
  head/sys/dev/agp/agppriv.h

Modified: head/sys/dev/agp/agp.c
==
--- head/sys/dev/agp/agp.c  Sun Nov  2 09:52:22 2014(r273962)
+++ head/sys/dev/agp/agp.c  Sun Nov  2 11:26:37 2014(r273963)
@@ -50,6 +50,8 @@ __FBSDID($FreeBSD$);
 #include dev/pci/pcireg.h
 
 #include vm/vm.h
+#include vm/vm_extern.h
+#include vm/vm_kern.h
 #include vm/vm_param.h
 #include vm/vm_object.h
 #include vm/vm_page.h
@@ -84,14 +86,6 @@ static devclass_t agp_devclass;
 
 /* Helper functions for implementing chipset mini drivers. */
 
-void
-agp_flush_cache()
-{
-#if defined(__i386__) || defined(__amd64__)
-   wbinvd();
-#endif
-}
-
 u_int8_t
 agp_find_caps(device_t dev)
 {
@@ -158,17 +152,16 @@ agp_alloc_gatt(device_t dev)
return 0;
 
gatt-ag_entries = entries;
-   gatt-ag_virtual = contigmalloc(entries * sizeof(u_int32_t), M_AGP, 0,
-   0, ~0, PAGE_SIZE, 0);
+   gatt-ag_virtual = (void *)kmem_alloc_contig(kernel_arena,
+   entries * sizeof(u_int32_t), M_NOWAIT | M_ZERO, 0, ~0, PAGE_SIZE,
+   0, VM_MEMATTR_WRITE_COMBINING);
if (!gatt-ag_virtual) {
if (bootverbose)
device_printf(dev, contiguous allocation failed\n);
free(gatt, M_AGP);
return 0;
}
-   bzero(gatt-ag_virtual, entries * sizeof(u_int32_t));
gatt-ag_physical = vtophys((vm_offset_t) gatt-ag_virtual);
-   agp_flush_cache();
 
return gatt;
 }
@@ -176,8 +169,8 @@ agp_alloc_gatt(device_t dev)
 void
 agp_free_gatt(struct agp_gatt *gatt)
 {
-   contigfree(gatt-ag_virtual,
-  gatt-ag_entries * sizeof(u_int32_t), M_AGP);
+   kmem_free(kernel_arena, (vm_offset_t)gatt-ag_virtual,
+   gatt-ag_entries * sizeof(u_int32_t));
free(gatt, M_AGP);
 }
 
@@ -280,7 +273,6 @@ agp_free_res(device_t dev)
bus_release_resource(dev, SYS_RES_MEMORY, sc-as_aperture_rid,
sc-as_aperture);
mtx_destroy(sc-as_lock);
-   agp_flush_cache();
 }
 
 int
@@ -605,12 +597,6 @@ agp_generic_bind_memory(device_t dev, st
VM_OBJECT_WUNLOCK(mem-am_obj);
 
/*
-* Flush the cpu cache since we are providing a new mapping
-* for these pages.
-*/
-   agp_flush_cache();
-
-   /*
 * Make sure the chipset gets the new mappings.
 */
AGP_FLUSH_TLB(dev);
@@ -668,7 +654,6 @@ agp_generic_unbind_memory(device_t dev, 
}
VM_OBJECT_WUNLOCK(mem-am_obj);

-   agp_flush_cache();
AGP_FLUSH_TLB(dev);
 
mem-am_offset = 0;
@@ -1040,7 +1025,6 @@ agp_bind_pages(device_t dev, vm_page_t *
}
}
 
-   agp_flush_cache();
AGP_FLUSH_TLB(dev);
 
mtx_unlock(sc-as_lock);
@@ -1063,7 +1047,6 @@ agp_unbind_pages(device_t dev, vm_size_t
for (i = 0; i  size; i += AGP_PAGE_SIZE)
AGP_UNBIND_PAGE(dev, offset + i);
 
-   agp_flush_cache();
AGP_FLUSH_TLB(dev);
 
mtx_unlock(sc-as_lock);

Modified: head/sys/dev/agp/agp_amd.c
==
--- head/sys/dev/agp/agp_amd.c  Sun Nov  2 09:52:22 2014(r273962)
+++ head/sys/dev/agp/agp_amd.c  Sun Nov  2 11:26:37 2014(r273963)
@@ -43,6 +43,8 @@ __FBSDID($FreeBSD$);
 #include dev/pci/pcireg.h
 
 #include vm/vm.h
+#include vm/vm_extern.h
+#include vm/vm_kern.h
 #include vm/vm_object.h
 #include vm/pmap.h
 #include machine/bus.h
@@ -92,34 +94,35 @@ agp_amd_alloc_gatt(device_t dev)
 
/*
 * The AMD751 uses a page directory to map a non-contiguous
-* gatt so we don't need to use contigmalloc.
-* Malloc individual gatt pages and map them into the page
+* gatt so we don't need to use kmem_alloc_contig.
+* Allocate individual GATT pages and map them into the page
 * directory.
 */

svn commit: r273964 - head/sys/dev/agp

2014-11-02 Thread Tijl Coosemans
Author: tijl
Date: Sun Nov  2 11:28:15 2014
New Revision: 273964
URL: https://svnweb.freebsd.org/changeset/base/273964

Log:
  In agp_amd_bind_page don't flush the AGP TLB.  It's done by the calling
  function.

Modified:
  head/sys/dev/agp/agp_amd.c

Modified: head/sys/dev/agp/agp_amd.c
==
--- head/sys/dev/agp/agp_amd.c  Sun Nov  2 11:26:37 2014(r273963)
+++ head/sys/dev/agp/agp_amd.c  Sun Nov  2 11:28:15 2014(r273964)
@@ -347,9 +347,6 @@ agp_amd_bind_page(device_t dev, vm_offse
return EINVAL;
 
sc-gatt-ag_virtual[offset  AGP_PAGE_SHIFT] = physical | 1;
-
-   /* invalidate the cache */
-   AGP_FLUSH_TLB(dev);
return 0;
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273965 - head/sys/dev/agp

2014-11-02 Thread Tijl Coosemans
Author: tijl
Date: Sun Nov  2 11:47:40 2014
New Revision: 273965
URL: https://svnweb.freebsd.org/changeset/base/273965

Log:
  - agp_generic_unbind_memory: flush AGP TLB before unwiring pages
  - agp_bind_pages: assert that pages have been wired down
  
  MFC after:1 month

Modified:
  head/sys/dev/agp/agp.c

Modified: head/sys/dev/agp/agp.c
==
--- head/sys/dev/agp/agp.c  Sun Nov  2 11:28:15 2014(r273964)
+++ head/sys/dev/agp/agp.c  Sun Nov  2 11:47:40 2014(r273965)
@@ -645,6 +645,9 @@ agp_generic_unbind_memory(device_t dev, 
 */
for (i = 0; i  mem-am_size; i += AGP_PAGE_SIZE)
AGP_UNBIND_PAGE(dev, mem-am_offset + i);
+
+   AGP_FLUSH_TLB(dev);
+
VM_OBJECT_WLOCK(mem-am_obj);
for (i = 0; i  mem-am_size; i += PAGE_SIZE) {
m = vm_page_lookup(mem-am_obj, atop(i));
@@ -653,8 +656,6 @@ agp_generic_unbind_memory(device_t dev, 
vm_page_unlock(m);
}
VM_OBJECT_WUNLOCK(mem-am_obj);
-   
-   AGP_FLUSH_TLB(dev);
 
mem-am_offset = 0;
mem-am_is_bound = 0;
@@ -1000,6 +1001,8 @@ agp_bind_pages(device_t dev, vm_page_t *
mtx_lock(sc-as_lock);
for (i = 0; i  size; i += PAGE_SIZE) {
m = pages[OFF_TO_IDX(i)];
+   KASSERT(m-wire_count  0,
+   (agp_bind_pages: page %p hasn't been wired, m));
 
/*
 * Install entries in the GATT, making sure that if
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273969 - head/sys/dev/drm2/ttm

2014-11-02 Thread Tijl Coosemans
Author: tijl
Date: Sun Nov  2 14:08:54 2014
New Revision: 273969
URL: https://svnweb.freebsd.org/changeset/base/273969

Log:
  Use default memory type for TTM buffer objects that may be cached.
  
  MFC after:1 week

Modified:
  head/sys/dev/drm2/ttm/ttm_bo_util.c

Modified: head/sys/dev/drm2/ttm/ttm_bo_util.c
==
--- head/sys/dev/drm2/ttm/ttm_bo_util.c Sun Nov  2 13:43:04 2014
(r273968)
+++ head/sys/dev/drm2/ttm/ttm_bo_util.c Sun Nov  2 14:08:54 2014
(r273969)
@@ -508,8 +508,7 @@ static int ttm_bo_kmap_ttm(struct ttm_bu
 * or to make the buffer object look contiguous.
 */
prot = (mem-placement  TTM_PL_FLAG_CACHED) ?
-   VM_MEMATTR_WRITE_COMBINING :
-   ttm_io_prot(mem-placement);
+   VM_MEMATTR_DEFAULT : ttm_io_prot(mem-placement);
map-bo_kmap_type = ttm_bo_map_vmap;
map-num_pages = num_pages;
map-virtual = (void *)kva_alloc(num_pages * PAGE_SIZE);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r273963 - head/sys/dev/agp

2014-11-02 Thread Tijl Coosemans
On Sun, 02 Nov 2014 07:27:24 -0800 Nathan Whitehorn nwhiteh...@freebsd.org 
wrote:
 There is actually a write-combining memory type on PowerPC. You can set 
 it the same way as on x86 (with VM_MEMATTR_WRITE_COMBINING).

Yes, that's what the patch does, but in sys/powerpc (aim/mmu_oea.c,
aim/mmu_oea64.c and booke/pmap.c) VM_MEMATTR_WRITE_COMBINING becomes
PTE_I meaning Caching Inhibited.  Does powerpc do write-combining for
this type?

That code also maps VM_MEMATTR_WRITE_BACK to PTE_I by the way.  I think
that should be PTE_M (write-back caching + cache coherency).
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273902 - head/sys/modules/drm2/drm2

2014-10-31 Thread Tijl Coosemans
Author: tijl
Date: Fri Oct 31 10:45:34 2014
New Revision: 273902
URL: https://svnweb.freebsd.org/changeset/base/273902

Log:
  Build ttm_agp_backend.c.
  
  Reported by:  dumbbell
  MFC after:1 month

Modified:
  head/sys/modules/drm2/drm2/Makefile

Modified: head/sys/modules/drm2/drm2/Makefile
==
--- head/sys/modules/drm2/drm2/Makefile Fri Oct 31 10:35:01 2014
(r273901)
+++ head/sys/modules/drm2/drm2/Makefile Fri Oct 31 10:45:34 2014
(r273902)
@@ -35,6 +35,7 @@ SRCS  = \
drm_stub.c \
drm_sysctl.c \
drm_vm.c \
+   ttm_agp_backend.c \
ttm_lock.c \
ttm_object.c \
ttm_tt.c \
@@ -46,7 +47,6 @@ SRCS  = \
ttm_page_alloc.c \
ttm_bo_vm.c \
ati_pcigart.c
-#ttm_agp_backend.c
 #ttm_page_alloc_dma.c
 
 .if ${MACHINE_CPUARCH} == amd64
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273856 - head/sys/dev/agp

2014-10-30 Thread Tijl Coosemans
Author: tijl
Date: Thu Oct 30 11:27:03 2014
New Revision: 273856
URL: https://svnweb.freebsd.org/changeset/base/273856

Log:
  Add two new functions to the AGP driver KPI to bind/unbind arbitrary sets
  of pages into the GTT.
  
  Reviewed by:  kib
  MFC after:1 month

Modified:
  head/sys/dev/agp/agp.c
  head/sys/dev/agp/agpvar.h

Modified: head/sys/dev/agp/agp.c
==
--- head/sys/dev/agp/agp.c  Thu Oct 30 10:59:57 2014(r273855)
+++ head/sys/dev/agp/agp.c  Thu Oct 30 11:27:03 2014(r273856)
@@ -996,3 +996,76 @@ void agp_memory_info(device_t dev, void 
mi-ami_offset = mem-am_offset;
mi-ami_is_bound = mem-am_is_bound;
 }
+
+int
+agp_bind_pages(device_t dev, vm_page_t *pages, vm_size_t size,
+vm_offset_t offset)
+{
+   struct agp_softc *sc;
+   vm_offset_t i, j, k, pa;
+   vm_page_t m;
+   int error;
+
+   if ((size  (AGP_PAGE_SIZE - 1)) != 0 ||
+   (offset  (AGP_PAGE_SIZE - 1)) != 0)
+   return (EINVAL);
+
+   sc = device_get_softc(dev);
+
+   mtx_lock(sc-as_lock);
+   for (i = 0; i  size; i += PAGE_SIZE) {
+   m = pages[OFF_TO_IDX(i)];
+
+   /*
+* Install entries in the GATT, making sure that if
+* AGP_PAGE_SIZE  PAGE_SIZE and size is not
+* aligned to PAGE_SIZE, we don't modify too many GATT 
+* entries.
+*/
+   for (j = 0; j  PAGE_SIZE  i + j  size; j += AGP_PAGE_SIZE) {
+   pa = VM_PAGE_TO_PHYS(m) + j;
+   AGP_DPF(binding offset %#jx to pa %#jx\n,
+   (uintmax_t)offset + i + j, (uintmax_t)pa);
+   error = AGP_BIND_PAGE(dev, offset + i + j, pa);
+   if (error) {
+   /*
+* Bail out. Reverse all the mappings.
+*/
+   for (k = 0; k  i + j; k += AGP_PAGE_SIZE)
+   AGP_UNBIND_PAGE(dev, offset + k);
+
+   mtx_unlock(sc-as_lock);
+   return (error);
+   }
+   }
+   }
+
+   agp_flush_cache();
+   AGP_FLUSH_TLB(dev);
+
+   mtx_unlock(sc-as_lock);
+   return (0);
+}
+
+int
+agp_unbind_pages(device_t dev, vm_size_t size, vm_offset_t offset)
+{
+   struct agp_softc *sc;
+   vm_offset_t i;
+
+   if ((size  (AGP_PAGE_SIZE - 1)) != 0 ||
+   (offset  (AGP_PAGE_SIZE - 1)) != 0)
+   return (EINVAL);
+
+   sc = device_get_softc(dev);
+
+   mtx_lock(sc-as_lock);
+   for (i = 0; i  size; i += AGP_PAGE_SIZE)
+   AGP_UNBIND_PAGE(dev, offset + i);
+
+   agp_flush_cache();
+   AGP_FLUSH_TLB(dev);
+
+   mtx_unlock(sc-as_lock);
+   return (0);
+}

Modified: head/sys/dev/agp/agpvar.h
==
--- head/sys/dev/agp/agpvar.h   Thu Oct 30 10:59:57 2014(r273855)
+++ head/sys/dev/agp/agpvar.h   Thu Oct 30 11:27:03 2014(r273856)
@@ -122,6 +122,19 @@ int agp_unbind_memory(device_t dev, void
  */
 void agp_memory_info(device_t dev, void *handle, struct agp_memory_info *mi);
 
+/*
+ * Bind a set of pages at a given offset within the AGP aperture.
+ * Returns EINVAL if the given size or offset is not at an AGP page boundary.
+ */
+int agp_bind_pages(device_t dev, vm_page_t *pages, vm_size_t size,
+  vm_offset_t offset);
+
+/*
+ * Unbind a set of pages from the AGP aperture.
+ * Returns EINVAL if the given size or offset is not at an AGP page boundary.
+ */
+int agp_unbind_pages(device_t dev, vm_size_t size, vm_offset_t offset);
+
 #define AGP_NORMAL_MEMORY 0
 
 #define AGP_USER_TYPES (1  16)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273862 - in head/sys/dev/drm2: . radeon ttm

2014-10-30 Thread Tijl Coosemans
Author: tijl
Date: Thu Oct 30 14:26:36 2014
New Revision: 273862
URL: https://svnweb.freebsd.org/changeset/base/273862

Log:
  Port the TTM AGP backend to the FreeBSD agp driver and enable AGP support
  in the radeonkms driver.
  
  Note: In PCI mode virtual addresses on the graphics card that map to system
  RAM are translated to physical addresses by the graphics card itself.   In
  AGP mode address translation is done by the AGP chipset so fictitious
  addresses appear on the system bus.  For the CPU cache management to work
  correctly when the CPU accesses this memory it needs to use the same
  fictitious addresses (and let the chipset translate them) instead of using
  the physical addresses directly.
  
  Reviewed by:  kib
  MFC after:1 month

Modified:
  head/sys/dev/drm2/drm_agpsupport.c
  head/sys/dev/drm2/radeon/radeon.h
  head/sys/dev/drm2/radeon/radeon_device.c
  head/sys/dev/drm2/radeon/radeon_ttm.c
  head/sys/dev/drm2/ttm/ttm_agp_backend.c
  head/sys/dev/drm2/ttm/ttm_bo_driver.h
  head/sys/dev/drm2/ttm/ttm_page_alloc.c

Modified: head/sys/dev/drm2/drm_agpsupport.c
==
--- head/sys/dev/drm2/drm_agpsupport.c  Thu Oct 30 14:05:48 2014
(r273861)
+++ head/sys/dev/drm2/drm_agpsupport.c  Thu Oct 30 14:26:36 2014
(r273862)
@@ -396,7 +396,7 @@ void *drm_agp_allocate_memory(size_t pag
if (!agpdev)
return NULL;
 
-   return agp_alloc_memory(agpdev, type, pages  AGP_PAGE_SHIFT);
+   return agp_alloc_memory(agpdev, type, pages  PAGE_SHIFT);
 }
 
 int drm_agp_free_memory(void *handle)

Modified: head/sys/dev/drm2/radeon/radeon.h
==
--- head/sys/dev/drm2/radeon/radeon.h   Thu Oct 30 14:05:48 2014
(r273861)
+++ head/sys/dev/drm2/radeon/radeon.h   Thu Oct 30 14:26:36 2014
(r273862)
@@ -1618,6 +1618,7 @@ struct radeon_device {
boolneed_dma32;
boolaccel_working;
boolfictitious_range_registered;
+   boolfictitious_agp_range_registered;
struct radeon_surface_reg surface_regs[RADEON_GEM_MAX_SURFACES];
const struct firmware *me_fw;   /* all family ME firmware */
const struct firmware *pfp_fw;  /* r6/700 PFP firmware */

Modified: head/sys/dev/drm2/radeon/radeon_device.c
==
--- head/sys/dev/drm2/radeon/radeon_device.cThu Oct 30 14:05:48 2014
(r273861)
+++ head/sys/dev/drm2/radeon/radeon_device.cThu Oct 30 14:26:36 2014
(r273862)
@@ -1014,6 +1014,7 @@ int radeon_device_init(struct radeon_dev
rdev-mc.gtt_size = radeon_gart_size * 1024 * 1024;
rdev-accel_working = false;
rdev-fictitious_range_registered = false;
+   rdev-fictitious_agp_range_registered = false;
/* set up ring ids */
for (i = 0; i  RADEON_NUM_RINGS; i++) {
rdev-ring[i].idx = i;
@@ -1168,6 +1169,24 @@ int radeon_device_init(struct radeon_dev
return (-r);
}
rdev-fictitious_range_registered = true;
+#if __OS_HAS_AGP
+   if (rdev-flags  RADEON_IS_AGP) {
+   DRM_INFO(%s: Taking over the fictitious range 0x%jx-0x%jx\n,
+   __func__, (uintmax_t)rdev-mc.agp_base,
+   (uintmax_t)rdev-mc.agp_base + rdev-mc.gtt_size);
+   r = vm_phys_fictitious_reg_range(
+   rdev-mc.agp_base,
+   rdev-mc.agp_base + rdev-mc.gtt_size,
+   VM_MEMATTR_WRITE_COMBINING);
+   if (r != 0) {
+   DRM_ERROR(Failed to register fictitious range 
+   0x%jx-0x%jx (%d).\n, (uintmax_t)rdev-mc.agp_base,
+   (uintmax_t)rdev-mc.agp_base + rdev-mc.gtt_size, 
r);
+   return (-r);
+   }
+   rdev-fictitious_agp_range_registered = true;
+   }
+#endif
 
if ((radeon_testing  1)) {
radeon_test_moves(rdev);
@@ -1205,6 +1224,13 @@ void radeon_device_fini(struct radeon_de
rdev-mc.aper_base,
rdev-mc.aper_base + rdev-mc.visible_vram_size);
}
+#if __OS_HAS_AGP
+   if (rdev-fictitious_agp_range_registered) {
+   vm_phys_fictitious_unreg_range(
+   rdev-mc.agp_base,
+   rdev-mc.agp_base + rdev-mc.gtt_size);
+   }
+#endif
 
radeon_fini(rdev);
 #ifdef DUMBBELL_WIP

Modified: head/sys/dev/drm2/radeon/radeon_ttm.c
==
--- head/sys/dev/drm2/radeon/radeon_ttm.c   Thu Oct 30 14:05:48 2014
(r273861)
+++ head/sys/dev/drm2/radeon/radeon_ttm.c   Thu Oct 30 14:26:36 2014
(r273862)
@@ -560,12 +560,10 @@ 

svn commit: r273863 - head/sys/dev/agp

2014-10-30 Thread Tijl Coosemans
Author: tijl
Date: Thu Oct 30 14:36:27 2014
New Revision: 273863
URL: https://svnweb.freebsd.org/changeset/base/273863

Log:
  Avoid possible overflow in agp_generic_alloc_memory.
  
  MFC after:1 week

Modified:
  head/sys/dev/agp/agp.c

Modified: head/sys/dev/agp/agp.c
==
--- head/sys/dev/agp/agp.c  Thu Oct 30 14:26:36 2014(r273862)
+++ head/sys/dev/agp/agp.c  Thu Oct 30 14:36:27 2014(r273863)
@@ -485,7 +485,7 @@ agp_generic_alloc_memory(device_t dev, i
if ((size  (AGP_PAGE_SIZE - 1)) != 0)
return 0;
 
-   if (sc-as_allocated + size  sc-as_maxmem)
+   if (size  sc-as_maxmem - sc-as_allocated)
return 0;
 
if (type != 0) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r270757 - head/contrib/binutils/ld/emultempl

2014-08-28 Thread Tijl Coosemans
Author: tijl
Date: Thu Aug 28 18:33:42 2014
New Revision: 270757
URL: http://svnweb.freebsd.org/changeset/base/270757

Log:
  In r253839 the default behaviour of ld(1) was changed such that all
  libraries that need to be linked into an executable or library have to be
  listed on the command line explicitly.  This commit fixes a bug in ld(1)
  where it would scan dependencies of the libraries on the command line and
  link them if needed if they were also found in ld.so.cache.
  
  The important bit of the patch is the initialisation of needed.by such that
  libraries found by scanning dependencies are marked as such and not used in
  the link.
  
  The patch is a backport of binutils git commit
  d5c8b1f8561426b41aa5330ed60f578178fe6be2
  
  The author gave permission to use it under GPLv2 terms.
  
  PR:   192062
  Exp-run by:   antoine
  MFC after:1 week

Modified:
  head/contrib/binutils/ld/emultempl/elf32.em

Modified: head/contrib/binutils/ld/emultempl/elf32.em
==
--- head/contrib/binutils/ld/emultempl/elf32.em Thu Aug 28 18:11:05 2014
(r270756)
+++ head/contrib/binutils/ld/emultempl/elf32.em Thu Aug 28 18:33:42 2014
(r270757)
@@ -541,7 +541,8 @@ EOF
 #endif
 
 static bfd_boolean
-gld${EMULATION_NAME}_check_ld_elf_hints (const char *name, int force)
+gld${EMULATION_NAME}_check_ld_elf_hints (const struct bfd_link_needed_list *l,
+int force)
 {
   static bfd_boolean initialized;
   static char *ld_elf_hints;
@@ -584,10 +585,9 @@ gld${EMULATION_NAME}_check_ld_elf_hints 
   if (ld_elf_hints == NULL)
 return FALSE;
 
-  needed.by = NULL;
-  needed.name = name;
-  return gld${EMULATION_NAME}_search_needed (ld_elf_hints,  needed,
-force);
+  needed.by = l-by;
+  needed.name = l-name;
+  return gld${EMULATION_NAME}_search_needed (ld_elf_hints, needed, force);
 }
 EOF
 # FreeBSD
@@ -759,7 +759,8 @@ gld${EMULATION_NAME}_parse_ld_so_conf
 }
 
 static bfd_boolean
-gld${EMULATION_NAME}_check_ld_so_conf (const char *name, int force)
+gld${EMULATION_NAME}_check_ld_so_conf (const struct bfd_link_needed_list *l,
+  int force)
 {
   static bfd_boolean initialized;
   static char *ld_so_conf;
@@ -794,8 +795,8 @@ gld${EMULATION_NAME}_check_ld_so_conf (c
 return FALSE;
 
 
-  needed.by = NULL;
-  needed.name = name;
+  needed.by = l-by;
+  needed.name = l-name;
   return gld${EMULATION_NAME}_search_needed (ld_so_conf, needed, force);
 }
 
@@ -1037,7 +1038,7 @@ if [ x${USE_LIBPATH} = xyes ] ; then
   case ${target} in
 *-*-freebsd* | *-*-dragonfly*)
   cat e${EMULATION_NAME}.c EOF
- if (gld${EMULATION_NAME}_check_ld_elf_hints (l-name, force))
+ if (gld${EMULATION_NAME}_check_ld_elf_hints (l, force))
break;
 EOF
 # FreeBSD
@@ -1046,7 +1047,7 @@ EOF
 *-*-linux-* | *-*-k*bsd*-*)
 # Linux
   cat e${EMULATION_NAME}.c EOF
- if (gld${EMULATION_NAME}_check_ld_so_conf (l-name, force))
+ if (gld${EMULATION_NAME}_check_ld_so_conf (l, force))
break;
 
 EOF
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r270516 - head/sys/dev/drm2/i915

2014-08-25 Thread Tijl Coosemans
On Mon, 25 Aug 2014 19:11:43 +0200 Jean-Sébastien Pédron dumbb...@freebsd.org 
wrote:
 On 25.08.2014 19:04, Nathan Whitehorn wrote:
 Does our radeon KMS code support AGP-based Radeons? I vaguely remember
 this not being the case.
 
 Unfortunately no, AGP isn't supported. And I currently don't have 
 neither the knowledge nor the hardware to add this. Furthermore, it 
 would be a lower priority compared to more urgent topics in the graphics 
 stack.

It's not that they don't work.  They fall back to PCI mode.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r269950 - head/share/vt/keymaps

2014-08-14 Thread Tijl Coosemans
On Wed, 13 Aug 2014 19:06:30 + (UTC) Ed Maste wrote:
 Author: emaste
 Date: Wed Aug 13 19:06:29 2014
 New Revision: 269950
 URL: http://svnweb.freebsd.org/changeset/base/269950
 
 Log:
   Copy country-code .iso syscons keymaps for vt(4)
   
   Existing syscons ISO 8859-1 keymaps (??.iso.kbd) are usable without
   change as Unicode keymaps for vt(4).

On European layouts the alt+e 164 is iso-8859-15 € and not iso-8859-1 ¤
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org

Re: svn commit: r269973 - head/share/vt/keymaps

2014-08-14 Thread Tijl Coosemans
On Thu, 14 Aug 2014 13:45:03 + (UTC) Ed Maste wrote:
 Modified: head/share/vt/keymaps/hr.kbd
 ==
 --- head/share/vt/keymaps/hr.kbd  Thu Aug 14 13:25:05 2014
 (r269972)
 +++ head/share/vt/keymaps/hr.kbd  Thu Aug 14 13:45:02 2014
 (r269973)
 @@ -48,7 +48,7 @@
040   230198nopnop223223nopnop C
041   184168nopnop184168nopnop O
042   lshift lshift lshift lshift lshift lshift lshift lshift  O
 -  043   190174fs fs 164164fs fs  C
 +  043   190174fs fs 8364   8364   fs fs  C

This was correct I think.  See:
http://commons.wikimedia.org/wiki/File:Croatian_keyboard_layout.jpg

But both hr.kbd and si.kbd are iso-8859-2 or iso-8859-16 so they need
other conversions (e.g. 163 is Ł).
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org

Re: svn commit: r268619 - head/usr.bin/users

2014-07-14 Thread Tijl Coosemans
On Mon, 14 Jul 2014 12:24:38 + (UTC) Pietro Cerutti wrote:
 Author: gahr (ports committer)
 Date: Mon Jul 14 12:24:38 2014
 New Revision: 268619
 URL: http://svnweb.freebsd.org/changeset/base/268619
 
 Log:
   Unbreak the build by re-enabling exceptions.
   
   Disabling them breaks build on archs using GCC. The problem is at line 156 
 of
   bits/basic_ios.h:
   
   if (this-exceptions()  __state)
   __throw_exception_again;
   
   With exceptions disabled __throw_exception_again is defined as
   
   #define __throw_exception_again
   
   at line 45 of exception_defines.h and the code results in an empty loop 
 body,
   which fails because of -Werror.

Maybe define it as ((void)0) instead?
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r267441 - in head: include tools/build/mk

2014-06-14 Thread Tijl Coosemans
On Fri, 13 Jun 2014 10:43:28 -0400 Benjamin Kaduk wrote:
 On Fri, Jun 13, 2014 at 6:08 AM, Tijl Coosemans t...@freebsd.org wrote:
 Author: tijl
 Date: Fri Jun 13 10:08:18 2014
 New Revision: 267441
 URL: http://svnweb.freebsd.org/changeset/base/267441

 Log:
   Don't install GSS-API headers when the GSSAPI option has been disabled.
   Some ports assume GSS-API is supported when they find the headers.
 
 I am somewhat surprised that MK_GSSAPI=no does not disable the installation
 of gssapi_krb5.h as well, which currently is controlled by MK_KERBEROS.
  Does the infrastructure require that we pick one or the other, or could we
 make it such that disabling either one disables the gssapi_krb5
 functionality?

The GSSAPI option controls the compilation of lib/libgssapi and
gssapi_krb5.h belongs to a different library under kerberos/.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r267436 - head/lib/libiconv_modules/HZ

2014-06-13 Thread Tijl Coosemans
Author: tijl
Date: Fri Jun 13 08:26:53 2014
New Revision: 267436
URL: http://svnweb.freebsd.org/changeset/base/267436

Log:
  Replace malloc+memset with calloc.

Modified:
  head/lib/libiconv_modules/HZ/citrus_hz.c

Modified: head/lib/libiconv_modules/HZ/citrus_hz.c
==
--- head/lib/libiconv_modules/HZ/citrus_hz.cFri Jun 13 07:33:43 2014
(r267435)
+++ head/lib/libiconv_modules/HZ/citrus_hz.cFri Jun 13 08:26:53 2014
(r267436)
@@ -532,10 +532,9 @@ _citrus_HZ_parse_graphic(void *context, 
p = (void **)context;
escape = (escape_t *)p[0];
ei = (_HZEncodingInfo *)p[1];
-   graphic = malloc(sizeof(*graphic));
+   graphic = calloc(1, sizeof(*graphic));
if (graphic == NULL)
return (ENOMEM);
-   memset(graphic, 0, sizeof(*graphic));
if (strcmp(GL, name) == 0) {
if (GL(escape) != NULL)
goto release;
@@ -598,10 +597,9 @@ _citrus_HZ_parse_escape(void *context, c
void *p[2];
 
ei = (_HZEncodingInfo *)context;
-   escape = malloc(sizeof(*escape));
+   escape = calloc(1, sizeof(*escape));
if (escape == NULL)
return (EINVAL);
-   memset(escape, 0, sizeof(*escape));
if (strcmp(0, name) == 0) {
escape-set = E0SET(ei);
TAILQ_INSERT_TAIL(E0SET(ei), escape, entry);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r267437 - head/lib/libc/iconv

2014-06-13 Thread Tijl Coosemans
Author: tijl
Date: Fri Jun 13 08:28:51 2014
New Revision: 267437
URL: http://svnweb.freebsd.org/changeset/base/267437

Log:
  Replace malloc+memset with calloc.

Modified:
  head/lib/libc/iconv/citrus_db_factory.c
  head/lib/libc/iconv/citrus_iconv.c

Modified: head/lib/libc/iconv/citrus_db_factory.c
==
--- head/lib/libc/iconv/citrus_db_factory.c Fri Jun 13 08:26:53 2014
(r267436)
+++ head/lib/libc/iconv/citrus_db_factory.c Fri Jun 13 08:28:51 2014
(r267437)
@@ -270,11 +270,9 @@ _citrus_db_factory_serialize(struct _cit
return (0);
}
/* allocate hash table */
-   depp = malloc(sizeof(*depp) * df-df_num_entries);
+   depp = calloc(df-df_num_entries, sizeof(*depp));
if (depp == NULL)
return (-1);
-   for (i = 0; i  df-df_num_entries; i++)
-   depp[i] = NULL;
 
/* step1: store the entries which are not conflicting */
STAILQ_FOREACH(de, df-df_entries, de_entry) {

Modified: head/lib/libc/iconv/citrus_iconv.c
==
--- head/lib/libc/iconv/citrus_iconv.c  Fri Jun 13 08:26:53 2014
(r267436)
+++ head/lib/libc/iconv/citrus_iconv.c  Fri Jun 13 08:28:51 2014
(r267437)
@@ -344,9 +344,8 @@ const char
 {
char *buf;
 
-   if ((buf = malloc((size_t)PATH_MAX)) == NULL)
+   if ((buf = calloc((size_t)PATH_MAX, sizeof(*buf))) == NULL)
return (NULL);
-   memset((void *)buf, 0, (size_t)PATH_MAX);
_citrus_esdb_alias(name, buf, (size_t)PATH_MAX);
return (buf);
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r267438 - head/lib/libc/iconv

2014-06-13 Thread Tijl Coosemans
Author: tijl
Date: Fri Jun 13 08:36:10 2014
New Revision: 267438
URL: http://svnweb.freebsd.org/changeset/base/267438

Log:
  iconv_open: initialise ci_ilseq_invalid field of _citrus_iconv_shared
  struct after allocation with malloc.
  
  iconvlist: reduce a memory leak by copying strings only once.

Modified:
  head/lib/libc/iconv/bsd_iconv.c

Modified: head/lib/libc/iconv/bsd_iconv.c
==
--- head/lib/libc/iconv/bsd_iconv.c Fri Jun 13 08:28:51 2014
(r267437)
+++ head/lib/libc/iconv/bsd_iconv.c Fri Jun 13 08:36:10 2014
(r267438)
@@ -83,6 +83,7 @@ __bsd___iconv_open(const char *out, cons
}
 
handle-cv_shared-ci_discard_ilseq = strcasestr(out, //IGNORE);
+   handle-cv_shared-ci_ilseq_invalid = false;
handle-cv_shared-ci_hooks = NULL;
 
return ((iconv_t)(void *)handle);
@@ -223,7 +224,7 @@ __bsd_iconvlist(int (*do_one) (unsigned 
return;
}
strlcpy(curkey, list[i], slashpos - list[i] + 1);
-   names[j++] = strdup(curkey);
+   names[j++] = curkey;
for (; (i  sz)  (memcmp(curkey, list[i], strlen(curkey)) == 
0); i++) {
slashpos = strchr(list[i], '/');
curitem = (char *)malloc(strlen(slashpos) + 1);
@@ -235,7 +236,7 @@ __bsd_iconvlist(int (*do_one) (unsigned 
if (strcmp(curkey, curitem) == 0) {
continue;
}
-   names[j++] = strdup(curitem);
+   names[j++] = curitem;
}
np = (const char * const *)names;
do_one(j, np, data);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r267439 - head/usr.bin/iconv

2014-06-13 Thread Tijl Coosemans
Author: tijl
Date: Fri Jun 13 08:44:03 2014
New Revision: 267439
URL: http://svnweb.freebsd.org/changeset/base/267439

Log:
  - Make invalids variable local to do_conv such that it prints the number
of invalid characters of the current file instead of an accumulated
value.
  - Make do_conv return an error when invalid characters have been found.
Return EXIT_FAILURE from main if any file contained invalid characters.
This matches the behaviour of GNU iconv.
  - Mark usage with __dead2 attribute.
  - Make the long_options array const.

Modified:
  head/usr.bin/iconv/iconv.c

Modified: head/usr.bin/iconv/iconv.c
==
--- head/usr.bin/iconv/iconv.c  Fri Jun 13 08:36:10 2014(r267438)
+++ head/usr.bin/iconv/iconv.c  Fri Jun 13 08:44:03 2014(r267439)
@@ -41,13 +41,11 @@
 #include string.h
 #include unistd.h
 
-static unsigned long long invalids;
+static int do_conv(FILE *, const char *, const char *, bool, bool);
+static int do_list(unsigned int, const char * const *, void *);
+static voidusage(void) __dead2;
 
-static void do_conv(FILE *, const char *, const char *, bool, 
bool);
-static int  do_list(unsigned int, const char * const *, void *);
-static void usage(void);
-
-static struct option long_options[] = {
+static const struct option long_options[] = {
{from-code,   required_argument,  NULL, 'f'},
{list,no_argument,NULL, 'l'},
{silent,  no_argument,NULL, 's'},
@@ -68,12 +66,13 @@ usage(void)
 
 #define INBUFSIZE 1024
 #define OUTBUFSIZE (INBUFSIZE * 2)
-static void
+static int
 do_conv(FILE *fp, const char *from, const char *to, bool silent,
 bool hide_invalid)
 {
iconv_t cd;
char inbuf[INBUFSIZE], outbuf[OUTBUFSIZE], *out;
+   unsigned long long invalids;
const char *in;
size_t inbytes, outbytes, ret;
 
@@ -84,8 +83,9 @@ do_conv(FILE *fp, const char *from, cons
int arg = 1;
 
if (iconvctl(cd, ICONV_SET_DISCARD_ILSEQ, (void *)arg) == -1)
-   err(1, NULL);
+   err(EXIT_FAILURE, NULL);
}
+   invalids = 0;
while ((inbytes = fread(inbuf, 1, INBUFSIZE, fp))  0) {
in = inbuf;
while (inbytes  0) {
@@ -135,6 +135,7 @@ do_conv(FILE *fp, const char *from, cons
warnx(warning: invalid characters: %llu, invalids);
 
iconv_close(cd);
+   return (invalids  0);
 }
 
 static int
@@ -157,7 +158,7 @@ main(int argc, char **argv)
 {
FILE *fp;
char *opt_f, *opt_t;
-   int ch, i;
+   int ch, i, res;
bool opt_c = false, opt_s = false;
 
opt_f = opt_t = strdup();
@@ -202,18 +203,18 @@ main(int argc, char **argv)
if ((strcmp(opt_f, ) == 0)  (strcmp(opt_t, ) == 0))
usage();
if (argc == 0)
-   do_conv(stdin, opt_f, opt_t, opt_s, opt_c);
+   res = do_conv(stdin, opt_f, opt_t, opt_s, opt_c);
else {
+   res = 0;
for (i = 0; i  argc; i++) {
fp = (strcmp(argv[i], -) != 0) ?
fopen(argv[i], r) : stdin;
if (fp == NULL)
err(EXIT_FAILURE, Cannot open `%s',
argv[i]);
-   do_conv(fp, opt_f, opt_t, opt_s,
-   opt_c);
+   res |= do_conv(fp, opt_f, opt_t, opt_s, opt_c);
(void)fclose(fp);
}
}
-   return (EXIT_SUCCESS);
+   return (res == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r267441 - in head: include tools/build/mk

2014-06-13 Thread Tijl Coosemans
Author: tijl
Date: Fri Jun 13 10:08:18 2014
New Revision: 267441
URL: http://svnweb.freebsd.org/changeset/base/267441

Log:
  Don't install GSS-API headers when the GSSAPI option has been disabled.
  Some ports assume GSS-API is supported when they find the headers.
  
  PR:   189156
  Submitted by: Garrett Cooper yaneg...@gmail.com

Modified:
  head/include/Makefile
  head/tools/build/mk/OptionalObsoleteFiles.inc

Modified: head/include/Makefile
==
--- head/include/Makefile   Fri Jun 13 08:53:49 2014(r267440)
+++ head/include/Makefile   Fri Jun 13 10:08:18 2014(r267441)
@@ -6,11 +6,11 @@
 .include src.opts.mk
 
 CLEANFILES= osreldate.h version vers.c
-SUBDIR= arpa gssapi protocols rpcsvc rpc xlocale
+SUBDIR= arpa protocols rpcsvc rpc xlocale
 INCS=  a.out.h ar.h assert.h bitstring.h complex.h cpio.h _ctype.h ctype.h \
db.h \
dirent.h dlfcn.h elf.h elf-hints.h err.h fmtmsg.h fnmatch.h fstab.h \
-   fts.h ftw.h getopt.h glob.h grp.h gssapi.h \
+   fts.h ftw.h getopt.h glob.h grp.h \
ieeefp.h ifaddrs.h \
inttypes.h iso646.h kenv.h langinfo.h libgen.h limits.h link.h \
locale.h malloc.h malloc_np.h memory.h monetary.h mpool.h mqueue.h \
@@ -67,6 +67,11 @@ _dev_powermac_nvram= dev/powermac_nvram
 _dev_ieee488=  dev/ieee488
 .endif
 
+.if ${MK_GSSAPI} != no
+SUBDIR+=   gssapi
+INCS+= gssapi.h
+.endif
+
 .if ${MK_HESIOD} != no
 INCS+= hesiod.h
 .endif

Modified: head/tools/build/mk/OptionalObsoleteFiles.inc
==
--- head/tools/build/mk/OptionalObsoleteFiles.inc   Fri Jun 13 08:53:49 
2014(r267440)
+++ head/tools/build/mk/OptionalObsoleteFiles.inc   Fri Jun 13 10:08:18 
2014(r267441)
@@ -1833,6 +1833,9 @@ OLD_DIRS+=usr/share/tmac
 .endif
 
 .if ${MK_GSSAPI} == no
+OLD_FILES+=usr/include/gssapi/gssapi.h
+OLD_DIRS+=usr/include/gssapi
+OLD_FILES+=usr/include/gssapi.h
 OLD_FILES+=usr/lib/libgssapi.a
 OLD_FILES+=usr/lib/libgssapi.so
 OLD_LIBS+=usr/lib/libgssapi.so.10
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r266553 - head/release/scripts

2014-05-28 Thread Tijl Coosemans
On Tue, 27 May 2014 14:31:44 -0600 Warner Losh wrote:
 On May 27, 2014, at 1:40 PM, Tijl Coosemans t...@freebsd.org wrote:
 On Tue, 27 May 2014 07:18:06 -0600 Warner Losh wrote:
 On May 27, 2014, at 1:36 AM, Tijl Coosemans t...@freebsd.org wrote:
 On Mon, 26 May 2014 16:31:21 -0600 Warner Losh wrote:
 So I?m still waiting for a use case that requires the new names. One has
 not been articulated, and I don?t think one actually exists.
 
 Imagine you've built a system with MACHINE_ARCH amd64 and one with
 MACHINE_ARCH mips64.  Now you want to populate these systems with a list
 of packages for which you wrote a script.  These systems each support 2
 ABIs: a native 64-bit one (amd64 and mips64) and a native 32-bit one (x32
 and mipsn32).  Both are native in the sense that they make full use of the
 instruction set.  This is not like i386 on amd64 or mips o32 on mips64
 because those are more like compat shims that operate under special
 (crippled) cpu modes that nobody uses unless they're stuck with old code.
 Both our ABIs on the other hand are native and equally valid and which one
 to use for a particular package depends entirely on the use case.  If your
 use case requires more than 4G of address space you'll have to use the
 64-bit package, otherwise you can use the 32-bit package which, depending
 on how pointer heavy the code is, may give a performance benefit.  You
 make this choice for each of the packages in your list and add that
 information to your script.
 
 Long hypothetical, but so what? In such a case, you’d pick one of two
 different MACHINE_ARCH values depending on the package. This this is a
 fairly atypical use case, it would not be unreasonable for the person
 wanting to do this to know the proper companion ABI. In both cases, you
 have the choice of two other values to use. Which one you use will depend
 on a variety of factors, and what might be right for one application may
 be wrong for others.
 
 And in both cases, there’s actually two choices: for amd64, you’d have
 i386 and x32. Both of these are fine choices, and it would depend on the
 workload which one is better (i386 has better toolchain support and
 maturity, x32 offers some interesting theoretical wins, but doesn’t have
 the same maturity). Same with mips64, you’d have two choices as well. In
 both cases, you can’t just take uname/MACHINE_ARCH and slap :32 on the end.

As far as I can see nobody uses i386 on amd64 except in cases where you
know you're dealing with i386 like an i386 jail, or you need to run an old
i386 binary that you're stuck with, or with compat shims like Wine.  The
choice of i386 is not comparable with the generic choice between ILP32 or
LP64 on a 64-bit instruction set, which is why I'm ok with changing the
x86 in the pkg scheme to either i386 or amd64 like you are proposing.
If pkg would keep using instruction set families like x86 or mips then
you could distinguish between old 32-bit, new 32-bit and new 64-bit using
3 generic suffixes to avoid lookup tables.  The pattern of an old 32-bit
instruction set that got extended to 64-bit on which you can define a new
32-bit ABI is common to many instruction set families, but I'm ok with
old 32-bit and new 64-bit having separate MACHINE_ARCH values.
 
 Now let's work with Nathan's patch which uses the following string to
 identify the pkg repository to fetch packages from:
 `uname -s`:`uname -r | cut -f 1 -d .`:`uname -p`
 
 On our two systems that would be FreeBSD:11:amd64 and FreeBSD:11:mips64.
 Now if your script has to install the 32-bit version of a package how
 can it go from those two strings to FreeBSD:11:x32 or FreeBSD:11:mipsn32
 without a lookup table?

 You couldn’t. Which is the whole reason I want to have them have a
 standard name so you don’t need the lookup table for the common case.
 This is an “off in the weeds” case, and optimizing for it doesn’t make
 sense. Especially because in each case, you have two different 32-bit
 ABIs to choose from. You’d have to have some kind of table in either
 case. Also, the proper name for n32, in your current system, is
 mips:32:n32, which (a) is wrong and (b) isn’t regular.

Well, it may not make sense to you and be off in the weeds, but it does
to me.  Very few processes actually need more than 4G of virtual address
space.  I cannot immediately find anything in /bin or /usr/bin for
instance (maybe clang when compiling a very large C++ file?).

I'm not sure where you're getting mips:32:n32 from.  We're talking in the
context of Nathan's patch here.

  I say, you can more easily indicate whether you
 want the 32-bit or 64-bit package by appending :32 or :64 to the original
 strings, so FreeBSD:11:amd64:32 and FreeBSD:11:mips64:32.
 
 Except there’s no such thing as mips64:32 in the current system. There’s
 two different ABIs that could mean. It could be o32 or n32, with the same
 sort of trade offs. There’d need to be a person in the loop to know, so
 there’s already a need to have special knowledge. You

Re: svn commit: r266553 - head/release/scripts

2014-05-27 Thread Tijl Coosemans
On Mon, 26 May 2014 18:47:34 -0700 Nathan Whitehorn wrote:
 I've written two patches today. The first 
 (http://people.freebsd.org/~nwhitehorn/pkg_machinearch.diff) is to pkg 
 itself and the second 
 (http://people.freebsd.org/~nwhitehorn/pkg_bootstrap_machinearch.diff) 
 is to the pkg bootstrapper in base. These switch pkg from using 
 identifiers like freebsd:11:arm:be:eabi:softfp to identifiers like 
 FreeBSD:11:armeb, matching the canonical FreeBSD platform identifiers. 
 The strings it uses can be predicted easily from scripts, as they are 
 identical in all cases to the output of `uname -s`:`uname -r | cut -f 1 
 -d .`:`uname -p`.

If those are the current names for arm then I also prefer uname -p for
the third field.  If each arch gets a default value of 32 or 64 for the
fourth field it can also be left out in many cases.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r266553 - head/release/scripts

2014-05-27 Thread Tijl Coosemans
On Mon, 26 May 2014 16:31:21 -0600 Warner Losh wrote:
 On May 26, 2014, at 4:18 PM, Tijl Coosemans t...@freebsd.org wrote: 
 On Mon, 26 May 2014 09:53:57 -0600 Warner Losh wrote:
 On May 26, 2014, at 8:39 AM, Nathan Whitehorn nwhiteh...@freebsd.org 
 wrote:
 On 05/26/14 02:35, Tijl Coosemans wrote:
 I suppose you could replace the x86 in the pkg scheme with i386/amd64,
 but then you'd still be talking about i386:32, amd64:32 and amd64:64
 instead of x86:32, x86:x32 and x86:64.  
 
 I suppose you could replace these by “i386”, “x32” (or “amd64x32”) and
 “amd64” respectively.
 
 So you're on an amd64 or mips64 system (as indicated by uname) but you
 want to use the 32-bit package if possible.  How does your script know
 about the magic x32, amd64x32 or mipsn32 strings?  Wouldn't it be
 easier if you could just use `uname -p`:32”?
 
 Oh give me a break. You know it because you know you are building for
 mipsn32 because that’s what you’ve set MACHINE_ARCH or TARGET_ARCH to,

No, MACHINE_ARCH or TARGET_ARCH is amd64 or mips64.  You are building
the 64-bit OS and then decide separately per package whether you want the
ILP32 one or the LP64 one.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org

Re: svn commit: r266553 - head/release/scripts

2014-05-27 Thread Tijl Coosemans
On Tue, 27 May 2014 07:18:06 -0600 Warner Losh wrote:
 On May 27, 2014, at 1:36 AM, Tijl Coosemans t...@freebsd.org wrote:
 On Mon, 26 May 2014 16:31:21 -0600 Warner Losh wrote:
 On May 26, 2014, at 4:18 PM, Tijl Coosemans t...@freebsd.org wrote: 
 On Mon, 26 May 2014 09:53:57 -0600 Warner Losh wrote:
 On May 26, 2014, at 8:39 AM, Nathan Whitehorn nwhiteh...@freebsd.org 
 wrote:
 On 05/26/14 02:35, Tijl Coosemans wrote:
 I suppose you could replace the x86 in the pkg scheme with i386/amd64,
 but then you'd still be talking about i386:32, amd64:32 and amd64:64
 instead of x86:32, x86:x32 and x86:64.  
 
 I suppose you could replace these by ?i386?, ?x32? (or ?amd64x32?) and
 ?amd64? respectively.
 
 So you're on an amd64 or mips64 system (as indicated by uname) but you
 want to use the 32-bit package if possible.  How does your script know
 about the magic x32, amd64x32 or mipsn32 strings?  Wouldn't it be
 easier if you could just use `uname -p`:32??
 
 Oh give me a break. You know it because you know you are building for
 mipsn32 because that?s what you?ve set MACHINE_ARCH or TARGET_ARCH to,
 
 No, MACHINE_ARCH or TARGET_ARCH is amd64 or mips64.  You are building
 the 64-bit OS and then decide separately per package whether you want the
 ILP32 one or the LP64 one.
 
 I think I understand why we?re talking past each other. This bit is wrong.
 The  LP64 one has a MACHINE_ARCH of ?amd64? or ?mips64?. The ILP32 one will
 have MACHINE_ARCH of ?i386? or ?mips?. The weird ones (ILP32 with 64-bit
 registers) will have a different MACHINE_ARCH of ?x32? or ?mipsn32?.
 Selection can be done on a case by case basis, but this will be validated
 against the supported_abis sysctl. There?s no need to have different names
 here, the current standard ones do just fine, are completely sufficient and
 all inclusive. This is rather by definition, and your understanding of the
 definition sounds flawed.
 
 While we have limited support for building 32-bit binaries, it is to build
 32-bit binaries for a different MACHINE_ARCH. -m32 on amd64 creates i386
 binaries, not amd64:32 binaries. -m32 on powerpc64 creates powerpc binaries,
 not powerpc64:32 binaries. On mips, -mabi-n32 (I think the option is) is
 required to create the mipsn32 binaries. In every single one of these cases,
 there exists a MACHINE_ARCH that completely describes the binary.

amd64:32 is provided by the -mx32 compiler flag.

 So I?m still waiting for a use case that requires the new names. One has
 not been articulated, and I don?t think one actually exists.

Imagine you've built a system with MACHINE_ARCH amd64 and one with
MACHINE_ARCH mips64.  Now you want to populate these systems with a list
of packages for which you wrote a script.  These systems each support 2
ABIs: a native 64-bit one (amd64 and mips64) and a native 32-bit one (x32
and mipsn32).  Both are native in the sense that they make full use of the
instruction set.  This is not like i386 on amd64 or mips o32 on mips64
because those are more like compat shims that operate under special
(crippled) cpu modes that nobody uses unless they're stuck with old code.
Both our ABIs on the other hand are native and equally valid and which one
to use for a particular package depends entirely on the use case.  If your
use case requires more than 4G of address space you'll have to use the
64-bit package, otherwise you can use the 32-bit package which, depending
on how pointer heavy the code is, may give a performance benefit.  You
make this choice for each of the packages in your list and add that
information to your script.

Now let's work with Nathan's patch which uses the following string to
identify the pkg repository to fetch packages from:
`uname -s`:`uname -r | cut -f 1 -d .`:`uname -p`

On our two systems that would be FreeBSD:11:amd64 and FreeBSD:11:mips64.
Now if your script has to install the 32-bit version of a package how
can it go from those two strings to FreeBSD:11:x32 or FreeBSD:11:mipsn32
without a lookup table?  I say, you can more easily indicate whether you
want the 32-bit or 64-bit package by appending :32 or :64 to the original
strings, so FreeBSD:11:amd64:32 and FreeBSD:11:mips64:32.

Like I said in a reply to Nathan's patch, pkg could default to :32 or :64
for every arch so it can be left out in many cases.  FreeBSD:11:i386
would then be equivalent to FreeBSD:11:i386:32, FreeBSD:11:amd64 to
FreeBSD:11:amd64:64, etc.

This also does not preclude the existence of a mipsn32 MACHINE_ARCH in
case you want to build a pure mipsn32 system (including the kernel), but
I wonder how many people would use that if it is possible to have a
mips64 system run n32 binaries.  I don't think many people would run a
pure x32 system (with x32 kernel) so I don't see the need to have an
x32 value for MACHINE_ARCH (or TARGET_ARCH).
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn

Re: svn commit: r266553 - head/release/scripts

2014-05-26 Thread Tijl Coosemans
On Sat, 24 May 2014 19:00:18 -0600 Warner Losh wrote:
 On May 24, 2014, at 5:53 PM, Warner Losh i...@bsdimp.com wrote:
 On May 24, 2014, at 5:13 PM, Tijl Coosemans t...@freebsd.org wrote:
 There isn't necessarily any chroot environment.  There's one kernel,
 two equally valid ABIs (ILP32 and LP64) and any binary like uname might
 use either of them.  If uname -p returns a different result depending on
 which of these two ABIs it was compiled for that could be a problem for
 any script that uses it.
 
 Well, it depends on what you want to do with the script, eh? If you want
 to know the ABI of the native binary uname, that’s one thing. But if you
 want to know the supported ABIs, you are doing it wrong by using uname.
 You should be using sysctl kern.supported_abi. That will tell you all the
 ABIs that you can install packages for on this machine, which is what you
 really want to know. So I’m having trouble connecting the dots between
 this and what you are saying here.
 
 I still am absolutely flabbergasted why the MACHINE_ARCH names aren’t
 necessary and sufficient for packaging. I’ve yet to see any coherent
 reason to not use them.
 
 Why do I care that they match? Good question. When I was doing FreeNAS, I
 looked at integrating pkgng into nanobsd. At the time this was quite
 difficult because every single architecture name was different between
 pkgng and MACHINE_ARCH.  This would mean I’d have to drag around a huge
 table to know how to translate one to the other (there was no simple regex
 either, and things like mipsn32 wouldn’t have fit into the scheme at the
 time). I would very much like us to see us keep these names in sync and
 avoid large translation tables that are difficult to maintain.
 
 Now, do you need to get it from uname -p? No. If you want to parse elf
 files to get it, that’s fine, so long as the names map directly to the
 MACHINE_ARCH names that we’ve been using for years. They completely
 describe the universe of supported platforms. Are they perfect? No, around
 the edge there may be an odd-ball that’s possible to build, but is
 unsupported and likely doesn’t work at all. Have we learned from these
 mistakes? Yes. Anything that’s actively supported has a proper name. This
 name is needed, btw, so that any machine can self-host, a nice feature of
 the /usr/src system.

ABI consists of the following elements:

- OS
- OS ABI version (major version number in FreeBSD)
- instruction set
- programming model (ILP32 or LP64)
- byte order (little/big endian)

These are almost orthogonal dimensions in the sense that almost any
combination is possible.  (A combination that isn't possible is a
32-bit instruction set with LP64.)

What you are asking for now is to combine two dimensions into one and
combination in this case means multiplication so if you have 3
instruction sets and 2 programming models, the combined dimension needs
6 different values.  You need to make the case for why you think this
is a good idea.  For the past 20 years we got away with this because
on every installation of FreeBSD we only used one programming model at
a time.  This is still the case for byte order of course.

What I'm saying is to keep the option open for installations with
multiple programming models, where most binaries could use ILP32 and
only the ones that actually need a 64-bit address space use LP64.
You query the instruction set using uname and the programming models
using getconf.

I suppose you could replace the x86 in the pkg scheme with i386/amd64,
but then you'd still be talking about i386:32, amd64:32 and amd64:64
instead of x86:32, x86:x32 and x86:64.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org

Re: svn commit: r266553 - head/release/scripts

2014-05-26 Thread Tijl Coosemans
On Mon, 26 May 2014 09:53:57 -0600 Warner Losh wrote:
 On May 26, 2014, at 8:39 AM, Nathan Whitehorn nwhiteh...@freebsd.org wrote:
 On 05/26/14 02:35, Tijl Coosemans wrote:
 On Sat, 24 May 2014 19:00:18 -0600 Warner Losh wrote:
 On May 24, 2014, at 5:53 PM, Warner Losh i...@bsdimp.com wrote:
 On May 24, 2014, at 5:13 PM, Tijl Coosemans t...@freebsd.org wrote:
 There isn't necessarily any chroot environment.  There's one kernel,
 two equally valid ABIs (ILP32 and LP64) and any binary like uname might
 use either of them.  If uname -p returns a different result depending on
 which of these two ABIs it was compiled for that could be a problem for
 any script that uses it.
 Well, it depends on what you want to do with the script, eh? If you want
 to know the ABI of the native binary uname, that’s one thing. But if you
 want to know the supported ABIs, you are doing it wrong by using uname.
 You should be using sysctl kern.supported_abi. That will tell you all the
 ABIs that you can install packages for on this machine, which is what you
 really want to know. So I’m having trouble connecting the dots between
 this and what you are saying here.
 
 I still am absolutely flabbergasted why the MACHINE_ARCH names aren’t
 necessary and sufficient for packaging. I’ve yet to see any coherent
 reason to not use them.
 Why do I care that they match? Good question. When I was doing FreeNAS, I
 looked at integrating pkgng into nanobsd. At the time this was quite
 difficult because every single architecture name was different between
 pkgng and MACHINE_ARCH.  This would mean I’d have to drag around a huge
 table to know how to translate one to the other (there was no simple regex
 either, and things like mipsn32 wouldn’t have fit into the scheme at the
 time). I would very much like us to see us keep these names in sync and
 avoid large translation tables that are difficult to maintain.
 
 Now, do you need to get it from uname -p? No. If you want to parse elf
 files to get it, that’s fine, so long as the names map directly to the
 MACHINE_ARCH names that we’ve been using for years. They completely
 describe the universe of supported platforms. Are they perfect? No, around
 the edge there may be an odd-ball that’s possible to build, but is
 unsupported and likely doesn’t work at all. Have we learned from these
 mistakes? Yes. Anything that’s actively supported has a proper name. This
 name is needed, btw, so that any machine can self-host, a nice feature of
 the /usr/src system.
 ABI consists of the following elements:
 
 - OS
 - OS ABI version (major version number in FreeBSD)
 
 These two are encoded in FreeBSD and major version. There’s no problem
 encoding these in the package architecture string. They are easily
 scriptable and totally obvious to FreeBSD users and pose no problems.
 Nobody is opposed to these, and actually they are rather a good idea.
 
 - instruction set
 - programming model (ILP32 or LP64)
 - byte order (little/big endian)
 
 These three are encoded in MACHINE_ARCH and have been for quite some
 time. And you forgot several things as well: register conventions,
 calling conventions, stack alignment, struct alignment, pointer
 conversion conventions, address space layout, page size constraints,
 etc. There are simply far too many to try to break down like you are
 trying to do. And that’s even before we get into shared library
 conventions...

I didn't forget them, I just restricted it to the elements that came up
so far.  All these extra elements are like byte order: you use only one
of each per combination of the first four fields so they can be discarded.
Things like calling conventions and register use can be considered part
of the programming model.  The amd64 programming models that matter to
FreeBSD (both ILP32 and LP64) are documented in the System V Application
Binary Interface AMD64 Architecture Processor Supplement.

 These are almost orthogonal dimensions in the sense that almost any
 combination is possible.  (A combination that isn't possible is a
 32-bit instruction set with LP64.)
 
 All of these items are encoded in MACHINE_ARACH and have been for at
 least a decade. There’s no new argument here.  If they were actually
 orthogonal, then that would be one thing. But they aren’t. They are all
 closely interrelated and we only support a vanishingly small number of
 possible conventions. Combinatorically, it can be hundreds. Practically,
 it is usually only a handful.

 What you are asking for now is to combine two dimensions into one and
 combination in this case means multiplication so if you have 3
 instruction sets and 2 programming models, the combined dimension needs
 6 different values.  You need to make the case for why you think this
 is a good idea.
 
 Because uanme has to be 6 different things so the right binaries are
 built. It is really that simple.

Uname is a per system (or per jail) setting.  Whether you then want a
32-bit or 64-bit address space is a separate per program

Re: svn commit: r266553 - head/release/scripts

2014-05-24 Thread Tijl Coosemans
On Fri, 23 May 2014 17:29:48 -0600 Warner Losh wrote:
 On May 23, 2014, at 10:20 AM, Baptiste Daroussin b...@freebsd.org wrote:
 On Fri, May 23, 2014 at 08:52:28AM -0700, Nathan Whitehorn wrote:
 On 05/23/14 08:36, Baptiste Daroussin wrote:
 On Fri, May 23, 2014 at 08:19:34AM -0700, Nathan Whitehorn wrote:
 Is there any chance of finally switching the pkg abi identifiers to just
 be uname -p?
 -Nathan
 Keeping asking won't make it happen, I have explained a large number of 
 time why it
 happened, why it is not easy for compatibility and why uname -p is still 
 not
 representing the ABI we do support, and what flexibility we need that the
 current string offers to us.
 
 if one is willing to do the work, please be my guess, just dig into the 
 archives
 and join the pkg development otherwise: no it won't happen before a while
 because we have way too much work on the todo and this item is stored at 
 the
 very end of this todo.
 
 regards,
 Bapt
 
 I'm happy to do the work, and have volunteered now many times. If uname 
 -p does not describe the ABI fully, then uname -p needs changes on the 
 relevant platforms. Which are they? What extra flexibility does the 
 string give you if uname -p describes the ABI completely?
 -Nathan
 
 just simple examples in armv6:
 - eabi vs oabi
 - The different float abi (even if only one is supported for now others are
  being worked on)
 - little endian vs big endian
 
 All of those are encoded in the MACHINE_ARCH + freebsd version, no exceptions
 on supported architectures that are tier 2 or higher. This seems like a weak 
 reason.
 
 the extras flexibilit is being able to say this binary do support freebsd 
 i386
 and amd64 in one key, freebsd:9:x86:*, or or all arches freebsd:10:*
 
 Will there be a program to convert this new, special invention to the standard
 that we’ve used for the past 20 years? If you need the flexibility, which I’m 
 not
 entirely sure I’ve seen a good use case for. When would you have a x86 binary
 package? Wouldn’t it be either i386 or amd64?

ABI isn't just about the instruction set.  It's also about the sizes of C
types (like pointers).  If I remember correctly, the pkg scheme was chosen
to allow for ABIs like x32 which use the 64 bit instruction set with 32
bit pointers.  MACHINE_ARCH would also be amd64 in this case.

The advantage of the pkg scheme is that it has a formal structure.  That's
what makes it flexible, extensible, machine parsable, etc.  I'd rather see
the rest of FreeBSD adopt this scheme than that pkg would have to adopt
the informal names.  The use of x86 instead of i386/amd64 is part of the
idea to merge more of sys/i386 and sys/amd64 into sys/x86 and eventually
define MACHINE as x86.

Patterns like freebsd:9:* will probably become more prevalent when support
for subpackages is added.  Some of the subpackages (like documentation) will
be ABI independent.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


  1   2   3   >