diff options
author | ngie <ngie@FreeBSD.org> | 2015-12-09 05:35:46 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2015-12-09 05:35:46 +0000 |
commit | dcd31244e8ecc492a511e48ed4c631615e092491 (patch) | |
tree | 9651a748c83288640926c2d597a2e1b13816acc4 | |
parent | 51e48e07fddf9730600dec32c469c760f731bed5 (diff) | |
parent | 81405113199dc2ec33e9cd60464efa5f2423a65c (diff) | |
download | FreeBSD-src-dcd31244e8ecc492a511e48ed4c631615e092491.zip FreeBSD-src-dcd31244e8ecc492a511e48ed4c631615e092491.tar.gz |
MFhead @ r292005
232 files changed, 4387 insertions, 1694 deletions
diff --git a/Makefile.inc1 b/Makefile.inc1 index 9d2253c..645167b 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -163,7 +163,7 @@ OSRELDATE= 0 .endif # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION. -.if !defined(VERSION) +.if !defined(VERSION) && !make(showconfig) REVISION!= ${MAKE} -C ${SRCDIR}/release -V REVISION BRANCH!= ${MAKE} -C ${SRCDIR}/release -V BRANCH SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \ @@ -195,11 +195,14 @@ _TARGET_CPUTYPE=${TARGET_CPUTYPE} .else _TARGET_CPUTYPE=dummy .endif +# Skip for showconfig as it is just wasted time and may invoke auto.obj.mk. +.if !make(showconfig) _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \ -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE .if ${_CPUTYPE} != ${_TARGET_CPUTYPE} .error CPUTYPE global should be set with ?=. .endif +.endif .if make(buildworld) BUILD_ARCH!= uname -p .if ${MACHINE_ARCH} != ${BUILD_ARCH} @@ -666,7 +669,7 @@ everything: @echo "--------------------------------------------------------------" @echo ">>> stage 4.4: building everything" @echo "--------------------------------------------------------------" - ${_+_}cd ${.CURDIR}; _PARALLEL_SUBUDIR_OK=1 ${WMAKE} all + ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all .if defined(LIB32TMP) build32: .PHONY @echo @@ -2008,14 +2011,14 @@ _prebuild_libs: ${_prebuild_libs:S/$/__L/} _generic_libs: ${_generic_libs:S/$/__L/} # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from -# 'everything' with _PARALLEL_SUBUDIR_OK set. This is because it is unlikely +# 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in # parallel. This is safe for the world stage of buildworld though since it has # already built libraries in a proper order and installed includes into # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to # avoid trashing a system if it crashes mid-install. -.if !make(all) || defined(_PARALLEL_SUBUDIR_OK) +.if !make(all) || defined(_PARALLEL_SUBDIR_OK) SUBDIR_PARALLEL= .endif @@ -31,6 +31,13 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11.x IS SLOW: disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20151207: + Debug data files are now built by default with 'make buildworld' and + installed with 'make installworld'. This facilitates debugging but + requires more disk space both during the build and for the installed + world. Debug files may be disabled by setting WITHOUT_DEBUG_FILES=yes + in src.conf(5). + 20151130: r291527 changed the internal interface between the nfsd.ko and nfscommon.ko modules. As such, they must both be upgraded to-gether. diff --git a/bin/freebsd-version/Makefile b/bin/freebsd-version/Makefile index e515d0c..91945ac 100644 --- a/bin/freebsd-version/Makefile +++ b/bin/freebsd-version/Makefile @@ -2,7 +2,7 @@ SCRIPTS = freebsd-version MAN = freebsd-version.1 -CLEANFILES = freebsd-version.sh +CLEANFILES = freebsd-version freebsd-version.sh NEWVERS = ${.CURDIR}/../../sys/conf/newvers.sh freebsd-version.sh: ${.CURDIR}/freebsd-version.sh.in ${NEWVERS} diff --git a/bin/ls/print.c b/bin/ls/print.c index 70f53ba..7fe73a6 100644 --- a/bin/ls/print.c +++ b/bin/ls/print.c @@ -47,12 +47,14 @@ __FBSDID("$FreeBSD$"); #include <fts.h> #include <langinfo.h> #include <libutil.h> +#include <limits.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> +#include <wchar.h> #ifdef COLORLS #include <ctype.h> #include <termcap.h> @@ -105,6 +107,9 @@ static struct { } colors[C_NUMCOLORS]; #endif +static size_t padding_for_month[12]; +static size_t month_max_size = 0; + void printscol(const DISPLAY *dp) { @@ -138,6 +143,70 @@ printname(const char *field, const char *name) return rc; } +static const char * +get_abmon(int mon) +{ + + switch (mon) { + case 0: return (nl_langinfo(ABMON_1)); + case 1: return (nl_langinfo(ABMON_2)); + case 2: return (nl_langinfo(ABMON_3)); + case 3: return (nl_langinfo(ABMON_4)); + case 4: return (nl_langinfo(ABMON_5)); + case 5: return (nl_langinfo(ABMON_6)); + case 6: return (nl_langinfo(ABMON_7)); + case 7: return (nl_langinfo(ABMON_8)); + case 8: return (nl_langinfo(ABMON_9)); + case 9: return (nl_langinfo(ABMON_10)); + case 10: return (nl_langinfo(ABMON_11)); + case 11: return (nl_langinfo(ABMON_12)); + } + + /* should never happen */ + abort(); +} + +static size_t +mbswidth(const char *month) +{ + wchar_t wc; + size_t width, donelen, clen, w; + + width = donelen = 0; + while ((clen = mbrtowc(&wc, month + donelen, MB_LEN_MAX, NULL)) != 0) { + if (clen == (size_t)-1 || clen == (size_t)-2) + return (-1); + donelen += clen; + if ((w = wcwidth(wc)) == (size_t)-1) + return (-1); + width += w; + } + + return (width); +} + +static void +compute_abbreviated_month_size(void) +{ + int i; + size_t width; + size_t months_width[12]; + + for (i = 0; i < 12; i++) { + width = mbswidth(get_abmon(i)); + if (width == (size_t)-1) { + month_max_size = -1; + return; + } + months_width[i] = width; + if (width > month_max_size) + month_max_size = width; + } + + for (i = 0; i < 12; i++) + padding_for_month[i] = month_max_size - months_width[i]; +} + /* * print name in current style */ @@ -425,6 +494,31 @@ printdev(size_t width, dev_t dev) xo_emit("{:device/%#*jx} ", (u_int)width, (uintmax_t)dev); } +static size_t +ls_strftime(char *str, size_t len, const char *fmt, const struct tm *tm) +{ + char *posb, nfmt[BUFSIZ]; + const char *format = fmt; + size_t ret; + + if ((posb = strstr(fmt, "%b")) != NULL) { + if (month_max_size == 0) { + compute_abbreviated_month_size(); + } + if (month_max_size > 0) { + snprintf(nfmt, sizeof(nfmt), "%.*s%s%*s%s", + (int)(posb - fmt), fmt, + get_abmon(tm->tm_mon), + (int)padding_for_month[tm->tm_mon], + "", + posb + 2); + format = nfmt; + } + } + ret = strftime(str, len, format, tm); + return (ret); +} + static void printtime(const char *field, time_t ftime) { @@ -451,7 +545,7 @@ printtime(const char *field, time_t ftime) else /* mmm dd yyyy || dd mmm yyyy */ format = d_first ? "%e %b %Y" : "%b %e %Y"; - strftime(longstring, sizeof(longstring), format, localtime(&ftime)); + ls_strftime(longstring, sizeof(longstring), format, localtime(&ftime)); snprintf(fmt, sizeof(fmt), "{d:%s/%%hs} ", field); xo_attr("value", "%ld", (long) ftime); diff --git a/bin/ls/tests/ls_tests.sh b/bin/ls/tests/ls_tests.sh index fbbf24d..3317876 100755 --- a/bin/ls/tests/ls_tests.sh +++ b/bin/ls/tests/ls_tests.sh @@ -170,8 +170,6 @@ B_flag_head() B_flag_body() { - atf_skip "kyua report-jenkins doesn't properly escape non-printable chars: https://github.com/jmmv/kyua/issues/136" - atf_check -e empty -o empty -s exit:0 touch "$(printf "y\013z")" atf_check -e empty -o match:'y\\013z' -s exit:0 ls -B } @@ -467,8 +465,6 @@ b_flag_head() b_flag_body() { - atf_skip "kyua report-jenkins doesn't properly escape non-printable chars: https://github.com/jmmv/kyua/issues/136" - atf_check -e empty -o empty -s exit:0 touch "$(printf "y\013z")" atf_check -e empty -o match:'y\\vz' -s exit:0 ls -b } @@ -747,8 +743,6 @@ q_flag_and_w_flag_head() q_flag_and_w_flag_body() { - atf_skip "kyua report-jenkins doesn't properly escape non-printable chars: https://github.com/jmmv/kyua/issues/136" - create_test_dir test_file="$(printf "y\01z")" diff --git a/bin/sh/tests/parameters/Makefile b/bin/sh/tests/parameters/Makefile index d496492..528697d 100644 --- a/bin/sh/tests/parameters/Makefile +++ b/bin/sh/tests/parameters/Makefile @@ -21,6 +21,7 @@ FILES+= positional5.0 FILES+= positional6.0 FILES+= positional7.0 FILES+= positional8.0 +FILES+= positional9.0 FILES+= pwd1.0 FILES+= pwd2.0 diff --git a/bin/sh/tests/parameters/positional9.0 b/bin/sh/tests/parameters/positional9.0 new file mode 100644 index 0000000..8571bfa --- /dev/null +++ b/bin/sh/tests/parameters/positional9.0 @@ -0,0 +1,18 @@ +# $FreeBSD$ +# Although POSIX leaves the result of expanding ${#@} and ${#*} unspecified, +# make sure it is at least numeric. + +set -- bb cc ddd +set -f +lengths=${#*}${#@}"${#*}${#@}"$(echo ${#*}${#@}"${#*}${#@}") +IFS= +lengths=$lengths${#*}${#@}"${#*}${#@}"$(echo ${#*}${#@}"${#*}${#@}") +case $lengths in +*[!0-9]*) + printf 'bad: %s\n' "$lengths" + exit 3 ;; +????????????????*) ;; +*) + printf 'too short: %s\n' "$lengths" + exit 3 ;; +esac diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printa/tst.walltimestamp.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printa/tst.walltimestamp.ksh.out index 7462cf8..724e45e 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printa/tst.walltimestamp.ksh.out +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printa/tst.walltimestamp.ksh.out @@ -1,2 +1,3 @@ Sun, 25 Jan 2004 13:00:00 PST 2004 Jan 25 13:00:00 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh new file mode 100644 index 0000000..2e404f4 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh @@ -0,0 +1,99 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2015, Joyent, Inc. All rights reserved. +# + +# +# This test assures that we can have the same provider name across multiple +# probe definitions, and that the result will be the union of those +# definitions. In particular, libusdt depends on this when (for example) +# node modules that create a provider are loaded multiple times due to +# being included by different modules. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > test.c <<EOF +#include <unistd.h> + +void +main() +{ +EOF + +objs= + +for oogle in bagnoogle stalloogle cockoogle; do + cat > $oogle.c <<EOF +#include <sys/sdt.h> + +void +$oogle() +{ + DTRACE_PROBE(doogle, $oogle); +} +EOF + + cat > $oogle.d <<EOF +provider doogle { + probe $oogle(); +}; +EOF + + cc -c $oogle.c + + if [ $? -ne 0 ]; then + print -u2 "failed to compile $oogle.c" + exit 1 + fi + + $dtrace -G -s $oogle.d $oogle.o -o $oogle.d.o + + if [ $? -ne 0 ]; then + print -u2 "failed to process $oogle.d" + exit 1 + fi + + objs="$objs $oogle.o $oogle.d.o" + echo $oogle'();' >> test.c +done + +echo "}" >> test.c + +cc -o test test.c $objs + +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi + +$dtrace -n 'doogle$target:::{@[probename] = count()}' \ + -n 'END{printa("%-10s %@d\n", @)}' -x quiet -x aggsortkey -Zc ./test + +if [ $? -ne 0 ]; then + print -u2 "failed to execute test" + exit 1 +fi + +cd / +rm -rf $DIR +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh.out new file mode 100644 index 0000000..bdeeb1e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh.out @@ -0,0 +1,4 @@ +bagnoogle 1 +cockoogle 1 +stalloogle 1 + diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c index c61a710..5444477 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c @@ -571,12 +571,6 @@ dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname) prsyminfo_t sip; dof_helper_t dh; GElf_Half e_type; -#ifdef __FreeBSD__ - dof_hdr_t hdr; - size_t sz; - uint64_t dofmax; - void *dof; -#endif const char *mname; const char *syms[] = { "___SUNW_dof", "__SUNW_dof" }; int i, fd = -1; @@ -606,61 +600,25 @@ dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname) continue; } -#ifdef __FreeBSD__ + dh.dofhp_dof = sym.st_value; dh.dofhp_addr = (e_type == ET_EXEC) ? 0 : pmp->pr_vaddr; - if (Pread(P, &hdr, sizeof (hdr), sym.st_value) != - sizeof (hdr)) { - dt_dprintf("read of DOF header failed\n"); - continue; - } - - sz = sizeof(dofmax); - if (sysctlbyname("kern.dtrace.dof_maxsize", &dofmax, &sz, - NULL, 0) != 0) { - dt_dprintf("failed to read dof_maxsize: %s\n", - strerror(errno)); - continue; - } - if (dofmax < hdr.dofh_loadsz) { - dt_dprintf("DOF load size exceeds maximum\n"); - continue; - } - - if ((dof = malloc(hdr.dofh_loadsz)) == NULL) - return (-1); - - if (Pread(P, dof, hdr.dofh_loadsz, sym.st_value) != - hdr.dofh_loadsz) { - free(dof); - dt_dprintf("read of DOF section failed\n"); - continue; - } - - dh.dofhp_dof = (uintptr_t)dof; - dh.dofhp_pid = proc_getpid(P); dt_pid_objname(dh.dofhp_mod, sizeof (dh.dofhp_mod), sip.prs_lmid, mname); +#ifdef __FreeBSD__ + dh.dofhp_pid = proc_getpid(P); + if (fd == -1 && (fd = open("/dev/dtrace/helper", O_RDWR, 0)) < 0) { dt_dprintf("open of helper device failed: %s\n", strerror(errno)); - free(dof); return (-1); /* errno is set for us */ } if (ioctl(fd, DTRACEHIOC_ADDDOF, &dh, sizeof (dh)) < 0) dt_dprintf("DOF was rejected for %s\n", dh.dofhp_mod); - - free(dof); #else - dh.dofhp_dof = sym.st_value; - dh.dofhp_addr = (e_type == ET_EXEC) ? 0 : pmp->pr_vaddr; - - dt_pid_objname(dh.dofhp_mod, sizeof (dh.dofhp_mod), - sip.prs_lmid, mname); - if (fd == -1 && (fd = pr_open(P, "/dev/dtrace/helper", O_RDWR, 0)) < 0) { dt_dprintf("pr_open of helper device failed: %s\n", diff --git a/cddl/usr.sbin/dtrace/tests/common/proc/Makefile b/cddl/usr.sbin/dtrace/tests/common/proc/Makefile index 6ca6b58..d565364 100644 --- a/cddl/usr.sbin/dtrace/tests/common/proc/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/proc/Makefile @@ -24,6 +24,6 @@ CFILES= \ tst.sigwait.c \ -LIBADD.tst.sigwait.exe=rt +LIBADD.tst.sigwait.exe+= rt .include "../../dtrace.test.mk" diff --git a/cddl/usr.sbin/dtrace/tests/common/usdt/Makefile b/cddl/usr.sbin/dtrace/tests/common/usdt/Makefile index 717d0c6..b4f6623 100644 --- a/cddl/usr.sbin/dtrace/tests/common/usdt/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/usdt/Makefile @@ -46,6 +46,8 @@ TESTFILES= \ tst.onlyenabled.ksh \ tst.reap.ksh \ tst.reeval.ksh \ + tst.sameprovmulti.ksh \ + tst.sameprovmulti.ksh.out \ tst.static.ksh \ tst.static.ksh.out \ tst.static2.ksh \ diff --git a/contrib/bmake/ChangeLog b/contrib/bmake/ChangeLog index ec3255e..c620c84 100644 --- a/contrib/bmake/ChangeLog +++ b/contrib/bmake/ChangeLog @@ -1,3 +1,35 @@ +2015-12-01 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (MAKE_VERSION): 20151201 + Merge with NetBSD make, pick up + o cond.c: CondCvtArg: avoid access beyond end of empty buffer. + o meta.c: meta_oodate: use lstat(2) for checking link target + in case it is a symlink. + o var.c: avoid calling brk_string and Var_Export1 with empty + strings. + +2015-11-26 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (MAKE_VERSION): 20151126 + Merge with NetBSD make, pick up + o parse.c: ParseTrackInput don't access beyond + end of old value. + +2015-10-22 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (MAKE_VERSION): 20151022 + + * Add support for BSD/OS which lacks inttypes.h + and really needs sys/param.h for sys/sysctl.h + also 'type' is not a shell builtin. + + * var.c: eliminate uint32_t and need for inttypes.h + + * main.c: PrintOnError flush stdout before run .ERROR + + * parse.c: cope with _SC_PAGESIZE not being defined. + + 2015-10-20 Simon J. Gerraty <sjg@bad.crufty.net> * Makefile (MAKE_VERSION): 20151020 diff --git a/contrib/bmake/Makefile b/contrib/bmake/Makefile index a059ec4..861e8f5 100644 --- a/contrib/bmake/Makefile +++ b/contrib/bmake/Makefile @@ -1,7 +1,7 @@ -# $Id: Makefile,v 1.44 2015/10/20 21:41:40 sjg Exp $ +# $Id: Makefile,v 1.48 2015/12/02 00:36:42 sjg Exp $ # Base version on src date -MAKE_VERSION= 20151020 +MAKE_VERSION= 20151201 PROG= bmake diff --git a/contrib/bmake/boot-strap b/contrib/bmake/boot-strap index 340c46a..a49ffb1 100755 --- a/contrib/bmake/boot-strap +++ b/contrib/bmake/boot-strap @@ -111,7 +111,7 @@ # Simon J. Gerraty <sjg@crufty.net> # RCSid: -# $Id: boot-strap,v 1.45 2014/04/05 22:56:54 sjg Exp $ +# $Id: boot-strap,v 1.48 2015/10/25 05:20:48 sjg Exp $ # # @(#) Copyright (c) 2001 Simon J. Gerraty # @@ -395,8 +395,15 @@ Bmake() { ) } +# there is actually a shell where type is not a builtin +# if type is missing, which(1) had better exists! +if (type cat) > /dev/null 2>&1; then +which() { + type "$@" | sed 's,[()],,g;s,^[^/][^/]*,,;q' +} +fi # make sure test below uses the same diff that configure did -TOOL_DIFF=`type diff | sed 's,[()],,g;s,^[^/][^/]*,,;q'` +TOOL_DIFF=`which diff` export TOOL_DIFF op_configure() { diff --git a/contrib/bmake/cond.c b/contrib/bmake/cond.c index 2d2f087..1916300 100644 --- a/contrib/bmake/cond.c +++ b/contrib/bmake/cond.c @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.69 2015/10/11 04:51:24 sjg Exp $ */ +/* $NetBSD: cond.c,v 1.71 2015/12/02 00:28:24 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: cond.c,v 1.69 2015/10/11 04:51:24 sjg Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.71 2015/12/02 00:28:24 sjg Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: cond.c,v 1.69 2015/10/11 04:51:24 sjg Exp $"); +__RCSID("$NetBSD: cond.c,v 1.71 2015/12/02 00:28:24 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -490,6 +490,10 @@ CondCvtArg(char *str, double *value) double d_val; errno = 0; + if (!*str) { + *value = (double)0; + return TRUE; + } l_val = strtoul(str, &eptr, str[1] == 'x' ? 16 : 10); ech = *eptr; if (ech == 0 && errno != ERANGE) { diff --git a/contrib/bmake/config.h.in b/contrib/bmake/config.h.in index ce30da1..ce1700d 100644 --- a/contrib/bmake/config.h.in +++ b/contrib/bmake/config.h.in @@ -59,6 +59,12 @@ /* Define to 1 if you have the `killpg' function. */ #undef HAVE_KILLPG +/* Define to 1 if you have the <libgen.h> header file. */ +#undef HAVE_LIBGEN_H + +/* Define to 1 if you have the <limits.h> header file. */ +#undef HAVE_LIMITS_H + /* Define to 1 if you have the <memory.h> header file. */ #undef HAVE_MEMORY_H @@ -158,6 +164,9 @@ */ #undef HAVE_SYS_NDIR_H +/* Define to 1 if you have the <sys/param.h> header file. */ +#undef HAVE_SYS_PARAM_H + /* Define to 1 if you have the <sys/select.h> header file. */ #undef HAVE_SYS_SELECT_H @@ -304,6 +313,11 @@ /* Define to 1 if you need to in order for `stat' and other things to work. */ #undef _POSIX_SOURCE +/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>, + <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +#undef _UINT32_T + /* C99 function name */ #undef __func__ @@ -319,5 +333,9 @@ /* Define to `unsigned int' if <sys/types.h> does not define. */ #undef size_t +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +#undef uint32_t + /* Define as `fork' if `vfork' does not work. */ #undef vfork diff --git a/contrib/bmake/configure b/contrib/bmake/configure index 08b21b3..946b8da 100755 --- a/contrib/bmake/configure +++ b/contrib/bmake/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.64 for bmake 20140214. +# Generated by GNU Autoconf 2.64 for bmake 20151022. # # Report bugs to <sjg@NetBSD.org>. # @@ -549,8 +549,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='bmake' PACKAGE_TARNAME='bmake' -PACKAGE_VERSION='20140214' -PACKAGE_STRING='bmake 20140214' +PACKAGE_VERSION='20151022' +PACKAGE_STRING='bmake 20151022' PACKAGE_BUGREPORT='sjg@NetBSD.org' PACKAGE_URL='' @@ -1221,7 +1221,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures bmake 20140214 to adapt to many kinds of systems. +\`configure' configures bmake 20151022 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1282,7 +1282,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of bmake 20140214:";; + short | recursive ) echo "Configuration of bmake 20151022:";; esac cat <<\_ACEOF @@ -1387,7 +1387,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -bmake configure 20140214 +bmake configure 20151022 generated by GNU Autoconf 2.64 Copyright (C) 2009 Free Software Foundation, Inc. @@ -1742,6 +1742,58 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_check_type +# ac_fn_c_find_uintX_t LINENO BITS VAR +# ------------------------------------ +# Finds an unsigned integer type with width BITS, setting cache variable VAR +# accordingly. +ac_fn_c_find_uintX_t () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 +$as_echo_n "checking for uint$2_t... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ + 'unsigned long long int' 'unsigned short int' 'unsigned char'; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(($ac_type) -1 >> ($2 - 1) == 1)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + case $ac_type in #( + uint$2_t) : + eval "$3=yes" ;; #( + *) : + eval "$3=\$ac_type" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + eval as_val=\$$3 + if test "x$as_val" = x""no; then : + +else + break +fi + done +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_find_uintX_t + # ac_fn_c_check_decl LINENO SYMBOL VAR # ------------------------------------ # Tests whether SYMBOL is declared, setting cache variable VAR accordingly. @@ -1908,7 +1960,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by bmake $as_me 20140214, which was +It was created by bmake $as_me 20151022, which was generated by GNU Autoconf 2.64. Invocation command line was $ $0 $@ @@ -4569,10 +4621,41 @@ fi fi +for ac_header in sys/param.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "sys/param.h" "ac_cv_header_sys_param_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_param_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_PARAM_H 1 +_ACEOF + +fi + +done + +for ac_header in sys/sysctl.h +do : + ac_fn_c_check_header_compile "$LINENO" "sys/sysctl.h" "ac_cv_header_sys_sysctl_h" "#ifdef HAVE_SYS_PARAM_H +# include <sys/param.h> +# endif + +" +if test "x$ac_cv_header_sys_sysctl_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_SYSCTL_H 1 +_ACEOF + +fi + +done + + for ac_header in \ ar.h \ err.h \ fcntl.h \ + libgen.h \ + limits.h \ paths.h \ poll.h \ ranlib.h \ @@ -4580,7 +4663,6 @@ for ac_header in \ sys/mman.h \ sys/select.h \ sys/socket.h \ - sys/sysctl.h \ sys/time.h \ sys/uio.h \ unistd.h \ @@ -5006,6 +5088,20 @@ _ACEOF fi +ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" +case $ac_cv_c_uint32_t in #( + no|yes) ;; #( + *) + +$as_echo "#define _UINT32_T 1" >>confdefs.h + + +cat >>confdefs.h <<_ACEOF +#define uint32_t $ac_cv_c_uint32_t +_ACEOF +;; + esac + ac_fn_c_check_decl "$LINENO" "sys_siglist" "ac_cv_have_decl_sys_siglist" "#include <signal.h> /* NetBSD declares sys_siglist in unistd.h. */ #ifdef HAVE_UNISTD_H @@ -6406,7 +6502,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by bmake $as_me 20140214, which was +This file was extended by bmake $as_me 20151022, which was generated by GNU Autoconf 2.64. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -6466,7 +6562,7 @@ Report bugs to <sjg@NetBSD.org>." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -bmake config.status 20140214 +bmake config.status 20151022 configured by $0, generated by GNU Autoconf 2.64, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/contrib/bmake/configure.in b/contrib/bmake/configure.in index ae3e425..c4b6808 100644 --- a/contrib/bmake/configure.in +++ b/contrib/bmake/configure.in @@ -1,11 +1,11 @@ dnl dnl RCSid: -dnl $Id: configure.in,v 1.54 2015/10/10 04:17:10 sjg Exp $ +dnl $Id: configure.in,v 1.56 2015/10/25 05:20:48 sjg Exp $ dnl dnl Process this file with autoconf to produce a configure script dnl AC_PREREQ(2.50) -AC_INIT([bmake], [20151009], [sjg@NetBSD.org]) +AC_INIT([bmake], [20151022], [sjg@NetBSD.org]) AC_CONFIG_HEADERS(config.h) dnl make srcdir absolute @@ -101,10 +101,19 @@ AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_HEADER_DIRENT dnl Keep this list sorted +AC_CHECK_HEADERS(sys/param.h) +dnl On BSDi at least we really need sys/param.h for sys/sysctl.h +AC_CHECK_HEADERS([sys/sysctl.h], [], [], +[#ifdef HAVE_SYS_PARAM_H +# include <sys/param.h> +# endif +]) + AC_CHECK_HEADERS( \ ar.h \ err.h \ fcntl.h \ + libgen.h \ limits.h \ paths.h \ poll.h \ @@ -113,7 +122,6 @@ AC_CHECK_HEADERS( \ sys/mman.h \ sys/select.h \ sys/socket.h \ - sys/sysctl.h \ sys/time.h \ sys/uio.h \ unistd.h \ @@ -143,6 +151,7 @@ AC_C_CONST AC_TYPE_OFF_T AC_TYPE_PID_T AC_TYPE_SIZE_T +AC_TYPE_UINT32_T AC_DECL_SYS_SIGLIST AC_HEADER_TIME AC_STRUCT_TM diff --git a/contrib/bmake/main.c b/contrib/bmake/main.c index d7fe534..fcae496 100644 --- a/contrib/bmake/main.c +++ b/contrib/bmake/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.234 2015/10/11 04:51:24 sjg Exp $ */ +/* $NetBSD: main.c,v 1.235 2015/10/25 05:24:44 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,7 +69,7 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: main.c,v 1.234 2015/10/11 04:51:24 sjg Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.235 2015/10/25 05:24:44 sjg Exp $"; #else #include <sys/cdefs.h> #ifndef lint @@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\ #if 0 static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: main.c,v 1.234 2015/10/11 04:51:24 sjg Exp $"); +__RCSID("$NetBSD: main.c,v 1.235 2015/10/25 05:24:44 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -1902,6 +1902,8 @@ PrintOnError(GNode *gn, const char *s) printf("%s", cp); free(cp); } + fflush(stdout); + /* * Finally, see if there is a .ERROR target, and run it if so. */ diff --git a/contrib/bmake/meta.c b/contrib/bmake/meta.c index 09febfc..a7a4b19 100644 --- a/contrib/bmake/meta.c +++ b/contrib/bmake/meta.c @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.40 2015/10/11 04:51:24 sjg Exp $ */ +/* $NetBSD: meta.c,v 1.41 2015/11/30 23:37:56 sjg Exp $ */ /* * Implement 'meta' mode. @@ -38,7 +38,11 @@ #include <sys/stat.h> #include <sys/ioctl.h> #include <fcntl.h> +#ifdef HAVE_LIBGEN_H #include <libgen.h> +#elif !defined(HAVE_DIRNAME) +char * dirname(char *); +#endif #include <errno.h> #if !defined(HAVE_CONFIG_H) || defined(HAVE_ERR_H) #include <err.h> @@ -1183,7 +1187,8 @@ meta_oodate(GNode *gn, Boolean oodate) if ((strstr("tmp", p))) break; - if (stat(p, &fs) < 0) { + if ((link_src != NULL && lstat(p, &fs) < 0) || + (link_src == NULL && stat(p, &fs) < 0)) { Lst_AtEnd(missingFiles, bmake_strdup(p)); } break; diff --git a/contrib/bmake/mk/ChangeLog b/contrib/bmake/mk/ChangeLog index e7f71b5..965ff4d 100644 --- a/contrib/bmake/mk/ChangeLog +++ b/contrib/bmake/mk/ChangeLog @@ -1,3 +1,29 @@ +2015-11-14 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20151111 + + * meta.sys.mk: include sys.dependfile.mk + + * sys.mk (OPTIONS_DEFAULT_NO): use options.mk + to set MK_AUTO_OBJ and MK_DIRDEPS_BUILD + include local.sys.env.mk early + include local.sys.mk later + + * own.mk (OPTIONS_DEFAULT_NO): AUTO_OBJ etc moved to sys.mk + +2015-11-13 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.sys.mk (META_COOKIE_TOUCH): + add ${META_COOKIE_TOUCH} to the end of scripts to touch cookie + + * meta.stage.mk: stage_libs should ignore SYMLINKS. + +2015-10-23 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20151022 + + * sys.mk: BSD/OS does not have 'type' as a shell builtin. + 2015-10-20 Simon J. Gerraty <sjg@bad.crufty.net> * install-mk (MK_VERSION): 20151020 @@ -460,7 +486,7 @@ needed. * gendirdeps.mk: only produce unqualified deps if no .MAKE.DEPENDFILE_PREFERENCE ends in .${MACHINE} - * meta.subdir.mk: apply SUBDIREPS_FILTER + * meta.subdir.mk: apply SUBDIRDEPS_FILTER 2012-04-20 Simon J. Gerraty <sjg@bad.crufty.net> diff --git a/contrib/bmake/mk/host-target.mk b/contrib/bmake/mk/host-target.mk index b67c34d..f528db9 100644 --- a/contrib/bmake/mk/host-target.mk +++ b/contrib/bmake/mk/host-target.mk @@ -1,5 +1,5 @@ # RCSid: -# $Id: host-target.mk,v 1.9 2015/09/10 18:42:57 sjg Exp $ +# $Id: host-target.mk,v 1.11 2015/10/25 00:07:20 sjg Exp $ # Host platform information; may be overridden .if !defined(_HOST_OSNAME) @@ -21,7 +21,7 @@ _HOST_ARCH := ${_HOST_MACHINE} .else _HOST_ARCH != uname -p 2> /dev/null || uname -m # uname -p may produce garbage on linux -.if ${_HOST_ARCH:[\#]} > 1 +.if ${_HOST_ARCH:[\#]} > 1 || ${_HOST_ARCH:Nunknown} == "" _HOST_ARCH := ${_HOST_MACHINE} .endif .endif @@ -33,10 +33,10 @@ HOST_MACHINE := ${_HOST_MACHINE} .endif HOST_OSMAJOR := ${_HOST_OSREL:C/[^0-9].*//} -HOST_OSTYPE := ${_HOST_OSNAME}-${_HOST_OSREL:C/\([^\)]*\)//}-${_HOST_ARCH} +HOST_OSTYPE := ${_HOST_OSNAME:S,/,,g}-${_HOST_OSREL:C/\([^\)]*\)//}-${_HOST_ARCH} HOST_OS := ${_HOST_OSNAME} host_os := ${_HOST_OSNAME:tl} -HOST_TARGET := ${host_os}${HOST_OSMAJOR}-${_HOST_ARCH} +HOST_TARGET := ${host_os:S,/,,g}${HOST_OSMAJOR}-${_HOST_ARCH} # tr is insanely non-portable, accommodate the lowest common denominator TR ?= tr diff --git a/contrib/bmake/mk/init.mk b/contrib/bmake/mk/init.mk index e700370..43561b5 100644 --- a/contrib/bmake/mk/init.mk +++ b/contrib/bmake/mk/init.mk @@ -1,4 +1,4 @@ -# $Id: init.mk,v 1.9 2013/07/18 05:46:24 sjg Exp $ +# $Id: init.mk,v 1.10 2015/12/07 04:28:31 sjg Exp $ # # @(#) Copyright (c) 2002, Simon J. Gerraty # @@ -47,4 +47,8 @@ PROFFLAGS?= -DGPROF -DPROF _SKIP_BUILD = not building at level 0 .endif +.if !empty(_SKIP_BUILD) +all: .PHONY +.warning ${_SKIP_BUILD} +.endif .endif diff --git a/contrib/bmake/mk/install-mk b/contrib/bmake/mk/install-mk index eca75e0..d2500da 100644 --- a/contrib/bmake/mk/install-mk +++ b/contrib/bmake/mk/install-mk @@ -55,7 +55,7 @@ # Simon J. Gerraty <sjg@crufty.net> # RCSid: -# $Id: install-mk,v 1.115 2015/10/20 22:04:53 sjg Exp $ +# $Id: install-mk,v 1.117 2015/11/14 18:09:57 sjg Exp $ # # @(#) Copyright (c) 1994 Simon J. Gerraty # @@ -70,7 +70,7 @@ # sjg@crufty.net # -MK_VERSION=20151020 +MK_VERSION=20151111 OWNER= GROUP= MODE=444 diff --git a/contrib/bmake/mk/lib.mk b/contrib/bmake/mk/lib.mk index 417aa02..c76fd9b 100644 --- a/contrib/bmake/mk/lib.mk +++ b/contrib/bmake/mk/lib.mk @@ -1,4 +1,4 @@ -# $Id: lib.mk,v 1.51 2014/05/23 01:30:36 sjg Exp $ +# $Id: lib.mk,v 1.52 2015/11/14 18:09:57 sjg Exp $ .if !target(__${.PARSEFILE}__) __${.PARSEFILE}__: @@ -254,7 +254,7 @@ DLLIB ?= -ldl # is a waste of time, this tells meta.autodep.mk to just pick one # (typically .So) # yes, 42 is a random number. -.if ${MK_META_MODE} == "yes" && ${SRCS:Uno:[\#]} > 42 +.if ${MK_DIRDEPS_BUILD} == "yes" && ${SRCS:Uno:[\#]} > 42 OPTIMIZE_OBJECT_META_FILES ?= yes .endif diff --git a/contrib/bmake/mk/meta.autodep.mk b/contrib/bmake/mk/meta.autodep.mk index a062e47..c9fdb0e 100644 --- a/contrib/bmake/mk/meta.autodep.mk +++ b/contrib/bmake/mk/meta.autodep.mk @@ -1,4 +1,4 @@ -# $Id: meta.autodep.mk,v 1.37 2015/06/16 06:29:17 sjg Exp $ +# $Id: meta.autodep.mk,v 1.39 2015/12/07 04:35:32 sjg Exp $ # # @(#) Copyright (c) 2010, Simon J. Gerraty @@ -50,6 +50,9 @@ UPDATE_DEPENDFILE = NO .endif _CURDIR ?= ${.CURDIR} +_OBJDIR ?= ${.OBJDIR} +_OBJTOP ?= ${OBJTOP} +_OBJROOT ?= ${OBJROOT:U${_OBJTOP}} _DEPENDFILE := ${_CURDIR}/${.MAKE.DEPENDFILE:T} .if ${.MAKE.LEVEL} == 0 @@ -190,7 +193,7 @@ gendirdeps: ${_DEPENDFILE} # anything which matches ${_OBJROOT}* but not ${_OBJTOP}* # needs to be qualified in DIRDEPS # The pseudo machine "host" is used for HOST_TARGET -DIRDEPS = \ +DIRDEPS += \ ${DPADD:M${_OBJTOP}*:H:C,${_OBJTOP}[^/]*/,,:N.:O:u} \ ${DPADD:M${_OBJROOT}*:N${_OBJTOP}*:H:S,${_OBJROOT},,:C,^([^/]+)/(.*),\2.\1,:S,${HOST_TARGET}$,host,:N.*:O:u} diff --git a/contrib/bmake/mk/meta.stage.mk b/contrib/bmake/mk/meta.stage.mk index 4337c0e..b77b27a 100644 --- a/contrib/bmake/mk/meta.stage.mk +++ b/contrib/bmake/mk/meta.stage.mk @@ -1,4 +1,4 @@ -# $Id: meta.stage.mk,v 1.40 2015/10/04 17:36:54 sjg Exp $ +# $Id: meta.stage.mk,v 1.41 2015/11/13 17:34:04 sjg Exp $ # # @(#) Copyright (c) 2011, Simon J. Gerraty # @@ -155,7 +155,7 @@ stage_libs: .dirdep @${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} \ ${SHLIB_LINKS:@t@${STAGE_LIBS:T:M$t.*} $t@} .elif !empty(SHLIB_LINK) && !empty(SHLIB_NAME) - @${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} ${SHLIB_NAME} ${SHLIB_LINK} ${SYMLINKS:T} + @${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} ${SHLIB_NAME} ${SHLIB_LINK} .endif .endif @touch $@ diff --git a/contrib/bmake/mk/meta.subdir.mk b/contrib/bmake/mk/meta.subdir.mk index 2b739ee..d27de10 100644 --- a/contrib/bmake/mk/meta.subdir.mk +++ b/contrib/bmake/mk/meta.subdir.mk @@ -1,4 +1,4 @@ -# $Id: meta.subdir.mk,v 1.10 2012/07/03 05:26:46 sjg Exp $ +# $Id: meta.subdir.mk,v 1.11 2015/11/24 22:26:51 sjg Exp $ # # @(#) Copyright (c) 2010, Simon J. Gerraty @@ -62,7 +62,7 @@ _subdeps != cd ${.CURDIR} && \ DIRDEPS = .else # clean up if needed -DIRDEPS := ${DIRDEPS:S,^./,,:S,/./,/,g:${SUBDIREPS_FILTER:Uu}} +DIRDEPS := ${DIRDEPS:S,^./,,:S,/./,/,g:${SUBDIRDEPS_FILTER:Uu}} .endif # we just dealt with it, if we leave it defined, # dirdeps.mk will compute some interesting combinations. diff --git a/contrib/bmake/mk/meta.sys.mk b/contrib/bmake/mk/meta.sys.mk index 1d1ba53..8e55878 100644 --- a/contrib/bmake/mk/meta.sys.mk +++ b/contrib/bmake/mk/meta.sys.mk @@ -1,4 +1,4 @@ -# $Id: meta.sys.mk,v 1.22 2015/06/16 06:31:05 sjg Exp $ +# $Id: meta.sys.mk,v 1.26 2015/11/14 21:16:13 sjg Exp $ # # @(#) Copyright (c) 2010, Simon J. Gerraty @@ -51,17 +51,6 @@ META_MODE += silent=yes .endif .endif -# make defaults .MAKE.DEPENDFILE to .depend -# that won't work for us. -.if ${.MAKE.DEPENDFILE} == ".depend" -.undef .MAKE.DEPENDFILE -.endif - -# if you don't cross build for multiple MACHINEs concurrently, then -# .MAKE.DEPENDFILE = Makefile.depend -# probably makes sense - you can set that in local.sys.mk -.MAKE.DEPENDFILE ?= Makefile.depend.${MACHINE} - # we use the pseudo machine "host" for the build host. # this should be taken care of before we get here .if ${OBJTOP:Ua} == ${HOST_OBJTOP:Ub} @@ -109,10 +98,27 @@ _metaError: .NOMETA .NOTMAIN .endif +META_COOKIE_TOUCH= +# some targets need to be .PHONY in non-meta mode +META_NOPHONY= .PHONY # Are we, after all, in meta mode? .if ${.MAKE.MODE:Mmeta*} != "" MKDEP_MK = meta.autodep.mk +.if ${.MAKE.MAKEFILES:M*sys.dependfile.mk} == "" +# this does all the smarts of setting .MAKE.DEPENDFILE +.-include <sys.dependfile.mk> +# check if we got anything sane +.if ${.MAKE.DEPENDFILE} == ".depend" +.undef .MAKE.DEPENDFILE +.endif +.MAKE.DEPENDFILE ?= Makefile.depend +.endif + +# we can afford to use cookies to prevent some targets +# re-running needlessly +META_COOKIE_TOUCH= touch ${COOKIE.${.TARGET}:U${.OBJDIR}/${.TARGET}} +META_NOPHONY= .if ${UPDATE_DEPENDFILE:Uyes:tl} != "no" .if ${.MAKEFLAGS:Uno:M-k} != "" # make this more obvious diff --git a/contrib/bmake/mk/own.mk b/contrib/bmake/mk/own.mk index 3fdb16b..070044f 100644 --- a/contrib/bmake/mk/own.mk +++ b/contrib/bmake/mk/own.mk @@ -1,4 +1,4 @@ -# $Id: own.mk,v 1.29 2015/09/08 06:15:31 sjg Exp $ +# $Id: own.mk,v 1.30 2015/11/14 18:09:57 sjg Exp $ .if !target(__${.PARSEFILE}__) __${.PARSEFILE}__: @@ -89,12 +89,10 @@ OPTIONS_DEFAULT_NO+= DPADD_MK # process options OPTIONS_DEFAULT_NO+= \ - AUTO_OBJ \ INSTALL_AS_USER \ GPROF \ LIBTOOL \ LINT \ - META_MODE \ OPTIONS_DEFAULT_YES+= \ ARCHIVE \ diff --git a/contrib/bmake/mk/sys.mk b/contrib/bmake/mk/sys.mk index 236f62d..9dc0796 100644 --- a/contrib/bmake/mk/sys.mk +++ b/contrib/bmake/mk/sys.mk @@ -1,4 +1,4 @@ -# $Id: sys.mk,v 1.36 2014/05/11 00:30:19 sjg Exp $ +# $Id: sys.mk,v 1.41 2015/11/14 20:20:34 sjg Exp $ # # @(#) Copyright (c) 2003-2009, Simon J. Gerraty # @@ -75,8 +75,12 @@ M_L_TARGETS = ${M_ListToMatch:S,V,_TARGETS,} M_ListToSkip= O:u:ts::S,:,:N,g:S,^,N, # type should be a builtin in any sh since about 1980, +# but sadly there are exceptions! +.if ${.MAKE.OS:Unknown:NBSD/OS} == "" +_type_sh = which +.endif # AUTOCONF := ${autoconf:L:${M_whence}} -M_type = @x@(type $$x 2> /dev/null); echo;@:sh:[0]:N* found*:[@]:C,[()],,g +M_type = @x@(${_type_sh:Utype} $$x) 2> /dev/null; echo;@:sh:[0]:N* found*:[@]:C,[()],,g M_whence = ${M_type}:M/*:[1] # convert a path to a valid shell variable @@ -102,6 +106,9 @@ _TARGETS := ${.TARGETS} # we need HOST_TARGET etc below. .include <host-target.mk> +# early customizations +.-include <local.sys.env.mk> + # find the OS specifics .if defined(SYS_OS_MK) .include <${SYS_OS_MK}> @@ -126,11 +133,30 @@ SYS_OS_MK := ${_sys_mk} .export SYS_OS_MK .endif -# allow customization without editing. -.-include <local.sys.mk> +# some options we need to know early +OPTIONS_DEFAULT_NO += \ + DIRDEPS_BUILD \ + DIRDEPS_CACHE \ + META_MODE + +OPTIONS_DEFAULT_DEPENDENT += \ + AUTO_OBJ/DIRDEPS_BUILD \ + STAGING/DIRDEPS_BUILD \ + +.-include "options.mk" + +.if ${MK_DIRDEPS_BUILD:Uno} == "yes" +MK_META_MODE = yes +.-include <meta.sys.mk> +.elif ${MK_META_MODE:Uno} == "yes" +.MAKE.MODE = meta verbose +.endif +# make sure we have a harmless value +.MAKE.MODE ?= normal # if you want objdirs make them automatic -.if ${MKOBJDIRS:Uno} == "auto" +# and do it early before we compute .PATH +.if ${MK_AUTO_OBJ:Uno} == "yes" || ${MKOBJDIRS:Uno} == "auto" .include <auto.obj.mk> .endif @@ -178,17 +204,8 @@ Mkdirs= Mkdirs() { \ .cc.cpp-out: @${COMPILE.cc:N-c} -E ${.IMPSRC} | grep -v '^[ ]*$$' -# we don't include own.mk but user can expect -DWITH_META_MODE to work -.if defined(WITHOUT_META_MODE) -USE_META= no -.elif defined(WITH_META_MODE) -USE_META= yes -.endif -.if ${USE_META:Uno} == "yes" -.-include <meta.sys.mk> -.endif -# make sure we have a harmless value -.MAKE.MODE ?= normal +# late customizations +.-include <local.sys.mk> # if .CURDIR is matched by any entry in DEBUG_MAKE_DIRS we # will apply DEBUG_MAKE_FLAGS, now. diff --git a/contrib/bmake/os.sh b/contrib/bmake/os.sh index 1df67b8..93d4387 100755 --- a/contrib/bmake/os.sh +++ b/contrib/bmake/os.sh @@ -17,7 +17,7 @@ # Simon J. Gerraty <sjg@crufty.net> # RCSid: -# $Id: os.sh,v 1.47 2015/09/10 05:53:10 sjg Exp $ +# $Id: os.sh,v 1.49 2015/10/25 00:05:40 sjg Exp $ # # @(#) Copyright (c) 1994 Simon J. Gerraty # @@ -44,7 +44,7 @@ MACHINE_ARCH=`uname -p 2>/dev/null || echo $MACHINE` # there is at least one case of `uname -p` outputting # a bunch of usless drivel case "$MACHINE_ARCH" in -*[!A-Za-z0-9_-]*) MACHINE_ARCH="$MACHINE";; +unknown|*[!A-Za-z0-9_-]*) MACHINE_ARCH="$MACHINE";; esac # we need this here, and it is not always available... @@ -213,7 +213,7 @@ LN=${LN:-ln} TR=${TR:-tr} # Some people like have /share/$HOST_TARGET/bin etc. -HOST_TARGET=`echo ${OS}${OSMAJOR}-$HOST_ARCH | toLower` +HOST_TARGET=`echo ${OS}${OSMAJOR}-$HOST_ARCH | tr -d / | toLower` export HOST_TARGET case `echo -n .` in -n*) N=; C="\c";; *) N=-n; C=;; esac diff --git a/contrib/bmake/parse.c b/contrib/bmake/parse.c index 71735cb..7f3afbd 100644 --- a/contrib/bmake/parse.c +++ b/contrib/bmake/parse.c @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.205 2015/10/11 04:51:24 sjg Exp $ */ +/* $NetBSD: parse.c,v 1.206 2015/11/26 00:23:04 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: parse.c,v 1.205 2015/10/11 04:51:24 sjg Exp $"; +static char rcsid[] = "$NetBSD: parse.c,v 1.206 2015/11/26 00:23:04 sjg Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: parse.c,v 1.205 2015/10/11 04:51:24 sjg Exp $"); +__RCSID("$NetBSD: parse.c,v 1.206 2015/11/26 00:23:04 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -508,7 +508,11 @@ loadfile(const char *path, int fd) #ifdef HAVE_MMAP if (load_getsize(fd, &lf->len) == SUCCESS) { /* found a size, try mmap */ +#ifdef _SC_PAGESIZE pagesize = sysconf(_SC_PAGESIZE); +#else + pagesize = 0; +#endif if (pagesize <= 0) { pagesize = 0x1000; } diff --git a/contrib/bmake/unit-tests/Makefile.in b/contrib/bmake/unit-tests/Makefile.in index 6974d48..4ee94bd 100644 --- a/contrib/bmake/unit-tests/Makefile.in +++ b/contrib/bmake/unit-tests/Makefile.in @@ -1,4 +1,4 @@ -# $Id: Makefile.in,v 1.47 2015/05/05 21:58:06 sjg Exp $ +# $Id: Makefile.in,v 1.48 2015/12/07 04:06:29 sjg Exp $ # # $NetBSD: Makefile,v 1.52 2015/05/05 21:51:09 sjg Exp $ # @@ -128,7 +128,7 @@ SED_CMDS.varshell = -e 's,^[a-z]*sh: ,,' \ test: ${OUTFILES} .PHONY @failed= ; \ for test in ${TESTNAMES}; do \ - ${TOOL_DIFF} -u ${UNIT_TESTS}/$${test}.exp $${test}.out \ + ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \ || failed="$${failed}$${failed:+ }$${test}" ; \ done ; \ if [ -n "$${failed}" ]; then \ diff --git a/contrib/bmake/unit-tests/cond2.mk b/contrib/bmake/unit-tests/cond2.mk index d6a0620..943df43 100644 --- a/contrib/bmake/unit-tests/cond2.mk +++ b/contrib/bmake/unit-tests/cond2.mk @@ -1,4 +1,4 @@ -# $Id: cond2.mk,v 1.1.1.1 2015/05/05 21:53:13 sjg Exp $ +# $Id: cond2.mk,v 1.1.1.2 2015/12/02 00:34:27 sjg Exp $ TEST_UNAME_S= NetBSD @@ -21,5 +21,9 @@ Y!= echo TEST_NOT_SET is empty or not defined >&2; echo Y= oops .endif +.if defined(.NDEF) && ${.NDEF} > 0 +Z= yes +.endif + all: @echo $@ diff --git a/contrib/bmake/unit-tests/doterror.exp b/contrib/bmake/unit-tests/doterror.exp index 0447a51..5655644 100644 --- a/contrib/bmake/unit-tests/doterror.exp +++ b/contrib/bmake/unit-tests/doterror.exp @@ -1,9 +1,9 @@ At first, I am happy and now: sad -.ERROR: Looks like 'sad' is upset. *** Error code 1 Stop. make: stopped in unit-tests +.ERROR: Looks like 'sad' is upset. exit status 1 diff --git a/contrib/bmake/unit-tests/modts.mk b/contrib/bmake/unit-tests/modts.mk index 616bd89..54b3d3d 100644 --- a/contrib/bmake/unit-tests/modts.mk +++ b/contrib/bmake/unit-tests/modts.mk @@ -12,9 +12,9 @@ all: mod-ts # Use print or printf iff they are builtin. # XXX note that this causes problems, when make decides # there is no need to use a shell, so avoid where possible. -.if ${type print 2> /dev/null || echo:L:sh:Mbuiltin} != "" +.if ${(type print) 2> /dev/null || echo:L:sh:Mbuiltin} != "" PRINT= print -r -- -.elif ${type printf 2> /dev/null || echo:L:sh:Mbuiltin} != "" +.elif ${(type printf) 2> /dev/null || echo:L:sh:Mbuiltin} != "" PRINT= printf '%s\n' .else PRINT= echo diff --git a/contrib/bmake/var.c b/contrib/bmake/var.c index 6fd3825..43429e2 100644 --- a/contrib/bmake/var.c +++ b/contrib/bmake/var.c @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.199 2015/10/20 21:30:57 sjg Exp $ */ +/* $NetBSD: var.c,v 1.200 2015/12/01 07:26:08 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.199 2015/10/20 21:30:57 sjg Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.200 2015/12/01 07:26:08 sjg Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: var.c,v 1.199 2015/10/20 21:30:57 sjg Exp $"); +__RCSID("$NetBSD: var.c,v 1.200 2015/12/01 07:26:08 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -129,7 +129,6 @@ __RCSID("$NetBSD: var.c,v 1.199 2015/10/20 21:30:57 sjg Exp $"); #include <regex.h> #endif #include <ctype.h> -#include <inttypes.h> #include <stdlib.h> #include <limits.h> #include <time.h> @@ -702,13 +701,15 @@ Var_ExportVars(void) int i; val = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE); - av = brk_string(val, &ac, FALSE, &as); - for (i = 0; i < ac; i++) { - Var_Export1(av[i], 0); + if (*val) { + av = brk_string(val, &ac, FALSE, &as); + for (i = 0; i < ac; i++) { + Var_Export1(av[i], 0); + } + free(as); + free(av); } free(val); - free(as); - free(av); } } @@ -740,35 +741,37 @@ Var_Export(char *str, int isExport) track = VAR_EXPORT_PARENT; } val = Var_Subst(NULL, str, VAR_GLOBAL, FALSE, TRUE); - av = brk_string(val, &ac, FALSE, &as); - for (i = 0; i < ac; i++) { - name = av[i]; - if (!name[1]) { - /* - * A single char. - * If it is one of the vars that should only appear in - * local context, skip it, else we can get Var_Subst - * into a loop. - */ - switch (name[0]) { - case '@': - case '%': - case '*': - case '!': - continue; + if (*val) { + av = brk_string(val, &ac, FALSE, &as); + for (i = 0; i < ac; i++) { + name = av[i]; + if (!name[1]) { + /* + * A single char. + * If it is one of the vars that should only appear in + * local context, skip it, else we can get Var_Subst + * into a loop. + */ + switch (name[0]) { + case '@': + case '%': + case '*': + case '!': + continue; + } } - } - if (Var_Export1(name, track)) { - if (VAR_EXPORTED_ALL != var_exportedVars) - var_exportedVars = VAR_EXPORTED_YES; - if (isExport && track) { - Var_Append(MAKE_EXPORTED, name, VAR_GLOBAL); + if (Var_Export1(name, track)) { + if (VAR_EXPORTED_ALL != var_exportedVars) + var_exportedVars = VAR_EXPORTED_YES; + if (isExport && track) { + Var_Append(MAKE_EXPORTED, name, VAR_GLOBAL); + } } } + free(as); + free(av); } free(val); - free(as); - free(av); } @@ -2306,7 +2309,7 @@ VarHash(char *str) Buffer buf; size_t len, len2; unsigned char *ustr = (unsigned char *)str; - uint32_t h, k, c1, c2; + unsigned int h, k, c1, c2; h = 0x971e137bU; c1 = 0x95543787U; diff --git a/contrib/elftoolchain/elfcopy/binary.c b/contrib/elftoolchain/elfcopy/binary.c index 23e46e7..6213623 100644 --- a/contrib/elftoolchain/elfcopy/binary.c +++ b/contrib/elftoolchain/elfcopy/binary.c @@ -37,6 +37,16 @@ ELFTC_VCSID("$Id: binary.c 3174 2015-03-27 17:13:41Z emaste $"); +static int +basename_length(const char *filename) +{ + char *p; + + if ((p = strchr(filename, '.')) != NULL) + return (p - filename); + return (strlen(filename)); +} + /* * Convert ELF object to `binary'. Sections with SHF_ALLOC flag set * are copied to the result binary. The relative offsets for each section @@ -211,7 +221,8 @@ create_elf_from_binary(struct elfcopy *ecp, int ifd, const char *ifn) shtab->sz += gelf_fsize(ecp->eout, ELF_T_SHDR, 2, EV_CURRENT); #define _GEN_SYMNAME(S) do { \ - snprintf(name, sizeof(name), "%s%s%s", "_binary_", ifn, S); \ + snprintf(name, sizeof(name), "%s%.*s%s", "_binary_", \ + basename_length(ifn), ifn, S); \ } while (0) /* diff --git a/include/resolv.h b/include/resolv.h index 78da374..f372f94 100644 --- a/include/resolv.h +++ b/include/resolv.h @@ -57,6 +57,7 @@ #include <sys/types.h> #include <sys/cdefs.h> #include <sys/socket.h> +#include <sys/timespec.h> #include <stdio.h> #include <arpa/nameser.h> diff --git a/kerberos5/lib/libgssapi_krb5/Makefile.depend b/kerberos5/lib/libgssapi_krb5/Makefile.depend index e37825c..4d9610a 100644 --- a/kerberos5/lib/libgssapi_krb5/Makefile.depend +++ b/kerberos5/lib/libgssapi_krb5/Makefile.depend @@ -18,7 +18,6 @@ DIRDEPS = \ lib/libcom_err \ lib/libcompiler_rt \ lib/libgssapi \ - lib/libthr \ secure/lib/libcrypto \ diff --git a/kerberos5/lib/libgssapi_ntlm/Makefile.depend b/kerberos5/lib/libgssapi_ntlm/Makefile.depend index db48cf0..fe01ea6 100644 --- a/kerberos5/lib/libgssapi_ntlm/Makefile.depend +++ b/kerberos5/lib/libgssapi_ntlm/Makefile.depend @@ -15,7 +15,6 @@ DIRDEPS = \ lib/libc \ lib/libcompiler_rt \ lib/libgssapi \ - lib/libthr \ secure/lib/libcrypto \ diff --git a/kerberos5/lib/libhdb/Makefile.depend b/kerberos5/lib/libhdb/Makefile.depend index 38020be..227302e 100644 --- a/kerberos5/lib/libhdb/Makefile.depend +++ b/kerberos5/lib/libhdb/Makefile.depend @@ -18,7 +18,6 @@ DIRDEPS = \ lib/libcom_err \ lib/libcompiler_rt \ lib/libsqlite3 \ - lib/libthr \ secure/lib/libcrypto \ diff --git a/kerberos5/lib/libheimntlm/Makefile.depend b/kerberos5/lib/libheimntlm/Makefile.depend index ff20bce..9e9f631 100644 --- a/kerberos5/lib/libheimntlm/Makefile.depend +++ b/kerberos5/lib/libheimntlm/Makefile.depend @@ -14,7 +14,6 @@ DIRDEPS = \ lib/libc \ lib/libcom_err \ lib/libcompiler_rt \ - lib/libthr \ secure/lib/libcrypto \ diff --git a/kerberos5/lib/libkadm5clnt/Makefile.depend b/kerberos5/lib/libkadm5clnt/Makefile.depend index 8b5c57d..f1c4cb5 100644 --- a/kerberos5/lib/libkadm5clnt/Makefile.depend +++ b/kerberos5/lib/libkadm5clnt/Makefile.depend @@ -15,7 +15,6 @@ DIRDEPS = \ lib/libc \ lib/libcom_err \ lib/libcompiler_rt \ - lib/libthr \ .include <dirdeps.mk> diff --git a/kerberos5/lib/libkadm5srv/Makefile.depend b/kerberos5/lib/libkadm5srv/Makefile.depend index bf42cd8..1b24784 100644 --- a/kerberos5/lib/libkadm5srv/Makefile.depend +++ b/kerberos5/lib/libkadm5srv/Makefile.depend @@ -15,7 +15,6 @@ DIRDEPS = \ lib/libc \ lib/libcom_err \ lib/libcompiler_rt \ - lib/libthr \ .include <dirdeps.mk> diff --git a/kerberos5/lib/libkafs5/Makefile.depend b/kerberos5/lib/libkafs5/Makefile.depend index e8bb93c..5649824 100644 --- a/kerberos5/lib/libkafs5/Makefile.depend +++ b/kerberos5/lib/libkafs5/Makefile.depend @@ -13,7 +13,6 @@ DIRDEPS = \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ - lib/libthr \ secure/lib/libcrypto \ diff --git a/kerberos5/lib/libkdc/Makefile.depend b/kerberos5/lib/libkdc/Makefile.depend index 2f174fa..384382b 100644 --- a/kerberos5/lib/libkdc/Makefile.depend +++ b/kerberos5/lib/libkdc/Makefile.depend @@ -19,7 +19,6 @@ DIRDEPS = \ lib/libc \ lib/libcom_err \ lib/libcompiler_rt \ - lib/libthr \ lib/libutil \ secure/lib/libcrypto \ diff --git a/lib/csu/aarch64/crt1.c b/lib/csu/aarch64/crt1.c index be59317..ed24f46 100644 --- a/lib/csu/aarch64/crt1.c +++ b/lib/csu/aarch64/crt1.c @@ -32,12 +32,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#ifndef lint -#ifndef __GNUC__ -#error "GCC is needed to compile this file" -#endif -#endif /* lint */ - #include <stdlib.h> #include "libc_private.h" diff --git a/lib/csu/amd64/crt1.c b/lib/csu/amd64/crt1.c index 3740e73..c4f07e0 100644 --- a/lib/csu/amd64/crt1.c +++ b/lib/csu/amd64/crt1.c @@ -27,12 +27,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#ifndef lint -#ifndef __GNUC__ -#error "GCC is needed to compile this file" -#endif -#endif /* lint */ - #include <stdlib.h> #include "libc_private.h" diff --git a/lib/csu/arm/crt1.c b/lib/csu/arm/crt1.c index d2fbab3..5dec5e5 100644 --- a/lib/csu/arm/crt1.c +++ b/lib/csu/arm/crt1.c @@ -42,12 +42,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#ifndef lint -#ifndef __GNUC__ -#error "GCC is needed to compile this file" -#endif -#endif /* lint */ - #include <stdlib.h> #include "libc_private.h" diff --git a/lib/csu/i386/crt1_c.c b/lib/csu/i386/crt1_c.c index 65de04c..8b16f16 100644 --- a/lib/csu/i386/crt1_c.c +++ b/lib/csu/i386/crt1_c.c @@ -29,12 +29,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#ifndef lint -#ifndef __GNUC__ -#error "GCC is needed to compile this file" -#endif -#endif /* lint */ - #include <stdlib.h> #include "libc_private.h" diff --git a/lib/csu/mips/crt1.c b/lib/csu/mips/crt1.c index 95348b7..4030ce0 100644 --- a/lib/csu/mips/crt1.c +++ b/lib/csu/mips/crt1.c @@ -36,10 +36,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#ifndef __GNUC__ -#error "GCC is needed to compile this file" -#endif - #include <stdlib.h> #include "libc_private.h" #include "crtbrand.c" diff --git a/lib/csu/powerpc/crt1.c b/lib/csu/powerpc/crt1.c index d1a3ea0..4e41bf7 100644 --- a/lib/csu/powerpc/crt1.c +++ b/lib/csu/powerpc/crt1.c @@ -42,12 +42,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#ifndef lint -#ifndef __GNUC__ -#error "GCC is needed to compile this file" -#endif -#endif /* lint */ - #include <stdlib.h> #include "libc_private.h" diff --git a/lib/csu/powerpc64/crt1.c b/lib/csu/powerpc64/crt1.c index 35c5a6e..3ae5250 100644 --- a/lib/csu/powerpc64/crt1.c +++ b/lib/csu/powerpc64/crt1.c @@ -42,12 +42,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#ifndef lint -#ifndef __GNUC__ -#error "GCC is needed to compile this file" -#endif -#endif /* lint */ - #include <stdlib.h> #include "libc_private.h" diff --git a/lib/csu/sparc64/crt1.c b/lib/csu/sparc64/crt1.c index e11ae39..35132b8 100644 --- a/lib/csu/sparc64/crt1.c +++ b/lib/csu/sparc64/crt1.c @@ -33,12 +33,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#ifndef lint -#ifndef __GNUC__ -#error "GCC is needed to compile this file" -#endif -#endif /* lint */ - #include <stdlib.h> #include "libc_private.h" diff --git a/lib/lib80211/Makefile.depend b/lib/lib80211/Makefile.depend index 806b5fd..7f43259 100644 --- a/lib/lib80211/Makefile.depend +++ b/lib/lib80211/Makefile.depend @@ -10,6 +10,7 @@ DIRDEPS = \ lib/libc \ lib/libcompiler_rt \ lib/libexpat \ + lib/libsbuf \ .include <dirdeps.mk> diff --git a/lib/libc/aarch64/sys/Makefile.inc b/lib/libc/aarch64/sys/Makefile.inc index cb56f73..b33b568 100644 --- a/lib/libc/aarch64/sys/Makefile.inc +++ b/lib/libc/aarch64/sys/Makefile.inc @@ -1,6 +1,6 @@ # $FreeBSD$ -SRCS+= trivial-vdso_tc.c +SRCS+= __vdso_gettc.c #MDASM= ptrace.S MDASM= brk.S \ diff --git a/lib/libc/aarch64/sys/__vdso_gettc.c b/lib/libc/aarch64/sys/__vdso_gettc.c new file mode 100644 index 0000000..f9015e2 --- /dev/null +++ b/lib/libc/aarch64/sys/__vdso_gettc.c @@ -0,0 +1,74 @@ +/*- + * Copyright (c) 2015 The FreeBSD Foundation + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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 <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/elf.h> +#include <sys/time.h> +#include <sys/vdso.h> +#include <machine/cpufunc.h> +#include "libc_private.h" + +static inline uint64_t +cp15_cntvct_get(void) +{ + uint64_t reg; + + __asm __volatile("mrs %0, cntvct_el0" : "=r" (reg)); + return (reg); +} + +static inline uint64_t +cp15_cntpct_get(void) +{ + uint64_t reg; + + __asm __volatile("mrs %0, cntpct_el0" : "=r" (reg)); + return (reg); +} + +#pragma weak __vdso_gettc +u_int +__vdso_gettc(const struct vdso_timehands *th) +{ + uint64_t val; + + __asm __volatile("isb" : : : "memory"); + val = th->th_physical == 0 ? cp15_cntvct_get() : cp15_cntpct_get(); + return (val); +} + +#pragma weak __vdso_gettimekeep +int +__vdso_gettimekeep(struct vdso_timekeep **tk) +{ + + return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk))); +} diff --git a/lib/libc/arm/sys/Makefile.inc b/lib/libc/arm/sys/Makefile.inc index 60c2dc3..5e89109 100644 --- a/lib/libc/arm/sys/Makefile.inc +++ b/lib/libc/arm/sys/Makefile.inc @@ -1,6 +1,6 @@ # $FreeBSD$ -SRCS+= trivial-vdso_tc.c +SRCS+= __vdso_gettc.c MDASM= Ovfork.S brk.S cerror.S pipe.S ptrace.S sbrk.S shmat.S sigreturn.S syscall.S diff --git a/lib/libc/arm/sys/__vdso_gettc.c b/lib/libc/arm/sys/__vdso_gettc.c new file mode 100644 index 0000000..d75d866 --- /dev/null +++ b/lib/libc/arm/sys/__vdso_gettc.c @@ -0,0 +1,79 @@ +/*- + * Copyright (c) 2015 The FreeBSD Foundation + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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 <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/elf.h> +#include <sys/time.h> +#include <sys/vdso.h> +#include <machine/cpufunc.h> +#include "libc_private.h" + +static inline uint64_t +cp15_cntvct_get(void) +{ + uint64_t reg; + + __asm __volatile("mrrc\tp15, 1, %Q0, %R0, c14" : "=r" (reg)); + return (reg); +} + +static inline uint64_t +cp15_cntpct_get(void) +{ + uint64_t reg; + + __asm __volatile("mrrc\tp15, 0, %Q0, %R0, c14" : "=r" (reg)); + return (reg); +} + +#pragma weak __vdso_gettc +u_int +__vdso_gettc(const struct vdso_timehands *th) +{ + uint64_t val; + + /* + * Userspace gettimeofday() is only enabled on ARMv7 CPUs, but + * libc is compiled for ARMv6. Due to clang issues, .arch + * armv7-a directive does not work. + */ + __asm __volatile(".word\t0xf57ff06f" : : : "memory"); /* isb */ + val = th->th_physical == 0 ? cp15_cntvct_get() : cp15_cntpct_get(); + return (val); +} + +#pragma weak __vdso_gettimekeep +int +__vdso_gettimekeep(struct vdso_timekeep **tk) +{ + + return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk))); +} diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c index 4c56461..4bf0a14 100644 --- a/lib/libc/gen/getnetgrent.c +++ b/lib/libc/gen/getnetgrent.c @@ -512,6 +512,7 @@ parse_netgrp(const char *group) ng[NG_DOM] == NULL ? "" : ",", ng[NG_DOM] == NULL ? "" : ng[NG_DOM], lp->l_groupname); + } #endif } else { spos = strsep(&pos, ", \t"); diff --git a/lib/libc/stdio/open_memstream.c b/lib/libc/stdio/open_memstream.c index baa71e4..f3d1ee5 100644 --- a/lib/libc/stdio/open_memstream.c +++ b/lib/libc/stdio/open_memstream.c @@ -31,6 +31,9 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" #include <assert.h> #include <errno.h> +#ifdef DEBUG +#include <inttypes.h> +#endif #include <limits.h> #include <stdio.h> #include <stdlib.h> diff --git a/lib/libc/stdio/open_wmemstream.c b/lib/libc/stdio/open_wmemstream.c index 299e3d8..4585531 100644 --- a/lib/libc/stdio/open_wmemstream.c +++ b/lib/libc/stdio/open_wmemstream.c @@ -31,6 +31,9 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" #include <assert.h> #include <errno.h> +#ifdef DEBUG +#include <inttypes.h> +#endif #include <limits.h> #include <stdio.h> #include <stdlib.h> diff --git a/lib/libc/tests/stdio/getdelim_test.c b/lib/libc/tests/stdio/getdelim_test.c index b7596b3..37737ae 100644 --- a/lib/libc/tests/stdio/getdelim_test.c +++ b/lib/libc/tests/stdio/getdelim_test.c @@ -207,7 +207,6 @@ ATF_TC_BODY(empty_NULL_buffer, tc) /* Make sure NULL *linep and zero *linecapp are handled. */ fp = mkfilebuf(); - free(line); line = NULL; linecap = 42; ATF_REQUIRE(getline(&line, &linecap, fp) == sizeof(apothegm) - 1); diff --git a/lib/libc/tests/stdio/printbasic_test.c b/lib/libc/tests/stdio/printbasic_test.c index d1fab29..376981e 100644 --- a/lib/libc/tests/stdio/printbasic_test.c +++ b/lib/libc/tests/stdio/printbasic_test.c @@ -94,6 +94,8 @@ _testfmt(const char *result, const char *argstr, const char *fmt,...) "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]\n", wfmt, argstr, ws, wresult); } + va_end(ap); + va_end(ap2); } ATF_TC_WITHOUT_HEAD(int_within_limits); diff --git a/lib/libc/tests/stdio/printfloat_test.c b/lib/libc/tests/stdio/printfloat_test.c index 6b4e455..2319747 100644 --- a/lib/libc/tests/stdio/printfloat_test.c +++ b/lib/libc/tests/stdio/printfloat_test.c @@ -86,6 +86,8 @@ _testfmt(const char *result, const char *argstr, const char *fmt,...) "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]\n", wfmt, argstr, ws, wresult); } + va_end(ap); + va_end(ap2); } ATF_TC_WITHOUT_HEAD(float_within_limits); diff --git a/lib/libpam/modules/pam_krb5/Makefile.depend b/lib/libpam/modules/pam_krb5/Makefile.depend index 2cde78f..8bd8a57 100644 --- a/lib/libpam/modules/pam_krb5/Makefile.depend +++ b/lib/libpam/modules/pam_krb5/Makefile.depend @@ -13,7 +13,6 @@ DIRDEPS = \ lib/libcom_err \ lib/libcompiler_rt \ lib/libpam/libpam \ - lib/libthr \ .include <dirdeps.mk> diff --git a/lib/libpam/modules/pam_ksu/Makefile.depend b/lib/libpam/modules/pam_ksu/Makefile.depend index d360572..d951012 100644 --- a/lib/libpam/modules/pam_ksu/Makefile.depend +++ b/lib/libpam/modules/pam_ksu/Makefile.depend @@ -12,7 +12,6 @@ DIRDEPS = \ lib/libc \ lib/libcompiler_rt \ lib/libpam/libpam \ - lib/libthr \ .include <dirdeps.mk> diff --git a/lib/libpam/modules/pam_ssh/Makefile b/lib/libpam/modules/pam_ssh/Makefile index b5ca478..21991dc 100644 --- a/lib/libpam/modules/pam_ssh/Makefile +++ b/lib/libpam/modules/pam_ssh/Makefile @@ -12,11 +12,10 @@ SRCS+= roaming_dummy.c WARNS?= 3 CFLAGS+= -I${SSHDIR} -include ssh_namespace.h +SRCS+= ssh_namespace.h LIBADD= ssh .include <bsd.lib.mk> .PATH: ${SSHDIR} - -${OBJS} ${POBJS} ${SOBJS}: ssh_namespace.h diff --git a/sbin/newfs_msdos/mkfs_msdos.c b/sbin/newfs_msdos/mkfs_msdos.c index b14896d..0f72a85 100644 --- a/sbin/newfs_msdos/mkfs_msdos.c +++ b/sbin/newfs_msdos/mkfs_msdos.c @@ -242,38 +242,41 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) ssize_t n; time_t now; u_int fat, bss, rds, cls, dir, lsn, x, x1, x2; - int fd, fd1; + int fd, fd1, rv; struct msdos_options o = *op; + img = NULL; + rv = -1; + if (o.block_size && o.sectors_per_cluster) { warnx("Cannot specify both block size and sectors per cluster"); - return -1; + goto done; } if (o.OEM_string && strlen(o.OEM_string) > 8) { warnx("%s: bad OEM string", o.OEM_string); - return -1; + goto done; } if (o.create_size) { if (o.no_create) { warnx("create (-C) is incompatible with -N"); - return -1; + goto done; } fd = open(fname, O_RDWR | O_CREAT | O_TRUNC, 0644); if (fd == -1) { warnx("failed to create %s", fname); - return -1; + goto done; } if (ftruncate(fd, o.create_size)) { warnx("failed to initialize %jd bytes", (intmax_t)o.create_size); - return -1; + goto done; } } else if ((fd = open(fname, o.no_create ? O_RDONLY : O_RDWR)) == -1) { warn("%s", fname); - return -1; + goto done; } if (fstat(fd, &sb)) { warn("%s", fname); - return -1; + goto done; } if (o.create_size) { if (!S_ISREG(sb.st_mode)) @@ -284,15 +287,15 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) } if (!o.no_create) if (check_mounted(fname, sb.st_mode) == -1) - return -1; + goto done; if (o.offset && o.offset != lseek(fd, o.offset, SEEK_SET)) { warnx("cannot seek to %jd", (intmax_t)o.offset); - return -1; + goto done; } memset(&bpb, 0, sizeof(bpb)); if (o.floppy) { if (getstdfmt(o.floppy, &bpb) == -1) - return -1; + goto done; bpb.bpbHugeSectors = bpb.bpbSectors; bpb.bpbSectors = 0; bpb.bpbBigFATsecs = bpb.bpbFATsecs; @@ -334,17 +337,17 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) } if (!powerof2(bpb.bpbBytesPerSec)) { warnx("bytes/sector (%u) is not a power of 2", bpb.bpbBytesPerSec); - return -1; + goto done; } if (bpb.bpbBytesPerSec < MINBPS) { warnx("bytes/sector (%u) is too small; minimum is %u", bpb.bpbBytesPerSec, MINBPS); - return -1; + goto done; } if (o.volume_label && !oklabel(o.volume_label)) { warnx("%s: bad volume label", o.volume_label); - return -1; + goto done; } if (!(fat = o.fat_type)) { if (o.floppy) @@ -356,29 +359,29 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) warnx("-%c is not a legal FAT%s option", fat == 32 ? 'e' : o.info_sector ? 'i' : 'k', fat == 32 ? "32" : "12/16"); - return -1; + goto done; } if (o.floppy && fat == 32) bpb.bpbRootDirEnts = 0; if (fat != 0 && fat != 12 && fat != 16 && fat != 32) { warnx("%d: bad FAT type", fat); - return -1; + goto done; } if (o.block_size) { if (!powerof2(o.block_size)) { warnx("block size (%u) is not a power of 2", o.block_size); - return -1; + goto done; } if (o.block_size < bpb.bpbBytesPerSec) { warnx("block size (%u) is too small; minimum is %u", o.block_size, bpb.bpbBytesPerSec); - return -1; + goto done; } if (o.block_size > bpb.bpbBytesPerSec * MAXSPC) { warnx("block size (%u) is too large; maximum is %u", o.block_size, bpb.bpbBytesPerSec * MAXSPC); - return -1; + goto done; } bpb.bpbSecPerClust = o.block_size / bpb.bpbBytesPerSec; } @@ -386,7 +389,7 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) if (!powerof2(o.sectors_per_cluster)) { warnx("sectors/cluster (%u) is not a power of 2", o.sectors_per_cluster); - return -1; + goto done; } bpb.bpbSecPerClust = o.sectors_per_cluster; } @@ -396,7 +399,7 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) if (o.num_FAT > MAXNFT) { warnx("number of FATs (%u) is too large; maximum is %u", o.num_FAT, MAXNFT); - return -1; + goto done; } bpb.bpbFATs = o.num_FAT; } @@ -405,7 +408,7 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) if (o.media_descriptor_set) { if (o.media_descriptor < 0xf0) { warnx("illegal media descriptor (%#x)", o.media_descriptor); - return -1; + goto done; } bpb.bpbMedia = o.media_descriptor; } @@ -424,18 +427,18 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) snprintf(buf, sizeof(buf), "/boot/%s", bname); if (!(bname = strdup(buf))) { warn(NULL); - return -1; + goto done; } } if ((fd1 = open(bname, O_RDONLY)) == -1 || fstat(fd1, &sb)) { warn("%s", bname); - return -1; + goto done; } if (!S_ISREG(sb.st_mode) || sb.st_size % bpb.bpbBytesPerSec || sb.st_size < bpb.bpbBytesPerSec || sb.st_size > bpb.bpbBytesPerSec * MAXU16) { warnx("%s: inappropriate file type or format", bname); - return -1; + goto done; } bss = sb.st_size / bpb.bpbBytesPerSec; } @@ -470,7 +473,7 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) if (!bpb.bpbFSInfo) { if (x == MAXU16 || x == bpb.bpbBackup) { warnx("no room for info sector"); - return -1; + goto done; } bpb.bpbFSInfo = x; } @@ -479,12 +482,12 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) if (!bpb.bpbBackup) { if (x == MAXU16) { warnx("no room for backup sector"); - return -1; + goto done; } bpb.bpbBackup = x; } else if (bpb.bpbBackup != MAXU16 && bpb.bpbBackup == bpb.bpbFSInfo) { warnx("backup sector would overwrite info sector"); - return -1; + goto done; } if (bpb.bpbBackup != MAXU16 && x <= bpb.bpbBackup) x = bpb.bpbBackup + 1; @@ -495,7 +498,7 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) else if (bpb.bpbResSectors < x) { warnx("too few reserved sectors (need %d have %d)", x, bpb.bpbResSectors); - return -1; + goto done; } if (fat != 32 && !bpb.bpbRootDirEnts) bpb.bpbRootDirEnts = DEFRDE; @@ -515,13 +518,13 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) continue; if (fat != 32 && bpb.bpbBigFATsecs > MAXU16) { warnx("too many sectors/FAT for FAT12/16"); - return -1; + goto done; } x1 = bpb.bpbResSectors + rds; x = bpb.bpbBigFATsecs ? bpb.bpbBigFATsecs : 1; if (x1 + (u_int64_t)x * bpb.bpbFATs > bpb.bpbHugeSectors) { warnx("meta data exceeds file system size"); - return -1; + goto done; } x1 += x * bpb.bpbFATs; x = (u_int64_t)(bpb.bpbHugeSectors - x1) * bpb.bpbBytesPerSec * NPB / @@ -544,7 +547,7 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) if (cls < mincls(fat)) { warnx("%u clusters too few clusters for FAT%u, need %u", cls, fat, mincls(fat)); - return -1; + goto done; } if (cls > maxcls(fat)) { cls = maxcls(fat); @@ -575,7 +578,7 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) tm = localtime(&now); if (!(img = malloc(bpb.bpbBytesPerSec))) { warn(NULL); - return -1; + goto done; } dir = bpb.bpbResSectors + (bpb.bpbFATsecs ? bpb.bpbFATsecs : bpb.bpbBigFATsecs) * bpb.bpbFATs; @@ -583,7 +586,7 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) si_sa.sa_handler = infohandler; if (sigaction(SIGINFO, &si_sa, NULL) == -1) { warn("sigaction SIGINFO"); - return -1; + goto done; } for (lsn = 0; lsn < dir + (fat == 32 ? bpb.bpbSecPerClust : rds); lsn++) { if (got_siginfo) { @@ -601,17 +604,17 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) x -= bpb.bpbBackup; if (!x && lseek(fd1, o.offset, SEEK_SET)) { warn("%s", bname); - return -1; + goto done; } } if (o.bootstrap && x < bss) { if ((n = read(fd1, img, bpb.bpbBytesPerSec)) == -1) { warn("%s", bname); - return -1; + goto done; } if ((unsigned)n != bpb.bpbBytesPerSec) { warnx("%s: can't read sector %u", bname, x); - return -1; + goto done; } } else memset(img, 0, bpb.bpbBytesPerSec); @@ -701,15 +704,19 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op) } if ((n = write(fd, img, bpb.bpbBytesPerSec)) == -1) { warn("%s", fname); - return -1; + goto done; } if ((unsigned)n != bpb.bpbBytesPerSec) { warnx("%s: can't write sector %u", fname, lsn); - return -1; + goto done; } } } - return 0; + rv = 0; +done: + free(img); + + return rv; } /* diff --git a/sbin/swapon/swapon.c b/sbin/swapon/swapon.c index ed9f568..f581431 100644 --- a/sbin/swapon/swapon.c +++ b/sbin/swapon/swapon.c @@ -642,6 +642,7 @@ run_cmd(int *ofd, const char *cmdline, ...) rv = vasprintf(&cmd, cmdline, ap); if (rv == -1) { warn("%s", __func__); + va_end(ap); return (rv); } va_end(ap); diff --git a/secure/lib/libssh/Makefile b/secure/lib/libssh/Makefile index 91f1587..139021b 100644 --- a/secure/lib/libssh/Makefile +++ b/secure/lib/libssh/Makefile @@ -38,9 +38,11 @@ LIBADD+= ldns .endif CFLAGS+= -I${SSHDIR} -include ssh_namespace.h +SRCS+= ssh_namespace.h .if ${MK_KERBEROS_SUPPORT} != "no" CFLAGS+= -include krb5_config.h +SRCS+= krb5_config.h .endif NO_LINT= @@ -50,8 +52,3 @@ LIBADD+= crypto crypt z .include <bsd.lib.mk> .PATH: ${SSHDIR} ${SSHDIR}/openbsd-compat - -${OBJS} ${POBJS} ${SOBJS}: ssh_namespace.h -.if ${MK_KERBEROS_SUPPORT} != "no" -${OBJS} ${POBJS} ${SOBJS}: krb5_config.h -.endif diff --git a/secure/libexec/sftp-server/Makefile b/secure/libexec/sftp-server/Makefile index 11839ff..f0bedff 100644 --- a/secure/libexec/sftp-server/Makefile +++ b/secure/libexec/sftp-server/Makefile @@ -6,6 +6,7 @@ PROG= sftp-server SRCS= sftp-server.c sftp-common.c sftp-server-main.c MAN= sftp-server.8 CFLAGS+=-I${SSHDIR} -include ssh_namespace.h +SRCS+= ssh_namespace.h .if !defined(NO_SHARED) # required when linking with a dynamic libssh @@ -23,5 +24,3 @@ CFLAGS+= -DHAVE_LDNS=1 .include <bsd.prog.mk> .PATH: ${SSHDIR} - -${OBJS} ${POBJS} ${SOBJS}: ssh_namespace.h diff --git a/secure/libexec/ssh-keysign/Makefile b/secure/libexec/ssh-keysign/Makefile index 9813e5d..c546e83 100644 --- a/secure/libexec/ssh-keysign/Makefile +++ b/secure/libexec/ssh-keysign/Makefile @@ -6,6 +6,7 @@ PROG= ssh-keysign SRCS= ssh-keysign.c roaming_dummy.c readconf.c MAN= ssh-keysign.8 CFLAGS+=-I${SSHDIR} -include ssh_namespace.h +SRCS+= ssh_namespace.h BINMODE=4555 LIBADD= ssh @@ -21,5 +22,3 @@ LIBADD+= crypto .include <bsd.prog.mk> .PATH: ${SSHDIR} - -${OBJS} ${POBJS} ${SOBJS}: ssh_namespace.h diff --git a/secure/libexec/ssh-pkcs11-helper/Makefile b/secure/libexec/ssh-pkcs11-helper/Makefile index a8d681e..d8046d1 100644 --- a/secure/libexec/ssh-pkcs11-helper/Makefile +++ b/secure/libexec/ssh-pkcs11-helper/Makefile @@ -6,6 +6,7 @@ PROG= ssh-pkcs11-helper SRCS= ssh-pkcs11.c ssh-pkcs11-helper.c MAN= ssh-pkcs11-helper.8 CFLAGS+=-I${SSHDIR} -include ssh_namespace.h +SRCS+= ssh_namespace.h .if !defined(NO_SHARED) # required when linking with a dynamic libssh @@ -25,5 +26,3 @@ LIBADD+= crypto .include <bsd.prog.mk> .PATH: ${SSHDIR} - -${OBJS} ${POBJS} ${SOBJS}: ssh_namespace.h diff --git a/secure/usr.bin/scp/Makefile b/secure/usr.bin/scp/Makefile index fa11479..18cfbaf 100644 --- a/secure/usr.bin/scp/Makefile +++ b/secure/usr.bin/scp/Makefile @@ -5,6 +5,7 @@ PROG= scp SRCS= scp.c CFLAGS+=-I${SSHDIR} -include ssh_namespace.h +SRCS+= ssh_namespace.h .if !defined(NO_SHARED) # required when linking with a dynamic libssh @@ -22,5 +23,3 @@ CFLAGS+= -DHAVE_LDNS=1 .include <bsd.prog.mk> .PATH: ${SSHDIR} - -${OBJS} ${POBJS} ${SOBJS}: ssh_namespace.h diff --git a/secure/usr.bin/sftp/Makefile b/secure/usr.bin/sftp/Makefile index 281ae24..9cea9fe 100644 --- a/secure/usr.bin/sftp/Makefile +++ b/secure/usr.bin/sftp/Makefile @@ -5,6 +5,7 @@ PROG= sftp SRCS= sftp.c sftp-client.c sftp-common.c sftp-glob.c progressmeter.c CFLAGS+=-I${SSHDIR} -include ssh_namespace.h +SRCS+= ssh_namespace.h .if !defined(NO_SHARED) # required when linking with a dynamic libssh @@ -22,5 +23,3 @@ CFLAGS+= -DHAVE_LDNS=1 .include <bsd.prog.mk> .PATH: ${SSHDIR} - -${OBJS} ${POBJS} ${SOBJS}: ssh_namespace.h diff --git a/secure/usr.bin/ssh-add/Makefile b/secure/usr.bin/ssh-add/Makefile index 13dc5c6..2f5d76e 100644 --- a/secure/usr.bin/ssh-add/Makefile +++ b/secure/usr.bin/ssh-add/Makefile @@ -5,6 +5,7 @@ PROG= ssh-add SRCS+= ssh-add.c CFLAGS+=-I${SSHDIR} -include ssh_namespace.h +SRCS+= ssh_namespace.h .if !defined(NO_SHARED) # required when linking with a dynamic libssh @@ -22,5 +23,3 @@ CFLAGS+= -DHAVE_LDNS=1 .include <bsd.prog.mk> .PATH: ${SSHDIR} - -${OBJS} ${POBJS} ${SOBJS}: ssh_namespace.h diff --git a/secure/usr.bin/ssh-agent/Makefile b/secure/usr.bin/ssh-agent/Makefile index 3aa71da..e79a02e 100644 --- a/secure/usr.bin/ssh-agent/Makefile +++ b/secure/usr.bin/ssh-agent/Makefile @@ -5,6 +5,7 @@ PROG= ssh-agent SRCS= ssh-agent.c CFLAGS+=-I${SSHDIR} -include ssh_namespace.h +SRCS+= ssh_namespace.h .if !defined(NO_SHARED) # required when linking with a dynamic libssh @@ -24,5 +25,3 @@ LIBADD+= crypto .include <bsd.prog.mk> .PATH: ${SSHDIR} - -${OBJS} ${POBJS} ${SOBJS}: ssh_namespace.h diff --git a/secure/usr.bin/ssh-keygen/Makefile b/secure/usr.bin/ssh-keygen/Makefile index db8dc7e..c3d6b2f 100644 --- a/secure/usr.bin/ssh-keygen/Makefile +++ b/secure/usr.bin/ssh-keygen/Makefile @@ -5,6 +5,7 @@ PROG= ssh-keygen SRCS= ssh-keygen.c CFLAGS+=-I${SSHDIR} -include ssh_namespace.h +SRCS+= ssh_namespace.h .if !defined(NO_SHARED) # required when linking with a dynamic libssh @@ -22,5 +23,3 @@ LIBADD+= crypto .include <bsd.prog.mk> .PATH: ${SSHDIR} - -${OBJS} ${POBJS} ${SOBJS}: ssh_namespace.h diff --git a/secure/usr.bin/ssh-keyscan/Makefile b/secure/usr.bin/ssh-keyscan/Makefile index a44d96a..a2237a4 100644 --- a/secure/usr.bin/ssh-keyscan/Makefile +++ b/secure/usr.bin/ssh-keyscan/Makefile @@ -5,6 +5,7 @@ PROG= ssh-keyscan SRCS= ssh-keyscan.c roaming_dummy.c CFLAGS+=-I${SSHDIR} -include ssh_namespace.h +SRCS+= ssh_namespace.h LIBADD= ssh @@ -17,5 +18,3 @@ CFLAGS+= -DHAVE_LDNS=1 .include <bsd.prog.mk> .PATH: ${SSHDIR} - -${OBJS} ${POBJS} ${SOBJS}: ssh_namespace.h diff --git a/secure/usr.bin/ssh/Makefile b/secure/usr.bin/ssh/Makefile index a16f254..cad6b30 100644 --- a/secure/usr.bin/ssh/Makefile +++ b/secure/usr.bin/ssh/Makefile @@ -3,7 +3,6 @@ .include <src.opts.mk> PROG= ssh -CFLAGS+=-I${SSHDIR} -include ssh_namespace.h LINKS= ${BINDIR}/ssh ${BINDIR}/slogin MAN= ssh.1 ssh_config.5 MLINKS= ssh.1 slogin.1 @@ -15,6 +14,9 @@ SRCS= ssh.c readconf.c clientloop.c sshtty.c \ # gss-genr.c really belongs in libssh; see src/secure/lib/libssh/Makefile SRCS+= gss-genr.c +CFLAGS+=-I${SSHDIR} -include ssh_namespace.h +SRCS+= ssh_namespace.h + LIBADD= ssh .if ${MK_LDNS} != "no" @@ -23,6 +25,7 @@ CFLAGS+= -DHAVE_LDNS=1 .if ${MK_KERBEROS_SUPPORT} != "no" CFLAGS+= -include krb5_config.h +SRCS+= krb5_config.h LIBADD+= gssapi .endif @@ -35,8 +38,3 @@ CFLAGS+= -DXAUTH_PATH=\"${LOCALBASE}/bin/xauth\" .include <bsd.prog.mk> .PATH: ${SSHDIR} - -${OBJS} ${POBJS} ${SOBJS}: ssh_namespace.h -.if ${MK_KERBEROS_SUPPORT} != "no" -${OBJS} ${POBJS} ${SOBJS}: krb5_config.h -.endif diff --git a/secure/usr.sbin/sshd/Makefile b/secure/usr.sbin/sshd/Makefile index 7ccc5ea..2974f6b 100644 --- a/secure/usr.sbin/sshd/Makefile +++ b/secure/usr.sbin/sshd/Makefile @@ -24,6 +24,7 @@ SRCS+= gss-genr.c MAN= sshd.8 sshd_config.5 CFLAGS+=-I${SSHDIR} -include ssh_namespace.h +SRCS+= ssh_namespace.h # pam should always happen before ssh here for static linking LIBADD= pam ssh util wrap @@ -41,6 +42,7 @@ LIBADD+= bsm .if ${MK_KERBEROS_SUPPORT} != "no" CFLAGS+= -include krb5_config.h +SRCS+= krb5_config.h LIBADD+= gssapi_krb5 gssapi krb5 .endif @@ -53,8 +55,3 @@ CFLAGS+= -DXAUTH_PATH=\"${LOCALBASE}/bin/xauth\" .include <bsd.prog.mk> .PATH: ${SSHDIR} - -${OBJS} ${POBJS} ${SOBJS}: ssh_namespace.h -.if ${MK_KERBEROS_SUPPORT} != "no" -${OBJS} ${POBJS} ${SOBJS}: krb5_config.h -.endif diff --git a/share/examples/etc/make.conf b/share/examples/etc/make.conf index 4925d99..7dbfc51 100644 --- a/share/examples/etc/make.conf +++ b/share/examples/etc/make.conf @@ -32,7 +32,7 @@ # Intel x86 architecture: # (AMD CPUs) amdfam10, opteron-sse3, athlon64-sse3, k8-sse3, # opteron, athlon64, athlon-fx, k8, athlon-mp, -# athlen-xp, athlon-4, athlon-tbird, athlon, k7, +# athlon-xp, athlon-4, athlon-tbird, athlon, k7, # geode, k6-3, k6-2, k6 # (Intel CPUs) core2, core, nocona, pentium4m, pentium4, prescott, # pentium3m, pentium3, pentium-m, pentium2, diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 index f6223b8..e4f2208 100644 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -1,7 +1,7 @@ .\" DO NOT EDIT-- this file is automatically generated. .\" from FreeBSD: head/tools/build/options/makeman 291414 2015-11-28 00:41:37Z ume .\" $FreeBSD$ -.Dd November 28, 2015 +.Dd December 8, 2015 .Dt SRC.CONF 5 .Os .Sh NAME @@ -452,14 +452,10 @@ When set, it also enforces the following options: .It .Va WITHOUT_GROFF .El -.It Va WITH_DEBUG_FILES -.\" from FreeBSD: head/tools/build/options/WITH_DEBUG_FILES 251512 2013-06-07 21:40:02Z emaste -Set to strip debug info into a separate file for each executable binary -and shared library. -The debug files will be placed in a subdirectory of -.Pa /usr/lib/debug -and are located automatically by -.Xr gdb 1 . +.It Va WITHOUT_DEBUG_FILES +.\" from FreeBSD: head/tools/build/options/WITHOUT_DEBUG_FILES 290059 2015-10-27 20:49:56Z emaste +Set to avoid building or installing standalone debug files for each +executable binary and shared library. .It Va WITHOUT_DICT .\" from FreeBSD: head/tools/build/options/WITHOUT_DICT 156932 2006-03-21 07:50:50Z ru Set to not build the Webster dictionary files. diff --git a/share/man/man7/release.7 b/share/man/man7/release.7 index 7b53a6d..f9a0b9b 100644 --- a/share/man/man7/release.7 +++ b/share/man/man7/release.7 @@ -369,7 +369,7 @@ variables are relevant only to virtual machine disk image builds: Set to a non-null value to build virtual machine disk images as part of the release build. .Va WITH_VMIMAGES -may also be specified as an envirionment variable passed to +may also be specified as an environment variable passed to .Xr make 1 . .Pp The option requires @@ -528,7 +528,7 @@ The target requires the .Va WITH_VMIMAGES .Xr make 1 -envirionment variable to be set to a non-null value. +environment variable to be set to a non-null value. .It Cm vm-cloudware Builds .Fx diff --git a/share/man/man7/tests.7 b/share/man/man7/tests.7 index e8e216a..22bf7df 100644 --- a/share/man/man7/tests.7 +++ b/share/man/man7/tests.7 @@ -26,20 +26,22 @@ .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd April 13, 2014 +.Dd December 5, 2015 .Dt TESTS 7 .Os .Sh NAME .Nm tests -.Nd introduction to the FreeBSD Test Suite +.Nd introduction to the +.Fx +Test Suite .Sh DESCRIPTION The .Fx Test Suite provides a collection of automated tests for two major purposes. On one hand, the test suite aids .Em developers -to detect bugs and regressions when they modify the source tree. On the other -hand, it allows +to detect bugs and regressions when they modify the source tree. +On the other hand, it allows .Em end users (and, in particular, system administrators) to verify that fresh installations of the @@ -164,23 +166,26 @@ Test Suite: .Bl -tag -width "allow_sysctl_side_effects" .It allow_devfs_side_effects If defined, enables tests that may destroy and recreate semipermanent device -nodes, like disk devices. Without this variable, tests may still create and -destroy devices nodes that are normally transient, like /dev/tap* and -/dev/pts*, as long as they clean them up afterwards. However, tests that -require this variable have a relaxed cleanup requirement; they must recreate -any devices that they destroyed, but not necessarily with the same devnames. +nodes, like disk devices. +Without this variable, tests may still create and destroy devices nodes that +are normally transient, like /dev/tap* and /dev/pts*, as long as they clean +them up afterwards. +However, tests that require this variable have a relaxed cleanup requirement; +they must recreate any devices that they destroyed, but not necessarily with +the same devnames. .It allow_sysctl_side_effects Enables tests that change globally significant .Xr sysctl 8 -variables. The tests will undo any changes in their cleanup phases. +variables. +The tests will undo any changes in their cleanup phases. .It disks -Must be set to a space delimited list of disk device nodes. Tests that need -destructive access to disks must use these devices. Tests are not required to -preserve any data present on these disks. +Must be set to a space delimited list of disk device nodes. +Tests that need destructive access to disks must use these devices. +Tests are not required to preserve any data present on these disks. .It fibs -Must be set to a space delimited list of FIBs (routing tables). Tests that -need to modify a routing table may use any of these. Tests will cleanup any -new routes that they create. +Must be set to a space delimited list of FIBs (routing tables). +Tests that need to modify a routing table may use any of these. +Tests will cleanup any new routes that they create. .El .Ss What to do if something fails? If there is diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index c4f0b4e..30cb503 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -239,6 +239,7 @@ MAN= accept_filter.9 \ printf.9 \ prison_check.9 \ priv.9 \ + proc_rwmem.9 \ pseudofs.9 \ psignal.9 \ random.9 \ @@ -1053,6 +1054,7 @@ MLINKS+=\ mbuf.9 m_cat.9 \ mbuf.9 MCHTYPE.9 \ mbuf.9 MCLGET.9 \ + mbuf.9 m_collapse.9 \ mbuf.9 m_copyback.9 \ mbuf.9 m_copydata.9 \ mbuf.9 m_copym.9 \ @@ -1339,6 +1341,8 @@ MLINKS+=printf.9 log.9 \ printf.9 uprintf.9 MLINKS+=priv.9 priv_check.9 \ priv.9 priv_check_cred.9 +MLINKS+=proc_rwmem.9 proc_readmem.9 \ + proc_rwmem.9 proc_writemem.9 MLINKS+=psignal.9 gsignal.9 \ psignal.9 pgsignal.9 \ psignal.9 tdsignal.9 diff --git a/share/man/man9/g_bio.9 b/share/man/man9/g_bio.9 index e3ac64e..686c0cc 100644 --- a/share/man/man9/g_bio.9 +++ b/share/man/man9/g_bio.9 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 1, 2006 +.Dd December 7, 2015 .Dt G_BIO 9 .Os .Sh NAME @@ -253,7 +253,7 @@ example_start(struct bio *bp) /* Ok, schedule it down. */ /* * The consumer can be obtained from - * LIST_FIRST(&bp->bio_to->geom->consumers) as well, + * LIST_FIRST(&bp->bio_to->geom->consumer) as well, * if there is only one in our geom. */ g_io_request(cbp, sc->ex_consumer); diff --git a/share/man/man9/proc_rwmem.9 b/share/man/man9/proc_rwmem.9 new file mode 100644 index 0000000..10a4773 --- /dev/null +++ b/share/man/man9/proc_rwmem.9 @@ -0,0 +1,104 @@ +.\" +.\" Copyright (c) 2015 Mark Johnston <markj@FreeBSD.org> +.\" +.\" 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 DEVELOPERS ``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 DEVELOPERS 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. +.\" +.\" $FreeBSD$ +.\" +.Dd December 7, 2015 +.Dt PROC_RWMEM 9 +.Os +.Sh NAME +.Nm proc_rwmem , +.Nm proc_readmem , +.Nm proc_writemem +.Nd read from or write to a process address space +.Sh SYNOPSIS +.In sys/types.h +.In sys/ptrace.h +.Ft int +.Fn proc_rwmem "struct proc *p" "struct uio *uio" +.Ft ssize_t +.Fn proc_readmem "struct thread *td" "struct proc *p" "vm_offset_t va" "void *buf" "size_t len" +.Ft ssize_t +.Fn proc_writemem "struct thread *td" "struct proc *p" "vm_offset_t va" "void *buf" "size_t len" +.Sh DESCRIPTION +These functions are used to read to or write from the address space of the +process +.Fa p . +The +.Fn proc_rwmem +function requires the caller to specify the I/O parameters using a +.Vt "struct uio" , +described in +.Xr uio 9 . +The +.Fn proc_readmem +and +.Fn proc_writemem +functions provide a simpler, less general interface which allows the caller to +read into or write the kernel buffer +.Fa buf +of size +.Fa len +from or to the memory at offset +.Fa va +in the address space of +.Fa p . +The operation is performed on behalf of thread +.Fa td , +which will most often be the current thread. +.Pp +These functions may sleep and thus may not be called with any non-sleepable +locks held. +The process +.Fa p +must be held by the caller using +.Xr PHOLD 9 . +.Sh RETURN VALUES +The +.Fn proc_rwmem +function returns +.Dv 0 +on success. +.Dv EFAULT +is returned if the specified user address is invalid, and +.Dv ENOMEM +is returned if the target pages could not be faulted in due to a resource +shortage. +.Pp +The +.Fn proc_readmem +and +.Fn proc_writemem +functions return the number of bytes read or written, respectively. +This may be smaller than the number of bytes requested, for example if the +request spans multiple pages in the process address space and one of them after +the first is not mapped. +Otherwise, -1 is returned. +.Sh SEE ALSO +.Xr copyin 9 , +.Xr locking 9 , +.Xr PHOLD 9 , +.Xr uio 9 +.Sh AUTHORS +This manual page was written by +.An Mark Johnston Aq Mt markj@FreeBSD.org . diff --git a/share/misc/bsd-family-tree b/share/misc/bsd-family-tree index ad954d1..e4790ae 100644 --- a/share/misc/bsd-family-tree +++ b/share/misc/bsd-family-tree @@ -335,6 +335,7 @@ FreeBSD 5.2 | | | | | 10.2 | | | | | OS X NetBSD 7.0 | | | 10.11 | OpenBSD 5.8 | + | | | | DragonFly 4.4.1 | | | | | FreeBSD 11 -current | NetBSD -current OpenBSD -current DragonFly -current | | | | | @@ -681,6 +682,7 @@ FreeBSD 10.2 2015-08-13 [FBD] NetBSD 7.0 2015-09-25 [NBD] OS X 10.11 2015-09-30 [APL] OpenBSD 5.8 2015-10-18 [OBD] +DragonFly 4.4.1 2015-12-07 [DFB] Bibliography ------------------------ diff --git a/share/mk/atf.test.mk b/share/mk/atf.test.mk index b9c94a7..babecd9 100644 --- a/share/mk/atf.test.mk +++ b/share/mk/atf.test.mk @@ -22,29 +22,6 @@ ATF_TESTS_C?= ATF_TESTS_CXX?= ATF_TESTS_SH?= -# Path to the prefix of the installed ATF tools, if any. -# -# If atf-run and atf-report are installed from ports, we automatically define a -# realcheck target below to run the tests using these tools. The tools are -# searched for in the hierarchy specified by this variable. -ATF_PREFIX?= /usr/local - -# C compiler passed to ATF tests that need to build code. -ATF_BUILD_CC?= ${DESTDIR}/usr/bin/cc -TESTS_ENV+= ATF_BUILD_CC=${ATF_BUILD_CC} - -# C preprocessor passed to ATF tests that need to build code. -ATF_BUILD_CPP?= ${DESTDIR}/usr/bin/cpp -TESTS_ENV+= ATF_BUILD_CPP=${ATF_BUILD_CPP} - -# C++ compiler passed to ATF tests that need to build code. -ATF_BUILD_CXX?= ${DESTDIR}/usr/bin/c++ -TESTS_ENV+= ATF_BUILD_CXX=${ATF_BUILD_CXX} - -# Shell interpreter used to run atf-sh(1) based tests. -ATF_SHELL?= ${DESTDIR}/bin/sh -TESTS_ENV+= ATF_SHELL=${ATF_SHELL} - .if !empty(ATF_TESTS_C) PROGS+= ${ATF_TESTS_C} _TESTS+= ${ATF_TESTS_C} diff --git a/share/mk/bsd.compiler.mk b/share/mk/bsd.compiler.mk index 30da2af..d7763e4 100644 --- a/share/mk/bsd.compiler.mk +++ b/share/mk/bsd.compiler.mk @@ -30,6 +30,7 @@ __<bsd.compiler.mk>__: # Handle ccache after CC is determined, but not if CC/CXX are already # overridden with a manual setup. .if ${MK_CCACHE_BUILD:Uno} == "yes" && \ + !make(showconfig) && \ (${CC:M*ccache/world/*} == "" || ${CXX:M*ccache/world/*} == "") # CC is always prepended with the ccache wrapper rather than modifying # PATH since it is more clear that ccache is used and avoids wasting time @@ -63,8 +64,10 @@ CCACHE_COMPILERCHECK?= mtime # Remove ccache from the PATH to prevent double calls and wasted CPP/LD time. PATH:= ${PATH:C,:?${CCACHE_WRAPPER_PATH}(/world)?(:$)?,,g} # Ensure no bogus CCACHE_PATH leaks in which might avoid the in-tree compiler. +.if !empty(CCACHE_PATH) CCACHE_PATH= .export CCACHE_PATH +.endif # Override various toolchain vars. .for var in CC CXX HOST_CC HOST_CXX .if defined(${var}) && ${${var}:M${CCACHE_BIN}} == "" diff --git a/share/mk/bsd.dep.mk b/share/mk/bsd.dep.mk index d34b9a9..87491fe 100644 --- a/share/mk/bsd.dep.mk +++ b/share/mk/bsd.dep.mk @@ -57,23 +57,6 @@ _MKDEPCC+= ${DEPFLAGS} MKDEPCMD?= CC='${_MKDEPCC}' mkdep DEPENDFILE?= .depend DEPENDFILES= ${DEPENDFILE} -.if ${MK_FAST_DEPEND} == "yes" && ${.MAKE.MODE:Unormal:Mmeta*} == "" -DEPENDFILES+= ${DEPENDFILE}.* -DEPEND_MP?= -MP -# Handle OBJS=../somefile.o hacks. Just replace '/' rather than use :T to -# avoid collisions. -DEPEND_FILTER= C,/,_,g -DEPEND_CFLAGS+= -MD ${DEPEND_MP} -MF${DEPENDFILE}.${.TARGET:${DEPEND_FILTER}} -DEPEND_CFLAGS+= -MT${.TARGET} -CFLAGS+= ${DEPEND_CFLAGS} -DEPENDOBJS+= ${OBJS} ${POBJS} ${SOBJS} -.for __obj in ${DEPENDOBJS:O:u} -.if ${.MAKEFLAGS:M-V} == "" -.sinclude "${DEPENDFILE}.${__obj:${DEPEND_FILTER}}" -.endif -DEPENDFILES_OBJS+= ${DEPENDFILE}.${__obj:${DEPEND_FILTER}} -.endfor -.endif # ${MK_FAST_DEPEND} == "yes" # Keep `tags' here, before SRCS are mangled below for `depend'. .if !target(tags) && defined(SRCS) && !defined(NO_TAGS) @@ -165,7 +148,36 @@ ${_D}.po: ${_DSRC} ${POBJS:S/^${_D}.po$//} .endfor beforedepend: ${DHDRS} beforebuild: ${DHDRS} + + +.if ${MK_FAST_DEPEND} == "yes" && ${.MAKE.MODE:Unormal:Mmeta*} == "" +DEPENDFILES+= ${DEPENDFILE}.* +DEPEND_MP?= -MP +# Handle OBJS=../somefile.o hacks. Just replace '/' rather than use :T to +# avoid collisions. +DEPEND_FILTER= C,/,_,g +DEPEND_CFLAGS+= -MD ${DEPEND_MP} -MF${DEPENDFILE}.${.TARGET:${DEPEND_FILTER}} +DEPEND_CFLAGS+= -MT${.TARGET} +.if defined(.PARSEDIR) +# Only add in DEPEND_CFLAGS for CFLAGS on files we expect from DEPENDOBJS +# as those are the only ones we will include. +DEPEND_CFLAGS_CONDITION= !empty(DEPENDOBJS:M${.TARGET:${DEPEND_FILTER}}) +CFLAGS+= ${${DEPEND_CFLAGS_CONDITION}:?${DEPEND_CFLAGS}:} +.else +CFLAGS+= ${DEPEND_CFLAGS} +.endif +DEPENDSRCS= ${SRCS:M*.[cSC]} ${SRCS:M*.cxx} ${SRCS:M*.cpp} ${SRCS:M*.cc} +.if !empty(DEPENDSRCS) +DEPENDOBJS+= ${DEPENDSRCS:R:S,$,.o,} .endif +.for __obj in ${DEPENDOBJS:O:u} +.if ${.MAKEFLAGS:M-V} == "" +.sinclude "${DEPENDFILE}.${__obj:${DEPEND_FILTER}}" +.endif +DEPENDFILES_OBJS+= ${DEPENDFILE}.${__obj:${DEPEND_FILTER}} +.endfor +.endif # ${MK_FAST_DEPEND} == "yes" +.endif # defined(SRCS) .if ${MK_DIRDEPS_BUILD} == "yes" .include <meta.autodep.mk> diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index 463b3d9..6e26cff 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -182,6 +182,7 @@ lib${LIB_PRIVATE}${LIB}.a: ${OBJS} ${STATICOBJS} .if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB) _LIBS+= lib${LIB_PRIVATE}${LIB}_p.a POBJS+= ${OBJS:.o=.po} ${STATICOBJS:.o=.po} +DEPENDOBJS+= ${POBJS} CLEANFILES+= ${POBJS} lib${LIB_PRIVATE}${LIB}_p.a: ${POBJS} @@ -194,6 +195,7 @@ lib${LIB_PRIVATE}${LIB}_p.a: ${POBJS} .if defined(SHLIB_NAME) || \ defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) SOBJS+= ${OBJS:.o=.So} +DEPENDOBJS+= ${SOBJS} CLEANFILES+= ${SOBJS} .endif diff --git a/share/mk/bsd.opts.mk b/share/mk/bsd.opts.mk index d242da5..3c27322 100644 --- a/share/mk/bsd.opts.mk +++ b/share/mk/bsd.opts.mk @@ -50,6 +50,7 @@ __<bsd.opts.mk>__: __DEFAULT_YES_OPTIONS = \ ASSERT_DEBUG \ + DEBUG_FILES \ DOCCOMPRESS \ INCLUDES \ INSTALLLIB \ @@ -69,7 +70,6 @@ __DEFAULT_NO_OPTIONS = \ CCACHE_BUILD \ FAST_DEPEND \ CTF \ - DEBUG_FILES \ INSTALL_AS_USER \ STALE_STAGED diff --git a/share/mk/local.meta.sys.mk b/share/mk/local.meta.sys.mk index 03c4723..a97f6f2 100644 --- a/share/mk/local.meta.sys.mk +++ b/share/mk/local.meta.sys.mk @@ -148,7 +148,11 @@ STAGE_MACHINE:= ${TARGET_OBJ_SPEC} .endif STAGE_OBJTOP:= ${STAGE_ROOT}/${STAGE_MACHINE} STAGE_COMMON_OBJTOP:= ${STAGE_ROOT}/common +STAGE_TARGET_OBJTOP:= ${STAGE_ROOT}/${TARGET_OBJ_SPEC} STAGE_HOST_OBJTOP:= ${STAGE_ROOT}/${HOST_TARGET} +# These are exported for hooking in out-of-tree builds. They will always +# be overridden in sub-makes above when building in-tree. +.export STAGE_OBJTOP STAGE_TARGET_OBJTOP STAGE_HOST_OBJTOP # Use tools/install.sh which can avoid the need for xinstall for simple cases. INSTALL?= sh ${SRCTOP}/tools/install.sh @@ -215,6 +219,7 @@ TOOLSDIR?= ${STAGE_HOST_OBJTOP} .endif # Don't use the bootstrap tools logic on itself. .if ${.TARGETS:Mbootstrap-tools} == "" && \ + !make(showconfig) && \ !defined(BOOTSTRAPPING_TOOLS) && !empty(TOOLSDIR) && ${.MAKE.LEVEL} == 0 .for dir in /sbin /bin /usr/sbin /usr/bin PATH:= ${TOOLSDIR}${dir}:${PATH} diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index a5862dc..094019d 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -228,6 +228,7 @@ __DEFAULT_NO_OPTIONS+=CLANG_BOOTSTRAP CLANG_IS_CC __DEFAULT_YES_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX __DEFAULT_NO_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC .endif +# In-tree binutils/gcc are older versions without modern architecture support. .if ${__T} == "aarch64" BROKEN_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP GCC GCC_BOOTSTRAP GDB __DEFAULT_YES_OPTIONS+=ELFCOPY_AS_OBJCOPY diff --git a/share/mk/suite.test.mk b/share/mk/suite.test.mk index 9afce75..0ffffba 100644 --- a/share/mk/suite.test.mk +++ b/share/mk/suite.test.mk @@ -8,10 +8,6 @@ .error suite.test.mk cannot be included directly. .endif -# Directory in which to install tests defined by the current Makefile. -# Makefiles have to override this to point to a subdirectory of TESTSBASE. -TESTSDIR?= . - # Name of the test suite these tests belong to. Should rarely be changed for # Makefiles built into the FreeBSD src tree. TESTSUITE?= FreeBSD diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index ee10dd5..db1b77a 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -798,12 +798,7 @@ struct soft_segment_descriptor gdt_segs[] = { }; void -setidt(idx, func, typ, dpl, ist) - int idx; - inthand_t *func; - int typ; - int dpl; - int ist; +setidt(int idx, inthand_t *func, int typ, int dpl, int ist) { struct gate_descriptor *ip; diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 9f9654a..8b04eab 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -1421,6 +1421,9 @@ pmap_invalidate_page(pmap_t pmap, vm_offset_t va) sched_unpin(); } +/* 4k PTEs -- Chosen to exceed the total size of Broadwell L2 TLB */ +#define PMAP_INVLPG_THRESHOLD (4 * 1024 * PAGE_SIZE) + void pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) { @@ -1428,6 +1431,11 @@ pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) vm_offset_t addr; u_int cpuid, i; + if (eva - sva >= PMAP_INVLPG_THRESHOLD) { + pmap_invalidate_all(pmap); + return; + } + if (pmap_type_guest(pmap)) { pmap_invalidate_ept(pmap); return; diff --git a/sys/amd64/include/md_var.h b/sys/amd64/include/md_var.h index 0657dee..983485a 100644 --- a/sys/amd64/include/md_var.h +++ b/sys/amd64/include/md_var.h @@ -32,69 +32,18 @@ #ifndef _MACHINE_MD_VAR_H_ #define _MACHINE_MD_VAR_H_ -/* - * Miscellaneous machine-dependent declarations. - */ +#include <x86/x86_var.h> -extern long Maxmem; -extern u_int basemem; -extern int busdma_swi_pending; -extern u_int cpu_exthigh; -extern u_int cpu_feature; -extern u_int cpu_feature2; -extern u_int amd_feature; -extern u_int amd_feature2; -extern u_int amd_pminfo; -extern u_int via_feature_rng; -extern u_int via_feature_xcrypt; -extern u_int cpu_clflush_line_size; -extern u_int cpu_stdext_feature; -extern u_int cpu_stdext_feature2; -extern u_int cpu_fxsr; -extern u_int cpu_high; -extern u_int cpu_id; -extern u_int cpu_max_ext_state_size; -extern u_int cpu_mxcsr_mask; -extern u_int cpu_procinfo; -extern u_int cpu_procinfo2; -extern char cpu_vendor[]; -extern u_int cpu_vendor_id; -extern u_int cpu_mon_mwait_flags; -extern u_int cpu_mon_min_size; -extern u_int cpu_mon_max_size; -extern u_int cpu_maxphyaddr; extern char ctx_switch_xsave[]; -extern u_int hv_high; -extern char hv_vendor[]; -extern char kstack[]; -extern char sigcode[]; -extern int szsigcode; -extern uint64_t *vm_page_dump; -extern int vm_page_dump_size; -extern int workaround_erratum383; -extern int _udatasel; -extern int _ucodesel; -extern int _ucode32sel; -extern int _ufssel; -extern int _ugssel; -extern int use_xsave; -extern uint64_t xsave_mask; +extern uint64_t *vm_page_dump; +/* XXX */ typedef void alias_for_inthand_t(u_int cs, u_int ef, u_int esp, u_int ss); -struct pcb; + struct savefpu; -struct thread; -struct reg; -struct fpreg; -struct dbreg; -struct dumperinfo; -void *alloc_fpusave(int flags); +void amd64_db_resume_dbreg(void); void amd64_syscall(struct thread *td, int traced); -void busdma_swi(void); -bool cpu_mwait_usable(void); -void cpu_probe_amdc1e(void); -void cpu_setregs(void); void doreti_iret(void) __asm(__STRING(doreti_iret)); void doreti_iret_fault(void) __asm(__STRING(doreti_iret_fault)); void ld_ds(void) __asm(__STRING(ld_ds)); @@ -109,26 +58,10 @@ void fs_load_fault(void) __asm(__STRING(fs_load_fault)); void gs_load_fault(void) __asm(__STRING(gs_load_fault)); void fsbase_load_fault(void) __asm(__STRING(fsbase_load_fault)); void gsbase_load_fault(void) __asm(__STRING(gsbase_load_fault)); -void dump_add_page(vm_paddr_t); -void dump_drop_page(vm_paddr_t); -void identify_cpu(void); -void initializecpu(void); -void initializecpucache(void); -bool intel_fix_cpuid(void); -void fillw(int /*u_short*/ pat, void *base, size_t cnt); void fpstate_drop(struct thread *td); -int is_physical_memory(vm_paddr_t addr); -int isa_nmi(int cd); -void panicifcpuunsupported(void); -void pagecopy(void *from, void *to); void pagezero(void *addr); -void printcpuinfo(void); void setidt(int idx, alias_for_inthand_t *func, int typ, int dpl, int ist); -int user_dbreg_trap(void); -int minidumpsys(struct dumperinfo *); struct savefpu *get_pcb_user_save_td(struct thread *td); struct savefpu *get_pcb_user_save_pcb(struct pcb *pcb); -struct pcb *get_pcb_td(struct thread *td); -void amd64_db_resume_dbreg(void); #endif /* !_MACHINE_MD_VAR_H_ */ diff --git a/sys/amd64/include/smp.h b/sys/amd64/include/smp.h index 9c93e5c..212d1ee 100644 --- a/sys/amd64/include/smp.h +++ b/sys/amd64/include/smp.h @@ -19,106 +19,25 @@ #ifndef LOCORE -#include <sys/bus.h> -#include <machine/frame.h> -#include <machine/intr_machdep.h> -#include <x86/apicvar.h> -#include <machine/pcb.h> +#include <x86/x86_smp.h> -struct pmap; +extern int pmap_pcid_enabled; +extern int invpcid_works; /* global symbols in mpboot.S */ extern char mptramp_start[]; extern char mptramp_end[]; extern u_int32_t mptramp_pagetables; -/* global data in mp_machdep.c */ -extern int mp_naps; -extern int boot_cpu_id; -extern struct pcb stoppcbs[]; -extern int cpu_apic_ids[]; -extern void *dpcpu; -extern char *bootSTK; -extern int bootAP; -extern void *bootstacks[]; -extern volatile u_int cpu_ipi_pending[]; -extern volatile int aps_ready; -extern struct mtx ap_boot_mtx; -extern int cpu_logical; -extern int cpu_cores; -extern int pmap_pcid_enabled; -extern int invpcid_works; -extern u_int xhits_gbl[]; -extern u_int xhits_pg[]; -extern u_int xhits_rng[]; -extern u_int ipi_global; -extern u_int ipi_page; -extern u_int ipi_range; -extern u_int ipi_range_size; -extern struct pmap *smp_tlb_pmap; - -extern volatile int smp_tlb_wait; - -struct cpu_info { - int cpu_present:1; - int cpu_bsp:1; - int cpu_disabled:1; - int cpu_hyperthread:1; -}; -extern struct cpu_info cpu_info[]; - -#ifdef COUNT_IPIS -extern u_long *ipi_invltlb_counts[MAXCPU]; -extern u_long *ipi_invlrng_counts[MAXCPU]; -extern u_long *ipi_invlpg_counts[MAXCPU]; -extern u_long *ipi_invlcache_counts[MAXCPU]; -extern u_long *ipi_rendezvous_counts[MAXCPU]; -#endif - /* IPI handlers */ inthand_t - IDTVEC(invltlb), /* TLB shootdowns - global */ IDTVEC(invltlb_pcid), /* TLB shootdowns - global, pcid */ IDTVEC(invltlb_invpcid),/* TLB shootdowns - global, invpcid */ - IDTVEC(invlpg), /* TLB shootdowns - 1 page */ - IDTVEC(invlrng), /* TLB shootdowns - page range */ - IDTVEC(invlcache), /* Write back and invalidate cache */ - IDTVEC(ipi_intr_bitmap_handler), /* Bitmap based IPIs */ - IDTVEC(cpustop), /* CPU stops & waits to be restarted */ - IDTVEC(cpususpend), /* CPU suspends & waits to be resumed */ - IDTVEC(justreturn), /* interrupt CPU with minimum overhead */ - IDTVEC(rendezvous); /* handle CPU rendezvous */ + IDTVEC(justreturn); /* interrupt CPU with minimum overhead */ -/* functions in mp_machdep.c */ -void assign_cpu_ids(void); -void cpu_add(u_int apic_id, char boot_cpu); -void cpustop_handler(void); -void cpususpend_handler(void); -void init_secondary_tail(void); -void invltlb_handler(void); void invltlb_pcid_handler(void); void invltlb_invpcid_handler(void); -void invlpg_handler(void); -void invlrng_handler(void); -void invlcache_handler(void); -void init_secondary(void); -void ipi_startup(int apic_id, int vector); -void ipi_all_but_self(u_int ipi); -void ipi_bitmap_handler(struct trapframe frame); -void ipi_cpu(int cpu, u_int ipi); -int ipi_nmi_handler(void); -void ipi_selected(cpuset_t cpus, u_int ipi); -u_int mp_bootaddress(u_int); -void set_interrupt_apic_ids(void); -void smp_cache_flush(void); -void smp_masked_invlpg(cpuset_t mask, vm_offset_t addr); -void smp_masked_invlpg_range(cpuset_t mask, vm_offset_t startva, - vm_offset_t endva); -void smp_masked_invltlb(cpuset_t mask, struct pmap *pmap); int native_start_all_aps(void); -void mem_range_AP_init(void); -void topo_probe(void); -void ipi_send_cpu(int cpu, u_int ipi); #endif /* !LOCORE */ #endif /* SMP */ diff --git a/sys/arm/arm/elf_machdep.c b/sys/arm/arm/elf_machdep.c index 1081bdf..02f7128 100644 --- a/sys/arm/arm/elf_machdep.c +++ b/sys/arm/arm/elf_machdep.c @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include <vm/pmap.h> #include <vm/vm_param.h> +#include <machine/acle-compat.h> #include <machine/elf.h> #include <machine/md_var.h> @@ -73,13 +74,20 @@ struct sysentvec elf32_freebsd_sysvec = { .sv_setregs = exec_setregs, .sv_fixlimit = NULL, .sv_maxssiz = NULL, - .sv_flags = SV_ABI_FREEBSD | SV_ILP32, + .sv_flags = +#if __ARM_ARCH >= 6 + SV_SHP | SV_TIMEKEEP | +#endif + SV_ABI_FREEBSD | SV_ILP32, .sv_set_syscall_retval = cpu_set_syscall_retval, .sv_fetch_syscall_args = cpu_fetch_syscall_args, .sv_syscallnames = syscallnames, + .sv_shared_page_base = SHAREDPAGE, + .sv_shared_page_len = PAGE_SIZE, .sv_schedtail = NULL, .sv_thread_detach = NULL, }; +INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec); static Elf32_Brandinfo freebsd_brand_info = { .brand = ELFOSABI_FREEBSD, diff --git a/sys/arm/arm/generic_timer.c b/sys/arm/arm/generic_timer.c index 636ba75..fd1f029 100644 --- a/sys/arm/arm/generic_timer.c +++ b/sys/arm/arm/generic_timer.c @@ -49,10 +49,13 @@ __FBSDID("$FreeBSD$"); #include <sys/rman.h> #include <sys/timeet.h> #include <sys/timetc.h> +#include <sys/smp.h> +#include <sys/vdso.h> #include <sys/watchdog.h> #include <machine/bus.h> #include <machine/cpu.h> #include <machine/intr.h> +#include <machine/md_var.h> #ifdef FDT #include <dev/fdt/fdt_common.h> @@ -121,6 +124,9 @@ static struct timecounter arm_tmr_timecount = { #define set_el1(x, val) WRITE_SPECIALREG(x ##_el1, val) #endif +static uint32_t arm_tmr_fill_vdso_timehands(struct vdso_timehands *vdso_th, + struct timecounter *tc); + static int get_freq(void) { @@ -181,17 +187,32 @@ get_ctrl(bool physical) } static void -disable_user_access(void) +setup_user_access(void *arg __unused) { uint32_t cntkctl; cntkctl = get_el1(cntkctl); cntkctl &= ~(GT_CNTKCTL_PL0PTEN | GT_CNTKCTL_PL0VTEN | - GT_CNTKCTL_EVNTEN | GT_CNTKCTL_PL0VCTEN | GT_CNTKCTL_PL0PCTEN); + GT_CNTKCTL_EVNTEN); + if (arm_tmr_sc->physical) { + cntkctl |= GT_CNTKCTL_PL0PCTEN; + cntkctl &= ~GT_CNTKCTL_PL0VCTEN; + } else { + cntkctl |= GT_CNTKCTL_PL0VCTEN; + cntkctl &= ~GT_CNTKCTL_PL0PCTEN; + } set_el1(cntkctl, cntkctl); isb(); } +static void +tmr_setup_user_access(void *arg __unused) +{ + + smp_rendezvous(NULL, setup_user_access, NULL, NULL); +} +SYSINIT(tmr_ua, SI_SUB_SMP, SI_ORDER_SECOND, tmr_setup_user_access, NULL); + static unsigned arm_tmr_get_timecount(struct timecounter *tc) { @@ -381,7 +402,7 @@ arm_tmr_attach(device_t dev) } } - disable_user_access(); + arm_cpu_fill_vdso_timehands = arm_tmr_fill_vdso_timehands; arm_tmr_timecount.tc_frequency = sc->clkfreq; tc_init(&arm_tmr_timecount); @@ -485,3 +506,13 @@ DELAY(int usec) first = last; } } + +static uint32_t +arm_tmr_fill_vdso_timehands(struct vdso_timehands *vdso_th, + struct timecounter *tc) +{ + + vdso_th->th_physical = arm_tmr_sc->physical; + bzero(vdso_th->th_res, sizeof(vdso_th->th_res)); + return (tc == &arm_tmr_timecount); +} diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c index bd01383..af7ee99 100644 --- a/sys/arm/arm/machdep.c +++ b/sys/arm/arm/machdep.c @@ -82,6 +82,7 @@ __FBSDID("$FreeBSD$"); #include <sys/sysent.h> #include <sys/sysproto.h> #include <sys/uio.h> +#include <sys/vdso.h> #include <vm/vm.h> #include <vm/pmap.h> @@ -271,6 +272,7 @@ sendsig(catcher, ksi, mask) struct trapframe *tf; struct sigframe *fp, frame; struct sigacts *psp; + struct sysentvec *sysent; int onstack; int sig; int code; @@ -337,7 +339,12 @@ sendsig(catcher, ksi, mask) tf->tf_r5 = (register_t)&fp->sf_uc; tf->tf_pc = (register_t)catcher; tf->tf_usr_sp = (register_t)fp; - tf->tf_usr_lr = (register_t)(PS_STRINGS - *(p->p_sysent->sv_szsigcode)); + sysent = p->p_sysent; + if (sysent->sv_sigcode_base != 0) + tf->tf_usr_lr = (register_t)sysent->sv_sigcode_base; + else + tf->tf_usr_lr = (register_t)(sysent->sv_psstrings - + *(sysent->sv_szsigcode)); /* Set the mode to enter in the signal handler */ #if __ARM_ARCH >= 7 if ((register_t)catcher & 1) @@ -591,41 +598,21 @@ set_dbregs(struct thread *td, struct dbreg *regs) static int -ptrace_read_int(struct thread *td, vm_offset_t addr, u_int32_t *v) +ptrace_read_int(struct thread *td, vm_offset_t addr, uint32_t *v) { - struct iovec iov; - struct uio uio; - - PROC_LOCK_ASSERT(td->td_proc, MA_NOTOWNED); - iov.iov_base = (caddr_t) v; - iov.iov_len = sizeof(u_int32_t); - uio.uio_iov = &iov; - uio.uio_iovcnt = 1; - uio.uio_offset = (off_t)addr; - uio.uio_resid = sizeof(u_int32_t); - uio.uio_segflg = UIO_SYSSPACE; - uio.uio_rw = UIO_READ; - uio.uio_td = td; - return proc_rwmem(td->td_proc, &uio); + + if (proc_readmem(td, td->td_proc, addr, v, sizeof(*v)) != sizeof(*v)) + return (ENOMEM); + return (0); } static int -ptrace_write_int(struct thread *td, vm_offset_t addr, u_int32_t v) +ptrace_write_int(struct thread *td, vm_offset_t addr, uint32_t v) { - struct iovec iov; - struct uio uio; - - PROC_LOCK_ASSERT(td->td_proc, MA_NOTOWNED); - iov.iov_base = (caddr_t) &v; - iov.iov_len = sizeof(u_int32_t); - uio.uio_iov = &iov; - uio.uio_iovcnt = 1; - uio.uio_offset = (off_t)addr; - uio.uio_resid = sizeof(u_int32_t); - uio.uio_segflg = UIO_SYSSPACE; - uio.uio_rw = UIO_WRITE; - uio.uio_td = td; - return proc_rwmem(td->td_proc, &uio); + + if (proc_writemem(td, td->td_proc, addr, &v, sizeof(v)) != sizeof(v)) + return (ENOMEM); + return (0); } static u_int @@ -1910,3 +1897,14 @@ initarm(struct arm_boot_params *abp) #endif /* !ARM_NEW_PMAP */ #endif /* FDT */ + +uint32_t (*arm_cpu_fill_vdso_timehands)(struct vdso_timehands *, + struct timecounter *); + +uint32_t +cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th, struct timecounter *tc) +{ + + return (arm_cpu_fill_vdso_timehands != NULL ? + arm_cpu_fill_vdso_timehands(vdso_th, tc) : 0); +} diff --git a/sys/arm/include/md_var.h b/sys/arm/include/md_var.h index 642124d..981c0b3 100644 --- a/sys/arm/include/md_var.h +++ b/sys/arm/include/md_var.h @@ -45,6 +45,11 @@ extern int (*_arm_bzero)(void *, int, int); extern int _min_memcpy_size; extern int _min_bzero_size; +struct vdso_timehands; +struct timecounter; +extern uint32_t (*arm_cpu_fill_vdso_timehands)(struct vdso_timehands *, + struct timecounter *); + #define DST_IS_USER 0x1 #define SRC_IS_USER 0x2 #define IS_PHYSICAL 0x4 diff --git a/sys/arm/include/vdso.h b/sys/arm/include/vdso.h index d6aa162..6a0ec7b 100644 --- a/sys/arm/include/vdso.h +++ b/sys/arm/include/vdso.h @@ -29,6 +29,7 @@ #define _ARM_VDSO_H #define VDSO_TIMEHANDS_MD \ - uint32_t th_res[8]; + uint32_t th_physical; \ + uint32_t th_res[7]; #endif diff --git a/sys/arm/include/vmparam.h b/sys/arm/include/vmparam.h index b6e76bf..36f19a3 100644 --- a/sys/arm/include/vmparam.h +++ b/sys/arm/include/vmparam.h @@ -124,7 +124,8 @@ #endif #define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS -#define USRSTACK VM_MAXUSER_ADDRESS +#define SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE) +#define USRSTACK SHAREDPAGE /* initial pagein size of beginning of executable file */ #ifndef VM_INITIAL_PAGEIN diff --git a/sys/arm64/arm64/elf_machdep.c b/sys/arm64/arm64/elf_machdep.c index 2506de3..9ba2541 100644 --- a/sys/arm64/arm64/elf_machdep.c +++ b/sys/arm64/arm64/elf_machdep.c @@ -80,12 +80,15 @@ static struct sysentvec elf64_freebsd_sysvec = { .sv_setregs = exec_setregs, .sv_fixlimit = NULL, .sv_maxssiz = NULL, - .sv_flags = SV_ABI_FREEBSD | SV_LP64, + .sv_flags = SV_SHP | SV_TIMEKEEP | SV_ABI_FREEBSD | SV_LP64, .sv_set_syscall_retval = cpu_set_syscall_retval, .sv_fetch_syscall_args = cpu_fetch_syscall_args, .sv_syscallnames = syscallnames, + .sv_shared_page_base = SHAREDPAGE, + .sv_shared_page_len = PAGE_SIZE, .sv_schedtail = NULL, }; +INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec); static Elf64_Brandinfo freebsd_brand_info = { .brand = ELFOSABI_FREEBSD, diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index e92a99f..f7e1456 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #include <sys/sysent.h> #include <sys/sysproto.h> #include <sys/ucontext.h> +#include <sys/vdso.h> #include <vm/vm.h> #include <vm/vm_kern.h> @@ -72,6 +73,7 @@ __FBSDID("$FreeBSD$"); #include <machine/devmap.h> #include <machine/machdep.h> #include <machine/metadata.h> +#include <machine/md_var.h> #include <machine/pcb.h> #include <machine/reg.h> #include <machine/vmparam.h> @@ -505,6 +507,7 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) struct trapframe *tf; struct sigframe *fp, frame; struct sigacts *psp; + struct sysentvec *sysent; int code, onstack, sig; td = curthread; @@ -563,7 +566,12 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) tf->tf_elr = (register_t)catcher; tf->tf_sp = (register_t)fp; - tf->tf_lr = (register_t)(PS_STRINGS - *(p->p_sysent->sv_szsigcode)); + sysent = p->p_sysent; + if (sysent->sv_sigcode_base != 0) + tf->tf_lr = (register_t)sysent->sv_sigcode_base; + else + tf->tf_lr = (register_t)(sysent->sv_psstrings - + *(sysent->sv_szsigcode)); CTR3(KTR_SIG, "sendsig: return td=%p pc=%#x sp=%#x", td, tf->tf_elr, tf->tf_sp); @@ -875,6 +883,17 @@ initarm(struct arm64_bootparams *abp) early_boot = 0; } +uint32_t (*arm_cpu_fill_vdso_timehands)(struct vdso_timehands *, + struct timecounter *); + +uint32_t +cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th, struct timecounter *tc) +{ + + return (arm_cpu_fill_vdso_timehands != NULL ? + arm_cpu_fill_vdso_timehands(vdso_th, tc) : 0); +} + #ifdef DDB #include <ddb/ddb.h> diff --git a/sys/arm64/include/md_var.h b/sys/arm64/include/md_var.h index 8545591..d6cecfc 100644 --- a/sys/arm64/include/md_var.h +++ b/sys/arm64/include/md_var.h @@ -46,4 +46,9 @@ void dump_add_page(vm_paddr_t); void dump_drop_page(vm_paddr_t); int minidumpsys(struct dumperinfo *); +struct vdso_timehands; +struct timecounter; +extern uint32_t (*arm_cpu_fill_vdso_timehands)(struct vdso_timehands *, + struct timecounter *); + #endif /* !_MACHINE_MD_VAR_H_ */ diff --git a/sys/arm64/include/vdso.h b/sys/arm64/include/vdso.h index 5a8f7f5..285e986 100644 --- a/sys/arm64/include/vdso.h +++ b/sys/arm64/include/vdso.h @@ -29,6 +29,7 @@ #define _MACHINE_VDSO_H_ #define VDSO_TIMEHANDS_MD \ - uint32_t th_res[8]; + uint32_t th_physical; \ + uint32_t th_res[7]; #endif /* !_MACHINE_VDSO_H_ */ diff --git a/sys/arm64/include/vmparam.h b/sys/arm64/include/vmparam.h index e3c1d74..2752ee1 100644 --- a/sys/arm64/include/vmparam.h +++ b/sys/arm64/include/vmparam.h @@ -194,7 +194,8 @@ extern vm_paddr_t dmap_phys_base; #define VM_MAXUSER_ADDRESS (VM_MAX_USER_ADDRESS) #define KERNBASE (VM_MIN_KERNEL_ADDRESS) -#define USRSTACK (VM_MAX_USER_ADDRESS) +#define SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE) +#define USRSTACK SHAREDPAGE /* * How many physical pages per kmem arena virtual page. diff --git a/sys/boot/userboot/test/Makefile.depend b/sys/boot/userboot/test/Makefile.depend index 3646e2e..a5da8fd 100644 --- a/sys/boot/userboot/test/Makefile.depend +++ b/sys/boot/userboot/test/Makefile.depend @@ -8,6 +8,7 @@ DIRDEPS = \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ + lib/libc_nonshared \ lib/libcompiler_rt \ diff --git a/sys/cam/cam_ccb.h b/sys/cam/cam_ccb.h index 834e2b7..28abc30 100644 --- a/sys/cam/cam_ccb.h +++ b/sys/cam/cam_ccb.h @@ -110,9 +110,9 @@ typedef enum { } ccb_flags; typedef enum { - CAM_USER_DATA_ADDR = 0x00000001,/* Userspace data pointers */ - CAM_SG_FORMAT_IOVEC = 0x00000002,/* iovec instead of busdma S/G*/ - CAM_UNMAPPED_BUF = 0x00000004 /* use unmapped I/O */ + CAM_USER_DATA_ADDR = 0x00000002,/* Userspace data pointers */ + CAM_SG_FORMAT_IOVEC = 0x00000004,/* iovec instead of busdma S/G*/ + CAM_UNMAPPED_BUF = 0x00000008 /* use unmapped I/O */ } ccb_xflags; /* XPT Opcodes for xpt_action */ diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index 89736f2..c2dd6a5 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -2450,7 +2450,8 @@ void xpt_action(union ccb *start_ccb) { - CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("xpt_action\n")); + CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_TRACE, + ("xpt_action: func=%#x\n", start_ccb->ccb_h.func_code)); start_ccb->ccb_h.status = CAM_REQ_INPROG; (*(start_ccb->ccb_h.path->bus->xport->action))(start_ccb); @@ -2464,7 +2465,8 @@ xpt_action_default(union ccb *start_ccb) int lock; path = start_ccb->ccb_h.path; - CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_action_default\n")); + CAM_DEBUG(path, CAM_DEBUG_TRACE, + ("xpt_action_default: func=%#x\n", start_ccb->ccb_h.func_code)); switch (start_ccb->ccb_h.func_code) { case XPT_SCSI_IO: @@ -2618,7 +2620,11 @@ call_sim: lock = (mtx_owned(sim->mtx) == 0); if (lock) CAM_SIM_LOCK(sim); + CAM_DEBUG(path, CAM_DEBUG_TRACE, + ("sim->sim_action: func=%#x\n", start_ccb->ccb_h.func_code)); (*(sim->sim_action))(sim, start_ccb); + CAM_DEBUG(path, CAM_DEBUG_TRACE, + ("sim->sim_action: status=%#x\n", start_ccb->ccb_h.status)); if (lock) CAM_SIM_UNLOCK(sim); break; diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c index 4b356d7..2719a47 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c +++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c @@ -120,13 +120,17 @@ #include <sys/kdb.h> #include <sys/kernel.h> #include <sys/malloc.h> -#include <sys/sysctl.h> #include <sys/lock.h> #include <sys/mutex.h> +#include <sys/ptrace.h> #include <sys/rwlock.h> #include <sys/sx.h> +#include <sys/sysctl.h> + #include <sys/dtrace_bsd.h> + #include <netinet/in.h> + #include "dtrace_cddl.h" #include "dtrace_debug.c" #endif @@ -13030,9 +13034,60 @@ dtrace_dof_copyin(uintptr_t uarg, int *errp) return (dof); } -#ifndef illumos +#ifdef __FreeBSD__ +static dof_hdr_t * +dtrace_dof_copyin_proc(struct proc *p, uintptr_t uarg, int *errp) +{ + dof_hdr_t hdr, *dof; + struct thread *td; + size_t loadsz; + + ASSERT(!MUTEX_HELD(&dtrace_lock)); + + td = curthread; + + /* + * First, we're going to copyin() the sizeof (dof_hdr_t). + */ + if (proc_readmem(td, p, uarg, &hdr, sizeof(hdr)) != sizeof(hdr)) { + dtrace_dof_error(NULL, "failed to copyin DOF header"); + *errp = EFAULT; + return (NULL); + } + + /* + * Now we'll allocate the entire DOF and copy it in -- provided + * that the length isn't outrageous. + */ + if (hdr.dofh_loadsz >= dtrace_dof_maxsize) { + dtrace_dof_error(&hdr, "load size exceeds maximum"); + *errp = E2BIG; + return (NULL); + } + loadsz = (size_t)hdr.dofh_loadsz; + + if (loadsz < sizeof (hdr)) { + dtrace_dof_error(&hdr, "invalid load size"); + *errp = EINVAL; + return (NULL); + } + + dof = kmem_alloc(loadsz, KM_SLEEP); + + if (proc_readmem(td, p, uarg, dof, loadsz) != loadsz || + dof->dofh_loadsz != loadsz) { + kmem_free(dof, hdr.dofh_loadsz); + *errp = EFAULT; + return (NULL); + } + + return (dof); +} + static __inline uchar_t -dtrace_dof_char(char c) { +dtrace_dof_char(char c) +{ + switch (c) { case '0': case '1': @@ -13063,7 +13118,7 @@ dtrace_dof_char(char c) { /* Should not reach here. */ return (0); } -#endif +#endif /* __FreeBSD__ */ static dof_hdr_t * dtrace_dof_property(const char *name) @@ -15694,8 +15749,8 @@ dtrace_helper_provider_add(dof_helper_t *dofhp, dtrace_helpers_t *help, int gen) * Check to make sure this isn't a duplicate. */ for (i = 0; i < help->dthps_nprovs; i++) { - if (dofhp->dofhp_dof == - help->dthps_provs[i]->dthp_prov.dofhp_dof) + if (dofhp->dofhp_addr == + help->dthps_provs[i]->dthp_prov.dofhp_addr) return (EALREADY); } @@ -15967,31 +16022,23 @@ dtrace_helper_provider_validate(dof_hdr_t *dof, dof_sec_t *sec) } static int +#ifdef __FreeBSD__ +dtrace_helper_slurp(dof_hdr_t *dof, dof_helper_t *dhp, struct proc *p) +#else dtrace_helper_slurp(dof_hdr_t *dof, dof_helper_t *dhp) +#endif { dtrace_helpers_t *help; dtrace_vstate_t *vstate; dtrace_enabling_t *enab = NULL; +#ifndef __FreeBSD__ proc_t *p = curproc; +#endif int i, gen, rv, nhelpers = 0, nprovs = 0, destroy = 1; uintptr_t daddr = (uintptr_t)dof; ASSERT(MUTEX_HELD(&dtrace_lock)); -#ifdef __FreeBSD__ - if (dhp->dofhp_pid != p->p_pid) { - if ((p = pfind(dhp->dofhp_pid)) == NULL) - return (-1); - if (!P_SHOULDSTOP(p) || - (p->p_flag & P_TRACED) == 0 || - p->p_pptr->p_pid != curproc->p_pid) { - PROC_UNLOCK(p); - return (-1); - } - PROC_UNLOCK(p); - } -#endif - if ((help = p->p_dtrace_helpers) == NULL) help = dtrace_helpers_create(p); @@ -16063,7 +16110,14 @@ dtrace_helper_slurp(dof_hdr_t *dof, dof_helper_t *dhp) dtrace_enabling_destroy(enab); if (dhp != NULL && nprovs > 0) { + /* + * Now that this is in-kernel, we change the sense of the + * members: dofhp_dof denotes the in-kernel copy of the DOF + * and dofhp_addr denotes the address at user-level. + */ + dhp->dofhp_addr = dhp->dofhp_dof; dhp->dofhp_dof = (uint64_t)(uintptr_t)dof; + if (dtrace_helper_provider_add(dhp, help, gen) == 0) { mutex_exit(&dtrace_lock); dtrace_helper_provider_register(p, help, dhp); diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c index 348222c..758ce0b 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c +++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c @@ -2117,6 +2117,18 @@ fasttrap_meta_provide(void *arg, dtrace_helper_provdesc_t *dhpv, pid_t pid) return (provider); } +/* + * We know a few things about our context here: we know that the probe being + * created doesn't already exist (DTrace won't load DOF at the same address + * twice, even if explicitly told to do so) and we know that we are + * single-threaded with respect to the meta provider machinery. Knowing that + * this is a new probe and that there is no way for us to race with another + * operation on this provider allows us an important optimization: we need not + * lookup a probe before adding it. Saving this lookup is important because + * this code is in the fork path for processes with USDT probes, and lookups + * here are potentially very expensive because of long hash conflicts on + * module, function and name (DTrace doesn't hash on provider name). + */ /*ARGSUSED*/ static void fasttrap_meta_create_probe(void *arg, void *parg, @@ -2153,19 +2165,6 @@ fasttrap_meta_create_probe(void *arg, void *parg, return; } - /* - * Grab the creation lock to ensure consistency between calls to - * dtrace_probe_lookup() and dtrace_probe_create() in the face of - * other threads creating probes. - */ - mutex_enter(&provider->ftp_cmtx); - - if (dtrace_probe_lookup(provider->ftp_provid, dhpb->dthpb_mod, - dhpb->dthpb_func, dhpb->dthpb_name) != 0) { - mutex_exit(&provider->ftp_cmtx); - return; - } - ntps = dhpb->dthpb_noffs + dhpb->dthpb_nenoffs; ASSERT(ntps > 0); @@ -2173,7 +2172,6 @@ fasttrap_meta_create_probe(void *arg, void *parg, if (fasttrap_total > fasttrap_max) { atomic_add_32(&fasttrap_total, -ntps); - mutex_exit(&provider->ftp_cmtx); return; } @@ -2237,8 +2235,6 @@ fasttrap_meta_create_probe(void *arg, void *parg, */ pp->ftp_id = dtrace_probe_create(provider->ftp_provid, dhpb->dthpb_mod, dhpb->dthpb_func, dhpb->dthpb_name, FASTTRAP_OFFSET_AFRAMES, pp); - - mutex_exit(&provider->ftp_cmtx); } /*ARGSUSED*/ diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h index f3ececc..7224242 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h +++ b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h @@ -2205,12 +2205,18 @@ extern void dtrace_probe(dtrace_id_t, uintptr_t arg0, uintptr_t arg1, * * 1.2.4 Caller's context * - * dtms_create_probe() is called from either ioctl() or module load context. - * The DTrace framework is locked in such a way that meta providers may not - * register or unregister. This means that the meta provider cannot call - * dtrace_meta_register() or dtrace_meta_unregister(). However, the context is - * such that the provider may (and is expected to) call provider-related - * DTrace provider APIs including dtrace_probe_create(). + * dtms_create_probe() is called from either ioctl() or module load context + * in the context of a newly-created provider (that is, a provider that + * is a result of a call to dtms_provide_pid()). The DTrace framework is + * locked in such a way that meta providers may not register or unregister, + * such that no other thread can call into a meta provider operation and that + * atomicity is assured with respect to meta provider operations across + * dtms_provide_pid() and subsequent calls to dtms_create_probe(). + * The context is thus effectively single-threaded with respect to the meta + * provider, and that the meta provider cannot call dtrace_meta_register() + * or dtrace_meta_unregister(). However, the context is such that the + * provider may (and is expected to) call provider-related DTrace provider + * APIs including dtrace_probe_create(). * * 1.3 void *dtms_provide_pid(void *arg, dtrace_meta_provider_t *mprov, * pid_t pid) diff --git a/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c b/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c index 5d60a07..4c9fc0f 100644 --- a/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c +++ b/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c @@ -60,43 +60,31 @@ #include <sys/ptrace.h> static int -proc_ops(int op, proc_t *p, void *kaddr, off_t uaddr, size_t len) +uread(proc_t *p, void *kaddr, size_t len, uintptr_t uaddr) { - struct iovec iov; - struct uio uio; - - iov.iov_base = kaddr; - iov.iov_len = len; - uio.uio_offset = uaddr; - uio.uio_iov = &iov; - uio.uio_resid = len; - uio.uio_iovcnt = 1; - uio.uio_segflg = UIO_SYSSPACE; - uio.uio_td = curthread; - uio.uio_rw = op; + ssize_t n; + PHOLD(p); - if (proc_rwmem(p, &uio) != 0) { - PRELE(p); - return (-1); - } + n = proc_readmem(curthread, p, uaddr, kaddr, len); PRELE(p); - + if (n != len) + return (ENOMEM); return (0); } static int -uread(proc_t *p, void *kaddr, size_t len, uintptr_t uaddr) -{ - - return (proc_ops(UIO_READ, p, kaddr, uaddr, len)); -} - -static int uwrite(proc_t *p, void *kaddr, size_t len, uintptr_t uaddr) { + ssize_t n; - return (proc_ops(UIO_WRITE, p, kaddr, uaddr, len)); + PHOLD(p); + n = proc_writemem(curthread, p, uaddr, kaddr, len); + PRELE(p); + if (n != len) + return (ENOMEM); + return (0); } + #endif /* illumos */ #ifdef __i386__ #define r_rax r_eax diff --git a/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c b/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c index ea01d5f..8e4c647 100644 --- a/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c +++ b/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c @@ -43,44 +43,30 @@ #define OP_RA(x) (((x) & 0x001F0000) >> 16) #define OP_RB(x) (((x) & 0x0000F100) >> 11) - static int -proc_ops(int op, proc_t *p, void *kaddr, off_t uaddr, size_t len) +uread(proc_t *p, void *kaddr, size_t len, uintptr_t uaddr) { - struct iovec iov; - struct uio uio; - - iov.iov_base = kaddr; - iov.iov_len = len; - uio.uio_offset = uaddr; - uio.uio_iov = &iov; - uio.uio_resid = len; - uio.uio_iovcnt = 1; - uio.uio_segflg = UIO_SYSSPACE; - uio.uio_td = curthread; - uio.uio_rw = op; + ssize_t n; + PHOLD(p); - if (proc_rwmem(p, &uio) != 0) { - PRELE(p); - return (-1); - } + n = proc_readmem(curthread, p, uaddr, kaddr, len); PRELE(p); - + if (n <= 0 || n < len) + return (ENOMEM); return (0); } static int -uread(proc_t *p, void *kaddr, size_t len, uintptr_t uaddr) -{ - - return (proc_ops(UIO_READ, p, kaddr, uaddr, len)); -} - -static int uwrite(proc_t *p, void *kaddr, size_t len, uintptr_t uaddr) { + ssize_t n; - return (proc_ops(UIO_WRITE, p, kaddr, uaddr, len)); + PHOLD(p); + n = proc_writemem(curthread, p, uaddr, kaddr, len); + PRELE(p); + if (n <= 0 || n < len) + return (ENOMEM); + return (0); } int diff --git a/sys/cddl/dev/dtrace/dtrace_ioctl.c b/sys/cddl/dev/dtrace/dtrace_ioctl.c index 524e937..666c077 100644 --- a/sys/cddl/dev/dtrace/dtrace_ioctl.c +++ b/sys/cddl/dev/dtrace/dtrace_ioctl.c @@ -32,25 +32,47 @@ static int dtrace_ioctl_helper(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td) { - dof_helper_t *dhp = NULL; - dof_hdr_t *dof = NULL; + struct proc *p; + dof_helper_t *dhp; + dof_hdr_t *dof; int rval; + dhp = NULL; + dof = NULL; + rval = 0; switch (cmd) { case DTRACEHIOC_ADDDOF: dhp = (dof_helper_t *)addr; - /* XXX all because dofhp_dof is 64 bit */ - addr = (caddr_t)(vm_offset_t)dhp->dofhp_dof; + addr = (caddr_t)(uintptr_t)dhp->dofhp_dof; /* FALLTHROUGH */ case DTRACEHIOC_ADD: - dof = dtrace_dof_copyin((intptr_t)addr, &rval); + p = curproc; + if (p->p_pid == dhp->dofhp_pid) { + dof = dtrace_dof_copyin((uintptr_t)addr, &rval); + } else { + p = pfind(dhp->dofhp_pid); + if (p == NULL) + return (EINVAL); + if (!P_SHOULDSTOP(p) || + (p->p_flag & P_TRACED|P_WEXIT) == 0 || + p->p_pptr != curproc) { + PROC_UNLOCK(p); + return (EINVAL); + } + _PHOLD(p); + PROC_UNLOCK(p); + dof = dtrace_dof_copyin_proc(p, (uintptr_t)addr, &rval); + } - if (dof == NULL) - return (rval); + if (dof == NULL) { + if (p != curproc) + PRELE(p); + break; + } mutex_enter(&dtrace_lock); - if ((rval = dtrace_helper_slurp((dof_hdr_t *)dof, dhp)) != -1) { - if (dhp) { + if ((rval = dtrace_helper_slurp(dof, dhp, p)) != -1) { + if (dhp != NULL) { dhp->dofhp_gen = rval; copyout(dhp, addr, sizeof(*dhp)); } @@ -59,19 +81,19 @@ dtrace_ioctl_helper(struct cdev *dev, u_long cmd, caddr_t addr, int flags, rval = EINVAL; } mutex_exit(&dtrace_lock); - - return (rval); + if (p != curproc) + PRELE(p); + break; case DTRACEHIOC_REMOVE: mutex_enter(&dtrace_lock); - rval = dtrace_helper_destroygen(NULL, (int)*addr); + rval = dtrace_helper_destroygen(NULL, *(int *)(uintptr_t)addr); mutex_exit(&dtrace_lock); - - return (rval); + break; default: + rval = ENOTTY; break; } - - return (ENOTTY); + return (rval); } /* ARGSUSED */ diff --git a/sys/conf/files b/sys/conf/files index 3eb2ab5..55174f7 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -3643,6 +3643,7 @@ netinet/in.c optional inet netinet/in_debug.c optional inet ddb netinet/in_kdtrace.c optional inet | inet6 netinet/ip_carp.c optional inet carp | inet6 carp +netinet/in_fib.c optional inet netinet/in_gif.c optional gif inet | netgraph_gif inet netinet/ip_gre.c optional gre inet netinet/ip_id.c optional inet @@ -3709,6 +3710,7 @@ netinet6/frag6.c optional inet6 netinet6/icmp6.c optional inet6 netinet6/in6.c optional inet6 netinet6/in6_cksum.c optional inet6 +netinet6/in6_fib.c optional inet6 netinet6/in6_gif.c optional gif inet6 | netgraph_gif inet6 netinet6/in6_ifattach.c optional inet6 netinet6/in6_mcast.c optional inet6 diff --git a/sys/conf/files.arm b/sys/conf/files.arm index cd27a39..1c57106 100644 --- a/sys/conf/files.arm +++ b/sys/conf/files.arm @@ -110,7 +110,6 @@ font.h optional sc \ no-obj no-implicit-rule before-depend \ clean "font.h ${SC_DFLT_FONT}-8x14 ${SC_DFLT_FONT}-8x16 ${SC_DFLT_FONT}-8x8" kern/subr_busdma_bufalloc.c standard -kern/subr_dummy_vdso_tc.c standard kern/subr_sfbuf.c standard libkern/arm/aeabi_unwind.c standard libkern/arm/divsi3.S standard diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index 7c8c4f7..6ecf36a 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -79,7 +79,6 @@ dev/vnic/thunder_mdio_fdt.c optional vnic fdt dev/vnic/thunder_mdio.c optional vnic dev/vnic/lmac_if.m optional vnic kern/kern_clocksource.c standard -kern/subr_dummy_vdso_tc.c standard libkern/bcmp.c standard libkern/ffs.c standard libkern/ffsl.c standard diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index 10430f6..826afd2 100644 --- a/sys/dev/iscsi/iscsi.c +++ b/sys/dev/iscsi/iscsi.c @@ -2365,7 +2365,7 @@ iscsi_load(void) sc->sc_cdev->si_drv1 = sc; sc->sc_shutdown_eh = EVENTHANDLER_REGISTER(shutdown_pre_sync, - iscsi_shutdown, sc, SHUTDOWN_PRI_FIRST); + iscsi_shutdown, sc, SHUTDOWN_PRI_DEFAULT-1); return (0); } diff --git a/sys/dev/mlx5/device.h b/sys/dev/mlx5/device.h index 3e90859..b9a8eec 100644 --- a/sys/dev/mlx5/device.h +++ b/sys/dev/mlx5/device.h @@ -1023,6 +1023,25 @@ enum { MLX5_MODIFY_ESW_VPORT_CONTEXT_FIELD_SELECT_CVLAN_INSERT = 1 << 3 }; +enum { + MLX5_UC_ADDR_CHANGE = (1 << 0), + MLX5_MC_ADDR_CHANGE = (1 << 1), + MLX5_VLAN_CHANGE = (1 << 2), + MLX5_PROMISC_CHANGE = (1 << 3), + MLX5_MTU_CHANGE = (1 << 4), +}; + +enum mlx5_list_type { + MLX5_NIC_VPORT_LIST_TYPE_UC = 0x0, + MLX5_NIC_VPORT_LIST_TYPE_MC = 0x1, + MLX5_NIC_VPORT_LIST_TYPE_VLAN = 0x2, +}; + +enum { + MLX5_ESW_VPORT_ADMIN_STATE_DOWN = 0x0, + MLX5_ESW_VPORT_ADMIN_STATE_UP = 0x1, + MLX5_ESW_VPORT_ADMIN_STATE_AUTO = 0x2, +}; /* MLX5 DEV CAPs */ /* TODO: EAT.ME */ @@ -1087,6 +1106,22 @@ enum mlx5_cap_type { MLX5_GET(flow_table_eswitch_cap, \ mdev->hca_caps_max[MLX5_CAP_ESWITCH_FLOW_TABLE], cap) +#define MLX5_CAP_ESW_FLOWTABLE_EGRESS_ACL(mdev, cap) \ + MLX5_CAP_ESW_FLOWTABLE(dev, \ + flow_table_properties_esw_acl_egress.cap) + +#define MLX5_CAP_ESW_FLOWTABLE_EGRESS_ACL_MAX(mdev, cap) \ + MLX5_CAP_ESW_FLOWTABLE_MAX(dev, \ + flow_table_properties_esw_acl_egress.cap) + +#define MLX5_CAP_ESW_FLOWTABLE_INGRESS_ACL(mdev, cap) \ + MLX5_CAP_ESW_FLOWTABLE(dev, \ + flow_table_properties_esw_acl_ingress.cap) + +#define MLX5_CAP_ESW_FLOWTABLE_INGRESS_ACL_MAX(mdev, cap) \ + MLX5_CAP_ESW_FLOWTABLE_MAX(dev, \ + flow_table_properties_esw_acl_ingress.cap) + #define MLX5_CAP_ESW(mdev, cap) \ MLX5_GET(e_switch_cap, \ mdev->hca_caps_cur[MLX5_CAP_ESWITCH], cap) diff --git a/sys/dev/mlx5/driver.h b/sys/dev/mlx5/driver.h index 6f4031e..83793d5 100644 --- a/sys/dev/mlx5/driver.h +++ b/sys/dev/mlx5/driver.h @@ -934,7 +934,7 @@ struct mlx5_profile { }; -#define MLX5_EEPROM_MAX_BYTES 48 +#define MLX5_EEPROM_MAX_BYTES 32 #define MLX5_EEPROM_IDENTIFIER_BYTE_MASK 0x000000ff #define MLX5_EEPROM_REVISION_ID_BYTE_MASK 0x0000ff00 #define MLX5_EEPROM_PAGE_3_VALID_BIT_MASK 0x00040000 diff --git a/sys/dev/mlx5/eswitch_vacl.h b/sys/dev/mlx5/eswitch_vacl.h new file mode 100644 index 0000000..f55fdb8 --- /dev/null +++ b/sys/dev/mlx5/eswitch_vacl.h @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 2013-2015, Mellanox Technologies, Ltd. 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 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 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. + * + * $FreeBSD$ + */ + +#ifndef MLX5_ESWITCH_VACL_TABLE_H +#define MLX5_ESWITCH_VACL_TABLE_H + +#include <dev/mlx5/driver.h> + +void *mlx5_vacl_table_create(struct mlx5_core_dev *dev, + u16 vport, bool is_egress); +void mlx5_vacl_table_cleanup(void *acl_t); +int mlx5_vacl_table_add_vlan(void *acl_t, u16 vlan); +void mlx5_vacl_table_del_vlan(void *acl_t, u16 vlan); +int mlx5_vacl_table_enable_vlan_filter(void *acl_t); +void mlx5_vacl_table_disable_vlan_filter(void *acl_t); +int mlx5_vacl_table_drop_untagged(void *acl_t); +int mlx5_vacl_table_allow_untagged(void *acl_t); +int mlx5_vacl_table_drop_unknown_vlan(void *acl_t); +int mlx5_vacl_table_allow_unknown_vlan(void *acl_t); +int mlx5_vacl_table_set_spoofchk(void *acl_t, bool spoofchk, u8 *vport_mac); + +#endif /* MLX5_ESWITCH_VACL_TABLE_H */ diff --git a/sys/dev/mlx5/mlx5_core/mlx5_eq.c b/sys/dev/mlx5/mlx5_core/mlx5_eq.c index 11b560a..dd407e8 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_eq.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_eq.c @@ -31,6 +31,13 @@ #include <dev/mlx5/mlx5_ifc.h> #include "mlx5_core.h" +#include "opt_rss.h" + +#ifdef RSS +#include <net/rss_config.h> +#include <netinet/in_rss.h> +#endif + enum { MLX5_EQE_SIZE = sizeof(struct mlx5_eqe), MLX5_EQE_OWNER_INIT_VAL = 0x1, @@ -55,7 +62,6 @@ enum { (1ull << MLX5_EVENT_TYPE_WQ_INVAL_REQ_ERROR) | \ (1ull << MLX5_EVENT_TYPE_WQ_ACCESS_ERROR) | \ (1ull << MLX5_EVENT_TYPE_PORT_CHANGE) | \ - (1ull << MLX5_EVENT_TYPE_NIC_VPORT_CHANGE) | \ (1ull << MLX5_EVENT_TYPE_SRQ_CATAS_ERROR) | \ (1ull << MLX5_EVENT_TYPE_SRQ_LAST_WQE) | \ (1ull << MLX5_EVENT_TYPE_SRQ_RQ_LIMIT)) @@ -389,6 +395,18 @@ int mlx5_create_map_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq, u8 vecidx, priv->irq_info[vecidx].name, eq); if (err) goto err_eq; +#ifdef RSS + if (vecidx >= MLX5_EQ_VEC_COMP_BASE) { + u8 bucket = vecidx - MLX5_EQ_VEC_COMP_BASE; + err = bind_irq_to_cpu(priv->msix_arr[vecidx].vector, + rss_getcpu(bucket % rss_getnumbuckets())); + if (err) + goto err_irq; + } +#else + if (0) + goto err_irq; +#endif /* EQs are created in ARMED state @@ -398,6 +416,8 @@ int mlx5_create_map_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq, u8 vecidx, kvfree(in); return 0; +err_irq: + free_irq(priv->msix_arr[vecidx].vector, eq); err_eq: mlx5_cmd_destroy_eq(dev, eq->eqn); @@ -452,6 +472,10 @@ int mlx5_start_eqs(struct mlx5_core_dev *dev) async_event_mask |= (1ull << MLX5_EVENT_TYPE_CODING_PORT_MODULE_EVENT); + if (MLX5_CAP_GEN(dev, nic_vport_change_event)) + async_event_mask |= (1ull << + MLX5_EVENT_TYPE_NIC_VPORT_CHANGE); + err = mlx5_create_map_eq(dev, &table->cmd_eq, MLX5_EQ_VEC_CMD, MLX5_NUM_CMD_EQE, 1ull << MLX5_EVENT_TYPE_CMD, "mlx5_cmd_eq", &dev->priv.uuari.uars[0]); diff --git a/sys/dev/mlx5/mlx5_core/mlx5_eswitch_vacl.c b/sys/dev/mlx5/mlx5_core/mlx5_eswitch_vacl.c new file mode 100644 index 0000000..cb149b9 --- /dev/null +++ b/sys/dev/mlx5/mlx5_core/mlx5_eswitch_vacl.c @@ -0,0 +1,803 @@ +/*- + * Copyright (c) 2013-2015, Mellanox Technologies, Ltd. 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 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 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. + * + * $FreeBSD$ + */ + +#include <linux/etherdevice.h> +#include <dev/mlx5/driver.h> +#include <dev/mlx5/flow_table.h> +#include <dev/mlx5/eswitch_vacl.h> +#include "mlx5_core.h" + +enum { + MLX5_ACL_LOOPBACK_GROUP_IDX = 0, + MLX5_ACL_UNTAGGED_GROUP_IDX = 1, + MLX5_ACL_VLAN_GROUP_IDX = 2, + MLX5_ACL_UNKNOWN_VLAN_GROUP_IDX = 3, + MLX5_ACL_DEFAULT_GROUP_IDX = 4, + MLX5_ACL_GROUPS_NUM, +}; + +struct mlx_vacl_fr { + bool applied; + u32 fi; + u16 action; +}; + +struct mlx5_vacl_table { + struct mlx5_core_dev *dev; + u16 vport; + void *ft; + int max_ft_size; + int acl_type; + + struct mlx_vacl_fr loopback_fr; + struct mlx_vacl_fr untagged_fr; + struct mlx_vacl_fr unknown_vlan_fr; + struct mlx_vacl_fr default_fr; + + bool vlan_filter_enabled; + bool vlan_filter_applied; + unsigned long *vlan_allowed_bitmap; + u32 vlan_fi_table[4096]; + + bool spoofchk_enabled; + u8 smac[ETH_ALEN]; +}; + +static int mlx5_vacl_table_allow_vlan(void *acl_t, u16 vlan) +{ + struct mlx5_vacl_table *acl_table = (struct mlx5_vacl_table *)acl_t; + u32 *flow_context = NULL; + void *in_match_criteria = NULL; + void *in_match_value = NULL; + u8 *smac; + int vlan_mc_enable = MLX5_MATCH_OUTER_HEADERS; + int err = 0; + + if (!test_bit(vlan, acl_table->vlan_allowed_bitmap)) + return -EINVAL; + + flow_context = mlx5_vzalloc(MLX5_ST_SZ_BYTES(flow_context)); + if (!flow_context) { + err = -ENOMEM; + goto out; + } + + in_match_criteria = mlx5_vzalloc(MLX5_ST_SZ_BYTES(fte_match_param)); + if (!in_match_criteria) { + err = -ENOMEM; + goto out; + } + + /* Apply vlan rule */ + MLX5_SET(flow_context, flow_context, action, + MLX5_FLOW_CONTEXT_ACTION_ALLOW); + in_match_value = MLX5_ADDR_OF(flow_context, flow_context, match_value); + MLX5_SET(fte_match_param, in_match_value, outer_headers.vlan_tag, 1); + MLX5_SET(fte_match_param, in_match_value, outer_headers.first_vid, + vlan); + MLX5_SET(fte_match_param, in_match_criteria, outer_headers.vlan_tag, 1); + MLX5_SET(fte_match_param, in_match_criteria, outer_headers.first_vid, + 0xfff); + if (acl_table->spoofchk_enabled) { + smac = MLX5_ADDR_OF(fte_match_param, + in_match_value, + outer_headers.smac_47_16); + ether_addr_copy(smac, acl_table->smac); + smac = MLX5_ADDR_OF(fte_match_param, + in_match_criteria, + outer_headers.smac_47_16); + memset(smac, 0xff, ETH_ALEN); + } + err = mlx5_add_flow_table_entry(acl_table->ft, vlan_mc_enable, + in_match_criteria, flow_context, + &acl_table->vlan_fi_table[vlan]); +out: + if (flow_context) + vfree(flow_context); + if (in_match_criteria) + vfree(in_match_criteria); + return err; +} + +static int mlx5_vacl_table_apply_loopback_filter(void *acl_t, u16 new_action) +{ + struct mlx5_vacl_table *acl_table = (struct mlx5_vacl_table *)acl_t; + u8 loopback_mc_enable = MLX5_MATCH_MISC_PARAMETERS; + u32 *flow_context = NULL; + void *in_match_criteria = NULL; + void *in_match_value = NULL; + void *mv_misc = NULL; + void *mc_misc = NULL; + int err = 0; + + flow_context = mlx5_vzalloc(MLX5_ST_SZ_BYTES(flow_context)); + if (!flow_context) { + err = -ENOMEM; + goto out; + } + + in_match_criteria = mlx5_vzalloc(MLX5_ST_SZ_BYTES(fte_match_param)); + if (!in_match_criteria) { + err = -ENOMEM; + goto out; + } + + if (acl_table->loopback_fr.applied) + mlx5_del_flow_table_entry(acl_table->ft, + acl_table->loopback_fr.fi); + + /* Apply new loopback rule */ + MLX5_SET(flow_context, flow_context, action, new_action); + in_match_value = MLX5_ADDR_OF(flow_context, flow_context, match_value); + mv_misc = MLX5_ADDR_OF(fte_match_param, in_match_value, + misc_parameters); + mc_misc = MLX5_ADDR_OF(fte_match_param, in_match_criteria, + misc_parameters); + MLX5_SET(fte_match_set_misc, mv_misc, source_port, acl_table->vport); + + MLX5_SET_TO_ONES(fte_match_set_misc, mc_misc, source_port); + + err = mlx5_add_flow_table_entry(acl_table->ft, loopback_mc_enable, + in_match_criteria, flow_context, + &acl_table->loopback_fr.fi); + if (err) { + acl_table->loopback_fr.applied = false; + } else { + acl_table->loopback_fr.applied = true; + acl_table->loopback_fr.action = new_action; + } + +out: + if (flow_context) + vfree(flow_context); + if (in_match_criteria) + vfree(in_match_criteria); + return err; +} + +static int mlx5_vacl_table_apply_default(void *acl_t, u16 new_action) +{ + struct mlx5_vacl_table *acl_table = (struct mlx5_vacl_table *)acl_t; + u8 default_mc_enable = 0; + u32 *flow_context = NULL; + void *in_match_criteria = NULL; + int err = 0; + + if (!acl_table->spoofchk_enabled) + return -EINVAL; + + flow_context = mlx5_vzalloc(MLX5_ST_SZ_BYTES(flow_context)); + if (!flow_context) { + err = -ENOMEM; + goto out; + } + + in_match_criteria = mlx5_vzalloc(MLX5_ST_SZ_BYTES(fte_match_param)); + if (!in_match_criteria) { + err = -ENOMEM; + goto out; + } + + if (acl_table->default_fr.applied) + mlx5_del_flow_table_entry(acl_table->ft, + acl_table->default_fr.fi); + + /* Apply new default rule */ + MLX5_SET(flow_context, flow_context, action, new_action); + err = mlx5_add_flow_table_entry(acl_table->ft, default_mc_enable, + in_match_criteria, flow_context, + &acl_table->default_fr.fi); + if (err) { + acl_table->default_fr.applied = false; + } else { + acl_table->default_fr.applied = true; + acl_table->default_fr.action = new_action; + } + +out: + if (flow_context) + vfree(flow_context); + if (in_match_criteria) + vfree(in_match_criteria); + return err; +} + +static int mlx5_vacl_table_apply_untagged(void *acl_t, u16 new_action) +{ + struct mlx5_vacl_table *acl_table = (struct mlx5_vacl_table *)acl_t; + u8 untagged_mc_enable = MLX5_MATCH_OUTER_HEADERS; + u8 *smac; + u32 *flow_context = NULL; + void *in_match_criteria = NULL; + void *in_match_value = NULL; + int err = 0; + + flow_context = mlx5_vzalloc(MLX5_ST_SZ_BYTES(flow_context)); + if (!flow_context) { + err = -ENOMEM; + goto out; + } + + in_match_criteria = mlx5_vzalloc(MLX5_ST_SZ_BYTES(fte_match_param)); + if (!in_match_criteria) { + err = -ENOMEM; + goto out; + } + + if (acl_table->untagged_fr.applied) + mlx5_del_flow_table_entry(acl_table->ft, + acl_table->untagged_fr.fi); + + /* Apply new untagged rule */ + MLX5_SET(flow_context, flow_context, action, new_action); + in_match_value = MLX5_ADDR_OF(flow_context, flow_context, match_value); + MLX5_SET(fte_match_param, in_match_value, outer_headers.vlan_tag, 0); + MLX5_SET(fte_match_param, in_match_criteria, outer_headers.vlan_tag, 1); + if (acl_table->spoofchk_enabled) { + smac = MLX5_ADDR_OF(fte_match_param, + in_match_value, + outer_headers.smac_47_16); + ether_addr_copy(smac, acl_table->smac); + smac = MLX5_ADDR_OF(fte_match_param, + in_match_criteria, + outer_headers.smac_47_16); + memset(smac, 0xff, ETH_ALEN); + } + err = mlx5_add_flow_table_entry(acl_table->ft, untagged_mc_enable, + in_match_criteria, flow_context, + &acl_table->untagged_fr.fi); + if (err) { + acl_table->untagged_fr.applied = false; + } else { + acl_table->untagged_fr.applied = true; + acl_table->untagged_fr.action = new_action; + } + +out: + if (flow_context) + vfree(flow_context); + if (in_match_criteria) + vfree(in_match_criteria); + return err; +} + +static int mlx5_vacl_table_apply_unknown_vlan(void *acl_t, u16 new_action) +{ + struct mlx5_vacl_table *acl_table = (struct mlx5_vacl_table *)acl_t; + u8 default_mc_enable = (!acl_table->spoofchk_enabled) ? 0 : + MLX5_MATCH_OUTER_HEADERS; + u32 *flow_context = NULL; + void *in_match_criteria = NULL; + void *in_match_value = NULL; + u8 *smac; + int err = 0; + + flow_context = mlx5_vzalloc(MLX5_ST_SZ_BYTES(flow_context)); + if (!flow_context) { + err = -ENOMEM; + goto out; + } + + in_match_criteria = mlx5_vzalloc(MLX5_ST_SZ_BYTES(fte_match_param)); + if (!in_match_criteria) { + err = -ENOMEM; + goto out; + } + + if (acl_table->unknown_vlan_fr.applied) + mlx5_del_flow_table_entry(acl_table->ft, + acl_table->unknown_vlan_fr.fi); + + /* Apply new unknown vlan rule */ + MLX5_SET(flow_context, flow_context, action, new_action); + if (acl_table->spoofchk_enabled) { + in_match_value = MLX5_ADDR_OF(flow_context, flow_context, + match_value); + smac = MLX5_ADDR_OF(fte_match_param, + in_match_value, + outer_headers.smac_47_16); + ether_addr_copy(smac, acl_table->smac); + smac = MLX5_ADDR_OF(fte_match_param, + in_match_criteria, + outer_headers.smac_47_16); + memset(smac, 0xff, ETH_ALEN); + } + err = mlx5_add_flow_table_entry(acl_table->ft, default_mc_enable, + in_match_criteria, flow_context, + &acl_table->unknown_vlan_fr.fi); + if (err) { + acl_table->unknown_vlan_fr.applied = false; + } else { + acl_table->unknown_vlan_fr.applied = true; + acl_table->unknown_vlan_fr.action = new_action; + } + +out: + if (flow_context) + vfree(flow_context); + if (in_match_criteria) + vfree(in_match_criteria); + return err; +} + +static int mlx5_vacl_table_apply_vlan_filter(void *acl_t) +{ + struct mlx5_vacl_table *acl_table = (struct mlx5_vacl_table *)acl_t; + int index = 0; + int err_index = 0; + int err = 0; + + if (acl_table->vlan_filter_applied) + return 0; + + for (index = find_first_bit(acl_table->vlan_allowed_bitmap, 4096); + index < 4096; + index = find_next_bit(acl_table->vlan_allowed_bitmap, + 4096, ++index)) { + err = mlx5_vacl_table_allow_vlan(acl_t, index); + if (err) + goto err_disable_vlans; + } + + acl_table->vlan_filter_applied = true; + return 0; + +err_disable_vlans: + for (err_index = find_first_bit(acl_table->vlan_allowed_bitmap, 4096); + err_index < index; + err_index = find_next_bit(acl_table->vlan_allowed_bitmap, 4096, + ++err_index)) { + mlx5_del_flow_table_entry(acl_table->ft, + acl_table->vlan_fi_table[err_index]); + } + return err; +} + +static void mlx5_vacl_table_disapply_vlan_filter(void *acl_t) +{ + struct mlx5_vacl_table *acl_table = (struct mlx5_vacl_table *)acl_t; + int index = 0; + + if (!acl_table->vlan_filter_applied) + return; + + for (index = find_first_bit(acl_table->vlan_allowed_bitmap, 4096); + index < 4096; + index = find_next_bit(acl_table->vlan_allowed_bitmap, 4096, + ++index)) { + mlx5_del_flow_table_entry(acl_table->ft, + acl_table->vlan_fi_table[index]); + } + + acl_table->vlan_filter_applied = false; +} + +static void mlx5_vacl_table_disapply_all_filters(void *acl_t) +{ + struct mlx5_vacl_table *acl_table = (struct mlx5_vacl_table *)acl_t; + + if (acl_table->default_fr.applied) { + mlx5_del_flow_table_entry(acl_table->ft, + acl_table->default_fr.fi); + acl_table->default_fr.applied = false; + } + if (acl_table->unknown_vlan_fr.applied) { + mlx5_del_flow_table_entry(acl_table->ft, + acl_table->unknown_vlan_fr.fi); + acl_table->unknown_vlan_fr.applied = false; + } + if (acl_table->loopback_fr.applied) { + mlx5_del_flow_table_entry(acl_table->ft, + acl_table->loopback_fr.fi); + acl_table->loopback_fr.applied = false; + } + if (acl_table->untagged_fr.applied) { + mlx5_del_flow_table_entry(acl_table->ft, + acl_table->untagged_fr.fi); + acl_table->untagged_fr.applied = false; + } + if (acl_table->vlan_filter_applied) { + mlx5_vacl_table_disapply_vlan_filter(acl_t); + acl_table->vlan_filter_applied = false; + } +} + +static int mlx5_vacl_table_apply_all_filters(void *acl_t) +{ + struct mlx5_vacl_table *acl_table = (struct mlx5_vacl_table *)acl_t; + int err = 0; + + if (!acl_table->default_fr.applied && acl_table->spoofchk_enabled) { + err = mlx5_vacl_table_apply_default(acl_table, + acl_table->default_fr.action); + if (err) + goto err_disapply_all; + } + + if (!acl_table->unknown_vlan_fr.applied) { + err = mlx5_vacl_table_apply_unknown_vlan(acl_table, + acl_table->unknown_vlan_fr.action); + if (err) + goto err_disapply_all; + } + + if (!acl_table->loopback_fr.applied && + acl_table->acl_type == MLX5_FLOW_TABLE_TYPE_EGRESS_ACL) { + err = mlx5_vacl_table_apply_loopback_filter( + acl_table, + acl_table->loopback_fr.action); + if (err) + goto err_disapply_all; + } + + if (!acl_table->untagged_fr.applied) { + err = mlx5_vacl_table_apply_untagged(acl_table, + acl_table->untagged_fr.action); + if (err) + goto err_disapply_all; + } + + if (!acl_table->vlan_filter_applied && acl_table->vlan_filter_enabled) { + err = mlx5_vacl_table_apply_vlan_filter(acl_t); + if (err) + goto err_disapply_all; + } + + goto out; + +err_disapply_all: + mlx5_vacl_table_disapply_all_filters(acl_t); + +out: + return err; +} + +static void mlx5_vacl_table_destroy_ft(void *acl_t) +{ + struct mlx5_vacl_table *acl_table = (struct mlx5_vacl_table *)acl_t; + + mlx5_vacl_table_disapply_all_filters(acl_t); + if (acl_table->ft) + mlx5_destroy_flow_table(acl_table->ft); + acl_table->ft = NULL; +} + +static int mlx5_vacl_table_create_ft(void *acl_t, bool spoofchk) +{ + struct mlx5_vacl_table *acl_table = (struct mlx5_vacl_table *)acl_t; + int log_acl_ft_size; + int err = 0; + int groups_num = MLX5_ACL_GROUPS_NUM - 1; + int shift_idx = MLX5_ACL_UNTAGGED_GROUP_IDX; + u8 *smac; + struct mlx5_flow_table_group *g; + + if (acl_table->ft) + return -EINVAL; + + g = kcalloc(MLX5_ACL_GROUPS_NUM, sizeof(*g), GFP_KERNEL); + if (!g) + goto out; + + acl_table->spoofchk_enabled = spoofchk; + + /* + * for vlan group + */ + log_acl_ft_size = 4096; + /* + * for loopback filter rule + */ + log_acl_ft_size += 1; + /* + * for untagged rule + */ + log_acl_ft_size += 1; + /* + * for unknown vlan rule + */ + log_acl_ft_size += 1; + /* + * for default rule + */ + log_acl_ft_size += 1; + + log_acl_ft_size = order_base_2(log_acl_ft_size); + log_acl_ft_size = min_t(int, log_acl_ft_size, acl_table->max_ft_size); + + if (log_acl_ft_size < 2) + goto out; + + if (acl_table->acl_type == MLX5_FLOW_TABLE_TYPE_EGRESS_ACL) { + /* Loopback filter group */ + g[MLX5_ACL_LOOPBACK_GROUP_IDX].log_sz = 0; + g[MLX5_ACL_LOOPBACK_GROUP_IDX].match_criteria_enable = + MLX5_MATCH_MISC_PARAMETERS; + MLX5_SET_TO_ONES(fte_match_param, + g[MLX5_ACL_LOOPBACK_GROUP_IDX].match_criteria, + misc_parameters.source_port); + groups_num++; + shift_idx = MLX5_ACL_LOOPBACK_GROUP_IDX; + } + /* Untagged traffic group */ + g[MLX5_ACL_UNTAGGED_GROUP_IDX - shift_idx].log_sz = 0; + g[MLX5_ACL_UNTAGGED_GROUP_IDX - shift_idx].match_criteria_enable = + MLX5_MATCH_OUTER_HEADERS; + MLX5_SET(fte_match_param, + g[MLX5_ACL_UNTAGGED_GROUP_IDX - shift_idx].match_criteria, + outer_headers.vlan_tag, 1); + if (spoofchk) { + smac = MLX5_ADDR_OF(fte_match_param, + g[MLX5_ACL_UNTAGGED_GROUP_IDX - shift_idx] + .match_criteria, + outer_headers.smac_47_16); + memset(smac, 0xff, ETH_ALEN); + } + + /* Allowed vlans group */ + g[MLX5_ACL_VLAN_GROUP_IDX - shift_idx].log_sz = log_acl_ft_size - 1; + g[MLX5_ACL_VLAN_GROUP_IDX - shift_idx].match_criteria_enable = + MLX5_MATCH_OUTER_HEADERS; + MLX5_SET(fte_match_param, + g[MLX5_ACL_VLAN_GROUP_IDX - shift_idx].match_criteria, + outer_headers.vlan_tag, 1); + MLX5_SET(fte_match_param, + g[MLX5_ACL_VLAN_GROUP_IDX - shift_idx].match_criteria, + outer_headers.first_vid, 0xfff); + if (spoofchk) { + smac = MLX5_ADDR_OF(fte_match_param, + g[MLX5_ACL_VLAN_GROUP_IDX - shift_idx] + .match_criteria, + outer_headers.smac_47_16); + memset(smac, 0xff, ETH_ALEN); + } + + /* Unknown vlan traffic group */ + g[MLX5_ACL_UNKNOWN_VLAN_GROUP_IDX - shift_idx].log_sz = 0; + g[MLX5_ACL_UNKNOWN_VLAN_GROUP_IDX - shift_idx].match_criteria_enable = + (spoofchk ? MLX5_MATCH_OUTER_HEADERS : 0); + if (spoofchk) { + smac = MLX5_ADDR_OF( + fte_match_param, + g[MLX5_ACL_UNKNOWN_VLAN_GROUP_IDX - shift_idx] + .match_criteria, + outer_headers.smac_47_16); + memset(smac, 0xff, ETH_ALEN); + } + + /* + * Default group - for spoofchk only. + */ + g[MLX5_ACL_DEFAULT_GROUP_IDX - shift_idx].log_sz = 0; + g[MLX5_ACL_DEFAULT_GROUP_IDX - shift_idx].match_criteria_enable = 0; + + acl_table->ft = mlx5_create_flow_table(acl_table->dev, + 0, + acl_table->acl_type, + acl_table->vport, + groups_num, + g); + if (!acl_table->ft) { + err = -ENOMEM; + goto out; + } + + err = mlx5_vacl_table_apply_all_filters(acl_t); + if (err) + goto err_destroy_ft; + + goto out; + +err_destroy_ft: + mlx5_vacl_table_destroy_ft(acl_table->ft); + acl_table->ft = NULL; + +out: + kfree(g); + return err; +} + +void *mlx5_vacl_table_create(struct mlx5_core_dev *dev, + u16 vport, bool is_egress) +{ + struct mlx5_vacl_table *acl_table; + int err = 0; + + if (is_egress && !MLX5_CAP_ESW_FLOWTABLE_EGRESS_ACL(dev, ft_support)) + return NULL; + + if (!is_egress && !MLX5_CAP_ESW_FLOWTABLE_INGRESS_ACL(dev, ft_support)) + return NULL; + + acl_table = kzalloc(sizeof(*acl_table), GFP_KERNEL); + if (!acl_table) + return NULL; + + acl_table->acl_type = is_egress ? MLX5_FLOW_TABLE_TYPE_EGRESS_ACL : + MLX5_FLOW_TABLE_TYPE_INGRESS_ACL; + acl_table->max_ft_size = (is_egress ? + MLX5_CAP_ESW_FLOWTABLE_EGRESS_ACL(dev, + log_max_ft_size) : + MLX5_CAP_ESW_FLOWTABLE_INGRESS_ACL(dev, + log_max_ft_size)); + acl_table->dev = dev; + acl_table->vport = vport; + + /* + * default behavior : Allow and if spoofchk drop the default + */ + acl_table->default_fr.action = MLX5_FLOW_CONTEXT_ACTION_DROP; + acl_table->loopback_fr.action = MLX5_FLOW_CONTEXT_ACTION_DROP; + acl_table->unknown_vlan_fr.action = MLX5_FLOW_CONTEXT_ACTION_ALLOW; + acl_table->untagged_fr.action = MLX5_FLOW_CONTEXT_ACTION_ALLOW; + err = mlx5_vacl_table_create_ft(acl_table, false); + if (err) + goto err_free_acl_table; + + acl_table->vlan_allowed_bitmap = kcalloc(BITS_TO_LONGS(4096), + sizeof(uintptr_t), + GFP_KERNEL); + if (!acl_table->vlan_allowed_bitmap) + goto err_destroy_ft; + + goto out; + +err_destroy_ft: + mlx5_vacl_table_destroy_ft(acl_table->ft); + acl_table->ft = NULL; + +err_free_acl_table: + kfree(acl_table); + acl_table = NULL; + +out: + return (void *)acl_table; +} +EXPORT_SYMBOL(mlx5_vacl_table_create); + +void mlx5_vacl_table_cleanup(void *acl_t) +{ + struct mlx5_vacl_table *acl_table = (struct mlx5_vacl_table *)acl_t; + + mlx5_vacl_table_destroy_ft(acl_t); + kfree(acl_table->vlan_allowed_bitmap); + kfree(acl_table); +} +EXPORT_SYMBOL(mlx5_vacl_table_cleanup); + +int mlx5_vacl_table_add_vlan(void *acl_t, u16 vlan) +{ + struct mlx5_vacl_table *acl_table = (struct mlx5_vacl_table *)acl_t; + int err = 0; + + if (test_bit(vlan, acl_table->vlan_allowed_bitmap)) + return 0; + __set_bit(vlan, acl_table->vlan_allowed_bitmap); + if (!acl_table->vlan_filter_applied) + return 0; + + err = mlx5_vacl_table_allow_vlan(acl_t, vlan); + if (err) + goto err_clear_vbit; + + goto out; + +err_clear_vbit: + __clear_bit(vlan, acl_table->vlan_allowed_bitmap); + +out: + return err; +} +EXPORT_SYMBOL(mlx5_vacl_table_add_vlan); + +void mlx5_vacl_table_del_vlan(void *acl_t, u16 vlan) +{ + struct mlx5_vacl_table *acl_table = (struct mlx5_vacl_table *)acl_t; + + if (!test_bit(vlan, acl_table->vlan_allowed_bitmap)) + return; + + __clear_bit(vlan, acl_table->vlan_allowed_bitmap); + + if (!acl_table->vlan_filter_applied) + return; + + mlx5_del_flow_table_entry(acl_table->ft, + acl_table->vlan_fi_table[vlan]); +} +EXPORT_SYMBOL(mlx5_vacl_table_del_vlan); + +int mlx5_vacl_table_enable_vlan_filter(void *acl_t) +{ + struct mlx5_vacl_table *acl_table = (struct mlx5_vacl_table *)acl_t; + + acl_table->vlan_filter_enabled = true; + return mlx5_vacl_table_apply_vlan_filter(acl_t); +} +EXPORT_SYMBOL(mlx5_vacl_table_enable_vlan_filter); + +void mlx5_vacl_table_disable_vlan_filter(void *acl_t) +{ + struct mlx5_vacl_table *acl_table = (struct mlx5_vacl_table *)acl_t; + + acl_table->vlan_filter_enabled = false; + mlx5_vacl_table_disapply_vlan_filter(acl_t); +} +EXPORT_SYMBOL(mlx5_vacl_table_disable_vlan_filter); + +int mlx5_vacl_table_drop_untagged(void *acl_t) +{ + return mlx5_vacl_table_apply_untagged(acl_t, + MLX5_FLOW_CONTEXT_ACTION_DROP); +} +EXPORT_SYMBOL(mlx5_vacl_table_drop_untagged); + +int mlx5_vacl_table_allow_untagged(void *acl_t) +{ + return mlx5_vacl_table_apply_untagged(acl_t, + MLX5_FLOW_CONTEXT_ACTION_ALLOW); +} +EXPORT_SYMBOL(mlx5_vacl_table_allow_untagged); + +int mlx5_vacl_table_drop_unknown_vlan(void *acl_t) +{ + return mlx5_vacl_table_apply_unknown_vlan(acl_t, + MLX5_FLOW_CONTEXT_ACTION_DROP); +} +EXPORT_SYMBOL(mlx5_vacl_table_drop_unknown_vlan); + +int mlx5_vacl_table_allow_unknown_vlan(void *acl_t) +{ + return mlx5_vacl_table_apply_unknown_vlan(acl_t, + MLX5_FLOW_CONTEXT_ACTION_ALLOW); +} +EXPORT_SYMBOL(mlx5_vacl_table_allow_unknown_vlan); + +int mlx5_vacl_table_set_spoofchk(void *acl_t, bool spoofchk, u8 *vport_mac) +{ + struct mlx5_vacl_table *acl_table = (struct mlx5_vacl_table *)acl_t; + int err = 0; + + if (spoofchk == acl_table->spoofchk_enabled) { + if (!spoofchk || + (spoofchk && !memcmp(acl_table->smac, vport_mac, ETH_ALEN))) + return 0; + } + + ether_addr_copy(acl_table->smac, vport_mac); + if (spoofchk != acl_table->spoofchk_enabled) { + mlx5_vacl_table_destroy_ft(acl_t); + err = mlx5_vacl_table_create_ft(acl_t, spoofchk); + } else { + mlx5_vacl_table_disapply_all_filters(acl_t); + err = mlx5_vacl_table_apply_all_filters(acl_t); + } + + return err; +} +EXPORT_SYMBOL(mlx5_vacl_table_set_spoofchk); + diff --git a/sys/dev/mlx5/mlx5_core/mlx5_vport.c b/sys/dev/mlx5/mlx5_core/mlx5_vport.c index 803f119..5c8626b 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_vport.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_vport.c @@ -328,7 +328,8 @@ int mlx5_set_nic_vport_current_mac(struct mlx5_core_dev *mdev, int vport, MLX5_SET(modify_nic_vport_context_in, in, field_select.addresses_list, 1); MLX5_SET(modify_nic_vport_context_in, in, - nic_vport_context.allowed_list_type, 0); + nic_vport_context.allowed_list_type, + MLX5_NIC_VPORT_LIST_TYPE_UC); MLX5_SET(modify_nic_vport_context_in, in, nic_vport_context.allowed_list_size, 1); @@ -345,6 +346,131 @@ int mlx5_set_nic_vport_current_mac(struct mlx5_core_dev *mdev, int vport, return err; } EXPORT_SYMBOL_GPL(mlx5_set_nic_vport_current_mac); + +int mlx5_set_nic_vport_vlan_list(struct mlx5_core_dev *dev, u32 vport, + u16 *vlan_list, int list_len) +{ + void *in, *ctx; + int i, err; + int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in) + + MLX5_ST_SZ_BYTES(vlan_layout) * (int)list_len; + + int max_list_size = 1 << MLX5_CAP_GEN_MAX(dev, log_max_vlan_list); + + if (list_len > max_list_size) { + mlx5_core_warn(dev, "Requested list size (%d) > (%d) max_list_size\n", + list_len, max_list_size); + return -ENOSPC; + } + + in = mlx5_vzalloc(inlen); + if (!in) { + mlx5_core_warn(dev, "failed to allocate inbox\n"); + return -ENOMEM; + } + + MLX5_SET(modify_nic_vport_context_in, in, vport_number, vport); + if (vport) + MLX5_SET(modify_nic_vport_context_in, in, + other_vport, 1); + MLX5_SET(modify_nic_vport_context_in, in, + field_select.addresses_list, 1); + + ctx = MLX5_ADDR_OF(modify_nic_vport_context_in, in, nic_vport_context); + + MLX5_SET(nic_vport_context, ctx, allowed_list_type, + MLX5_NIC_VPORT_LIST_TYPE_VLAN); + MLX5_SET(nic_vport_context, ctx, allowed_list_size, list_len); + + for (i = 0; i < list_len; i++) { + u8 *vlan_lout = MLX5_ADDR_OF(nic_vport_context, ctx, + current_uc_mac_address[i]); + MLX5_SET(vlan_layout, vlan_lout, vlan, vlan_list[i]); + } + + err = mlx5_modify_nic_vport_context(dev, in, inlen); + + kvfree(in); + return err; +} +EXPORT_SYMBOL_GPL(mlx5_set_nic_vport_vlan_list); + +int mlx5_set_nic_vport_mc_list(struct mlx5_core_dev *mdev, int vport, + u64 *addr_list, size_t addr_list_len) +{ + void *in, *ctx; + int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in) + + MLX5_ST_SZ_BYTES(mac_address_layout) * (int)addr_list_len; + int err; + size_t i; + int max_list_sz = 1 << MLX5_CAP_GEN_MAX(mdev, log_max_current_mc_list); + + if ((int)addr_list_len > max_list_sz) { + mlx5_core_warn(mdev, "Requested list size (%d) > (%d) max_list_size\n", + (int)addr_list_len, max_list_sz); + return -ENOSPC; + } + + in = mlx5_vzalloc(inlen); + if (!in) { + mlx5_core_warn(mdev, "failed to allocate inbox\n"); + return -ENOMEM; + } + + MLX5_SET(modify_nic_vport_context_in, in, vport_number, vport); + if (vport) + MLX5_SET(modify_nic_vport_context_in, in, + other_vport, 1); + MLX5_SET(modify_nic_vport_context_in, in, + field_select.addresses_list, 1); + + ctx = MLX5_ADDR_OF(modify_nic_vport_context_in, in, nic_vport_context); + + MLX5_SET(nic_vport_context, ctx, allowed_list_type, + MLX5_NIC_VPORT_LIST_TYPE_MC); + MLX5_SET(nic_vport_context, ctx, allowed_list_size, addr_list_len); + + for (i = 0; i < addr_list_len; i++) { + u8 *mac_lout = (u8 *)MLX5_ADDR_OF(nic_vport_context, ctx, + current_uc_mac_address[i]); + u8 *mac_ptr = (u8 *)MLX5_ADDR_OF(mac_address_layout, mac_lout, + mac_addr_47_32); + ether_addr_copy(mac_ptr, (u8 *)&addr_list[i]); + } + + err = mlx5_modify_nic_vport_context(mdev, in, inlen); + + kvfree(in); + + return err; +} +EXPORT_SYMBOL_GPL(mlx5_set_nic_vport_mc_list); + +int mlx5_set_nic_vport_promisc(struct mlx5_core_dev *mdev, int vport, + bool promisc_mc, bool promisc_uc, + bool promisc_all) +{ + u8 in[MLX5_ST_SZ_BYTES(modify_nic_vport_context_in)]; + u8 *ctx = MLX5_ADDR_OF(modify_nic_vport_context_in, in, + nic_vport_context); + + memset(in, 0, MLX5_ST_SZ_BYTES(modify_nic_vport_context_in)); + + MLX5_SET(modify_nic_vport_context_in, in, vport_number, vport); + if (vport) + MLX5_SET(modify_nic_vport_context_in, in, + other_vport, 1); + MLX5_SET(modify_nic_vport_context_in, in, field_select.promisc, 1); + if (promisc_mc) + MLX5_SET(nic_vport_context, ctx, promisc_mc, 1); + if (promisc_uc) + MLX5_SET(nic_vport_context, ctx, promisc_uc, 1); + if (promisc_all) + MLX5_SET(nic_vport_context, ctx, promisc_all, 1); + + return mlx5_modify_nic_vport_context(mdev, in, sizeof(in)); +} +EXPORT_SYMBOL_GPL(mlx5_set_nic_vport_promisc); int mlx5_set_nic_vport_permanent_mac(struct mlx5_core_dev *mdev, int vport, u8 *addr) { diff --git a/sys/dev/mlx5/mlx5_en/en.h b/sys/dev/mlx5/mlx5_en/en.h index 5339006..23e4fd0 100644 --- a/sys/dev/mlx5/mlx5_en/en.h +++ b/sys/dev/mlx5/mlx5_en/en.h @@ -50,6 +50,13 @@ #include <net/ethernet.h> #include <sys/buf_ring.h> +#include "opt_rss.h" + +#ifdef RSS +#include <net/rss_config.h> +#include <netinet/in_rss.h> +#endif + #include <machine/bus.h> #ifdef HAVE_TURBO_LRO @@ -356,6 +363,7 @@ struct mlx5e_params { u8 default_vlan_prio; u8 num_tc; u8 rx_cq_moderation_mode; + u8 tx_cq_moderation_mode; u16 rx_cq_moderation_usec; u16 rx_cq_moderation_pkts; u16 tx_cq_moderation_usec; @@ -381,6 +389,7 @@ struct mlx5e_params { m(+1, u64 rx_coalesce_mode, "rx_coalesce_mode", "0: EQE mode 1: CQE mode") \ m(+1, u64 tx_coalesce_usecs, "tx_coalesce_usecs", "Limit in usec for joining tx packets") \ m(+1, u64 tx_coalesce_pkts, "tx_coalesce_pkts", "Maximum number of tx packets to join") \ + m(+1, u64 tx_coalesce_mode, "tx_coalesce_mode", "0: EQE mode 1: CQE mode") \ m(+1, u64 hw_lro, "hw_lro", "set to enable hw_lro") #define MLX5E_PARAMS_NUM (0 MLX5E_PARAMS(MLX5E_STATS_COUNT)) diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c b/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c index 6a7b911..eede82f 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c @@ -136,6 +136,11 @@ mlx5e_ethtool_handler(SYSCTL_HANDLER_ARGS) priv->params_ethtool.rx_coalesce_mode = 1; priv->params.rx_cq_moderation_mode = priv->params_ethtool.rx_coalesce_mode; + /* import TX mode */ + if (priv->params_ethtool.tx_coalesce_mode != 0) + priv->params_ethtool.tx_coalesce_mode = 1; + priv->params.tx_cq_moderation_mode = priv->params_ethtool.tx_coalesce_mode; + /* import RX coal time */ if (priv->params_ethtool.rx_coalesce_usecs < 1) priv->params_ethtool.rx_coalesce_usecs = 0; @@ -460,6 +465,7 @@ mlx5e_create_ethtool(struct mlx5e_priv *priv) priv->params_ethtool.rx_coalesce_mode = priv->params.rx_cq_moderation_mode; priv->params_ethtool.rx_coalesce_usecs = priv->params.rx_cq_moderation_usec; priv->params_ethtool.rx_coalesce_pkts = priv->params.rx_cq_moderation_pkts; + priv->params_ethtool.tx_coalesce_mode = priv->params.tx_cq_moderation_mode; priv->params_ethtool.tx_coalesce_usecs = priv->params.tx_cq_moderation_usec; priv->params_ethtool.tx_coalesce_pkts = priv->params.tx_cq_moderation_pkts; priv->params_ethtool.hw_lro = priv->params.hw_lro_en; diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c index a4a1ec7..77aaf7b 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c @@ -931,6 +931,10 @@ mlx5e_create_sq(struct mlx5e_channel *c, void *sqc = param->sqc; void *sqc_wq = MLX5_ADDR_OF(sqc, sqc, wq); +#ifdef RSS + cpuset_t cpu_mask; + int cpu_id; +#endif int err; /* Create DMA descriptor TAG */ @@ -991,9 +995,15 @@ mlx5e_create_sq(struct mlx5e_channel *c, } TASK_INIT(&sq->sq_task, 0, mlx5e_tx_que, sq); - taskqueue_start_threads(&sq->sq_tq, 1, PI_NET, "%s tx sq", - c->ifp->if_xname); - +#ifdef RSS + cpu_id = rss_getcpu(c->ix % rss_getnumbuckets()); + CPU_SETOF(cpu_id, &cpu_mask); + taskqueue_start_threads_cpuset(&sq->sq_tq, 1, PI_NET, &cpu_mask, + "%s TX SQ%d.%d CPU%d", c->ifp->if_xname, c->ix, tc, cpu_id); +#else + taskqueue_start_threads(&sq->sq_tq, 1, PI_NET, + "%s TX SQ%d.%d", c->ifp->if_xname, c->ix, tc); +#endif snprintf(buffer, sizeof(buffer), "txstat%dtc%d", c->ix, tc); mlx5e_create_stats(&sq->stats.ctx, SYSCTL_CHILDREN(priv->sysctl_ifnet), buffer, mlx5e_sq_stats_desc, MLX5E_SQ_STATS_NUM, @@ -1324,13 +1334,25 @@ static int mlx5e_open_tx_cqs(struct mlx5e_channel *c, struct mlx5e_channel_param *cparam) { + u8 tx_moderation_mode; int err; int tc; + switch (c->priv->params.tx_cq_moderation_mode) { + case 0: + tx_moderation_mode = MLX5_CQ_PERIOD_MODE_START_FROM_EQE; + break; + default: + if (MLX5_CAP_GEN(c->priv->mdev, cq_period_start_from_cqe)) + tx_moderation_mode = MLX5_CQ_PERIOD_MODE_START_FROM_CQE; + else + tx_moderation_mode = MLX5_CQ_PERIOD_MODE_START_FROM_EQE; + break; + } for (tc = 0; tc < c->num_tc; tc++) { /* open completion queue */ err = mlx5e_open_cq(c, &cparam->tx_cq, &c->sq[tc].cq, - &mlx5e_tx_cq_comp, MLX5_CQ_PERIOD_MODE_START_FROM_EQE); + &mlx5e_tx_cq_comp, tx_moderation_mode); if (err) goto err_close_tx_cqs; } @@ -1756,8 +1778,14 @@ mlx5e_open_rqt(struct mlx5e_priv *priv) MLX5_SET(rqtc, rqtc, rqt_max_size, sz); for (i = 0; i < sz; i++) { - int ix = i % priv->params.num_channels; - + int ix; +#ifdef RSS + ix = rss_get_indirection_to_bucket(i); +#else + ix = i; +#endif + /* ensure we don't overflow */ + ix %= priv->params.num_channels; MLX5_SET(rqtc, rqtc, rq_num[i], priv->channel[ix]->rq.rqn); } @@ -1822,6 +1850,8 @@ mlx5e_build_tir_ctx(struct mlx5e_priv *priv, u32 * tirc, int tt) MLX5_CAP_ETH(priv->mdev, lro_timer_supported_periods[2])); } + + /* setup parameters for hashing TIR type, if any */ switch (tt) { case MLX5E_TT_ANY: MLX5_SET(tirc, tirc, disp_type, @@ -1836,8 +1866,16 @@ mlx5e_build_tir_ctx(struct mlx5e_priv *priv, u32 * tirc, int tt) priv->rqtn); MLX5_SET(tirc, tirc, rx_hash_fn, MLX5_TIRC_RX_HASH_FN_HASH_TOEPLITZ); - MLX5_SET(tirc, tirc, rx_hash_symmetric, 1); hkey = (__be32 *) MLX5_ADDR_OF(tirc, tirc, rx_hash_toeplitz_key); +#ifdef RSS + /* + * The FreeBSD RSS implementation does currently not + * support symmetric Toeplitz hashes: + */ + MLX5_SET(tirc, tirc, rx_hash_symmetric, 0); + rss_getkey((uint8_t *)hkey); +#else + MLX5_SET(tirc, tirc, rx_hash_symmetric, 1); hkey[0] = cpu_to_be32(0xD181C62C); hkey[1] = cpu_to_be32(0xF7F4DB5B); hkey[2] = cpu_to_be32(0x1983A2FC); @@ -1848,6 +1886,7 @@ mlx5e_build_tir_ctx(struct mlx5e_priv *priv, u32 * tirc, int tt) hkey[7] = cpu_to_be32(0x593D56D9); hkey[8] = cpu_to_be32(0xF3253C06); hkey[9] = cpu_to_be32(0x2ADC1FFC); +#endif break; } @@ -1857,6 +1896,12 @@ mlx5e_build_tir_ctx(struct mlx5e_priv *priv, u32 * tirc, int tt) MLX5_L3_PROT_TYPE_IPV4); MLX5_SET(rx_hash_field_select, hfso, l4_prot_type, MLX5_L4_PROT_TYPE_TCP); +#ifdef RSS + if (!(rss_gethashconfig() & RSS_HASHTYPE_RSS_TCP_IPV4)) { + MLX5_SET(rx_hash_field_select, hfso, selected_fields, + MLX5_HASH_IP); + } else +#endif MLX5_SET(rx_hash_field_select, hfso, selected_fields, MLX5_HASH_ALL); break; @@ -1866,6 +1911,12 @@ mlx5e_build_tir_ctx(struct mlx5e_priv *priv, u32 * tirc, int tt) MLX5_L3_PROT_TYPE_IPV6); MLX5_SET(rx_hash_field_select, hfso, l4_prot_type, MLX5_L4_PROT_TYPE_TCP); +#ifdef RSS + if (!(rss_gethashconfig() & RSS_HASHTYPE_RSS_TCP_IPV6)) { + MLX5_SET(rx_hash_field_select, hfso, selected_fields, + MLX5_HASH_IP); + } else +#endif MLX5_SET(rx_hash_field_select, hfso, selected_fields, MLX5_HASH_ALL); break; @@ -1875,6 +1926,12 @@ mlx5e_build_tir_ctx(struct mlx5e_priv *priv, u32 * tirc, int tt) MLX5_L3_PROT_TYPE_IPV4); MLX5_SET(rx_hash_field_select, hfso, l4_prot_type, MLX5_L4_PROT_TYPE_UDP); +#ifdef RSS + if (!(rss_gethashconfig() & RSS_HASHTYPE_RSS_UDP_IPV4)) { + MLX5_SET(rx_hash_field_select, hfso, selected_fields, + MLX5_HASH_IP); + } else +#endif MLX5_SET(rx_hash_field_select, hfso, selected_fields, MLX5_HASH_ALL); break; @@ -1884,6 +1941,12 @@ mlx5e_build_tir_ctx(struct mlx5e_priv *priv, u32 * tirc, int tt) MLX5_L3_PROT_TYPE_IPV6); MLX5_SET(rx_hash_field_select, hfso, l4_prot_type, MLX5_L4_PROT_TYPE_UDP); +#ifdef RSS + if (!(rss_gethashconfig() & RSS_HASHTYPE_RSS_UDP_IPV6)) { + MLX5_SET(rx_hash_field_select, hfso, selected_fields, + MLX5_HASH_IP); + } else +#endif MLX5_SET(rx_hash_field_select, hfso, selected_fields, MLX5_HASH_ALL); break; @@ -2005,32 +2068,15 @@ mlx5e_set_dev_port_mtu(struct ifnet *ifp, int sw_mtu) struct mlx5e_priv *priv = ifp->if_softc; struct mlx5_core_dev *mdev = priv->mdev; int hw_mtu; - int min_mtu; int err; - /* - * Trying to set MTU to zero, in order - * to find out the FW's minimal MTU - */ - err = mlx5_set_port_mtu(mdev, 0); - if (err) - return (err); - err = mlx5_query_port_oper_mtu(mdev, &min_mtu); + err = mlx5_set_port_mtu(mdev, MLX5E_SW2HW_MTU(sw_mtu)); if (err) { - if_printf(ifp, "Query port minimal MTU failed\n"); + if_printf(ifp, "%s: mlx5_set_port_mtu failed setting %d, err=%d\n", + __func__, sw_mtu, err); return (err); } - - if (sw_mtu < MLX5E_HW2SW_MTU(min_mtu)) { - ifp->if_mtu = sw_mtu; - return (0); - } - - err = mlx5_set_port_mtu(mdev, MLX5E_SW2HW_MTU(sw_mtu)); - if (err) - return (err); - err = mlx5_query_port_oper_mtu(mdev, &hw_mtu); if (!err) { ifp->if_mtu = MLX5E_HW2SW_MTU(hw_mtu); @@ -2057,6 +2103,13 @@ mlx5e_open_locked(struct ifnet *ifp) if (test_bit(MLX5E_STATE_OPENED, &priv->state) != 0) return (0); +#ifdef RSS + if (rss_getnumbuckets() > priv->params.num_channels) { + if_printf(ifp, "NOTE: There are more RSS buckets(%u) than " + "channels(%u) available\n", rss_getnumbuckets(), + priv->params.num_channels); + } +#endif err = mlx5e_open_tises(priv); if (err) { if_printf(ifp, "%s: mlx5e_open_tises failed, %d\n", diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c b/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c index 3e827bd..87fc524 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c @@ -192,12 +192,43 @@ mlx5e_build_rx_mbuf(struct mlx5_cqe64 *cqe, mb->m_pkthdr.len = mb->m_len = cqe_bcnt; /* check if a Toeplitz hash was computed */ - if (cqe->rss_hash_type != 0) + if (cqe->rss_hash_type != 0) { mb->m_pkthdr.flowid = be32_to_cpu(cqe->rss_hash_result); - else +#ifdef RSS + /* decode the RSS hash type */ + switch (cqe->rss_hash_type & + (CQE_RSS_DST_HTYPE_L4 | CQE_RSS_DST_HTYPE_IP)) { + /* IPv4 */ + case (CQE_RSS_DST_HTYPE_TCP | CQE_RSS_DST_HTYPE_IPV4): + M_HASHTYPE_SET(mb, M_HASHTYPE_RSS_TCP_IPV4); + break; + case (CQE_RSS_DST_HTYPE_UDP | CQE_RSS_DST_HTYPE_IPV4): + M_HASHTYPE_SET(mb, M_HASHTYPE_RSS_UDP_IPV4); + break; + case CQE_RSS_DST_HTYPE_IPV4: + M_HASHTYPE_SET(mb, M_HASHTYPE_RSS_IPV4); + break; + /* IPv6 */ + case (CQE_RSS_DST_HTYPE_TCP | CQE_RSS_DST_HTYPE_IPV6): + M_HASHTYPE_SET(mb, M_HASHTYPE_RSS_TCP_IPV6); + break; + case (CQE_RSS_DST_HTYPE_UDP | CQE_RSS_DST_HTYPE_IPV6): + M_HASHTYPE_SET(mb, M_HASHTYPE_RSS_UDP_IPV6); + break; + case CQE_RSS_DST_HTYPE_IPV6: + M_HASHTYPE_SET(mb, M_HASHTYPE_RSS_IPV6); + break; + default: /* Other */ + M_HASHTYPE_SET(mb, M_HASHTYPE_OPAQUE); + break; + } +#else + M_HASHTYPE_SET(mb, M_HASHTYPE_OPAQUE); +#endif + } else { mb->m_pkthdr.flowid = rq->ix; - - M_HASHTYPE_SET(mb, M_HASHTYPE_OPAQUE); + M_HASHTYPE_SET(mb, M_HASHTYPE_OPAQUE); + } mb->m_pkthdr.rcvif = ifp; if (likely(ifp->if_capenable & (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6)) && diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c b/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c index 0256fc7..cb08727 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c @@ -85,7 +85,15 @@ mlx5e_select_queue(struct ifnet *ifp, struct mbuf *mb) /* check if flowid is set */ if (M_HASHTYPE_GET(mb) != M_HASHTYPE_NONE) { - ch = (mb->m_pkthdr.flowid % 128) % ch; +#ifdef RSS + u32 temp; + + if (rss_hash2bucket(mb->m_pkthdr.flowid, + M_HASHTYPE_GET(mb), &temp) == 0) + ch = temp % ch; + else +#endif + ch = (mb->m_pkthdr.flowid % 128) % ch; } else { #if (__FreeBSD_version >= 1100000) ch = m_ether_tcpip_hash(MBUF_HASHFLAG_L3 | diff --git a/sys/dev/mlx5/vport.h b/sys/dev/mlx5/vport.h index 7d79c59..c5948e7 100644 --- a/sys/dev/mlx5/vport.h +++ b/sys/dev/mlx5/vport.h @@ -42,6 +42,13 @@ int mlx5_query_nic_vport_mac_address(struct mlx5_core_dev *mdev, u32 vport, u8 *addr); int mlx5_set_nic_vport_current_mac(struct mlx5_core_dev *mdev, int vport, bool other_vport, u8 *addr); +int mlx5_set_nic_vport_vlan_list(struct mlx5_core_dev *dev, u32 vport, + u16 *vlan_list, int list_len); +int mlx5_set_nic_vport_mc_list(struct mlx5_core_dev *mdev, int vport, + u64 *addr_list, size_t addr_list_len); +int mlx5_set_nic_vport_promisc(struct mlx5_core_dev *mdev, int vport, + bool promisc_mc, bool promisc_uc, + bool promisc_all); int mlx5_set_nic_vport_permanent_mac(struct mlx5_core_dev *mdev, int vport, u8 *addr); int mlx5_nic_vport_enable_roce(struct mlx5_core_dev *mdev); diff --git a/sys/dev/sfxge/common/efsys.h b/sys/dev/sfxge/common/efsys.h index be73ea1..10dc04d 100644 --- a/sys/dev/sfxge/common/efsys.h +++ b/sys/dev/sfxge/common/efsys.h @@ -246,6 +246,7 @@ sfxge_map_mbuf_fast(bus_dma_tag_t tag, bus_dmamap_t map, #define EFSYS_OPT_MCDI 1 #define EFSYS_OPT_MCDI_LOGGING 0 +#define EFSYS_OPT_MCDI_PROXY_AUTH 0 #define EFSYS_OPT_MAC_FALCON_GMAC 0 #define EFSYS_OPT_MAC_FALCON_XMAC 0 diff --git a/sys/dev/sfxge/common/efx.h b/sys/dev/sfxge/common/efx.h index 671c84a..531b6c9 100644 --- a/sys/dev/sfxge/common/efx.h +++ b/sys/dev/sfxge/common/efx.h @@ -1173,8 +1173,10 @@ typedef struct efx_nic_cfg_s { /* Datapath firmware vadapter/vport/vswitch support */ boolean_t enc_datapath_cap_evb; boolean_t enc_rx_disable_scatter_supported; + boolean_t enc_allow_set_mac_with_installed_filters; /* External port identifier */ uint8_t enc_external_port; + uint32_t enc_mcdi_max_payload_length; } efx_nic_cfg_t; #define EFX_PCI_FUNCTION_IS_PF(_encp) ((_encp)->enc_vf == 0xffff) @@ -2026,6 +2028,9 @@ efx_tx_fini( #define EFX_TXQ_MAX_BUFS 8 /* Maximum independent of EFX_BUG35388_WORKAROUND. */ +#define EFX_TXQ_CKSUM_IPV4 0x0001 +#define EFX_TXQ_CKSUM_TCPUDP 0x0002 + extern __checkReturn efx_rc_t efx_tx_qcreate( __in efx_nic_t *enp, diff --git a/sys/dev/sfxge/common/efx_check.h b/sys/dev/sfxge/common/efx_check.h index e3a6827..684cbbf 100644 --- a/sys/dev/sfxge/common/efx_check.h +++ b/sys/dev/sfxge/common/efx_check.h @@ -153,6 +153,13 @@ # endif #endif /* EFSYS_OPT_MCDI_LOGGING */ +/* Support MCDI proxy authorization */ +#if EFSYS_OPT_MCDI_PROXY_AUTH +# if !EFSYS_OPT_MCDI +# error "MCDI_PROXY_AUTH requires MCDI" +# endif +#endif /* EFSYS_OPT_MCDI_PROXY_AUTH */ + /* Support LM87 monitor */ #if EFSYS_OPT_MON_LM87 # if !EFSYS_OPT_FALCON diff --git a/sys/dev/sfxge/common/efx_crc32.c b/sys/dev/sfxge/common/efx_crc32.c index 7e4cfc4..1fb8b02 100644 --- a/sys/dev/sfxge/common/efx_crc32.c +++ b/sys/dev/sfxge/common/efx_crc32.c @@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$"); * with polynomial 0x04c11db7 (bit-reversed 0xedb88320) */ -static const uint32_t crc32_table[256] = { +static const uint32_t efx_crc32_table[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, @@ -120,7 +120,7 @@ efx_crc32_calculate( for (index = 0; index < length; index++) { uint32_t data = *(input++); - crc = (crc >> 8) ^ crc32_table[(crc ^ data) & 0xff]; + crc = (crc >> 8) ^ efx_crc32_table[(crc ^ data) & 0xff]; } return (crc); diff --git a/sys/dev/sfxge/common/efx_impl.h b/sys/dev/sfxge/common/efx_impl.h index 8f60532..27ea406 100644 --- a/sys/dev/sfxge/common/efx_impl.h +++ b/sys/dev/sfxge/common/efx_impl.h @@ -463,6 +463,7 @@ typedef struct efx_mcdi_ops_s { efx_rc_t (*emco_fw_update_supported)(efx_nic_t *, boolean_t *); efx_rc_t (*emco_macaddr_change_supported)(efx_nic_t *, boolean_t *); efx_rc_t (*emco_link_control_supported)(efx_nic_t *, boolean_t *); + void (*emco_read_response)(efx_nic_t *, void *, size_t, size_t); } efx_mcdi_ops_t; typedef struct efx_mcdi_s { diff --git a/sys/dev/sfxge/common/efx_mcdi.c b/sys/dev/sfxge/common/efx_mcdi.c index 5f440a4..25c879e 100644 --- a/sys/dev/sfxge/common/efx_mcdi.c +++ b/sys/dev/sfxge/common/efx_mcdi.c @@ -52,9 +52,10 @@ static efx_mcdi_ops_t __efx_mcdi_siena_ops = { siena_mcdi_fini, /* emco_fini */ siena_mcdi_fw_update_supported, /* emco_fw_update_supported */ siena_mcdi_macaddr_change_supported, - /* emco_macaddr_change_supported */ + /* emco_macaddr_change_supported */ siena_mcdi_link_control_supported, - /* emco_link_control_supported */ + /* emco_link_control_supported */ + siena_mcdi_read_response, /* emco_read_response */ }; #endif /* EFSYS_OPT_SIENA */ @@ -70,9 +71,10 @@ static efx_mcdi_ops_t __efx_mcdi_hunt_ops = { hunt_mcdi_fini, /* emco_fini */ hunt_mcdi_fw_update_supported, /* emco_fw_update_supported */ hunt_mcdi_macaddr_change_supported, - /* emco_macaddr_change_supported */ + /* emco_macaddr_change_supported */ hunt_mcdi_link_control_supported, - /* emco_link_control_supported */ + /* emco_link_control_supported */ + hunt_mcdi_read_response, /* emco_read_response */ }; #endif /* EFSYS_OPT_HUNTINGTON */ diff --git a/sys/dev/sfxge/common/efx_nvram.c b/sys/dev/sfxge/common/efx_nvram.c index 4d58f69..b7d29fd 100644 --- a/sys/dev/sfxge/common/efx_nvram.c +++ b/sys/dev/sfxge/common/efx_nvram.c @@ -749,6 +749,11 @@ fail1: return (rc); } +/* + * The NVRAM_WRITE MCDI command is a V1 command and so is supported by both + * Sienna and EF10 based boards. However EF10 based boards support the use + * of this command with payloads up to the maximum MCDI V2 payload length. + */ __checkReturn efx_rc_t efx_mcdi_nvram_write( __in efx_nic_t *enp, @@ -758,11 +763,18 @@ efx_mcdi_nvram_write( __in size_t size) { efx_mcdi_req_t req; - uint8_t payload[MAX(MC_CMD_NVRAM_WRITE_IN_LENMAX, - MC_CMD_NVRAM_WRITE_OUT_LEN)]; + uint8_t payload[MAX(MCDI_CTL_SDU_LEN_MAX_V1, + MCDI_CTL_SDU_LEN_MAX_V2)]; efx_rc_t rc; + size_t max_data_size; + + max_data_size = enp->en_nic_cfg.enc_mcdi_max_payload_length + - MC_CMD_NVRAM_WRITE_IN_LEN(0); + EFSYS_ASSERT3U(enp->en_nic_cfg.enc_mcdi_max_payload_length, >, 0); + EFSYS_ASSERT3U(max_data_size, <, + enp->en_nic_cfg.enc_mcdi_max_payload_length); - if (size > MC_CMD_NVRAM_WRITE_IN_LENMAX) { + if (size > max_data_size) { rc = EINVAL; goto fail1; } diff --git a/sys/dev/sfxge/common/efx_tx.c b/sys/dev/sfxge/common/efx_tx.c index 35fba05..9cf31bc 100644 --- a/sys/dev/sfxge/common/efx_tx.c +++ b/sys/dev/sfxge/common/efx_tx.c @@ -921,9 +921,9 @@ falconsiena_tx_qcreate( EFX_SET_OWORD_FIELD(oword, FRF_BZ_TX_NON_IP_DROP_DIS, 1); EFX_SET_OWORD_FIELD(oword, FRF_BZ_TX_IP_CHKSM_DIS, - (flags & EFX_CKSUM_IPV4) ? 0 : 1); + (flags & EFX_TXQ_CKSUM_IPV4) ? 0 : 1); EFX_SET_OWORD_FIELD(oword, FRF_BZ_TX_TCP_CHKSM_DIS, - (flags & EFX_CKSUM_TCPUDP) ? 0 : 1); + (flags & EFX_TXQ_CKSUM_TCPUDP) ? 0 : 1); EFX_BAR_TBL_WRITEO(enp, FR_AZ_TX_DESC_PTR_TBL, etp->et_index, &oword, B_TRUE); diff --git a/sys/dev/sfxge/common/hunt_impl.h b/sys/dev/sfxge/common/hunt_impl.h index 075a2b8..313912b 100644 --- a/sys/dev/sfxge/common/hunt_impl.h +++ b/sys/dev/sfxge/common/hunt_impl.h @@ -263,6 +263,13 @@ hunt_mcdi_request_copyin( __in boolean_t ev_cpl, __in boolean_t new_epoch); +extern void +hunt_mcdi_read_response( + __in efx_nic_t *enp, + __out void *bufferp, + __in size_t offset, + __in size_t length); + extern __checkReturn boolean_t hunt_mcdi_request_poll( __in efx_nic_t *enp); diff --git a/sys/dev/sfxge/common/hunt_mcdi.c b/sys/dev/sfxge/common/hunt_mcdi.c index 1a694a1..592406f 100644 --- a/sys/dev/sfxge/common/hunt_mcdi.c +++ b/sys/dev/sfxge/common/hunt_mcdi.c @@ -229,64 +229,90 @@ hunt_mcdi_request_copyout( __in efx_nic_t *enp, __in efx_mcdi_req_t *emrp) { +#if EFSYS_OPT_MCDI_LOGGING const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp; - efsys_mem_t *esmp = emtp->emt_dma_mem; - unsigned int pos; - unsigned int offset; +#endif /* EFSYS_OPT_MCDI_LOGGING */ efx_dword_t hdr[2]; - efx_dword_t data; + unsigned int hdr_len; size_t bytes; if (emrp->emr_out_buf == NULL) return; /* Read the command header to detect MCDI response format */ - EFSYS_MEM_READD(esmp, 0, &hdr[0]); + hdr_len = sizeof (hdr[0]); + hunt_mcdi_read_response(enp, &hdr[0], 0, hdr_len); if (EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_CODE) == MC_CMD_V2_EXTN) { - offset = 2 * sizeof (efx_dword_t); - /* * Read the actual payload length. The length given in the event * is only correct for responses with the V1 format. */ - EFSYS_MEM_READD(esmp, sizeof (efx_dword_t), &hdr[1]); + hunt_mcdi_read_response(enp, &hdr[1], hdr_len, sizeof (hdr[1])); + hdr_len += sizeof (hdr[1]); + emrp->emr_out_length_used = EFX_DWORD_FIELD(hdr[1], MC_CMD_V2_EXTN_IN_ACTUAL_LEN); - } else { - offset = sizeof (efx_dword_t); } /* Copy payload out into caller supplied buffer */ bytes = MIN(emrp->emr_out_length_used, emrp->emr_out_length); - for (pos = 0; pos < bytes; pos += sizeof (efx_dword_t)) { - EFSYS_MEM_READD(esmp, offset + pos, &data); - memcpy(MCDI_OUT(*emrp, efx_dword_t, pos), &data, - MIN(sizeof (data), bytes - pos)); - } + hunt_mcdi_read_response(enp, emrp->emr_out_buf, hdr_len, bytes); #if EFSYS_OPT_MCDI_LOGGING if (emtp->emt_logger != NULL) { emtp->emt_logger(emtp->emt_context, EFX_LOG_MCDI_RESPONSE, - &hdr, offset, - emrp->emr_out_buf, emrp->emr_out_length_used); + &hdr, hdr_len, + emrp->emr_out_buf, bytes); } #endif /* EFSYS_OPT_MCDI_LOGGING */ } +static __checkReturn boolean_t +hunt_mcdi_poll_response( + __in efx_nic_t *enp) +{ + const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp; + efsys_mem_t *esmp = emtp->emt_dma_mem; + efx_dword_t hdr; + + EFSYS_MEM_READD(esmp, 0, &hdr); + return (EFX_DWORD_FIELD(hdr, MCDI_HEADER_RESPONSE) ? B_TRUE : B_FALSE); +} + + void +hunt_mcdi_read_response( + __in efx_nic_t *enp, + __out void *bufferp, + __in size_t offset, + __in size_t length) +{ + const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp; + efsys_mem_t *esmp = emtp->emt_dma_mem; + unsigned int pos; + efx_dword_t data; + + for (pos = 0; pos < length; pos += sizeof (efx_dword_t)) { + EFSYS_MEM_READD(esmp, offset + pos, &data); + memcpy((uint8_t *)bufferp + pos, &data, + MIN(sizeof (data), length - pos)); + } +} + __checkReturn boolean_t hunt_mcdi_request_poll( __in efx_nic_t *enp) { - efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); +#if EFSYS_OPT_MCDI_LOGGING const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp; - efsys_mem_t *esmp = emtp->emt_dma_mem; +#endif /* EFSYS_OPT_MCDI_LOGGING */ + efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); efx_mcdi_req_t *emrp; efx_dword_t hdr[2]; + unsigned int hdr_len; + unsigned int data_len; unsigned int seq; unsigned int cmd; - unsigned int length; - size_t offset; int state; efx_rc_t rc; @@ -299,24 +325,26 @@ hunt_mcdi_request_poll( EFSYS_ASSERT(!emip->emi_ev_cpl); emrp = emip->emi_pending_req; - offset = 0; - - /* Read the command header */ - EFSYS_MEM_READD(esmp, offset, &hdr[0]); - offset += sizeof (efx_dword_t); - if (EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_RESPONSE) == 0) { + /* Check if a response is available */ + if (hunt_mcdi_poll_response(enp) == B_FALSE) { EFSYS_UNLOCK(enp->en_eslp, state); return (B_FALSE); } + + /* Read the response header */ + hdr_len = sizeof (hdr[0]); + hunt_mcdi_read_response(enp, &hdr[0], 0, hdr_len); + if (EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_CODE) == MC_CMD_V2_EXTN) { - EFSYS_MEM_READD(esmp, offset, &hdr[1]); - offset += sizeof (efx_dword_t); + hunt_mcdi_read_response(enp, &hdr[1], hdr_len, sizeof (hdr[1])); + hdr_len += sizeof (hdr[1]); cmd = EFX_DWORD_FIELD(hdr[1], MC_CMD_V2_EXTN_IN_EXTENDED_CMD); - length = EFX_DWORD_FIELD(hdr[1], MC_CMD_V2_EXTN_IN_ACTUAL_LEN); + data_len = + EFX_DWORD_FIELD(hdr[1], MC_CMD_V2_EXTN_IN_ACTUAL_LEN); } else { cmd = EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_CODE); - length = EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_DATALEN); + data_len = EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_DATALEN); } /* Request complete */ @@ -324,7 +352,7 @@ hunt_mcdi_request_poll( seq = (emip->emi_seq - 1) & EFX_MASK32(MCDI_HEADER_SEQ); /* Check for synchronous reboot */ - if (EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_ERROR) != 0 && length == 0) { + if (EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_ERROR) != 0 && data_len == 0) { /* The MC has rebooted since the request was sent. */ EFSYS_SPIN(EFX_MCDI_STATUS_SLEEP_US); hunt_mcdi_poll_reboot(enp); @@ -348,34 +376,37 @@ hunt_mcdi_request_poll( } if (EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_ERROR)) { efx_dword_t err[2]; - int errcode; - int argnum; + unsigned int err_len = MIN(data_len, sizeof (err)); + int err_code = MC_CMD_ERR_EPROTO; + int err_arg = 0; /* Read error code (and arg num for MCDI v2 commands) */ - EFSYS_MEM_READD(esmp, offset + MC_CMD_ERR_CODE_OFST, &err[0]); - errcode = EFX_DWORD_FIELD(err[0], EFX_DWORD_0); + hunt_mcdi_read_response(enp, &err[0], hdr_len, err_len); + + if (err_len >= MC_CMD_ERR_CODE_OFST + sizeof (efx_dword_t)) + err_code = EFX_DWORD_FIELD(err[0], EFX_DWORD_0); - EFSYS_MEM_READD(esmp, offset + MC_CMD_ERR_ARG_OFST, &err[1]); - argnum = EFX_DWORD_FIELD(err[1], EFX_DWORD_0); + if (err_len >= MC_CMD_ERR_ARG_OFST + sizeof (efx_dword_t)) + err_arg = EFX_DWORD_FIELD(err[1], EFX_DWORD_0); #if EFSYS_OPT_MCDI_LOGGING if (emtp->emt_logger != NULL) { emtp->emt_logger(emtp->emt_context, EFX_LOG_MCDI_RESPONSE, - &hdr, offset, - &err, sizeof (err)); + &hdr, hdr_len, + &err, err_len); } #endif /* EFSYS_OPT_MCDI_LOGGING */ - rc = efx_mcdi_request_errcode(errcode); + rc = efx_mcdi_request_errcode(err_code); if (!emrp->emr_quiet) { EFSYS_PROBE3(mcdi_err_arg, int, emrp->emr_cmd, - int, errcode, int, argnum); + int, err_code, int, err_arg); } goto fail3; } else { - emrp->emr_out_length_used = length; + emrp->emr_out_length_used = data_len; emrp->emr_rc = 0; hunt_mcdi_request_copyout(enp, emrp); } diff --git a/sys/dev/sfxge/common/hunt_nic.c b/sys/dev/sfxge/common/hunt_nic.c index b41eb40..2869ad5 100644 --- a/sys/dev/sfxge/common/hunt_nic.c +++ b/sys/dev/sfxge/common/hunt_nic.c @@ -149,6 +149,9 @@ efx_mcdi_vadaptor_alloc( req.emr_out_length = MC_CMD_VADAPTOR_ALLOC_OUT_LEN; MCDI_IN_SET_DWORD(req, VADAPTOR_ALLOC_IN_UPSTREAM_PORT_ID, port_id); + MCDI_IN_POPULATE_DWORD_1(req, VADAPTOR_ALLOC_IN_FLAGS, + VADAPTOR_ALLOC_IN_FLAG_PERMIT_SET_MAC_WHEN_FILTERS_INSTALLED, + enp->en_nic_cfg.enc_allow_set_mac_with_installed_filters ? 1 : 0); efx_mcdi_execute(enp, &req); @@ -928,6 +931,15 @@ hunt_get_datapath_caps( encp->enc_rx_disable_scatter_supported = B_FALSE; } + /* Check if the firmware supports set mac with running filters */ + if (MCDI_CMD_DWORD_FIELD(&datapath_capabilities, + GET_CAPABILITIES_OUT_VADAPTOR_PERMIT_SET_MAC_WHEN_FILTERS_INSTALLED) + == 1) { + encp->enc_allow_set_mac_with_installed_filters = B_TRUE; + } else { + encp->enc_allow_set_mac_with_installed_filters = B_FALSE; + } + return (0); fail2: @@ -1669,6 +1681,7 @@ hunt_nic_init( } enp->en_vport_id = EVB_PORT_ID_ASSIGNED; + enp->en_nic_cfg.enc_mcdi_max_payload_length = MCDI_CTL_SDU_LEN_MAX_V2; return (0); diff --git a/sys/dev/sfxge/common/hunt_nvram.c b/sys/dev/sfxge/common/hunt_nvram.c index 341a31b..c25fa10 100644 --- a/sys/dev/sfxge/common/hunt_nvram.c +++ b/sys/dev/sfxge/common/hunt_nvram.c @@ -497,7 +497,7 @@ efx_nvram_tlv_validate( } /* The partition header must be the first item (at offset zero) */ - if ((rc = tlv_init_cursor_from_size(&cursor, partn_data, + if ((rc = tlv_init_cursor_from_size(&cursor, (uint8_t *)partn_data, partn_size)) != 0) { rc = EFAULT; goto fail2; @@ -607,7 +607,7 @@ hunt_nvram_read_tlv_segment( } /* A PARTITION_HEADER tag must be the first item at the given offset */ - if ((rc = tlv_init_cursor_from_size(&cursor, seg_data, + if ((rc = tlv_init_cursor_from_size(&cursor, (uint8_t *)seg_data, max_seg_size)) != 0) { rc = EFAULT; goto fail3; @@ -725,7 +725,7 @@ hunt_nvram_buf_read_tlv( } /* Find requested TLV tag in segment data */ - if ((rc = tlv_init_cursor_from_size(&cursor, seg_data, + if ((rc = tlv_init_cursor_from_size(&cursor, (uint8_t *)seg_data, max_seg_size)) != 0) { rc = EFAULT; goto fail2; @@ -734,7 +734,7 @@ hunt_nvram_buf_read_tlv( rc = ENOENT; goto fail3; } - value = tlv_value(&cursor); + value = (caddr_t)tlv_value(&cursor); length = tlv_length(&cursor); if (length == 0) @@ -859,7 +859,7 @@ hunt_nvram_buf_segment_size( uint32_t segment_length; /* A PARTITION_HEADER tag must be the first item at the given offset */ - if ((rc = tlv_init_cursor_from_size(&cursor, seg_data, + if ((rc = tlv_init_cursor_from_size(&cursor, (uint8_t *)seg_data, max_seg_size)) != 0) { rc = EFAULT; goto fail1; @@ -993,7 +993,7 @@ hunt_nvram_buf_write_tlv( efx_rc_t rc; /* A PARTITION_HEADER tag must be the first item (at offset zero) */ - if ((rc = tlv_init_cursor_from_size(&cursor, seg_data, + if ((rc = tlv_init_cursor_from_size(&cursor, (uint8_t *)seg_data, max_seg_size)) != 0) { rc = EFAULT; goto fail1; @@ -1008,7 +1008,7 @@ hunt_nvram_buf_write_tlv( if ((rc = tlv_find(&cursor, tag)) == 0) { /* Modify existing TLV item */ if ((rc = tlv_modify(&cursor, tag, - tag_data, tag_size)) != 0) + (uint8_t *)tag_data, tag_size)) != 0) goto fail3; } else { /* Insert a new TLV item before the PARTITION_TRAILER */ @@ -1018,7 +1018,7 @@ hunt_nvram_buf_write_tlv( goto fail4; } if ((rc = tlv_insert(&cursor, tag, - tag_data, tag_size)) != 0) { + (uint8_t *)tag_data, tag_size)) != 0) { rc = EINVAL; goto fail5; } @@ -1409,14 +1409,32 @@ hunt_nvram_partn_write( __in size_t size) { size_t chunk; + uint32_t write_size; efx_rc_t rc; + if ((rc = efx_mcdi_nvram_info(enp, partn, NULL, NULL, + NULL, &write_size)) != 0) + goto fail1; + + if (write_size != 0) { + /* + * Check that the size is a multiple of the write chunk size if + * the write chunk size is available. + */ + if (size % write_size != 0) { + rc = EINVAL; + goto fail2; + } + } else { + write_size = HUNTINGTON_NVRAM_CHUNK; + } + while (size > 0) { - chunk = MIN(size, HUNTINGTON_NVRAM_CHUNK); + chunk = MIN(size, write_size); if ((rc = efx_mcdi_nvram_write(enp, partn, offset, data, chunk)) != 0) { - goto fail1; + goto fail3; } size -= chunk; @@ -1426,6 +1444,10 @@ hunt_nvram_partn_write( return (0); +fail3: + EFSYS_PROBE(fail3); +fail2: + EFSYS_PROBE(fail2); fail1: EFSYS_PROBE1(fail1, efx_rc_t, rc); diff --git a/sys/dev/sfxge/common/hunt_tx.c b/sys/dev/sfxge/common/hunt_tx.c index 910ee2e..45fdd83 100755 --- a/sys/dev/sfxge/common/hunt_tx.c +++ b/sys/dev/sfxge/common/hunt_tx.c @@ -90,8 +90,10 @@ efx_mcdi_init_txq( MCDI_IN_POPULATE_DWORD_6(req, INIT_TXQ_IN_FLAGS, INIT_TXQ_IN_FLAG_BUFF_MODE, 0, - INIT_TXQ_IN_FLAG_IP_CSUM_DIS, (flags & EFX_CKSUM_IPV4) ? 0 : 1, - INIT_TXQ_IN_FLAG_TCP_CSUM_DIS, (flags & EFX_CKSUM_TCPUDP) ? 0 : 1, + INIT_TXQ_IN_FLAG_IP_CSUM_DIS, + (flags & EFX_TXQ_CKSUM_IPV4) ? 0 : 1, + INIT_TXQ_IN_FLAG_TCP_CSUM_DIS, + (flags & EFX_TXQ_CKSUM_TCPUDP) ? 0 : 1, INIT_TXQ_IN_FLAG_TCP_UDP_ONLY, 0, INIT_TXQ_IN_CRC_MODE, 0, INIT_TXQ_IN_FLAG_TIMESTAMP, 0); @@ -210,8 +212,10 @@ hunt_tx_qcreate( EFX_POPULATE_QWORD_4(desc, ESF_DZ_TX_DESC_IS_OPT, 1, ESF_DZ_TX_OPTION_TYPE, ESE_DZ_TX_OPTION_DESC_CRC_CSUM, - ESF_DZ_TX_OPTION_UDP_TCP_CSUM, (flags & EFX_CKSUM_TCPUDP) ? 1 : 0, - ESF_DZ_TX_OPTION_IP_CSUM, (flags & EFX_CKSUM_IPV4) ? 1 : 0); + ESF_DZ_TX_OPTION_UDP_TCP_CSUM, + (flags & EFX_TXQ_CKSUM_TCPUDP) ? 1 : 0, + ESF_DZ_TX_OPTION_IP_CSUM, + (flags & EFX_TXQ_CKSUM_IPV4) ? 1 : 0); EFSYS_MEM_WRITEQ(etp->et_esmp, 0, &desc); hunt_tx_qpush(etp, *addedp, 0); diff --git a/sys/dev/sfxge/common/siena_impl.h b/sys/dev/sfxge/common/siena_impl.h index 58c9400..386d53b 100644 --- a/sys/dev/sfxge/common/siena_impl.h +++ b/sys/dev/sfxge/common/siena_impl.h @@ -121,6 +121,13 @@ siena_mcdi_request_copyin( __in boolean_t ev_cpl, __in boolean_t new_epoch); +extern void +siena_mcdi_read_response( + __in efx_nic_t *enp, + __out void *bufferp, + __in size_t offset, + __in size_t length); + extern __checkReturn boolean_t siena_mcdi_request_poll( __in efx_nic_t *enp); diff --git a/sys/dev/sfxge/common/siena_mcdi.c b/sys/dev/sfxge/common/siena_mcdi.c index a05791b..64707ab 100644 --- a/sys/dev/sfxge/common/siena_mcdi.c +++ b/sys/dev/sfxge/common/siena_mcdi.c @@ -123,33 +123,22 @@ siena_mcdi_request_copyout( const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp; efx_dword_t hdr; #endif - efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); - unsigned int pos; - unsigned int pdur; - efx_dword_t data; - - pdur = SIENA_MCDI_PDU(emip); + size_t bytes = MIN(emrp->emr_out_length_used, emrp->emr_out_length); /* Copy payload out if caller supplied buffer */ if (emrp->emr_out_buf != NULL) { - size_t bytes = MIN(emrp->emr_out_length_used, - emrp->emr_out_length); - for (pos = 0; pos < bytes; pos += sizeof (efx_dword_t)) { - EFX_BAR_TBL_READD(enp, FR_CZ_MC_TREG_SMEM, - pdur + 1 + (pos >> 2), &data, B_FALSE); - memcpy(MCDI_OUT(*emrp, efx_dword_t, pos), &data, - MIN(sizeof (data), bytes - pos)); - } + siena_mcdi_read_response(enp, emrp->emr_out_buf, + sizeof (efx_dword_t), bytes); } #if EFSYS_OPT_MCDI_LOGGING if (emtp->emt_logger != NULL) { - EFX_BAR_TBL_READD(enp, FR_CZ_MC_TREG_SMEM, pdur, &hdr, B_FALSE); + siena_mcdi_read_response(enp, &hdr, 0, sizeof (hdr)); emtp->emt_logger(emtp->emt_context, EFX_LOG_MCDI_RESPONSE, &hdr, sizeof (hdr), - emrp->emr_out_buf, emrp->emr_out_length_used); + emrp->emr_out_buf, bytes); } #endif /* EFSYS_OPT_MCDI_LOGGING */ } @@ -191,6 +180,44 @@ siena_mcdi_poll_reboot( #endif } +static __checkReturn boolean_t +siena_mcdi_poll_response( + __in efx_nic_t *enp) +{ + efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); + efx_dword_t hdr; + unsigned int pdur; + + EFSYS_ASSERT(emip->emi_port == 1 || emip->emi_port == 2); + pdur = SIENA_MCDI_PDU(emip); + + EFX_BAR_TBL_READD(enp, FR_CZ_MC_TREG_SMEM, pdur, &hdr, B_FALSE); + return (EFX_DWORD_FIELD(hdr, MCDI_HEADER_RESPONSE) ? B_TRUE : B_FALSE); +} + + void +siena_mcdi_read_response( + __in efx_nic_t *enp, + __out void *bufferp, + __in size_t offset, + __in size_t length) +{ + efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); + unsigned int pdur; + unsigned int pos; + efx_dword_t data; + + EFSYS_ASSERT(emip->emi_port == 1 || emip->emi_port == 2); + pdur = SIENA_MCDI_PDU(emip); + + for (pos = 0; pos < length; pos += sizeof (efx_dword_t)) { + EFX_BAR_TBL_READD(enp, FR_CZ_MC_TREG_SMEM, + pdur + ((offset + pos) >> 2), &data, B_FALSE); + memcpy((uint8_t *)bufferp + pos, &data, + MIN(sizeof (data), length - pos)); + } +} + __checkReturn boolean_t siena_mcdi_request_poll( __in efx_nic_t *enp) @@ -201,9 +228,9 @@ siena_mcdi_request_poll( efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); efx_mcdi_req_t *emrp; efx_dword_t hdr; - unsigned int pdur; + unsigned int hdr_len; + unsigned int data_len; unsigned int seq; - unsigned int length; int state; efx_rc_t rc; @@ -226,16 +253,16 @@ siena_mcdi_request_poll( } } - EFSYS_ASSERT(emip->emi_port == 1 || emip->emi_port == 2); - pdur = SIENA_MCDI_PDU(emip); - - /* Read the command header */ - EFX_BAR_TBL_READD(enp, FR_CZ_MC_TREG_SMEM, pdur, &hdr, B_FALSE); - if (EFX_DWORD_FIELD(hdr, MCDI_HEADER_RESPONSE) == 0) { + /* Check if a response is available */ + if (siena_mcdi_poll_response(enp) == B_FALSE) { EFSYS_UNLOCK(enp->en_eslp, state); return (B_FALSE); } + /* Read the response header */ + hdr_len = sizeof (hdr); + siena_mcdi_read_response(enp, &hdr, 0, hdr_len); + /* Request complete */ emip->emi_pending_req = NULL; seq = (emip->emi_seq - 1) & EFX_MASK32(MCDI_HEADER_SEQ); @@ -261,35 +288,36 @@ siena_mcdi_request_poll( goto fail3; } - length = EFX_DWORD_FIELD(hdr, MCDI_HEADER_DATALEN); + data_len = EFX_DWORD_FIELD(hdr, MCDI_HEADER_DATALEN); if (EFX_DWORD_FIELD(hdr, MCDI_HEADER_ERROR)) { - efx_dword_t errdword; - int errcode; + efx_dword_t err; + int err_code = MC_CMD_ERR_EPROTO; + unsigned int err_len = MIN(data_len, sizeof (err)); - EFSYS_ASSERT3U(length, ==, 4); - EFX_BAR_TBL_READD(enp, FR_CZ_MC_TREG_SMEM, - pdur + 1 + (MC_CMD_ERR_CODE_OFST >> 2), - &errdword, B_FALSE); - errcode = EFX_DWORD_FIELD(errdword, EFX_DWORD_0); + /* Read error code */ + siena_mcdi_read_response(enp, &err, hdr_len, err_len); + + if (err_len >= MC_CMD_ERR_CODE_OFST + sizeof (efx_dword_t)) + err_code = EFX_DWORD_FIELD(err, EFX_DWORD_0); #if EFSYS_OPT_MCDI_LOGGING if (emtp->emt_logger != NULL) { emtp->emt_logger(emtp->emt_context, EFX_LOG_MCDI_RESPONSE, - &hdr, sizeof (hdr), - &errdword, sizeof (errdword)); + &hdr, hdr_len, + &err, err_len); } #endif /* EFSYS_OPT_MCDI_LOGGING */ - rc = efx_mcdi_request_errcode(errcode); + rc = efx_mcdi_request_errcode(err_code); if (!emrp->emr_quiet) { EFSYS_PROBE2(mcdi_err, int, emrp->emr_cmd, - int, errcode); + int, err_code); } goto fail4; } else { - emrp->emr_out_length_used = length; + emrp->emr_out_length_used = data_len; emrp->emr_rc = 0; siena_mcdi_request_copyout(enp, emrp); } diff --git a/sys/dev/sfxge/common/siena_nic.c b/sys/dev/sfxge/common/siena_nic.c index 6652f1e..e3f1732 100644 --- a/sys/dev/sfxge/common/siena_nic.c +++ b/sys/dev/sfxge/common/siena_nic.c @@ -170,6 +170,7 @@ siena_board_cfg( encp->enc_hw_tx_insert_vlan_enabled = B_FALSE; encp->enc_fw_assisted_tso_enabled = B_FALSE; + encp->enc_allow_set_mac_with_installed_filters = B_TRUE; return (0); @@ -419,6 +420,8 @@ siena_nic_init( if ((rc = siena_phy_reconfigure(enp)) != 0) goto fail2; + enp->en_nic_cfg.enc_mcdi_max_payload_length = MCDI_CTL_SDU_LEN_MAX_V1; + return (0); fail2: diff --git a/sys/dev/sfxge/sfxge_tx.c b/sys/dev/sfxge/sfxge_tx.c index 5554852..1ffb4be 100644 --- a/sys/dev/sfxge/sfxge_tx.c +++ b/sys/dev/sfxge/sfxge_tx.c @@ -1439,10 +1439,10 @@ sfxge_tx_qstart(struct sfxge_softc *sc, unsigned int index) flags = 0; break; case SFXGE_TXQ_IP_CKSUM: - flags = EFX_CKSUM_IPV4; + flags = EFX_TXQ_CKSUM_IPV4; break; case SFXGE_TXQ_IP_TCP_UDP_CKSUM: - flags = EFX_CKSUM_IPV4 | EFX_CKSUM_TCPUDP; + flags = EFX_TXQ_CKSUM_IPV4 | EFX_TXQ_CKSUM_TCPUDP; break; default: KASSERT(0, ("Impossible TX queue")); diff --git a/sys/dev/usb/net/if_smsc.c b/sys/dev/usb/net/if_smsc.c index 841353c..b642a69 100644 --- a/sys/dev/usb/net/if_smsc.c +++ b/sys/dev/usb/net/if_smsc.c @@ -1707,7 +1707,7 @@ smsc_attach_post_sub(struct usb_ether *ue) /* The chip supports TCP/UDP checksum offloading on TX and RX paths, however * currently only RX checksum is supported in the driver (see top of file). */ - ifp->if_capabilities |= IFCAP_RXCSUM; + ifp->if_capabilities |= IFCAP_RXCSUM | IFCAP_VLAN_MTU; ifp->if_hwassist = 0; /* TX checksuming is disabled (for now?) diff --git a/sys/dev/usb/wlan/if_urtwn.c b/sys/dev/usb/wlan/if_urtwn.c index 8db58d6..d705267 100644 --- a/sys/dev/usb/wlan/if_urtwn.c +++ b/sys/dev/usb/wlan/if_urtwn.c @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include <sys/sysctl.h> #include <sys/lock.h> #include <sys/mutex.h> +#include <sys/condvar.h> #include <sys/mbuf.h> #include <sys/kernel.h> #include <sys/socket.h> @@ -70,6 +71,7 @@ __FBSDID("$FreeBSD$"); #include <dev/usb/usb.h> #include <dev/usb/usbdi.h> +#include <dev/usb/usb_device.h> #include "usbdevs.h" #define USB_DEBUG_VAR urtwn_debug @@ -265,8 +267,7 @@ static void urtwn_r88e_fw_reset(struct urtwn_softc *); static int urtwn_fw_loadpage(struct urtwn_softc *, int, const uint8_t *, int); static int urtwn_load_firmware(struct urtwn_softc *); -static int urtwn_r92c_dma_init(struct urtwn_softc *); -static int urtwn_r88e_dma_init(struct urtwn_softc *); +static int urtwn_dma_init(struct urtwn_softc *); static int urtwn_mac_init(struct urtwn_softc *); static void urtwn_bb_init(struct urtwn_softc *); static void urtwn_rf_init(struct urtwn_softc *); @@ -396,7 +397,7 @@ urtwn_attach(device_t self) struct usb_attach_arg *uaa = device_get_ivars(self); struct urtwn_softc *sc = device_get_softc(self); struct ieee80211com *ic = &sc->sc_ic; - uint8_t iface_index, bands; + uint8_t bands; int error; device_set_usb_desc(self); @@ -410,9 +411,9 @@ urtwn_attach(device_t self) callout_init(&sc->sc_watchdog_ch, 0); mbufq_init(&sc->sc_snd, ifqmaxlen); - iface_index = URTWN_IFACE_INDEX; - error = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_xfer, - urtwn_config, URTWN_N_TRANSFER, sc, &sc->sc_mtx); + sc->sc_iface_index = URTWN_IFACE_INDEX; + error = usbd_transfer_setup(uaa->device, &sc->sc_iface_index, + sc->sc_xfer, urtwn_config, URTWN_N_TRANSFER, sc, &sc->sc_mtx); if (error) { device_printf(self, "could not allocate USB transfers, " "err=%s\n", usbd_errstr(error)); @@ -1471,7 +1472,6 @@ urtwn_read_rom(struct urtwn_softc *sc) sc->sc_rf_write = urtwn_r92c_rf_write; sc->sc_power_on = urtwn_r92c_power_on; - sc->sc_dma_init = urtwn_r92c_dma_init; return (0); } @@ -1503,7 +1503,6 @@ urtwn_r88e_read_rom(struct urtwn_softc *sc) sc->sc_rf_write = urtwn_r88e_rf_write; sc->sc_power_on = urtwn_r88e_power_on; - sc->sc_dma_init = urtwn_r88e_dma_init; return (0); } @@ -2811,86 +2810,103 @@ fail: return (error); } -static __inline int +static int urtwn_dma_init(struct urtwn_softc *sc) { + struct usb_endpoint *ep, *ep_end; usb_error_t usb_err; - int error; + uint32_t reg; + int hashq, hasnq, haslq, nqueues, ntx; + int error, pagecount, npubqpages, nqpages, nrempages, tx_boundary; /* Initialize LLT table. */ error = urtwn_llt_init(sc); if (error != 0) return (error); - error = sc->sc_dma_init(sc); - if (error != 0) - return (error); - - /* Set Tx/Rx transfer page size. */ - usb_err = urtwn_write_1(sc, R92C_PBP, - SM(R92C_PBP_PSRX, R92C_PBP_128) | - SM(R92C_PBP_PSTX, R92C_PBP_128)); - if (usb_err != USB_ERR_NORMAL_COMPLETION) + /* Determine the number of bulk-out pipes. */ + ntx = 0; + ep = sc->sc_udev->endpoints; + ep_end = sc->sc_udev->endpoints + sc->sc_udev->endpoints_max; + for (; ep != ep_end; ep++) { + if ((ep->edesc == NULL) || + (ep->iface_index != sc->sc_iface_index)) + continue; + if (UE_GET_DIR(ep->edesc->bEndpointAddress) == UE_DIR_OUT) + ntx++; + } + if (ntx == 0) { + device_printf(sc->sc_dev, + "%d: invalid number of Tx bulk pipes\n", ntx); return (EIO); - - return (0); -} - -static int -urtwn_r92c_dma_init(struct urtwn_softc *sc) -{ - int hashq, hasnq, haslq, nqueues, nqpages, nrempages; - usb_error_t error; - uint32_t reg; + } /* Get Tx queues to USB endpoints mapping. */ - hashq = hasnq = haslq = 0; - reg = urtwn_read_2(sc, R92C_USB_EP + 1); - DPRINTFN(2, "USB endpoints mapping 0x%x\n", reg); - if (MS(reg, R92C_USB_EP_HQ) != 0) - hashq = 1; - if (MS(reg, R92C_USB_EP_NQ) != 0) - hasnq = 1; - if (MS(reg, R92C_USB_EP_LQ) != 0) - haslq = 1; + hashq = hasnq = haslq = nqueues = 0; + switch (ntx) { + case 1: hashq = 1; break; + case 2: hashq = hasnq = 1; break; + case 3: case 4: hashq = hasnq = haslq = 1; break; + } nqueues = hashq + hasnq + haslq; if (nqueues == 0) return (EIO); - /* Get the number of pages for each queue. */ - nqpages = (R92C_TX_PAGE_COUNT - R92C_PUBQ_NPAGES) / nqueues; - /* The remaining pages are assigned to the high priority queue. */ - nrempages = (R92C_TX_PAGE_COUNT - R92C_PUBQ_NPAGES) % nqueues; + + npubqpages = nqpages = nrempages = pagecount = 0; + if (sc->chip & URTWN_CHIP_88E) + tx_boundary = R88E_TX_PAGE_BOUNDARY; + else { + pagecount = R92C_TX_PAGE_COUNT; + npubqpages = R92C_PUBQ_NPAGES; + tx_boundary = R92C_TX_PAGE_BOUNDARY; + } /* Set number of pages for normal priority queue. */ - error = urtwn_write_1(sc, R92C_RQPN_NPQ, hasnq ? nqpages : 0); - if (error != USB_ERR_NORMAL_COMPLETION) - return (EIO); - error = urtwn_write_4(sc, R92C_RQPN, - /* Set number of pages for public queue. */ - SM(R92C_RQPN_PUBQ, R92C_PUBQ_NPAGES) | - /* Set number of pages for high priority queue. */ - SM(R92C_RQPN_HPQ, hashq ? nqpages + nrempages : 0) | - /* Set number of pages for low priority queue. */ - SM(R92C_RQPN_LPQ, haslq ? nqpages : 0) | - /* Load values. */ - R92C_RQPN_LD); - if (error != USB_ERR_NORMAL_COMPLETION) - return (EIO); + if (sc->chip & URTWN_CHIP_88E) { + usb_err = urtwn_write_2(sc, R92C_RQPN_NPQ, 0xd); + if (usb_err != USB_ERR_NORMAL_COMPLETION) + return (EIO); + usb_err = urtwn_write_4(sc, R92C_RQPN, 0x808e000d); + if (usb_err != USB_ERR_NORMAL_COMPLETION) + return (EIO); + } else { + /* Get the number of pages for each queue. */ + nqpages = (pagecount - npubqpages) / nqueues; + /* + * The remaining pages are assigned to the high priority + * queue. + */ + nrempages = (pagecount - npubqpages) % nqueues; + usb_err = urtwn_write_1(sc, R92C_RQPN_NPQ, hasnq ? nqpages : 0); + if (usb_err != USB_ERR_NORMAL_COMPLETION) + return (EIO); + usb_err = urtwn_write_4(sc, R92C_RQPN, + /* Set number of pages for public queue. */ + SM(R92C_RQPN_PUBQ, npubqpages) | + /* Set number of pages for high priority queue. */ + SM(R92C_RQPN_HPQ, hashq ? nqpages + nrempages : 0) | + /* Set number of pages for low priority queue. */ + SM(R92C_RQPN_LPQ, haslq ? nqpages : 0) | + /* Load values. */ + R92C_RQPN_LD); + if (usb_err != USB_ERR_NORMAL_COMPLETION) + return (EIO); + } - error = urtwn_write_1(sc, R92C_TXPKTBUF_BCNQ_BDNY, R92C_TX_PAGE_BOUNDARY); - if (error != USB_ERR_NORMAL_COMPLETION) + usb_err = urtwn_write_1(sc, R92C_TXPKTBUF_BCNQ_BDNY, tx_boundary); + if (usb_err != USB_ERR_NORMAL_COMPLETION) return (EIO); - error = urtwn_write_1(sc, R92C_TXPKTBUF_MGQ_BDNY, R92C_TX_PAGE_BOUNDARY); - if (error != USB_ERR_NORMAL_COMPLETION) + usb_err = urtwn_write_1(sc, R92C_TXPKTBUF_MGQ_BDNY, tx_boundary); + if (usb_err != USB_ERR_NORMAL_COMPLETION) return (EIO); - error = urtwn_write_1(sc, R92C_TXPKTBUF_WMAC_LBK_BF_HD, R92C_TX_PAGE_BOUNDARY); - if (error != USB_ERR_NORMAL_COMPLETION) + usb_err = urtwn_write_1(sc, R92C_TXPKTBUF_WMAC_LBK_BF_HD, tx_boundary); + if (usb_err != USB_ERR_NORMAL_COMPLETION) return (EIO); - error = urtwn_write_1(sc, R92C_TRXFF_BNDY, R92C_TX_PAGE_BOUNDARY); - if (error != USB_ERR_NORMAL_COMPLETION) + usb_err = urtwn_write_1(sc, R92C_TRXFF_BNDY, tx_boundary); + if (usb_err != USB_ERR_NORMAL_COMPLETION) return (EIO); - error = urtwn_write_1(sc, R92C_TDECTRL + 1, R92C_TX_PAGE_BOUNDARY); - if (error != USB_ERR_NORMAL_COMPLETION) + usb_err = urtwn_write_1(sc, R92C_TDECTRL + 1, tx_boundary); + if (usb_err != USB_ERR_NORMAL_COMPLETION) return (EIO); /* Set queue to USB pipe mapping. */ @@ -2913,72 +2929,21 @@ urtwn_r92c_dma_init(struct urtwn_softc *sc) reg |= R92C_TRXDMA_CTRL_QMAP_HQ_LQ; } else reg |= R92C_TRXDMA_CTRL_QMAP_3EP; - error = urtwn_write_2(sc, R92C_TRXDMA_CTRL, reg); - if (error != USB_ERR_NORMAL_COMPLETION) + usb_err = urtwn_write_2(sc, R92C_TRXDMA_CTRL, reg); + if (usb_err != USB_ERR_NORMAL_COMPLETION) return (EIO); /* Set Tx/Rx transfer page boundary. */ - error = urtwn_write_2(sc, R92C_TRXFF_BNDY + 2, 0x27ff); - if (error != USB_ERR_NORMAL_COMPLETION) - return (EIO); - - return (0); -} - -static int -urtwn_r88e_dma_init(struct urtwn_softc *sc) -{ - struct usb_interface *iface; - uint32_t reg; - usb_error_t error; - int nqueues; - - /* Get Tx queues to USB endpoints mapping. */ - iface = usbd_get_iface(sc->sc_udev, 0); - nqueues = iface->idesc->bNumEndpoints - 1; - if (nqueues == 0) - return (EIO); - - /* Set number of pages for normal priority queue. */ - error = urtwn_write_2(sc, R92C_RQPN_NPQ, 0x000d); - if (error != USB_ERR_NORMAL_COMPLETION) - return (EIO); - error = urtwn_write_4(sc, R92C_RQPN, 0x808e000d); - if (error != USB_ERR_NORMAL_COMPLETION) - return (EIO); - - error = urtwn_write_1(sc, R92C_TXPKTBUF_BCNQ_BDNY, R88E_TX_PAGE_BOUNDARY); - if (error != USB_ERR_NORMAL_COMPLETION) - return (EIO); - error = urtwn_write_1(sc, R92C_TXPKTBUF_MGQ_BDNY, R88E_TX_PAGE_BOUNDARY); - if (error != USB_ERR_NORMAL_COMPLETION) - return (EIO); - error = urtwn_write_1(sc, R92C_TXPKTBUF_WMAC_LBK_BF_HD, R88E_TX_PAGE_BOUNDARY); - if (error != USB_ERR_NORMAL_COMPLETION) - return (EIO); - error = urtwn_write_1(sc, R92C_TRXFF_BNDY, R88E_TX_PAGE_BOUNDARY); - if (error != USB_ERR_NORMAL_COMPLETION) - return (EIO); - error = urtwn_write_1(sc, R92C_TDECTRL + 1, R88E_TX_PAGE_BOUNDARY); - if (error != USB_ERR_NORMAL_COMPLETION) - return (EIO); - - /* Set queue to USB pipe mapping. */ - reg = urtwn_read_2(sc, R92C_TRXDMA_CTRL); - reg &= ~R92C_TRXDMA_CTRL_QMAP_M; - if (nqueues == 1) - reg |= R92C_TRXDMA_CTRL_QMAP_LQ; - else if (nqueues == 2) - reg |= R92C_TRXDMA_CTRL_QMAP_HQ_NQ; - else - reg |= R92C_TRXDMA_CTRL_QMAP_3EP; - error = urtwn_write_2(sc, R92C_TRXDMA_CTRL, reg); - if (error != USB_ERR_NORMAL_COMPLETION) + usb_err = urtwn_write_2(sc, R92C_TRXFF_BNDY + 2, + (sc->chip & URTWN_CHIP_88E) ? 0x23ff : 0x27ff); + if (usb_err != USB_ERR_NORMAL_COMPLETION) return (EIO); - /* Set Tx/Rx transfer page boundary. */ - error = urtwn_write_2(sc, R92C_TRXFF_BNDY + 2, 0x23ff); - if (error != USB_ERR_NORMAL_COMPLETION) + /* Set Tx/Rx transfer page size. */ + usb_err = urtwn_write_1(sc, R92C_PBP, + SM(R92C_PBP_PSRX, R92C_PBP_128) | + SM(R92C_PBP_PSTX, R92C_PBP_128)); + if (usb_err != USB_ERR_NORMAL_COMPLETION) return (EIO); return (0); diff --git a/sys/dev/usb/wlan/if_urtwnvar.h b/sys/dev/usb/wlan/if_urtwnvar.h index 2fb47f3..6e0b149 100644 --- a/sys/dev/usb/wlan/if_urtwnvar.h +++ b/sys/dev/usb/wlan/if_urtwnvar.h @@ -139,6 +139,7 @@ struct urtwn_softc { device_t sc_dev; struct usb_device *sc_udev; + uint8_t sc_iface_index; int ac2idx[WME_NUM_AC]; u_int sc_flags; #define URTWN_FLAG_CCK_HIPWR 0x01 @@ -155,7 +156,6 @@ struct urtwn_softc { void (*sc_rf_write)(struct urtwn_softc *, int, uint8_t, uint32_t); int (*sc_power_on)(struct urtwn_softc *); - int (*sc_dma_init)(struct urtwn_softc *); uint8_t board_type; uint8_t regulatory; diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index 379eb6d..be00559 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -301,10 +301,6 @@ init_secondary(void) init_secondary_tail(); } -/******************************************************************* - * local functions and data - */ - /* * start each AP in our list */ diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index 5ae41a3..5bdc988 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -1032,6 +1032,9 @@ pmap_invalidate_page(pmap_t pmap, vm_offset_t va) sched_unpin(); } +/* 4k PTEs -- Chosen to exceed the total size of Broadwell L2 TLB */ +#define PMAP_INVLPG_THRESHOLD (4 * 1024 * PAGE_SIZE) + void pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) { @@ -1039,6 +1042,11 @@ pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) vm_offset_t addr; u_int cpuid; + if (eva - sva >= PMAP_INVLPG_THRESHOLD) { + pmap_invalidate_all(pmap); + return; + } + sched_pin(); if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) { for (addr = sva; addr < eva; addr += PAGE_SIZE) diff --git a/sys/i386/i386/sys_machdep.c b/sys/i386/i386/sys_machdep.c index dc367a6..861cf49 100644 --- a/sys/i386/i386/sys_machdep.c +++ b/sys/i386/i386/sys_machdep.c @@ -275,8 +275,7 @@ i386_extend_pcb(struct thread *td) ext = (struct pcb_ext *)kmem_malloc(kernel_arena, ctob(IOPAGES+1), M_WAITOK | M_ZERO); /* -16 is so we can convert a trapframe into vm86trapframe inplace */ - ext->ext_tss.tss_esp0 = td->td_kstack + ctob(td->td_kstack_pages) - - sizeof(struct pcb) - 16; + ext->ext_tss.tss_esp0 = (vm_offset_t)td->td_pcb - 16; ext->ext_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL); /* * The last byte of the i/o map must be followed by an 0xff byte. diff --git a/sys/i386/include/md_var.h b/sys/i386/include/md_var.h index 13655ee..f854373 100644 --- a/sys/i386/include/md_var.h +++ b/sys/i386/include/md_var.h @@ -32,46 +32,12 @@ #ifndef _MACHINE_MD_VAR_H_ #define _MACHINE_MD_VAR_H_ -/* - * Miscellaneous machine-dependent declarations. - */ +#include <x86/x86_var.h> -extern long Maxmem; -extern u_int basemem; /* PA of original top of base memory */ -extern int busdma_swi_pending; -extern u_int cpu_exthigh; -extern u_int cpu_feature; -extern u_int cpu_feature2; -extern u_int amd_feature; -extern u_int amd_feature2; -extern u_int amd_pminfo; -extern u_int via_feature_rng; -extern u_int via_feature_xcrypt; -extern u_int cpu_clflush_line_size; -extern u_int cpu_stdext_feature; -extern u_int cpu_stdext_feature2; -extern u_int cpu_fxsr; -extern u_int cpu_high; -extern u_int cpu_id; -extern u_int cpu_max_ext_state_size; -extern u_int cpu_mxcsr_mask; -extern u_int cpu_procinfo; -extern u_int cpu_procinfo2; -extern char cpu_vendor[]; -extern u_int cpu_vendor_id; -extern u_int cpu_mon_mwait_flags; -extern u_int cpu_mon_min_size; -extern u_int cpu_mon_max_size; -extern u_int cpu_maxphyaddr; extern u_int cyrix_did; #if defined(I586_CPU) && !defined(NO_F00F_HACK) extern int has_f00f_bug; #endif -extern u_int hv_high; -extern char hv_vendor[]; -extern char kstack[]; -extern char sigcode[]; -extern int szsigcode; #ifdef COMPAT_FREEBSD4 extern int szfreebsd4_sigcode; #endif @@ -79,29 +45,12 @@ extern int szfreebsd4_sigcode; extern int szosigcode; #endif extern uint32_t *vm_page_dump; -extern int vm_page_dump_size; -extern int workaround_erratum383; -extern int _udatasel; -extern int _ucodesel; -extern int use_xsave; -extern uint64_t xsave_mask; typedef void alias_for_inthand_t(u_int cs, u_int ef, u_int esp, u_int ss); -struct pcb; -union savefpu; -struct thread; -struct reg; -struct fpreg; -struct dbreg; -struct dumperinfo; struct segment_descriptor; +union savefpu; -void *alloc_fpusave(int flags); void bcopyb(const void *from, void *to, size_t len); -void busdma_swi(void); -bool cpu_mwait_usable(void); -void cpu_probe_amdc1e(void); -void cpu_setregs(void); void cpu_switch_load_gs(void) __asm(__STRING(cpu_switch_load_gs)); void doreti_iret(void) __asm(__STRING(doreti_iret)); void doreti_iret_fault(void) __asm(__STRING(doreti_iret_fault)); @@ -111,26 +60,14 @@ void doreti_popl_es(void) __asm(__STRING(doreti_popl_es)); void doreti_popl_es_fault(void) __asm(__STRING(doreti_popl_es_fault)); void doreti_popl_fs(void) __asm(__STRING(doreti_popl_fs)); void doreti_popl_fs_fault(void) __asm(__STRING(doreti_popl_fs_fault)); -void dump_add_page(vm_paddr_t); -void dump_drop_page(vm_paddr_t); void finishidentcpu(void); -void fillw(int /*u_short*/ pat, void *base, size_t cnt); void fill_based_sd(struct segment_descriptor *sdp, uint32_t base); -void initializecpu(void); -void initializecpucache(void); -bool intel_fix_cpuid(void); void i686_pagezero(void *addr); void sse2_pagezero(void *addr); void init_AMD_Elan_sc520(void); -int is_physical_memory(vm_paddr_t addr); -int isa_nmi(int cd); vm_paddr_t kvtop(void *addr); -void panicifcpuunsupported(void); void ppro_reenable_apic(void); -void printcpuinfo(void); void setidt(int idx, alias_for_inthand_t *func, int typ, int dpl, int selec); -int user_dbreg_trap(void); -int minidumpsys(struct dumperinfo *); union savefpu *get_pcb_user_save_td(struct thread *td); union savefpu *get_pcb_user_save_pcb(struct pcb *pcb); struct pcb *get_pcb_td(struct thread *td); diff --git a/sys/i386/include/smp.h b/sys/i386/include/smp.h index 5948c25..971f75c 100644 --- a/sys/i386/include/smp.h +++ b/sys/i386/include/smp.h @@ -19,6 +19,8 @@ #ifndef LOCORE +#include <x86/x86_smp.h> + #include <sys/bus.h> #include <machine/frame.h> #include <machine/intr_machdep.h> @@ -26,88 +28,10 @@ #include <machine/pcb.h> /* global data in mpboot.s */ -extern int bootMP_size; +extern int bootMP_size; /* functions in mpboot.s */ -void bootMP(void); - -/* global data in mp_machdep.c */ -extern int mp_naps; -extern int boot_cpu_id; -extern struct pcb stoppcbs[]; -extern int cpu_apic_ids[]; -extern int bootAP; -extern void *dpcpu; -extern char *bootSTK; -extern void *bootstacks[]; -extern volatile u_int cpu_ipi_pending[]; -extern volatile int aps_ready; -extern struct mtx ap_boot_mtx; -extern int cpu_logical; -extern int cpu_cores; -extern volatile int smp_tlb_wait; -extern u_int xhits_gbl[]; -extern u_int xhits_pg[]; -extern u_int xhits_rng[]; -extern u_int ipi_global; -extern u_int ipi_page; -extern u_int ipi_range; -extern u_int ipi_range_size; - -struct cpu_info { - int cpu_present:1; - int cpu_bsp:1; - int cpu_disabled:1; - int cpu_hyperthread:1; -}; -extern struct cpu_info cpu_info[]; - -#ifdef COUNT_IPIS -extern u_long *ipi_invltlb_counts[MAXCPU]; -extern u_long *ipi_invlrng_counts[MAXCPU]; -extern u_long *ipi_invlpg_counts[MAXCPU]; -extern u_long *ipi_invlcache_counts[MAXCPU]; -extern u_long *ipi_rendezvous_counts[MAXCPU]; -#endif - -/* IPI handlers */ -inthand_t - IDTVEC(invltlb), /* TLB shootdowns - global */ - IDTVEC(invlpg), /* TLB shootdowns - 1 page */ - IDTVEC(invlrng), /* TLB shootdowns - page range */ - IDTVEC(invlcache), /* Write back and invalidate cache */ - IDTVEC(ipi_intr_bitmap_handler), /* Bitmap based IPIs */ - IDTVEC(cpustop), /* CPU stops & waits to be restarted */ - IDTVEC(cpususpend), /* CPU suspends & waits to be resumed */ - IDTVEC(rendezvous); /* handle CPU rendezvous */ - -/* functions in mp_machdep.c */ -void assign_cpu_ids(void); -void cpu_add(u_int apic_id, char boot_cpu); -void cpustop_handler(void); -void cpususpend_handler(void); -void init_secondary_tail(void); -void invltlb_handler(void); -void invlpg_handler(void); -void invlrng_handler(void); -void invlcache_handler(void); -void init_secondary(void); -void ipi_startup(int apic_id, int vector); -void ipi_all_but_self(u_int ipi); -void ipi_bitmap_handler(struct trapframe frame); -void ipi_cpu(int cpu, u_int ipi); -int ipi_nmi_handler(void); -void ipi_selected(cpuset_t cpus, u_int ipi); -u_int mp_bootaddress(u_int); -void set_interrupt_apic_ids(void); -void smp_cache_flush(void); -void smp_masked_invlpg(cpuset_t mask, vm_offset_t addr); -void smp_masked_invlpg_range(cpuset_t mask, vm_offset_t startva, - vm_offset_t endva); -void smp_masked_invltlb(cpuset_t mask, struct pmap *pmap); -void mem_range_AP_init(void); -void topo_probe(void); -void ipi_send_cpu(int cpu, u_int ipi); +void bootMP(void); #endif /* !LOCORE */ #endif /* SMP */ diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 7fe36cf..f9ef458 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -80,6 +80,9 @@ __FBSDID("$FreeBSD$"); #include <machine/elf.h> #include <machine/md_var.h> +#ifdef __arm__ +#include <machine/acle-compat.h> +#endif #define ELF_NOTE_ROUNDSIZE 4 #define OLD_EI_BRAND 8 @@ -116,7 +119,8 @@ SYSCTL_INT(_debug, OID_AUTO, __elfN(legacy_coredump), CTLFLAG_RW, &elf_legacy_coredump, 0, ""); int __elfN(nxstack) = -#if defined(__amd64__) || defined(__powerpc64__) /* both 64 and 32 bit */ +#if defined(__amd64__) || defined(__powerpc64__) /* both 64 and 32 bit */ || \ + (defined(__arm__) && __ARM_ARCH >= 7) || defined(__aarch64__) 1; #else 0; @@ -144,7 +148,7 @@ static const char FREEBSD_ABI_VENDOR[] = "FreeBSD"; Elf_Brandnote __elfN(freebsd_brandnote) = { .hdr.n_namesz = sizeof(FREEBSD_ABI_VENDOR), .hdr.n_descsz = sizeof(int32_t), - .hdr.n_type = 1, + .hdr.n_type = NT_FREEBSD_ABI_TAG, .vendor = FREEBSD_ABI_VENDOR, .flags = BN_TRANSLATE_OSREL, .trans_osrel = __elfN(freebsd_trans_osrel) diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 4e9136c..435a07b 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -1526,50 +1526,20 @@ pargs_drop(struct pargs *pa) } static int -proc_read_mem(struct thread *td, struct proc *p, vm_offset_t offset, void* buf, - size_t len) -{ - struct iovec iov; - struct uio uio; - - iov.iov_base = (caddr_t)buf; - iov.iov_len = len; - uio.uio_iov = &iov; - uio.uio_iovcnt = 1; - uio.uio_offset = offset; - uio.uio_resid = (ssize_t)len; - uio.uio_segflg = UIO_SYSSPACE; - uio.uio_rw = UIO_READ; - uio.uio_td = td; - - return (proc_rwmem(p, &uio)); -} - -static int proc_read_string(struct thread *td, struct proc *p, const char *sptr, char *buf, size_t len) { - size_t i; - int error; + ssize_t n; - error = proc_read_mem(td, p, (vm_offset_t)sptr, buf, len); /* - * Reading the chunk may validly return EFAULT if the string is shorter - * than the chunk and is aligned at the end of the page, assuming the - * next page is not mapped. So if EFAULT is returned do a fallback to - * one byte read loop. + * This may return a short read if the string is shorter than the chunk + * and is aligned at the end of the page, and the following page is not + * mapped. */ - if (error == EFAULT) { - for (i = 0; i < len; i++, buf++, sptr++) { - error = proc_read_mem(td, p, (vm_offset_t)sptr, buf, 1); - if (error != 0) - return (error); - if (*buf == '\0') - break; - } - error = 0; - } - return (error); + n = proc_readmem(td, p, (vm_offset_t)sptr, buf, len); + if (n <= 0) + return (ENOMEM); + return (0); } #define PROC_AUXV_MAX 256 /* Safety limit on auxv size. */ @@ -1593,10 +1563,10 @@ get_proc_vector32(struct thread *td, struct proc *p, char ***proc_vectorp, size_t vsize, size; int i, error; - error = proc_read_mem(td, p, (vm_offset_t)(p->p_sysent->sv_psstrings), - &pss, sizeof(pss)); - if (error != 0) - return (error); + error = 0; + if (proc_readmem(td, p, (vm_offset_t)p->p_sysent->sv_psstrings, &pss, + sizeof(pss)) != sizeof(pss)) + return (ENOMEM); switch (type) { case PROC_ARG: vptr = (vm_offset_t)PTRIN(pss.ps_argvstr); @@ -1618,9 +1588,9 @@ get_proc_vector32(struct thread *td, struct proc *p, char ***proc_vectorp, if (vptr % 4 != 0) return (ENOEXEC); for (ptr = vptr, i = 0; i < PROC_AUXV_MAX; i++) { - error = proc_read_mem(td, p, ptr, &aux, sizeof(aux)); - if (error != 0) - return (error); + if (proc_readmem(td, p, ptr, &aux, sizeof(aux)) != + sizeof(aux)) + return (ENOMEM); if (aux.a_type == AT_NULL) break; ptr += sizeof(aux); @@ -1635,9 +1605,10 @@ get_proc_vector32(struct thread *td, struct proc *p, char ***proc_vectorp, return (EINVAL); } proc_vector32 = malloc(size, M_TEMP, M_WAITOK); - error = proc_read_mem(td, p, vptr, proc_vector32, size); - if (error != 0) + if (proc_readmem(td, p, vptr, proc_vector32, size) != size) { + error = ENOMEM; goto done; + } if (type == PROC_AUX) { *proc_vectorp = (char **)proc_vector32; *vsizep = vsize; @@ -1663,16 +1634,15 @@ get_proc_vector(struct thread *td, struct proc *p, char ***proc_vectorp, vm_offset_t vptr, ptr; char **proc_vector; size_t vsize, size; - int error, i; + int i; #ifdef COMPAT_FREEBSD32 if (SV_PROC_FLAG(p, SV_ILP32) != 0) return (get_proc_vector32(td, p, proc_vectorp, vsizep, type)); #endif - error = proc_read_mem(td, p, (vm_offset_t)(p->p_sysent->sv_psstrings), - &pss, sizeof(pss)); - if (error != 0) - return (error); + if (proc_readmem(td, p, (vm_offset_t)p->p_sysent->sv_psstrings, &pss, + sizeof(pss)) != sizeof(pss)) + return (ENOMEM); switch (type) { case PROC_ARG: vptr = (vm_offset_t)pss.ps_argvstr; @@ -1709,9 +1679,9 @@ get_proc_vector(struct thread *td, struct proc *p, char ***proc_vectorp, * to the allocated proc_vector. */ for (ptr = vptr, i = 0; i < PROC_AUXV_MAX; i++) { - error = proc_read_mem(td, p, ptr, &aux, sizeof(aux)); - if (error != 0) - return (error); + if (proc_readmem(td, p, ptr, &aux, sizeof(aux)) != + sizeof(aux)) + return (ENOMEM); if (aux.a_type == AT_NULL) break; ptr += sizeof(aux); @@ -1732,12 +1702,9 @@ get_proc_vector(struct thread *td, struct proc *p, char ***proc_vectorp, return (EINVAL); /* In case we are built without INVARIANTS. */ } proc_vector = malloc(size, M_TEMP, M_WAITOK); - if (proc_vector == NULL) - return (ENOMEM); - error = proc_read_mem(td, p, vptr, proc_vector, size); - if (error != 0) { + if (proc_readmem(td, p, vptr, proc_vector, size) != size) { free(proc_vector, M_TEMP); - return (error); + return (ENOMEM); } *proc_vectorp = proc_vector; *vsizep = vsize; diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 8976941..732d754 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -252,6 +252,7 @@ proc_rwmem(struct proc *p, struct uio *uio) * from exiting out from under us until this operation completes. */ PROC_ASSERT_HELD(p); + PROC_LOCK_ASSERT(p, MA_NOTOWNED); /* * The map we want... @@ -327,6 +328,49 @@ proc_rwmem(struct proc *p, struct uio *uio) return (error); } +static ssize_t +proc_iop(struct thread *td, struct proc *p, vm_offset_t va, void *buf, + size_t len, enum uio_rw rw) +{ + struct iovec iov; + struct uio uio; + ssize_t slen; + int error; + + MPASS(len < SSIZE_MAX); + slen = (ssize_t)len; + + iov.iov_base = (caddr_t)buf; + iov.iov_len = len; + uio.uio_iov = &iov; + uio.uio_iovcnt = 1; + uio.uio_offset = va; + uio.uio_resid = slen; + uio.uio_segflg = UIO_SYSSPACE; + uio.uio_rw = rw; + uio.uio_td = td; + error = proc_rwmem(p, &uio); + if (uio.uio_resid == slen) + return (-1); + return (slen - uio.uio_resid); +} + +ssize_t +proc_readmem(struct thread *td, struct proc *p, vm_offset_t va, void *buf, + size_t len) +{ + + return (proc_iop(td, p, va, buf, len, UIO_READ)); +} + +ssize_t +proc_writemem(struct thread *td, struct proc *p, vm_offset_t va, void *buf, + size_t len) +{ + + return (proc_iop(td, p, va, buf, len, UIO_WRITE)); +} + static int ptrace_vm_entry(struct thread *td, struct proc *p, struct ptrace_vm_entry *pve) { @@ -644,7 +688,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) struct thread *td2 = NULL, *td3; struct ptrace_io_desc *piod = NULL; struct ptrace_lwpinfo *pl; - int error, write, tmp, num; + int error, num, tmp; int proctree_locked = 0; lwpid_t tid = 0, *buf; #ifdef COMPAT_FREEBSD32 @@ -674,7 +718,6 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) break; } - write = 0; if (req == PT_TRACE_ME) { p = td->td_proc; PROC_LOCK(p); @@ -1033,46 +1076,28 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) case PT_WRITE_I: case PT_WRITE_D: td2->td_dbgflags |= TDB_USERWR; - write = 1; - /* FALLTHROUGH */ + PROC_UNLOCK(p); + error = 0; + if (proc_writemem(td, p, (off_t)(uintptr_t)addr, &data, + sizeof(int)) != sizeof(int)) + error = ENOMEM; + else + CTR3(KTR_PTRACE, "PT_WRITE: pid %d: %p <= %#x", + p->p_pid, addr, data); + PROC_LOCK(p); + break; + case PT_READ_I: case PT_READ_D: PROC_UNLOCK(p); - tmp = 0; - /* write = 0 set above */ - iov.iov_base = write ? (caddr_t)&data : (caddr_t)&tmp; - iov.iov_len = sizeof(int); - uio.uio_iov = &iov; - uio.uio_iovcnt = 1; - uio.uio_offset = (off_t)(uintptr_t)addr; - uio.uio_resid = sizeof(int); - uio.uio_segflg = UIO_SYSSPACE; /* i.e.: the uap */ - uio.uio_rw = write ? UIO_WRITE : UIO_READ; - uio.uio_td = td; - error = proc_rwmem(p, &uio); - if (uio.uio_resid != 0) { - /* - * XXX proc_rwmem() doesn't currently return ENOSPC, - * so I think write() can bogusly return 0. - * XXX what happens for short writes? We don't want - * to write partial data. - * XXX proc_rwmem() returns EPERM for other invalid - * addresses. Convert this to EINVAL. Does this - * clobber returns of EPERM for other reasons? - */ - if (error == 0 || error == ENOSPC || error == EPERM) - error = EINVAL; /* EOF */ - } - if (!write) - td->td_retval[0] = tmp; - if (error == 0) { - if (write) - CTR3(KTR_PTRACE, "PT_WRITE: pid %d: %p <= %#x", - p->p_pid, addr, data); - else - CTR3(KTR_PTRACE, "PT_READ: pid %d: %p >= %#x", - p->p_pid, addr, tmp); - } + error = tmp = 0; + if (proc_readmem(td, p, (off_t)(uintptr_t)addr, &tmp, + sizeof(int)) != sizeof(int)) + error = ENOMEM; + else + CTR3(KTR_PTRACE, "PT_READ: pid %d: %p >= %#x", + p->p_pid, addr, tmp); + td->td_retval[0] = tmp; PROC_LOCK(p); break; diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 6376cdf..ccd1b64 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -1280,7 +1280,7 @@ bufshutdown(int show_busybufs) /* * Unmount filesystems */ - if (panicstr == 0) + if (panicstr == NULL) vfs_unmountall(); } swapoff_all(); diff --git a/sys/mips/mips/pm_machdep.c b/sys/mips/mips/pm_machdep.c index d5f6df0..9bccaec 100644 --- a/sys/mips/mips/pm_machdep.c +++ b/sys/mips/mips/pm_machdep.c @@ -214,39 +214,19 @@ ptrace_set_pc(struct thread *td, unsigned long addr) static int ptrace_read_int(struct thread *td, off_t addr, int *v) { - struct iovec iov; - struct uio uio; - - PROC_LOCK_ASSERT(td->td_proc, MA_NOTOWNED); - iov.iov_base = (caddr_t) v; - iov.iov_len = sizeof(int); - uio.uio_iov = &iov; - uio.uio_iovcnt = 1; - uio.uio_offset = (off_t)addr; - uio.uio_resid = sizeof(int); - uio.uio_segflg = UIO_SYSSPACE; - uio.uio_rw = UIO_READ; - uio.uio_td = td; - return proc_rwmem(td->td_proc, &uio); + + if (proc_readmem(td, td->td_proc, addr, v, sizeof(*v)) != sizeof(*v)) + return (ENOMEM); + return (0); } static int ptrace_write_int(struct thread *td, off_t addr, int v) { - struct iovec iov; - struct uio uio; - - PROC_LOCK_ASSERT(td->td_proc, MA_NOTOWNED); - iov.iov_base = (caddr_t) &v; - iov.iov_len = sizeof(int); - uio.uio_iov = &iov; - uio.uio_iovcnt = 1; - uio.uio_offset = (off_t)addr; - uio.uio_resid = sizeof(int); - uio.uio_segflg = UIO_SYSSPACE; - uio.uio_rw = UIO_WRITE; - uio.uio_td = td; - return proc_rwmem(td->td_proc, &uio); + + if (proc_writemem(td, td->td_proc, addr, &v, sizeof(v)) != sizeof(v)) + return (ENOMEM); + return (0); } int diff --git a/sys/modules/ahci/Makefile b/sys/modules/ahci/Makefile index 451859e..5666870 100644 --- a/sys/modules/ahci/Makefile +++ b/sys/modules/ahci/Makefile @@ -6,7 +6,7 @@ KMOD= ahci SRCS= ahci.c ahci_pci.c ahciem.c ahci.h device_if.h bus_if.h pci_if.h opt_cam.h .if ${MACHINE_CPUARCH} == "aarch64" -SRCS+= ahci_generic.c +SRCS+= ahci_generic.c ofw_bus_if.h .endif .include <bsd.kmod.mk> diff --git a/sys/modules/cam/Makefile b/sys/modules/cam/Makefile index 7e5465e..19bd9ec 100644 --- a/sys/modules/cam/Makefile +++ b/sys/modules/cam/Makefile @@ -11,6 +11,7 @@ SRCS= opt_cam.h SRCS+= opt_ada.h SRCS+= opt_scsi.h SRCS+= opt_cd.h +SRCS+= opt_kdtrace.h SRCS+= opt_pt.h SRCS+= opt_sa.h SRCS+= opt_ses.h diff --git a/sys/modules/mlx5/Makefile b/sys/modules/mlx5/Makefile index eaf5206..831e49b 100644 --- a/sys/modules/mlx5/Makefile +++ b/sys/modules/mlx5/Makefile @@ -7,6 +7,7 @@ mlx5_alloc.c \ mlx5_cmd.c \ mlx5_cq.c \ mlx5_eq.c \ +mlx5_eswitch_vacl.c \ mlx5_flow_table.c \ mlx5_fw.c \ mlx5_health.c \ @@ -24,7 +25,7 @@ mlx5_uar.c \ mlx5_vport.c \ mlx5_wq.c \ device_if.h bus_if.h vnode_if.h pci_if.h \ - opt_inet.h opt_inet6.h opt_random.h + opt_inet.h opt_inet6.h opt_random.h opt_rss.h CFLAGS+= -I${.CURDIR}/../../ofed/include CFLAGS+= -I${.CURDIR}/../../compat/linuxkpi/common/include diff --git a/sys/modules/mlx5en/Makefile b/sys/modules/mlx5en/Makefile index b112bf55..a9b48c6 100644 --- a/sys/modules/mlx5en/Makefile +++ b/sys/modules/mlx5en/Makefile @@ -10,7 +10,7 @@ mlx5_en_flow_table.c \ mlx5_en_rx.c \ mlx5_en_txrx.c \ device_if.h bus_if.h vnode_if.h pci_if.h \ - opt_inet.h opt_inet6.h + opt_inet.h opt_inet6.h opt_rss.h .if defined(HAVE_TURBO_LRO) CFLAGS+= -DHAVE_TURBO_LRO diff --git a/sys/net/route.h b/sys/net/route.h index ffbcb3c..c1d0997 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -171,6 +171,37 @@ struct rtentry { RTF_REJECT | RTF_STATIC | RTF_STICKY) /* + * fib_ nexthop API flags. + */ + +/* Consumer-visible nexthop info flags */ +#define NHF_REJECT 0x0010 /* RTF_REJECT */ +#define NHF_BLACKHOLE 0x0020 /* RTF_BLACKHOLE */ +#define NHF_REDIRECT 0x0040 /* RTF_DYNAMIC|RTF_MODIFIED */ +#define NHF_DEFAULT 0x0080 /* Default route */ +#define NHF_BROADCAST 0x0100 /* RTF_BROADCAST */ +#define NHF_GATEWAY 0x0200 /* RTF_GATEWAY */ + +/* Nexthop request flags */ +#define NHR_IFAIF 0x01 /* Return ifa_ifp interface */ +#define NHR_REF 0x02 /* For future use */ + +/* rte<>nhop translation */ +static inline uint16_t +fib_rte_to_nh_flags(int rt_flags) +{ + uint16_t res; + + res = (rt_flags & RTF_REJECT) ? NHF_REJECT : 0; + res |= (rt_flags & RTF_BLACKHOLE) ? NHF_BLACKHOLE : 0; + res |= (rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) ? NHF_REDIRECT : 0; + res |= (rt_flags & RTF_BROADCAST) ? NHF_BROADCAST : 0; + res |= (rt_flags & RTF_GATEWAY) ? NHF_GATEWAY : 0; + + return (res); +} + +/* * Routing statistics. */ struct rtstat { diff --git a/sys/netinet/in_fib.c b/sys/netinet/in_fib.c new file mode 100644 index 0000000..b4101b6 --- /dev/null +++ b/sys/netinet/in_fib.c @@ -0,0 +1,222 @@ +/*- + * Copyright (c) 2015 + * Alexander V. Chernikov <melifaro@FreeBSD.org> + * + * 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. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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 <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "opt_inet.h" +#include "opt_route.h" +#include "opt_mpath.h" + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/lock.h> +#include <sys/rwlock.h> +#include <sys/malloc.h> +#include <sys/mbuf.h> +#include <sys/socket.h> +#include <sys/sysctl.h> +#include <sys/kernel.h> + +#include <net/if.h> +#include <net/if_var.h> +#include <net/if_dl.h> +#include <net/route.h> +#include <net/vnet.h> + +#ifdef RADIX_MPATH +#include <net/radix_mpath.h> +#endif + +#include <netinet/in.h> +#include <netinet/in_var.h> +#include <netinet/in_fib.h> + +#ifdef INET +static void fib4_rte_to_nh_basic(struct rtentry *rte, struct in_addr dst, + uint32_t flags, struct nhop4_basic *pnh4); +static void fib4_rte_to_nh_extended(struct rtentry *rte, struct in_addr dst, + uint32_t flags, struct nhop4_extended *pnh4); + +#define RNTORT(p) ((struct rtentry *)(p)) + +static void +fib4_rte_to_nh_basic(struct rtentry *rte, struct in_addr dst, + uint32_t flags, struct nhop4_basic *pnh4) +{ + struct sockaddr_in *gw; + + if ((flags & NHR_IFAIF) != 0) + pnh4->nh_ifp = rte->rt_ifa->ifa_ifp; + else + pnh4->nh_ifp = rte->rt_ifp; + pnh4->nh_mtu = min(rte->rt_mtu, rte->rt_ifp->if_mtu); + if (rte->rt_flags & RTF_GATEWAY) { + gw = (struct sockaddr_in *)rte->rt_gateway; + pnh4->nh_addr = gw->sin_addr; + } else + pnh4->nh_addr = dst; + /* Set flags */ + pnh4->nh_flags = fib_rte_to_nh_flags(rte->rt_flags); + gw = (struct sockaddr_in *)rt_key(rte); + if (gw->sin_addr.s_addr == 0) + pnh4->nh_flags |= NHF_DEFAULT; + /* TODO: Handle RTF_BROADCAST here */ +} + +static void +fib4_rte_to_nh_extended(struct rtentry *rte, struct in_addr dst, + uint32_t flags, struct nhop4_extended *pnh4) +{ + struct sockaddr_in *gw; + struct in_ifaddr *ia; + + pnh4->nh_ifp = rte->rt_ifa->ifa_ifp; + pnh4->nh_mtu = min(rte->rt_mtu, rte->rt_ifp->if_mtu); + if (rte->rt_flags & RTF_GATEWAY) { + gw = (struct sockaddr_in *)rte->rt_gateway; + pnh4->nh_addr = gw->sin_addr; + } else + pnh4->nh_addr = dst; + /* Set flags */ + pnh4->nh_flags = fib_rte_to_nh_flags(rte->rt_flags); + gw = (struct sockaddr_in *)rt_key(rte); + if (gw->sin_addr.s_addr == 0) + pnh4->nh_flags |= NHF_DEFAULT; + /* XXX: Set RTF_BROADCAST if GW address is broadcast */ + + ia = ifatoia(rte->rt_ifa); + pnh4->nh_src = IA_SIN(ia)->sin_addr; +} + +/* + * Performs IPv4 route table lookup on @dst. Returns 0 on success. + * Stores nexthop info provided @pnh4 structure. + * Note that + * - nh_ifp cannot be safely dereferenced + * - nh_ifp represents logical transmit interface (rt_ifp) (e.g. if + * looking up address on interface "ix0" pointer to "lo0" interface + * will be returned instead of "ix0") + * - nh_ifp represents "address" interface if NHR_IFAIF flag is passed + * - howewer mtu from "transmit" interface will be returned. + */ +int +fib4_lookup_nh_basic(uint32_t fibnum, struct in_addr dst, uint32_t flags, + uint32_t flowid, struct nhop4_basic *pnh4) +{ + struct radix_node_head *rh; + struct radix_node *rn; + struct sockaddr_in sin; + struct rtentry *rte; + + KASSERT((fibnum < rt_numfibs), ("fib4_lookup_nh_basic: bad fibnum")); + rh = rt_tables_get_rnh(fibnum, AF_INET); + if (rh == NULL) + return (ENOENT); + + /* Prepare lookup key */ + memset(&sin, 0, sizeof(sin)); + sin.sin_len = sizeof(struct sockaddr_in); + sin.sin_addr = dst; + + RADIX_NODE_HEAD_RLOCK(rh); + rn = rh->rnh_matchaddr((void *)&sin, rh); + if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) { + rte = RNTORT(rn); + /* Ensure route & ifp is UP */ + if (RT_LINK_IS_UP(rte->rt_ifp)) { + fib4_rte_to_nh_basic(rte, dst, flags, pnh4); + RADIX_NODE_HEAD_RUNLOCK(rh); + + return (0); + } + } + RADIX_NODE_HEAD_RUNLOCK(rh); + + return (ENOENT); +} + +/* + * Performs IPv4 route table lookup on @dst. Returns 0 on success. + * Stores extende nexthop info provided @pnh4 structure. + * Note that + * - nh_ifp cannot be safely dereferenced unless NHR_REF is specified. + * - in that case you need to call fib4_free_nh_ext() + * - nh_ifp represents logical transmit interface (rt_ifp) (e.g. if + * looking up address of interface "ix0" pointer to "lo0" interface + * will be returned instead of "ix0") + * - nh_ifp represents "address" interface if NHR_IFAIF flag is passed + * - howewer mtu from "transmit" interface will be returned. + */ +int +fib4_lookup_nh_ext(uint32_t fibnum, struct in_addr dst, uint32_t flowid, + uint32_t flags, struct nhop4_extended *pnh4) +{ + struct radix_node_head *rh; + struct radix_node *rn; + struct sockaddr_in sin; + struct rtentry *rte; + + KASSERT((fibnum < rt_numfibs), ("fib4_lookup_nh_ext: bad fibnum")); + rh = rt_tables_get_rnh(fibnum, AF_INET); + if (rh == NULL) + return (ENOENT); + + /* Prepare lookup key */ + memset(&sin, 0, sizeof(sin)); + sin.sin_len = sizeof(struct sockaddr_in); + sin.sin_addr = dst; + + RADIX_NODE_HEAD_RLOCK(rh); + rn = rh->rnh_matchaddr((void *)&sin, rh); + if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) { + rte = RNTORT(rn); + /* Ensure route & ifp is UP */ + if (RT_LINK_IS_UP(rte->rt_ifp)) { + fib4_rte_to_nh_extended(rte, dst, flags, pnh4); + if ((flags & NHR_REF) != 0) { + /* TODO: lwref on egress ifp's ? */ + } + RADIX_NODE_HEAD_RUNLOCK(rh); + + return (0); + } + } + RADIX_NODE_HEAD_RUNLOCK(rh); + + return (ENOENT); +} + +void +fib4_free_nh_ext(uint32_t fibnum, struct nhop4_extended *pnh4) +{ + +} + +#endif diff --git a/sys/netinet/in_fib.h b/sys/netinet/in_fib.h new file mode 100644 index 0000000..754a2e3 --- /dev/null +++ b/sys/netinet/in_fib.h @@ -0,0 +1,61 @@ +/*- + * Copyright (c) 2015 + * Alexander V. Chernikov <melifaro@FreeBSD.org> + * + * 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. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. + * + * $FreeBSD$ + */ + +#ifndef _NETINET_IN_FIB_H_ +#define _NETINET_IN_FIB_H_ + +/* Basic nexthop info used for uRPF/mtu checks */ +struct nhop4_basic { + struct ifnet *nh_ifp; /* Logical egress interface */ + uint16_t nh_mtu; /* nexthop mtu */ + uint16_t nh_flags; /* nhop flags */ + struct in_addr nh_addr; /* GW/DST IPv4 address */ +}; + +/* Extended nexthop info used for control protocols */ +struct nhop4_extended { + struct ifnet *nh_ifp; /* Logical egress interface */ + uint16_t nh_mtu; /* nexthop mtu */ + uint16_t nh_flags; /* nhop flags */ + uint8_t spare[4]; + struct in_addr nh_addr; /* GW/DST IPv4 address */ + struct in_addr nh_src; /* default source IPv4 address */ + uint64_t spare2[2]; +}; + +int fib4_lookup_nh_basic(uint32_t fibnum, struct in_addr dst, uint32_t flags, + uint32_t flowid, struct nhop4_basic *pnh4); +int fib4_lookup_nh_ext(uint32_t fibnum, struct in_addr dst, uint32_t flags, + uint32_t flowid, struct nhop4_extended *pnh4); +void fib4_free_nh_ext(uint32_t fibnum, struct nhop4_extended *pnh4); + +#endif + diff --git a/sys/netinet/in_gif.c b/sys/netinet/in_gif.c index 0afdea2..0d9945c 100644 --- a/sys/netinet/in_gif.c +++ b/sys/netinet/in_gif.c @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include <netinet/in_var.h> #include <netinet/ip_encap.h> #include <netinet/ip_ecn.h> +#include <netinet/in_fib.h> #ifdef INET6 #include <netinet/ip6.h> @@ -188,22 +189,16 @@ in_gif_encapcheck(const struct mbuf *m, int off, int proto, void *arg) /* ingress filters on outer source */ if ((GIF2IFP(sc)->if_flags & IFF_LINK2) == 0) { - struct sockaddr_in sin; - struct rtentry *rt; - - bzero(&sin, sizeof(sin)); - sin.sin_family = AF_INET; - sin.sin_len = sizeof(struct sockaddr_in); - sin.sin_addr = ip->ip_src; - /* XXX MRT check for the interface we would use on output */ - rt = in_rtalloc1((struct sockaddr *)&sin, 0, - 0UL, sc->gif_fibnum); - if (rt == NULL || rt->rt_ifp != m->m_pkthdr.rcvif) { - if (rt != NULL) - RTFREE_LOCKED(rt); + struct nhop4_basic nh4; + struct in_addr dst; + + dst = ip->ip_src; + + if (fib4_lookup_nh_basic(sc->gif_fibnum, dst, 0, 0, &nh4) != 0) + return (0); + + if (nh4.nh_ifp != m->m_pkthdr.rcvif) return (0); - } - RTFREE_LOCKED(rt); } return (ret); } diff --git a/sys/netinet/ip_options.c b/sys/netinet/ip_options.c index 17ad423..6db9c91 100644 --- a/sys/netinet/ip_options.c +++ b/sys/netinet/ip_options.c @@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$"); #include <net/vnet.h> #include <netinet/in.h> +#include <netinet/in_fib.h> #include <netinet/in_systm.h> #include <netinet/in_var.h> #include <netinet/ip.h> @@ -104,6 +105,7 @@ ip_dooptions(struct mbuf *m, int pass) int opt, optlen, cnt, off, code, type = ICMP_PARAMPROB, forward = 0; struct in_addr *sin, dst; uint32_t ntime; + struct nhop4_extended nh_ext; struct sockaddr_in ipaddr = { sizeof(ipaddr), AF_INET }; /* Ignore or reject packets with IP options. */ @@ -227,6 +229,9 @@ dropit: (void)memcpy(&ipaddr.sin_addr, cp + off, sizeof(ipaddr.sin_addr)); + type = ICMP_UNREACH; + code = ICMP_UNREACH_SRCFAIL; + if (opt == IPOPT_SSRR) { #define INA struct in_ifaddr * #define SA struct sockaddr * @@ -235,18 +240,23 @@ dropit: if (ia == NULL) ia = (INA)ifa_ifwithnet((SA)&ipaddr, 0, RT_ALL_FIBS); - } else -/* XXX MRT 0 for routing */ - ia = ip_rtaddr(ipaddr.sin_addr, M_GETFIB(m)); - if (ia == NULL) { - type = ICMP_UNREACH; - code = ICMP_UNREACH_SRCFAIL; - goto bad; + if (ia == NULL) + goto bad; + + memcpy(cp + off, &(IA_SIN(ia)->sin_addr), + sizeof(struct in_addr)); + ifa_free(&ia->ia_ifa); + } else { + /* XXX MRT 0 for routing */ + if (fib4_lookup_nh_ext(M_GETFIB(m), + ipaddr.sin_addr, 0, 0, &nh_ext) != 0) + goto bad; + + memcpy(cp + off, &nh_ext.nh_src, + sizeof(struct in_addr)); } + ip->ip_dst = ipaddr.sin_addr; - (void)memcpy(cp + off, &(IA_SIN(ia)->sin_addr), - sizeof(struct in_addr)); - ifa_free(&ia->ia_ifa); cp[IPOPT_OFFSET] += sizeof(struct in_addr); /* * Let ip_intr's mcast routing check handle mcast pkts diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c index 32788d3..ca15a0d 100644 --- a/sys/netinet/sctp_input.c +++ b/sys/netinet/sctp_input.c @@ -2103,6 +2103,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, */ stcb = sctp_aloc_assoc(inp, init_src, &error, ntohl(initack_cp->init.initiate_tag), vrf_id, + ntohs(initack_cp->init.num_outbound_streams), (struct thread *)NULL ); if (stcb == NULL) { diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index 55e049f..1929b24 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -3652,6 +3652,7 @@ sctp_process_cmsgs_for_init(struct sctp_tcb *stcb, struct mbuf *control, int *er #endif stcb->asoc.strmout[i].stream_no = i; stcb->asoc.strmout[i].last_msg_incomplete = 0; + stcb->asoc.strmout[i].state = SCTP_STREAM_OPENING; stcb->asoc.ss_functions.sctp_ss_init_stream(&stcb->asoc.strmout[i], NULL); } } @@ -5841,10 +5842,10 @@ do_a_abort: his_limit = ntohs(init_chk->init.num_inbound_streams); /* choose what I want */ if (asoc != NULL) { - if (asoc->streamoutcnt > inp->sctp_ep.pre_open_stream_count) { + if (asoc->streamoutcnt > asoc->pre_open_streams) { i_want = asoc->streamoutcnt; } else { - i_want = inp->sctp_ep.pre_open_stream_count; + i_want = asoc->pre_open_streams; } } else { i_want = inp->sctp_ep.pre_open_stream_count; @@ -12601,6 +12602,7 @@ sctp_lower_sosend(struct socket *so, } #endif stcb = sctp_aloc_assoc(inp, addr, &error, 0, vrf_id, + inp->sctp_ep.pre_open_stream_count, p ); if (stcb == NULL) { diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c index 71b55cb..fc3be4c 100644 --- a/sys/netinet/sctp_pcb.c +++ b/sys/netinet/sctp_pcb.c @@ -4160,6 +4160,7 @@ try_again: struct sctp_tcb * sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr, int *error, uint32_t override_tag, uint32_t vrf_id, + uint16_t o_streams, struct thread *p ) { @@ -4318,7 +4319,7 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr, /* setup back pointer's */ stcb->sctp_ep = inp; stcb->sctp_socket = inp->sctp_socket; - if ((err = sctp_init_asoc(inp, stcb, override_tag, vrf_id))) { + if ((err = sctp_init_asoc(inp, stcb, override_tag, vrf_id, o_streams))) { /* failed */ SCTP_TCB_LOCK_DESTROY(stcb); SCTP_TCB_SEND_LOCK_DESTROY(stcb); diff --git a/sys/netinet/sctp_pcb.h b/sys/netinet/sctp_pcb.h index f5ede2a..ff6ccc5 100644 --- a/sys/netinet/sctp_pcb.h +++ b/sys/netinet/sctp_pcb.h @@ -584,7 +584,7 @@ void sctp_inpcb_free(struct sctp_inpcb *, int, int); struct sctp_tcb * sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *, - int *, uint32_t, uint32_t, struct thread *); + int *, uint32_t, uint32_t, uint16_t, struct thread *); int sctp_free_assoc(struct sctp_inpcb *, struct sctp_tcb *, int, int); diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c index eafa2c9..60deff0 100644 --- a/sys/netinet/sctp_usrreq.c +++ b/sys/netinet/sctp_usrreq.c @@ -1501,6 +1501,7 @@ sctp_do_connect_x(struct socket *so, struct sctp_inpcb *inp, void *optval, /* We are GOOD to go */ stcb = sctp_aloc_assoc(inp, sa, &error, 0, vrf_id, + inp->sctp_ep.pre_open_stream_count, (struct thread *)p ); if (stcb == NULL) { @@ -6929,7 +6930,7 @@ sctp_connect(struct socket *so, struct sockaddr *addr, struct thread *p) } vrf_id = inp->def_vrf_id; /* We are GOOD to go */ - stcb = sctp_aloc_assoc(inp, addr, &error, 0, vrf_id, p); + stcb = sctp_aloc_assoc(inp, addr, &error, 0, vrf_id, inp->sctp_ep.pre_open_stream_count, p); if (stcb == NULL) { /* Gak! no memory */ goto out_now; diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index 8d8f375..f2e9457 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -938,7 +938,7 @@ sctp_map_assoc_state(int kernel_state) int sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, - uint32_t override_tag, uint32_t vrf_id) + uint32_t override_tag, uint32_t vrf_id, uint16_t o_strms) { struct sctp_association *asoc; @@ -1100,7 +1100,7 @@ sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, * that we request by default. */ asoc->strm_realoutsize = asoc->streamoutcnt = asoc->pre_open_streams = - inp->sctp_ep.pre_open_stream_count; + o_strms; SCTP_MALLOC(asoc->strmout, struct sctp_stream_out *, asoc->streamoutcnt * sizeof(struct sctp_stream_out), SCTP_M_STRMO); diff --git a/sys/netinet/sctputil.h b/sys/netinet/sctputil.h index 82de736..354d40e 100644 --- a/sys/netinet/sctputil.h +++ b/sys/netinet/sctputil.h @@ -83,7 +83,7 @@ uint32_t sctp_select_initial_TSN(struct sctp_pcb *); uint32_t sctp_select_a_tag(struct sctp_inpcb *, uint16_t lport, uint16_t rport, int); -int sctp_init_asoc(struct sctp_inpcb *, struct sctp_tcb *, uint32_t, uint32_t); +int sctp_init_asoc(struct sctp_inpcb *, struct sctp_tcb *, uint32_t, uint32_t, uint16_t); void sctp_fill_random_store(struct sctp_pcb *); diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 4caea80..f73c397 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1481,7 +1481,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, struct tcpcb *tp, int drop_hdrlen, int tlen, uint8_t iptos, int ti_locked) { - int thflags, acked, ourfinisacked, needoutput = 0; + int thflags, acked, ourfinisacked, needoutput = 0, sack_changed; int rstreason, todrop, win; u_long tiwin; char *s; @@ -1501,6 +1501,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, thflags = th->th_flags; inc = &tp->t_inpcb->inp_inc; tp->sackhint.last_sack_ack = 0; + sack_changed = 0; /* * If this is either a state-changing packet or current state isn't @@ -2424,7 +2425,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, if ((tp->t_flags & TF_SACK_PERMIT) && ((to.to_flags & TOF_SACK) || !TAILQ_EMPTY(&tp->snd_holes))) - tcp_sack_doack(tp, &to, th->th_ack); + sack_changed = tcp_sack_doack(tp, &to, th->th_ack); else /* * Reset the value so that previous (valid) value @@ -2436,7 +2437,9 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, hhook_run_tcp_est_in(tp, th, &to); if (SEQ_LEQ(th->th_ack, tp->snd_una)) { - if (tlen == 0 && tiwin == tp->snd_wnd) { + if (tlen == 0 && + (tiwin == tp->snd_wnd || + (tp->t_flags & TF_SACK_PERMIT))) { /* * If this is the first time we've seen a * FIN from the remote, this is not a @@ -2478,8 +2481,20 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, * When using TCP ECN, notify the peer that * we reduced the cwnd. */ - if (!tcp_timer_active(tp, TT_REXMT) || - th->th_ack != tp->snd_una) + /* + * Following 2 kinds of acks should not affect + * dupack counting: + * 1) Old acks + * 2) Acks with SACK but without any new SACK + * information in them. These could result from + * any anomaly in the network like a switch + * duplicating packets or a possible DoS attack. + */ + if (th->th_ack != tp->snd_una || + ((tp->t_flags & TF_SACK_PERMIT) && + !sack_changed)) + break; + else if (!tcp_timer_active(tp, TT_REXMT)) tp->t_dupacks = 0; else if (++tp->t_dupacks > tcprexmtthresh || IN_FASTRECOVERY(tp->t_flags)) { @@ -2608,9 +2623,20 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, tp->snd_cwnd = oldcwnd; goto drop; } - } else - tp->t_dupacks = 0; + } break; + } else { + /* + * This ack is advancing the left edge, reset the + * counter. + */ + tp->t_dupacks = 0; + /* + * If this ack also has new SACK info, increment the + * counter as per rfc6675. + */ + if ((tp->t_flags & TF_SACK_PERMIT) && sack_changed) + tp->t_dupacks++; } KASSERT(SEQ_GT(th->th_ack, tp->snd_una), @@ -2629,7 +2655,6 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, } else cc_post_recovery(tp, th); } - tp->t_dupacks = 0; /* * If we reach this point, ACK is not a duplicate, * i.e., it ACKs something we sent. diff --git a/sys/netinet/tcp_sack.c b/sys/netinet/tcp_sack.c index f9c71c8..82e2251 100644 --- a/sys/netinet/tcp_sack.c +++ b/sys/netinet/tcp_sack.c @@ -345,17 +345,22 @@ tcp_sackhole_remove(struct tcpcb *tp, struct sackhole *hole) * Process cumulative ACK and the TCP SACK option to update the scoreboard. * tp->snd_holes is an ordered list of holes (oldest to newest, in terms of * the sequence space). + * Returns 1 if incoming ACK has previously unknown SACK information, + * 0 otherwise. Note: We treat (snd_una, th_ack) as a sack block so any changes + * to that (i.e. left edge moving) would also be considered a change in SACK + * information which is slightly different than rfc6675. */ -void +int tcp_sack_doack(struct tcpcb *tp, struct tcpopt *to, tcp_seq th_ack) { struct sackhole *cur, *temp; struct sackblk sack, sack_blocks[TCP_MAX_SACK + 1], *sblkp; - int i, j, num_sack_blks; + int i, j, num_sack_blks, sack_changed; INP_WLOCK_ASSERT(tp->t_inpcb); num_sack_blks = 0; + sack_changed = 0; /* * If SND.UNA will be advanced by SEG.ACK, and if SACK holes exist, * treat [SND.UNA, SEG.ACK) as if it is a SACK block. @@ -392,7 +397,7 @@ tcp_sack_doack(struct tcpcb *tp, struct tcpopt *to, tcp_seq th_ack) * received. */ if (num_sack_blks == 0) - return; + return (sack_changed); /* * Sort the SACK blocks so we can update the scoreboard with just one @@ -443,6 +448,7 @@ tcp_sack_doack(struct tcpcb *tp, struct tcpopt *to, tcp_seq th_ack) tp->snd_fack = sblkp->end; /* Go to the previous sack block. */ sblkp--; + sack_changed = 1; } else { /* * We failed to add a new hole based on the current @@ -459,9 +465,11 @@ tcp_sack_doack(struct tcpcb *tp, struct tcpopt *to, tcp_seq th_ack) SEQ_LT(tp->snd_fack, sblkp->end)) tp->snd_fack = sblkp->end; } - } else if (SEQ_LT(tp->snd_fack, sblkp->end)) + } else if (SEQ_LT(tp->snd_fack, sblkp->end)) { /* fack is advanced. */ tp->snd_fack = sblkp->end; + sack_changed = 1; + } /* We must have at least one SACK hole in scoreboard. */ KASSERT(!TAILQ_EMPTY(&tp->snd_holes), ("SACK scoreboard must not be empty")); @@ -490,6 +498,7 @@ tcp_sack_doack(struct tcpcb *tp, struct tcpopt *to, tcp_seq th_ack) tp->sackhint.sack_bytes_rexmit -= (cur->rxmit - cur->start); KASSERT(tp->sackhint.sack_bytes_rexmit >= 0, ("sackhint bytes rtx >= 0")); + sack_changed = 1; if (SEQ_LEQ(sblkp->start, cur->start)) { /* Data acks at least the beginning of hole. */ if (SEQ_GEQ(sblkp->end, cur->end)) { @@ -545,6 +554,7 @@ tcp_sack_doack(struct tcpcb *tp, struct tcpopt *to, tcp_seq th_ack) else sblkp--; } + return (sack_changed); } /* diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index a013bda..652ca07 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -741,7 +741,7 @@ void tcp_hc_update(struct in_conninfo *, struct hc_metrics_lite *); extern struct pr_usrreqs tcp_usrreqs; tcp_seq tcp_new_isn(struct tcpcb *); -void tcp_sack_doack(struct tcpcb *, struct tcpopt *, tcp_seq); +int tcp_sack_doack(struct tcpcb *, struct tcpopt *, tcp_seq); void tcp_update_sack_list(struct tcpcb *tp, tcp_seq rcv_laststart, tcp_seq rcv_lastend); void tcp_clean_sackreport(struct tcpcb *tp); void tcp_sack_adjust(struct tcpcb *tp); diff --git a/sys/netinet6/in6_fib.c b/sys/netinet6/in6_fib.c new file mode 100644 index 0000000..70bd1772 --- /dev/null +++ b/sys/netinet6/in6_fib.c @@ -0,0 +1,264 @@ +/*- + * Copyright (c) 2015 + * Alexander V. Chernikov <melifaro@FreeBSD.org> + * + * 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. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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 <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "opt_inet.h" +#include "opt_inet6.h" +#include "opt_route.h" +#include "opt_mpath.h" + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/lock.h> +#include <sys/rwlock.h> +#include <sys/malloc.h> +#include <sys/mbuf.h> +#include <sys/socket.h> +#include <sys/sysctl.h> +#include <sys/kernel.h> + +#include <net/if.h> +#include <net/if_var.h> +#include <net/if_dl.h> +#include <net/route.h> +#include <net/vnet.h> + +#ifdef RADIX_MPATH +#include <net/radix_mpath.h> +#endif + +#include <netinet/in.h> +#include <netinet/in_var.h> +#include <netinet/ip_mroute.h> +#include <netinet/ip6.h> +#include <netinet6/in6_fib.h> +#include <netinet6/in6_var.h> +#include <netinet6/nd6.h> +#include <netinet6/scope6_var.h> + +#include <net/if_types.h> + +#ifdef INET6 +static void fib6_rte_to_nh_extended(struct rtentry *rte, + const struct in6_addr *dst, uint32_t flags, struct nhop6_extended *pnh6); +static void fib6_rte_to_nh_basic(struct rtentry *rte, const struct in6_addr *dst, + uint32_t flags, struct nhop6_basic *pnh6); +static struct ifnet *fib6_get_ifaifp(struct rtentry *rte); +#define RNTORT(p) ((struct rtentry *)(p)) + +/* + * Gets real interface for the @rte. + * Returns rt_ifp for !IFF_LOOPBACK routers. + * Extracts "real" address interface from interface address + * loopback routes. + */ +static struct ifnet * +fib6_get_ifaifp(struct rtentry *rte) +{ + struct ifnet *ifp; + struct sockaddr_dl *sdl; + + ifp = rte->rt_ifp; + if ((ifp->if_flags & IFF_LOOPBACK) && + rte->rt_gateway->sa_family == AF_LINK) { + sdl = (struct sockaddr_dl *)rte->rt_gateway; + return (ifnet_byindex(sdl->sdl_index)); + } + + return (ifp); +} + +static void +fib6_rte_to_nh_basic(struct rtentry *rte, const struct in6_addr *dst, + uint32_t flags, struct nhop6_basic *pnh6) +{ + struct sockaddr_in6 *gw; + + /* Do explicit nexthop zero unless we're copying it */ + memset(pnh6, 0, sizeof(*pnh6)); + + if ((flags & NHR_IFAIF) != 0) + pnh6->nh_ifp = fib6_get_ifaifp(rte); + else + pnh6->nh_ifp = rte->rt_ifp; + + pnh6->nh_mtu = min(rte->rt_mtu, IN6_LINKMTU(rte->rt_ifp)); + if (rte->rt_flags & RTF_GATEWAY) { + gw = (struct sockaddr_in6 *)rte->rt_gateway; + pnh6->nh_addr = gw->sin6_addr; + in6_clearscope(&pnh6->nh_addr); + } else + pnh6->nh_addr = *dst; + /* Set flags */ + pnh6->nh_flags = fib_rte_to_nh_flags(rte->rt_flags); + gw = (struct sockaddr_in6 *)rt_key(rte); + if (IN6_IS_ADDR_UNSPECIFIED(&gw->sin6_addr)) + pnh6->nh_flags |= NHF_DEFAULT; +} + +static void +fib6_rte_to_nh_extended(struct rtentry *rte, const struct in6_addr *dst, + uint32_t flags, struct nhop6_extended *pnh6) +{ + struct sockaddr_in6 *gw; + + /* Do explicit nexthop zero unless we're copying it */ + memset(pnh6, 0, sizeof(*pnh6)); + + if ((flags & NHR_IFAIF) != 0) + pnh6->nh_ifp = fib6_get_ifaifp(rte); + else + pnh6->nh_ifp = rte->rt_ifp; + + pnh6->nh_mtu = min(rte->rt_mtu, IN6_LINKMTU(rte->rt_ifp)); + if (rte->rt_flags & RTF_GATEWAY) { + gw = (struct sockaddr_in6 *)rte->rt_gateway; + pnh6->nh_addr = gw->sin6_addr; + in6_clearscope(&pnh6->nh_addr); + } else + pnh6->nh_addr = *dst; + /* Set flags */ + pnh6->nh_flags = fib_rte_to_nh_flags(rte->rt_flags); + gw = (struct sockaddr_in6 *)rt_key(rte); + if (IN6_IS_ADDR_UNSPECIFIED(&gw->sin6_addr)) + pnh6->nh_flags |= NHF_DEFAULT; +} + +/* + * Performs IPv6 route table lookup on @dst. Returns 0 on success. + * Stores basic nexthop info into provided @pnh6 structure. + * Note that + * - nh_ifp represents logical transmit interface (rt_ifp) by default + * - nh_ifp represents "address" interface if NHR_IFAIF flag is passed + * - mtu from logical transmit interface will be returned. + * - nh_ifp cannot be safely dereferenced + * - nh_ifp represents rt_ifp (e.g. if looking up address on + * interface "ix0" pointer to "ix0" interface will be returned instead + * of "lo0") + * - howewer mtu from "transmit" interface will be returned. + */ +int +fib6_lookup_nh_basic(uint32_t fibnum, const struct in6_addr *dst, uint32_t scopeid, + uint32_t flags, uint32_t flowid, struct nhop6_basic *pnh6) +{ + struct radix_node_head *rh; + struct radix_node *rn; + struct sockaddr_in6 sin6; + struct rtentry *rte; + + KASSERT((fibnum < rt_numfibs), ("fib6_lookup_nh_basic: bad fibnum")); + rh = rt_tables_get_rnh(fibnum, AF_INET6); + if (rh == NULL) + return (ENOENT); + + /* Prepare lookup key */ + memset(&sin6, 0, sizeof(sin6)); + sin6.sin6_addr = *dst; + /* Assume scopeid is valid and embed it directly */ + if (IN6_IS_SCOPE_LINKLOCAL(dst)) + sin6.sin6_addr.s6_addr16[1] = htons(scopeid & 0xffff); + + RADIX_NODE_HEAD_RLOCK(rh); + rn = rh->rnh_matchaddr((void *)&sin6, rh); + if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) { + rte = RNTORT(rn); + /* Ensure route & ifp is UP */ + if (RT_LINK_IS_UP(rte->rt_ifp)) { + fib6_rte_to_nh_basic(rte, dst, flags, pnh6); + RADIX_NODE_HEAD_RUNLOCK(rh); + return (0); + } + } + RADIX_NODE_HEAD_RUNLOCK(rh); + + return (ENOENT); +} + +/* + * Performs IPv6 route table lookup on @dst. Returns 0 on success. + * Stores extended nexthop info into provided @pnh6 structure. + * Note that + * - nh_ifp cannot be safely dereferenced unless NHR_REF is specified. + * - in that case you need to call fib6_free_nh_ext() + * - nh_ifp represents logical transmit interface (rt_ifp) by default + * - nh_ifp represents "address" interface if NHR_IFAIF flag is passed + * - mtu from logical transmit interface will be returned. + */ +int +fib6_lookup_nh_ext(uint32_t fibnum, const struct in6_addr *dst,uint32_t scopeid, + uint32_t flags, uint32_t flowid, struct nhop6_extended *pnh6) +{ + struct radix_node_head *rh; + struct radix_node *rn; + struct sockaddr_in6 sin6; + struct rtentry *rte; + + KASSERT((fibnum < rt_numfibs), ("fib6_lookup_nh_ext: bad fibnum")); + rh = rt_tables_get_rnh(fibnum, AF_INET6); + if (rh == NULL) + return (ENOENT); + + /* Prepare lookup key */ + memset(&sin6, 0, sizeof(sin6)); + sin6.sin6_len = sizeof(struct sockaddr_in6); + sin6.sin6_addr = *dst; + /* Assume scopeid is valid and embed it directly */ + if (IN6_IS_SCOPE_LINKLOCAL(dst)) + sin6.sin6_addr.s6_addr16[1] = htons(scopeid & 0xffff); + + RADIX_NODE_HEAD_RLOCK(rh); + rn = rh->rnh_matchaddr((void *)&sin6, rh); + if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) { + rte = RNTORT(rn); + /* Ensure route & ifp is UP */ + if (RT_LINK_IS_UP(rte->rt_ifp)) { + fib6_rte_to_nh_extended(rte, dst, flags, pnh6); + if ((flags & NHR_REF) != 0) { + /* TODO: Do lwref on egress ifp's */ + } + RADIX_NODE_HEAD_RUNLOCK(rh); + + return (0); + } + } + RADIX_NODE_HEAD_RUNLOCK(rh); + + return (ENOENT); +} + +void +fib6_free_nh_ext(uint32_t fibnum, struct nhop6_extended *pnh6) +{ + +} + +#endif + diff --git a/sys/netinet6/in6_fib.h b/sys/netinet6/in6_fib.h new file mode 100644 index 0000000..3d58cd2 --- /dev/null +++ b/sys/netinet6/in6_fib.h @@ -0,0 +1,61 @@ +/*- + * Copyright (c) 2015 + * Alexander V. Chernikov <melifaro@FreeBSD.org> + * + * 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. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. + * + * $FreeBSD$ + */ + +#ifndef _NETINET6_IN6_FIB_H_ +#define _NETINET6_IN6_FIB_H_ + +/* Basic nexthop info used for uRPF/mtu checks */ +struct nhop6_basic { + struct ifnet *nh_ifp; /* Logical egress interface */ + uint16_t nh_mtu; /* nexthop mtu */ + uint16_t nh_flags; /* nhop flags */ + uint8_t spare[4]; + struct in6_addr nh_addr; /* GW/DST IPv4 address */ +}; + +/* Does not differ from nhop6_basic */ +struct nhop6_extended { + struct ifnet *nh_ifp; /* Logical egress interface */ + uint16_t nh_mtu; /* nexthop mtu */ + uint16_t nh_flags; /* nhop flags */ + uint8_t spare[4]; + struct in6_addr nh_addr; /* GW/DST IPv6 address */ + uint64_t spare2[2]; +}; + +int fib6_lookup_nh_basic(uint32_t fibnum, const struct in6_addr *dst, + uint32_t scopeid, uint32_t flags, uint32_t flowid,struct nhop6_basic *pnh6); +int fib6_lookup_nh_ext(uint32_t fibnum, const struct in6_addr *dst, + uint32_t scopeid, uint32_t flags, uint32_t flowid, + struct nhop6_extended *pnh6); +void fib6_free_nh_ext(uint32_t fibnum, struct nhop6_extended *pnh6); +#endif + diff --git a/sys/netinet6/in6_gif.c b/sys/netinet6/in6_gif.c index d714f23..76ab400 100644 --- a/sys/netinet6/in6_gif.c +++ b/sys/netinet6/in6_gif.c @@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$"); #include <netinet/ip_ecn.h> #ifdef INET6 #include <netinet6/ip6_ecn.h> +#include <netinet6/in6_fib.h> #endif #include <net/if_gif.h> @@ -203,23 +204,15 @@ in6_gif_encapcheck(const struct mbuf *m, int off, int proto, void *arg) /* ingress filters on outer source */ if ((GIF2IFP(sc)->if_flags & IFF_LINK2) == 0) { - struct sockaddr_in6 sin6; - struct rtentry *rt; - - bzero(&sin6, sizeof(sin6)); - sin6.sin6_family = AF_INET6; - sin6.sin6_len = sizeof(struct sockaddr_in6); - sin6.sin6_addr = ip6->ip6_src; - sin6.sin6_scope_id = 0; /* XXX */ - - rt = in6_rtalloc1((struct sockaddr *)&sin6, 0, 0UL, - sc->gif_fibnum); - if (rt == NULL || rt->rt_ifp != m->m_pkthdr.rcvif) { - if (rt != NULL) - RTFREE_LOCKED(rt); + struct nhop6_basic nh6; + struct in6_addr *dst; + + /* XXX empty scope id */ + if (fib6_lookup_nh_basic(sc->gif_fibnum, dst, 0, 0, 0, &nh6)!=0) + return (0); + + if (nh6.nh_ifp != m->m_pkthdr.rcvif) return (0); - } - RTFREE_LOCKED(rt); } return (ret); } diff --git a/sys/netinet6/scope6.c b/sys/netinet6/scope6.c index 0e4d303..1a9d038 100644 --- a/sys/netinet6/scope6.c +++ b/sys/netinet6/scope6.c @@ -487,6 +487,22 @@ in6_getscopezone(const struct ifnet *ifp, int scope) } /* + * Extracts scope from adddress @dst, stores cleared address + * inside @dst and zone inside @scopeid + */ +void +in6_splitscope(const struct in6_addr *src, struct in6_addr *dst, + uint32_t *scopeid) +{ + uint32_t zoneid; + + *dst = *src; + zoneid = ntohs(in6_getscope(dst)); + in6_clearscope(dst); + *scopeid = zoneid; +} + +/* * This function is for checking sockaddr_in6 structure passed * from the application level (usually). * diff --git a/sys/netinet6/scope6_var.h b/sys/netinet6/scope6_var.h index d4d0478..e38d77a 100644 --- a/sys/netinet6/scope6_var.h +++ b/sys/netinet6/scope6_var.h @@ -63,6 +63,7 @@ int in6_setscope(struct in6_addr *, struct ifnet *, u_int32_t *); int in6_clearscope(struct in6_addr *); uint16_t in6_getscope(struct in6_addr *); uint32_t in6_getscopezone(const struct ifnet *, int); +void in6_splitscope(const struct in6_addr *, struct in6_addr *, uint32_t *); struct ifnet* in6_getlinkifnet(uint32_t); #endif /* _KERNEL */ diff --git a/sys/netinet6/sctp6_usrreq.c b/sys/netinet6/sctp6_usrreq.c index 4f0d83d..43df06e 100644 --- a/sys/netinet6/sctp6_usrreq.c +++ b/sys/netinet6/sctp6_usrreq.c @@ -946,7 +946,7 @@ sctp6_connect(struct socket *so, struct sockaddr *addr, struct thread *p) return (EALREADY); } /* We are GOOD to go */ - stcb = sctp_aloc_assoc(inp, addr, &error, 0, vrf_id, p); + stcb = sctp_aloc_assoc(inp, addr, &error, 0, vrf_id, inp->sctp_ep.pre_open_stream_count, p); SCTP_ASOC_CREATE_UNLOCK(inp); if (stcb == NULL) { /* Gak! no memory */ diff --git a/sys/netpfil/ipfw/ip_fw2.c b/sys/netpfil/ipfw/ip_fw2.c index 73a27df..3a17c3c 100644 --- a/sys/netpfil/ipfw/ip_fw2.c +++ b/sys/netpfil/ipfw/ip_fw2.c @@ -84,7 +84,9 @@ __FBSDID("$FreeBSD$"); #include <netinet/ip6.h> #include <netinet/icmp6.h> +#include <netinet/in_fib.h> #ifdef INET6 +#include <netinet6/in6_fib.h> #include <netinet6/in6_pcb.h> #include <netinet6/scope6_var.h> #include <netinet6/ip6_var.h> @@ -437,19 +439,10 @@ verify_path(struct in_addr src, struct ifnet *ifp, u_int fib) #if defined(USERSPACE) || !defined(__FreeBSD__) return 0; #else - struct route ro; - struct sockaddr_in *dst; + struct nhop4_basic nh4; - bzero(&ro, sizeof(ro)); - - dst = (struct sockaddr_in *)&(ro.ro_dst); - dst->sin_family = AF_INET; - dst->sin_len = sizeof(*dst); - dst->sin_addr = src; - in_rtalloc_ign(&ro, 0, fib); - - if (ro.ro_rt == NULL) - return 0; + if (fib4_lookup_nh_basic(fib, src, NHR_IFAIF, 0, &nh4) != 0) + return (0); /* * If ifp is provided, check for equality with rtentry. @@ -458,26 +451,18 @@ verify_path(struct in_addr src, struct ifnet *ifp, u_int fib) * routing entry (via lo0) for our own address * may exist, so we need to handle routing assymetry. */ - if (ifp != NULL && ro.ro_rt->rt_ifa->ifa_ifp != ifp) { - RTFREE(ro.ro_rt); - return 0; - } + if (ifp != NULL && ifp != nh4.nh_ifp) + return (0); /* if no ifp provided, check if rtentry is not default route */ - if (ifp == NULL && - satosin(rt_key(ro.ro_rt))->sin_addr.s_addr == INADDR_ANY) { - RTFREE(ro.ro_rt); - return 0; - } + if (ifp == NULL && (nh4.nh_flags & NHF_DEFAULT) != 0) + return (0); /* or if this is a blackhole/reject route */ - if (ifp == NULL && ro.ro_rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) { - RTFREE(ro.ro_rt); - return 0; - } + if (ifp == NULL && (nh4.nh_flags & (NHF_REJECT|NHF_BLACKHOLE)) != 0) + return (0); /* found valid route */ - RTFREE(ro.ro_rt); return 1; #endif /* __FreeBSD__ */ } @@ -537,49 +522,28 @@ ipfw_localip6(struct in6_addr *in6) static int verify_path6(struct in6_addr *src, struct ifnet *ifp, u_int fib) { - struct route_in6 ro; - struct sockaddr_in6 *dst; - - bzero(&ro, sizeof(ro)); + struct nhop6_basic nh6; - dst = (struct sockaddr_in6 * )&(ro.ro_dst); - dst->sin6_family = AF_INET6; - dst->sin6_len = sizeof(*dst); - dst->sin6_addr = *src; + if (IN6_IS_SCOPE_LINKLOCAL(src)) + return (1); - in6_rtalloc_ign(&ro, 0, fib); - if (ro.ro_rt == NULL) - return 0; + if (fib6_lookup_nh_basic(fib, src, 0, NHR_IFAIF, 0, &nh6) != 0) + return (0); - /* - * if ifp is provided, check for equality with rtentry - * We should use rt->rt_ifa->ifa_ifp, instead of rt->rt_ifp, - * to support the case of sending packets to an address of our own. - * (where the former interface is the first argument of if_simloop() - * (=ifp), the latter is lo0) - */ - if (ifp != NULL && ro.ro_rt->rt_ifa->ifa_ifp != ifp) { - RTFREE(ro.ro_rt); - return 0; - } + /* If ifp is provided, check for equality with route table. */ + if (ifp != NULL && ifp != nh6.nh_ifp) + return (0); /* if no ifp provided, check if rtentry is not default route */ - if (ifp == NULL && - IN6_IS_ADDR_UNSPECIFIED(&satosin6(rt_key(ro.ro_rt))->sin6_addr)) { - RTFREE(ro.ro_rt); - return 0; - } + if (ifp == NULL && (nh6.nh_flags & NHF_DEFAULT) != 0) + return (0); /* or if this is a blackhole/reject route */ - if (ifp == NULL && ro.ro_rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) { - RTFREE(ro.ro_rt); - return 0; - } + if (ifp == NULL && (nh6.nh_flags & (NHF_REJECT|NHF_BLACKHOLE)) != 0) + return (0); /* found valid route */ - RTFREE(ro.ro_rt); return 1; - } static int diff --git a/sys/sys/elf_common.h b/sys/sys/elf_common.h index d6ca101..30c6c44 100644 --- a/sys/sys/elf_common.h +++ b/sys/sys/elf_common.h @@ -727,6 +727,11 @@ typedef struct { #define LL_DELAY_LOAD 0x10 #define LL_DELTA 0x20 +/* Values for n_type used in executables. */ +#define NT_FREEBSD_ABI_TAG 1 +#define NT_FREEBSD_NOINIT_TAG 2 +#define NT_FREEBSD_ARCH_TAG 3 + /* Values for n_type. Used in core files. */ #define NT_PRSTATUS 1 /* Process status. */ #define NT_FPREGSET 2 /* Floating point registers. */ diff --git a/sys/sys/ptrace.h b/sys/sys/ptrace.h index 7135767..7ccd3d6 100644 --- a/sys/sys/ptrace.h +++ b/sys/sys/ptrace.h @@ -166,6 +166,10 @@ int proc_read_dbregs(struct thread *_td, struct dbreg *_dbreg); int proc_write_dbregs(struct thread *_td, struct dbreg *_dbreg); int proc_sstep(struct thread *_td); int proc_rwmem(struct proc *_p, struct uio *_uio); +ssize_t proc_readmem(struct thread *_td, struct proc *_p, vm_offset_t _va, + void *_buf, size_t _len); +ssize_t proc_writemem(struct thread *_td, struct proc *_p, vm_offset_t _va, + void *_buf, size_t _len); #ifdef COMPAT_FREEBSD32 struct reg32; struct fpreg32; diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 3d7a21d..c0729f8 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -639,19 +639,14 @@ ufs_setattr(ap) error = vn_utimes_perm(vp, vap, cred, td); if (error != 0) return (error); - if (vap->va_atime.tv_sec != VNOVAL) - ip->i_flag |= IN_ACCESS; - if (vap->va_mtime.tv_sec != VNOVAL) - ip->i_flag |= IN_CHANGE | IN_UPDATE; - if (vap->va_birthtime.tv_sec != VNOVAL && - ip->i_ump->um_fstype == UFS2) - ip->i_flag |= IN_MODIFIED; - ufs_itimes(vp); + ip->i_flag |= IN_CHANGE | IN_MODIFIED; if (vap->va_atime.tv_sec != VNOVAL) { + ip->i_flag &= ~IN_ACCESS; DIP_SET(ip, i_atime, vap->va_atime.tv_sec); DIP_SET(ip, i_atimensec, vap->va_atime.tv_nsec); } if (vap->va_mtime.tv_sec != VNOVAL) { + ip->i_flag &= ~IN_UPDATE; DIP_SET(ip, i_mtime, vap->va_mtime.tv_sec); DIP_SET(ip, i_mtimensec, vap->va_mtime.tv_nsec); } diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index 50983ca..6990d12 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -839,7 +839,7 @@ vnode_locked: * get rid of the unnecessary page */ vm_page_lock(fs.first_m); - vm_page_free(fs.first_m); + vm_page_remove(fs.first_m); vm_page_unlock(fs.first_m); /* * grab the page and put it into the @@ -848,9 +848,13 @@ vnode_locked: */ if (vm_page_rename(fs.m, fs.first_object, fs.first_pindex)) { + VM_OBJECT_WUNLOCK(fs.first_object); unlock_and_deallocate(&fs); goto RetryFault; } + vm_page_lock(fs.first_m); + vm_page_free(fs.first_m); + vm_page_unlock(fs.first_m); #if VM_NRESERVLEVEL > 0 /* * Rename the reservation. diff --git a/sys/x86/include/x86_smp.h b/sys/x86/include/x86_smp.h new file mode 100644 index 0000000..38d7625 --- /dev/null +++ b/sys/x86/include/x86_smp.h @@ -0,0 +1,103 @@ +/*- + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp + * ---------------------------------------------------------------------------- + * + * $FreeBSD$ + * + */ + +#ifndef _X86_X86_SMP_H_ +#define _X86_X86_SMP_H_ + +#include <sys/bus.h> +#include <machine/frame.h> +#include <machine/intr_machdep.h> +#include <x86/apicvar.h> +#include <machine/pcb.h> + +struct pmap; + +/* global data in mp_x86.c */ +extern int mp_naps; +extern int boot_cpu_id; +extern struct pcb stoppcbs[]; +extern int cpu_apic_ids[]; +extern int bootAP; +extern void *dpcpu; +extern char *bootSTK; +extern void *bootstacks[]; +extern volatile u_int cpu_ipi_pending[]; +extern volatile int aps_ready; +extern struct mtx ap_boot_mtx; +extern int cpu_logical; +extern int cpu_cores; +extern volatile int smp_tlb_wait; +extern struct pmap *smp_tlb_pmap; +extern u_int xhits_gbl[]; +extern u_int xhits_pg[]; +extern u_int xhits_rng[]; +extern u_int ipi_global; +extern u_int ipi_page; +extern u_int ipi_range; +extern u_int ipi_range_size; + +struct cpu_info { + int cpu_present:1; + int cpu_bsp:1; + int cpu_disabled:1; + int cpu_hyperthread:1; +}; +extern struct cpu_info cpu_info[]; + +#ifdef COUNT_IPIS +extern u_long *ipi_invltlb_counts[MAXCPU]; +extern u_long *ipi_invlrng_counts[MAXCPU]; +extern u_long *ipi_invlpg_counts[MAXCPU]; +extern u_long *ipi_invlcache_counts[MAXCPU]; +extern u_long *ipi_rendezvous_counts[MAXCPU]; +#endif + +/* IPI handlers */ +inthand_t + IDTVEC(invltlb), /* TLB shootdowns - global */ + IDTVEC(invlpg), /* TLB shootdowns - 1 page */ + IDTVEC(invlrng), /* TLB shootdowns - page range */ + IDTVEC(invlcache), /* Write back and invalidate cache */ + IDTVEC(ipi_intr_bitmap_handler), /* Bitmap based IPIs */ + IDTVEC(cpustop), /* CPU stops & waits to be restarted */ + IDTVEC(cpususpend), /* CPU suspends & waits to be resumed */ + IDTVEC(rendezvous); /* handle CPU rendezvous */ + +/* functions in x86_mp.c */ +void assign_cpu_ids(void); +void cpu_add(u_int apic_id, char boot_cpu); +void cpustop_handler(void); +void cpususpend_handler(void); +void init_secondary_tail(void); +void invltlb_handler(void); +void invlpg_handler(void); +void invlrng_handler(void); +void invlcache_handler(void); +void init_secondary(void); +void ipi_startup(int apic_id, int vector); +void ipi_all_but_self(u_int ipi); +void ipi_bitmap_handler(struct trapframe frame); +void ipi_cpu(int cpu, u_int ipi); +int ipi_nmi_handler(void); +void ipi_selected(cpuset_t cpus, u_int ipi); +u_int mp_bootaddress(u_int); +void set_interrupt_apic_ids(void); +void smp_cache_flush(void); +void smp_masked_invlpg(cpuset_t mask, vm_offset_t addr); +void smp_masked_invlpg_range(cpuset_t mask, vm_offset_t startva, + vm_offset_t endva); +void smp_masked_invltlb(cpuset_t mask, struct pmap *pmap); +void mem_range_AP_init(void); +void topo_probe(void); +void ipi_send_cpu(int cpu, u_int ipi); + +#endif diff --git a/sys/x86/include/x86_var.h b/sys/x86/include/x86_var.h new file mode 100644 index 0000000..c349913 --- /dev/null +++ b/sys/x86/include/x86_var.h @@ -0,0 +1,110 @@ +/*- + * Copyright (c) 1995 Bruce D. Evans. + * 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. + * 3. Neither the name of the author nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * 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. + * + * $FreeBSD$ + */ + +#ifndef _X86_X86_VAR_H_ +#define _X86_X86_VAR_H_ + +/* + * Miscellaneous machine-dependent declarations. + */ + +extern long Maxmem; +extern u_int basemem; +extern int busdma_swi_pending; +extern u_int cpu_exthigh; +extern u_int cpu_feature; +extern u_int cpu_feature2; +extern u_int amd_feature; +extern u_int amd_feature2; +extern u_int amd_pminfo; +extern u_int via_feature_rng; +extern u_int via_feature_xcrypt; +extern u_int cpu_clflush_line_size; +extern u_int cpu_stdext_feature; +extern u_int cpu_stdext_feature2; +extern u_int cpu_fxsr; +extern u_int cpu_high; +extern u_int cpu_id; +extern u_int cpu_max_ext_state_size; +extern u_int cpu_mxcsr_mask; +extern u_int cpu_procinfo; +extern u_int cpu_procinfo2; +extern char cpu_vendor[]; +extern u_int cpu_vendor_id; +extern u_int cpu_mon_mwait_flags; +extern u_int cpu_mon_min_size; +extern u_int cpu_mon_max_size; +extern u_int cpu_maxphyaddr; +extern char ctx_switch_xsave[]; +extern u_int hv_high; +extern char hv_vendor[]; +extern char kstack[]; +extern char sigcode[]; +extern int szsigcode; +extern int vm_page_dump_size; +extern int workaround_erratum383; +extern int _udatasel; +extern int _ucodesel; +extern int _ucode32sel; +extern int _ufssel; +extern int _ugssel; +extern int use_xsave; +extern uint64_t xsave_mask; + +struct pcb; +struct thread; +struct reg; +struct fpreg; +struct dbreg; +struct dumperinfo; + +void *alloc_fpusave(int flags); +void busdma_swi(void); +bool cpu_mwait_usable(void); +void cpu_probe_amdc1e(void); +void cpu_setregs(void); +void dump_add_page(vm_paddr_t); +void dump_drop_page(vm_paddr_t); +void identify_cpu(void); +void initializecpu(void); +void initializecpucache(void); +bool intel_fix_cpuid(void); +void fillw(int /*u_short*/ pat, void *base, size_t cnt); +int is_physical_memory(vm_paddr_t addr); +int isa_nmi(int cd); +void panicifcpuunsupported(void); +void pagecopy(void *from, void *to); +void printcpuinfo(void); +int user_dbreg_trap(void); +int minidumpsys(struct dumperinfo *); +struct pcb *get_pcb_td(struct thread *td); + +#endif diff --git a/targets/pseudo/gcc/Makefile.depend b/targets/pseudo/gcc/Makefile.depend index 795a752..daf2dfc 100644 --- a/targets/pseudo/gcc/Makefile.depend +++ b/targets/pseudo/gcc/Makefile.depend @@ -11,11 +11,9 @@ DIRDEPS = \ gnu/usr.bin/cc/cc \ gnu/usr.bin/cc/cc1 \ gnu/usr.bin/cc/include \ - gnu/usr.bin/cc/doc \ gnu/usr.bin/cc/cpp \ gnu/usr.bin/cc/cc1plus \ gnu/usr.bin/cc/c++ \ - gnu/usr.bin/cc/c++filt \ gnu/usr.bin/cc/gcov \ diff --git a/targets/pseudo/universe/Makefile b/targets/pseudo/universe/Makefile index ef696d3..838c4a4 100644 --- a/targets/pseudo/universe/Makefile +++ b/targets/pseudo/universe/Makefile @@ -36,8 +36,6 @@ UNIVERSE_TARGET_RELDIR?= targets/pseudo/the-lot # the list of machines TARGET_MACHINE_LIST = i386 amd64 -# some machines have more than one arch -TARGET_ARCHES_arm?= arm armeb armv6 armv6hf # avoid ../Makefile.inc defining this all: diff --git a/tools/regression/mac/mac_portacl/misc.sh b/tools/regression/mac/mac_portacl/misc.sh index 0fabe15..a1f152b 100755 --- a/tools/regression/mac/mac_portacl/misc.sh +++ b/tools/regression/mac/mac_portacl/misc.sh @@ -3,8 +3,7 @@ sysctl security.mac.portacl >/dev/null 2>&1 if [ $? -ne 0 ]; then - echo "1..1" - echo "not ok 1 # MAC_PORTACL is unavailable." + echo "1..0 # SKIP MAC_PORTACL is unavailable." exit 0 fi diff --git a/tools/regression/tls/ttls2/ttls2.c b/tools/regression/tls/ttls2/ttls2.c index f528e3d..15eb640 100644 --- a/tools/regression/tls/ttls2/ttls2.c +++ b/tools/regression/tls/ttls2/ttls2.c @@ -1,7 +1,8 @@ /* $FreeBSD$ */ -#include <stdio.h> #include <pthread.h> +#include <stdio.h> +#include <unistd.h> int __thread i; @@ -13,6 +14,7 @@ foo1(void *arg) printf("thread %p, i = %d\n", pthread_self(), i); sleep(1); } + return (NULL); } void * @@ -23,9 +25,11 @@ foo2(void *arg) printf("thread %p, i = %d\n", pthread_self(), i); sleep(1); } + return (NULL); } -int main(int argc, char** argv) +int +main(int argc, char** argv) { pthread_t t1, t2; @@ -33,4 +37,6 @@ int main(int argc, char** argv) pthread_create(&t2, 0, foo2, 0); pthread_join(t1, 0); pthread_join(t2, 0); + + return (0); } diff --git a/tools/regression/tls/ttls4/ttls4.c b/tools/regression/tls/ttls4/ttls4.c index d55e51b..914b220 100644 --- a/tools/regression/tls/ttls4/ttls4.c +++ b/tools/regression/tls/ttls4/ttls4.c @@ -9,11 +9,13 @@ #include <stdio.h> #include <pthread.h> +#include <stdlib.h> #include <unistd.h> int __thread n; -void *f1(void *arg) +void +*f1(void *arg) { if (n != 0) { printf("bug, n == %d \n", n); @@ -23,7 +25,8 @@ void *f1(void *arg) return (0); } -int main() +int +main(void) { pthread_t td; int i; diff --git a/tools/tools/nanobsd/defaults.sh b/tools/tools/nanobsd/defaults.sh index 067d306..46608f4 100755 --- a/tools/tools/nanobsd/defaults.sh +++ b/tools/tools/nanobsd/defaults.sh @@ -134,7 +134,7 @@ NANO_BOOTLOADER="boot/boot0sio" # boot2 flags/options # default force serial console -NANO_BOOT2CFG="-h" +NANO_BOOT2CFG="-h -S115200" # Backing type of md(4) device # Can be "file" or "swap" @@ -157,6 +157,9 @@ NANO_SLICE_ALTROOT=s2 NANO_SLICE_CFG=s3 NANO_SLICE_DATA=s4 +# Default ownwership for nopriv build +NANO_DEF_UNAME=root +NANO_DEF_GNAME=wheel ####################################################################### # Architecture to build. Corresponds to TARGET_ARCH in a buildworld. @@ -226,19 +229,52 @@ nano_make_kernel_env ( ) { } nano_global_make_env ( ) ( - [ ! -z "${NANO_ARCH}" ] && echo TARGET_ARCH="${NANO_ARCH}" || true - [ ! -z "${NANO_CPUTYPE}" ] && echo TARGET_CPUTYPE="${NANO_CPUTYPE}" || true + # global settings for the make.conf file, if set + [ -z "${NANO_ARCH}" ] || echo TARGET_ARCH="${NANO_ARCH}" + [ -z "${NANO_CPUTYPE}" ] || echo TARGET_CPUTYPE="${NANO_CPUTYPE}" ) # rm doesn't know -x prior to FreeBSD 10, so cope with a variety of build -# hosts for now. -nano_rm ( ) { +# hosts for now. This will go away when support in the base goes away. +rm ( ) { + echo "NANO RM $*" case $(uname -r) in - 7*|8*|9*) rm $* ;; - *) rm -x $* ;; + 7*|8*|9*) command rm $* ;; + *) command rm -x $* ;; esac } +# +# Create empty files in the target tree, and record the fact. All paths +# are relative to NANO_WORLDDIR. +# +tgt_touch ( ) ( + + cd "${NANO_WORLDDIR}" + for i; do + touch $i + echo "./${i} type=file" >> ${NANO_METALOG} + done +) + +# +# Convert a directory into a symlink. Takes two arguments, the +# current directory and what it should become a symlink to. The +# directory is removed and a symlink is created. If we're doing +# a nopriv build, then append this fact to the metalog +# +tgt_dir2symlink () ( + dir=$1 + symlink=$2 + + cd "${NANO_WORLDDIR}" + rm -rf "$dir" + ln -s "$symlink" "$dir" + if [ -n "$NANO_METALOG" ]; then + echo "./${dir} type=link mode=0777 link=${symlink}" >> ${NANO_METALOG} + fi +) + # run in the world chroot, errors fatal CR ( ) { chroot "${NANO_WORLDDIR}" /bin/sh -exc "$*" @@ -250,18 +286,16 @@ CR0 ( ) { } nano_cleanup ( ) ( - if [ $? -ne 0 ]; then - echo "Error encountered. Check for errors in last log file." 1>&2 - fi + [ $? -eq 0 ] || echo "Error encountered. Check for errors in last log file." 1>&2 exit $? ) clean_build ( ) ( pprint 2 "Clean and create object directory (${MAKEOBJDIRPREFIX})" - if ! nano_rm -rf ${MAKEOBJDIRPREFIX}/ > /dev/null 2>&1 ; then + if ! rm -rf ${MAKEOBJDIRPREFIX}/ > /dev/null 2>&1 ; then chflags -R noschg ${MAKEOBJDIRPREFIX}/ - nano_rm -r ${MAKEOBJDIRPREFIX}/ + rm -r ${MAKEOBJDIRPREFIX}/ fi ) @@ -315,17 +349,17 @@ build_kernel ( ) ( clean_world ( ) ( if [ "${NANO_OBJ}" != "${MAKEOBJDIRPREFIX}" ]; then pprint 2 "Clean and create object directory (${NANO_OBJ})" - if ! nano_rm -rf ${NANO_OBJ}/ > /dev/null 2>&1 ; then + if ! rm -rf ${NANO_OBJ}/ > /dev/null 2>&1 ; then chflags -R noschg ${NANO_OBJ} - nano_rm -r ${NANO_OBJ}/ + rm -r ${NANO_OBJ}/ fi mkdir -p "${NANO_OBJ}" "${NANO_WORLDDIR}" printenv > ${NANO_OBJ}/_.env else pprint 2 "Clean and create world directory (${NANO_WORLDDIR})" - if ! nano_rm -rf "${NANO_WORLDDIR}/" > /dev/null 2>&1 ; then + if ! rm -rf "${NANO_WORLDDIR}/" > /dev/null 2>&1 ; then chflags -R noschg "${NANO_WORLDDIR}" - nano_rm -rf "${NANO_WORLDDIR}/" + rm -rf "${NANO_WORLDDIR}/" fi mkdir -p "${NANO_WORLDDIR}" fi @@ -340,7 +374,7 @@ make_conf_install ( ) ( nano_global_make_env echo "${CONF_WORLD}" echo "${CONF_INSTALL}" - if [ ! -z "${NANO_NOPRIV_BUILD}" ]; then + if [ -n "${NANO_NOPRIV_BUILD}" ]; then echo NO_ROOT=t echo METALOG=${NANO_METALOG} fi @@ -413,6 +447,11 @@ native_xtools ( ) ( ) > ${NANO_OBJ}/_.native_xtools 2>&1 ) +# +# Run the requested set of customization scripts, run after we've +# done an installworld, installed the etc files, installed the kernel +# and tweaked them in the standard way. +# run_customize ( ) ( pprint 2 "run customize scripts" @@ -425,6 +464,10 @@ run_customize ( ) ( done ) +# +# Run any last-minute customization commands after we've had a chance to +# setup nanobsd, prune empty dirs from /usr, etc +# run_late_customize ( ) ( pprint 2 "run late customize scripts" @@ -437,6 +480,33 @@ run_late_customize ( ) ( done ) +# +# Hook called after we run all the late customize commands, but +# before we invoke the disk imager. The nopriv build uses it to +# read in the meta log, apply the changes other parts of nanobsd +# have been recording their actions. It's not anticipated that +# a user's cfg file would override this. +# +fixup_before_diskimage ( ) ( + + # Run the deduplication script that takes the matalog journal and + # combines multiple entries for the same file (see source for + # details). We take the extra step of removing the size keywords. This + # script, and many of the user scripts, copies, appeneds and otherwise + # modifies files in the build, changing their sizes. These actions are + # impossible to trap, so go ahead remove the size= keyword. For this + # narrow use, it doesn't buy us any protection and just gets in the way. + # The dedup tool's output must be sorted due to limitations in awk. + if [ -n "${NANO_METALOG}" ]; then + pprint 2 "Fixing metalog" + cp ${NANO_METALOG} ${NANO_METALOG}.pre + (echo "/set uname=${NANO_DEF_UNAME} gname=${NANO_DEF_GNAME}" && + cat ${NANO_METALOG}.pre) | \ + ${NANO_TOOLS}/mtree-dedup.awk | \ + sed -e 's/ size=[0-9][0-9]*//' | sort > ${NANO_METALOG} + fi +) + setup_nanobsd ( ) ( pprint 2 "configure nanobsd setup" pprint 3 "log: ${NANO_OBJ}/_.dl" @@ -453,7 +523,7 @@ setup_nanobsd ( ) ( cd usr/local/etc find . -print | cpio -dumpl ../../../etc/local cd .. - nano_rm -rf etc + rm -rf etc ln -s ../../etc/local etc ) fi @@ -474,8 +544,7 @@ setup_nanobsd ( ) ( echo "mount -o ro /dev/${NANO_DRIVE}${NANO_SLICE_CFG}" > conf/default/etc/remount # Put /tmp on the /var ramdisk (could be symlink already) - nano_rm -rf tmp - ln -s var/tmp tmp + tgt_dir2symlink tmp var/tmp ) > ${NANO_OBJ}/_.dl 2>&1 ) @@ -489,10 +558,14 @@ setup_nanobsd_etc ( ) ( # create diskless marker file touch etc/diskless + [ -n "${NANO_NOPRIV_BUILD}" ] && chmod 666 etc/defaults/rc.conf + # Make root filesystem R/O by default - [ ! -z "${NANO_NOPRIV_BUILD}" ] && chmod 666 etc/defaults/rc.conf echo "root_rw_mount=NO" >> etc/defaults/rc.conf - [ ! -z "${NANO_NOPRIV_BUILD}" ] && chmod 444 etc/defaults/rc.conf + # Disable entropy file, since / is read-only /var/db/entropy should be enough? + echo "entropy_file=NO" >> etc/defaults/rc.conf + + [ -n "${NANO_NOPRIV_BUILD}" ] && chmod 444 etc/defaults/rc.conf # save config file for scripts echo "NANO_DRIVE=${NANO_DRIVE}" > etc/nanobsd.conf @@ -636,7 +709,7 @@ create_diskimage ( ) ( -y ${NANO_HEADS}` else echo "Creating md backing file..." - nano_rm -f ${IMG} + rm -f ${IMG} dd if=/dev/zero of=${IMG} seek=${NANO_MEDIASIZE} count=0 MD=`mdconfig -a -t vnode -f ${IMG} -x ${NANO_SECTS} \ -y ${NANO_HEADS}` @@ -678,7 +751,7 @@ create_diskimage ( ) ( nano_umount ${MNT} # Override the label from the first partition so we # don't confuse glabel with duplicates. - if [ ! -z ${NANO_LABEL} ]; then + if [ -n "${NANO_LABEL}" ]; then tunefs -L ${NANO_LABEL}"${NANO_SLICE_ALTROOT}a" /dev/${MD}${NANO_SLICE_ALTROOT}a fi fi @@ -687,12 +760,12 @@ create_diskimage ( ) ( populate_cfg_slice /dev/${MD}${NANO_SLICE_CFG} "${NANO_CFGDIR}" ${MNT} "${NANO_SLICE_CFG}" # Create Data slice, if any. - if [ ! -z $NANO_SLICE_DATA -a $NANO_SLICE_CFG = $NANO_SLICE_DATA -a \ - $NANO_DATASIZE -ne 0 ]; then + if [ -n "$NANO_SLICE_DATA" -a "$NANO_SLICE_CFG" = "$NANO_SLICE_DATA" -a \ + "$NANO_DATASIZE" -ne 0 ]; then pprint 2 "NANO_SLICE_DATA is the same as NANO_SLICE_CFG, fix." exit 2 fi - if [ $NANO_DATASIZE -ne 0 -a ! -z $NANO_SLICE_DATA ] ; then + if [ $NANO_DATASIZE -ne 0 -a -n "$NANO_SLICE_DATA" ] ; then populate_data_slice /dev/${MD}${NANO_SLICE_DATA} "${NANO_DATADIR}" ${MNT} "${NANO_SLICE_DATA}" fi @@ -853,7 +926,7 @@ cust_pkgng ( ) ( echo "FAILED: pkg bootstrapping faied" exit 2 fi - nano_rm -f ${NANO_WORLDDIR}/Pkg/pkg-* + rm -f ${NANO_WORLDDIR}/Pkg/pkg-* # Count & report how many we have to install todo=`ls ${NANO_WORLDDIR}/Pkg | /usr/bin/wc -l` @@ -882,7 +955,7 @@ cust_pkgng ( ) ( exit 2 fi done - nano_rm -rf ${NANO_WORLDDIR}/Pkg + rm -rf ${NANO_WORLDDIR}/Pkg ) ####################################################################### @@ -949,21 +1022,21 @@ export_var ( ) { # Don't wawnt a subshell # Call this function to set defaults _after_ parsing options. # dont want a subshell otherwise variable setting is thrown away. set_defaults_and_export ( ) { - test -n "${NANO_OBJ}" || NANO_OBJ=/usr/obj/nanobsd.${NANO_NAME} - test -n "${MAKEOBJDIRPREFIX}" || MAKEOBJDIRPREFIX=${NANO_OBJ} - test -n "${NANO_DISKIMGDIR}" || NANO_DISKIMGDIR=${NANO_OBJ} + : ${NANO_OBJ:=/usr/obj/nanobsd.${NANO_NAME}} + : ${MAKEOBJDIRPREFIX:=${NANO_OBJ}} + : ${NANO_DISKIMGDIR=:${NANO_OBJ}} NANO_WORLDDIR=${NANO_OBJ}/_.w NANO_MAKE_CONF_BUILD=${MAKEOBJDIRPREFIX}/make.conf.build NANO_MAKE_CONF_INSTALL=${NANO_OBJ}/make.conf.install # Override user's NANO_DRIVE if they specified a NANO_LABEL - [ ! -z "${NANO_LABEL}" ] && NANO_DRIVE="ufs/${NANO_LABEL}" || true + [ -n "${NANO_LABEL}" ] && NANO_DRIVE="ufs/${NANO_LABEL}" || true # Set a default NANO_TOOLS to NANO_SRC/NANO_TOOLS if it exists. [ ! -d "${NANO_TOOLS}" ] && [ -d "${NANO_SRC}/${NANO_TOOLS}" ] && \ NANO_TOOLS="${NANO_SRC}/${NANO_TOOLS}" || true - [ ! -z "${NANO_NOPRIV_BUILD}" ] && [ -z "${NANO_METALOG}" ] && \ + [ -n "${NANO_NOPRIV_BUILD}" ] && [ -z "${NANO_METALOG}" ] && \ NANO_METALOG=${NANO_OBJ}/_.metalog || true NANO_STARTTIME=`date +%s` diff --git a/tools/tools/nanobsd/embedded/README b/tools/tools/nanobsd/embedded/README index 7be7978..e8b1c8c 100644 --- a/tools/tools/nanobsd/embedded/README +++ b/tools/tools/nanobsd/embedded/README @@ -12,3 +12,40 @@ This is a work in progress. Generally, to build this you should sudo sh ../nanobsd.sh -c foo.cfg but do be careful if things are interrupted. There may still be bugs lurking that cause your entire FreeBSD tree to disappear. + +Some features: + +Image size is minimal, we grow the last partition on first boot to +fill the media. + +Images are both as easy as possible to construct, as well as easy as +possible to expand. + +Config Short description +beaglebone.cfg Create a bootable beaglebone image +qemu-amd64.cfg Create a bootable amd64 image for qemu (W) +qemu-i386.cfg Create a bootable i386 image for qemu (W) +qemu-mips.cfg Create a bootable mips malta board image for + qemu +qemu-mips64.cfg Create a bootable mips malta board (64-bit + mode) image for qemu +qemu-powerpc.cfg Create a bootable 32-bit powerpc image for + qemu +qemu-powerpc64.cfg Create a bootable 64-bit IBM-flavor image for + qemu +qemu-sparc64.cfg Create a bootable sparc64 image for qemu +rpi.cfg Create a bootable image for Raspberry Pi B +rpi2.cfg Create a bootable image for Raspberry Pi2 +sam9260ek.cfg Create a bootable image for an Atmel SAM9260-EK + evaluation board (still needs a kenrel loaded + into dataflash or NAND, so experimental). +sam9g20ek.cfg Create a bootable image for an Atmel SAM9G20-EK + evaluation board (still needs a kenrel loaded + into dataflash or NAND, so experimental). Also + works on many after-market boards that are somewhat + compatible with the refernce board. + +QEMU command lines for serial console access + +i386: qemu-system-i386 -m 512 -hda _.disk.image.qemu-i386.qcow2 -nographic +amd64: qemu-system-amd64 -m 512 -hda _.disk.image.qemu-amd64.qcow2 -nographic diff --git a/tools/tools/nanobsd/embedded/beaglebone.cfg b/tools/tools/nanobsd/embedded/beaglebone.cfg index 3f28feb..8defe5e 100644 --- a/tools/tools/nanobsd/embedded/beaglebone.cfg +++ b/tools/tools/nanobsd/embedded/beaglebone.cfg @@ -25,12 +25,6 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# This file is heavily derived from both Sam Leffler's Avilia config, -# as well as the BSDRP project's config file. Neither of these have -# an explicit copyright/license statement, but are implicitly BSDL. This -# example has been taken from the FreeNAS project and simplified to meet -# the needs of the example. -# NANO_ARCH=armv6 NANO_KERNEL=BEAGLEBONE diff --git a/tools/tools/nanobsd/embedded/common b/tools/tools/nanobsd/embedded/common index a4635f0..c0bbae9 100644 --- a/tools/tools/nanobsd/embedded/common +++ b/tools/tools/nanobsd/embedded/common @@ -73,26 +73,6 @@ if [ -z $NANO_NAME ]; then echo "NANO_NAME not defined. Use foo.cfg instead." fi -# Slice 1: FAT for ROM loading bootstrap -# Slice 2: Config partition -# Slice 3: FreeBSD partition (sized exactly) -# Slice 4: FreeBSD partition (empty) -# on first boot, we resize slice 3 & 4 to be 1/2 of what's -# left over on the SD card after slice 1 and 2 are taken -# off the top. We also resize the 'a' partion on first boot -# to the size of the partition for the ping/pong upgrade. -if [ -z "$EMBED_OMIT_FAT" ]; then - NANO_SLICE_FAT=s1 - NANO_SLICE_CFG=s2 - NANO_SLICE_ROOT=s3 - NANO_SLICE_ALTROOT=s4 -else - NANO_SLICE_CFG=s1 - NANO_SLICE_ROOT=s2 - NANO_SLICE_ALTROOT=s3 -fi -NANO_SLICE_DATA= # Not included - NANO_SLICE_FAT_SIZE=32m NANO_SLICE_CFG_SIZE=32m @@ -138,16 +118,6 @@ cust_install_machine_files() customize_cmd cust_install_files customize_cmd cust_install_machine_files -buildenv() -{ - cd ${NANO_SRC} - env __MAKE_CONF=${NANO_MAKE_CONF_BUILD} DESTDIR=${NANO_WORLDDIR} make buildenv -} - -NANO_MAKEFS="makefs -B big \ - -o bsize=4096,fsize=512,density=8192,optimization=space" -export NANO_MAKEFS - # NB: leave c++ enabled so devd can be built CONF_BUILD=" WITHOUT_ACPI=true @@ -184,6 +154,7 @@ WITHOUT_SENDMAIL=true WITHOUT_SHAREDOCS=true WITHOUT_SYSCONS=true WITHOUT_LIB32=true +WITHOUT_TESTS=true " CONF_INSTALL="$CONF_BUILD INSTALL_NODEBUG=t @@ -305,61 +276,93 @@ add_port () { fi } -create_diskimage ( ) ( - local extra +# Creates images for all the formats that use MBR +create_diskimage_mbr ( ) ( pprint 2 "build diskimage ${NANO_NAME}" pprint 3 "log: ${NANO_OBJ}/_.di" ( - if [ ! -z ${NANO_NOPRIV_BUILD} ]; then - extra="-F ${NANO_OBJ}/_.metalog" - fi + local extra i sz fmt fmtarg bootmbr bootbsd skiparg + set -o xtrace + + [ -z ${NANO_DISKIMAGE_FORMAT} ] || fmtarg="-f ${NANO_DISKIMAGE_FORMAT}" + [ -z ${NANO_DISKIMAGE_FORMAT} ] || fmt=".${NANO_DISKIMAGE_FORMAT}" + bootmbr=${NANO_BOOT_MBR:+-b ${NANO_BOOT_MBR}} + bootbsd=${NANO_BOOT_BSD:+-b ${NANO_BOOT_BSD}} + skiparg=${NANO_MBR_FIRST_SKIP:+-S ${NANO_MBR_FIRST_SKIP}} for i in s1 s2 s3 s4 empty; do rm -fr ${NANO_OBJ}/_.${i}* done - if [ ! -z "${NANO_SLICE_FAT}" ]; then + # Populate the FAT partition + if [-n "${NANO_SLICE_FAT}" ]; then echo Creating MSDOS partition for kernel - newfs_msdos -C ${NANO_SLICE_FAT_SIZE:-100m} -F 16 -L ${NANO_NAME} \ + newfs_msdos -C ${NANO_SLICE_FAT_SIZE} -F 16 -L ${NANO_NAME} \ ${NANO_OBJ}/_.${NANO_SLICE_FAT} + # Need to copy files from ${NANO_FATDIR} with mtools, or use + # makefs -t msdos once that's supported fi - echo Creating main partition + + # Populate the / partition, and place it into a slice with a + # bsd label + [ -z ${NANO_NOPRIV_BUILD} ] || extra="-F ${NANO_METALOG}" sz=${NANO_SLICE_ROOT_SIZE:+-s ${NANO_SLICE_ROOT_SIZE}} - makefs ${extra} -B little $sz -t ffs ${NANO_OBJ}/_.${NANO_SLICE_ROOT}a "${NANO_WORLDDIR}" + eval "${NANO_MAKEFS_UFS}" ${extra} $sz "${NANO_OBJ}/_.${NANO_SLICE_ROOT}a" \ + "${NANO_WORLDDIR}" + mkimg -s bsd ${bootbsd} -p freebsd-ufs:=${NANO_OBJ}/_.${NANO_SLICE_ROOT}a \ + -o ${NANO_OBJ}/_.${NANO_SLICE_ROOT} + + # Populate the /cfg partition, empty if none given if [ -z "${NANO_CFGDIR}" ]; then echo "Faking cfg dir, it's empty" NANO_CFGDIR=${NANO_OBJ}/_.empty mkdir ${NANO_CFGDIR} fi - echo Creating cfg parittion -# XXX -F cfg-mtree - makefs -B little -t ffs -s ${NANO_SLICE_CFG_SIZE:-100m} \ - ${NANO_OBJ}/_.${NANO_SLICE_CFG} "${NANO_CFGDIR}" + # XXX -F cfg-mtree + eval "${NANO_MAKEFS_UFS}" -s ${NANO_SLICE_CFG_SIZE} \ + "${NANO_OBJ}/_.${NANO_SLICE_CFG}" "${NANO_CFGDIR}" + # data slice not supported since we need the part for FAT for # booting - echo Slicing up the main partition into a full bsd part - mkimg -s bsd -p freebsd-ufs:=${NANO_OBJ}/_.${NANO_SLICE_ROOT}a \ - -o ${NANO_OBJ}/_.${NANO_SLICE_ROOT} - echo Making the whole shooting match - if [ ! -z $NANO_SLICE_FAT ]; then + + # Now shuffle all the slices together into the proper layout + if [ -n "$NANO_SLICE_FAT" ]; then eval $NANO_SLICE_FAT=fat16b fi eval $NANO_SLICE_CFG=freebsd eval $NANO_SLICE_ROOT=freebsd - if [ ! -z "${NANO_SLICE_FAT}" ]; then - mkimg -s mbr -p ${s1}:=${NANO_OBJ}/_.s1 \ + # below depends on https://reviews.freebsd.org/D4403 not yet in the tree + # but there's problems: it marks all partitions as active, so you have to + # boot off parittion 3 or 2 by hand if you're playing around with this WIP + case ${NANO_LAYOUT} in + std-embedded) + mkimg -a 3 ${skiparg} ${fmtarg} ${bootmbr} -s mbr -p ${s1}:=${NANO_OBJ}/_.s1 \ -p ${s2}:=${NANO_OBJ}/_.s2 \ -p ${s3}:=${NANO_OBJ}/_.s3 \ - -o ${NANO_OBJ}/_.disk.image.${NANO_NAME} - else + -o ${NANO_OBJ}/_.disk.image.${NANO_NAME}${fmt} + ;; + std-x86) # s1 is cfg, s2 is /, not sure how to make that # boot (marked as active) with mkimg yet - mkimg -s mbr -p ${s1}:=${NANO_OBJ}/_.s1 \ + mkimg -a 2 ${fmtarg} ${bootmbr} -s mbr -p ${s1}:=${NANO_OBJ}/_.s1 \ -p ${s2}:=${NANO_OBJ}/_.s2 \ - -o ${NANO_OBJ}/_.disk.image.${NANO_NAME} - fi + -o ${NANO_OBJ}/_.disk.image.${NANO_NAME}${fmt} + ;; + powerpc64-ibm) + # A lie to make the boot loader work, it boots the first BSD partition + # it finds, regardless of the active flag. + s2=fat16b + # boot image is on a special partition, ala std-embedded, but that + # partition isn't FAT with special files, but a copy of the boot + # loader itself. + mkimg ${fmtarg} -s mbr -p ppcboot:=${NANO_WORLDDIR}/boot/boot1.elf \ + -p ${s2}:=${NANO_OBJ}/_.s2 \ + -p ${s3}:=${NANO_OBJ}/_.s3 \ + -o ${NANO_OBJ}/_.disk.image.${NANO_NAME}${fmt} + ;; + esac ) > ${NANO_OBJ}/_.di 2>&1 ) @@ -371,7 +374,9 @@ die() # Automatically include the packaging port here so it is always first so it # builds the port and adds the package so we can add other packages. -#XXX Not sure this works for cross build, so punting for the moment +#XXX Doesn't work for cross build, so punting until I can integreate qemu-static +#XXX or poudere, both of which require priv'd execution. Or qemu-system, which +#XXX is super, super slow. #add_port ports-mgmt/pkg #add_port security/sudo #add_port ftp/curl @@ -383,8 +388,6 @@ if [ -n "$__a" ]; then umount $__a fi -NANO_BOOTLOADER="boot/boot0" - if [ "$DEBUG" = 1 ]; then DEBUG_BUILD=" DEBUG_FLAGS= -g @@ -421,15 +424,6 @@ $var=$val" fi done -hack_nsswitch_conf ( ) -{ - # Remove all references to NIS in the nsswitch.conf file - # Not sure this is still needed, but FreeNAS has it... - sed -i.bak -es/nis/files/g ${NANO_WORLDDIR}/etc/nsswitch.conf - rm -f ${NANO_WORLDDIR}/etc/nsswitch.conf.bak -} -customize_cmd hack_nsswitch_conf - save_build ( ) { VERSION_FILE=${NANO_WORLDDIR}/etc/version @@ -441,12 +435,6 @@ save_build ( ) } customize_cmd save_build -remove_patch_divots ( ) -{ - find ${NANO_WORLDDIR} -name \*.orig -or -name \*.rej -delete -} -customize_cmd remove_patch_divots - shrink_md_fbsize() { # We have a lot of little files on our memory disks. Let's decrease @@ -459,21 +447,11 @@ shrink_md_fbsize() } customize_cmd shrink_md_fbsize -if [ "${DEBUG}" = 1 ]; then - -unmute_console_logging() -{ - # /var is small. Don't fill it up with messages from console.log - # because it's a chatty log. - sed -i '' -e 's/#console.info/console.info/' \ - "${NANO_WORLDDIR}/etc/syslog.conf" -} -customize_cmd unmute_console_logging - -fi +customize_cmd cust_comconsole product_custom() { + # not quie ready to tweak these in nopriv build if [ -z ${NANO_NOPRIV_BUILD} ]; then # Last second tweaks -- generally not needed chown -R root:wheel ${NANO_WORLDDIR}/root @@ -483,85 +461,133 @@ product_custom() chown -R root:wheel ${NANO_WORLDDIR}/boot chown root:wheel ${NANO_WORLDDIR}/ chown root:wheel ${NANO_WORLDDIR}/usr - else - # Construct an mtree after our messing around with the tree - # Trim out all the uid / gid stuff, since for new files it - # is likely wrong, and for other files it doesn't matter. - mtree -p ${NANO_WORLDDIR} -c | \ - mtree -C | \ - sed -e 's/ uid=[0-9][0-9]* / /g;s/ gid=[0-9][0-9]* / /' \ - > ${NANO_OBJ}/_.mtree.post - - # Sort the metalog, and save the original. Sadly, this - # seems to expand the uname= and gname= to uid= and gid= - # which is lame and likely a bug in mtree. The man page - # is just vague enough to be infuriating as to the proper - # behavior. Happily, it removes all the // that can confound - # things. - mtree -C -S -f ${NANO_OBJ}/_.metalog > ${NANO_OBJ}/_.mtree.pre - mv ${NANO_OBJ}/_.metalog ${NANO_OBJ}/_.metalog.install - - # mtree -f -f produces a comm-like output. The first column will - # be the files we deleted, so we ignore it. The second column is - # the same in both, so we pass it through. The third column is - # listed twice, so we ignore the second one. We also trim out - # the size, because size just doesn't matter as nanobsd and - # customizations often tweak files changing their size. We also - # add 'optional' to every file in case something slipped through - # that's gone from the tree, though maybe that's a real bug. - # - # To make matters worse, currently mtree in freebsd uses the - # old 'file' keyword rather than the newer type=file. Ditto - # dir and link. Also, nlinks is output, which is lame. And - # there's a bloatload of extra flags=none, which I remove too. - # - # Even worse is that all the uid / gid stuff is also tossed - # into the scrap heap. Hope they weren't important. - # - # And somewhere along the way, flags seem to have gone missing. - # - # Oh, and we have to add back in ./ to keep makefs happy. - # - # And then we have to sort the damn hing so directories come - # before subdirectories - # - # Note: For reasons unknown, all the directories are changing - # from 755 to 775, so that's why we ignore the second line. - # We also get repeats for all the files whose size changed. - # Perhaps we should filter those going into the pre/post files - # and not here. - mtree -f ${NANO_OBJ}/_.mtree.pre -f ${NANO_OBJ}/_.mtree.post | \ - awk ' - function frob_bogus_mtree_line(old) { - line = "./" old " gid=0 uid=0" - # XXX make this a damn function - sub(/^\.\/\./, ".", line); - sub(/ file /, " type=file ", line); - sub(/ dir /, " type=dir ", line); - sub(/ link /, " type=link ", line); - sub(/ size=[0-9][0-9]*/, "", line); - sub(/ nlinks=[0-9][0-9]*/, "", line); - sub(/ flags=none*/, "", line); - return line; - } - BEGIN { - x = 0; - FS="\t"; - print "#mtree 2.0"; - } - $1 != "" {} - $2 != "" { - print frob_bogus_mtree_line($2); - } - $3 != "" { - if (x == 0) { - print frob_bogus_mtree_line($3); - x = 1; - } else { - x = 0; - } - } - ' | sort > ${NANO_OBJ}/_.metalog fi } late_customize_cmd product_custom + +# +# Convenience routines to bring up many settings for standard environments +# + +# +# For each architecture, we have a standard set of settings to the extent +# it makes sense. For architectures that don't have a standard environment +# cfg files need to either define a lot of settings, provide their own disk +# imaging, or set which of the variants we support. +# + +std_aarch64 ( ) { +} + +std_amd64 ( ) { + std_i386 +} + +std_arm ( ) { +} + +std_armeb ( ) { + NANO_ENDIAN=big +} + +std_armv6 ( ) { +} + +std_i386 ( ) { + # Default values, if not overridden in .cfg file + : ${NANO_KERNEL:=GENERIC} + : ${NANO_DRIVE:=ada0} + : ${NANO_LAYOUT:=std-x86} + : ${NANO_BOOT_MBR:=${NANO_WORLDDIR}/boot/boot0sio} + : ${NANO_BOOT_BSD:=${NANO_WORLDDIR}/boot/boot} +} + +std_mips ( ) { + NANO_ENDIAN=big +} + +std_mipsel ( ) { +} + +std_mips64 ( ) { + NANO_ENDIAN=big +} + +std_mips64el ( ) { +} + +std_powerpc ( ) { + NANO_ENDIAN=big +} + +std_powerpc64 ( ) { + NANO_LAYOUT=powerpc64-ibm + NANO_ENDIAN=big +} + +std_sparc64 ( ) { + NANO_ENDIAN=big +} + +# +# QEMU settings for the standard environments +# +qemu_env ( ) { + + NANO_DISKIMAGE_FORMAT=qcow2 +} + +# other standard environments will go here + +eval std_${NANO_ARCH} + +# Slice 1: FAT for ROM loading bootstrap +# Slice 2: Config partition +# Slice 3: FreeBSD partition (sized exactly) +# Slice 4: FreeBSD partition (empty) +# on first boot, we resize slice 3 & 4 to be 1/2 of what's +# left over on the SD card after slice 1 and 2 are taken +# off the top. We also resize the 'a' partion on first boot +# to the size of the partition for the ping/pong upgrade. +# This feature needs support in the rc.d bootup script. + +: ${NANO_ENDIAN:=little} # make -V something to figure it out? +: ${NANO_LAYOUT:=std-embedded} +: ${NANO_MAKEFS_UFS:=makefs -t ffs -B ${NANO_ENDIAN}} +: ${NANO_DISK_SCHEME:=mbr} # No others really supported ATM +case ${NANO_LAYOUT} in +std-embedded) + NANO_SLICE_FAT=s1 + NANO_SLICE_CFG=s2 + NANO_SLICE_ROOT=s3 + NANO_SLICE_ALTROOT=s4 + ;; +std-x86) + NANO_SLICE_CFG=s1 + NANO_SLICE_ROOT=s2 + NANO_SLICE_ALTROOT=s3 + ;; +powerpc64-ibm) + NANO_SLICE_PPCBOOT=s1 + NANO_SLICE_CFG=s2 + NANO_SLICE_ROOT=s3 + NANO_SLICE_ALTROOT=s4 + ;; +powerpc64-apple) + echo Not yet + exit 1 + ;; +*) + echo Unknown Layout ${NANO_LAYOUT} + exit 1 + ;; +esac + +NANO_SLICE_DATA= # Not included + +# Each major disk scheme has its own routine. Generally +# this is for mbr, gpt, etc. These are generally are widely +# shared, but some specialized formats won't be shared. +create_diskimage ( ) ( + eval create_diskimage_${NANO_DISK_SCHEME} +) diff --git a/tools/tools/nanobsd/embedded/qemu-amd64.cfg b/tools/tools/nanobsd/embedded/qemu-amd64.cfg index 5ca6837..c405f04 100644 --- a/tools/tools/nanobsd/embedded/qemu-amd64.cfg +++ b/tools/tools/nanobsd/embedded/qemu-amd64.cfg @@ -25,18 +25,10 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# This file is heavily derived from both Sam Leffler's Avilia config, -# as well as the BSDRP project's config file. Neither of these have -# an explicit copyright/license statement, but are implicitly BSDL. This -# example has been taken from the FreeNAS project and simplified to meet -# the needs of the example. -# NANO_ARCH=amd64 -NANO_KERNEL=GENERIC -NANO_DRIVE=ada0 NANO_NAME=qemu-amd64 -export EMBED_OMIT_FAT=t +qemu_env . common # Pull in common definitions, keep last diff --git a/tools/tools/nanobsd/embedded/qemu-i386.cfg b/tools/tools/nanobsd/embedded/qemu-i386.cfg index 856f61f..642f19a 100644 --- a/tools/tools/nanobsd/embedded/qemu-i386.cfg +++ b/tools/tools/nanobsd/embedded/qemu-i386.cfg @@ -25,18 +25,10 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# This file is heavily derived from both Sam Leffler's Avilia config, -# as well as the BSDRP project's config file. Neither of these have -# an explicit copyright/license statement, but are implicitly BSDL. This -# example has been taken from the FreeNAS project and simplified to meet -# the needs of the example. -# NANO_ARCH=i386 -NANO_KERNEL=GENERIC -NANO_DRIVE=ada0 NANO_NAME=qemu-i386 -export EMBED_OMIT_FAT=t +qemu_env . common # Pull in common definitions, keep last diff --git a/tools/tools/nanobsd/embedded/qemu-mips.cfg b/tools/tools/nanobsd/embedded/qemu-mips.cfg index 9b9581d..1582fdf 100644 --- a/tools/tools/nanobsd/embedded/qemu-mips.cfg +++ b/tools/tools/nanobsd/embedded/qemu-mips.cfg @@ -25,18 +25,12 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# This file is heavily derived from both Sam Leffler's Avilia config, -# as well as the BSDRP project's config file. Neither of these have -# an explicit copyright/license statement, but are implicitly BSDL. This -# example has been taken from the FreeNAS project and simplified to meet -# the needs of the example. -# NANO_ARCH=mips NANO_KERNEL=MALTA NANO_DRIVE=ada0 NANO_NAME=qemu-mips -export EMBED_OMIT_FAT=t +qemu_env . common # Pull in common definitions, keep last diff --git a/tools/tools/nanobsd/embedded/qemu-mips64.cfg b/tools/tools/nanobsd/embedded/qemu-mips64.cfg index 9ac22cd..a6ad39e 100644 --- a/tools/tools/nanobsd/embedded/qemu-mips64.cfg +++ b/tools/tools/nanobsd/embedded/qemu-mips64.cfg @@ -25,18 +25,12 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# This file is heavily derived from both Sam Leffler's Avilia config, -# as well as the BSDRP project's config file. Neither of these have -# an explicit copyright/license statement, but are implicitly BSDL. This -# example has been taken from the FreeNAS project and simplified to meet -# the needs of the example. -# NANO_ARCH=mips NANO_KERNEL=MALTA64 NANO_DRIVE=ada0 NANO_NAME=qemu-mips64 -export EMBED_OMIT_FAT=t +qemu_env . common # Pull in common definitions, keep last diff --git a/tools/tools/nanobsd/embedded/qemu-powerpc.cfg b/tools/tools/nanobsd/embedded/qemu-powerpc.cfg index 8c588b1..ac1efa1 100644 --- a/tools/tools/nanobsd/embedded/qemu-powerpc.cfg +++ b/tools/tools/nanobsd/embedded/qemu-powerpc.cfg @@ -25,12 +25,6 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# This file is heavily derived from both Sam Leffler's Avilia config, -# as well as the BSDRP project's config file. Neither of these have -# an explicit copyright/license statement, but are implicitly BSDL. This -# example has been taken from the FreeNAS project and simplified to meet -# the needs of the example. -# # Open question: do we have one for MAC G4 and one for Book-E? NANO_ARCH=powerpc @@ -38,6 +32,6 @@ NANO_KERNEL=GENERIC NANO_DRIVE=ada0 NANO_NAME=qemu-powerpc -export EMBED_OMIT_FAT=t +qemu_env . common # Pull in common definitions, keep last diff --git a/tools/tools/nanobsd/embedded/qemu-powerpc64.cfg b/tools/tools/nanobsd/embedded/qemu-powerpc64.cfg index 1563472..00f177a 100644 --- a/tools/tools/nanobsd/embedded/qemu-powerpc64.cfg +++ b/tools/tools/nanobsd/embedded/qemu-powerpc64.cfg @@ -25,18 +25,12 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# This file is heavily derived from both Sam Leffler's Avilia config, -# as well as the BSDRP project's config file. Neither of these have -# an explicit copyright/license statement, but are implicitly BSDL. This -# example has been taken from the FreeNAS project and simplified to meet -# the needs of the example. -# NANO_ARCH=powerpc64 NANO_KERNEL=GENERIC64 NANO_DRIVE=ada0 NANO_NAME=qemu-powerpc64 -export EMBED_OMIT_FAT=t +qemu_env . common # Pull in common definitions, keep last diff --git a/tools/tools/nanobsd/embedded/qemu-sparc64.cfg b/tools/tools/nanobsd/embedded/qemu-sparc64.cfg index 656fcef..d497dd4 100644 --- a/tools/tools/nanobsd/embedded/qemu-sparc64.cfg +++ b/tools/tools/nanobsd/embedded/qemu-sparc64.cfg @@ -25,18 +25,12 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# This file is heavily derived from both Sam Leffler's Avilia config, -# as well as the BSDRP project's config file. Neither of these have -# an explicit copyright/license statement, but are implicitly BSDL. This -# example has been taken from the FreeNAS project and simplified to meet -# the needs of the example. -# NANO_ARCH=sparc64 NANO_KERNEL=GENERIC NANO_DRIVE=ada0 NANO_NAME=qemu-sparc64 -export EMBED_OMIT_FAT=t +qemu_env . common # Pull in common definitions, keep last diff --git a/tools/tools/nanobsd/embedded/rpi.cfg b/tools/tools/nanobsd/embedded/rpi.cfg index 598de19..25304e4 100644 --- a/tools/tools/nanobsd/embedded/rpi.cfg +++ b/tools/tools/nanobsd/embedded/rpi.cfg @@ -25,12 +25,6 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# This file is heavily derived from both Sam Leffler's Avilia config, -# as well as the BSDRP project's config file. Neither of these have -# an explicit copyright/license statement, but are implicitly BSDL. This -# example has been taken from the FreeNAS project and simplified to meet -# the needs of the example. -# NANO_ARCH=armv6 NANO_KERNEL=RPI-B diff --git a/tools/tools/nanobsd/embedded/rpi2.cfg b/tools/tools/nanobsd/embedded/rpi2.cfg index 043874c..8415e35 100644 --- a/tools/tools/nanobsd/embedded/rpi2.cfg +++ b/tools/tools/nanobsd/embedded/rpi2.cfg @@ -25,12 +25,6 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# This file is heavily derived from both Sam Leffler's Avilia config, -# as well as the BSDRP project's config file. Neither of these have -# an explicit copyright/license statement, but are implicitly BSDL. This -# example has been taken from the FreeNAS project and simplified to meet -# the needs of the example. -# NANO_ARCH=armv6 NANO_KERNEL=RPI2 diff --git a/tools/tools/nanobsd/embedded/sam9260ek.cfg b/tools/tools/nanobsd/embedded/sam9260ek.cfg index fec892a..50bbf1d 100644 --- a/tools/tools/nanobsd/embedded/sam9260ek.cfg +++ b/tools/tools/nanobsd/embedded/sam9260ek.cfg @@ -25,12 +25,6 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# This file is heavily derived from both Sam Leffler's Avilia config, -# as well as the BSDRP project's config file. Neither of these have -# an explicit copyright/license statement, but are implicitly BSDL. This -# example has been taken from the FreeNAS project and simplified to meet -# the needs of the example. -# NANO_ARCH=arm NANO_KERNEL=SAM9260EK diff --git a/tools/tools/nanobsd/embedded/sam9g20ek.cfg b/tools/tools/nanobsd/embedded/sam9g20ek.cfg index 8fe67d4..6964e3f 100644 --- a/tools/tools/nanobsd/embedded/sam9g20ek.cfg +++ b/tools/tools/nanobsd/embedded/sam9g20ek.cfg @@ -25,12 +25,6 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# This file is heavily derived from both Sam Leffler's Avilia config, -# as well as the BSDRP project's config file. Neither of these have -# an explicit copyright/license statement, but are implicitly BSDL. This -# example has been taken from the FreeNAS project and simplified to meet -# the needs of the example. -# NANO_ARCH=arm NANO_KERNEL=SAM9G20EK diff --git a/tools/tools/nanobsd/mtree-dedup.awk b/tools/tools/nanobsd/mtree-dedup.awk index 17aa5e2..ca0f186 100755 --- a/tools/tools/nanobsd/mtree-dedup.awk +++ b/tools/tools/nanobsd/mtree-dedup.awk @@ -178,6 +178,8 @@ BEGIN { nv = "___NO__VALUE___"; while ((getline < "/dev/stdin") > 0) { + if ($1 ~ "^#") + continue; if ($1 == "/set") { for (i = 2; i <= NF; i++) { kv($i); @@ -192,6 +194,9 @@ BEGIN { process_line($1, $0); } + # Print the last set of defaults. This will carry + # over, I think, to makefs' defaults + print mtree_from_kvs("/set", defaults) for (x in tree) print tree[x]; } diff --git a/tools/tools/nanobsd/nanobsd.sh b/tools/tools/nanobsd/nanobsd.sh index 776b246..a17db7a 100755 --- a/tools/tools/nanobsd/nanobsd.sh +++ b/tools/tools/nanobsd/nanobsd.sh @@ -178,6 +178,7 @@ run_customize setup_nanobsd prune_usr run_late_customize +fixup_before_diskimage if $do_image ; then create_diskimage else diff --git a/usr.bin/bmake/Makefile b/usr.bin/bmake/Makefile index e12072d..59c2a6a 100644 --- a/usr.bin/bmake/Makefile +++ b/usr.bin/bmake/Makefile @@ -14,10 +14,10 @@ CFLAGS+= -I${.CURDIR} CLEANDIRS+= FreeBSD CLEANFILES+= bootstrap -# $Id: Makefile,v 1.44 2015/10/20 21:41:40 sjg Exp $ +# $Id: Makefile,v 1.48 2015/12/02 00:36:42 sjg Exp $ # Base version on src date -MAKE_VERSION= 20151020 +MAKE_VERSION= 20151201 PROG?= ${.CURDIR:T} diff --git a/usr.bin/bmake/config.h b/usr.bin/bmake/config.h index 0e4e32d..6119dcf 100644 --- a/usr.bin/bmake/config.h +++ b/usr.bin/bmake/config.h @@ -61,6 +61,12 @@ /* Define to 1 if you have the `killpg' function. */ #define HAVE_KILLPG 1 +/* Define to 1 if you have the <libgen.h> header file. */ +#define HAVE_LIBGEN_H 1 + +/* Define to 1 if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + /* Define to 1 if you have the <memory.h> header file. */ #define HAVE_MEMORY_H 1 @@ -160,6 +166,9 @@ */ /* #undef HAVE_SYS_NDIR_H */ +/* Define to 1 if you have the <sys/param.h> header file. */ +#define HAVE_SYS_PARAM_H 1 + /* Define to 1 if you have the <sys/select.h> header file. */ #define HAVE_SYS_SELECT_H 1 @@ -236,7 +245,7 @@ #define PACKAGE_NAME "bmake" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "bmake 20140214" +#define PACKAGE_STRING "bmake 20151022" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "bmake" @@ -245,7 +254,7 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "20140214" +#define PACKAGE_VERSION "20151022" /* Define as the return type of signal handlers (`int' or `void'). */ #define RETSIGTYPE void @@ -306,6 +315,11 @@ /* Define to 1 if you need to in order for `stat' and other things to work. */ /* #undef _POSIX_SOURCE */ +/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>, + <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + /* C99 function name */ /* #undef __func__ */ @@ -321,5 +335,9 @@ /* Define to `unsigned int' if <sys/types.h> does not define. */ /* #undef size_t */ +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + /* Define as `fork' if `vfork' does not work. */ /* #undef vfork */ diff --git a/usr.bin/bmake/unit-tests/Makefile b/usr.bin/bmake/unit-tests/Makefile index 100b467..ced3aeb 100644 --- a/usr.bin/bmake/unit-tests/Makefile +++ b/usr.bin/bmake/unit-tests/Makefile @@ -5,7 +5,7 @@ SRCTOP?= ${.CURDIR:H:H:H} -# $Id: Makefile.in,v 1.47 2015/05/05 21:58:06 sjg Exp $ +# $Id: Makefile.in,v 1.48 2015/12/07 04:06:29 sjg Exp $ # # $NetBSD: Makefile,v 1.52 2015/05/05 21:51:09 sjg Exp $ # @@ -135,7 +135,7 @@ SED_CMDS.varshell = -e 's,^[a-z]*sh: ,,' \ test: ${OUTFILES} .PHONY @failed= ; \ for test in ${TESTNAMES}; do \ - ${TOOL_DIFF} -u ${UNIT_TESTS}/$${test}.exp $${test}.out \ + ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \ || failed="$${failed}$${failed:+ }$${test}" ; \ done ; \ if [ -n "$${failed}" ]; then \ diff --git a/usr.bin/clang/lldb/Makefile.depend b/usr.bin/clang/lldb/Makefile.depend index d615d32..ce522d3 100644 --- a/usr.bin/clang/lldb/Makefile.depend +++ b/usr.bin/clang/lldb/Makefile.depend @@ -143,6 +143,7 @@ DIRDEPS = \ lib/libthr \ lib/libz \ lib/msun \ + lib/ncurses/ncurses \ lib/ncurses/ncursesw \ lib/ncurses/panel \ diff --git a/usr.bin/xo/tests/Makefile b/usr.bin/xo/tests/Makefile index ea4916d..f22c005 100644 --- a/usr.bin/xo/tests/Makefile +++ b/usr.bin/xo/tests/Makefile @@ -32,6 +32,7 @@ FILES+= xo_01.XP.err FILES+= xo_01.XP.out SCRIPTS+= xo_01 +CLEANFILES+= xo_01 LIBADD+= xo diff --git a/usr.sbin/ofwdump/Makefile.depend b/usr.sbin/ofwdump/Makefile.depend index 79eb58b..a5da8fd 100644 --- a/usr.sbin/ofwdump/Makefile.depend +++ b/usr.sbin/ofwdump/Makefile.depend @@ -2,11 +2,14 @@ # Autogenerated - do NOT edit! DIRDEPS = \ + gnu/lib/csu \ gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ + lib/libc_nonshared \ + lib/libcompiler_rt \ .include <dirdeps.mk> |