CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Mon Dec 3 06:43:19 UTC 2018 Modified Files: src/bin/sh: eval.c eval.h main.c sh.1 trap.c trap.h Log Message: Cleanup traps a bit - attempt to handle weird uses in traps, such as traps that issue break/continue/return to cause the loop/function executing when the trap occurred to break/continue/return, and generating the correct exit code from the shell including when a signal is caught, but the trap handler for it exits. All that from FreeBSD. Also make T=$(trap) work as it is supposed to (also trap -p). For now this is handled by the same technique as $(jobs) - rather than clearing the traps in subshells, just mark them invalid, and then whenever they're invalid, clear them before executing anything other than the special blessed "trap" command. Eventually we will handle these using non-subshell command substitution instead (not creating a subshell environ when the commands in a command-sub alter nothing in the environment). To generate a diff of this commit: cvs rdiff -u -r1.167 -r1.168 src/bin/sh/eval.c cvs rdiff -u -r1.21 -r1.22 src/bin/sh/eval.h cvs rdiff -u -r1.77 -r1.78 src/bin/sh/main.c cvs rdiff -u -r1.209 -r1.210 src/bin/sh/sh.1 cvs rdiff -u -r1.46 -r1.47 src/bin/sh/trap.c cvs rdiff -u -r1.23 -r1.24 src/bin/sh/trap.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/eval.c diff -u src/bin/sh/eval.c:1.167 src/bin/sh/eval.c:1.168 --- src/bin/sh/eval.c:1.167 Mon Dec 3 06:42:25 2018 +++ src/bin/sh/eval.c Mon Dec 3 06:43:19 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: eval.c,v 1.167 2018/12/03 06:42:25 kre Exp $ */ +/* $NetBSD: eval.c,v 1.168 2018/12/03 06:43:19 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95"; #else -__RCSID("$NetBSD: eval.c,v 1.167 2018/12/03 06:42:25 kre Exp $"); +__RCSID("$NetBSD: eval.c,v 1.168 2018/12/03 06:43:19 kre Exp $"); #endif #endif /* not lint */ @@ -87,8 +87,10 @@ __RCSID("$NetBSD: eval.c,v 1.167 2018/12 #endif -STATIC enum skipstate evalskip; /* != SKIPNONE if we are skipping commands */ -STATIC int skipcount; /* number of levels to skip */ +STATIC struct skipsave s_k_i_p; +#define evalskip (s_k_i_p.state) +#define skipcount (s_k_i_p.count) + STATIC int loopnest; /* current loop nesting level */ STATIC int funcnest; /* depth of function calls */ STATIC int builtin_flags; /* evalcommand flags for builtins */ @@ -278,6 +280,8 @@ evaltree(union node *n, int flags) next = NULL; CTRACE(DBG_EVAL, ("pid %d, evaltree(%p: %s(%d), %#x) called\n", getpid(), n, NODETYPENAME(n->type), n->type, flags)); + if (n->type != NCMD && traps_invalid) + free_traps(); switch (n->type) { case NSEMI: evaltree(n->nbinary.ch1, sflags); @@ -1026,6 +1030,9 @@ evalcommand(union node *cmd, int flgs, s cmdentry.cmdtype = CMDBUILTIN; } + if (traps_invalid && cmdentry.cmdtype != CMDSPLBLTIN) + free_traps(); + /* Fork off a child process if necessary. */ if (cmd->ncmd.backgnd || (have_traps() && (flags & EV_EXIT) != 0) || ((cmdentry.cmdtype == CMDNORMAL || cmdentry.cmdtype == CMDUNKNOWN) @@ -1376,6 +1383,18 @@ current_skipstate(void) } void +save_skipstate(struct skipsave *p) +{ + *p = s_k_i_p; +} + +void +restore_skipstate(const struct skipsave *p) +{ + s_k_i_p = *p; +} + +void stop_skipping(void) { evalskip = SKIPNONE; Index: src/bin/sh/eval.h diff -u src/bin/sh/eval.h:1.21 src/bin/sh/eval.h:1.22 --- src/bin/sh/eval.h:1.21 Sun Aug 19 11:16:13 2018 +++ src/bin/sh/eval.h Mon Dec 3 06:43:19 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: eval.h,v 1.21 2018/08/19 11:16:13 kre Exp $ */ +/* $NetBSD: eval.h,v 1.22 2018/12/03 06:43:19 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -66,7 +66,14 @@ enum skipstate { SKIPFILE /* return in a dot command */ }; +struct skipsave { + enum skipstate state; /* skipping or not */ + int count; /* when break or continue, how many */ +}; + enum skipstate current_skipstate(void); +void save_skipstate(struct skipsave *); +void restore_skipstate(const struct skipsave *); void stop_skipping(void); /* reset internal skipping state to SKIPNONE */ /* Index: src/bin/sh/main.c diff -u src/bin/sh/main.c:1.77 src/bin/sh/main.c:1.78 --- src/bin/sh/main.c:1.77 Mon Dec 3 02:38:30 2018 +++ src/bin/sh/main.c Mon Dec 3 06:43:19 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.77 2018/12/03 02:38:30 kre Exp $ */ +/* $NetBSD: main.c,v 1.78 2018/12/03 06:43:19 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19 #if 0 static char sccsid[] = "@(#)main.c 8.7 (Berkeley) 7/19/95"; #else -__RCSID("$NetBSD: main.c,v 1.77 2018/12/03 02:38:30 kre Exp $"); +__RCSID("$NetBSD: main.c,v 1.78 2018/12/03 06:43:19 kre Exp $"); #endif #endif /* not lint */ @@ -378,7 +378,8 @@ exitcmd(int argc, char **argv) if (stoppedjobs())
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Mon Dec 3 06:42:25 UTC 2018 Modified Files: src/bin/sh: eval.c var.c var.h Log Message: Fix "export -x" (and its consequences) to behave as originally intended (and as documented) rather than how it has been behaving (which was not very rational.) Since it is unlikely that anyone is using this, the change should be mostly invisible. While here, a couple of other minor cleanups: . One call of geteuid() is enough in choose_ps1() . Fix a typo in a comment . Improve appearance (whitspace changes) in find_var() To generate a diff of this commit: cvs rdiff -u -r1.166 -r1.167 src/bin/sh/eval.c cvs rdiff -u -r1.70 -r1.71 src/bin/sh/var.c cvs rdiff -u -r1.36 -r1.37 src/bin/sh/var.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/eval.c diff -u src/bin/sh/eval.c:1.166 src/bin/sh/eval.c:1.167 --- src/bin/sh/eval.c:1.166 Mon Dec 3 06:40:26 2018 +++ src/bin/sh/eval.c Mon Dec 3 06:42:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: eval.c,v 1.166 2018/12/03 06:40:26 kre Exp $ */ +/* $NetBSD: eval.c,v 1.167 2018/12/03 06:42:25 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95"; #else -__RCSID("$NetBSD: eval.c,v 1.166 2018/12/03 06:40:26 kre Exp $"); +__RCSID("$NetBSD: eval.c,v 1.167 2018/12/03 06:42:25 kre Exp $"); #endif #endif /* not lint */ @@ -1085,7 +1085,8 @@ evalcommand(union node *cmd, int flgs, s } savehandler = handler; handler = -listmklocal(varlist.list, VEXPORT | VNOFUNC); +listmklocal(varlist.list, +VDOEXPORT | VEXPORT | VNOFUNC); forkchild(jp, cmd, mode, vforked); break; default: @@ -1189,7 +1190,7 @@ evalcommand(union node *cmd, int flgs, s cmdentry.lineno, cmdentry.lno_frel?" (=1)":"", funclinebase)); } - listmklocal(varlist.list, VEXPORT); + listmklocal(varlist.list, VDOEXPORT | VEXPORT); /* stop shell blowing its stack */ if (++funcnest > 1000) error("too many nested function calls"); @@ -1317,7 +1318,7 @@ evalcommand(union node *cmd, int flgs, s (vforked ? REDIR_VFORK : 0) | REDIR_KEEP); if (!vforked) for (sp = varlist.list ; sp ; sp = sp->next) -setvareq(sp->text, VEXPORT|VSTACK); +setvareq(sp->text, VDOEXPORT|VEXPORT|VSTACK); envp = environment(); shellexec(argv, envp, path, cmdentry.u.index, vforked); break; @@ -1579,7 +1580,7 @@ execcmd(int argc, char **argv) mflag = 0; optschanged(); for (sp = cmdenviron; sp; sp = sp->next) - setvareq(sp->text, VEXPORT|VSTACK); + setvareq(sp->text, VDOEXPORT|VEXPORT|VSTACK); shellexec(argv + 1, environment(), pathval(), 0, 0); } return 0; Index: src/bin/sh/var.c diff -u src/bin/sh/var.c:1.70 src/bin/sh/var.c:1.71 --- src/bin/sh/var.c:1.70 Fri Jul 13 22:43:44 2018 +++ src/bin/sh/var.c Mon Dec 3 06:42:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.70 2018/07/13 22:43:44 kre Exp $ */ +/* $NetBSD: var.c,v 1.71 2018/12/03 06:42:25 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: var.c,v 1.70 2018/07/13 22:43:44 kre Exp $"); +__RCSID("$NetBSD: var.c,v 1.71 2018/12/03 06:42:25 kre Exp $"); #endif #endif /* not lint */ @@ -323,15 +323,17 @@ initvar(void) void choose_ps1(void) { + uid_t u = geteuid(); + if ((vps1.flags & (VTEXTFIXED|VSTACK)) == 0) free(vps1.text); - vps1.text = strdup(geteuid() ? "PS1=$ " : "PS1=# "); + vps1.text = strdup(u != 0 ? "PS1=$ " : "PS1=# "); vps1.flags &= ~(VTEXTFIXED|VSTACK); /* * Update PSc whenever we feel the need to update PS1 */ - setvarsafe("PSc", (geteuid() == 0 ? "#" : "$"), 0); + setvarsafe("PSc", (u == 0 ? "#" : "$"), 0); } /* @@ -480,9 +482,11 @@ setvareq(char *s, int flags) vp->flags &= ~(VTEXTFIXED|VSTACK|VUNSET); if (flags & VNOEXPORT) vp->flags &= ~VEXPORT; + if (flags & VDOEXPORT) + vp->flags &= ~VNOEXPORT; if (vp->flags & VNOEXPORT) flags &= ~VEXPORT; - vp->flags |= flags & ~VNOFUNC; + vp->flags |= flags & ~(VNOFUNC | VDOEXPORT); vp->text = s; /* @@ -495,20 +499,22 @@ setvareq(char *s, int flags) INTON; return; } - VTRACE(DBG_VARS, ("new\n")); /* not found */ if (flags & VNOSET) { + VTRACE(DBG_VARS, ("new noset\n")); if ((flags & (VTEXTFIXED|VSTACK)) == 0) ckfree(s); return; } vp = ckmalloc(sizeof (*vp)); - vp->flags = flags & ~(VNOFUNC|VFUNCREF); + vp->flags = flags & ~(VNOFUNC|VFUNCREF|VDOEXPORT); vp->text = s; vp->name_len = nlen; - vp->next = *vpp; vp->func = NULL; + vp->next = *vpp; *vpp = vp; + + VTRACE(DBG_VARS, ("new [%s] (%d) %#x\n", s, nlen, vp->flags)); } @@ -853,26 +859,32 @@ exportcmd(int argc, char **argv) res = 0; while ((name = *argptr++) != NULL) { + int len; + f = flag; - if ((p = strchr(name, '=')) !=
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Mon Dec 3 06:41:30 UTC 2018 Modified Files: src/bin/sh: expand.c parser.c Log Message: Yet another foray into the mysterious world of $@ -- this time to fix the (unusual) idiom "${1+$@}" (the quotes are part of it). This seems to have broken about 5 or 6 years ago (somewhere between -6 and -7), I believe. Note this is not the same as "$@" and also not the same as ${1+"$@"} (much more common idioms) which both worked. Also attempt to deal with "" more correctly, especially when it appears adjacent to "$@" (or one of the similar constructs.) This stuff is still all as ugly and hackish (and fragile) as is possible to imagine, but in an effort to allow some of the weirdness to eventually go away, the parser output has been made more regular and all quoted (parts of) words always now start with CTLQUOTEMARK and end with CTLQUOTEEND regardless of where the quotes appear. This allows us to tell the difference between """$@" and "$@" which was impossible before - yet they are required to generate different output when there are no args (when "$@" simply vanishes). Needless to say that change had ramifications all over the place. To simplify any similar change in the future, there are some new macros that can generally be used to detect the "noise" data when processing words, rather than open coding that every time (which meant that there would *always* be one which missed getting updated...) Several other bugs (of my making, and older ones) are also fixed. The aim is that (aside from anything that is detecting the cases that were broken before - which were all unlikely uses of sh syntax) these changes should have no external visible impact. Sure... To generate a diff of this commit: cvs rdiff -u -r1.128 -r1.129 src/bin/sh/expand.c cvs rdiff -u -r1.156 -r1.157 src/bin/sh/parser.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/expand.c diff -u src/bin/sh/expand.c:1.128 src/bin/sh/expand.c:1.129 --- src/bin/sh/expand.c:1.128 Sun Nov 18 17:23:37 2018 +++ src/bin/sh/expand.c Mon Dec 3 06:41:30 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: expand.c,v 1.128 2018/11/18 17:23:37 kre Exp $ */ +/* $NetBSD: expand.c,v 1.129 2018/12/03 06:41:30 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95"; #else -__RCSID("$NetBSD: expand.c,v 1.128 2018/11/18 17:23:37 kre Exp $"); +__RCSID("$NetBSD: expand.c,v 1.129 2018/12/03 06:41:30 kre Exp $"); #endif #endif /* not lint */ @@ -127,6 +127,16 @@ STATIC void rmescapes_nl(char *); #define NULLTERM_4_TRACE(p) do { /* nothing */ } while (/*CONSTCOND*/0) #endif +#define IS_BORING(_ch) \ + ((_ch) == CTLQUOTEMARK || (_ch) == CTLQUOTEEND || (_ch) == CTLNONL) +#define SKIP_BORING(p) \ + do { \ + char _ch; \ +\ + while ((_ch = *(p)), IS_BORING(_ch)) \ + (p)++; \ + } while (0) + /* * Expand shell variables and backquotes inside a here document. */ @@ -271,6 +281,8 @@ argstr(const char *p, int flag) STPUTC('\n', expdest); /* no line_number++ */ break; case CTLQUOTEEND: + if ((flag & EXP_SPLIT) != 0) +STPUTC(c, expdest); ifs_split = EXP_IFS_SPLIT; break; case CTLESC: @@ -284,11 +296,13 @@ argstr(const char *p, int flag) case CTLVAR: { #ifdef DEBUG unsigned int pos = expdest - stackblock(); + NULLTERM_4_TRACE(expdest); #endif p = evalvar(p, (flag & ~EXP_IFS_SPLIT) | (flag & ifs_split)); NULLTERM_4_TRACE(expdest); VTRACE(DBG_EXPAND, ("argstr evalvar " - "added \"%s\" to expdest\n", + "added %zd \"%s\" to expdest\n", + (size_t)(expdest - (stackblock() + pos)), stackblock() + pos)); break; } @@ -810,7 +824,7 @@ subevalvar_trim(const char *p, int strlo abort(); } -recordleft: + recordleft: *loc = c; amount = ((str - 1) - (loc - startp)) - expdest; STADJUST(amount, expdest); @@ -818,7 +832,7 @@ recordleft: *startp++ = *loc++; return 1; -recordright: + recordright: amount = loc - expdest; STADJUST(amount, expdest); STPUTC('\0', expdest); @@ -897,6 +911,10 @@ evalvar(const char *p, int flag) } } + if (!set && subtype != VSPLUS && special && *var == '@') + if (startloc > 0 && expdest[-1] == CTLQUOTEMARK) + expdest--, startloc--; + if (set && subtype != VSPLUS) { /* insert the value of the variable */ if (special) { @@ -936,9 +954,7 @@ evalvar(const char *p, int flag) } - if (flag & EXP_IN_QUOTES) - apply_ifs = 0; - else if (varflags & VSQUOTE) { + if (varflags & VSQUOTE) { if (*var == '@' && shellparam.nparam != 1) apply_ifs = 1; else { @@ -949,6 +965,8 @@ evalvar(const char *p, int flag) flag |= EXP_IN_QUOTES; apply_ifs = 0; } + } else if (flag & EXP_IN_QUOTES) { + apply_ifs = 0; } else apply_ifs = 1; @@ -,6 +1129,12 @@ varvalue(const
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Mon Dec 3 06:40:26 UTC 2018 Modified Files: src/bin/sh: alias.c alias.h eval.c input.c parser.c parser.h syntax.c syntax.h Log Message: Revamp aliases - as dumb an idea as they are, if we're going to have them, they should work as documented, not cause core dumps, reference after free, incorrect replacements, failing to implement alias after alias, ... The big comment that ended: This is a good idea --- ***NOT*** and the hack it was describing are gone. Note that most of this was from original CVS version 1.1 code (ie: came from the original import, even before 4.4-Lite was merged. That is, May 1994. And no-one in 24.5 years noticed (or at least complained about) all the bugs (or at least, most of them)). With these changes, aliases ought to work (if you can call it that) as they are expected to by POSIX. Now if only we could get POSIX to delete them (or make them optional)... Changes partly inspired by similar changes made by FreeBSD, (as was the previous change to alias.c, forgot ack in commit log for that one, apologies) but done a little differently, and perhaps with a slightly better outcome. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/bin/sh/alias.c cvs rdiff -u -r1.8 -r1.9 src/bin/sh/alias.h cvs rdiff -u -r1.165 -r1.166 src/bin/sh/eval.c cvs rdiff -u -r1.63 -r1.64 src/bin/sh/input.c cvs rdiff -u -r1.155 -r1.156 src/bin/sh/parser.c cvs rdiff -u -r1.25 -r1.26 src/bin/sh/parser.h cvs rdiff -u -r1.6 -r1.7 src/bin/sh/syntax.c cvs rdiff -u -r1.10 -r1.11 src/bin/sh/syntax.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/alias.c diff -u src/bin/sh/alias.c:1.19 src/bin/sh/alias.c:1.20 --- src/bin/sh/alias.c:1.19 Sun Dec 2 10:27:58 2018 +++ src/bin/sh/alias.c Mon Dec 3 06:40:26 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: alias.c,v 1.19 2018/12/02 10:27:58 kre Exp $ */ +/* $NetBSD: alias.c,v 1.20 2018/12/03 06:40:26 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)alias.c 8.3 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: alias.c,v 1.19 2018/12/02 10:27:58 kre Exp $"); +__RCSID("$NetBSD: alias.c,v 1.20 2018/12/03 06:40:26 kre Exp $"); #endif #endif /* not lint */ @@ -61,7 +61,9 @@ STATIC void setalias(char *, char *); STATIC int by_name(const void *, const void *); STATIC void list_aliases(void); STATIC int unalias(char *); +STATIC struct alias **freealias(struct alias **, int); STATIC struct alias **hashalias(const char *); +STATIC size_t countaliases(void); STATIC void @@ -76,97 +78,80 @@ setalias(char *name, char *val) ap = ckmalloc(sizeof (struct alias)); ap->name = savestr(name); ap->flag = 0; - /* - * XXX - HACK: in order that the parser will not finish reading the - * alias value off the input before processing the next alias, we - * dummy up an extra space at the end of the alias. This is a crock - * and should be re-thought. The idea (if you feel inclined to help) - * is to avoid alias recursions. The mechanism used is: when - * expanding an alias, the value of the alias is pushed back on the - * input as a string and a pointer to the alias is stored with the - * string. The alias is marked as being in use. When the input - * routine finishes reading the string, it markes the alias not - * in use. The problem is synchronization with the parser. Since - * it reads ahead, the alias is marked not in use before the - * resulting token(s) is next checked for further alias sub. The - * H A C K is that we add a little fluff after the alias value - * so that the string will not be exhausted. This is a good - * idea --- ***NOT*** - */ -#ifdef notyet ap->val = savestr(val); -#else /* hack */ - { - int len = strlen(val); - ap->val = ckmalloc(len + 2); - memcpy(ap->val, val, len); - ap->val[len] = ' '; /* fluff */ - ap->val[len+1] = '\0'; - } -#endif ap->next = *app; *app = ap; INTON; } +STATIC struct alias ** +freealias(struct alias **app, int force) +{ + struct alias *ap = *app; + + if (ap == NULL) + return app; + + /* + * if the alias is currently in use (i.e. its + * buffer is being used by the input routine) we + * just null out the name instead of discarding it. + * If we encounter it later, when it is idle, + * we will finish freeing it then. + * + * Unless we want to simply free everything (INIT) + */ + if (ap->flag & ALIASINUSE && !force) { + *ap->name = '\0'; + return >next; + } + + INTOFF; + *app = ap->next; + ckfree(ap->name); + ckfree(ap->val); + ckfree(ap); + INTON; + + return app; +} + STATIC int unalias(char *name) { struct alias *ap, **app; app = hashalias(name); - - for (ap = *app; ap; app = &(ap->next), ap = ap->next) { + while ((ap = *app) != NULL) { if (equal(name, ap->name)) { - /* - * if the alias is currently in use (i.e. its - * buffer is
CVS commit: src/sys/dev/acpi
Module Name:src Committed By: cherry Date: Mon Dec 3 05:22:03 UTC 2018 Modified Files: src/sys/dev/acpi: acpi_mcfg.c Log Message: Define macro before using it. This macro is used as a compile time "plugin" mechanism to use various platform specific enumeration functions. It is currently separately defined for 'native' and XEN, but the mechanism is not exported globally as it should be. XXX: fix this. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/dev/acpi/acpi_mcfg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/acpi_mcfg.c diff -u src/sys/dev/acpi/acpi_mcfg.c:1.13 src/sys/dev/acpi/acpi_mcfg.c:1.14 --- src/sys/dev/acpi/acpi_mcfg.c:1.13 Fri Nov 2 19:51:08 2018 +++ src/sys/dev/acpi/acpi_mcfg.c Mon Dec 3 05:22:03 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_mcfg.c,v 1.13 2018/11/02 19:51:08 jmcneill Exp $ */ +/* $NetBSD: acpi_mcfg.c,v 1.14 2018/12/03 05:22:03 cherry Exp $ */ /*- * Copyright (C) 2015 NONAKA Kimihiro @@ -28,7 +28,7 @@ #include "opt_pci.h" #include -__KERNEL_RCSID(0, "$NetBSD: acpi_mcfg.c,v 1.13 2018/11/02 19:51:08 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_mcfg.c,v 1.14 2018/12/03 05:22:03 cherry Exp $"); #include #include @@ -539,6 +539,10 @@ acpimcfg_device_probe(const struct pci_a return 0; } +#ifdef PCI_MACHDEP_ENUMERATE_BUS +#define pci_enumerate_bus PCI_MACHDEP_ENUMERATE_BUS +#endif + static void acpimcfg_scan_bus(struct pci_softc *sc, pci_chipset_tag_t pc, int bus) {
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Dec 3 04:39:44 UTC 2018 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe.h Log Message: Some counters are not per queue but per traffic class. Make new evcnt group "ixgM tcN" (N = 0..7) and move those counters into it. We are using only traffic class 0, so we will see only tc0's counter are updated. To generate a diff of this commit: cvs rdiff -u -r1.167 -r1.168 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.51 -r1.52 src/sys/dev/pci/ixgbe/ixgbe.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.167 src/sys/dev/pci/ixgbe/ixgbe.c:1.168 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.167 Thu Sep 27 05:40:27 2018 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Dec 3 04:39:44 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.167 2018/09/27 05:40:27 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.168 2018/12/03 04:39:44 msaitoh Exp $ */ /** @@ -1537,6 +1537,7 @@ ixgbe_update_stats_counters(struct adapt u32 missed_rx = 0, bprc, lxon, lxoff, total; u64 total_missed_rx = 0; uint64_t crcerrs, rlec; + int i, j; crcerrs = IXGBE_READ_REG(hw, IXGBE_CRCERRS); stats->crcerrs.ev_count += crcerrs; @@ -1547,8 +1548,8 @@ ixgbe_update_stats_counters(struct adapt stats->mbsdc.ev_count += IXGBE_READ_REG(hw, IXGBE_MBSDC); /* 16 registers */ - for (int i = 0; i < __arraycount(stats->qprc); i++) { - int j = i % adapter->num_queues; + for (i = 0; i < __arraycount(stats->qprc); i++) { + j = i % adapter->num_queues; stats->qprc[j].ev_count += IXGBE_READ_REG(hw, IXGBE_QPRC(i)); stats->qptc[j].ev_count += IXGBE_READ_REG(hw, IXGBE_QPTC(i)); @@ -1559,36 +1560,35 @@ ixgbe_update_stats_counters(struct adapt } /* 8 registers */ - for (int i = 0; i < __arraycount(stats->mpc); i++) { + for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) { uint32_t mp; - int j = i % adapter->num_queues; /* MPC */ mp = IXGBE_READ_REG(hw, IXGBE_MPC(i)); /* global total per queue */ - stats->mpc[j].ev_count += mp; + stats->mpc[i].ev_count += mp; /* running comprehensive total for stats display */ total_missed_rx += mp; if (hw->mac.type == ixgbe_mac_82598EB) - stats->rnbc[j].ev_count + stats->rnbc[i].ev_count += IXGBE_READ_REG(hw, IXGBE_RNBC(i)); - stats->pxontxc[j].ev_count + stats->pxontxc[i].ev_count += IXGBE_READ_REG(hw, IXGBE_PXONTXC(i)); - stats->pxofftxc[j].ev_count + stats->pxofftxc[i].ev_count += IXGBE_READ_REG(hw, IXGBE_PXOFFTXC(i)); if (hw->mac.type >= ixgbe_mac_82599EB) { - stats->pxonrxc[j].ev_count + stats->pxonrxc[i].ev_count += IXGBE_READ_REG(hw, IXGBE_PXONRXCNT(i)); - stats->pxoffrxc[j].ev_count + stats->pxoffrxc[i].ev_count += IXGBE_READ_REG(hw, IXGBE_PXOFFRXCNT(i)); - stats->pxon2offc[j].ev_count + stats->pxon2offc[i].ev_count += IXGBE_READ_REG(hw, IXGBE_PXON2OFFCNT(i)); } else { - stats->pxonrxc[j].ev_count + stats->pxonrxc[i].ev_count += IXGBE_READ_REG(hw, IXGBE_PXONRXC(i)); - stats->pxoffrxc[j].ev_count + stats->pxoffrxc[i].ev_count += IXGBE_READ_REG(hw, IXGBE_PXOFFRXC(i)); } } @@ -1738,6 +1738,43 @@ ixgbe_add_hw_stats(struct adapter *adapt evcnt_attach_dynamic(>phy_sicount, EVCNT_TYPE_INTR, NULL, xname, "external PHY softint"); + /* Max number of traffic class is 8 */ + KASSERT(IXGBE_DCB_MAX_TRAFFIC_CLASS == 8); + for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) { + snprintf(adapter->tcs[i].evnamebuf, + sizeof(adapter->tcs[i].evnamebuf), "%s tc%d", + xname, i); + if (i < __arraycount(stats->mpc)) { + evcnt_attach_dynamic(>mpc[i], + EVCNT_TYPE_MISC, NULL, adapter->tcs[i].evnamebuf, + "RX Missed Packet Count"); + if (hw->mac.type == ixgbe_mac_82598EB) +evcnt_attach_dynamic(>rnbc[i], +EVCNT_TYPE_MISC, NULL, +adapter->tcs[i].evnamebuf, +"Receive No Buffers"); + } + if (i < __arraycount(stats->pxontxc)) { + evcnt_attach_dynamic(>pxontxc[i], + EVCNT_TYPE_MISC, NULL, adapter->tcs[i].evnamebuf, + "pxontxc"); + evcnt_attach_dynamic(>pxonrxc[i], + EVCNT_TYPE_MISC, NULL, adapter->tcs[i].evnamebuf, + "pxonrxc"); + evcnt_attach_dynamic(>pxofftxc[i], + EVCNT_TYPE_MISC, NULL, adapter->tcs[i].evnamebuf, + "pxofftxc"); + evcnt_attach_dynamic(>pxoffrxc[i], + EVCNT_TYPE_MISC, NULL, adapter->tcs[i].evnamebuf, + "pxoffrxc"); + if (hw->mac.type >= ixgbe_mac_82599EB) +evcnt_attach_dynamic(>pxon2offc[i], +EVCNT_TYPE_MISC, NULL, +adapter->tcs[i].evnamebuf, + "pxon2offc"); + } + } + for (i = 0; i < adapter->num_queues; i++, rxr++, txr++) { #ifdef LRO struct lro_ctrl *lro = >lro; @@ -1826,35 +1863,6 @@
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Mon Dec 3 02:38:30 UTC 2018 Modified Files: src/bin/sh: jobs.c main.c main.h Log Message: When forking a child shell, arrange for errors/exit to always unwind to the main handler, rather than wherever the parent shell would go. nb: not needed for vfork(), after vfork() we never go that path - which is good or we'd be corrupting the parent's handler. This allows the child to always exit (when it should) rather than being caught up doing something else (and while it would eventually exit, the status would be incorrect in some cases). One test is: sh -c 'trap "(! :) && echo BUG || echo nobug" EXIT' from Martijn Dekker Fix from FreeBSD (missed earlier). XXX - 2b part of the 48875 pullup to -8 To generate a diff of this commit: cvs rdiff -u -r1.102 -r1.103 src/bin/sh/jobs.c cvs rdiff -u -r1.76 -r1.77 src/bin/sh/main.c cvs rdiff -u -r1.11 -r1.12 src/bin/sh/main.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/jobs.c diff -u src/bin/sh/jobs.c:1.102 src/bin/sh/jobs.c:1.103 --- src/bin/sh/jobs.c:1.102 Sun Oct 28 18:16:01 2018 +++ src/bin/sh/jobs.c Mon Dec 3 02:38:30 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: jobs.c,v 1.102 2018/10/28 18:16:01 kre Exp $ */ +/* $NetBSD: jobs.c,v 1.103 2018/12/03 02:38:30 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: jobs.c,v 1.102 2018/10/28 18:16:01 kre Exp $"); +__RCSID("$NetBSD: jobs.c,v 1.103 2018/12/03 02:38:30 kre Exp $"); #endif #endif /* not lint */ @@ -1161,8 +1161,11 @@ forkchild(struct job *jp, union node *n, wasroot = rootshell; CTRACE(DBG_JOBS, ("Child shell %d %sforked from %d (mode %d)\n", getpid(), vforked?"v":"", getppid(), mode)); - if (!vforked) + + if (!vforked) { rootshell = 0; + handler = _handler; + } closescript(vforked); clear_traps(vforked); Index: src/bin/sh/main.c diff -u src/bin/sh/main.c:1.76 src/bin/sh/main.c:1.77 --- src/bin/sh/main.c:1.76 Wed Aug 22 20:08:54 2018 +++ src/bin/sh/main.c Mon Dec 3 02:38:30 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.76 2018/08/22 20:08:54 kre Exp $ */ +/* $NetBSD: main.c,v 1.77 2018/12/03 02:38:30 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19 #if 0 static char sccsid[] = "@(#)main.c 8.7 (Berkeley) 7/19/95"; #else -__RCSID("$NetBSD: main.c,v 1.76 2018/08/22 20:08:54 kre Exp $"); +__RCSID("$NetBSD: main.c,v 1.77 2018/12/03 02:38:30 kre Exp $"); #endif #endif /* not lint */ @@ -83,6 +83,7 @@ __RCSID("$NetBSD: main.c,v 1.76 2018/08/ int rootpid; int rootshell; +struct jmploc main_handler; int max_user_fd; #if PROFILE short profile_buf[16384]; @@ -102,7 +103,6 @@ STATIC void read_profile(const char *); int main(int argc, char **argv) { - struct jmploc jmploc; struct stackmark smark; volatile int state; char *shinit; @@ -123,7 +123,7 @@ main(int argc, char **argv) monitor(4, etext, profile_buf, sizeof profile_buf, 50); #endif state = 0; - if (setjmp(jmploc.loc)) { + if (setjmp(main_handler.loc)) { /* * When a shell procedure is executed, we raise the * exception EXSHELLPROC to clean up before executing @@ -170,7 +170,7 @@ main(int argc, char **argv) else goto state4; } - handler = + handler = _handler; #ifdef DEBUG #if DEBUG >= 2 debug = 1; /* this may be reset by procargs() later */ Index: src/bin/sh/main.h diff -u src/bin/sh/main.h:1.11 src/bin/sh/main.h:1.12 --- src/bin/sh/main.h:1.11 Sat Jun 18 21:18:46 2011 +++ src/bin/sh/main.h Mon Dec 3 02:38:30 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: main.h,v 1.11 2011/06/18 21:18:46 christos Exp $ */ +/* $NetBSD: main.h,v 1.12 2018/12/03 02:38:30 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -36,6 +36,7 @@ extern int rootpid; /* pid of main shell */ extern int rootshell; /* true if we aren't a child of the main shell */ +extern struct jmploc main_handler; /* top level exception handler */ void readcmdfile(char *); void cmdloop(int);
CVS commit: src/sys/arch/amd64/conf
Module Name:src Committed By: christos Date: Mon Dec 3 00:12:22 UTC 2018 Modified Files: src/sys/arch/amd64/conf: files.amd64 Log Message: KASLR is in files.kern now. To generate a diff of this commit: cvs rdiff -u -r1.107 -r1.108 src/sys/arch/amd64/conf/files.amd64 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/conf/files.amd64 diff -u src/sys/arch/amd64/conf/files.amd64:1.107 src/sys/arch/amd64/conf/files.amd64:1.108 --- src/sys/arch/amd64/conf/files.amd64:1.107 Wed Oct 31 02:26:25 2018 +++ src/sys/arch/amd64/conf/files.amd64 Sun Dec 2 19:12:22 2018 @@ -1,4 +1,4 @@ -# $NetBSD: files.amd64,v 1.107 2018/10/31 06:26:25 maxv Exp $ +# $NetBSD: files.amd64,v 1.108 2018/12/03 00:12:22 christos Exp $ # # new style config file for amd64 architecture # @@ -28,8 +28,7 @@ defflag opt_spectre.h SPECTRE_V2_GCC_MIT # defflag USER_LDT -defflag KASLR -defflag eisa.h EISA +defflag eisa.h EISA # Start code file arch/amd64/amd64/locore.S machdep
CVS commit: src/sys/arch/i386/conf
Module Name:src Committed By: christos Date: Mon Dec 3 00:11:39 UTC 2018 Modified Files: src/sys/arch/i386/conf: files.i386 Log Message: KASLR is in files.kern To generate a diff of this commit: cvs rdiff -u -r1.396 -r1.397 src/sys/arch/i386/conf/files.i386 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/conf/files.i386 diff -u src/sys/arch/i386/conf/files.i386:1.396 src/sys/arch/i386/conf/files.i386:1.397 --- src/sys/arch/i386/conf/files.i386:1.396 Sat Aug 25 03:48:56 2018 +++ src/sys/arch/i386/conf/files.i386 Sun Dec 2 19:11:39 2018 @@ -1,4 +1,4 @@ -# $NetBSD: files.i386,v 1.396 2018/08/25 07:48:56 maxv Exp $ +# $NetBSD: files.i386,v 1.397 2018/12/03 00:11:39 christos Exp $ # # new style config file for i386 architecture # @@ -18,8 +18,6 @@ defparam CPURESET_DELAY # Obsolete Xbox support obsolete defflag XBOX -defflag KASLR - # User-settable LDT (used by WINE) defflag USER_LDT
CVS commit: src/sys/kern
Module Name:src Committed By: christos Date: Mon Dec 3 00:11:02 UTC 2018 Modified Files: src/sys/kern: files.kern init_sysctl.c Log Message: Expose addresses depending on the KASLR setting (from mrg@). Restores the status quo of exposing kernel addresses if there is no KASLR. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/kern/files.kern cvs rdiff -u -r1.219 -r1.220 src/sys/kern/init_sysctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/files.kern diff -u src/sys/kern/files.kern:1.26 src/sys/kern/files.kern:1.27 --- src/sys/kern/files.kern:1.26 Sun Dec 2 16:00:13 2018 +++ src/sys/kern/files.kern Sun Dec 2 19:11:02 2018 @@ -1,4 +1,4 @@ -# $NetBSD: files.kern,v 1.26 2018/12/02 21:00:13 maxv Exp $ +# $NetBSD: files.kern,v 1.27 2018/12/03 00:11:02 christos Exp $ # # kernel sources @@ -6,6 +6,7 @@ define kern: machdep, uvm defflag opt_kern.h KERN defflag opt_script.h SETUIDSCRIPTS FDSCRIPTS +defflag KASLR file compat/common/compat_util.c kern file compat/common/compat_mod.c compat_netbsd | compat_netbsd32 file conf/debugsyms.c kern Index: src/sys/kern/init_sysctl.c diff -u src/sys/kern/init_sysctl.c:1.219 src/sys/kern/init_sysctl.c:1.220 --- src/sys/kern/init_sysctl.c:1.219 Sat Nov 24 12:26:27 2018 +++ src/sys/kern/init_sysctl.c Sun Dec 2 19:11:02 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: init_sysctl.c,v 1.219 2018/11/24 17:26:27 maxv Exp $ */ +/* $NetBSD: init_sysctl.c,v 1.220 2018/12/03 00:11:02 christos Exp $ */ /*- * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -30,12 +30,13 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.219 2018/11/24 17:26:27 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.220 2018/12/03 00:11:02 christos Exp $"); #include "opt_sysv.h" #include "opt_compat_netbsd.h" #include "opt_modular.h" #include "opt_gprof.h" +#include "opt_kaslr.h" #include "pty.h" #include @@ -85,7 +86,11 @@ int kern_has_sysvmsg = 0; int kern_has_sysvshm = 0; int kern_has_sysvsem = 0; +#ifdef KASLR int kern_expose_address = 0; +#else +int kern_expose_address = 1; +#endif static const u_int sysctl_lwpprflagmap[] = { LPR_DETACHED, L_DETACHED,
CVS commit: src
Module Name:src Committed By: maxv Date: Sun Dec 2 21:00:13 UTC 2018 Modified Files: src/share/mk: bsd.sys.mk src/sys/arch/amd64/conf: GENERIC src/sys/arch/amd64/include: param.h src/sys/conf: files ssp.mk src/sys/kern: files.kern subr_pool.c sys_syscall.c src/sys/sys: systm.h src/sys/uvm: uvm_km.c Added Files: src/sys/arch/amd64/include: kleak.h src/sys/kern: subr_kleak.c src/usr.sbin/kleak: Makefile kleak.c Log Message: Introduce KLEAK, a new feature that can detect kernel information leaks. It works by tainting memory sources with marker values, letting the data travel through the kernel, and scanning the kernel<->user frontier for these marker values. Combined with compiler instrumentation and rotation of the markers, it is able to yield relevant results with little effort. We taint the pools and the stack, and scan copyout/copyoutstr. KLEAK is supported on amd64 only for now, but it is not complicated to add more architectures (just a matter of having the address of .text, and a stack unwinder). A userland tool is provided, that allows to execute a command in rounds and monitor the leaks generated all the while. KLEAK already detected directly 12 kernel info leaks, and prompted changes that in total fixed 25+ leaks. Based on an idea developed jointly with Thomas Barabosch (of Fraunhofer FKIE). To generate a diff of this commit: cvs rdiff -u -r1.286 -r1.287 src/share/mk/bsd.sys.mk cvs rdiff -u -r1.508 -r1.509 src/sys/arch/amd64/conf/GENERIC cvs rdiff -u -r0 -r1.1 src/sys/arch/amd64/include/kleak.h cvs rdiff -u -r1.26 -r1.27 src/sys/arch/amd64/include/param.h cvs rdiff -u -r1.1216 -r1.1217 src/sys/conf/files cvs rdiff -u -r1.2 -r1.3 src/sys/conf/ssp.mk cvs rdiff -u -r1.25 -r1.26 src/sys/kern/files.kern cvs rdiff -u -r0 -r1.1 src/sys/kern/subr_kleak.c cvs rdiff -u -r1.227 -r1.228 src/sys/kern/subr_pool.c cvs rdiff -u -r1.11 -r1.12 src/sys/kern/sys_syscall.c cvs rdiff -u -r1.279 -r1.280 src/sys/sys/systm.h cvs rdiff -u -r1.145 -r1.146 src/sys/uvm/uvm_km.c cvs rdiff -u -r0 -r1.1 src/usr.sbin/kleak/Makefile src/usr.sbin/kleak/kleak.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/mk/bsd.sys.mk diff -u src/share/mk/bsd.sys.mk:1.286 src/share/mk/bsd.sys.mk:1.287 --- src/share/mk/bsd.sys.mk:1.286 Fri Aug 3 02:34:31 2018 +++ src/share/mk/bsd.sys.mk Sun Dec 2 21:00:13 2018 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.sys.mk,v 1.286 2018/08/03 02:34:31 kamil Exp $ +# $NetBSD: bsd.sys.mk,v 1.287 2018/12/02 21:00:13 maxv Exp $ # # Build definitions used for NetBSD source tree builds. @@ -232,6 +232,14 @@ CPUFLAGS+= -Wa,--fatal-warnings CFLAGS+= ${CPUFLAGS} AFLAGS+= ${CPUFLAGS} +.if ${KLEAK:U0} > 0 +KLEAKFLAGS= -fsanitize-coverage=trace-pc +.for f in subr_kleak.c +KLEAKFLAGS.${f}= # empty +.endfor +CFLAGS+= ${KLEAKFLAGS.${.IMPSRC:T}:U${KLEAKFLAGS}} +.endif + .if !defined(NOPIE) && (!defined(LDSTATIC) || ${LDSTATIC} != "-static") # Position Independent Executable flags PIE_CFLAGS?=-fPIE Index: src/sys/arch/amd64/conf/GENERIC diff -u src/sys/arch/amd64/conf/GENERIC:1.508 src/sys/arch/amd64/conf/GENERIC:1.509 --- src/sys/arch/amd64/conf/GENERIC:1.508 Sat Nov 24 18:23:29 2018 +++ src/sys/arch/amd64/conf/GENERIC Sun Dec 2 21:00:13 2018 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.508 2018/11/24 18:23:29 bouyer Exp $ +# $NetBSD: GENERIC,v 1.509 2018/12/02 21:00:13 maxv Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/amd64/conf/std.amd64" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.508 $" +#ident "GENERIC-$Revision: 1.509 $" maxusers 64 # estimated number of users @@ -125,6 +125,10 @@ options KDTRACE_HOOKS # kernel DTrace h #options KASAN #no options SVS +# Kernel Info Leak Detector. +#makeoptions KLEAK=1 +#options KLEAK + # Compatibility options # x86_64 never shipped with a.out binaries; the two options below are # only relevant to 32-bit i386 binaries Index: src/sys/arch/amd64/include/param.h diff -u src/sys/arch/amd64/include/param.h:1.26 src/sys/arch/amd64/include/param.h:1.27 --- src/sys/arch/amd64/include/param.h:1.26 Wed Aug 22 12:07:43 2018 +++ src/sys/arch/amd64/include/param.h Sun Dec 2 21:00:13 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.26 2018/08/22 12:07:43 maxv Exp $ */ +/* $NetBSD: param.h,v 1.27 2018/12/02 21:00:13 maxv Exp $ */ #ifdef __x86_64__ @@ -11,6 +11,7 @@ #include #if defined(_KERNEL_OPT) #include "opt_kasan.h" +#include "opt_kleak.h" #endif #endif @@ -61,7 +62,7 @@ #define SSIZE 1 /* initial stack size/NBPG */ #define SINCR 1 /* increment of stack/NBPG */ -#ifdef KASAN +#if defined(KASAN) || defined(KLEAK) #define UPAGES 8 #elif defined(DIAGNOSTIC) #define UPAGES 5 /* pages of u-area (1 for redzone) */ Index: src/sys/conf/files diff -u
CVS commit: src/sys/arch/aarch64/include
Module Name:src Committed By: alnsn Date: Sun Dec 2 20:54:44 UTC 2018 Modified Files: src/sys/arch/aarch64/include: sljit_machdep.h Log Message: Switch to __builtin___clear_cache() in userspace. aarch64_sync_icache() doesn't exist because there no libarm equivalent on aarch64. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/include/sljit_machdep.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/aarch64/include/sljit_machdep.h diff -u src/sys/arch/aarch64/include/sljit_machdep.h:1.1 src/sys/arch/aarch64/include/sljit_machdep.h:1.2 --- src/sys/arch/aarch64/include/sljit_machdep.h:1.1 Sun Aug 26 21:06:46 2018 +++ src/sys/arch/aarch64/include/sljit_machdep.h Sun Dec 2 20:54:44 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: sljit_machdep.h,v 1.1 2018/08/26 21:06:46 rjs Exp $ */ +/* $NetBSD: sljit_machdep.h,v 1.2 2018/12/02 20:54:44 alnsn Exp $ */ /*- * Copyright (c) 2014 Alexander Nasonov. @@ -47,7 +47,7 @@ cpu_icache_sync_range((vaddr_t)(from), (vsize_t)((to) - (from))) #else #define SLJIT_CACHE_FLUSH(from, to) \ - (void)aarch64_sync_icache((uintptr_t)(from), (size_t)((to) - (from))) + (void)__builtin___clear_cache((char *)(from), (char *)(to)) #endif #endif
CVS commit: src/sys/dev/pci
Module Name:src Committed By: jdolecek Date: Sun Dec 2 18:12:29 UTC 2018 Modified Files: src/sys/dev/pci: if_pcn.c Log Message: use pci_intr_establish_xname() To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sys/dev/pci/if_pcn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_pcn.c diff -u src/sys/dev/pci/if_pcn.c:1.65 src/sys/dev/pci/if_pcn.c:1.66 --- src/sys/dev/pci/if_pcn.c:1.65 Tue Jun 26 06:48:01 2018 +++ src/sys/dev/pci/if_pcn.c Sun Dec 2 18:12:29 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pcn.c,v 1.65 2018/06/26 06:48:01 msaitoh Exp $ */ +/* $NetBSD: if_pcn.c,v 1.66 2018/12/02 18:12:29 jdolecek Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pcn.c,v 1.65 2018/06/26 06:48:01 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pcn.c,v 1.66 2018/12/02 18:12:29 jdolecek Exp $"); #include #include @@ -684,7 +684,8 @@ pcn_attach(device_t parent, device_t sel return; } intrstr = pci_intr_string(pc, ih, intrbuf, sizeof(intrbuf)); - sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, pcn_intr, sc); + sc->sc_ih = pci_intr_establish_xname(pc, ih, IPL_NET, pcn_intr, sc, + device_xname(self)); if (sc->sc_ih == NULL) { aprint_error_dev(self, "unable to establish interrupt"); if (intrstr != NULL)
CVS commit: src/sys/dev/pci
Module Name:src Committed By: bouyer Date: Sun Dec 2 17:02:04 UTC 2018 Modified Files: src/sys/dev/pci: if_bge.c if_bgereg.h Log Message: Don't destroy the dma maps if we're not disabling the adapter, avoids a KASSERT() when bus_dmamap_destroy() is called from interrupt context via bge_watchdog() Set IFF_OACTIVE only when bge_encap() fails on adapter ressource shortage. Otherwise we may set IFF_OACTIVE while no transmit is in progress, and nothing will clear it. If bus_dmamap_load_mbuf() fails with EFBIG, m_defrag() the chain and retry. Refine the check for the 4GB boundary workaround (a fragment should also not cross the boundary), and do it only for TSO. If bge_encap() fails and didn't set IFF_OACTIVE, drop the packet. Bring in more hardware bug workarounds from freebsd. With these it seems that a BCM5720 A0 can survive a few hours of internet load with TSO4 enabled. To generate a diff of this commit: cvs rdiff -u -r1.319 -r1.320 src/sys/dev/pci/if_bge.c cvs rdiff -u -r1.93 -r1.94 src/sys/dev/pci/if_bgereg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_bge.c diff -u src/sys/dev/pci/if_bge.c:1.319 src/sys/dev/pci/if_bge.c:1.320 --- src/sys/dev/pci/if_bge.c:1.319 Fri Nov 30 17:53:08 2018 +++ src/sys/dev/pci/if_bge.c Sun Dec 2 17:02:04 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: if_bge.c,v 1.319 2018/11/30 17:53:08 jdolecek Exp $ */ +/* $NetBSD: if_bge.c,v 1.320 2018/12/02 17:02:04 bouyer Exp $ */ /* * Copyright (c) 2001 Wind River Systems @@ -79,7 +79,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.319 2018/11/30 17:53:08 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.320 2018/12/02 17:02:04 bouyer Exp $"); #include #include @@ -233,10 +233,10 @@ static int bge_newbuf_std(struct bge_sof bus_dmamap_t); static int bge_newbuf_jumbo(struct bge_softc *, int, struct mbuf *); static int bge_init_rx_ring_std(struct bge_softc *); -static void bge_free_rx_ring_std(struct bge_softc *); +static void bge_free_rx_ring_std(struct bge_softc *m, bool); static int bge_init_rx_ring_jumbo(struct bge_softc *); static void bge_free_rx_ring_jumbo(struct bge_softc *); -static void bge_free_tx_ring(struct bge_softc *); +static void bge_free_tx_ring(struct bge_softc *m, bool); static int bge_init_tx_ring(struct bge_softc *); static int bge_chipinit(struct bge_softc *); @@ -1713,6 +1713,9 @@ bge_newbuf_std(struct bge_softc *sc, int struct bge_rx_bd *r; int error; + if (dmamap == NULL) + dmamap = sc->bge_cdata.bge_rx_std_map[i]; + if (dmamap == NULL) { error = bus_dmamap_create(sc->bge_dmatag, MCLBYTES, 1, MCLBYTES, 0, BUS_DMA_NOWAIT, ); @@ -1852,7 +1855,7 @@ bge_init_rx_ring_std(struct bge_softc *s } static void -bge_free_rx_ring_std(struct bge_softc *sc) +bge_free_rx_ring_std(struct bge_softc *sc, bool disable) { int i; @@ -1863,8 +1866,11 @@ bge_free_rx_ring_std(struct bge_softc *s if (sc->bge_cdata.bge_rx_std_chain[i] != NULL) { m_freem(sc->bge_cdata.bge_rx_std_chain[i]); sc->bge_cdata.bge_rx_std_chain[i] = NULL; - bus_dmamap_destroy(sc->bge_dmatag, - sc->bge_cdata.bge_rx_std_map[i]); + if (disable) { +bus_dmamap_destroy(sc->bge_dmatag, +sc->bge_cdata.bge_rx_std_map[i]); +sc->bge_cdata.bge_rx_std_map[i] = NULL; + } } memset((char *)>bge_rdata->bge_rx_std_ring[i], 0, sizeof(struct bge_rx_bd)); @@ -1920,7 +1926,7 @@ bge_free_rx_ring_jumbo(struct bge_softc } static void -bge_free_tx_ring(struct bge_softc *sc) +bge_free_tx_ring(struct bge_softc *sc, bool disable) { int i; struct txdmamap_pool_entry *dma; @@ -1940,12 +1946,17 @@ bge_free_tx_ring(struct bge_softc *sc) sizeof(struct bge_tx_bd)); } - while ((dma = SLIST_FIRST(>txdma_list))) { - SLIST_REMOVE_HEAD(>txdma_list, link); - bus_dmamap_destroy(sc->bge_dmatag, dma->dmamap); - if (sc->bge_dma64) - bus_dmamap_destroy(sc->bge_dmatag32, dma->dmamap32); - free(dma, M_DEVBUF); + if (disable) { + while ((dma = SLIST_FIRST(>txdma_list))) { + SLIST_REMOVE_HEAD(>txdma_list, link); + bus_dmamap_destroy(sc->bge_dmatag, dma->dmamap); + if (sc->bge_dma64) { +bus_dmamap_destroy(sc->bge_dmatag32, +dma->dmamap32); + } + free(dma, M_DEVBUF); + } + SLIST_INIT(>txdma_list); } sc->bge_flags &= ~BGEF_TXRING_VALID; @@ -1988,7 +1999,9 @@ bge_init_tx_ring(struct bge_softc *sc) else maxsegsz = ETHER_MAX_LEN_JUMBO; - SLIST_INIT(>txdma_list); + if (SLIST_FIRST(>txdma_list) != NULL) + goto alloc_done; + for (i = 0; i < BGE_TX_RING_CNT; i++) { if (bus_dmamap_create(sc->bge_dmatag, BGE_TXDMA_MAX, BGE_NTXSEG, maxsegsz, 0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, @@ -2021,7 +2034,7 @@ bge_init_tx_ring(struct bge_softc *sc) dma->dmamap32 = dmamap32; SLIST_INSERT_HEAD(>txdma_list, dma, link); } - +alloc_done: sc->bge_flags |= BGEF_TXRING_VALID; return 0; @@
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sun Dec 2 16:58:13 UTC 2018 Modified Files: src/lib/libedit: readline.c tty.c tty.h src/lib/libedit/readline: readline.h Log Message: Add a couple more readline compat functions. To generate a diff of this commit: cvs rdiff -u -r1.147 -r1.148 src/lib/libedit/readline.c cvs rdiff -u -r1.67 -r1.68 src/lib/libedit/tty.c cvs rdiff -u -r1.22 -r1.23 src/lib/libedit/tty.h cvs rdiff -u -r1.43 -r1.44 src/lib/libedit/readline/readline.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.147 src/lib/libedit/readline.c:1.148 --- src/lib/libedit/readline.c:1.147 Sat Jun 9 13:41:55 2018 +++ src/lib/libedit/readline.c Sun Dec 2 11:58:13 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.147 2018/06/09 17:41:55 christos Exp $ */ +/* $NetBSD: readline.c,v 1.148 2018/12/02 16:58:13 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.147 2018/06/09 17:41:55 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.148 2018/12/02 16:58:13 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -2415,3 +2415,19 @@ rl_resize_terminal(void) { el_resize(e); } + +void +rl_reset_after_signal(void) +{ + if (rl_prep_term_function) + (*rl_prep_term_function)(); +} + +void +rl_echo_signal_char(int sig) +{ + int c = tty_get_signal_character(e, sig); + if (c == -1) + return; + re_putc(e, c, 0); +} Index: src/lib/libedit/tty.c diff -u src/lib/libedit/tty.c:1.67 src/lib/libedit/tty.c:1.68 --- src/lib/libedit/tty.c:1.67 Mon Jan 1 17:32:46 2018 +++ src/lib/libedit/tty.c Sun Dec 2 11:58:13 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: tty.c,v 1.67 2018/01/01 22:32:46 christos Exp $ */ +/* $NetBSD: tty.c,v 1.68 2018/12/02 16:58:13 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: tty.c,v 1.67 2018/01/01 22:32:46 christos Exp $"); +__RCSID("$NetBSD: tty.c,v 1.68 2018/12/02 16:58:13 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -1341,3 +1341,33 @@ tty_setup_flags(EditLine *el, struct ter *f = tty_update_flag(el, *f, mode, kind); } } + +libedit_private int +tty_get_signal_character(EditLine *el, int sig) +{ +#ifdef ECHOCTL + tcflag_t *ed = tty__get_flag(>el_tty.t_ed, MD_INP); + if ((*ed & ECHOCTL) == 0) + return -1; +#endif + switch (sig) { +#ifdef SIGINT + case SIGINT: + return el->el_tty.t_c[ED_IO][VINTR]; +#endif +#ifdef SIGQUIT + case SIGQUIT: + return el->el_tty.t_c[ED_IO][VQUIT]; +#endif +#ifdef SIGINFO + case SIGINFO: + return el->el_tty.t_c[ED_IO][VSTATUS]; +#endif +#ifdef SIGTSTP + case SIGTSTP: + return el->el_tty.t_c[ED_IO][VSUSP]; +#endif + default: + return -1; + } +} Index: src/lib/libedit/tty.h diff -u src/lib/libedit/tty.h:1.22 src/lib/libedit/tty.h:1.23 --- src/lib/libedit/tty.h:1.22 Mon Jan 1 17:32:46 2018 +++ src/lib/libedit/tty.h Sun Dec 2 11:58:13 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: tty.h,v 1.22 2018/01/01 22:32:46 christos Exp $ */ +/* $NetBSD: tty.h,v 1.23 2018/12/02 16:58:13 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -464,6 +464,7 @@ libedit_private int tty_cookedmode(EditL libedit_private int tty_quotemode(EditLine *); libedit_private int tty_noquotemode(EditLine *); libedit_private void tty_bind_char(EditLine *, int); +libedit_private int tty_get_signal_character(EditLine *, int); typedef struct { ttyperm_t t_t; Index: src/lib/libedit/readline/readline.h diff -u src/lib/libedit/readline/readline.h:1.43 src/lib/libedit/readline/readline.h:1.44 --- src/lib/libedit/readline/readline.h:1.43 Sat Jun 9 13:41:55 2018 +++ src/lib/libedit/readline/readline.h Sun Dec 2 11:58:13 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.h,v 1.43 2018/06/09 17:41:55 christos Exp $ */ +/* $NetBSD: readline.h,v 1.44 2018/12/02 16:58:13 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -211,6 +211,8 @@ char **rl_completion_matches(cons void rl_forced_update_display(void); int rl_set_prompt(const char *); int rl_on_new_line(void); +void rl_reset_after_signal(void); +void rl_echo_signal_char(int); /* * The following are not implemented
CVS commit: src/sys/arch/ia64/include
Module Name:src Committed By: scole Date: Sun Dec 2 16:49:24 UTC 2018 Modified Files: src/sys/arch/ia64/include: proc.h Log Message: fix SP offset To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/ia64/include/proc.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/ia64/include/proc.h diff -u src/sys/arch/ia64/include/proc.h:1.8 src/sys/arch/ia64/include/proc.h:1.9 --- src/sys/arch/ia64/include/proc.h:1.8 Thu Nov 15 20:06:23 2018 +++ src/sys/arch/ia64/include/proc.h Sun Dec 2 16:49:24 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: proc.h,v 1.8 2018/11/15 20:06:23 scole Exp $ */ +/* $NetBSD: proc.h,v 1.9 2018/12/02 16:49:24 scole Exp $ */ #ifndef _IA64_PROC_H_ #define _IA64_PROC_H_ @@ -41,9 +41,8 @@ struct mdproc { #define UAREA_PCB_OFFSET (USPACE - sizeof(struct pcb)) #define UAREA_TF_OFFSET (UAREA_PCB_OFFSET - sizeof(struct trapframe)) -#define UAREA_SP_OFFSET (UAREA_TF_OFFSET -16 -sizeof(uint64_t)) +#define UAREA_SP_OFFSET (UAREA_TF_OFFSET -16) #define UAREA_BSPSTORE_OFFSET (0) -#define UAREA_STACK_SIZE (USPACE - 16 - sizeof(struct trapframe) - \ - sizeof(struct pcb)) +#define UAREA_STACK_SIZE (USPACE - UAREA_SP_OFFSET) #endif /* _IA64_PROC_H_ */
CVS commit: src/distrib/utils/embedded/conf
Module Name:src Committed By: jmcneill Date: Sun Dec 2 15:43:05 UTC 2018 Modified Files: src/distrib/utils/embedded/conf: evbarm.conf Log Message: Fix variable escaping in dev_exists() To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/distrib/utils/embedded/conf/evbarm.conf Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/utils/embedded/conf/evbarm.conf diff -u src/distrib/utils/embedded/conf/evbarm.conf:1.31 src/distrib/utils/embedded/conf/evbarm.conf:1.32 --- src/distrib/utils/embedded/conf/evbarm.conf:1.31 Fri Nov 30 20:53:02 2018 +++ src/distrib/utils/embedded/conf/evbarm.conf Sun Dec 2 15:43:04 2018 @@ -1,4 +1,4 @@ -# $NetBSD: evbarm.conf,v 1.31 2018/11/30 20:53:02 jmcneill Exp $ +# $NetBSD: evbarm.conf,v 1.32 2018/12/02 15:43:04 jmcneill Exp $ # evbarm shared config # image=$HOME/${board}.img @@ -128,7 +128,7 @@ customize_evbarm() { cp ${release}/etc/rc.conf ${mnt}/etc/rc.conf cat >> ${mnt}/etc/rc.conf << EOF dev_exists() { - if /sbin/drvctl -l $1 >/dev/null 2>&1 ; then + if /sbin/drvctl -l \$1 >/dev/null 2>&1 ; then printf YES else printf NO
CVS commit: src/sys/dev/pci
Module Name:src Committed By: jdolecek Date: Sun Dec 2 13:22:28 UTC 2018 Modified Files: src/sys/dev/pci: mpii.c Log Message: use pci_intr_establish_xname() To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/dev/pci/mpii.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/mpii.c diff -u src/sys/dev/pci/mpii.c:1.13 src/sys/dev/pci/mpii.c:1.14 --- src/sys/dev/pci/mpii.c:1.13 Sat Nov 24 18:11:22 2018 +++ src/sys/dev/pci/mpii.c Sun Dec 2 13:22:28 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: mpii.c,v 1.13 2018/11/24 18:11:22 bouyer Exp $ */ +/* $NetBSD: mpii.c,v 1.14 2018/12/02 13:22:28 jdolecek Exp $ */ /* OpenBSD: mpii.c,v 1.51 2012/04/11 13:29:14 naddy Exp */ /* * Copyright (c) 2010 Mike Belopuhov @@ -20,7 +20,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.13 2018/11/24 18:11:22 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.14 2018/12/02 13:22:28 jdolecek Exp $"); #include "bio.h" @@ -621,8 +621,8 @@ mpii_attach(device_t parent, device_t se goto free_dev; } - sc->sc_ih = pci_intr_establish(sc->sc_pc, ih, IPL_BIO, - mpii_intr, sc); + sc->sc_ih = pci_intr_establish_xname(sc->sc_pc, ih, IPL_BIO, + mpii_intr, sc, DEVNAME(sc)); if (sc->sc_ih == NULL) { aprint_error_dev(self, "can't establish interrupt"); if (intrstr)
CVS commit: src/sys/dev/pci
Module Name:src Committed By: jdolecek Date: Sun Dec 2 13:17:19 UTC 2018 Modified Files: src/sys/dev/pci: mpt_pci.c Log Message: use pci_intr_establish_xname() To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/dev/pci/mpt_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/mpt_pci.c diff -u src/sys/dev/pci/mpt_pci.c:1.25 src/sys/dev/pci/mpt_pci.c:1.26 --- src/sys/dev/pci/mpt_pci.c:1.25 Thu Jul 14 04:19:27 2016 +++ src/sys/dev/pci/mpt_pci.c Sun Dec 2 13:17:19 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: mpt_pci.c,v 1.25 2016/07/14 04:19:27 msaitoh Exp $ */ +/* $NetBSD: mpt_pci.c,v 1.26 2018/12/02 13:17:19 jdolecek Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -46,7 +46,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mpt_pci.c,v 1.25 2016/07/14 04:19:27 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mpt_pci.c,v 1.26 2018/12/02 13:17:19 jdolecek Exp $"); #include /* pulls in all headers */ @@ -204,7 +204,8 @@ mpt_pci_attach(device_t parent, device_t return; } intrstr = pci_intr_string(pa->pa_pc, ih, intrbuf, sizeof(intrbuf)); - psc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO, mpt_intr, mpt); + psc->sc_ih = pci_intr_establish_xname(pa->pa_pc, ih, IPL_BIO, mpt_intr, + mpt, device_xname(mpt->sc_dev)); if (psc->sc_ih == NULL) { aprint_error_dev(mpt->sc_dev, "unable to establish interrupt"); if (intrstr != NULL)
CVS commit: src/usr.sbin/acpitools/acpidump
Module Name:src Committed By: msaitoh Date: Sun Dec 2 10:51:07 UTC 2018 Modified Files: src/usr.sbin/acpitools/acpidump: acpi.c acpidump.8 Log Message: Decode IO Remapping Table. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/acpitools/acpidump/acpi.c cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/acpitools/acpidump/acpidump.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/acpitools/acpidump/acpi.c diff -u src/usr.sbin/acpitools/acpidump/acpi.c:1.41 src/usr.sbin/acpitools/acpidump/acpi.c:1.42 --- src/usr.sbin/acpitools/acpidump/acpi.c:1.41 Sun Nov 11 00:24:01 2018 +++ src/usr.sbin/acpitools/acpidump/acpi.c Sun Dec 2 10:51:07 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi.c,v 1.41 2018/11/11 00:24:01 maya Exp $ */ +/* $NetBSD: acpi.c,v 1.42 2018/12/02 10:51:07 msaitoh Exp $ */ /*- * Copyright (c) 1998 Doug Rabson @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: acpi.c,v 1.41 2018/11/11 00:24:01 maya Exp $"); +__RCSID("$NetBSD: acpi.c,v 1.42 2018/12/02 10:51:07 msaitoh Exp $"); #include #include @@ -96,6 +96,7 @@ static void acpi_handle_einj(ACPI_TABLE_ static void acpi_handle_erst(ACPI_TABLE_HEADER *sdp); static void acpi_handle_gtdt(ACPI_TABLE_HEADER *sdp); static void acpi_handle_hest(ACPI_TABLE_HEADER *sdp); +static void acpi_handle_iort(ACPI_TABLE_HEADER *sdp); static void acpi_handle_lpit(ACPI_TABLE_HEADER *sdp); static void acpi_handle_madt(ACPI_TABLE_HEADER *sdp); static void acpi_handle_msct(ACPI_TABLE_HEADER *sdp); @@ -2063,6 +2064,320 @@ acpi_handle_hpet(ACPI_TABLE_HEADER *sdp) printf(END_COMMENT); } +/* + * IORT + * I/O Remapping Table + */ + +static void acpi_print_iort_its_group(ACPI_IORT_NODE *); +static void acpi_print_iort_named_component(ACPI_IORT_NODE *); +static void acpi_print_iort_root_complex(ACPI_IORT_NODE *); +static void acpi_print_iort_smmuv1v2(ACPI_IORT_NODE *); +static void acpi_print_iort_smmuv3(ACPI_IORT_NODE *); + +struct iort_node_list { + uint8_t Type; + const char *gname; + void (*func)(ACPI_IORT_NODE *); +} iort_node_list [] = { +#define NDMAC(name) ACPI_IORT_NODE_## name +#define PRFN(name) acpi_print_iort_## name + { NDMAC(ITS_GROUP), "ITS group", PRFN(its_group)}, + { NDMAC(NAMED_COMPONENT), "Named component", PRFN(named_component)}, + { NDMAC(PCI_ROOT_COMPLEX), "Root complex",PRFN(root_complex)}, + { NDMAC(SMMU), "SMMUv1 or v2",PRFN(smmuv1v2)}, + { NDMAC(SMMU_V3), "SMMUv3", PRFN(smmuv3)}, + { 255, NULL, NULL}, +#undef NDMAC +#undef PRFN +}; + +static void +acpi_print_iort_memory_access(ACPI_IORT_MEMORY_ACCESS *memacc) +{ + + printf("\tMemory Access={\n"); + printf("\t\tCacheCoherency="); + switch (memacc->CacheCoherency) { + case ACPI_IORT_NODE_COHERENT: + printf("Fully coherent\n"); + break; + case ACPI_IORT_NODE_NOT_COHERENT: + printf("Not coherent\n"); + break; + default: + printf("resrved (%u)\n", memacc->CacheCoherency); + break; + } + printf("\t\tAllocation Hints="); +#define PRINTFLAG(var, flag) printflag((var), ACPI_IORT_HT_## flag, #flag) + PRINTFLAG(memacc->Hints, TRANSIENT); + PRINTFLAG(memacc->Hints, WRITE); + PRINTFLAG(memacc->Hints, READ); + PRINTFLAG(memacc->Hints, OVERRIDE); + PRINTFLAG_END(); +#undef PRINTFLAG + printf("\t\tMemory Access Flags="); +#define PRINTFLAG(var, flag) printflag((var), ACPI_IORT_MF_## flag, #flag) + PRINTFLAG(memacc->MemoryFlags, COHERENCY); + PRINTFLAG(memacc->MemoryFlags, ATTRIBUTES); + PRINTFLAG_END(); +#undef PRINTFLAG + printf("\t}\n"); +} + +static void +acpi_print_iort_its_group(ACPI_IORT_NODE *node) +{ + ACPI_IORT_ITS_GROUP *itsg = (ACPI_IORT_ITS_GROUP *)node->NodeData; + uint32_t *idp; + unsigned int i; + + idp = itsg->Identifiers; + for (i = 0; i < itsg->ItsCount; i++) + printf("\tGIC ITS ID=%d\n", idp[i]); +} + +static void +acpi_print_iort_named_component(ACPI_IORT_NODE *node) +{ + ACPI_IORT_NAMED_COMPONENT *ncomp + = (ACPI_IORT_NAMED_COMPONENT *)node->NodeData; + +#define PRINTFLAG(var, flag) printflag((var), ACPI_IORT_NC_## flag, #flag) + printf("\tNode Flags={PASID_BITS=%u", + (ncomp->NodeFlags & ACPI_IORT_NC_PASID_BITS) >> 1); + pf_sep = ','; + PRINTFLAG(ncomp->NodeFlags, STALL_SUPPORTED); + PRINTFLAG_END(); +#undef PRINTFLAG + acpi_print_iort_memory_access( + (ACPI_IORT_MEMORY_ACCESS *)>MemoryProperties); + printf("\tMemory address size=%hhu\n", ncomp->MemoryAddressLimit); + printf("\tDevice object Name=%s\n", ncomp->DeviceName); +} + +static void +acpi_print_iort_root_complex(ACPI_IORT_NODE *node) +{ + ACPI_IORT_ROOT_COMPLEX *rcmp + = (ACPI_IORT_ROOT_COMPLEX *)node->NodeData; + + acpi_print_iort_memory_access( + (ACPI_IORT_MEMORY_ACCESS *)>MemoryProperties); + printf("\tATS Attribute=%s\n", + (rcmp->AtsAttribute & ACPI_IORT_ATS_SUPPORTED) + ? "supported" : "not supported"); + printf("\tPCI Segment=%u\n", rcmp->PciSegmentNumber); + printf("\tMemory address size
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Sun Dec 2 10:27:58 UTC 2018 Modified Files: src/bin/sh: alias.c Log Message: Fix the worst of the bugs in alias processing. This has been in sh since this code was first imported (May 1994) (ie: before 4.4-Lite) There is (much) more coming soon (the big ugly comment is going away). This one has been separated out, as it can easily cause sh core dumps, so needs: XXX pullup-8 (the other changes to aliases probably will not get that.) To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/bin/sh/alias.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/alias.c diff -u src/bin/sh/alias.c:1.18 src/bin/sh/alias.c:1.19 --- src/bin/sh/alias.c:1.18 Sat Dec 1 01:20:05 2018 +++ src/bin/sh/alias.c Sun Dec 2 10:27:58 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: alias.c,v 1.18 2018/12/01 01:20:05 kre Exp $ */ +/* $NetBSD: alias.c,v 1.19 2018/12/02 10:27:58 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)alias.c 8.3 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: alias.c,v 1.18 2018/12/01 01:20:05 kre Exp $"); +__RCSID("$NetBSD: alias.c,v 1.19 2018/12/02 10:27:58 kre Exp $"); #endif #endif /* not lint */ @@ -69,17 +69,9 @@ setalias(char *name, char *val) { struct alias *ap, **app; + (void) unalias(name); /* old one (if any) is now gone */ app = hashalias(name); - for (ap = *app; ap; ap = ap->next) { - if (equal(name, ap->name)) { - INTOFF; - ckfree(ap->val); - ap->val = savestr(val); - INTON; - return; - } - } - /* not found */ + INTOFF; ap = ckmalloc(sizeof (struct alias)); ap->name = savestr(name);
CVS commit: src/share/man/man4
Module Name:src Committed By: wiz Date: Sun Dec 2 10:06:45 UTC 2018 Modified Files: src/share/man/man4: ena.4 Log Message: New sentence, new line. Add .An -nosplit. Move RCS Id to top. Remove unnecessary quuotes. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/share/man/man4/ena.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man4/ena.4 diff -u src/share/man/man4/ena.4:1.1 src/share/man/man4/ena.4:1.2 --- src/share/man/man4/ena.4:1.1 Sat Dec 1 11:17:28 2018 +++ src/share/man/man4/ena.4 Sun Dec 2 10:06:45 2018 @@ -1,3 +1,5 @@ +.\" $NetBSD: ena.4,v 1.2 2018/12/02 10:06:45 wiz Exp $ +.\" .\" Copyright (c) 2015-2017 Amazon.com, Inc. or its affiliates. .\" All rights reserved. .\" @@ -25,14 +27,12 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $NetBSD: ena.4,v 1.1 2018/12/01 11:17:28 jdolecek Exp $ -.\" .Dd December 1, 2018 .Dt ENA 4 .Os .Sh NAME .Nm ena -.Nd "NetBSD kernel driver for Elastic Network Adapter (ENA) family" +.Nd NetBSD kernel driver for Elastic Network Adapter (ENA) family .Sh SYNOPSIS .Cd "ena* at pci? dev ? function ?" .Sh DESCRIPTION @@ -47,7 +47,8 @@ The driver supports a range of ENA devic (i.e., the same driver is used for 10GbE, 25GbE, 40GbE, etc.), and has a negotiated and extendable feature set. .Pp -Some ENA devices support SR-IOV. This driver is used for both the +Some ENA devices support SR-IOV. +This driver is used for both the SR-IOV Physical Function (PF) and Virtual Function (VF) devices. .Pp The ENA devices enable high speed and low overhead network traffic @@ -70,8 +71,8 @@ to recover in a manner transparent to th debug logs. .Pp Some of the ENA devices support a working mode called Low-latency -Queue (LLQ), which saves several more microseconds. This feature might -be implemented for driver in future releases. +Queue (LLQ), which saves several more microseconds. +This feature might be implemented for the driver in future releases. .Sh HARDWARE Supported PCI vendor ID/device IDs: .Pp @@ -92,6 +93,7 @@ Supported PCI vendor ID/device IDs: .Xr pci 4 , .Xr ifconfig 8 .Sh AUTHORS +.An -nosplit The .Nm driver was originally written by
CVS commit: src/share/man/man9
Module Name:src Committed By: isaki Date: Sun Dec 2 09:22:30 UTC 2018 Modified Files: src/share/man/man9: audio.9 Log Message: Correct function name. freem is used to free memory allocated by allocm. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/share/man/man9/audio.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/audio.9 diff -u src/share/man/man9/audio.9:1.48 src/share/man/man9/audio.9:1.49 --- src/share/man/man9/audio.9:1.48 Sun Dec 2 09:18:26 2018 +++ src/share/man/man9/audio.9 Sun Dec 2 09:22:30 2018 @@ -1,4 +1,4 @@ -.\" $NetBSD: audio.9,v 1.48 2018/12/02 09:18:26 isaki Exp $ +.\" $NetBSD: audio.9,v 1.49 2018/12/02 09:22:30 isaki Exp $ .\" .\" Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -420,7 +420,7 @@ is that some buses need special allocati Returns the address of the buffer, or 0 on failure. .It Dv void freem(void *hdl, void *addr, size_t size) optional, is called to free memory allocated by -.Va alloc . +.Va allocm . If not supplied .Xr free 9 is used.
CVS commit: src/share/man/man9
Module Name:src Committed By: isaki Date: Sun Dec 2 09:18:26 UTC 2018 Modified Files: src/share/man/man9: audio.9 Log Message: Sync prototypes with reality. These have been changed in 2011. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/share/man/man9/audio.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/audio.9 diff -u src/share/man/man9/audio.9:1.47 src/share/man/man9/audio.9:1.48 --- src/share/man/man9/audio.9:1.47 Mon May 28 00:18:06 2018 +++ src/share/man/man9/audio.9 Sun Dec 2 09:18:26 2018 @@ -1,4 +1,4 @@ -.\" $NetBSD: audio.9,v 1.47 2018/05/28 00:18:06 nat Exp $ +.\" $NetBSD: audio.9,v 1.48 2018/12/02 09:18:26 isaki Exp $ .\" .\" Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -75,8 +75,8 @@ struct audio_hw_if { int (*query_devinfo)(void *, mixer_devinfo_t *); - void *(*allocm)(void *, int, size_t, struct malloc_type *, int); - void (*freem)(void *, void *, struct malloc_type *); + void *(*allocm)(void *, int, size_t); + void (*freem)(void *, void *, size_t); size_t (*round_buffersize)(void *, int, size_t); paddr_t (*mappage)(void *, void *, off_t, int); @@ -409,8 +409,7 @@ It should fill the .Va mixer_devinfo_t struct. Return 0 on success, otherwise an error code. -.It Dv "void *allocm(void *hdl, int direction, size_t size, struct malloc_type *type, int flags)" -.Pp +.It Dv "void *allocm(void *hdl, int direction, size_t size)" optional, is called to allocate the device buffers. If not present .Xr malloc 9 @@ -419,7 +418,7 @@ The reason for using a device dependent .Xr malloc 9 is that some buses need special allocation to do DMA. Returns the address of the buffer, or 0 on failure. -.It Dv void freem(void *hdl, void *addr, struct malloc_type *type) +.It Dv void freem(void *hdl, void *addr, size_t size) optional, is called to free memory allocated by .Va alloc . If not supplied
CVS commit: src/sys/arch
Module Name:src Committed By: cherry Date: Sun Dec 2 08:19:44 UTC 2018 Modified Files: src/sys/arch/amd64/amd64: mainbus.c src/sys/arch/i386/i386: mainbus.c src/sys/arch/x86/pci: pci_intr_machdep.c src/sys/arch/x86/x86: intr.c Log Message: make options NO_PCI_MSI_MSIX work again for arch/x86/ To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/arch/amd64/amd64/mainbus.c cvs rdiff -u -r1.103 -r1.104 src/sys/arch/i386/i386/mainbus.c cvs rdiff -u -r1.47 -r1.48 src/sys/arch/x86/pci/pci_intr_machdep.c cvs rdiff -u -r1.135 -r1.136 src/sys/arch/x86/x86/intr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/mainbus.c diff -u src/sys/arch/amd64/amd64/mainbus.c:1.38 src/sys/arch/amd64/amd64/mainbus.c:1.39 --- src/sys/arch/amd64/amd64/mainbus.c:1.38 Tue May 23 08:54:38 2017 +++ src/sys/arch/amd64/amd64/mainbus.c Sun Dec 2 08:19:44 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: mainbus.c,v 1.38 2017/05/23 08:54:38 nonaka Exp $ */ +/* $NetBSD: mainbus.c,v 1.39 2018/12/02 08:19:44 cherry Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.38 2017/05/23 08:54:38 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.39 2018/12/02 08:19:44 cherry Exp $"); #include #include @@ -74,7 +74,9 @@ __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v #include #endif #endif +#ifdef __HAVE_PCI_MSI_MSIX #include +#endif /* __HAVE_PCI_MSI_MSIX */ #endif /* @@ -179,7 +181,9 @@ mainbus_attach(device_t parent, device_t #endif #if NPCI > 0 +#ifdef __HAVE_PCI_MSI_MSIX msipic_init(); +#endif /* * ACPI needs to be able to access PCI configuration space. @@ -209,9 +213,9 @@ mainbus_attach(device_t parent, device_t */ if (acpi_present) mpacpi_active = mpacpi_scan_apics(self, ) != 0; -#endif if (!mpacpi_active) { +#endif #ifdef MPBIOS if (mpbios_present) mpbios_scan(self, ); @@ -227,7 +231,9 @@ mainbus_attach(device_t parent, device_t config_found_ia(self, "cpubus", , mainbus_print); } +#if NACPICA > 0 } +#endif #if NISADMA > 0 && NACPICA > 0 /* Index: src/sys/arch/i386/i386/mainbus.c diff -u src/sys/arch/i386/i386/mainbus.c:1.103 src/sys/arch/i386/i386/mainbus.c:1.104 --- src/sys/arch/i386/i386/mainbus.c:1.103 Tue May 23 08:54:38 2017 +++ src/sys/arch/i386/i386/mainbus.c Sun Dec 2 08:19:44 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: mainbus.c,v 1.103 2017/05/23 08:54:38 nonaka Exp $ */ +/* $NetBSD: mainbus.c,v 1.104 2018/12/02 08:19:44 cherry Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.103 2017/05/23 08:54:38 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.104 2018/12/02 08:19:44 cherry Exp $"); #include #include @@ -86,7 +86,9 @@ __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v #include #endif #endif +#ifdef __HAVE_PCI_MSI_MSIX #include +#endif /* __HAVE_PCI_MSI_MSIX */ #endif void mainbus_childdetached(device_t, device_t); Index: src/sys/arch/x86/pci/pci_intr_machdep.c diff -u src/sys/arch/x86/pci/pci_intr_machdep.c:1.47 src/sys/arch/x86/pci/pci_intr_machdep.c:1.48 --- src/sys/arch/x86/pci/pci_intr_machdep.c:1.47 Tue Nov 27 21:03:50 2018 +++ src/sys/arch/x86/pci/pci_intr_machdep.c Sun Dec 2 08:19:44 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_intr_machdep.c,v 1.47 2018/11/27 21:03:50 jdolecek Exp $ */ +/* $NetBSD: pci_intr_machdep.c,v 1.48 2018/12/02 08:19:44 cherry Exp $ */ /*- * Copyright (c) 1997, 1998, 2009 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.47 2018/11/27 21:03:50 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.48 2018/12/02 08:19:44 cherry Exp $"); #include #include @@ -102,6 +102,8 @@ __KERNEL_RCSID(0, "$NetBSD: pci_intr_mac #include #include #include +#else +#include #endif #ifdef MPBIOS @@ -232,8 +234,10 @@ pci_intr_string(pci_chipset_tag_t pc, pc buf, len); } +#if defined(__HAVE_PCI_MSI_MSIX) if (INT_VIA_MSI(ih)) return x86_pci_msi_string(pc, ih, buf, len); +#endif return intr_string(ih & ~MPSAFE_MASK, buf, len); } @@ -319,6 +323,8 @@ pci_intr_establish_xname_internal(pci_ch pc, ih, level, func, arg); } + +#ifdef __HAVE_PCI_MSI_MSIX if (INT_VIA_MSI(ih)) { if (MSI_INT_IS_MSIX(ih)) return x86_pci_msix_establish(pc, ih, level, func, arg, @@ -327,7 +333,7 @@ pci_intr_establish_xname_internal(pci_ch return x86_pci_msi_establish(pc, ih, level, func, arg, xname); } - +#endif if (pci_intr_find_intx_irq(ih, , , )) { aprint_normal("%s: bad pic %d\n", __func__, APIC_IRQ_APIC(ih)); Index: src/sys/arch/x86/x86/intr.c diff -u src/sys/arch/x86/x86/intr.c:1.135