svn commit: r334020 - head/sys/sys

2018-05-21 Thread Matt Macy
Author: mmacy
Date: Tue May 22 05:49:40 2018
New Revision: 334020
URL: https://svnweb.freebsd.org/changeset/base/334020

Log:
  pmc: annotate locking for po_ssnext in pmc_owner

Modified:
  head/sys/sys/pmc.h

Modified: head/sys/sys/pmc.h
==
--- head/sys/sys/pmc.h  Tue May 22 05:21:53 2018(r334019)
+++ head/sys/sys/pmc.h  Tue May 22 05:49:40 2018(r334020)
@@ -657,6 +657,8 @@ struct pmc_op_getdyneventinfo {
  * (b) - pmc_bufferlist_mtx (spin lock)
  * (k) - pmc_kthread_mtx (sleep lock)
  * (o) - po->po_mtx (spin lock)
+ * (g) - global_epoch_preempt (epoch)
+ * (p) - pmc_sx (sx)
  */
 
 /*
@@ -852,7 +854,7 @@ struct pmc_process {
 
 struct pmc_owner  {
LIST_ENTRY(pmc_owner)   po_next;/* hash chain */
-   CK_LIST_ENTRY(pmc_owner)po_ssnext;  /* list of SS PMC 
owners */
+   CK_LIST_ENTRY(pmc_owner)po_ssnext;  /* (g/p) list of SS PMC 
owners */
LIST_HEAD(, pmc)po_pmcs;/* owned PMC list */
TAILQ_HEAD(, pmclog_buffer) po_logbuffers; /* (o) logbuffer list */
struct mtx  po_mtx; /* spin lock for (o) */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334019 - head/usr.sbin/bhyve

2018-05-21 Thread Marcelo Araujo
Author: araujo
Date: Tue May 22 05:21:53 2018
New Revision: 334019
URL: https://svnweb.freebsd.org/changeset/base/334019

Log:
  Include atkbdc header where there are declared the prototype functions
  atkbdc_event and atkbdc_init.
  
  MFC after:4 weeks.
  Sponsored by: iXsystems Inc.

Modified:
  head/usr.sbin/bhyve/atkbdc.c

Modified: head/usr.sbin/bhyve/atkbdc.c
==
--- head/usr.sbin/bhyve/atkbdc.cTue May 22 05:09:33 2018
(r334018)
+++ head/usr.sbin/bhyve/atkbdc.cTue May 22 05:21:53 2018
(r334019)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include "acpi.h"
+#include "atkbdc.h"
 #include "inout.h"
 #include "pci_emul.h"
 #include "pci_irq.h"
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334018 - in head/sys/i386: i386 include

2018-05-21 Thread Matt Macy
Author: mmacy
Date: Tue May 22 05:09:33 2018
New Revision: 334018
URL: https://svnweb.freebsd.org/changeset/base/334018

Log:
  fix i386 builds after r334005 and r334009
  
  r334005: add pc_ibpb_set as it is now referenced by common code
  (although presumably not needed on i386 since it has been there
  since the first spectre mitigation work on amd64)
  
  r334009: there is no amd64 rflags -> i386 eflags

Modified:
  head/sys/i386/i386/trap.c
  head/sys/i386/include/pcpu.h

Modified: head/sys/i386/i386/trap.c
==
--- head/sys/i386/i386/trap.c   Tue May 22 04:45:46 2018(r334017)
+++ head/sys/i386/i386/trap.c   Tue May 22 05:09:33 2018(r334018)
@@ -338,7 +338,7 @@ user_trctrap_out:
ucode = TRAP_TRACE;
dr6 = rdr6();
if (dr6 & DBREG_DR6_BS)
-   frame->tf_rflags &= ~PSL_T;
+   frame->tf_eflags &= ~PSL_T;
break;
 
case T_ARITHTRAP:   /* arithmetic trap */

Modified: head/sys/i386/include/pcpu.h
==
--- head/sys/i386/include/pcpu.hTue May 22 04:45:46 2018
(r334017)
+++ head/sys/i386/include/pcpu.hTue May 22 05:09:33 2018
(r334018)
@@ -77,7 +77,8 @@
struct  sx pc_copyout_slock;\
char*pc_copyout_buf;\
uint32_t pc_smp_tlb_done;   /* TLB op acknowledgement */\
-   char__pad[550]
+   uint32_t pc_ibpb_set;   \
+   char__pad[546]
 
 #ifdef _KERNEL
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r334008 - head/bin/sh

2018-05-21 Thread Cy Schubert
In message <20180522061339.21497...@freyja.zeit4.iv.bundesimmobilien.de>
, "O. H
artmann" writes:
> On Mon, 21 May 2018 21:52:48 + (UTC)
> Jilles Tjoelker  wrote:
>
> > Author: jilles
> > Date: Mon May 21 21:52:48 2018
> > New Revision: 334008
> > URL: https://svnweb.freebsd.org/changeset/base/334008
> > 
> > Log:
> >   sh: Split CNL syntax category to avoid a check on state[level].syntax
> >   
> >   No functional change is intended.
> > 
> > Modified:
> >   head/bin/sh/mksyntax.c
> >   head/bin/sh/parser.c
> > 
> > Modified: head/bin/sh/mksyntax.c
> > ===
> ===
> > --- head/bin/sh/mksyntax.c  Mon May 21 21:44:47 2018(r334007)
> > +++ head/bin/sh/mksyntax.c  Mon May 21 21:52:48 2018(r334008)
> > @@ -65,6 +65,7 @@ struct synclass {
> >  static const struct synclass synclass[] = {
> > { "CWORD",  "character is nothing special" },
> > { "CNL","newline character" },
> > +   { "CQNL",   "newline character in quotes" },
> > { "CBACK",  "a backslash character" },
> > { "CSBACK", "a backslash character in single quotes" },
> > { "CSQUOTE","single quote" },
> > @@ -185,7 +186,7 @@ main(int argc __unused, char **argv __unused)
> > fputs("\n/* syntax table used when in double quotes */\n", cfile);
> > init("dqsyntax");
> > add_default();
> > -   add("\n", "CNL");
> > +   add("\n", "CQNL");
> > add("\\", "CBACK");
> > add("\"", "CENDQUOTE");
> > add("`", "CBQUOTE");
> > @@ -198,7 +199,7 @@ main(int argc __unused, char **argv __unused)
> > fputs("\n/* syntax table used when in single quotes */\n", cfile);
> > init("sqsyntax");
> > add_default();
> > -   add("\n", "CNL");
> > +   add("\n", "CQNL");
> > add("\\", "CSBACK");
> > add("'", "CENDQUOTE");
> > /* ':/' for tilde expansion, '-^]' for [a\-x] pattern ranges */
> > @@ -208,7 +209,7 @@ main(int argc __unused, char **argv __unused)
> > fputs("\n/* syntax table used when in arithmetic */\n", cfile);
> > init("arisyntax");
> > add_default();
> > -   add("\n", "CNL");
> > +   add("\n", "CQNL");
> > add("\\", "CBACK");
> > add("`", "CBQUOTE");
> > add("\"", "CIGN");
> > 
> > Modified: head/bin/sh/parser.c
> > ===
> ===
> > --- head/bin/sh/parser.cMon May 21 21:44:47 2018(r334007)
> > +++ head/bin/sh/parser.cMon May 21 21:52:48 2018(r334008)
> > @@ -1434,9 +1434,10 @@ readtoken1(int firstc, char const *initialsyntax, co
> ns
> >  
> > switch(synentry) {
> > case CNL:   /* '\n' */
> > -   if (level == 0 &&
> > -   state[level].syntax == BASESYNTAX)
> > +   if (level == 0)
> > goto endword;   /* exit outer
> > loop */
> > +   /* FALLTHROUGH */
> > +   case CQNL:
> > USTPUTC(c, out);
> > plinno++;
> > if (doprompt)
> > ___
> > svn-src-head@freebsd.org mailing list
> > https://lists.freebsd.org/mailman/listinfo/svn-src-head
> > To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
>
>
> Have this been tested? Doesn't compile for me:
>
> [...]
> Building /usr/obj/usr/src/amd64.amd64/kerberos5/libexec/hprop/hprop
> --- all_subdir_rescue ---
> --- parser.o ---
> /usr/src/bin/sh/parser.c:1440:9: error: use of undeclared identifier 'CQNL'
> case CQNL:
>  ^
> --- all_subdir_gnu ---
> Building /usr/obj/usr/src/amd64.amd64/gnu/usr.bin/gdb/libgdb/amd64bsd-nat.o
> --- all_subdir_rescue ---
> 1 error generated.
> *** [parser.o] Error code 1
>
> make[6]: stopped in /usr/src/bin/sh
>

CQNL is defined in /usr/obj/opt/src/svn-current/amd64.amd64/bin/sh/synta
x.h, generated by mksyntax.

slippy$ ag -s CQNL /export/obj/opt/src/svn-current/amd64.amd64/bin/sh/*.
h
/export/obj/opt/src/svn-current/amd64.amd64/bin/sh/syntax.h
11:#define CQNL 2   /* newline character in quotes */
slippy$ 

Remove the file if it's not defined in your syntax.h.

Just out of interest, do you use meta mode?


-- 
Cheers,
Cy Schubert 
FreeBSD UNIX:     Web:  http://www.FreeBSD.org

The need of the many outweighs the greed of the few.


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


svn commit: r334017 - in head: lib/libpmcstat usr.sbin/pmcstat

2018-05-21 Thread Matt Macy
Author: mmacy
Date: Tue May 22 04:45:46 2018
New Revision: 334017
URL: https://svnweb.freebsd.org/changeset/base/334017

Log:
  pmcstat: add option to not decode the leaf function in top mode
  
  -I will allow the user to see the hot instruction in question
  as opposed getting the name of the function

Modified:
  head/lib/libpmcstat/libpmcstat.h
  head/usr.sbin/pmcstat/pmcpl_callgraph.c
  head/usr.sbin/pmcstat/pmcstat.c

Modified: head/lib/libpmcstat/libpmcstat.h
==
--- head/lib/libpmcstat/libpmcstat.hTue May 22 04:08:08 2018
(r334016)
+++ head/lib/libpmcstat/libpmcstat.hTue May 22 04:45:46 2018
(r334017)
@@ -106,6 +106,7 @@ struct pmcstat_args {
 #defineFLAGS_HAS_CPUMASK   0x0004  /* -c */
 #defineFLAG_HAS_DURATION   0x0008  /* -l secs */
 #defineFLAG_DO_WIDE_GPROF_HC   0x0010  /* -e */
+#defineFLAG_SKIP_TOP_FN_RES0x0020  /* -I */
 
int pa_required;/* required features */
int pa_pplugin; /* pre-processing plugin */

Modified: head/usr.sbin/pmcstat/pmcpl_callgraph.c
==
--- head/usr.sbin/pmcstat/pmcpl_callgraph.c Tue May 22 04:08:08 2018
(r334016)
+++ head/usr.sbin/pmcstat/pmcpl_callgraph.c Tue May 22 04:45:46 2018
(r334017)
@@ -473,7 +473,7 @@ pmcstat_callgraph_print(void)
 
 static void
 pmcstat_cgnode_topprint(struct pmcstat_cgnode *cg,
-int depth, uint32_t nsamples)
+int depth __unused, uint32_t nsamples)
 {
int v_attrs, vs_len, ns_len, width, len, n, nchildren;
float v;
@@ -481,15 +481,15 @@ pmcstat_cgnode_topprint(struct pmcstat_cgnode *cg,
struct pmcstat_symbol *sym;
struct pmcstat_cgnode **sortbuffer, **cgn, *pcg;
 
-   (void) depth;
-
/* Format value. */
v = PMCPL_CG_COUNTP(cg);
snprintf(vs, sizeof(vs), "%.1f", v);
v_attrs = PMCSTAT_ATTRPERCENT(v);
+   sym = NULL;
 
/* Format name. */
-   sym = pmcstat_symbol_search(cg->pcg_image, cg->pcg_func);
+   if (!(args.pa_flags & FLAG_SKIP_TOP_FN_RES))
+   sym = pmcstat_symbol_search(cg->pcg_image, cg->pcg_func);
if (sym != NULL) {
snprintf(ns, sizeof(ns), "%s",
pmcstat_string_unintern(sym->ps_name));

Modified: head/usr.sbin/pmcstat/pmcstat.c
==
--- head/usr.sbin/pmcstat/pmcstat.c Tue May 22 04:08:08 2018
(r334016)
+++ head/usr.sbin/pmcstat/pmcstat.c Tue May 22 04:45:46 2018
(r334017)
@@ -500,7 +500,7 @@ main(int argc, char **argv)
CPU_COPY(, );
 
while ((option = getopt(argc, argv,
-   "CD:EF:G:M:NO:P:R:S:TWa:c:def:gk:l:m:n:o:p:qr:s:t:vw:z:")) != -1)
+   "CD:EF:G:IM:NO:P:R:S:TWa:c:def:gk:l:m:n:o:p:qr:s:t:vw:z:")) != -1)
switch (option) {
case 'a':   /* Annotate + callgraph */
args.pa_flags |= FLAG_DO_ANNOTATE;
@@ -569,6 +569,9 @@ main(int argc, char **argv)
args.pa_plugin  = PMCSTAT_PL_GPROF;
break;
 
+   case 'I':
+   args.pa_flags |= FLAG_SKIP_TOP_FN_RES;
+   break;
case 'k':   /* pathname to the kernel */
free(args.pa_kernel);
args.pa_kernel = strdup(optarg);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r334008 - head/bin/sh

2018-05-21 Thread O. Hartmann
On Mon, 21 May 2018 21:52:48 + (UTC)
Jilles Tjoelker  wrote:

> Author: jilles
> Date: Mon May 21 21:52:48 2018
> New Revision: 334008
> URL: https://svnweb.freebsd.org/changeset/base/334008
> 
> Log:
>   sh: Split CNL syntax category to avoid a check on state[level].syntax
>   
>   No functional change is intended.
> 
> Modified:
>   head/bin/sh/mksyntax.c
>   head/bin/sh/parser.c
> 
> Modified: head/bin/sh/mksyntax.c
> ==
> --- head/bin/sh/mksyntax.cMon May 21 21:44:47 2018(r334007)
> +++ head/bin/sh/mksyntax.cMon May 21 21:52:48 2018(r334008)
> @@ -65,6 +65,7 @@ struct synclass {
>  static const struct synclass synclass[] = {
>   { "CWORD",  "character is nothing special" },
>   { "CNL","newline character" },
> + { "CQNL",   "newline character in quotes" },
>   { "CBACK",  "a backslash character" },
>   { "CSBACK", "a backslash character in single quotes" },
>   { "CSQUOTE","single quote" },
> @@ -185,7 +186,7 @@ main(int argc __unused, char **argv __unused)
>   fputs("\n/* syntax table used when in double quotes */\n", cfile);
>   init("dqsyntax");
>   add_default();
> - add("\n", "CNL");
> + add("\n", "CQNL");
>   add("\\", "CBACK");
>   add("\"", "CENDQUOTE");
>   add("`", "CBQUOTE");
> @@ -198,7 +199,7 @@ main(int argc __unused, char **argv __unused)
>   fputs("\n/* syntax table used when in single quotes */\n", cfile);
>   init("sqsyntax");
>   add_default();
> - add("\n", "CNL");
> + add("\n", "CQNL");
>   add("\\", "CSBACK");
>   add("'", "CENDQUOTE");
>   /* ':/' for tilde expansion, '-^]' for [a\-x] pattern ranges */
> @@ -208,7 +209,7 @@ main(int argc __unused, char **argv __unused)
>   fputs("\n/* syntax table used when in arithmetic */\n", cfile);
>   init("arisyntax");
>   add_default();
> - add("\n", "CNL");
> + add("\n", "CQNL");
>   add("\\", "CBACK");
>   add("`", "CBQUOTE");
>   add("\"", "CIGN");
> 
> Modified: head/bin/sh/parser.c
> ==
> --- head/bin/sh/parser.c  Mon May 21 21:44:47 2018(r334007)
> +++ head/bin/sh/parser.c  Mon May 21 21:52:48 2018(r334008)
> @@ -1434,9 +1434,10 @@ readtoken1(int firstc, char const *initialsyntax, cons
>  
>   switch(synentry) {
>   case CNL:   /* '\n' */
> - if (level == 0 &&
> - state[level].syntax == BASESYNTAX)
> + if (level == 0)
>   goto endword;   /* exit outer
> loop */
> + /* FALLTHROUGH */
> + case CQNL:
>   USTPUTC(c, out);
>   plinno++;
>   if (doprompt)
> ___
> svn-src-head@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/svn-src-head
> To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Have this been tested? Doesn't compile for me:

[...]
Building /usr/obj/usr/src/amd64.amd64/kerberos5/libexec/hprop/hprop
--- all_subdir_rescue ---
--- parser.o ---
/usr/src/bin/sh/parser.c:1440:9: error: use of undeclared identifier 'CQNL'
case CQNL:
 ^
--- all_subdir_gnu ---
Building /usr/obj/usr/src/amd64.amd64/gnu/usr.bin/gdb/libgdb/amd64bsd-nat.o
--- all_subdir_rescue ---
1 error generated.
*** [parser.o] Error code 1

make[6]: stopped in /usr/src/bin/sh
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334016 - head/usr.sbin/bhyve

2018-05-21 Thread Marcelo Araujo
Author: araujo
Date: Tue May 22 04:08:08 2018
New Revision: 334016
URL: https://svnweb.freebsd.org/changeset/base/334016

Log:
  We must free the variable str.
  
  Spotted by:   clang's static analyzer
  Submitted by: Tom Rix 
  Reviewed by:  grehan
  MFC after:4 weeks
  Sponsored by: iXsystems Inc.
  Differential Revision:https://reviews.freebsd.org/D10009

Modified:
  head/usr.sbin/bhyve/pci_emul.c

Modified: head/usr.sbin/bhyve/pci_emul.c
==
--- head/usr.sbin/bhyve/pci_emul.c  Tue May 22 03:57:32 2018
(r334015)
+++ head/usr.sbin/bhyve/pci_emul.c  Tue May 22 04:08:08 2018
(r334016)
@@ -231,8 +231,7 @@ pci_parse_slot(char *opt)
si->si_funcs[fnum].fi_param = config;
 
 done:
-   if (error)
-   free(str);
+   free(str);
 
return (error);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334015 - in head/sys: conf powerpc/powernv

2018-05-21 Thread Justin Hibbits
Author: jhibbits
Date: Tue May 22 03:57:32 2018
New Revision: 334015
URL: https://svnweb.freebsd.org/changeset/base/334015

Log:
  Add an IPMI attachment for PowerNV systems
  
  IPMI access on PowerNV systems is done through the OPAL firmware.  This adds a
  simple attachment for communicating with the FSP/BMC on these machines.  This
  has been tested on a Talos POWER9 workstation, only in the bootup phase, 
noting
  the successful attachment messages:
  
  ...
  ipmi0: IPMI device rev. 0, firmware rev. 2.00, version 2.0, device support 
mask 0
  ipmi0: Number of channels 2
  ...
  
  The ipmi device has not been added to GENERIC64, but may be after further
  testing.  It may also eventually be added to the ipmi module at that point.

Added:
  head/sys/powerpc/powernv/opal_ipmi.c   (contents, props changed)
Modified:
  head/sys/conf/files.powerpc
  head/sys/powerpc/powernv/opal.h

Modified: head/sys/conf/files.powerpc
==
--- head/sys/conf/files.powerpc Tue May 22 03:24:16 2018(r334014)
+++ head/sys/conf/files.powerpc Tue May 22 03:57:32 2018(r334015)
@@ -42,6 +42,7 @@ dev/iicbus/ds1631.c   optionalds1631 powermac
 dev/iicbus/ds1775.coptionalds1775 powermac
 dev/iicbus/max6690.c   optionalmax6690 powermac
 dev/iicbus/ofw_iicbus.coptionaliicbus aim
+dev/ipmi/ipmi.coptionalipmi
 dev/nand/nfc_fsl.c optionalnand mpc85xx
 dev/nand/nfc_rb.c  optionalnand mpc85xx
 # Most ofw stuff below is brought in by conf/files for options FDT, but
@@ -188,6 +189,7 @@ powerpc/powernv/opal_console.c  optionalpowernv
 powerpc/powernv/opal_dev.c optionalpowernv
 powerpc/powernv/opal_i2c.c optionaliicbus fdt powernv
 powerpc/powernv/opal_i2cm.coptionaliicbus fdt powernv
+powerpc/powernv/opal_ipmi.coptionalpowernv ipmi
 powerpc/powernv/opal_pci.c optionalpowernv pci
 powerpc/powernv/opal_sensor.c  optionalpowernv
 powerpc/powernv/opalcall.S optionalpowernv

Modified: head/sys/powerpc/powernv/opal.h
==
--- head/sys/powerpc/powernv/opal.h Tue May 22 03:24:16 2018
(r334014)
+++ head/sys/powerpc/powernv/opal.h Tue May 22 03:57:32 2018
(r334015)
@@ -73,6 +73,8 @@ int opal_call(uint64_t token, ...);
 #defineOPAL_REINIT_CPUS70
 #defineOPAL_CHECK_ASYNC_COMPLETION 86
 #defineOPAL_SENSOR_READ88
+#defineOPAL_IPMI_SEND  107
+#defineOPAL_IPMI_RECV  108
 #defineOPAL_I2C_REQUEST109
 #defineOPAL_INT_GET_XIRR   122
 #defineOPAL_INT_SET_CPPR   123
@@ -106,8 +108,12 @@ int opal_call(uint64_t token, ...);
 #defineOPAL_PARAMETER  -1
 #defineOPAL_BUSY   -2
 #defineOPAL_CLOSED -5
+#defineOPAL_HARDWARE   -6
+#defineOPAL_UNSUPPORTED-7
+#defineOPAL_RESOURCE   -10
 #defineOPAL_BUSY_EVENT -12
 #defineOPAL_ASYNC_COMPLETION   -15
+#defineOPAL_EMPTY  -16
 
 struct opal_msg {
uint32_t msg_type;
@@ -125,6 +131,15 @@ enum opal_msg_type {
OPAL_MSG_PRD= 6,
OPAL_MSG_OCC= 7,
OPAL_MSG_TYPE_MAX,
+};
+
+#defineOPAL_IPMI_MSG_FORMAT_VERSION_1  1
+
+struct opal_ipmi_msg {
+   uint8_t version;
+   uint8_t netfn;
+   uint8_t cmd;
+   uint8_t data[];
 };
 
 #endif

Added: head/sys/powerpc/powernv/opal_ipmi.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/powerpc/powernv/opal_ipmi.cTue May 22 03:57:32 2018
(r334015)
@@ -0,0 +1,241 @@
+/*-
+ * Copyright (C) 2018 Justin Hibbits
+ *
+ * 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 ``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 TOOLS GMBH BE LIABLE FOR 

svn commit: r334014 - head/sys/powerpc/pseries

2018-05-21 Thread Justin Hibbits
Author: jhibbits
Date: Tue May 22 03:24:16 2018
New Revision: 334014
URL: https://svnweb.freebsd.org/changeset/base/334014

Log:
  Add a comment explaining the need of a global temporary variable
  
  cpu_xirr is used only as a temporary location for the OPAL call in
  PIC_DISPATCH().
  
  Requested by: nwhitehorn

Modified:
  head/sys/powerpc/pseries/xics.c

Modified: head/sys/powerpc/pseries/xics.c
==
--- head/sys/powerpc/pseries/xics.c Tue May 22 03:22:02 2018
(r334013)
+++ head/sys/powerpc/pseries/xics.c Tue May 22 03:24:16 2018
(r334014)
@@ -140,6 +140,15 @@ static driver_t xics_driver = {
 };
 
 #ifdef POWERNV
+/* We can only pass physical addresses into OPAL.  Kernel stacks are in the 
KVA,
+ * not in the direct map, so we need to somehow extract the physical address.
+ * However, pmap_kextract() takes locks, which is forbidden in a critical 
region
+ * (which PMAP_DISPATCH() operates in).  The kernel is mapped into the Direct
+ * Map (0xc000), and the CPU implicitly drops the top two bits when doing
+ * real address by nature that the bus width is smaller than 64-bits.  Placing
+ * cpu_xirr into the DMAP lets us take advantage of this and avoids the
+ * pmap_kextract() that would otherwise be needed if using the stack variable.
+ */
 static uint32_t cpu_xirr[MAXCPU];
 #endif
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334011 - in head/sys: conf powerpc/powernv

2018-05-21 Thread Justin Hibbits
Author: jhibbits
Date: Tue May 22 02:42:53 2018
New Revision: 334011
URL: https://svnweb.freebsd.org/changeset/base/334011

Log:
  Basic OPAL sensor support for POWER9 platforms
  
  Summary:
  PowerNV architectures (in the test case POWER9) export sensors via the device
  tree, which are accessed via OPAL calls.  This adds sysctl nodes for each
  device in a generic fashion.  New sysctl nodes are:
  
  dev.opal_sensor.N.sensor
  dev.opal_sensor.N.sensor_min
  dev.opal_sensor.N.sensor_max
  dev.opal_sensor.N.type
  dev.opal_sensor.N.label
  
  These are rooted at a parent attachment under opal, called opalsens.  This 
does
  not add support for the "sensor groups" defined in the device tree.
  
  Reviewed by:  breno.leitao_gmail.com
  Differential Revision: https://reviews.freebsd.org/D15362

Added:
  head/sys/powerpc/powernv/opal_sensor.c   (contents, props changed)
Modified:
  head/sys/conf/files.powerpc
  head/sys/powerpc/powernv/opal.h

Modified: head/sys/conf/files.powerpc
==
--- head/sys/conf/files.powerpc Tue May 22 02:13:04 2018(r334010)
+++ head/sys/conf/files.powerpc Tue May 22 02:42:53 2018(r334011)
@@ -189,6 +189,7 @@ powerpc/powernv/opal_dev.c  optionalpowernv
 powerpc/powernv/opal_i2c.c optionaliicbus fdt powernv
 powerpc/powernv/opal_i2cm.coptionaliicbus fdt powernv
 powerpc/powernv/opal_pci.c optionalpowernv pci
+powerpc/powernv/opal_sensor.c  optionalpowernv
 powerpc/powernv/opalcall.S optionalpowernv
 powerpc/powernv/platform_powernv.c optionalpowernv
 powerpc/powernv/powernv_centaur.c  optionalpowernv

Modified: head/sys/powerpc/powernv/opal.h
==
--- head/sys/powerpc/powernv/opal.h Tue May 22 02:13:04 2018
(r334010)
+++ head/sys/powerpc/powernv/opal.h Tue May 22 02:42:53 2018
(r334011)
@@ -72,6 +72,7 @@ int opal_call(uint64_t token, ...);
 #defineOPAL_RETURN_CPU 69
 #defineOPAL_REINIT_CPUS70
 #defineOPAL_CHECK_ASYNC_COMPLETION 86
+#defineOPAL_SENSOR_READ88
 #defineOPAL_I2C_REQUEST109
 #defineOPAL_INT_GET_XIRR   122
 #defineOPAL_INT_SET_CPPR   123
@@ -79,6 +80,9 @@ int opal_call(uint64_t token, ...);
 #defineOPAL_INT_SET_MFRR   125
 #defineOPAL_PCI_TCE_KILL   126
 #defineOPAL_XIVE_RESET 128
+#defineOPAL_SENSOR_GROUP_CLEAR 156
+#defineOPAL_SENSOR_READ_U64162
+#defineOPAL_SENSOR_GROUP_ENABLE163
 
 /* For OPAL_PCI_SET_PE */
 #defineOPAL_UNMAP_PE   0

Added: head/sys/powerpc/powernv/opal_sensor.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/powerpc/powernv/opal_sensor.c  Tue May 22 02:42:53 2018
(r334011)
@@ -0,0 +1,336 @@
+/*-
+ * Copyright (C) 2018 Justin Hibbits
+ *
+ * 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 ``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 TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include "opal.h"
+
+struct opal_sensor_softc {
+   device_t sc_dev;
+   struct mtx   sc_mtx;
+   uint32_t sc_handle;
+   uint32_t sc_min_handle;
+   uint32_t sc_max_handle;
+   char*sc_label;
+   int  sc_type;
+};
+
+#define

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

2018-05-21 Thread Eitan Adler
Author: eadler
Date: Tue May 22 02:13:04 2018
New Revision: 334010
URL: https://svnweb.freebsd.org/changeset/base/334010

Log:
  top(1): unbreak build with gcc7; fix varargs
  
  - use correct function for varargs argument
  - allow build to complete with gcc7 at current WARNS
  
  Reported by:  jhibbits, ian

Modified:
  head/usr.bin/top/commands.c
  head/usr.bin/top/display.c
  head/usr.bin/top/machine.c
  head/usr.bin/top/top.c

Modified: head/usr.bin/top/commands.c
==
--- head/usr.bin/top/commands.c Tue May 22 00:45:00 2018(r334009)
+++ head/usr.bin/top/commands.c Tue May 22 02:13:04 2018(r334010)
@@ -129,11 +129,7 @@ next_field(char *str)
 }
 
 static int
-scanint(str, intp)
-
-char *str;
-int  *intp;
-
+scanint(char *str, int *intp)
 {
 int val = 0;
 char ch;

Modified: head/usr.bin/top/display.c
==
--- head/usr.bin/top/display.c  Tue May 22 00:45:00 2018(r334009)
+++ head/usr.bin/top/display.c  Tue May 22 02:13:04 2018(r334010)
@@ -1011,7 +1011,7 @@ new_message(int type, char *msgfmt, ...)
 va_start(args, msgfmt);
 
 /* first, format the message */
-snprintf(next_msg, sizeof(next_msg), msgfmt, args);
+vsnprintf(next_msg, sizeof(next_msg), msgfmt, args);
 
 va_end(args);
 

Modified: head/usr.bin/top/machine.c
==
--- head/usr.bin/top/machine.c  Tue May 22 00:45:00 2018(r334009)
+++ head/usr.bin/top/machine.c  Tue May 22 02:13:04 2018(r334010)
@@ -762,7 +762,6 @@ get_process_info(struct system_info *si, struct proces
int show_self;
int show_system;
int show_uid;
-   int show_command;
int show_kidle;
 
/*
@@ -832,7 +831,6 @@ get_process_info(struct system_info *si, struct proces
show_self = sel->self == -1;
show_system = sel->system;
show_uid = sel->uid[0] != -1;
-   show_command = sel->command != NULL;
show_kidle = sel->kidle;
 
/* count up process states and get pointers to interesting procs */
@@ -984,8 +982,7 @@ format_next_process(caddr_t xhandle, char *(*get_useri
break;
default:
 
-   if (state >= 0 &&
-   state < sizeof(state_abbrev) / sizeof(*state_abbrev))
+   if (state < sizeof(state_abbrev) / sizeof(*state_abbrev))
sprintf(status, "%.6s", state_abbrev[state]);
else
sprintf(status, "?%5zu", state);

Modified: head/usr.bin/top/top.c
==
--- head/usr.bin/top/top.c  Tue May 22 00:45:00 2018(r334009)
+++ head/usr.bin/top/top.c  Tue May 22 02:13:04 2018(r334010)
@@ -94,7 +94,7 @@ static void (*d_process)(int line, char *thisline) = i
 static void reset_display(void);
 
 static void
-reset_uids()
+reset_uids(void)
 {
 for (size_t i = 0; i < TOP_MAX_UIDS; ++i)
ps.uid[i] = -1;
@@ -198,11 +198,7 @@ end:
 }
 
 int
-main(argc, argv)
-
-int  argc;
-char *argv[];
-
+main(int argc, char *argv[])
 {
 int i;
 int active_procs;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333995 - head/sys/teken

2018-05-21 Thread Bruce Evans

On Mon, 21 May 2018, [UTF-8] Jean-S??bastien P??dron wrote:


Log:
 teken: Rename the "Set Cursor Style" sequence to match vt100.net docs

 This fixes inconsistencies with the rest of the `sequences` file.

 No functional changes.

 Requested by:  ed

Modified: head/sys/teken/sequences
==
--- head/sys/teken/sequencesMon May 21 20:23:04 2018(r333994)
+++ head/sys/teken/sequencesMon May 21 20:35:16 2018(r333995)
@@ -48,7 +48,7 @@ CUF   Cursor Forward  ^[ [ a  
n
CUP Cursor Position ^[ [ H  n n
CUP Cursor Position ^[ [ f  n n
CUU Cursor Up   ^[ [ A  n
-CS Cursor style^[ [ SP q   r
+DECSCUSR   Set Cursor Style^[ [ SP q   r
DA1 Primary Device Attributes   ^[ [ c  r
DA2 Secondary Device Attributes ^[ [ > c r
DC  Delete character^[ [ P  n


Any chance of keeping this file sorted?

DECSCUSR is a verbose yet cryptic abbreviation which is not even expanded
its name.  It is the only abbreviation longer than 7 characters.  This messes
up the souce formatting.

Not expanding DEC in the name is normal, but other letters are normally
expanded.  I don't know what USR is.  It looks like a bad abbreviation
for "user".  'S' in it might mean style.


Modified: head/sys/teken/teken_subr.h
==
--- head/sys/teken/teken_subr.h Mon May 21 20:23:04 2018(r333994)
+++ head/sys/teken/teken_subr.h Mon May 21 20:35:16 2018(r333995)
@@ -372,7 +372,7 @@ teken_subr_cursor_up(teken_t *t, unsigned int nrows)
}

static void
-teken_subr_cursor_style(teken_t *t, unsigned int style)
+teken_subr_set_cursor_style(teken_t *t, unsigned int style)
{

/* TODO */


Names must be chosen carefully since they become function names which tend
to be long and ugly.  This one is not long but is a bit to generic.  The
worst function name double_height_double_width_line_bottom() has one of
the best abbreviations (DECDHL).  DEC is mercifully not spelled out in the
function name, and Double Width Bottom is omitted from the abbreviation.

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


svn commit: r334009 - in head/sys: amd64/amd64 amd64/include amd64/vmm/amd amd64/vmm/intel i386/i386 i386/include x86/include

2018-05-21 Thread John Baldwin
Author: jhb
Date: Tue May 22 00:45:00 2018
New Revision: 334009
URL: https://svnweb.freebsd.org/changeset/base/334009

Log:
  Cleanups related to debug exceptions on x86.
  
  - Add constants for fields in DR6 and the reserved fields in DR7.  Use
these constants instead of magic numbers in most places that use DR6
and DR7.
  - Refer to T_TRCTRAP as "debug exception" rather than a "trace trap"
as it is not just for trace exceptions.
  - Always read DR6 for debug exceptions and only clear TF in the flags
register for user exceptions where DR6.BS is set.
  - Clear DR6 before returning from a debug exception handler as
recommended by the SDM dating all the way back to the 386.  This
allows debuggers to determine the cause of each exception.  For
kernel traps, clear DR6 in the T_TRCTRAP case and pass DR6 by value
to other parts of the handler (namely, user_dbreg_trap()).  For user
traps, wait until after trapsignal to clear DR6 so that userland
debuggers can read DR6 via PT_GETDBREGS while the thread is stopped
in trapsignal().
  
  Reviewed by:  kib, rgrimes
  MFC after:1 month
  Differential Revision:https://reviews.freebsd.org/D15189

Modified:
  head/sys/amd64/amd64/machdep.c
  head/sys/amd64/amd64/trap.c
  head/sys/amd64/include/db_machdep.h
  head/sys/amd64/vmm/amd/svm.c
  head/sys/amd64/vmm/intel/vmx.c
  head/sys/i386/i386/machdep.c
  head/sys/i386/i386/trap.c
  head/sys/i386/include/db_machdep.h
  head/sys/x86/include/reg.h
  head/sys/x86/include/x86_var.h

Modified: head/sys/amd64/amd64/machdep.c
==
--- head/sys/amd64/amd64/machdep.c  Mon May 21 21:52:48 2018
(r334008)
+++ head/sys/amd64/amd64/machdep.c  Tue May 22 00:45:00 2018
(r334009)
@@ -2486,14 +2486,23 @@ reset_dbregs(void)
  * breakpoint was in user space.  Return 0, otherwise.
  */
 int
-user_dbreg_trap(void)
+user_dbreg_trap(register_t dr6)
 {
-u_int64_t dr7, dr6; /* debug registers dr6 and dr7 */
+u_int64_t dr7;
 u_int64_t bp;   /* breakpoint bits extracted from dr6 */
 int nbp;/* number of breakpoints that triggered */
 caddr_t addr[4];/* breakpoint addresses */
 int i;
-
+
+bp = dr6 & DBREG_DR6_BMASK;
+if (bp == 0) {
+/*
+ * None of the breakpoint bits are set meaning this
+ * trap was not caused by any of the debug registers
+ */
+return 0;
+}
+
 dr7 = rdr7();
 if ((dr7 & 0x00ff) == 0) {
 /*
@@ -2505,16 +2514,6 @@ user_dbreg_trap(void)
 }
 
 nbp = 0;
-dr6 = rdr6();
-bp = dr6 & 0x000f;
-
-if (!bp) {
-/*
- * None of the breakpoint bits are set meaning this
- * trap was not caused by any of the debug registers
- */
-return 0;
-}
 
 /*
  * at least one of the breakpoints were hit, check to see

Modified: head/sys/amd64/amd64/trap.c
==
--- head/sys/amd64/amd64/trap.c Mon May 21 21:52:48 2018(r334008)
+++ head/sys/amd64/amd64/trap.c Tue May 22 00:45:00 2018(r334009)
@@ -126,7 +126,7 @@ static char *trap_msg[] = {
"", /*  7 unused */
"", /*  8 unused */
"general protection fault", /*  9 T_PROTFLT */
-   "trace trap",   /* 10 T_TRCTRAP */
+   "debug exception",  /* 10 T_TRCTRAP */
"", /* 11 unused */
"page fault",   /* 12 T_PAGEFLT */
"", /* 13 unused */
@@ -173,10 +173,7 @@ trap(struct trapframe *frame)
ksiginfo_t ksi;
struct thread *td;
struct proc *p;
-   register_t addr;
-#ifdef KDB
-   register_t dr6;
-#endif
+   register_t addr, dr6;
int signo, ucode;
u_int type;
 
@@ -185,6 +182,7 @@ trap(struct trapframe *frame)
signo = 0;
ucode = 0;
addr = 0;
+   dr6 = 0;
 
VM_CNT_INC(v_trap);
type = frame->tf_trapno;
@@ -272,20 +270,25 @@ trap(struct trapframe *frame)
break;
 
case T_BPTFLT:  /* bpt instruction fault */
-   case T_TRCTRAP: /* trace trap */
enable_intr();
 #ifdef KDTRACE_HOOKS
-   if (type == T_BPTFLT) {
-   if (dtrace_pid_probe_ptr != NULL &&
-   dtrace_pid_probe_ptr(frame) == 0)
-   return;
-   }
+   if 

Re: svn commit: r333962 - head/usr.bin/top

2018-05-21 Thread John Baldwin
On Monday, May 21, 2018 04:40:20 AM Eitan Adler wrote:
> Author: eadler
> Date: Mon May 21 04:40:20 2018
> New Revision: 333962
> URL: https://svnweb.freebsd.org/changeset/base/333962
> 
> Log:
>   top(1): further unconditionally assume we're on FreeBSD
> 
> Modified:
>   head/usr.bin/top/loadavg.h
>   head/usr.bin/top/machine.c
>   head/usr.bin/top/machine.h
>   head/usr.bin/top/top.c
> 
> Modified: head/usr.bin/top/top.c
> ==
> --- head/usr.bin/top/top.cMon May 21 04:32:14 2018(r333961)
> +++ head/usr.bin/top/top.cMon May 21 04:40:20 2018(r333962)
> @@ -403,7 +403,7 @@ char *argv[];
>   if (getuid() == 0)
>   {
>   /* be very un-nice! */
> - (void) nice(-20);
> + nice(-20);

FreeBSD doesn't support (void) casts?  (That's the only reasoning I can infer
from the log message.)  I believe that using these provides hints to static
analyzers to indicate that normally the return value should be checked for
certain functions but it is not needed in specific cases (permitting the
analyzer to warn about missing checks of return values in other cases).

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


svn commit: r334008 - head/bin/sh

2018-05-21 Thread Jilles Tjoelker
Author: jilles
Date: Mon May 21 21:52:48 2018
New Revision: 334008
URL: https://svnweb.freebsd.org/changeset/base/334008

Log:
  sh: Split CNL syntax category to avoid a check on state[level].syntax
  
  No functional change is intended.

Modified:
  head/bin/sh/mksyntax.c
  head/bin/sh/parser.c

Modified: head/bin/sh/mksyntax.c
==
--- head/bin/sh/mksyntax.c  Mon May 21 21:44:47 2018(r334007)
+++ head/bin/sh/mksyntax.c  Mon May 21 21:52:48 2018(r334008)
@@ -65,6 +65,7 @@ struct synclass {
 static const struct synclass synclass[] = {
{ "CWORD",  "character is nothing special" },
{ "CNL","newline character" },
+   { "CQNL",   "newline character in quotes" },
{ "CBACK",  "a backslash character" },
{ "CSBACK", "a backslash character in single quotes" },
{ "CSQUOTE","single quote" },
@@ -185,7 +186,7 @@ main(int argc __unused, char **argv __unused)
fputs("\n/* syntax table used when in double quotes */\n", cfile);
init("dqsyntax");
add_default();
-   add("\n", "CNL");
+   add("\n", "CQNL");
add("\\", "CBACK");
add("\"", "CENDQUOTE");
add("`", "CBQUOTE");
@@ -198,7 +199,7 @@ main(int argc __unused, char **argv __unused)
fputs("\n/* syntax table used when in single quotes */\n", cfile);
init("sqsyntax");
add_default();
-   add("\n", "CNL");
+   add("\n", "CQNL");
add("\\", "CSBACK");
add("'", "CENDQUOTE");
/* ':/' for tilde expansion, '-^]' for [a\-x] pattern ranges */
@@ -208,7 +209,7 @@ main(int argc __unused, char **argv __unused)
fputs("\n/* syntax table used when in arithmetic */\n", cfile);
init("arisyntax");
add_default();
-   add("\n", "CNL");
+   add("\n", "CQNL");
add("\\", "CBACK");
add("`", "CBQUOTE");
add("\"", "CIGN");

Modified: head/bin/sh/parser.c
==
--- head/bin/sh/parser.cMon May 21 21:44:47 2018(r334007)
+++ head/bin/sh/parser.cMon May 21 21:52:48 2018(r334008)
@@ -1434,9 +1434,10 @@ readtoken1(int firstc, char const *initialsyntax, cons
 
switch(synentry) {
case CNL:   /* '\n' */
-   if (level == 0 &&
-   state[level].syntax == BASESYNTAX)
+   if (level == 0)
goto endword;   /* exit outer loop */
+   /* FALLTHROUGH */
+   case CQNL:
USTPUTC(c, out);
plinno++;
if (doprompt)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334007 - head/etc/devd

2018-05-21 Thread Emmanuel Vadot
Author: manu
Date: Mon May 21 21:44:47 2018
New Revision: 334007
URL: https://svnweb.freebsd.org/changeset/base/334007

Log:
  devd: Always install devmatch.conf
  
  It allows devd to run devmatch to find the correct driver based on pnp info.
  
  No Objection from:imp

Modified:
  head/etc/devd/Makefile

Modified: head/etc/devd/Makefile
==
--- head/etc/devd/Makefile  Mon May 21 21:15:46 2018(r334006)
+++ head/etc/devd/Makefile  Mon May 21 21:44:47 2018(r334007)
@@ -4,6 +4,8 @@
 
 FILEGROUPS=FILES
 
+FILES+=devmatch.conf
+
 .if ${MACHINE} == "powerpc"
 FILES+=apple.conf
 .endif
@@ -12,7 +14,6 @@ FILES+=   apple.conf
 .if ${MK_ACPI} != "no"
 FILES+=asus.conf
 .endif
-FILES+=devmatch.conf
 .if ${MK_HYPERV} != "no"
 FILES+=hyperv.conf
 .endif
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334006 - head/sys/arm/allwinner

2018-05-21 Thread Emmanuel Vadot
Author: manu
Date: Mon May 21 21:15:46 2018
New Revision: 334006
URL: https://svnweb.freebsd.org/changeset/base/334006

Log:
  aw_mmc: Correctly reset the mmc controller
  
  Always disable FIFO access as we don't use it.
  Rename some register bits so they are in sync with the register name.
  
  While here add my copyright as I've probably wrote 70% of the code here.

Modified:
  head/sys/arm/allwinner/aw_mmc.c
  head/sys/arm/allwinner/aw_mmc.h

Modified: head/sys/arm/allwinner/aw_mmc.c
==
--- head/sys/arm/allwinner/aw_mmc.c Mon May 21 21:08:19 2018
(r334005)
+++ head/sys/arm/allwinner/aw_mmc.c Mon May 21 21:15:46 2018
(r334006)
@@ -1,4 +1,7 @@
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018 Emmanuel Vadot 
  * Copyright (c) 2013 Alexander Fedorov
  * All rights reserved.
  *
@@ -431,12 +434,12 @@ aw_mmc_prepare_dma(struct aw_mmc_softc *sc)
 
/* Enable DMA */
val = AW_MMC_READ_4(sc, AW_MMC_GCTL);
-   val &= ~AW_MMC_CTRL_FIFO_AC_MOD;
-   val |= AW_MMC_CTRL_DMA_ENB;
+   val &= ~AW_MMC_GCTL_FIFO_AC_MOD;
+   val |= AW_MMC_GCTL_DMA_ENB;
AW_MMC_WRITE_4(sc, AW_MMC_GCTL, val);
 
/* Reset DMA */
-   val |= AW_MMC_CTRL_DMA_RST;
+   val |= AW_MMC_GCTL_DMA_RST;
AW_MMC_WRITE_4(sc, AW_MMC_GCTL, val);
 
AW_MMC_WRITE_4(sc, AW_MMC_DMAC, AW_MMC_DMAC_IDMAC_SOFT_RST);
@@ -463,12 +466,15 @@ aw_mmc_prepare_dma(struct aw_mmc_softc *sc)
 static int
 aw_mmc_reset(struct aw_mmc_softc *sc)
 {
+   uint32_t reg;
int timeout;
 
-   AW_MMC_WRITE_4(sc, AW_MMC_GCTL, AW_MMC_RESET);
+   reg = AW_MMC_READ_4(sc, AW_MMC_GCTL);
+   reg |= AW_MMC_GCTL_RESET;
+   AW_MMC_WRITE_4(sc, AW_MMC_GCTL, reg);
timeout = 1000;
while (--timeout > 0) {
-   if ((AW_MMC_READ_4(sc, AW_MMC_GCTL) & AW_MMC_RESET) == 0)
+   if ((AW_MMC_READ_4(sc, AW_MMC_GCTL) & AW_MMC_GCTL_RESET) == 0)
break;
DELAY(100);
}
@@ -481,6 +487,7 @@ aw_mmc_reset(struct aw_mmc_softc *sc)
 static int
 aw_mmc_init(struct aw_mmc_softc *sc)
 {
+   uint32_t reg;
int ret;
 
ret = aw_mmc_reset(sc);
@@ -506,9 +513,12 @@ aw_mmc_init(struct aw_mmc_softc *sc)
 
AW_MMC_WRITE_4(sc, AW_MMC_IDST, 0x);
 
-   /* Enable interrupts and AHB access. */
-   AW_MMC_WRITE_4(sc, AW_MMC_GCTL,
-   AW_MMC_READ_4(sc, AW_MMC_GCTL) | AW_MMC_CTRL_INT_ENB);
+   /* Enable interrupts and disable AHB access. */
+   reg = AW_MMC_READ_4(sc, AW_MMC_GCTL);
+   reg |= AW_MMC_GCTL_INT_ENB;
+   reg &= ~AW_MMC_GCTL_FIFO_AC_MOD;
+   reg &= ~AW_MMC_GCTL_WAIT_MEM_ACCESS;
+   AW_MMC_WRITE_4(sc, AW_MMC_GCTL, reg);
 
return (0);
 }
@@ -524,7 +534,7 @@ aw_mmc_req_done(struct aw_mmc_softc *sc)
cmd = sc->aw_req->cmd;
if (cmd->error != MMC_ERR_NONE) {
/* Reset the FIFO and DMA engines. */
-   mask = AW_MMC_CTRL_FIFO_RST | AW_MMC_CTRL_DMA_RST;
+   mask = AW_MMC_GCTL_FIFO_RST | AW_MMC_GCTL_DMA_RST;
val = AW_MMC_READ_4(sc, AW_MMC_GCTL);
AW_MMC_WRITE_4(sc, AW_MMC_GCTL, val | mask);
 
@@ -998,9 +1008,9 @@ aw_mmc_update_ios(device_t bus, device_t child)
reg = AW_MMC_READ_4(sc, AW_MMC_GCTL);
if (ios->timing == bus_timing_uhs_ddr50 ||
  ios->timing == bus_timing_mmc_ddr52)
-   reg |= AW_MMC_CTRL_DDR_MOD_SEL;
+   reg |= AW_MMC_GCTL_DDR_MOD_SEL;
else
-   reg &= ~AW_MMC_CTRL_DDR_MOD_SEL;
+   reg &= ~AW_MMC_GCTL_DDR_MOD_SEL;
AW_MMC_WRITE_4(sc, AW_MMC_GCTL, reg);
 
if (ios->clock && ios->clock != sc->aw_clock) {

Modified: head/sys/arm/allwinner/aw_mmc.h
==
--- head/sys/arm/allwinner/aw_mmc.h Mon May 21 21:08:19 2018
(r334005)
+++ head/sys/arm/allwinner/aw_mmc.h Mon May 21 21:15:46 2018
(r334006)
@@ -1,4 +1,7 @@
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018 Emmanuel Vadot 
  * Copyright (c) 2013 Alexander Fedorov 
  * All rights reserved.
  *
@@ -66,16 +69,17 @@
 #defineA31_MMC_FIFO0x200   /* FIFO Access Address (A31) */
 
 /* AW_MMC_GCTL */
-#defineAW_MMC_CTRL_SOFT_RST(1U << 0)
-#defineAW_MMC_CTRL_FIFO_RST(1U << 1)
-#defineAW_MMC_CTRL_DMA_RST (1U << 2)
-#defineAW_MMC_CTRL_INT_ENB (1U << 4)
-#defineAW_MMC_CTRL_DMA_ENB (1U << 5)
-#defineAW_MMC_CTRL_CD_DBC_ENB  (1U << 8)
-#defineAW_MMC_CTRL_DDR_MOD_SEL (1U << 10)
-#defineAW_MMC_CTRL_FIFO_AC_MOD (1U << 31)
-#defineAW_MMC_RESET

svn commit: r334005 - in head/sys: amd64/amd64 amd64/include dev/cpuctl x86/acpica x86/include x86/x86

2018-05-21 Thread Konstantin Belousov
Author: kib
Date: Mon May 21 21:08:19 2018
New Revision: 334005
URL: https://svnweb.freebsd.org/changeset/base/334005

Log:
  Add Intel Spec Store Bypass Disable control.
  
  Speculative Store Bypass (SSB) is a speculative execution side channel
  vulnerability identified by Jann Horn of Google Project Zero (GPZ) and
  Ken Johnson of the Microsoft Security Response Center (MSRC)
  https://bugs.chromium.org/p/project-zero/issues/detail?id=1528.
  Updated Intel microcode introduces a MSR bit to disable SSB as a
  mitigation for the vulnerability.
  
  Introduce a sysctl hw.spec_store_bypass_disable to provide global
  control over the SSBD bit, akin to the existing sysctl that controls
  IBRS. The sysctl can be set to one of three values:
  0: off
  1: on
  2: auto
  
  Future work will enable applications to control SSBD on a per-process
  basis (when it is not enabled globally).
  
  SSBD bit detection and control was verified with prerelease microcode.
  
  Security: CVE-2018-3639
  Tested by:emaste (previous version, without updated microcode)
  Sponsored by: The FreeBSD Foundation
  MFC after:3 days

Modified:
  head/sys/amd64/amd64/initcpu.c
  head/sys/amd64/amd64/machdep.c
  head/sys/amd64/include/md_var.h
  head/sys/dev/cpuctl/cpuctl.c
  head/sys/x86/acpica/acpi_wakeup.c
  head/sys/x86/include/x86_var.h
  head/sys/x86/x86/cpu_machdep.c

Modified: head/sys/amd64/amd64/initcpu.c
==
--- head/sys/amd64/amd64/initcpu.c  Mon May 21 21:07:13 2018
(r334004)
+++ head/sys/amd64/amd64/initcpu.c  Mon May 21 21:08:19 2018
(r334005)
@@ -224,6 +224,7 @@ initializecpu(void)
pg_nx = PG_NX;
}
hw_ibrs_recalculate();
+   hw_ssb_recalculate(false);
switch (cpu_vendor_id) {
case CPU_VENDOR_AMD:
init_amd();

Modified: head/sys/amd64/amd64/machdep.c
==
--- head/sys/amd64/amd64/machdep.c  Mon May 21 21:07:13 2018
(r334004)
+++ head/sys/amd64/amd64/machdep.c  Mon May 21 21:08:19 2018
(r334005)
@@ -1843,6 +1843,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
thread0.td_critnest = 0;
 
TUNABLE_INT_FETCH("hw.ibrs_disable", _ibrs_disable);
+   TUNABLE_INT_FETCH("hw.spec_store_bypass_disable", _ssb_disable);
 
TSEXIT();
 

Modified: head/sys/amd64/include/md_var.h
==
--- head/sys/amd64/include/md_var.h Mon May 21 21:07:13 2018
(r334004)
+++ head/sys/amd64/include/md_var.h Mon May 21 21:08:19 2018
(r334005)
@@ -39,6 +39,7 @@
 extern uint64_t*vm_page_dump;
 extern int hw_lower_amd64_sharedpage;
 extern int hw_ibrs_disable;
+extern int hw_ssb_disable;
 
 /*
  * The file "conf/ldscript.amd64" defines the symbol "kernphys".  Its

Modified: head/sys/dev/cpuctl/cpuctl.c
==
--- head/sys/dev/cpuctl/cpuctl.cMon May 21 21:07:13 2018
(r334004)
+++ head/sys/dev/cpuctl/cpuctl.cMon May 21 21:08:19 2018
(r334005)
@@ -529,6 +529,7 @@ cpuctl_do_eval_cpu_features(int cpu, struct thread *td
identify_cpu2();
hw_ibrs_recalculate();
restore_cpu(oldcpu, is_bound, td);
+   hw_ssb_recalculate(true);
printcpuinfo();
return (0);
 }

Modified: head/sys/x86/acpica/acpi_wakeup.c
==
--- head/sys/x86/acpica/acpi_wakeup.c   Mon May 21 21:07:13 2018
(r334004)
+++ head/sys/x86/acpica/acpi_wakeup.c   Mon May 21 21:08:19 2018
(r334005)
@@ -244,6 +244,7 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state)
 #endif
 #ifdef __amd64__
hw_ibrs_active = 0;
+   hw_ssb_active = 0;
cpu_stdext_feature3 = 0;
CPU_FOREACH(i) {
pc = pcpu_find(i);

Modified: head/sys/x86/include/x86_var.h
==
--- head/sys/x86/include/x86_var.h  Mon May 21 21:07:13 2018
(r334004)
+++ head/sys/x86/include/x86_var.h  Mon May 21 21:08:19 2018
(r334005)
@@ -85,6 +85,7 @@ externuint64_t xsave_mask;
 extern u_int   max_apic_id;
 extern int pti;
 extern int hw_ibrs_active;
+extern int hw_ssb_active;
 
 struct pcb;
 struct thread;
@@ -137,6 +138,7 @@ int isa_nmi(int cd);
 void   handle_ibrs_entry(void);
 void   handle_ibrs_exit(void);
 void   hw_ibrs_recalculate(void);
+void   hw_ssb_recalculate(bool all_cpus);
 void   nmi_call_kdb(u_int cpu, u_int type, struct trapframe *frame);
 void   nmi_call_kdb_smp(u_int type, struct trapframe *frame);
 void   nmi_handle_intr(u_int type, struct trapframe *frame);

Modified: 

svn commit: r334004 - in head/sys/x86: include x86

2018-05-21 Thread Konstantin Belousov
Author: kib
Date: Mon May 21 21:07:13 2018
New Revision: 334004
URL: https://svnweb.freebsd.org/changeset/base/334004

Log:
  Add definition for Intel Speculative Store Bypass Disable MSR bits
  
  Security: CVE-2018-3639
  Sponsored by: The FreeBSD Foundation
  MFC after:3 days

Modified:
  head/sys/x86/include/specialreg.h
  head/sys/x86/x86/identcpu.c

Modified: head/sys/x86/include/specialreg.h
==
--- head/sys/x86/include/specialreg.h   Mon May 21 21:05:55 2018
(r334003)
+++ head/sys/x86/include/specialreg.h   Mon May 21 21:07:13 2018
(r334004)
@@ -428,10 +428,12 @@
 #defineCPUID_STDEXT3_IBPB  0x0400
 #defineCPUID_STDEXT3_STIBP 0x0800
 #defineCPUID_STDEXT3_ARCH_CAP  0x2000
+#defineCPUID_STDEXT3_SSBD  0x8000
 
 /* MSR IA32_ARCH_CAP(ABILITIES) bits */
 #defineIA32_ARCH_CAP_RDCL_NO   0x0001
 #defineIA32_ARCH_CAP_IBRS_ALL  0x0002
+#defineIA32_ARCH_CAP_SSBD_NO   0x0004
 
 /*
  * CPUID manufacturers identifiers
@@ -704,6 +706,7 @@
 /* MSR IA32_SPEC_CTRL */
 #defineIA32_SPEC_CTRL_IBRS 0x0001
 #defineIA32_SPEC_CTRL_STIBP0x0002
+#defineIA32_SPEC_CTRL_SSBD 0x0004
 
 /* MSR IA32_PRED_CMD */
 #defineIA32_PRED_CMD_IBPB_BARRIER  0x0001ULL

Modified: head/sys/x86/x86/identcpu.c
==
--- head/sys/x86/x86/identcpu.c Mon May 21 21:05:55 2018(r334003)
+++ head/sys/x86/x86/identcpu.c Mon May 21 21:07:13 2018(r334004)
@@ -990,6 +990,7 @@ printcpuinfo(void)
   "\033IBPB"
   "\034STIBP"
   "\036ARCH_CAP"
+  "\040SSBD"
   );
}
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334003 - head/sys/amd64/amd64

2018-05-21 Thread Konstantin Belousov
Author: kib
Date: Mon May 21 21:05:55 2018
New Revision: 334003
URL: https://svnweb.freebsd.org/changeset/base/334003

Log:
  Preserve other bits in IA32_SPEC_CTL MSR when changing the IBRS and
  STIBP states.
  
  Tested by:emaste (previous version)
  Sponsored by: The FreeBSD Foundation
  MFC after:3 days

Modified:
  head/sys/amd64/amd64/support.S

Modified: head/sys/amd64/amd64/support.S
==
--- head/sys/amd64/amd64/support.S  Mon May 21 21:04:31 2018
(r334002)
+++ head/sys/amd64/amd64/support.S  Mon May 21 21:05:55 2018
(r334003)
@@ -958,8 +958,9 @@ ENTRY(handle_ibrs_entry)
cmpb$0,hw_ibrs_active(%rip)
je  1f
movl$MSR_IA32_SPEC_CTRL,%ecx
-   movl$(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP),%eax
-   movl$(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP)>>32,%edx
+   rdmsr
+   orl $(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP),%eax
+   orl $(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP)>>32,%edx
wrmsr
movb$1,PCPU(IBPB_SET)
testl   $CPUID_STDEXT_SMEP,cpu_stdext_feature(%rip)
@@ -972,8 +973,9 @@ ENTRY(handle_ibrs_exit)
cmpb$0,PCPU(IBPB_SET)
je  1f
movl$MSR_IA32_SPEC_CTRL,%ecx
-   xorl%eax,%eax
-   xorl%edx,%edx
+   rdmsr
+   andl$~(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP),%eax
+   andl$~((IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP)>>32),%edx
wrmsr
movb$0,PCPU(IBPB_SET)
 1: ret
@@ -987,8 +989,9 @@ ENTRY(handle_ibrs_exit_rs)
pushq   %rdx
pushq   %rcx
movl$MSR_IA32_SPEC_CTRL,%ecx
-   xorl%eax,%eax
-   xorl%edx,%edx
+   rdmsr
+   andl$~(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP),%eax
+   andl$~((IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP)>>32),%edx
wrmsr
popq%rcx
popq%rdx
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334000 - head/sys/dev/usb/serial

2018-05-21 Thread Andriy Gapon
Author: avg
Date: Mon May 21 21:00:13 2018
New Revision: 334000
URL: https://svnweb.freebsd.org/changeset/base/334000

Log:
  uchcom: reject parity and double stop bits as unsupported
  
  Reviewed by:  hselasky
  MFC after:2 weeks

Modified:
  head/sys/dev/usb/serial/uchcom.c

Modified: head/sys/dev/usb/serial/uchcom.c
==
--- head/sys/dev/usb/serial/uchcom.cMon May 21 20:59:15 2018
(r333999)
+++ head/sys/dev/usb/serial/uchcom.cMon May 21 21:00:13 2018
(r334000)
@@ -689,6 +689,10 @@ uchcom_pre_param(struct ucom_softc *ucom, struct termi
default:
return (EIO);
}
+   if ((t->c_cflag & CSTOPB) != 0)
+   return (EIO);
+   if ((t->c_cflag & PARENB) != 0)
+   return (EIO);
 
if (uchcom_calc_divider_settings(, t->c_ospeed)) {
return (EIO);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334002 - head/sys/dev/usb/serial

2018-05-21 Thread Andriy Gapon
Author: avg
Date: Mon May 21 21:04:31 2018
New Revision: 334002
URL: https://svnweb.freebsd.org/changeset/base/334002

Log:
  uchcom: extend hardware support to version 0x30
  
  This change adds support for a UBS<->RS232 adapter based on CH340 (or an
  analogue) that I own.  The device seems to have a newer internal version
  (0x30) and the existing code incorrectly configures line control for it
  resulting in garbled transmission.  The changes are based on what I
  learned in Linux drivers for the same hardware.
  
  Additional changes:
  - use UCHCOM_REG_LCR1 / UCHCOM_REG_LCR2 instead of explicit 0x18 and
0x25
  - use NULL instead of 0 where a pointer is expected
  
  Reviewed by:  hselasky
  MFC after:3 weeks
  Differential Revision: https://reviews.freebsd.org/D15498

Modified:
  head/sys/dev/usb/serial/uchcom.c

Modified: head/sys/dev/usb/serial/uchcom.c
==
--- head/sys/dev/usb/serial/uchcom.cMon May 21 21:02:10 2018
(r334001)
+++ head/sys/dev/usb/serial/uchcom.cMon May 21 21:04:31 2018
(r334002)
@@ -126,6 +126,7 @@ SYSCTL_INT(_hw_usb_uchcom, OID_AUTO, debug, CTLFLAG_RW
 #defineUCHCOM_REG_LCR2 0x25
 
 #defineUCHCOM_VER_20   0x20
+#defineUCHCOM_VER_30   0x30
 
 #defineUCHCOM_BASE_UNKNOWN 0
 #defineUCHCOM_BPS_MOD_BASE 2000
@@ -706,11 +707,26 @@ uchcom_cfg_param(struct ucom_softc *ucom, struct termi
 {
struct uchcom_softc *sc = ucom->sc_parent;
 
-   uchcom_get_version(sc, 0);
+   uchcom_get_version(sc, NULL);
uchcom_ctrl_write(sc, UCHCOM_REQ_RESET, 0, 0);
uchcom_set_baudrate(sc, t->c_ospeed);
-   uchcom_read_reg(sc, 0x18, 0, 0x25, 0);
-   uchcom_write_reg(sc, 0x18, 0x50, 0x25, 0x00);
+   if (sc->sc_version < UCHCOM_VER_30) {
+   uchcom_read_reg(sc, UCHCOM_REG_LCR1, NULL,
+   UCHCOM_REG_LCR2, NULL);
+   uchcom_write_reg(sc, UCHCOM_REG_LCR1, 0x50,
+   UCHCOM_REG_LCR2, 0x00);
+   } else {
+   /*
+* Set up line control:
+* - enable transmit and receive
+* - set 8n1 mode
+* To do: support other sizes, parity, stop bits.
+*/
+   uchcom_write_reg(sc,
+   UCHCOM_REG_LCR1,
+   UCHCOM_LCR1_RX | UCHCOM_LCR1_TX | UCHCOM_LCR1_CS8,
+   UCHCOM_REG_LCR2, 0x00);
+   }
uchcom_update_status(sc);
uchcom_ctrl_write(sc, UCHCOM_REQ_RESET, 0x501f, 0xd90a);
uchcom_set_baudrate(sc, t->c_ospeed);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334001 - head/sys/dev/usb/serial

2018-05-21 Thread Andriy Gapon
Author: avg
Date: Mon May 21 21:02:10 2018
New Revision: 334001
URL: https://svnweb.freebsd.org/changeset/base/334001

Log:
  uchcom: remove UCHCOM_REG_BREAK2 alias of UCHCOM_REG_LCR1
  
  Also, add definitions for more bits of UCHCOM_REG_LCR1 as seen in the
  Linux driver.  UCHCOM_LCR1_PARENB definition was different from that in
  the Linux driver and clashed with newly added UCHCOM_LCR1_RX.  I took a
  liberty to change UCHCOM_LCR1_PARENB to the Linux definition as it was
  unused in the driver anyway.  This change should make
  uchcom_cfg_set_break() easier to understand.
  
  Approved by:  hselasky
  MFC after:2 weeks

Modified:
  head/sys/dev/usb/serial/uchcom.c

Modified: head/sys/dev/usb/serial/uchcom.c
==
--- head/sys/dev/usb/serial/uchcom.cMon May 21 21:00:13 2018
(r334000)
+++ head/sys/dev/usb/serial/uchcom.cMon May 21 21:02:10 2018
(r334001)
@@ -122,7 +122,6 @@ SYSCTL_INT(_hw_usb_uchcom, OID_AUTO, debug, CTLFLAG_RW
 #defineUCHCOM_REG_BPS_MOD  0x14
 #defineUCHCOM_REG_BPS_PAD  0x0F
 #defineUCHCOM_REG_BREAK1   0x05
-#defineUCHCOM_REG_BREAK2   0x18
 #defineUCHCOM_REG_LCR1 0x18
 #defineUCHCOM_REG_LCR2 0x25
 
@@ -135,12 +134,14 @@ SYSCTL_INT(_hw_usb_uchcom, OID_AUTO, debug, CTLFLAG_RW
 #defineUCHCOM_DTR_MASK 0x20
 #defineUCHCOM_RTS_MASK 0x40
 
-#defineUCHCOM_BRK1_MASK0x01
-#defineUCHCOM_BRK2_MASK0x40
+#defineUCHCOM_BRK_MASK 0x01
 
 #defineUCHCOM_LCR1_MASK0xAF
 #defineUCHCOM_LCR2_MASK0x07
-#defineUCHCOM_LCR1_PARENB  0x80
+#defineUCHCOM_LCR1_RX  0x80
+#defineUCHCOM_LCR1_TX  0x40
+#defineUCHCOM_LCR1_PARENB  0x08
+#defineUCHCOM_LCR1_CS8 0x03
 #defineUCHCOM_LCR2_PAREVEN 0x07
 #defineUCHCOM_LCR2_PARODD  0x06
 #defineUCHCOM_LCR2_PARMARK 0x05
@@ -556,17 +557,17 @@ uchcom_cfg_set_break(struct ucom_softc *ucom, uint8_t 
uint8_t brk1;
uint8_t brk2;
 
-   uchcom_read_reg(sc, UCHCOM_REG_BREAK1, , UCHCOM_REG_BREAK2, );
+   uchcom_read_reg(sc, UCHCOM_REG_BREAK1, , UCHCOM_REG_LCR1, );
if (onoff) {
/* on - clear bits */
-   brk1 &= ~UCHCOM_BRK1_MASK;
-   brk2 &= ~UCHCOM_BRK2_MASK;
+   brk1 &= ~UCHCOM_BRK_MASK;
+   brk2 &= ~UCHCOM_LCR1_TX;
} else {
/* off - set bits */
-   brk1 |= UCHCOM_BRK1_MASK;
-   brk2 |= UCHCOM_BRK2_MASK;
+   brk1 |= UCHCOM_BRK_MASK;
+   brk2 |= UCHCOM_LCR1_TX;
}
-   uchcom_write_reg(sc, UCHCOM_REG_BREAK1, brk1, UCHCOM_REG_BREAK2, brk2);
+   uchcom_write_reg(sc, UCHCOM_REG_BREAK1, brk1, UCHCOM_REG_LCR1, brk2);
 }
 
 static int
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333997 - head/sys/dev/usb/serial

2018-05-21 Thread Andriy Gapon
Author: avg
Date: Mon May 21 20:57:14 2018
New Revision: 333997
URL: https://svnweb.freebsd.org/changeset/base/333997

Log:
  uchcom: report detected product based on USB product ID
  
  Product IDs are specified in vendor documents.  The previously used
  device ID is not.  This is a cosmetic change.  No functionality depends
  on those IDs.
  
  Reviewed by:  hselasky
  MFC after:2 weeks

Modified:
  head/sys/dev/usb/serial/uchcom.c

Modified: head/sys/dev/usb/serial/uchcom.c
==
--- head/sys/dev/usb/serial/uchcom.cMon May 21 20:54:54 2018
(r333996)
+++ head/sys/dev/usb/serial/uchcom.cMon May 21 20:57:14 2018
(r333997)
@@ -322,12 +322,16 @@ uchcom_attach(device_t dev)
 
sc->sc_udev = uaa->device;
 
-   switch (uaa->info.bcdDevice) {
-   case UCHCOM_REV_CH340:
+   switch (uaa->info.idProduct) {
+   case USB_PRODUCT_WCH2_CH341SER:
device_printf(dev, "CH340 detected\n");
break;
-   default:
+   case USB_PRODUCT_WCH2_CH341SER_2:
device_printf(dev, "CH341 detected\n");
+   break;
+   default:
+   device_printf(dev, "New CH340/CH341 product 0x%04x detected\n",
+   uaa->info.idProduct);
break;
}
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333999 - head/sys/dev/usb/serial

2018-05-21 Thread Andriy Gapon
Author: avg
Date: Mon May 21 20:59:15 2018
New Revision: 333999
URL: https://svnweb.freebsd.org/changeset/base/333999

Log:
  uchcom: add a hardware configuration tweak seen in Linux code
  
  Reviewed by:  hselasky
  MFC after:2 weeks

Modified:
  head/sys/dev/usb/serial/uchcom.c

Modified: head/sys/dev/usb/serial/uchcom.c
==
--- head/sys/dev/usb/serial/uchcom.cMon May 21 20:58:06 2018
(r333998)
+++ head/sys/dev/usb/serial/uchcom.cMon May 21 20:59:15 2018
(r333999)
@@ -618,8 +618,12 @@ uchcom_set_baudrate(struct uchcom_softc *sc, uint32_t 
if (uchcom_calc_divider_settings(, rate))
return;
 
+   /*
+* According to linux code we need to set bit 7 of UCHCOM_REG_BPS_PRE,
+* otherwise the chip will buffer data.
+*/
uchcom_write_reg(sc,
-   UCHCOM_REG_BPS_PRE, dv.dv_prescaler,
+   UCHCOM_REG_BPS_PRE, dv.dv_prescaler | 0x80,
UCHCOM_REG_BPS_DIV, dv.dv_div);
uchcom_write_reg(sc,
UCHCOM_REG_BPS_MOD, dv.dv_mod,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333998 - head/sys/dev/usb/serial

2018-05-21 Thread Andriy Gapon
Author: avg
Date: Mon May 21 20:58:06 2018
New Revision: 333998
URL: https://svnweb.freebsd.org/changeset/base/333998

Log:
  uchcom: add DPRINTF-s to aid debugging of the driver
  
  Reviewed by:  hselasky
  MFC after:2 weeks

Modified:
  head/sys/dev/usb/serial/uchcom.c

Modified: head/sys/dev/usb/serial/uchcom.c
==
--- head/sys/dev/usb/serial/uchcom.cMon May 21 20:57:14 2018
(r333997)
+++ head/sys/dev/usb/serial/uchcom.cMon May 21 20:58:06 2018
(r333998)
@@ -416,6 +416,8 @@ uchcom_ctrl_write(struct uchcom_softc *sc, uint8_t req
USETW(req.wIndex, index);
USETW(req.wLength, 0);
 
+   DPRINTF("WR REQ 0x%02X VAL 0x%04X IDX 0x%04X\n",
+   reqno, value, index);
ucom_cfg_do_request(sc->sc_udev,
>sc_ucom, , NULL, 0, 1000);
 }
@@ -432,6 +434,8 @@ uchcom_ctrl_read(struct uchcom_softc *sc, uint8_t reqn
USETW(req.wIndex, index);
USETW(req.wLength, buflen);
 
+   DPRINTF("RD REQ 0x%02X VAL 0x%04X IDX 0x%04X LEN %d\n",
+   reqno, value, index, buflen);
ucom_cfg_do_request(sc->sc_udev,
>sc_ucom, , buf, USB_SHORT_XFER_OK, 1000);
 }
@@ -506,6 +510,7 @@ static void
 uchcom_update_version(struct uchcom_softc *sc)
 {
uchcom_get_version(sc, >sc_version);
+   DPRINTF("Chip version: 0x%02x\n", sc->sc_version);
 }
 
 static void
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333911 - head/sys/netinet

2018-05-21 Thread Matthew Macy
On Mon, May 21, 2018 at 6:15 AM, Jonathan Looney  wrote:
> On Sat, May 19, 2018 at 10:27 PM, Matt Macy  wrote:
>>
>> +   il = malloc(sizeof(struct in_pcblist) + n * sizeof(struct inpcb
>> *), M_TEMP, M_WAITOK|M_ZERO);
>> +   inp_list = il->il_inp_list;
>
>
> Why does this need M_ZERO?

It allows me to assert that it hasn't already been passed to
epoch_call. However, it doesn't make sense to pass it on
non-INVARIANTS builds.

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


Re: svn commit: r333859 - head/sys/kern

2018-05-21 Thread Matthew Macy
Bear in mind that prior to my change most functions would call it
without ever using it on non-debug builds.

On Mon, May 21, 2018 at 9:54 AM, Eric van Gyzen  wrote:
> On 05/19/2018 00:09, Matt Macy wrote:
>> @@ -1663,16 +1655,18 @@ static int
>>  umtxq_sleep_pi(struct umtx_q *uq, struct umtx_pi *pi, uint32_t owner,
>>  const char *wmesg, struct abs_timeout *timo, bool shared)
>>  {
>> - struct umtxq_chain *uc;
>>   struct thread *td, *td1;
>>   struct umtx_q *uq1;
>>   int error, pri;
>> +#ifdef INVARIANTS
>> + struct umtxq_chain *uc;
>>
>> + uc = umtxq_getchain(>pi_key);
>> +#endif
>>   error = 0;
>>   td = uq->uq_thread;
>>   KASSERT(td == curthread, ("inconsistent uq_thread"));
>> - uc = umtxq_getchain(>uq_key);
>> - UMTXQ_LOCKED_ASSERT(uc);
>> + UMTXQ_LOCKED_ASSERT(umtxq_getchain(>uq_key));
>
> Couldn't this line stay as it was?
>
> UMTXQ_LOCKED_ASSERT(uc);
>
> With the current code, we're calling umtxq_getchain() once more than
> necessary.  Also, the casual reader might be confused by calling it with
> two different arguments.
>
> Eric
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333995 - head/sys/teken

2018-05-21 Thread Jean-Sébastien Pédron
Author: dumbbell
Date: Mon May 21 20:35:16 2018
New Revision: 333995
URL: https://svnweb.freebsd.org/changeset/base/333995

Log:
  teken: Rename the "Set Cursor Style" sequence to match vt100.net docs
  
  This fixes inconsistencies with the rest of the `sequences` file.
  
  No functional changes.
  
  Requested by: ed

Modified:
  head/sys/teken/sequences
  head/sys/teken/teken_subr.h

Modified: head/sys/teken/sequences
==
--- head/sys/teken/sequencesMon May 21 20:23:04 2018(r333994)
+++ head/sys/teken/sequencesMon May 21 20:35:16 2018(r333995)
@@ -48,7 +48,7 @@ CUF   Cursor Forward  ^[ [ a  
n
 CUPCursor Position ^[ [ H  n n
 CUPCursor Position ^[ [ f  n n
 CUUCursor Up   ^[ [ A  n
-CS Cursor style^[ [ SP q   r
+DECSCUSR   Set Cursor Style^[ [ SP q   r
 DA1Primary Device Attributes   ^[ [ c  r
 DA2Secondary Device Attributes ^[ [ > cr
 DC Delete character^[ [ P  n

Modified: head/sys/teken/teken_subr.h
==
--- head/sys/teken/teken_subr.h Mon May 21 20:23:04 2018(r333994)
+++ head/sys/teken/teken_subr.h Mon May 21 20:35:16 2018(r333995)
@@ -372,7 +372,7 @@ teken_subr_cursor_up(teken_t *t, unsigned int nrows)
 }
 
 static void
-teken_subr_cursor_style(teken_t *t, unsigned int style)
+teken_subr_set_cursor_style(teken_t *t, unsigned int style)
 {
 
/* TODO */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333994 - in head/sys: dev/acpica kern sys

2018-05-21 Thread Andriy Gapon
Author: avg
Date: Mon May 21 20:23:04 2018
New Revision: 333994
URL: https://svnweb.freebsd.org/changeset/base/333994

Log:
  stop and restart kernel event timers in the suspend / resume cycle
  
  I have a system that is very unstable after resuming from suspend-to-RAM
  but only if HPET is used as the event timer.  The theory is that SMM
  code / firmware could be enabling HPET for its own uses and unexpected
  interrupts cause a trouble for it.  Originally I wanted to solve the
  problem in hpet_suspend() method, but that was insufficient as the event
  timer could get reprogrammed again.
  
  So, it's better, for my case and in general, to stop the event timer(s)
  before entering the hardware suspend.
  
  MFC after:4 weeks
  Differential Revision: https://reviews.freebsd.org/D15413

Modified:
  head/sys/dev/acpica/acpi.c
  head/sys/kern/kern_clocksource.c
  head/sys/sys/systm.h

Modified: head/sys/dev/acpica/acpi.c
==
--- head/sys/dev/acpica/acpi.c  Mon May 21 20:20:28 2018(r333993)
+++ head/sys/dev/acpica/acpi.c  Mon May 21 20:23:04 2018(r333994)
@@ -2958,6 +2958,7 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state)
 if (sc->acpi_sleep_delay > 0)
DELAY(sc->acpi_sleep_delay * 100);
 
+suspendclock();
 intr = intr_disable();
 if (state != ACPI_STATE_S1) {
sleep_result = acpi_sleep_machdep(sc, state);
@@ -3028,6 +3029,8 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state)
  * process.  This handles both the error and success cases.
  */
 backout:
+if (slp_state >= ACPI_SS_SLP_PREP)
+   resumeclock();
 if (slp_state >= ACPI_SS_GPE_SET) {
acpi_wake_prep_walk(state);
sc->acpi_sstate = ACPI_STATE_S0;

Modified: head/sys/kern/kern_clocksource.c
==
--- head/sys/kern/kern_clocksource.cMon May 21 20:20:28 2018
(r333993)
+++ head/sys/kern/kern_clocksource.cMon May 21 20:23:04 2018
(r333994)
@@ -698,6 +698,22 @@ cpu_initclocks_ap(void)
spinlock_exit();
 }
 
+void
+suspendclock(void)
+{
+   ET_LOCK();
+   configtimer(0);
+   ET_UNLOCK();
+}
+
+void
+resumeclock(void)
+{
+   ET_LOCK();
+   configtimer(1);
+   ET_UNLOCK();
+}
+
 /*
  * Switch to profiling clock rates.
  */

Modified: head/sys/sys/systm.h
==
--- head/sys/sys/systm.hMon May 21 20:20:28 2018(r333993)
+++ head/sys/sys/systm.hMon May 21 20:23:04 2018(r333994)
@@ -333,6 +333,8 @@ voidstartprofclock(struct proc *);
 void   stopprofclock(struct proc *);
 void   cpu_startprofclock(void);
 void   cpu_stopprofclock(void);
+void   suspendclock(void);
+void   resumeclock(void);
 sbintime_t cpu_idleclock(void);
 void   cpu_activeclock(void);
 void   cpu_new_callout(int cpu, sbintime_t bt, sbintime_t bt_opt);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2018-05-21 Thread Andreas Tobler

Hi Eitan,

On 20.05.18 07:06, Eitan Adler wrote:

Author: eadler
Date: Sun May 20 05:06:42 2018
New Revision: 333919
URL: https://svnweb.freebsd.org/changeset/base/333919

Log:
   MFV: file 5.33
   
   Merge the latest file(1) in.
   
   Relevent Changelog:

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


I bissected this commit as the one which breaks my ports build.
The one before, 333916 lets me build ports w/o problems.
This and the following one (333922) which fixed compilation leaves me 
with a weird situation.


For example, when I try to build x11-servers/xorg-server I do not find 
the libpciaccess.so lib, then the build tries to build the missing 
library and complains about the library is already there. Force 
installing it doesn't help, the configure step still complains about a 
libpciaccess.so which was not found.


Another example is a gccX build where it complains about libgmp.so not 
found.


This happens on amd64, two different machines, and also on armv7. I 
didn't try on other archs.


Stepping between the two revisions solves/exposes the issue.

Do you have an idea what happens here?

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


svn commit: r333992 - head/sys/amd64/amd64

2018-05-21 Thread Konstantin Belousov
Author: kib
Date: Mon May 21 19:15:05 2018
New Revision: 333992
URL: https://svnweb.freebsd.org/changeset/base/333992

Log:
  Fix grammar.
  
  Submitted by: alc
  MFC after:1 week

Modified:
  head/sys/amd64/amd64/pmap.c

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Mon May 21 18:59:34 2018(r333991)
+++ head/sys/amd64/amd64/pmap.c Mon May 21 19:15:05 2018(r333992)
@@ -1804,7 +1804,7 @@ pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm
if (cpuid != i)
pmap->pm_pcids[i].pm_gen = 0;
}
-   /* See comment int pmap_invalidate_page(). */
+   /* See the comment in pmap_invalidate_page(). */
atomic_thread_fence_seq_cst();
}
mask = >pm_active;
@@ -1877,7 +1877,7 @@ pmap_invalidate_all(pmap_t pmap)
if (cpuid != i)
pmap->pm_pcids[i].pm_gen = 0;
}
-   /* See comment int pmap_invalidate_page(). */
+   /* See the comment in pmap_invalidate_page(). */
atomic_thread_fence_seq_cst();
}
mask = >pm_active;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333990 - head/sys/amd64/amd64

2018-05-21 Thread Konstantin Belousov
Author: kib
Date: Mon May 21 18:41:16 2018
New Revision: 333990
URL: https://svnweb.freebsd.org/changeset/base/333990

Log:
  Add missed barrier for pm_gen/pm_active interaction.
  
  When we issue shootdown IPIs, we first assign zero to pm_gens to
  indicate the need to flush on the next context switch in case our IPI
  misses the context, next we read pm_active. On context switch we set
  our bit in pm_active, then we read pm_gen. It is crucial that both
  threads see the memory in the program order, otherwise invalidation
  thread might read pm_active bit as zero and the context switching
  thread might read pm_gen as zero.
  
  IA32 allows CPU for both reads to see zero. We must use the barriers
  between write and read. The pm_active bit set is already locked, so
  only the invalidation functions need it.
  
  I never saw it in real life, or at least I do not have a good
  reproduction case. I found this during code inspection when hunting
  for the Xen TLB issue reported by cperciva.
  
  Reviewed by:  alc, markj
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D15506

Modified:
  head/sys/amd64/amd64/pmap.c

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Mon May 21 17:33:52 2018(r333989)
+++ head/sys/amd64/amd64/pmap.c Mon May 21 18:41:16 2018(r333990)
@@ -1721,6 +1721,18 @@ pmap_invalidate_page(pmap_t pmap, vm_offset_t va)
if (cpuid != i)
pmap->pm_pcids[i].pm_gen = 0;
}
+
+   /*
+* The fence is between stores to pm_gen and the read of
+* the pm_active mask.  We need to ensure that it is
+* impossible for us to miss the bit update in pm_active
+* and simultaneously observe a non-zero pm_gen in
+* pmap_activate_sw(), otherwise TLB update is missed.
+* Without the fence, IA32 allows such an outcome.
+* Note that pm_active is updated by a locked operation,
+* which provides the reciprocal fence.
+*/
+   atomic_thread_fence_seq_cst();
}
mask = >pm_active;
}
@@ -1792,6 +1804,8 @@ pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm
if (cpuid != i)
pmap->pm_pcids[i].pm_gen = 0;
}
+   /* See comment int pmap_invalidate_page(). */
+   atomic_thread_fence_seq_cst();
}
mask = >pm_active;
}
@@ -1863,6 +1877,8 @@ pmap_invalidate_all(pmap_t pmap)
if (cpuid != i)
pmap->pm_pcids[i].pm_gen = 0;
}
+   /* See comment int pmap_invalidate_page(). */
+   atomic_thread_fence_seq_cst();
}
mask = >pm_active;
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333929 - head/usr.bin/top

2018-05-21 Thread Brooks Davis
On Sun, May 20, 2018 at 05:59:59PM +, Eitan Adler wrote:
> Author: eadler
> Date: Sun May 20 17:59:59 2018
> New Revision: 333929
> URL: https://svnweb.freebsd.org/changeset/base/333929
> 
> Log:
>   top(1): Make lack of "percent" information explicit
>   
>   When count is 1, no delta information can be produced. Make this
>   explicit.
>   
>   PR: 195717
>   Submitted by:   fernape
> 
> Modified:
>   head/usr.bin/top/top.1
> 
> Modified: head/usr.bin/top/top.1
> ==
> --- head/usr.bin/top/top.1Sun May 20 17:58:22 2018(r333928)
> +++ head/usr.bin/top/top.1Sun May 20 17:59:59 2018(r333929)
> @@ -162,7 +162,10 @@ screen.  This option allows the user to select the num
>  wants to see before
>  .I top
>  automatically exits.  For intelligent terminals, no upper limit
> -is set.  The default is 1 for dumb terminals.
> +is set.  The default is 1 for dumb terminals. Please, note that for
> +.I count
> += 1
> +no information is available about the percentage of time spent by the CPU in 
> every state.

When you're done clearing old PRs, it might be worth making this file
follow FreeBSD mandoc conventions (particularly line breaks after end of
sentence.)

-- Brooks

P.S. thanks for cleaning up top!


signature.asc
Description: PGP signature


svn commit: r333989 - head/sys/dev/usb/template

2018-05-21 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon May 21 17:33:52 2018
New Revision: 333989
URL: https://svnweb.freebsd.org/changeset/base/333989

Log:
  Add a somewhat ugly hack that makes OSX serial device node names
  human-readable.
  
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/dev/usb/template/usb_template_modem.c
  head/sys/dev/usb/template/usb_template_multi.c
  head/sys/dev/usb/template/usb_template_serialnet.c

Modified: head/sys/dev/usb/template/usb_template_modem.c
==
--- head/sys/dev/usb/template/usb_template_modem.c  Mon May 21 16:50:27 
2018(r333988)
+++ head/sys/dev/usb/template/usb_template_modem.c  Mon May 21 17:33:52 
2018(r333989)
@@ -81,7 +81,13 @@ enum {
 #defineMODEM_DEFAULT_INTERFACE "Virtual serial port"
 #defineMODEM_DEFAULT_MANUFACTURER  USB_TEMPLATE_MANUFACTURER
 #defineMODEM_DEFAULT_PRODUCT   "Virtual serial port"
-#defineMODEM_DEFAULT_SERIAL_NUMBER "March 2008"
+/*
+ * The reason for this being called like this is that OSX
+ * derives the device node name from it, resulting in a somewhat
+ * user-friendly "/dev/cu.usbmodemFreeBSD1".  And yes, the "1"
+ * needs to be there, otherwise OSX will mangle it.
+ */
+#defineMODEM_DEFAULT_SERIAL_NUMBER "FreeBSD1"
 
 static struct usb_string_descriptormodem_interface;
 static struct usb_string_descriptormodem_manufacturer;

Modified: head/sys/dev/usb/template/usb_template_multi.c
==
--- head/sys/dev/usb/template/usb_template_multi.c  Mon May 21 16:50:27 
2018(r333988)
+++ head/sys/dev/usb/template/usb_template_multi.c  Mon May 21 17:33:52 
2018(r333989)
@@ -99,7 +99,13 @@ enum {
 #defineMULTI_DEFAULT_CONFIGURATION "Default configuration"
 #defineMULTI_DEFAULT_MANUFACTURER  USB_TEMPLATE_MANUFACTURER
 #defineMULTI_DEFAULT_PRODUCT   "Multifunction Device"
-#defineMULTI_DEFAULT_SERIAL_NUMBER "May 2018"
+/*
+ * The reason for this being called like this is that OSX
+ * derives the device node name from it, resulting in a somewhat
+ * user-friendly "/dev/cu.usbmodemFreeBSD1".  And yes, the "1"
+ * needs to be there, otherwise OSX will mangle it.
+ */
+#define MULTI_DEFAULT_SERIAL_NUMBER"FreeBSD1"
 
 static struct usb_string_descriptormulti_modem;
 static struct usb_string_descriptormulti_eth_mac;

Modified: head/sys/dev/usb/template/usb_template_serialnet.c
==
--- head/sys/dev/usb/template/usb_template_serialnet.c  Mon May 21 16:50:27 
2018(r333988)
+++ head/sys/dev/usb/template/usb_template_serialnet.c  Mon May 21 17:33:52 
2018(r333989)
@@ -97,7 +97,13 @@ enum {
 #defineSERIALNET_DEFAULT_CONFIGURATION "Default configuration"
 #defineSERIALNET_DEFAULT_MANUFACTURER  USB_TEMPLATE_MANUFACTURER
 #defineSERIALNET_DEFAULT_PRODUCT   "Serial/Ethernet device"
-#defineSERIALNET_DEFAULT_SERIAL_NUMBER "January 2015"
+/*
+ * The reason for this being called like this is that OSX
+ * derives the device node name from it, resulting in a somewhat
+ * user-friendly "/dev/cu.usbmodemFreeBSD1".  And yes, the "1"
+ * needs to be there, otherwise OSX will mangle it.
+ */
+#define SERIALNET_DEFAULT_SERIAL_NUMBER"FreeBSD1"
 
 static struct usb_string_descriptorserialnet_modem;
 static struct usb_string_descriptorserialnet_eth_mac;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333859 - head/sys/kern

2018-05-21 Thread Matthew Macy
Good point. Will fix.

On Mon, May 21, 2018 at 9:54 AM, Eric van Gyzen  wrote:
> On 05/19/2018 00:09, Matt Macy wrote:
>> @@ -1663,16 +1655,18 @@ static int
>>  umtxq_sleep_pi(struct umtx_q *uq, struct umtx_pi *pi, uint32_t owner,
>>  const char *wmesg, struct abs_timeout *timo, bool shared)
>>  {
>> - struct umtxq_chain *uc;
>>   struct thread *td, *td1;
>>   struct umtx_q *uq1;
>>   int error, pri;
>> +#ifdef INVARIANTS
>> + struct umtxq_chain *uc;
>>
>> + uc = umtxq_getchain(>pi_key);
>> +#endif
>>   error = 0;
>>   td = uq->uq_thread;
>>   KASSERT(td == curthread, ("inconsistent uq_thread"));
>> - uc = umtxq_getchain(>uq_key);
>> - UMTXQ_LOCKED_ASSERT(uc);
>> + UMTXQ_LOCKED_ASSERT(umtxq_getchain(>uq_key));
>
> Couldn't this line stay as it was?
>
> UMTXQ_LOCKED_ASSERT(uc);
>
> With the current code, we're calling umtxq_getchain() once more than
> necessary.  Also, the casual reader might be confused by calling it with
> two different arguments.
>
> Eric
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333859 - head/sys/kern

2018-05-21 Thread Eric van Gyzen
On 05/19/2018 00:09, Matt Macy wrote:
> @@ -1663,16 +1655,18 @@ static int
>  umtxq_sleep_pi(struct umtx_q *uq, struct umtx_pi *pi, uint32_t owner,
>  const char *wmesg, struct abs_timeout *timo, bool shared)
>  {
> - struct umtxq_chain *uc;
>   struct thread *td, *td1;
>   struct umtx_q *uq1;
>   int error, pri;
> +#ifdef INVARIANTS
> + struct umtxq_chain *uc;
>  
> + uc = umtxq_getchain(>pi_key);
> +#endif
>   error = 0;
>   td = uq->uq_thread;
>   KASSERT(td == curthread, ("inconsistent uq_thread"));
> - uc = umtxq_getchain(>uq_key);
> - UMTXQ_LOCKED_ASSERT(uc);
> + UMTXQ_LOCKED_ASSERT(umtxq_getchain(>uq_key));

Couldn't this line stay as it was?

UMTXQ_LOCKED_ASSERT(uc);

With the current code, we're calling umtxq_getchain() once more than
necessary.  Also, the casual reader might be confused by calling it with
two different arguments.

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


svn commit: r333988 - head/share/man/man4

2018-05-21 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon May 21 16:50:27 2018
New Revision: 333988
URL: https://svnweb.freebsd.org/changeset/base/333988

Log:
  Fix typo.
  
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation

Modified:
  head/share/man/man4/cdce.4

Modified: head/share/man/man4/cdce.4
==
--- head/share/man/man4/cdce.4  Mon May 21 16:33:13 2018(r333987)
+++ head/share/man/man4/cdce.4  Mon May 21 16:50:27 2018(r333988)
@@ -28,7 +28,7 @@
 .\" $NetBSD: cdce.4,v 1.4 2004/12/08 18:35:56 peter Exp $
 .\" $FreeBSD$
 .\"
-.Dd April 26, 2018
+.Dd May 21, 2018
 .Dt CDCE 4
 .Os
 .Sh NAME
@@ -60,7 +60,7 @@ driver provides support for USB Host-to-Host (aka USB-
 USB-to-Ethernet bridges based on the USB Communication Device Class
 Ethernet Control Model (CDC ECM) and Network Control Model (CDC NCM)
 specifications.
-It also provides device-level CDC ECM support.
+It also provides device-side CDC ECM support.
 .Pp
 The USB bridge appears as a regular network interface on both sides,
 transporting Ethernet frames.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333987 - head/sys/dev/usb/template

2018-05-21 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon May 21 16:33:13 2018
New Revision: 333987
URL: https://svnweb.freebsd.org/changeset/base/333987

Log:
  Improve description strings for USB device-mode serial ports.
  
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/dev/usb/template/usb_template_modem.c
  head/sys/dev/usb/template/usb_template_multi.c
  head/sys/dev/usb/template/usb_template_serialnet.c

Modified: head/sys/dev/usb/template/usb_template_modem.c
==
--- head/sys/dev/usb/template/usb_template_modem.c  Mon May 21 16:19:00 
2018(r333986)
+++ head/sys/dev/usb/template/usb_template_modem.c  Mon May 21 16:33:13 
2018(r333987)
@@ -78,9 +78,9 @@ enum {
 
 #defineMODEM_DEFAULT_VENDOR_ID USB_TEMPLATE_VENDOR
 #defineMODEM_DEFAULT_PRODUCT_ID0x27dd
-#defineMODEM_DEFAULT_INTERFACE "Modem interface"
+#defineMODEM_DEFAULT_INTERFACE "Virtual serial port"
 #defineMODEM_DEFAULT_MANUFACTURER  USB_TEMPLATE_MANUFACTURER
-#defineMODEM_DEFAULT_PRODUCT   "Modem Test Device"
+#defineMODEM_DEFAULT_PRODUCT   "Virtual serial port"
 #defineMODEM_DEFAULT_SERIAL_NUMBER "March 2008"
 
 static struct usb_string_descriptormodem_interface;
@@ -284,7 +284,7 @@ modem_init(void *arg __unused)
parent = SYSCTL_ADD_NODE(_ctx_list,
SYSCTL_STATIC_CHILDREN(_hw_usb_templates), OID_AUTO,
parent_name, CTLFLAG_RW,
-   0, "USB Modem device side template");
+   0, "Virtual serial port device side template");
SYSCTL_ADD_U16(_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
"vendor_id", CTLFLAG_RWTUN,
_template_modem.idVendor, 1, "Vendor identifier");

Modified: head/sys/dev/usb/template/usb_template_multi.c
==
--- head/sys/dev/usb/template/usb_template_multi.c  Mon May 21 16:19:00 
2018(r333986)
+++ head/sys/dev/usb/template/usb_template_multi.c  Mon May 21 16:33:13 
2018(r333987)
@@ -91,7 +91,7 @@ enum {
 
 #defineMULTI_DEFAULT_VENDOR_ID USB_TEMPLATE_VENDOR
 #defineMULTI_DEFAULT_PRODUCT_ID0x05dc
-#defineMULTI_DEFAULT_MODEM "Virtual serial console"
+#defineMULTI_DEFAULT_MODEM "Virtual serial port"
 #defineMULTI_DEFAULT_ETH_MAC   "2A02030405060789AB"
 #defineMULTI_DEFAULT_ETH_CONTROL   "Ethernet Comm Interface"
 #defineMULTI_DEFAULT_ETH_DATA  "Ethernet Data Interface"

Modified: head/sys/dev/usb/template/usb_template_serialnet.c
==
--- head/sys/dev/usb/template/usb_template_serialnet.c  Mon May 21 16:19:00 
2018(r333986)
+++ head/sys/dev/usb/template/usb_template_serialnet.c  Mon May 21 16:33:13 
2018(r333987)
@@ -90,13 +90,13 @@ enum {
 
 #defineSERIALNET_DEFAULT_VENDOR_ID USB_TEMPLATE_VENDOR
 #defineSERIALNET_DEFAULT_PRODUCT_ID0x05dc
-#defineSERIALNET_DEFAULT_MODEM "USB Modem Interface"
+#defineSERIALNET_DEFAULT_MODEM "Virtual serial port"
 #defineSERIALNET_DEFAULT_ETH_MAC   "2A02030405060789AB"
 #defineSERIALNET_DEFAULT_ETH_CONTROL   "USB Ethernet Comm Interface"
 #defineSERIALNET_DEFAULT_ETH_DATA  "USB Ethernet Data Interface"
 #defineSERIALNET_DEFAULT_CONFIGURATION "Default configuration"
 #defineSERIALNET_DEFAULT_MANUFACTURER  USB_TEMPLATE_MANUFACTURER
-#defineSERIALNET_DEFAULT_PRODUCT   "SERIALNET"
+#defineSERIALNET_DEFAULT_PRODUCT   "Serial/Ethernet device"
 #defineSERIALNET_DEFAULT_SERIAL_NUMBER "January 2015"
 
 static struct usb_string_descriptorserialnet_modem;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333986 - head/sys/netpfil/ipfw

2018-05-21 Thread Andrey V. Elsukov
Author: ae
Date: Mon May 21 16:19:00 2018
New Revision: 333986
URL: https://svnweb.freebsd.org/changeset/base/333986

Log:
  Remove check for matching the rulenum, ruleid and rule pointer from
  dyn_lookup_ipv[46]_state_locked(). These checks are remnants of not
  ready to be committed code, and they are there by accident.
  Due to the race these checks can lead to creating of duplicate states
  when concurrent threads in the same time will try to add state for two
  packets of the same flow, but in reverse directions and matched by
  different parent rules.
  
  Reported by:  lev
  MFC after:3 days

Modified:
  head/sys/netpfil/ipfw/ip_fw_dynamic.c

Modified: head/sys/netpfil/ipfw/ip_fw_dynamic.c
==
--- head/sys/netpfil/ipfw/ip_fw_dynamic.c   Mon May 21 16:14:53 2018
(r333985)
+++ head/sys/netpfil/ipfw/ip_fw_dynamic.c   Mon May 21 16:19:00 2018
(r333986)
@@ -490,8 +490,7 @@ static struct dyn_ipv6_state *dyn_lookup_ipv6_state(
 const struct ipfw_flow_id *, uint32_t, const void *,
 struct ipfw_dyn_info *, int);
 static int dyn_lookup_ipv6_state_locked(const struct ipfw_flow_id *,
-uint32_t, const void *, int, const void *, uint32_t, uint16_t, uint32_t,
-uint16_t);
+uint32_t, const void *, int, uint32_t, uint16_t);
 static struct dyn_ipv6_state *dyn_alloc_ipv6_state(
 const struct ipfw_flow_id *, uint32_t, uint16_t, uint8_t);
 static int dyn_add_ipv6_state(void *, uint32_t, uint16_t, uint8_t,
@@ -547,7 +546,7 @@ static void dyn_update_proto_state(struct dyn_data *,
 struct dyn_ipv4_state *dyn_lookup_ipv4_state(const struct ipfw_flow_id *,
 const void *, struct ipfw_dyn_info *, int);
 static int dyn_lookup_ipv4_state_locked(const struct ipfw_flow_id *,
-const void *, int, const void *, uint32_t, uint16_t, uint32_t, uint16_t);
+const void *, int, uint32_t, uint16_t);
 static struct dyn_ipv4_state *dyn_alloc_ipv4_state(
 const struct ipfw_flow_id *, uint16_t, uint8_t);
 static int dyn_add_ipv4_state(void *, uint32_t, uint16_t, uint8_t,
@@ -1066,8 +1065,7 @@ restart:
  */
 static int
 dyn_lookup_ipv4_state_locked(const struct ipfw_flow_id *pkt,
-const void *ulp, int pktlen, const void *parent, uint32_t ruleid,
-uint16_t rulenum, uint32_t bucket, uint16_t kidx)
+const void *ulp, int pktlen, uint32_t bucket, uint16_t kidx)
 {
struct dyn_ipv4_state *s;
int dir;
@@ -1078,15 +1076,6 @@ dyn_lookup_ipv4_state_locked(const struct ipfw_flow_id
if (s->proto != pkt->proto ||
s->kidx != kidx)
continue;
-   /*
-* XXXAE: Install synchronized state only when there are
-*no matching states.
-*/
-   if (pktlen != 0 && (
-   s->data->parent != parent ||
-   s->data->ruleid != ruleid ||
-   s->data->rulenum != rulenum))
-   continue;
if (s->sport == pkt->src_port &&
s->dport == pkt->dst_port &&
s->src == pkt->src_ip && s->dst == pkt->dst_ip) {
@@ -1228,8 +1217,7 @@ restart:
  */
 static int
 dyn_lookup_ipv6_state_locked(const struct ipfw_flow_id *pkt, uint32_t zoneid,
-const void *ulp, int pktlen, const void *parent, uint32_t ruleid,
-uint16_t rulenum, uint32_t bucket, uint16_t kidx)
+const void *ulp, int pktlen, uint32_t bucket, uint16_t kidx)
 {
struct dyn_ipv6_state *s;
int dir;
@@ -1240,15 +1228,6 @@ dyn_lookup_ipv6_state_locked(const struct ipfw_flow_id
if (s->proto != pkt->proto || s->kidx != kidx ||
s->zoneid != zoneid)
continue;
-   /*
-* XXXAE: Install synchronized state only when there are
-*no matching states.
-*/
-   if (pktlen != 0 && (
-   s->data->parent != parent ||
-   s->data->ruleid != ruleid ||
-   s->data->rulenum != rulenum))
-   continue;
if (s->sport == pkt->src_port && s->dport == pkt->dst_port &&
IN6_ARE_ADDR_EQUAL(>src, >src_ip6) &&
IN6_ARE_ADDR_EQUAL(>dst, >dst_ip6)) {
@@ -1595,8 +1574,8 @@ dyn_add_ipv4_state(void *parent, uint32_t ruleid, uint
 * Bucket version has been changed since last lookup,
 * do lookup again to be sure that state does not exist.
 */
-   if (dyn_lookup_ipv4_state_locked(pkt, ulp, pktlen, parent,
-   ruleid, rulenum, bucket, kidx) != 0) {
+   if (dyn_lookup_ipv4_state_locked(pkt, ulp, pktlen,
+   bucket, kidx) != 0) {
DYN_BUCKET_UNLOCK(bucket);
return (EEXIST);
}
@@ -1727,7 +1706,7 @@ 

svn commit: r333985 - head/sys/arm64/arm64

2018-05-21 Thread Andrew Turner
Author: andrew
Date: Mon May 21 16:14:53 2018
New Revision: 333985
URL: https://svnweb.freebsd.org/changeset/base/333985

Log:
  Restrict the faulting addresses we call pmap_fault from to just those that
  may fault due to superpage mappings being changed.
  
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/arm64/arm64/trap.c

Modified: head/sys/arm64/arm64/trap.c
==
--- head/sys/arm64/arm64/trap.c Mon May 21 16:13:43 2018(r333984)
+++ head/sys/arm64/arm64/trap.c Mon May 21 16:14:53 2018(r333985)
@@ -189,8 +189,16 @@ data_abort(struct thread *td, struct trapframe *frame,
}
}
 
-   if (pmap_fault(map->pmap, esr, far) == KERN_SUCCESS)
-   return;
+   /*
+* We may fault from userspace or when in a DMAP region due to
+* a superpage being unmapped when the access took place. In these
+* cases we need to wait for the pmap to be unlocked and check
+* if the translation is still invalid.
+*/
+   if (map != kernel_map || VIRT_IN_DMAP(far)) {
+   if (pmap_fault(map->pmap, esr, far) == KERN_SUCCESS)
+   return;
+   }
 
KASSERT(td->td_md.md_spinlock_count == 0,
("data abort with spinlock held"));
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333984 - head/sys/netinet

2018-05-21 Thread Matt Macy
Author: mmacy
Date: Mon May 21 16:13:43 2018
New Revision: 333984
URL: https://svnweb.freebsd.org/changeset/base/333984

Log:
  inpcb: revert deferred inpcb free pending further review

Modified:
  head/sys/netinet/in_pcb.c
  head/sys/netinet/in_pcb.h

Modified: head/sys/netinet/in_pcb.c
==
--- head/sys/netinet/in_pcb.c   Mon May 21 16:03:51 2018(r333983)
+++ head/sys/netinet/in_pcb.c   Mon May 21 16:13:43 2018(r333984)
@@ -1336,34 +1336,6 @@ in_pcblist_rele_rlocked(epoch_context_t ctx)
free(il, M_TEMP);
 }
 
-static void
-in_pcbfree_deferred(epoch_context_t ctx)
-{
-   struct inpcb *inp;
-   struct inpcbinfo *pcbinfo;
-
-   inp = __containerof(ctx, struct inpcb, inp_epoch_ctx);
-   pcbinfo = inp->inp_pcbinfo;
-
-   INP_WLOCK(inp); 
-   /* XXXRW: Do as much as possible here. */
-#if defined(IPSEC) || defined(IPSEC_SUPPORT)
-   if (inp->inp_sp != NULL)
-   ipsec_delete_pcbpolicy(inp);
-#endif
-   if (inp->inp_options)
-   (void)m_free(inp->inp_options);
-
-   inp->inp_vflag = 0;
-   inp->inp_flags2 |= INP_FREED;
-   crfree(inp->inp_cred);
-#ifdef MAC
-   mac_inpcb_destroy(inp);
-#endif
-   if (!in_pcbrele_wlocked(inp))
-   INP_WUNLOCK(inp);
-}
-
 /*
  * Unconditionally schedule an inpcb to be freed by decrementing its
  * reference count, which should occur only after the inpcb has been detached
@@ -1376,15 +1348,16 @@ in_pcbfree_deferred(epoch_context_t ctx)
 void
 in_pcbfree(struct inpcb *inp)
 {
+   struct inpcbinfo *pcbinfo = inp->inp_pcbinfo;
+
 #ifdef INET6
struct ip6_moptions *im6o = NULL;
 #endif
 #ifdef INET
struct ip_moptions *imo = NULL;
 #endif
-   struct inpcbinfo *pcbinfo = inp->inp_pcbinfo;
-
KASSERT(inp->inp_socket == NULL, ("%s: inp_socket != NULL", __func__));
+
KASSERT((inp->inp_flags2 & INP_FREED) == 0,
("%s: called twice for pcb %p", __func__, inp));
if (inp->inp_flags2 & INP_FREED) {
@@ -1400,27 +1373,45 @@ in_pcbfree(struct inpcb *inp)
}
 #endif
INP_WLOCK_ASSERT(inp);
+
 #ifdef INET
imo = inp->inp_moptions;
inp->inp_moptions = NULL;
-   inp_freemoptions(imo);
 #endif
+   /* XXXRW: Do as much as possible here. */
+#if defined(IPSEC) || defined(IPSEC_SUPPORT)
+   if (inp->inp_sp != NULL)
+   ipsec_delete_pcbpolicy(inp);
+#endif
+   INP_LIST_WLOCK(pcbinfo);
+   inp->inp_gencnt = ++pcbinfo->ipi_gencnt;
+   in_pcbremlists(inp);
+   INP_LIST_WUNLOCK(pcbinfo);
 #ifdef INET6
if (inp->inp_vflag & INP_IPV6PROTO) {
ip6_freepcbopts(inp->in6p_outputopts);
im6o = inp->in6p_moptions;
inp->in6p_moptions = NULL;
-   ip6_freemoptions(im6o);
}
 #endif
-   /* Remove first from list */
-   INP_LIST_WLOCK(pcbinfo);
-   inp->inp_gencnt = ++pcbinfo->ipi_gencnt;
-   in_pcbremlists(inp);
-   INP_LIST_WUNLOCK(pcbinfo);
+   if (inp->inp_options)
+   (void)m_free(inp->inp_options);
RO_INVALIDATE_CACHE(>inp_route);
-   INP_WUNLOCK(inp);
-   epoch_call(net_epoch_preempt, >inp_epoch_ctx, in_pcbfree_deferred);
+
+   inp->inp_vflag = 0;
+   inp->inp_flags2 |= INP_FREED;
+   crfree(inp->inp_cred);
+#ifdef MAC
+   mac_inpcb_destroy(inp);
+#endif
+#ifdef INET6
+   ip6_freemoptions(im6o);
+#endif
+#ifdef INET
+   inp_freemoptions(imo);
+#endif
+   if (!in_pcbrele_wlocked(inp))
+   INP_WUNLOCK(inp);
 }
 
 /*

Modified: head/sys/netinet/in_pcb.h
==
--- head/sys/netinet/in_pcb.h   Mon May 21 16:03:51 2018(r333983)
+++ head/sys/netinet/in_pcb.h   Mon May 21 16:13:43 2018(r333984)
@@ -328,7 +328,6 @@ struct inpcb {
LIST_ENTRY(inpcb) inp_list; /* (p/l) list for all PCBs for proto */
/* (p[w]) for list iteration */
/* (p[r]/l) for addition/removal */
-   struct epoch_context inp_epoch_ctx;
 };
 #endif /* _KERNEL */
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333968 - in head/sys: netinet netinet6

2018-05-21 Thread Matthew Macy
Looking closer I think the ifp should always be set. I'll just add an
assert to that effect and make it non-conditional.
-M

On Mon, May 21, 2018 at 1:55 AM, Marko Zec  wrote:
> On Mon, 21 May 2018 08:34:10 +
> Matt Macy  wrote:
>
>> Author: mmacy
>> Date: Mon May 21 08:34:10 2018
>> New Revision: 333968
>> URL: https://svnweb.freebsd.org/changeset/base/333968
>>
>> Log:
>>   in(6)_mcast: Expand out vnet set / restore macro so that they work
>> in a conditional block
>>   Reported by:zec at fer.hr
>>
>> Modified:
>>   head/sys/netinet/in_mcast.c
>>   head/sys/netinet6/in6_mcast.c
>>
>> Modified: head/sys/netinet/in_mcast.c
>> ==
>> --- head/sys/netinet/in_mcast.c   Mon May 21 07:12:06
>> 2018  (r333967) +++ head/sys/netinet/in_mcast.c   Mon May
>> 21 08:34:10 2018  (r333968) @@ -653,6 +653,7 @@
>> inm_release(struct in_multi *inm) {
>>   struct ifmultiaddr *ifma;
>>   struct ifnet *ifp;
>> + struct vnet *saved_vnet;
>>
>>   CTR2(KTR_IGMPV3, "%s: refcount is %d", __func__,
>> inm->inm_refcount); MPASS(inm->inm_refcount == 0);
>> @@ -663,14 +664,16 @@ inm_release(struct in_multi *inm)
>>
>>   /* XXX this access is not covered by IF_ADDR_LOCK */
>>   CTR2(KTR_IGMPV3, "%s: purging ifma %p", __func__, ifma);
>> - if (ifp)
>> - CURVNET_SET(ifp->if_vnet);
>> + if (ifp) {
>> + saved_vnet = curvnet;
>> + curvnet = ifp->if_vnet;
>> + }
>
> Uhmm...  please don't do this, for at least two reasons:
>
> 1) so far we could identify all VNET context switches by tracking
> CURVNET_SET / _RESTORE macros.  With this change a non-standard hack is
> introduced, opening the door for more alternative / creative variations
> to come, thus increasing the entropy
>
> 2) CURVNET_* macros provide elementary capability of tracking vnet
> recursions, and much more importantly, forgotten or missed context
> restores.  Your change breaks this tracking chain.
>
> Is there a reason one could not extend struct in_multi with a struct
> vnet *inm_vnet entry, populate it on struct in_multi creation, and be
> done with all curvnet woes in a clean way?
>
> Marko
>
>
>>   inm_purge(inm);
>>   free(inm, M_IPMADDR);
>>
>>   if_delmulti_ifma_flags(ifma, 1);
>>   if (ifp) {
>> - CURVNET_RESTORE();
>> + curvnet = saved_vnet;
>>   if_rele(ifp);
>>   }
>>  }
>> @@ -1666,6 +1669,7 @@ inp_gcmoptions(epoch_context_t ctx)
>>   struct in_mfilter   *imf;
>>   struct in_multi *inm;
>>   struct ifnet *ifp;
>> + struct vnet *saved_vnet;
>>   size_t   idx, nmships;
>>
>>   imo =  __containerof(ctx, struct ip_moptions, imo_epoch_ctx);
>> @@ -1677,11 +1681,13 @@ inp_gcmoptions(epoch_context_t ctx)
>>   imf_leave(imf);
>>   inm = imo->imo_membership[idx];
>>   ifp = inm->inm_ifp;
>> - if (ifp)
>> - CURVNET_SET(ifp->if_vnet);
>> + if (ifp) {
>> + saved_vnet = curvnet;
>> + curvnet = ifp->if_vnet;
>> + }
>>   (void)in_leavegroup(inm, imf);
>>   if (ifp)
>> - CURVNET_RESTORE();
>> + curvnet = saved_vnet;
>>   if (imf)
>>   imf_purge(imf);
>>   }
>>
>> Modified: head/sys/netinet6/in6_mcast.c
>> ==
>> --- head/sys/netinet6/in6_mcast.c Mon May 21 07:12:06
>> 2018  (r333967) +++ head/sys/netinet6/in6_mcast.c Mon
>> May 21 08:34:10 2018  (r333968) @@ -524,6 +524,7 @@
>> in6m_release(struct in6_multi *inm) {
>>   struct ifmultiaddr *ifma;
>>   struct ifnet *ifp;
>> + struct vnet *saved_vnet;
>>
>>   CTR2(KTR_MLD, "%s: refcount is %d", __func__,
>> inm->in6m_refcount);
>> @@ -539,14 +540,16 @@ in6m_release(struct in6_multi *inm)
>>   KASSERT(ifma->ifma_protospec == NULL,
>>   ("%s: ifma_protospec != NULL", __func__));
>>
>> - if (ifp)
>> - CURVNET_SET(ifp->if_vnet);
>> + if (ifp) {
>> + saved_vnet = curvnet;
>> + curvnet = ifp->if_vnet;
>> + }
>>   in6m_purge(inm);
>>   free(inm, M_IP6MADDR);
>>
>>   if_delmulti_ifma_flags(ifma, 1);
>>   if (ifp) {
>> - CURVNET_RESTORE();
>> + curvnet = saved_vnet;
>>   if_rele(ifp);
>>   }
>>  }
>> @@ -1628,6 +1631,7 @@ inp_gcmoptions(epoch_context_t ctx)
>>   struct in6_mfilter  *imf;
>>   struct in6_multi *inm;
>>   struct ifnet *ifp;
>> + struct vnet *saved_vnet;
>>   size_t   idx, nmships;
>>
>>   imo =  __containerof(ctx, struct ip6_moptions,
>> imo6_epoch_ctx); @@ -1639,11 +1643,13 @@
>> inp_gcmoptions(epoch_context_t ctx) im6f_leave(imf);
>> 

svn commit: r333983 - head/sys/kern

2018-05-21 Thread Mark Johnston
Author: markj
Date: Mon May 21 16:03:51 2018
New Revision: 333983
URL: https://svnweb.freebsd.org/changeset/base/333983

Log:
  Don't pass a section cookie to CK for non-preemptible epoch sections.
  
  They're only useful when multiple threads may share an epoch record,
  and that can't happen with non-preemptible sections.
  
  Reviewed by:  mmacy
  Differential Revision:https://reviews.freebsd.org/D15507

Modified:
  head/sys/kern/subr_epoch.c

Modified: head/sys/kern/subr_epoch.c
==
--- head/sys/kern/subr_epoch.c  Mon May 21 15:06:19 2018(r333982)
+++ head/sys/kern/subr_epoch.c  Mon May 21 16:03:51 2018(r333983)
@@ -298,18 +298,15 @@ void
 epoch_enter(epoch_t epoch)
 {
ck_epoch_record_t *record;
-   ck_epoch_section_t *section;
struct thread *td;
 
MPASS(cold || epoch != NULL);
-   section = NULL;
td = curthread;
-   critical_enter();
-   if (__predict_true(td->td_epochnest++ == 0))
-   section = (ck_epoch_section_t*)>td_epoch_section;
 
+   critical_enter();
+   td->td_epochnest++;
record = >e_pcpu[curcpu]->eps_record.er_record;
-   ck_epoch_begin(record, section);
+   ck_epoch_begin(record, NULL);
 }
 
 void
@@ -339,16 +336,12 @@ void
 epoch_exit(epoch_t epoch)
 {
ck_epoch_record_t *record;
-   ck_epoch_section_t *section;
struct thread *td;
 
-   section = NULL;
td = curthread;
-   MPASS(td->td_critnest);
-   if (__predict_true(td->td_epochnest-- == 1))
-   section = (ck_epoch_section_t*)>td_epoch_section;
+   td->td_epochnest--;
record = >e_pcpu[curcpu]->eps_record.er_record;
-   ck_epoch_end(record, section);
+   ck_epoch_end(record, NULL);
critical_exit();
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333968 - in head/sys: netinet netinet6

2018-05-21 Thread Matthew Macy
Sorry about that

On Mon, May 21, 2018 at 04:59 Hans Petter Selasky  wrote:

> On 05/21/18 13:49, Ed Maste wrote:
> > After r333968 the build is also broken on all archs but amd64 and i386.
>
> It looks like amd64 and i386 build with VIMAGE enabled by default, while
> the others not. 12-current. So both VIMAGE and non-VIMAGE should be tested.
>
> --HPS
>
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333982 - head/sys/dev/usb/template

2018-05-21 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon May 21 15:06:19 2018
New Revision: 333982
URL: https://svnweb.freebsd.org/changeset/base/333982

Log:
  Use USB Vendor Identifiers and Product Identifiers provided by V-USB
  (https://github.com/obdev/v-usb/blob/master/usbdrv/USB-IDs-for-free.txt).
  Previously we were using an invalid (not assigned to us) VID.
  
  Reviewed by:  hselasky@
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/dev/usb/template/usb_template.h
  head/sys/dev/usb/template/usb_template_audio.c
  head/sys/dev/usb/template/usb_template_cdce.c
  head/sys/dev/usb/template/usb_template_kbd.c
  head/sys/dev/usb/template/usb_template_midi.c
  head/sys/dev/usb/template/usb_template_modem.c
  head/sys/dev/usb/template/usb_template_mouse.c
  head/sys/dev/usb/template/usb_template_msc.c
  head/sys/dev/usb/template/usb_template_mtp.c
  head/sys/dev/usb/template/usb_template_multi.c
  head/sys/dev/usb/template/usb_template_phone.c
  head/sys/dev/usb/template/usb_template_serialnet.c

Modified: head/sys/dev/usb/template/usb_template.h
==
--- head/sys/dev/usb/template/usb_template.hMon May 21 14:53:22 2018
(r333981)
+++ head/sys/dev/usb/template/usb_template.hMon May 21 15:06:19 2018
(r333982)
@@ -33,7 +33,12 @@
 #define_USB_TEMPLATE_H_
 
 #ifndef USB_TEMPLATE_VENDOR
-#defineUSB_TEMPLATE_VENDOR 0x0001
+/*
+ * https://github.com/obdev/v-usb/blob/master/usbdrv/USB-IDs-for-free.txt
+ */
+#defineUSB_TEMPLATE_VENDOR 0x16c0
+#defineUSB_TEMPLATE_MANUFACTURER   \
+   "The FreeBSD Project (https://www.FreeBSD.org)"
 #endif
 
 typedef const void *(usb_temp_get_string_desc_t)(uint16_t lang_id, uint8_t 
string_index);

Modified: head/sys/dev/usb/template/usb_template_audio.c
==
--- head/sys/dev/usb/template/usb_template_audio.c  Mon May 21 14:53:22 
2018(r333981)
+++ head/sys/dev/usb/template/usb_template_audio.c  Mon May 21 15:06:19 
2018(r333982)
@@ -79,11 +79,11 @@ enum {
 };
 
 #defineAUDIO_DEFAULT_VENDOR_ID USB_TEMPLATE_VENDOR
-#defineAUDIO_DEFAULT_PRODUCT_ID0x000A
+#defineAUDIO_DEFAULT_PRODUCT_ID0x05dc
 #defineAUDIO_DEFAULT_MIXER "Mixer interface"
 #defineAUDIO_DEFAULT_RECORD"Record interface"
 #defineAUDIO_DEFAULT_PLAYBACK  "Playback interface"
-#defineAUDIO_DEFAULT_MANUFACTURER  "FreeBSD foundation"
+#defineAUDIO_DEFAULT_MANUFACTURER  USB_TEMPLATE_MANUFACTURER
 #defineAUDIO_DEFAULT_PRODUCT   "Audio Test Device"
 #defineAUDIO_DEFAULT_SERIAL_NUMBER "March 2008"
 

Modified: head/sys/dev/usb/template/usb_template_cdce.c
==
--- head/sys/dev/usb/template/usb_template_cdce.c   Mon May 21 14:53:22 
2018(r333981)
+++ head/sys/dev/usb/template/usb_template_cdce.c   Mon May 21 15:06:19 
2018(r333982)
@@ -80,12 +80,12 @@ enum {
 };
 
 #defineETH_DEFAULT_VENDOR_ID   USB_TEMPLATE_VENDOR
-#defineETH_DEFAULT_PRODUCT_ID  0x0001
+#defineETH_DEFAULT_PRODUCT_ID  0x05dc
 #defineETH_DEFAULT_MAC "2A02030405060789AB"
 #defineETH_DEFAULT_CONTROL "USB Ethernet Comm Interface"
 #defineETH_DEFAULT_DATA"USB Ethernet Data Interface"
 #defineETH_DEFAULT_CONFIG  "Default Config"
-#defineETH_DEFAULT_MANUFACTURER"FreeBSD foundation"
+#defineETH_DEFAULT_MANUFACTURERUSB_TEMPLATE_MANUFACTURER
 #defineETH_DEFAULT_PRODUCT "USB Ethernet Adapter"
 #defineETH_DEFAULT_SERIAL_NUMBER   "December 2007"
 

Modified: head/sys/dev/usb/template/usb_template_kbd.c
==
--- head/sys/dev/usb/template/usb_template_kbd.cMon May 21 14:53:22 
2018(r333981)
+++ head/sys/dev/usb/template/usb_template_kbd.cMon May 21 15:06:19 
2018(r333982)
@@ -77,9 +77,9 @@ enum {
 };
 
 #defineKBD_DEFAULT_VENDOR_ID   USB_TEMPLATE_VENDOR
-#defineKBD_DEFAULT_PRODUCT_ID  0x00CB
+#defineKBD_DEFAULT_PRODUCT_ID  0x27db
 #defineKBD_DEFAULT_INTERFACE   "Keyboard Interface"
-#defineKBD_DEFAULT_MANUFACTURER"FreeBSD foundation"
+#defineKBD_DEFAULT_MANUFACTURERUSB_TEMPLATE_MANUFACTURER
 #defineKBD_DEFAULT_PRODUCT "Keyboard Test Device"
 #defineKBD_DEFAULT_SERIAL_NUMBER   "March 2008"
 

Modified: head/sys/dev/usb/template/usb_template_midi.c
==
--- 

svn commit: r333981 - head/sys/netinet

2018-05-21 Thread Michael Tuexen
Author: tuexen
Date: Mon May 21 14:53:22 2018
New Revision: 333981
URL: https://svnweb.freebsd.org/changeset/base/333981

Log:
  Only fillin data srucuture when actually stored.

Modified:
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctputil.c
==
--- head/sys/netinet/sctputil.c Mon May 21 14:52:18 2018(r333980)
+++ head/sys/netinet/sctputil.c Mon May 21 14:53:22 2018(r333981)
@@ -72,7 +72,8 @@ extern const struct sctp_ss_functions sctp_ss_function
 void
 sctp_sblog(struct sockbuf *sb, struct sctp_tcb *stcb, int from, int incr)
 {
-   struct sctp_cwnd_log sctp_clog __unused;
+#if defined(SCTP_LOCAL_TRACE_BUF)
+   struct sctp_cwnd_log sctp_clog;
 
sctp_clog.x.sb.stcb = stcb;
sctp_clog.x.sb.so_sbcc = sb->sb_cc;
@@ -88,12 +89,14 @@ sctp_sblog(struct sockbuf *sb, struct sctp_tcb *stcb, 
sctp_clog.x.misc.log2,
sctp_clog.x.misc.log3,
sctp_clog.x.misc.log4);
+#endif
 }
 
 void
 sctp_log_closing(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int16_t loc)
 {
-   struct sctp_cwnd_log sctp_clog __unused;
+#if defined(SCTP_LOCAL_TRACE_BUF)
+   struct sctp_cwnd_log sctp_clog;
 
sctp_clog.x.close.inp = (void *)inp;
sctp_clog.x.close.sctp_flags = inp->sctp_flags;
@@ -112,12 +115,14 @@ sctp_log_closing(struct sctp_inpcb *inp, struct sctp_t
sctp_clog.x.misc.log2,
sctp_clog.x.misc.log3,
sctp_clog.x.misc.log4);
+#endif
 }
 
 void
 rto_logging(struct sctp_nets *net, int from)
 {
-   struct sctp_cwnd_log sctp_clog __unused;
+#if defined(SCTP_LOCAL_TRACE_BUF)
+   struct sctp_cwnd_log sctp_clog;
 
memset(_clog, 0, sizeof(sctp_clog));
sctp_clog.x.rto.net = (void *)net;
@@ -129,12 +134,14 @@ rto_logging(struct sctp_nets *net, int from)
sctp_clog.x.misc.log2,
sctp_clog.x.misc.log3,
sctp_clog.x.misc.log4);
+#endif
 }
 
 void
 sctp_log_strm_del_alt(struct sctp_tcb *stcb, uint32_t tsn, uint16_t sseq, 
uint16_t stream, int from)
 {
-   struct sctp_cwnd_log sctp_clog __unused;
+#if defined(SCTP_LOCAL_TRACE_BUF)
+   struct sctp_cwnd_log sctp_clog;
 
sctp_clog.x.strlog.stcb = stcb;
sctp_clog.x.strlog.n_tsn = tsn;
@@ -149,12 +156,14 @@ sctp_log_strm_del_alt(struct sctp_tcb *stcb, uint32_t 
sctp_clog.x.misc.log2,
sctp_clog.x.misc.log3,
sctp_clog.x.misc.log4);
+#endif
 }
 
 void
 sctp_log_nagle_event(struct sctp_tcb *stcb, int action)
 {
-   struct sctp_cwnd_log sctp_clog __unused;
+#if defined(SCTP_LOCAL_TRACE_BUF)
+   struct sctp_cwnd_log sctp_clog;
 
sctp_clog.x.nagle.stcb = (void *)stcb;
sctp_clog.x.nagle.total_flight = stcb->asoc.total_flight;
@@ -168,12 +177,14 @@ sctp_log_nagle_event(struct sctp_tcb *stcb, int action
sctp_clog.x.misc.log2,
sctp_clog.x.misc.log3,
sctp_clog.x.misc.log4);
+#endif
 }
 
 void
 sctp_log_sack(uint32_t old_cumack, uint32_t cumack, uint32_t tsn, uint16_t 
gaps, uint16_t dups, int from)
 {
-   struct sctp_cwnd_log sctp_clog __unused;
+#if defined(SCTP_LOCAL_TRACE_BUF)
+   struct sctp_cwnd_log sctp_clog;
 
sctp_clog.x.sack.cumack = cumack;
sctp_clog.x.sack.oldcumack = old_cumack;
@@ -187,12 +198,14 @@ sctp_log_sack(uint32_t old_cumack, uint32_t cumack, ui
sctp_clog.x.misc.log2,
sctp_clog.x.misc.log3,
sctp_clog.x.misc.log4);
+#endif
 }
 
 void
 sctp_log_map(uint32_t map, uint32_t cum, uint32_t high, int from)
 {
-   struct sctp_cwnd_log sctp_clog __unused;
+#if defined(SCTP_LOCAL_TRACE_BUF)
+   struct sctp_cwnd_log sctp_clog;
 
memset(_clog, 0, sizeof(sctp_clog));
sctp_clog.x.map.base = map;
@@ -205,12 +218,14 @@ sctp_log_map(uint32_t map, uint32_t cum, uint32_t high
sctp_clog.x.misc.log2,
sctp_clog.x.misc.log3,
sctp_clog.x.misc.log4);
+#endif
 }
 
 void
 sctp_log_fr(uint32_t biggest_tsn, uint32_t biggest_new_tsn, uint32_t tsn, int 
from)
 {
-   struct sctp_cwnd_log sctp_clog __unused;
+#if defined(SCTP_LOCAL_TRACE_BUF)
+   struct sctp_cwnd_log sctp_clog;
 
memset(_clog, 0, sizeof(sctp_clog));
sctp_clog.x.fr.largest_tsn = biggest_tsn;
@@ -223,13 +238,15 @@ sctp_log_fr(uint32_t biggest_tsn, uint32_t biggest_new
sctp_clog.x.misc.log2,
sctp_clog.x.misc.log3,
sctp_clog.x.misc.log4);
+#endif
 }
 
 #ifdef SCTP_MBUF_LOGGING
 void
 sctp_log_mb(struct mbuf *m, int from)
 {
-   struct sctp_cwnd_log sctp_clog __unused;
+#if defined(SCTP_LOCAL_TRACE_BUF)
+   struct sctp_cwnd_log sctp_clog;
 
sctp_clog.x.mb.mp = m;
sctp_clog.x.mb.mbuf_flags = (uint8_t)(SCTP_BUF_GET_FLAGS(m));
@@ -249,6 +266,7 @@ sctp_log_mb(struct mbuf *m, int from)
sctp_clog.x.misc.log2,
sctp_clog.x.misc.log3,

svn commit: r333980 - head/sys/netinet

2018-05-21 Thread Michael Tuexen
Author: tuexen
Date: Mon May 21 14:52:18 2018
New Revision: 333980
URL: https://svnweb.freebsd.org/changeset/base/333980

Log:
  Do the appropriate accounting when ip_output() fails.

Modified:
  head/sys/netinet/sctp_output.c

Modified: head/sys/netinet/sctp_output.c
==
--- head/sys/netinet/sctp_output.c  Mon May 21 14:51:20 2018
(r333979)
+++ head/sys/netinet/sctp_output.c  Mon May 21 14:52:18 2018
(r333980)
@@ -11030,9 +11030,8 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockad
struct sctp_chunkhdr *ch;
 #if defined(INET) || defined(INET6)
struct udphdr *udp;
-   int ret __unused;
 #endif
-   int len, cause_len, padding_len;
+   int ret, len, cause_len, padding_len;
 #ifdef INET
struct sockaddr_in *src_sin, *dst_sin;
struct ip *ip;
@@ -11259,9 +11258,13 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockad
SCTP_LTRACE_ERR_RET_PKT(mout, NULL, NULL, NULL, 
SCTP_FROM_SCTP_OUTPUT, EFAULT);
return;
}
+   SCTPDBG(SCTP_DEBUG_OUTPUT3, "return from send is %d\n", ret);
SCTP_STAT_INCR(sctps_sendpackets);
SCTP_STAT_INCR_COUNTER64(sctps_outpackets);
SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
+   if (ret) {
+   SCTP_STAT_INCR(sctps_senderrors);
+   }
return;
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333979 - head/sys/netinet

2018-05-21 Thread Michael Tuexen
Author: tuexen
Date: Mon May 21 14:51:20 2018
New Revision: 333979
URL: https://svnweb.freebsd.org/changeset/base/333979

Log:
  Make clear why there is an assignment, which is not necessary.

Modified:
  head/sys/netinet/sctp_indata.c

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Mon May 21 13:08:44 2018
(r333978)
+++ head/sys/netinet/sctp_indata.c  Mon May 21 14:51:20 2018
(r333979)
@@ -1671,8 +1671,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struc
 struct sctp_nets *net, uint32_t *high_tsn, int *abort_flag,
 int *break_flag, int last_chunk, uint8_t chk_type)
 {
-   /* Process a data chunk */
-   struct sctp_tmit_chunk *chk = NULL;
+   struct sctp_tmit_chunk *chk = NULL; /* make gcc happy */
uint32_t tsn, fsn, gap, mid;
struct mbuf *dmbuf;
int the_len;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333959 - head/usr.bin/top

2018-05-21 Thread Ian Lepore
On Mon, 2018-05-21 at 09:46 +0100, Andrew Turner wrote:
> 
> > 
> > On 21 May 2018, at 04:58, Eitan Adler  wrote:
> > 
> > Author: eadler
> > Date: Mon May 21 03:58:15 2018
> > New Revision: 333959
> > URL: https://svnweb.freebsd.org/changeset/base/333959
> > 
> > Log:
> >  top(1): build with WARNS=3
> > 
> >  This fixes everything but
> >  -Wincompatible-pointer-types-discards-qualifiers
> > 
> > Modified:
> >  head/usr.bin/top/Makefile
> >  head/usr.bin/top/display.c
> >  head/usr.bin/top/display.h
> >  head/usr.bin/top/machine.h
> >  head/usr.bin/top/top.c
> > 
> > Modified: head/usr.bin/top/Makefile
> > ==
> > --- head/usr.bin/top/Makefile   Mon May 21 03:36:16 2018
> > (r333958)
> > +++ head/usr.bin/top/Makefile   Mon May 21 03:58:15 2018
> > (r333959)
> > @@ -7,7 +7,7 @@ SRCS+=  sigdesc.h top.local.h
> > CFLAGS+= -I ${.OBJDIR}
> > MAN=top.1
> > 
> > -WARNS?=2
> > +WARNS?=3
> > 
> > LIBADD= ncursesw m kvm jail
> > 
> > 
> > Modified: head/usr.bin/top/display.c
> > ==
> > --- head/usr.bin/top/display.c  Mon May 21 03:36:16 2018
> > (r333958)
> > +++ head/usr.bin/top/display.c  Mon May 21 03:58:15 2018
> > (r333959)
> > @@ -32,6 +32,7 @@
> > 
> > #include 
> > #include 
> > +#include 
> > #include 
> > #include 
> > #include 
> > @@ -1042,14 +1043,16 @@ display_header(int t)
> > }
> > }
> > 
> > -/*VARARGS2*/
> > void
> > -new_message(int type, char *msgfmt, caddr_t a1, caddr_t a2, caddr_t a3)
> > +new_message(int type, char *msgfmt, ...)
> > {
> > -int i;
> > +va_list args;
> > +size_t i;
> > 
> > +va_start(args, msgfmt);
> > +
> > /* first, format the message */
> > -snprintf(next_msg, sizeof(next_msg), msgfmt, a1, a2, a3);
> > +snprintf(next_msg, sizeof(next_msg), msgfmt, args);
> > 
> > if (msglen > 0)
> > {
> You missed the call to va_end. You need to call va_end within the same 
> function, and after you have finished with args. See stdarg(3):
> 
> Each invocation of va_start() or va_copy() must be paired with a 
> corresponding invocation of va_end() in the same function.
> 
> Andrew

Also, you can't pass a va_list to snprintf(), it needs to be
vsnprintf().  And new_message() should now have a __printf_like
attribute.

-- Ian

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


Re: svn commit: r333915 - head/sys/netinet

2018-05-21 Thread Jonathan T. Looney
Summary: I'm not sure this addresses all the subtleties of INPCB
destruction. I think it would benefit from wider review. I suggest it be
reverted in the meantime.

On Sun, May 20, 2018 at 12:38 AM, Matt Macy  wrote:

> +
> +/*
> + * Unconditionally schedule an inpcb to be freed by decrementing its
> + * reference count, which should occur only after the inpcb has been
> detached
> + * from its socket.  If another thread holds a temporary reference
> (acquired
> + * using in_pcbref()) then the free is deferred until that reference is
> + * released using in_pcbrele(), but the inpcb is still unlocked.  Almost
> all
> + * work, including removal from global lists, is done in this context,
> where
> + * the pcbinfo lock is held.
> + */
> +void
> +in_pcbfree(struct inpcb *inp)
> +{
> +   struct inpcbinfo *pcbinfo = inp->inp_pcbinfo;
> +
> +   KASSERT(inp->inp_socket == NULL, ("%s: inp_socket != NULL",
> __func__));
> +   KASSERT((inp->inp_flags2 & INP_FREED) == 0,
> +   ("%s: called twice for pcb %p", __func__, inp));
> +   if (inp->inp_flags2 & INP_FREED) {
> INP_WUNLOCK(inp);
> +   return;
> +   }
>

This check no longer serves its purpose; however, I believe it points to a
deeper problem: INP_FREED is not set until the deferred epoch context. So,
other threads may not know that another thread has already called
in_pcbfree.

This changes things, such as the behavior of in_pcbrele_[rw]locked().

In the worst case, if someone calls in_pcbfree() twice, the two calls to
in_pcbremlists() will result in running `LIST_REMOVE(inp, inp_list)` twice,
resulting in memory corruption.

I haven't undertaken to audit all the code. However, the fact that
in_pcbrele_[rw]locked() will no longer immediately return 1 may change
logic such that this is now possible.


> +
> +#ifdef INVARIANTS
> +   if (pcbinfo == _tcbinfo) {
> +   INP_INFO_LOCK_ASSERT(pcbinfo);
> +   } else {
> +   INP_INFO_WLOCK_ASSERT(pcbinfo);
> +   }
> +#endif
> +   INP_WLOCK_ASSERT(inp);
> +   /* Remove first from list */
> +   INP_LIST_WLOCK(pcbinfo);
> +   inp->inp_gencnt = ++pcbinfo->ipi_gencnt;
> +   in_pcbremlists(inp);
>

in_pcbremlists() also increments inp->inp_gencnt(); therefore, it is not
necessary to increment it above.



> +   INP_LIST_WUNLOCK(pcbinfo);
> +   RO_INVALIDATE_CACHE(>inp_route);
> +   INP_WUNLOCK(inp);
> +   epoch_call(net_epoch_preempt, >inp_epoch_ctx,
> in_pcbfree_deferred);
>  }
>
>  /*
>
> Modified: head/sys/netinet/in_pcb.h
> 
> ==
> --- head/sys/netinet/in_pcb.h   Sun May 20 04:32:48 2018(r333914)
> +++ head/sys/netinet/in_pcb.h   Sun May 20 04:38:04 2018(r333915)
> @@ -328,6 +328,7 @@ struct inpcb {
> LIST_ENTRY(inpcb) inp_list; /* (p/l) list for all PCBs for
> proto */
> /* (p[w]) for list iteration */
> /* (p[r]/l) for addition/removal */
> +   struct epoch_context inp_epoch_ctx;
>  };
>  #endif /* _KERNEL */
>
>
>
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333911 - head/sys/netinet

2018-05-21 Thread Jonathan Looney
On Sat, May 19, 2018 at 10:27 PM, Matt Macy  wrote:

> +   il = malloc(sizeof(struct in_pcblist) + n * sizeof(struct inpcb
> *), M_TEMP, M_WAITOK|M_ZERO);
> +   inp_list = il->il_inp_list;
>

Why does this need M_ZERO?

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


svn commit: r333978 - in head/sys: netinet netinet6

2018-05-21 Thread Ed Maste
Author: emaste
Date: Mon May 21 13:08:44 2018
New Revision: 333978
URL: https://svnweb.freebsd.org/changeset/base/333978

Log:
  Pair CURVNET_SET and CURVNET_RESTORE in a block
  
  Per vnet(9), CURVNET_SET and CURVNET_RESTORE cannot be used as a single
  statement for a conditional and CURVNET_RESTORE must be in the same
  block as CURVNET_SET (or a subblock).
  
  Reviewed by:  andrew
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/netinet/in_mcast.c
  head/sys/netinet6/in6_mcast.c

Modified: head/sys/netinet/in_mcast.c
==
--- head/sys/netinet/in_mcast.c Mon May 21 13:08:18 2018(r333977)
+++ head/sys/netinet/in_mcast.c Mon May 21 13:08:44 2018(r333978)
@@ -663,15 +663,17 @@ inm_release(struct in_multi *inm)
 
/* XXX this access is not covered by IF_ADDR_LOCK */
CTR2(KTR_IGMPV3, "%s: purging ifma %p", __func__, ifma);
-   if (ifp)
+   if (ifp != NULL) {
CURVNET_SET(ifp->if_vnet);
-   inm_purge(inm);
-   free(inm, M_IPMADDR);
-
-   if_delmulti_ifma_flags(ifma, 1);
-   if (ifp) {
+   inm_purge(inm);
+   free(inm, M_IPMADDR);
+   if_delmulti_ifma_flags(ifma, 1);
CURVNET_RESTORE();
if_rele(ifp);
+   } else {
+   inm_purge(inm);
+   free(inm, M_IPMADDR);
+   if_delmulti_ifma_flags(ifma, 1);
}
 }
 
@@ -1677,11 +1679,13 @@ inp_gcmoptions(epoch_context_t ctx)
imf_leave(imf);
inm = imo->imo_membership[idx];
ifp = inm->inm_ifp;
-   if (ifp)
+   if (ifp != NULL) {
CURVNET_SET(ifp->if_vnet);
-   (void)in_leavegroup(inm, imf);
-   if (ifp)
+   (void)in_leavegroup(inm, imf);
CURVNET_RESTORE();
+   } else {
+   (void)in_leavegroup(inm, imf);
+   }
if (imf)
imf_purge(imf);
}

Modified: head/sys/netinet6/in6_mcast.c
==
--- head/sys/netinet6/in6_mcast.c   Mon May 21 13:08:18 2018
(r333977)
+++ head/sys/netinet6/in6_mcast.c   Mon May 21 13:08:44 2018
(r333978)
@@ -539,15 +539,17 @@ in6m_release(struct in6_multi *inm)
KASSERT(ifma->ifma_protospec == NULL,
("%s: ifma_protospec != NULL", __func__));
 
-   if (ifp)
+   if (ifp != NULL) {
CURVNET_SET(ifp->if_vnet);
-   in6m_purge(inm);
-   free(inm, M_IP6MADDR);
-
-   if_delmulti_ifma_flags(ifma, 1);
-   if (ifp) {
+   in6m_purge(inm);
+   free(inm, M_IP6MADDR);
+   if_delmulti_ifma_flags(ifma, 1);
CURVNET_RESTORE();
if_rele(ifp);
+   } else {
+   in6m_purge(inm);
+   free(inm, M_IP6MADDR);
+   if_delmulti_ifma_flags(ifma, 1);
}
 }
 
@@ -1639,11 +1641,13 @@ inp_gcmoptions(epoch_context_t ctx)
im6f_leave(imf);
inm = imo->im6o_membership[idx];
ifp = inm->in6m_ifp;
-   if (ifp)
+   if (ifp != NULL) {
CURVNET_SET(ifp->if_vnet);
-   (void)in6_leavegroup(inm, imf);
-   if (ifp)
+   (void)in6_leavegroup(inm, imf);
CURVNET_RESTORE();
+   } else {
+   (void)in6_leavegroup(inm, imf);
+   }
if (imf)
im6f_purge(imf);
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333968 - in head/sys: netinet netinet6

2018-05-21 Thread Hans Petter Selasky

On 05/21/18 13:49, Ed Maste wrote:

After r333968 the build is also broken on all archs but amd64 and i386.


It looks like amd64 and i386 build with VIMAGE enabled by default, while 
the others not. 12-current. So both VIMAGE and non-VIMAGE should be tested.


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


svn commit: r333976 - head/release/arm64

2018-05-21 Thread Emmanuel Vadot
Author: manu
Date: Mon May 21 11:58:02 2018
New Revision: 333976
URL: https://svnweb.freebsd.org/changeset/base/333976

Log:
  release: arm64: Use loader.efi as bootaa64.efi for RPI3 and PINE64
  
  boot1.efi have some trouble to read MBR partitions, it needs them to be
  aligned a certain way while loader.efi can cope with them either way.
  We want to switch to loader.efi as the main efi loader everywhere, it seems
  that arm64 using MBR partition will be the guinea pig.
  
  Tested On: RPI3, Pine64
  Reviewed by:  imp
  Approved by:  gjb

Modified:
  head/release/arm64/PINE64.conf
  head/release/arm64/RPI3.conf

Modified: head/release/arm64/PINE64.conf
==
--- head/release/arm64/PINE64.conf  Mon May 21 11:56:07 2018
(r333975)
+++ head/release/arm64/PINE64.conf  Mon May 21 11:58:02 2018
(r333976)
@@ -34,7 +34,7 @@ arm_install_uboot() {
BOOTFILES="$(chroot ${CHROOTDIR} realpath ${BOOTFILES})"
 
chroot ${CHROOTDIR} mkdir -p ${FATMOUNT}/EFI/BOOT
-   chroot ${CHROOTDIR} cp -p ${BOOTFILES}/efi/boot1/boot1.efi \
+   chroot ${CHROOTDIR} cp -p ${BOOTFILES}/efi/loader/loader.efi \
${FATMOUNT}/EFI/BOOT/bootaa64.efi
chroot ${CHROOTDIR} touch ${UFSMOUNT}/firstboot
sync

Modified: head/release/arm64/RPI3.conf
==
--- head/release/arm64/RPI3.confMon May 21 11:56:07 2018
(r333975)
+++ head/release/arm64/RPI3.confMon May 21 11:58:02 2018
(r333976)
@@ -54,7 +54,7 @@ arm_install_uboot() {
BOOTFILES="$(chroot ${CHROOTDIR} realpath ${BOOTFILES})"
 
chroot ${CHROOTDIR} mkdir -p ${FATMOUNT}/EFI/BOOT
-   chroot ${CHROOTDIR} cp -p ${BOOTFILES}/efi/boot1/boot1.efi \
+   chroot ${CHROOTDIR} cp -p ${BOOTFILES}/efi/loader/loader.efi \
${FATMOUNT}/EFI/BOOT/bootaa64.efi
chroot ${CHROOTDIR} touch ${UFSMOUNT}/firstboot
sync
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333975 - in head/sys: netinet netinet6

2018-05-21 Thread Ed Maste
Author: emaste
Date: Mon May 21 11:56:07 2018
New Revision: 333975
URL: https://svnweb.freebsd.org/changeset/base/333975

Log:
  Revert r333968, it broke all archs but i386 and amd64

Modified:
  head/sys/netinet/in_mcast.c
  head/sys/netinet6/in6_mcast.c

Modified: head/sys/netinet/in_mcast.c
==
--- head/sys/netinet/in_mcast.c Mon May 21 09:43:50 2018(r333974)
+++ head/sys/netinet/in_mcast.c Mon May 21 11:56:07 2018(r333975)
@@ -653,7 +653,6 @@ inm_release(struct in_multi *inm)
 {
struct ifmultiaddr *ifma;
struct ifnet *ifp;
-   struct vnet *saved_vnet;
 
CTR2(KTR_IGMPV3, "%s: refcount is %d", __func__, inm->inm_refcount);
MPASS(inm->inm_refcount == 0);
@@ -664,16 +663,14 @@ inm_release(struct in_multi *inm)
 
/* XXX this access is not covered by IF_ADDR_LOCK */
CTR2(KTR_IGMPV3, "%s: purging ifma %p", __func__, ifma);
-   if (ifp) {
-   saved_vnet = curvnet;
-   curvnet = ifp->if_vnet;
-   }
+   if (ifp)
+   CURVNET_SET(ifp->if_vnet);
inm_purge(inm);
free(inm, M_IPMADDR);
 
if_delmulti_ifma_flags(ifma, 1);
if (ifp) {
-   curvnet = saved_vnet;
+   CURVNET_RESTORE();
if_rele(ifp);
}
 }
@@ -1669,7 +1666,6 @@ inp_gcmoptions(epoch_context_t ctx)
struct in_mfilter   *imf;
struct in_multi *inm;
struct ifnet *ifp;
-   struct vnet *saved_vnet;
size_t   idx, nmships;
 
imo =  __containerof(ctx, struct ip_moptions, imo_epoch_ctx);
@@ -1681,13 +1677,11 @@ inp_gcmoptions(epoch_context_t ctx)
imf_leave(imf);
inm = imo->imo_membership[idx];
ifp = inm->inm_ifp;
-   if (ifp) {
-   saved_vnet = curvnet;
-   curvnet = ifp->if_vnet;
-   }
+   if (ifp)
+   CURVNET_SET(ifp->if_vnet);
(void)in_leavegroup(inm, imf);
if (ifp)
-   curvnet = saved_vnet;
+   CURVNET_RESTORE();
if (imf)
imf_purge(imf);
}

Modified: head/sys/netinet6/in6_mcast.c
==
--- head/sys/netinet6/in6_mcast.c   Mon May 21 09:43:50 2018
(r333974)
+++ head/sys/netinet6/in6_mcast.c   Mon May 21 11:56:07 2018
(r333975)
@@ -524,7 +524,6 @@ in6m_release(struct in6_multi *inm)
 {
struct ifmultiaddr *ifma;
struct ifnet *ifp;
-   struct vnet *saved_vnet;
 
CTR2(KTR_MLD, "%s: refcount is %d", __func__, inm->in6m_refcount);
 
@@ -540,16 +539,14 @@ in6m_release(struct in6_multi *inm)
KASSERT(ifma->ifma_protospec == NULL,
("%s: ifma_protospec != NULL", __func__));
 
-   if (ifp) {
-   saved_vnet = curvnet;
-   curvnet = ifp->if_vnet;
-   }
+   if (ifp)
+   CURVNET_SET(ifp->if_vnet);
in6m_purge(inm);
free(inm, M_IP6MADDR);
 
if_delmulti_ifma_flags(ifma, 1);
if (ifp) {
-   curvnet = saved_vnet;
+   CURVNET_RESTORE();
if_rele(ifp);
}
 }
@@ -1631,7 +1628,6 @@ inp_gcmoptions(epoch_context_t ctx)
struct in6_mfilter  *imf;
struct in6_multi *inm;
struct ifnet *ifp;
-   struct vnet *saved_vnet;
size_t   idx, nmships;
 
imo =  __containerof(ctx, struct ip6_moptions, imo6_epoch_ctx);
@@ -1643,13 +1639,11 @@ inp_gcmoptions(epoch_context_t ctx)
im6f_leave(imf);
inm = imo->im6o_membership[idx];
ifp = inm->in6m_ifp;
-   if (ifp) {
-   saved_vnet = curvnet;
-   curvnet = ifp->if_vnet;
-   }   
+   if (ifp)
+   CURVNET_SET(ifp->if_vnet);
(void)in6_leavegroup(inm, imf);
if (ifp)
-   curvnet = saved_vnet;
+   CURVNET_RESTORE();
if (imf)
im6f_purge(imf);
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333968 - in head/sys: netinet netinet6

2018-05-21 Thread Ed Maste
On 21 May 2018 at 04:55, Marko Zec  wrote:
> On Mon, 21 May 2018 08:34:10 +
> Matt Macy  wrote:
>
>> Author: mmacy
>> Date: Mon May 21 08:34:10 2018
>> New Revision: 333968
>> URL: https://svnweb.freebsd.org/changeset/base/333968
>>
>> Log:
>>   in(6)_mcast: Expand out vnet set / restore macro so that they work
>> in a conditional block
>>   Reported by:zec at fer.hr
>>
>
> Uhmm...  please don't do this, for at least two reasons:

After r333968 the build is also broken on all archs but amd64 and i386.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2018-05-21 Thread Eitan Adler
Author: eadler
Date: Mon May 21 09:43:50 2018
New Revision: 333974
URL: https://svnweb.freebsd.org/changeset/base/333974

Log:
  top(1): fix build
  
  Remove 'top.local.hs'. This was not noticed since
  /srv/obj/fbsd/srv/src/freebsd/svn/head/amd64.amd64/usr.bin/top/top.local.h
  existed locally on my machine despite "make clean". Only fully removing
  the objdir allowed me to observe the error directly.
  
  Pointyhat to: me

Modified:
  head/usr.bin/top/Makefile
  head/usr.bin/top/display.c
  head/usr.bin/top/top.c
  head/usr.bin/top/username.c

Modified: head/usr.bin/top/Makefile
==
--- head/usr.bin/top/Makefile   Mon May 21 09:32:52 2018(r333973)
+++ head/usr.bin/top/Makefile   Mon May 21 09:43:50 2018(r333974)
@@ -2,8 +2,7 @@
 
 PROG=  top
 SRCS=  commands.c display.c machine.c screen.c top.c \
-   username.c utils.c
-SRCS+= sigdesc.h top.local.h
+   username.c utils.c sigdesc.h
 CFLAGS+= -I ${.OBJDIR}
 MAN=   top.1
 

Modified: head/usr.bin/top/display.c
==
--- head/usr.bin/top/display.c  Mon May 21 09:32:52 2018(r333973)
+++ head/usr.bin/top/display.c  Mon May 21 09:43:50 2018(r333974)
@@ -44,7 +44,6 @@
 #include "layout.h"/* defines for screen position layout */
 #include "display.h"
 #include "top.h"
-#include "top.local.h"
 #include "boolean.h"
 #include "machine.h"   /* we should eliminate this!!! */
 #include "utils.h"

Modified: head/usr.bin/top/top.c
==
--- head/usr.bin/top/top.c  Mon May 21 09:32:52 2018(r333973)
+++ head/usr.bin/top/top.c  Mon May 21 09:43:50 2018(r333974)
@@ -31,7 +31,6 @@
 #include "display.h"   /* interface to display package */
 #include "screen.h"/* interface to screen package */
 #include "top.h"
-#include "top.local.h"
 #include "boolean.h"
 #include "machine.h"
 #include "utils.h"

Modified: head/usr.bin/top/username.c
==
--- head/usr.bin/top/username.c Mon May 21 09:32:52 2018(r333973)
+++ head/usr.bin/top/username.c Mon May 21 09:43:50 2018(r333974)
@@ -37,7 +37,6 @@
 #include 
 #include 
 
-#include "top.local.h"
 #include "utils.h"
 #include "username.h"
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2018-05-21 Thread Eitan Adler
Author: eadler
Date: Mon May 21 09:32:52 2018
New Revision: 333973
URL: https://svnweb.freebsd.org/changeset/base/333973

Log:
  top(1): clean up some "const" related warnings
  
  This leaves at WARNS=6:
  35 warnings in top.c
  88 warnings in machine.c
  
  all of which are either "incompatible-pointer-types-discards-qualifiers"
  or "cast-qual"

Modified:
  head/usr.bin/top/commands.c

Modified: head/usr.bin/top/commands.c
==
--- head/usr.bin/top/commands.c Mon May 21 09:25:21 2018(r333972)
+++ head/usr.bin/top/commands.c Mon May 21 09:32:52 2018(r333973)
@@ -177,8 +177,8 @@ int  *intp;
 
 static struct errs errs[ERRMAX];
 static int errcnt;
-static char *err_toomany = " too many errors occurred";
-static char *err_listem = 
+static char err_toomany[] = " too many errors occurred";
+static char err_listem[] = 
" Many errors occurred.  Press `e' to display the list of errors.";
 
 /* These macros get used to reset and log the errors */
@@ -364,6 +364,11 @@ show_errors()
 }
 }
 
+static char no_proc_specified[] = " no processes specified";
+static char invalid_signal_number[] = " invalid_signal_number";
+static char bad_signal_name[] = " bad signal name";
+static char bad_pri_value[] = " bad priority value";
+
 /*
  *  kill_procs(str) - send signals to processes, much like the "kill"
  * command does; invoked in response to 'k'.
@@ -392,7 +397,7 @@ kill_procs(char *str)
/* explicit signal specified */
if ((nptr = next_field(str)) == NULL)
{
-   return(" kill: no processes specified");
+   return(no_proc_specified);
}
 
if (isdigit(str[1]))
@@ -400,7 +405,7 @@ kill_procs(char *str)
scanint(str + 1, );
if (signum <= 0 || signum >= NSIG)
{
-   return(" invalid signal number");
+   return(invalid_signal_number);
}
}
else 
@@ -418,7 +423,7 @@ kill_procs(char *str)
/* was it ever found */
if (sigp->name == NULL)
{
-   return(" bad signal name");
+   return(bad_signal_name);
}
}
/* put the new pointer in place */
@@ -487,13 +492,13 @@ renice_procs(char *str)
 /* check for validity */
 if (procnum == -1 || prio < PRIO_MIN || prio > PRIO_MAX)
 {
-   return(" bad priority value");
+   return(bad_pri_value);
 }
 
 /* move to the first process number */
 if ((str = next_field(str)) == NULL)
 {
-   return(" no processes specified");
+   return(no_proc_specified);
 }
 
 /* loop thru the process numbers, renicing each one */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2018-05-21 Thread Eitan Adler
Author: eadler
Date: Mon May 21 09:25:21 2018
New Revision: 333972
URL: https://svnweb.freebsd.org/changeset/base/333972

Log:
  top(1): modernize a bit; reduce warnings
  
  - Replace caddr_t with "void *". This reduces
  the number of warnings at WARNS=6
  - use "static" where possible
  - sprinkle const where possible
  
  This leaves at WARNS=6:
  35 warnings in top.c
  88 warnings in machine.c
  7 warnings in commands.c
  
  all of which are either "incompatible-pointer-types-discards-qualifiers"
  or "cast-qual"

Modified:
  head/usr.bin/top/display.c
  head/usr.bin/top/machine.c
  head/usr.bin/top/machine.h
  head/usr.bin/top/screen.c
  head/usr.bin/top/top.c
  head/usr.bin/top/top.h
  head/usr.bin/top/username.c

Modified: head/usr.bin/top/display.c
==
--- head/usr.bin/top/display.c  Mon May 21 09:21:42 2018(r333971)
+++ head/usr.bin/top/display.c  Mon May 21 09:25:21 2018(r333972)
@@ -588,13 +588,10 @@ for (cpu = 0; cpu < num_cpus; cpu++) {
  *for i_memory ONLY: cursor is on the previous line
  */
 
-char memory_buffer[MAX_COLS];
+static char memory_buffer[MAX_COLS];
 
 void
-i_memory(stats)
-
-int *stats;
-
+i_memory(int *stats)
 {
 fputs("\nMem: ", stdout);
 lastline++;
@@ -605,10 +602,7 @@ int *stats;
 }
 
 void
-u_memory(stats)
-
-int *stats;
-
+u_memory(int *stats)
 {
 static char new[MAX_COLS];
 

Modified: head/usr.bin/top/machine.c
==
--- head/usr.bin/top/machine.c  Mon May 21 09:21:42 2018(r333971)
+++ head/usr.bin/top/machine.c  Mon May 21 09:25:21 2018(r333972)
@@ -53,7 +53,6 @@
 #defineSMPUNAMELEN 13
 #defineUPUNAMELEN  15
 
-extern struct process_select ps;
 extern struct timeval timeout;
 static int smpmode;
 enum displaymodes displaymode;
@@ -743,7 +742,7 @@ get_io_total(struct kinfo_proc *pp)
 
 static struct handle handle;
 
-caddr_t
+void *
 get_process_info(struct system_info *si, struct process_select *sel,
 int (*compare)(const void *, const void *))
 {

Modified: head/usr.bin/top/machine.h
==
--- head/usr.bin/top/machine.h  Mon May 21 09:21:42 2018(r333971)
+++ head/usr.bin/top/machine.h  Mon May 21 09:25:21 2018(r333972)
@@ -84,8 +84,9 @@ intproc_owner(int pid);
 
 /* non-int routines typically used by the machine dependent module */
 char   *printable(char *string);
+extern struct process_select ps;
 
-caddr_t
+void *
 get_process_info(struct system_info *si, struct process_select *sel,
 int (*compare)(const void *, const void *));
 

Modified: head/usr.bin/top/screen.c
==
--- head/usr.bin/top/screen.c   Mon May 21 09:21:42 2018(r333971)
+++ head/usr.bin/top/screen.c   Mon May 21 09:25:21 2018(r333972)
@@ -39,18 +39,18 @@ char ch_erase;
 char ch_kill;
 char smart_terminal;
 char PC;
-char termcap_buf[1024];
-char string_buffer[1024];
-char home[15];
-char lower_left[15];
+static char termcap_buf[1024];
+static char string_buffer[1024];
+static char home[15];
+static char lower_left[15];
 char *clear_line;
-char *clear_screen;
+static char *clear_screen;
 char *clear_to_end;
 char *cursor_motion;
-char *start_standout;
-char *end_standout;
-char *terminal_init;
-char *terminal_end;
+static char *start_standout;
+static char *end_standout;
+static char *terminal_init;
+static char *terminal_end;
 
 static struct termios old_settings;
 static struct termios new_settings;

Modified: head/usr.bin/top/top.c
==
--- head/usr.bin/top/top.c  Mon May 21 09:21:42 2018(r333971)
+++ head/usr.bin/top/top.c  Mon May 21 09:25:21 2018(r333972)
@@ -40,7 +40,7 @@
 /* Size of the stdio buffer given to stdout */
 #define Buffersize 2048
 
-char *copyright =
+char copyright[] =
 "Copyright (c) 1984 through 1996, William LeFebvre";
 
 typedef void sigret_t;
@@ -211,7 +211,7 @@ char *argv[];
 
 struct system_info system_info;
 struct statics statics;
-caddr_t processes;
+void * processes;
 
 static char tempbuf1[50];
 static char tempbuf2[50];

Modified: head/usr.bin/top/top.h
==
--- head/usr.bin/top/top.h  Mon May 21 09:21:42 2018(r333971)
+++ head/usr.bin/top/top.h  Mon May 21 09:25:21 2018(r333972)
@@ -53,7 +53,7 @@ extern int (*compares[])(const void*, const void*);
 char* kill_procs(char *);
 char* renice_procs(char *);
 
-extern char *copyright;
+extern char copyright[];
 /* internal routines */
 void quit(int);
 

Modified: head/usr.bin/top/username.c
==
--- 

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

2018-05-21 Thread Eitan Adler
Author: eadler
Date: Mon May 21 09:21:42 2018
New Revision: 333971
URL: https://svnweb.freebsd.org/changeset/base/333971

Log:
  Add missing va_end
  
  Reported by:  andrew

Modified:
  head/usr.bin/top/display.c

Modified: head/usr.bin/top/display.c
==
--- head/usr.bin/top/display.c  Mon May 21 09:20:26 2018(r333970)
+++ head/usr.bin/top/display.c  Mon May 21 09:21:42 2018(r333971)
@@ -1020,6 +1020,8 @@ new_message(int type, char *msgfmt, ...)
 /* first, format the message */
 snprintf(next_msg, sizeof(next_msg), msgfmt, args);
 
+va_end(args);
+
 if (msglen > 0)
 {
/* message there already -- can we clear it? */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2018-05-21 Thread Eitan Adler
Author: eadler
Date: Mon May 21 09:20:26 2018
New Revision: 333970
URL: https://svnweb.freebsd.org/changeset/base/333970

Log:
  Revert r333969 which contained one too many changes

Modified:
  head/usr.bin/top/Makefile
  head/usr.bin/top/commands.c
  head/usr.bin/top/display.c
  head/usr.bin/top/machine.c
  head/usr.bin/top/machine.h
  head/usr.bin/top/screen.c
  head/usr.bin/top/top.c
  head/usr.bin/top/top.h
  head/usr.bin/top/username.c

Modified: head/usr.bin/top/Makefile
==
--- head/usr.bin/top/Makefile   Mon May 21 09:18:01 2018(r333969)
+++ head/usr.bin/top/Makefile   Mon May 21 09:20:26 2018(r333970)
@@ -7,7 +7,7 @@ SRCS+=  sigdesc.h top.local.h
 CFLAGS+= -I ${.OBJDIR}
 MAN=   top.1
 
-WARNS?=6
+WARNS?=3
 
 LIBADD=ncursesw m kvm jail
 

Modified: head/usr.bin/top/commands.c
==
--- head/usr.bin/top/commands.c Mon May 21 09:18:01 2018(r333969)
+++ head/usr.bin/top/commands.c Mon May 21 09:20:26 2018(r333970)
@@ -177,8 +177,8 @@ int  *intp;
 
 static struct errs errs[ERRMAX];
 static int errcnt;
-static char err_toomany[] = " too many errors occurred";
-static char err_listem[] = 
+static char *err_toomany = " too many errors occurred";
+static char *err_listem = 
" Many errors occurred.  Press `e' to display the list of errors.";
 
 /* These macros get used to reset and log the errors */

Modified: head/usr.bin/top/display.c
==
--- head/usr.bin/top/display.c  Mon May 21 09:18:01 2018(r333969)
+++ head/usr.bin/top/display.c  Mon May 21 09:20:26 2018(r333970)
@@ -588,10 +588,13 @@ for (cpu = 0; cpu < num_cpus; cpu++) {
  *for i_memory ONLY: cursor is on the previous line
  */
 
-static char memory_buffer[MAX_COLS];
+char memory_buffer[MAX_COLS];
 
 void
-i_memory(int *stats)
+i_memory(stats)
+
+int *stats;
+
 {
 fputs("\nMem: ", stdout);
 lastline++;
@@ -602,7 +605,10 @@ i_memory(int *stats)
 }
 
 void
-u_memory(int *stats)
+u_memory(stats)
+
+int *stats;
+
 {
 static char new[MAX_COLS];
 

Modified: head/usr.bin/top/machine.c
==
--- head/usr.bin/top/machine.c  Mon May 21 09:18:01 2018(r333969)
+++ head/usr.bin/top/machine.c  Mon May 21 09:20:26 2018(r333970)
@@ -53,6 +53,7 @@
 #defineSMPUNAMELEN 13
 #defineUPUNAMELEN  15
 
+extern struct process_select ps;
 extern struct timeval timeout;
 static int smpmode;
 enum displaymodes displaymode;
@@ -228,7 +229,7 @@ static int pageshift;   /* log base 2 of the 
pagesize *
 /*
  * Sorting orders.  The first element is the default.
  */
-static const char *ordernames[] = {
+char *ordernames[] = {
"cpu", "size", "res", "time", "pri", "threads",
"total", "read", "write", "fault", "vcsw", "ivcsw",
"jid", "swap", "pid", NULL
@@ -742,7 +743,7 @@ get_io_total(struct kinfo_proc *pp)
 
 static struct handle handle;
 
-void *
+caddr_t
 get_process_info(struct system_info *si, struct process_select *sel,
 int (*compare)(const void *, const void *))
 {
@@ -909,13 +910,13 @@ get_process_info(struct system_info *si, struct proces
/* pass back a handle */
handle.next_proc = pref;
handle.remaining = active_procs;
-   return ();
+   return ((caddr_t));
 }
 
 static char fmt[512];  /* static area where result is built */
 
 char *
-format_next_process(void * xhandle, char *(*get_userid)(int), int flags)
+format_next_process(caddr_t xhandle, char *(*get_userid)(int), int flags)
 {
struct kinfo_proc *pp;
const struct kinfo_proc *oldp;

Modified: head/usr.bin/top/machine.h
==
--- head/usr.bin/top/machine.h  Mon May 21 09:18:01 2018(r333969)
+++ head/usr.bin/top/machine.h  Mon May 21 09:20:26 2018(r333970)
@@ -75,18 +75,17 @@ struct process_select
 /* routines defined by the machine dependent module */
 
 char   *format_header(char *uname_field);
-char   *format_next_process(void * handle, char *(*get_userid)(int),
+char   *format_next_process(caddr_t handle, char *(*get_userid)(int),
int flags);
 voidtoggle_pcpustats(void);
 voidget_system_info(struct system_info *si);
 int machine_init(struct statics *statics);
 int proc_owner(int pid);
-extern struct process_select ps;
 
 /* non-int routines typically used by the machine dependent module */
 char   *printable(char *string);
 
-void *
+caddr_t
 get_process_info(struct system_info *si, struct process_select *sel,
 int (*compare)(const void *, const void *));
 

Modified: head/usr.bin/top/screen.c
==

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

2018-05-21 Thread Eitan Adler
Author: eadler
Date: Mon May 21 09:18:01 2018
New Revision: 333969
URL: https://svnweb.freebsd.org/changeset/base/333969

Log:
  top(1): modernize a bit; reduce warnings
  
  - Replace caddr_t with "void *". This reduces
  the number of warnings at WARNS=6
  - use "static" where possible
  - sprinkle const where possible
  
  This leaves at WARNS=6:
  35 warnings in top.c
  72 warnings in machine.c
  5 warnings in commands.c
  
  all of which are either "incompatible-pointer-types-discards-qualifiers"
  or "cast-qual"

Modified:
  head/usr.bin/top/Makefile
  head/usr.bin/top/commands.c
  head/usr.bin/top/display.c
  head/usr.bin/top/machine.c
  head/usr.bin/top/machine.h
  head/usr.bin/top/screen.c
  head/usr.bin/top/top.c
  head/usr.bin/top/top.h
  head/usr.bin/top/username.c

Modified: head/usr.bin/top/Makefile
==
--- head/usr.bin/top/Makefile   Mon May 21 08:34:10 2018(r333968)
+++ head/usr.bin/top/Makefile   Mon May 21 09:18:01 2018(r333969)
@@ -7,7 +7,7 @@ SRCS+=  sigdesc.h top.local.h
 CFLAGS+= -I ${.OBJDIR}
 MAN=   top.1
 
-WARNS?=3
+WARNS?=6
 
 LIBADD=ncursesw m kvm jail
 

Modified: head/usr.bin/top/commands.c
==
--- head/usr.bin/top/commands.c Mon May 21 08:34:10 2018(r333968)
+++ head/usr.bin/top/commands.c Mon May 21 09:18:01 2018(r333969)
@@ -177,8 +177,8 @@ int  *intp;
 
 static struct errs errs[ERRMAX];
 static int errcnt;
-static char *err_toomany = " too many errors occurred";
-static char *err_listem = 
+static char err_toomany[] = " too many errors occurred";
+static char err_listem[] = 
" Many errors occurred.  Press `e' to display the list of errors.";
 
 /* These macros get used to reset and log the errors */

Modified: head/usr.bin/top/display.c
==
--- head/usr.bin/top/display.c  Mon May 21 08:34:10 2018(r333968)
+++ head/usr.bin/top/display.c  Mon May 21 09:18:01 2018(r333969)
@@ -588,13 +588,10 @@ for (cpu = 0; cpu < num_cpus; cpu++) {
  *for i_memory ONLY: cursor is on the previous line
  */
 
-char memory_buffer[MAX_COLS];
+static char memory_buffer[MAX_COLS];
 
 void
-i_memory(stats)
-
-int *stats;
-
+i_memory(int *stats)
 {
 fputs("\nMem: ", stdout);
 lastline++;
@@ -605,10 +602,7 @@ int *stats;
 }
 
 void
-u_memory(stats)
-
-int *stats;
-
+u_memory(int *stats)
 {
 static char new[MAX_COLS];
 

Modified: head/usr.bin/top/machine.c
==
--- head/usr.bin/top/machine.c  Mon May 21 08:34:10 2018(r333968)
+++ head/usr.bin/top/machine.c  Mon May 21 09:18:01 2018(r333969)
@@ -53,7 +53,6 @@
 #defineSMPUNAMELEN 13
 #defineUPUNAMELEN  15
 
-extern struct process_select ps;
 extern struct timeval timeout;
 static int smpmode;
 enum displaymodes displaymode;
@@ -229,7 +228,7 @@ static int pageshift;   /* log base 2 of the 
pagesize *
 /*
  * Sorting orders.  The first element is the default.
  */
-char *ordernames[] = {
+static const char *ordernames[] = {
"cpu", "size", "res", "time", "pri", "threads",
"total", "read", "write", "fault", "vcsw", "ivcsw",
"jid", "swap", "pid", NULL
@@ -743,7 +742,7 @@ get_io_total(struct kinfo_proc *pp)
 
 static struct handle handle;
 
-caddr_t
+void *
 get_process_info(struct system_info *si, struct process_select *sel,
 int (*compare)(const void *, const void *))
 {
@@ -910,13 +909,13 @@ get_process_info(struct system_info *si, struct proces
/* pass back a handle */
handle.next_proc = pref;
handle.remaining = active_procs;
-   return ((caddr_t));
+   return ();
 }
 
 static char fmt[512];  /* static area where result is built */
 
 char *
-format_next_process(caddr_t xhandle, char *(*get_userid)(int), int flags)
+format_next_process(void * xhandle, char *(*get_userid)(int), int flags)
 {
struct kinfo_proc *pp;
const struct kinfo_proc *oldp;

Modified: head/usr.bin/top/machine.h
==
--- head/usr.bin/top/machine.h  Mon May 21 08:34:10 2018(r333968)
+++ head/usr.bin/top/machine.h  Mon May 21 09:18:01 2018(r333969)
@@ -75,17 +75,18 @@ struct process_select
 /* routines defined by the machine dependent module */
 
 char   *format_header(char *uname_field);
-char   *format_next_process(caddr_t handle, char *(*get_userid)(int),
+char   *format_next_process(void * handle, char *(*get_userid)(int),
int flags);
 voidtoggle_pcpustats(void);
 voidget_system_info(struct system_info *si);
 int machine_init(struct statics *statics);
 int proc_owner(int pid);
+extern struct process_select ps;
 
 /* non-int routines typically 

Re: svn commit: r333959 - head/usr.bin/top

2018-05-21 Thread Andrew Turner


> On 21 May 2018, at 04:58, Eitan Adler  wrote:
> 
> Author: eadler
> Date: Mon May 21 03:58:15 2018
> New Revision: 333959
> URL: https://svnweb.freebsd.org/changeset/base/333959
> 
> Log:
>  top(1): build with WARNS=3
> 
>  This fixes everything but
>  -Wincompatible-pointer-types-discards-qualifiers
> 
> Modified:
>  head/usr.bin/top/Makefile
>  head/usr.bin/top/display.c
>  head/usr.bin/top/display.h
>  head/usr.bin/top/machine.h
>  head/usr.bin/top/top.c
> 
> Modified: head/usr.bin/top/Makefile
> ==
> --- head/usr.bin/top/Makefile Mon May 21 03:36:16 2018(r333958)
> +++ head/usr.bin/top/Makefile Mon May 21 03:58:15 2018(r333959)
> @@ -7,7 +7,7 @@ SRCS+=sigdesc.h top.local.h
> CFLAGS+= -I ${.OBJDIR}
> MAN=  top.1
> 
> -WARNS?=  2
> +WARNS?=  3
> 
> LIBADD=   ncursesw m kvm jail
> 
> 
> Modified: head/usr.bin/top/display.c
> ==
> --- head/usr.bin/top/display.cMon May 21 03:36:16 2018
> (r333958)
> +++ head/usr.bin/top/display.cMon May 21 03:58:15 2018
> (r333959)
> @@ -32,6 +32,7 @@
> 
> #include 
> #include 
> +#include 
> #include 
> #include 
> #include 
> @@ -1042,14 +1043,16 @@ display_header(int t)
> }
> }
> 
> -/*VARARGS2*/
> void
> -new_message(int type, char *msgfmt, caddr_t a1, caddr_t a2, caddr_t a3)
> +new_message(int type, char *msgfmt, ...)
> {
> -int i;
> +va_list args;
> +size_t i;
> 
> +va_start(args, msgfmt);
> +
> /* first, format the message */
> -snprintf(next_msg, sizeof(next_msg), msgfmt, a1, a2, a3);
> +snprintf(next_msg, sizeof(next_msg), msgfmt, args);
> 
> if (msglen > 0)
> {

You missed the call to va_end. You need to call va_end within the same 
function, and after you have finished with args. See stdarg(3):

Each invocation of va_start() or va_copy() must be paired with a corresponding 
invocation of va_end() in the same function.

Andrew

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


Re: svn commit: r333968 - in head/sys: netinet netinet6

2018-05-21 Thread Marko Zec
On Mon, 21 May 2018 08:34:10 +
Matt Macy  wrote:

> Author: mmacy
> Date: Mon May 21 08:34:10 2018
> New Revision: 333968
> URL: https://svnweb.freebsd.org/changeset/base/333968
> 
> Log:
>   in(6)_mcast: Expand out vnet set / restore macro so that they work
> in a conditional block 
>   Reported by:zec at fer.hr
> 
> Modified:
>   head/sys/netinet/in_mcast.c
>   head/sys/netinet6/in6_mcast.c
> 
> Modified: head/sys/netinet/in_mcast.c
> ==
> --- head/sys/netinet/in_mcast.c   Mon May 21 07:12:06
> 2018  (r333967) +++ head/sys/netinet/in_mcast.c   Mon May
> 21 08:34:10 2018  (r333968) @@ -653,6 +653,7 @@
> inm_release(struct in_multi *inm) {
>   struct ifmultiaddr *ifma;
>   struct ifnet *ifp;
> + struct vnet *saved_vnet;
>  
>   CTR2(KTR_IGMPV3, "%s: refcount is %d", __func__,
> inm->inm_refcount); MPASS(inm->inm_refcount == 0);
> @@ -663,14 +664,16 @@ inm_release(struct in_multi *inm)
>  
>   /* XXX this access is not covered by IF_ADDR_LOCK */
>   CTR2(KTR_IGMPV3, "%s: purging ifma %p", __func__, ifma);
> - if (ifp)
> - CURVNET_SET(ifp->if_vnet);
> + if (ifp) {
> + saved_vnet = curvnet;
> + curvnet = ifp->if_vnet;
> + }

Uhmm...  please don't do this, for at least two reasons:

1) so far we could identify all VNET context switches by tracking
CURVNET_SET / _RESTORE macros.  With this change a non-standard hack is
introduced, opening the door for more alternative / creative variations
to come, thus increasing the entropy

2) CURVNET_* macros provide elementary capability of tracking vnet
recursions, and much more importantly, forgotten or missed context
restores.  Your change breaks this tracking chain.

Is there a reason one could not extend struct in_multi with a struct
vnet *inm_vnet entry, populate it on struct in_multi creation, and be
done with all curvnet woes in a clean way?

Marko


>   inm_purge(inm);
>   free(inm, M_IPMADDR);
>  
>   if_delmulti_ifma_flags(ifma, 1);
>   if (ifp) {
> - CURVNET_RESTORE();
> + curvnet = saved_vnet;
>   if_rele(ifp);
>   }
>  }
> @@ -1666,6 +1669,7 @@ inp_gcmoptions(epoch_context_t ctx)
>   struct in_mfilter   *imf;
>   struct in_multi *inm;
>   struct ifnet *ifp;
> + struct vnet *saved_vnet;
>   size_t   idx, nmships;
>  
>   imo =  __containerof(ctx, struct ip_moptions, imo_epoch_ctx);
> @@ -1677,11 +1681,13 @@ inp_gcmoptions(epoch_context_t ctx)
>   imf_leave(imf);
>   inm = imo->imo_membership[idx];
>   ifp = inm->inm_ifp;
> - if (ifp)
> - CURVNET_SET(ifp->if_vnet);
> + if (ifp) {
> + saved_vnet = curvnet;
> + curvnet = ifp->if_vnet;
> + }
>   (void)in_leavegroup(inm, imf);
>   if (ifp)
> - CURVNET_RESTORE();
> + curvnet = saved_vnet;
>   if (imf)
>   imf_purge(imf);
>   }
> 
> Modified: head/sys/netinet6/in6_mcast.c
> ==
> --- head/sys/netinet6/in6_mcast.c Mon May 21 07:12:06
> 2018  (r333967) +++ head/sys/netinet6/in6_mcast.c Mon
> May 21 08:34:10 2018  (r333968) @@ -524,6 +524,7 @@
> in6m_release(struct in6_multi *inm) {
>   struct ifmultiaddr *ifma;
>   struct ifnet *ifp;
> + struct vnet *saved_vnet;
>  
>   CTR2(KTR_MLD, "%s: refcount is %d", __func__,
> inm->in6m_refcount); 
> @@ -539,14 +540,16 @@ in6m_release(struct in6_multi *inm)
>   KASSERT(ifma->ifma_protospec == NULL,
>   ("%s: ifma_protospec != NULL", __func__));
>  
> - if (ifp)
> - CURVNET_SET(ifp->if_vnet);
> + if (ifp) {
> + saved_vnet = curvnet;
> + curvnet = ifp->if_vnet;
> + }
>   in6m_purge(inm);
>   free(inm, M_IP6MADDR);
>  
>   if_delmulti_ifma_flags(ifma, 1);
>   if (ifp) {
> - CURVNET_RESTORE();
> + curvnet = saved_vnet;
>   if_rele(ifp);
>   }
>  }
> @@ -1628,6 +1631,7 @@ inp_gcmoptions(epoch_context_t ctx)
>   struct in6_mfilter  *imf;
>   struct in6_multi *inm;
>   struct ifnet *ifp;
> + struct vnet *saved_vnet;
>   size_t   idx, nmships;
>  
>   imo =  __containerof(ctx, struct ip6_moptions,
> imo6_epoch_ctx); @@ -1639,11 +1643,13 @@
> inp_gcmoptions(epoch_context_t ctx) im6f_leave(imf);
>   inm = imo->im6o_membership[idx];
>   ifp = inm->in6m_ifp;
> - if (ifp)
> - CURVNET_SET(ifp->if_vnet);
> + if (ifp) {
> + saved_vnet = curvnet;
> + curvnet = ifp->if_vnet;
> + }   

svn commit: r333968 - in head/sys: netinet netinet6

2018-05-21 Thread Matt Macy
Author: mmacy
Date: Mon May 21 08:34:10 2018
New Revision: 333968
URL: https://svnweb.freebsd.org/changeset/base/333968

Log:
  in(6)_mcast: Expand out vnet set / restore macro so that they work in a 
conditional block
  
  Reported by:  zec at fer.hr

Modified:
  head/sys/netinet/in_mcast.c
  head/sys/netinet6/in6_mcast.c

Modified: head/sys/netinet/in_mcast.c
==
--- head/sys/netinet/in_mcast.c Mon May 21 07:12:06 2018(r333967)
+++ head/sys/netinet/in_mcast.c Mon May 21 08:34:10 2018(r333968)
@@ -653,6 +653,7 @@ inm_release(struct in_multi *inm)
 {
struct ifmultiaddr *ifma;
struct ifnet *ifp;
+   struct vnet *saved_vnet;
 
CTR2(KTR_IGMPV3, "%s: refcount is %d", __func__, inm->inm_refcount);
MPASS(inm->inm_refcount == 0);
@@ -663,14 +664,16 @@ inm_release(struct in_multi *inm)
 
/* XXX this access is not covered by IF_ADDR_LOCK */
CTR2(KTR_IGMPV3, "%s: purging ifma %p", __func__, ifma);
-   if (ifp)
-   CURVNET_SET(ifp->if_vnet);
+   if (ifp) {
+   saved_vnet = curvnet;
+   curvnet = ifp->if_vnet;
+   }
inm_purge(inm);
free(inm, M_IPMADDR);
 
if_delmulti_ifma_flags(ifma, 1);
if (ifp) {
-   CURVNET_RESTORE();
+   curvnet = saved_vnet;
if_rele(ifp);
}
 }
@@ -1666,6 +1669,7 @@ inp_gcmoptions(epoch_context_t ctx)
struct in_mfilter   *imf;
struct in_multi *inm;
struct ifnet *ifp;
+   struct vnet *saved_vnet;
size_t   idx, nmships;
 
imo =  __containerof(ctx, struct ip_moptions, imo_epoch_ctx);
@@ -1677,11 +1681,13 @@ inp_gcmoptions(epoch_context_t ctx)
imf_leave(imf);
inm = imo->imo_membership[idx];
ifp = inm->inm_ifp;
-   if (ifp)
-   CURVNET_SET(ifp->if_vnet);
+   if (ifp) {
+   saved_vnet = curvnet;
+   curvnet = ifp->if_vnet;
+   }
(void)in_leavegroup(inm, imf);
if (ifp)
-   CURVNET_RESTORE();
+   curvnet = saved_vnet;
if (imf)
imf_purge(imf);
}

Modified: head/sys/netinet6/in6_mcast.c
==
--- head/sys/netinet6/in6_mcast.c   Mon May 21 07:12:06 2018
(r333967)
+++ head/sys/netinet6/in6_mcast.c   Mon May 21 08:34:10 2018
(r333968)
@@ -524,6 +524,7 @@ in6m_release(struct in6_multi *inm)
 {
struct ifmultiaddr *ifma;
struct ifnet *ifp;
+   struct vnet *saved_vnet;
 
CTR2(KTR_MLD, "%s: refcount is %d", __func__, inm->in6m_refcount);
 
@@ -539,14 +540,16 @@ in6m_release(struct in6_multi *inm)
KASSERT(ifma->ifma_protospec == NULL,
("%s: ifma_protospec != NULL", __func__));
 
-   if (ifp)
-   CURVNET_SET(ifp->if_vnet);
+   if (ifp) {
+   saved_vnet = curvnet;
+   curvnet = ifp->if_vnet;
+   }
in6m_purge(inm);
free(inm, M_IP6MADDR);
 
if_delmulti_ifma_flags(ifma, 1);
if (ifp) {
-   CURVNET_RESTORE();
+   curvnet = saved_vnet;
if_rele(ifp);
}
 }
@@ -1628,6 +1631,7 @@ inp_gcmoptions(epoch_context_t ctx)
struct in6_mfilter  *imf;
struct in6_multi *inm;
struct ifnet *ifp;
+   struct vnet *saved_vnet;
size_t   idx, nmships;
 
imo =  __containerof(ctx, struct ip6_moptions, imo6_epoch_ctx);
@@ -1639,11 +1643,13 @@ inp_gcmoptions(epoch_context_t ctx)
im6f_leave(imf);
inm = imo->im6o_membership[idx];
ifp = inm->in6m_ifp;
-   if (ifp)
-   CURVNET_SET(ifp->if_vnet);
+   if (ifp) {
+   saved_vnet = curvnet;
+   curvnet = ifp->if_vnet;
+   }   
(void)in6_leavegroup(inm, imf);
if (ifp)
-   CURVNET_RESTORE();
+   curvnet = saved_vnet;
if (imf)
im6f_purge(imf);
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333967 - head/sys/netinet

2018-05-21 Thread Marko Zec
On Mon, 21 May 2018 01:03:53 -0700
Matthew Macy  wrote:
> On Mon, May 21, 2018 at 00:47 Marko Zec  wrote:
> > On Mon, 21 May 2018 07:12:06 + Matt Macy  wrote:
...
> > > + if (ifp)
> > > + CURVNET_SET(ifp->if_vnet);  
> >
> > Unfortunately, this won't work because CURVNET_SET() expands to a
> > sequence of declarations and assignments which are NOT enclosed in a
> > single block.  Instead, only the first statement in CURVNET_SET()
> > sequence, which is an assert, will be executed conditionally only if
> > ifp != NULL, while the rest of the CURVNET_SET() body will fall out
> > of the scope of the if (ifp) conditional.
> 
> That's pretty counter to the way macros are done _everywhere_ else in
> the kernel. 

Agreed, unfortunately it is.

> You should probably fix that.

This problem was discussed on numerous occasions but no better / more
convenient and workable proposals come up so far.

Bjoern clearly documented and emphasized this problem in vnet(9).

Marko

> 
> 
> > I'd recommend backing out this patch, and instead extending the
> > struct ip_moptions with an struct vnet * entry, which would be
> > populated before scheduling inp_gcmoptions().  Then
> > CURVNET_SET(imo->imo_vnet) could be called only once (and
> > unconditionally) in gcmoptions(), instead of (attempts at) doing
> > this multiple times in a for loop.
> >
> > Marko
> >
> >  
> > > + (void)in_leavegroup(inm, imf);
> > > + if (ifp)
> > > + CURVNET_RESTORE();
> > >   if (imf)
> > >   imf_purge(imf);
> > >   }
> > >  
> >
> >  

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


Re: svn commit: r333967 - head/sys/netinet

2018-05-21 Thread Matthew Macy
On Mon, May 21, 2018 at 00:47 Marko Zec  wrote:

> On Mon, 21 May 2018 07:12:06 +
> Matt Macy  wrote:
>
> > Author: mmacy
> > Date: Mon May 21 07:12:06 2018
> > New Revision: 333967
> > URL: https://svnweb.freebsd.org/changeset/base/333967
> >
> > Log:
> >   ensure that vnet is set when doing in_leavegroup
> >
> > Modified:
> >   head/sys/netinet/in_mcast.c
> >
> > Modified: head/sys/netinet/in_mcast.c
> >
> ==
> > --- head/sys/netinet/in_mcast.c   Mon May 21 05:20:23
> > 2018  (r333966) +++ head/sys/netinet/in_mcast.c   Mon May
> > 21 07:12:06 2018  (r333967) @@ -1664,6 +1664,8 @@
> > inp_gcmoptions(epoch_context_t ctx) {
> >   struct ip_moptions *imo;
> >   struct in_mfilter   *imf;
> > + struct in_multi *inm;
> > + struct ifnet *ifp;
> >   size_t   idx, nmships;
> >
> >   imo =  __containerof(ctx, struct ip_moptions, imo_epoch_ctx);
> > @@ -1673,7 +1675,13 @@ inp_gcmoptions(epoch_context_t ctx)
> >   imf = imo->imo_mfilters ? >imo_mfilters[idx] :
> > NULL; if (imf)
> >   imf_leave(imf);
> > - (void)in_leavegroup(imo->imo_membership[idx], imf);
> > + inm = imo->imo_membership[idx];
> > + ifp = inm->inm_ifp;
> > + if (ifp)
> > + CURVNET_SET(ifp->if_vnet);
>
> Unfortunately, this won't work because CURVNET_SET() expands to a
> sequence of declarations and assignments which are NOT enclosed in a
> single block.  Instead, only the first statement in CURVNET_SET()
> sequence, which is an assert, will be executed conditionally only if
> ifp != NULL, while the rest of the CURVNET_SET() body will fall out of
> the scope of the if (ifp) conditional.
>

That's pretty counter to the way macros are done _everywhere_ else in the
kernel. You should probably fix that.


> I'd recommend backing out this patch, and instead extending the struct
> ip_moptions with an struct vnet * entry, which would be populated
> before scheduling inp_gcmoptions().  Then CURVNET_SET(imo->imo_vnet)
> could be called only once (and unconditionally) in gcmoptions(),
> instead of (attempts at) doing this multiple times in a for loop.
>
> Marko
>
>
> > + (void)in_leavegroup(inm, imf);
> > + if (ifp)
> > + CURVNET_RESTORE();
> >   if (imf)
> >   imf_purge(imf);
> >   }
> >
>
>
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333967 - head/sys/netinet

2018-05-21 Thread Matthew Macy
Thanks

On Mon, May 21, 2018 at 00:47 Marko Zec  wrote:

> On Mon, 21 May 2018 07:12:06 +
> Matt Macy  wrote:
>
> > Author: mmacy
> > Date: Mon May 21 07:12:06 2018
> > New Revision: 333967
> > URL: https://svnweb.freebsd.org/changeset/base/333967
> >
> > Log:
> >   ensure that vnet is set when doing in_leavegroup
> >
> > Modified:
> >   head/sys/netinet/in_mcast.c
> >
> > Modified: head/sys/netinet/in_mcast.c
> >
> ==
> > --- head/sys/netinet/in_mcast.c   Mon May 21 05:20:23
> > 2018  (r333966) +++ head/sys/netinet/in_mcast.c   Mon May
> > 21 07:12:06 2018  (r333967) @@ -1664,6 +1664,8 @@
> > inp_gcmoptions(epoch_context_t ctx) {
> >   struct ip_moptions *imo;
> >   struct in_mfilter   *imf;
> > + struct in_multi *inm;
> > + struct ifnet *ifp;
> >   size_t   idx, nmships;
> >
> >   imo =  __containerof(ctx, struct ip_moptions, imo_epoch_ctx);
> > @@ -1673,7 +1675,13 @@ inp_gcmoptions(epoch_context_t ctx)
> >   imf = imo->imo_mfilters ? >imo_mfilters[idx] :
> > NULL; if (imf)
> >   imf_leave(imf);
> > - (void)in_leavegroup(imo->imo_membership[idx], imf);
> > + inm = imo->imo_membership[idx];
> > + ifp = inm->inm_ifp;
> > + if (ifp)
> > + CURVNET_SET(ifp->if_vnet);
>
> Unfortunately, this won't work because CURVNET_SET() expands to a
> sequence of declarations and assignments which are NOT enclosed in a
> single block.  Instead, only the first statement in CURVNET_SET()
> sequence, which is an assert, will be executed conditionally only if
> ifp != NULL, while the rest of the CURVNET_SET() body will fall out of
> the scope of the if (ifp) conditional.
>
> I'd recommend backing out this patch, and instead extending the struct
> ip_moptions with an struct vnet * entry, which would be populated
> before scheduling inp_gcmoptions().  Then CURVNET_SET(imo->imo_vnet)
> could be called only once (and unconditionally) in gcmoptions(),
> instead of (attempts at) doing this multiple times in a for loop.
>
> Marko
>
>
> > + (void)in_leavegroup(inm, imf);
> > + if (ifp)
> > + CURVNET_RESTORE();
> >   if (imf)
> >   imf_purge(imf);
> >   }
> >
>
>
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333967 - head/sys/netinet

2018-05-21 Thread Marko Zec
On Mon, 21 May 2018 07:12:06 +
Matt Macy  wrote:

> Author: mmacy
> Date: Mon May 21 07:12:06 2018
> New Revision: 333967
> URL: https://svnweb.freebsd.org/changeset/base/333967
> 
> Log:
>   ensure that vnet is set when doing in_leavegroup
> 
> Modified:
>   head/sys/netinet/in_mcast.c
> 
> Modified: head/sys/netinet/in_mcast.c
> ==
> --- head/sys/netinet/in_mcast.c   Mon May 21 05:20:23
> 2018  (r333966) +++ head/sys/netinet/in_mcast.c   Mon May
> 21 07:12:06 2018  (r333967) @@ -1664,6 +1664,8 @@
> inp_gcmoptions(epoch_context_t ctx) {
>   struct ip_moptions *imo;
>   struct in_mfilter   *imf;
> + struct in_multi *inm;
> + struct ifnet *ifp;
>   size_t   idx, nmships;
>  
>   imo =  __containerof(ctx, struct ip_moptions, imo_epoch_ctx);
> @@ -1673,7 +1675,13 @@ inp_gcmoptions(epoch_context_t ctx)
>   imf = imo->imo_mfilters ? >imo_mfilters[idx] :
> NULL; if (imf)
>   imf_leave(imf);
> - (void)in_leavegroup(imo->imo_membership[idx], imf);
> + inm = imo->imo_membership[idx];
> + ifp = inm->inm_ifp;
> + if (ifp)
> + CURVNET_SET(ifp->if_vnet);

Unfortunately, this won't work because CURVNET_SET() expands to a
sequence of declarations and assignments which are NOT enclosed in a
single block.  Instead, only the first statement in CURVNET_SET()
sequence, which is an assert, will be executed conditionally only if
ifp != NULL, while the rest of the CURVNET_SET() body will fall out of
the scope of the if (ifp) conditional.

I'd recommend backing out this patch, and instead extending the struct
ip_moptions with an struct vnet * entry, which would be populated
before scheduling inp_gcmoptions().  Then CURVNET_SET(imo->imo_vnet)
could be called only once (and unconditionally) in gcmoptions(),
instead of (attempts at) doing this multiple times in a for loop.

Marko


> + (void)in_leavegroup(inm, imf);
> + if (ifp)
> + CURVNET_RESTORE();
>   if (imf)
>   imf_purge(imf);
>   }
> 

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


svn commit: r333967 - head/sys/netinet

2018-05-21 Thread Matt Macy
Author: mmacy
Date: Mon May 21 07:12:06 2018
New Revision: 333967
URL: https://svnweb.freebsd.org/changeset/base/333967

Log:
  ensure that vnet is set when doing in_leavegroup

Modified:
  head/sys/netinet/in_mcast.c

Modified: head/sys/netinet/in_mcast.c
==
--- head/sys/netinet/in_mcast.c Mon May 21 05:20:23 2018(r333966)
+++ head/sys/netinet/in_mcast.c Mon May 21 07:12:06 2018(r333967)
@@ -1664,6 +1664,8 @@ inp_gcmoptions(epoch_context_t ctx)
 {
struct ip_moptions *imo;
struct in_mfilter   *imf;
+   struct in_multi *inm;
+   struct ifnet *ifp;
size_t   idx, nmships;
 
imo =  __containerof(ctx, struct ip_moptions, imo_epoch_ctx);
@@ -1673,7 +1675,13 @@ inp_gcmoptions(epoch_context_t ctx)
imf = imo->imo_mfilters ? >imo_mfilters[idx] : NULL;
if (imf)
imf_leave(imf);
-   (void)in_leavegroup(imo->imo_membership[idx], imf);
+   inm = imo->imo_membership[idx];
+   ifp = inm->inm_ifp;
+   if (ifp)
+   CURVNET_SET(ifp->if_vnet);
+   (void)in_leavegroup(inm, imf);
+   if (ifp)
+   CURVNET_RESTORE();
if (imf)
imf_purge(imf);
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333945 - head/usr.bin/top

2018-05-21 Thread Alexey Dokuchaev
On Mon, May 21, 2018 at 10:32:30AM +1000, Bruce Evans wrote:
> ...
> > if (smpmode && namelength > SMPUNAMELEN)
> > namelength = SMPUNAMELEN;
> > else if (namelength > UPUNAMELEN)
> 
> But 33 is too large.  It is much larger than the hard-coded maximum limits,
> so it is never used, but is reduced to SMPNAMELEN = 13 or UPUNAMELEN = 15.
> 
> So getting the correct value of about 8 is even harder than before, but
> changing SMPNAMELEN to 4 works quite well -- "USERNAME" in the header is
> then reduced to "USER" and space is made available for something useful
> like the command name.

Big +1.  I didn't go as far as 4, but have to patch top(1) locally to use
namelength = 8 and header format so it neatly looks like this:

  PID USERNAME THR PRI NICE   SIZERES STATE   C   TIMEWCPU COMMAND
  844 danfe  2  210   114M 38836K select  0  49:39   3.82% Xorg
 5836 danfe 12  200   101M 23020K select  0  38:19   2.26% deadbeef

instead of our ugly, default this:

  
  PID USERNAMETHR PRI NICE   SIZERES STATE   C   TIMEWCPU COMMAND
41086 danfe 1  200 13280K  3112K CPU11   0:00   0.09% top
  751 root  1  200 10812K   596K select  2  16:53   0.03% powerd
  ^^
The amount of wasted space (shown above) is unjustified IMO.

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