Re: svn commit: r334305 - head/sys/net

2018-05-28 Thread Peter Holm
On Tue, May 29, 2018 at 12:53:54AM +, Matt Macy wrote:
> Author: mmacy
> Date: Tue May 29 00:53:53 2018
> New Revision: 334305
> URL: https://svnweb.freebsd.org/changeset/base/334305
> 
> Log:
>   route: fix missed ref adds
>- ensure that we bump the ifa ref whenever we add a reference
>- defer freeing epoch protected references until after the if_purgaddrs
>  loop
> 
> Modified:
>   head/sys/net/if.c
>   head/sys/net/route.c
> 
> Modified: head/sys/net/if.c
> ==
> --- head/sys/net/if.c Tue May 29 00:19:23 2018(r334304)

Writing entropy file:.
Setting hostname: flix1a.netperf.freebsd.org.
lo0: link state changed to UP
Kernel page fault with the following non-sleepable locks held:
exclusive sleep mutex nd6 onlink (nd6 onlink) r = 0 (0xfe00e4fa7a98) locked 
@ netinet6/nd6_rtr.c:1145
stack backtrace:
#0 0x80be2923 at witness_debugger+0x73
#1 0x80be3d01 at witness_warn+0x461
#2 0x8104c753 at trap_pfault+0x53
#3 0x8104bdd7 at trap+0x2c7
#4 0x810277cc at calltrap+0x8
#5 0x80ca7276 at rtrequest1_fib+0x496
#6 0x80ca7de0 at rtrequest_fib+0x70
#7 0x80de628b at nd6_prefix_onlink+0x40b
#8 0x80de5daf at nd6_prelist_add+0x22f
#9 0x80dc17a4 at in6_ifattach+0x6e4
#10 0x80c7cd7a at if_up+0x6a
#11 0x80c7ebec at ifioctl+0x1a9c
#12 0x80be8009 at kern_ioctl+0x2b9
#13 0x80be7cdc at sys_ioctl+0x15c
#14 0x8104d067 at amd64_syscall+0x2a7
#15 0x810280ad at fast_syscall_common+0x101


Fatal trap 12: page fault while in kernel mode
cpuid = 31; apic id = 25
fault virtual address   = 0x18
fault code  = supervisor read data, page not present
instruction pointer = 0x20:0x80ca873b
stack pointer   = 0x28:0xfe00edce4ad0
frame pointer   = 0x28:0xfe00edce4b00
code segment= base 0x0, limit 0xf, type 0x1b
= DPL 0, pres 1, long 1, def32 0, gran 1
processor eflags= interrupt enabled, resume, IOPL = 0
current process = 321 (ifconfig)
[ thread pid 321 tid 100799 ]
Stopped at  rt_getifa_fib+0x12b:movq0x18(%r13),%rax
db> bt
Tracing pid 321 tid 100799 td 0xf8017a2af000
rt_getifa_fib() at rt_getifa_fib+0x12b/frame 0xfe00edce4b00
rtrequest1_fib() at rtrequest1_fib+0x496/frame 0xfe00edce4c00
rtrequest_fib() at rtrequest_fib+0x70/frame 0xfe00edce4cc0
nd6_prefix_onlink() at nd6_prefix_onlink+0x40b/frame 0xfe00edce4e10
nd6_prelist_add() at nd6_prelist_add+0x22f/frame 0xfe00edce4e90
in6_ifattach() at in6_ifattach+0x6e4/frame 0xfe00edce4fd0
if_up() at if_up+0x6a/frame 0xfe00edce5000
ifioctl() at ifioctl+0x1a9c/frame 0xfe00edce50d0
kern_ioctl() at kern_ioctl+0x2b9/frame 0xfe00edce5130
sys_ioctl() at sys_ioctl+0x15c/frame 0xfe00edce5200
amd64_syscall() at amd64_syscall+0x2a7/frame 0xfe00edce5330
fast_syscall_common() at fast_syscall_common+0x101/frame 0xfe00edce5330
--- syscall (54, FreeBSD ELF64, sys_ioctl), rip = 0x80047e83a, rsp = 
0x7fffe428, rbp = 0x7fffe480 ---
db> x/s version
version:FreeBSD 12.0-CURRENT #0 r334313: Tue May 29 06:47:31 CEST 
2018\012p...@flix1a.netperf.freebsd.org:/usr/src/sys/amd64/compile/PHO\012
db> 

- Peter
___
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: r334312 - head/lib/libpmc

2018-05-28 Thread Matt Macy
Author: mmacy
Date: Tue May 29 04:23:16 2018
New Revision: 334312
URL: https://svnweb.freebsd.org/changeset/base/334312

Log:
  libpmc: export names of counters for stat mode, make get_by_idx name 
consistent with others

Modified:
  head/lib/libpmc/libpmc_pmu_util.c   (contents, props changed)
  head/lib/libpmc/pmc.h
  head/lib/libpmc/pmclog.c

Modified: head/lib/libpmc/libpmc_pmu_util.c
==
--- head/lib/libpmc/libpmc_pmu_util.c   Tue May 29 04:04:06 2018
(r334311)
+++ head/lib/libpmc/libpmc_pmu_util.c   Tue May 29 04:23:16 2018
(r334312)
@@ -131,7 +131,7 @@ pmu_event_get(const char *event_name, int *idx)
 }
 
 const char *
-pmu_event_get_by_idx(int idx)
+pmc_pmu_event_get_by_idx(int idx)
 {
const struct pmu_events_map *pme;
const struct pmu_event *pe;
@@ -321,6 +321,27 @@ pmc_pmu_pmcallocate(const char *event_name, struct pmc
return (0);
 }
 
+/*
+ * Ultimately rely on AMD calling theirs the same
+ */
+static const char *stat_mode_cntrs[] = {
+   "inst_retired.any",
+   "cpu_clk_unhalted.thread_p_any",
+   "br_inst_retired.all_branches",
+   "br_misp_retired.all_branches",
+   "cpu_clk_unhalted.thread_p_any"
+};
+
+int
+pmc_pmu_stat_mode(const char ***cntrs)
+{
+   if (pmc_pmu_enabled()) {
+   *cntrs = stat_mode_cntrs;
+   return (0);
+   }
+   return (EOPNOTSUPP);
+}
+
 #else
 uint64_t pmc_pmu_sample_rate_get(const char *event_name __unused) { return 
(DEFAULT_SAMPLE_COUNT); }
 void pmc_pmu_print_counters(void) {}
@@ -328,6 +349,7 @@ void pmc_pmu_print_counter_desc(const char *e __unused
 void pmc_pmu_print_counter_desc_long(const char *e __unused) {}
 int pmc_pmu_enabled(void) { return (0); }
 int pmc_pmu_pmcallocate(const char *e __unused, struct pmc_op_pmcallocate *p 
__unused) { return (EOPNOTSUPP); }
-const char *pmu_event_get_by_idx(int idx __unused) { return (NULL); }
+const char *pmc_pmu_event_get_by_idx(int idx __unused) { return (NULL); }
+int pmc_pmu_stat_mode(const char ***a __unused) { return (EOPNOTSUPP); }
 
 #endif

Modified: head/lib/libpmc/pmc.h
==
--- head/lib/libpmc/pmc.h   Tue May 29 04:04:06 2018(r334311)
+++ head/lib/libpmc/pmc.h   Tue May 29 04:23:16 2018(r334312)
@@ -119,7 +119,8 @@ void pmc_pmu_print_counter_desc(const char *);
 void pmc_pmu_print_counter_desc_long(const char *);
 uint64_t pmc_pmu_sample_rate_get(const char *);
 int pmc_pmu_pmcallocate(const char *, struct pmc_op_pmcallocate *);
-const char *pmu_event_get_by_idx(int idx);
+const char *pmc_pmu_event_get_by_idx(int idx);
+int pmc_pmu_stat_mode(const char ***);
 __END_DECLS
 
 #endif

Modified: head/lib/libpmc/pmclog.c
==
--- head/lib/libpmc/pmclog.cTue May 29 04:04:06 2018(r334311)
+++ head/lib/libpmc/pmclog.cTue May 29 04:23:16 2018(r334312)
@@ -368,7 +368,7 @@ pmclog_get_event(void *cookie, char **data, ssize_t *l
PMCLOG_READ32(le,ev->pl_u.pl_a.pl_event);
PMCLOG_READ32(le,ev->pl_u.pl_a.pl_flags);
PMCLOG_READ32(le,noop);
-   ev->pl_u.pl_a.pl_evname = 
pmu_event_get_by_idx(ev->pl_u.pl_a.pl_event);
+   ev->pl_u.pl_a.pl_evname = 
pmc_pmu_event_get_by_idx(ev->pl_u.pl_a.pl_event);
if (ev->pl_u.pl_a.pl_evname != NULL)
break;
else if ((ev->pl_u.pl_a.pl_evname =
___
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: r334313 - head/lib/libpmc

2018-05-28 Thread Matt Macy
Author: mmacy
Date: Tue May 29 04:23:21 2018
New Revision: 334313
URL: https://svnweb.freebsd.org/changeset/base/334313

Log:
  libpmc: add support for using fixed function counters

Modified:
  head/lib/libpmc/libpmc_pmu_util.c   (contents, props changed)

Modified: head/lib/libpmc/libpmc_pmu_util.c
==
--- head/lib/libpmc/libpmc_pmu_util.c   Tue May 29 04:23:16 2018
(r334312)
+++ head/lib/libpmc/libpmc_pmu_util.c   Tue May 29 04:23:21 2018
(r334313)
@@ -63,6 +63,14 @@ static struct pmu_alias pmu_alias_table[] = {
{ NULL, NULL },
 };
 
+static const char *fixed_mode_cntrs[] = {
+   "inst_retired.any",
+   "cpu_clk_unhalted.thread",
+   "cpu_clk_unhalted.thread_any",
+   "cpu_clk_unhalted.ref_tsc",
+   NULL
+};
+
 static const char *
 pmu_alias_get(const char *name)
 {
@@ -288,11 +296,15 @@ pmc_pmu_pmcallocate(const char *event_name, struct pmc
const struct pmu_event *pe;
struct pmu_event_desc ped;
struct pmc_md_iap_op_pmcallocate *iap;
-   int idx;
+   struct pmc_md_iaf_op_pmcallocate *iaf;
+   int idx, isfixed;
 
iap = &pm->pm_md.pm_iap;
+   iaf = &pm->pm_md.pm_iaf;
+   isfixed = 0;
bzero(iap, sizeof(*iap));
event_name = pmu_alias_get(event_name);
+   pm->pm_caps |= (PMC_CAP_READ | PMC_CAP_WRITE);
if ((pe = pmu_event_get(event_name, &idx)) == NULL)
return (ENOENT);
if (pe->alias && (pe = pmu_event_get(pe->alias, &idx)) == NULL)
@@ -302,6 +314,29 @@ pmc_pmu_pmcallocate(const char *event_name, struct pmc
if (pmu_parse_event(&ped, pe->event))
return (ENOENT);
 
+   for (idx = 0; fixed_mode_cntrs[idx] != NULL; idx++)
+   if (strcmp(fixed_mode_cntrs[idx], event_name) == 0) {
+   isfixed = 1;
+   printf("%s is fixed\n", event_name);
+   }
+
+   if (isfixed) {
+   if (strcasestr(pe->desc, "retired") != NULL)
+   pm->pm_ev = PMC_EV_IAF_INSTR_RETIRED_ANY;
+   else if (strcasestr(pe->desc, "core") != NULL ||
+strcasestr(pe->desc, "unhalted"))
+   pm->pm_ev = PMC_EV_IAF_CPU_CLK_UNHALTED_CORE;
+   else if (strcasestr(pe->desc, "ref") != NULL)
+   pm->pm_ev = PMC_EV_IAF_CPU_CLK_UNHALTED_REF;
+   iaf->pm_iaf_flags |= (IAF_USR | IAF_OS);
+   if (ped.ped_any)
+   iaf->pm_iaf_flags |= IAF_ANY;
+   if (pm->pm_caps & PMC_CAP_INTERRUPT)
+   iaf->pm_iaf_flags |= IAF_PMI;
+   pm->pm_class = PMC_CLASS_IAF;
+   return (0);
+   }
+   pm->pm_caps |= PMC_CAP_QUALIFIER;
pm->pm_class = PMC_CLASS_IAP;
pm->pm_ev = idx;
iap->pm_iap_config |= IAP_EVSEL(ped.ped_event);
@@ -325,11 +360,12 @@ pmc_pmu_pmcallocate(const char *event_name, struct pmc
  * Ultimately rely on AMD calling theirs the same
  */
 static const char *stat_mode_cntrs[] = {
+   "cpu_clk_unhalted.thread_any",
"inst_retired.any",
-   "cpu_clk_unhalted.thread_p_any",
"br_inst_retired.all_branches",
"br_misp_retired.all_branches",
-   "cpu_clk_unhalted.thread_p_any"
+   "longest_lat_cache.reference",
+   "longest_lat_cache.miss",
 };
 
 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: r334311 - head/sys/dev/hwpmc

2018-05-28 Thread Matt Macy
Author: mmacy
Date: Tue May 29 04:04:06 2018
New Revision: 334311
URL: https://svnweb.freebsd.org/changeset/base/334311

Log:
  hwpmc: don't incrorrectly strip the ANY flag

Modified:
  head/sys/dev/hwpmc/hwpmc_core.c

Modified: head/sys/dev/hwpmc/hwpmc_core.c
==
--- head/sys/dev/hwpmc/hwpmc_core.c Tue May 29 03:58:29 2018
(r334310)
+++ head/sys/dev/hwpmc/hwpmc_core.c Tue May 29 04:04:06 2018
(r334311)
@@ -256,13 +256,6 @@ iaf_allocate_pmc(int cpu, int ri, struct pmc *pm,
 
validflags = IAF_MASK;
 
-   if (core_cputype != PMC_CPU_INTEL_ATOM &&
-   core_cputype != PMC_CPU_INTEL_ATOM_SILVERMONT)
-   validflags &= ~IAF_ANY;
-
-   if ((flags & ~validflags) != 0)
-   return (EINVAL);
-
if (caps & PMC_CAP_INTERRUPT)
flags |= IAF_PMI;
if (caps & PMC_CAP_SYSTEM)
@@ -445,10 +438,6 @@ iaf_stop_pmc(int cpu, int ri)
("[core,%d] illegal row-index %d", __LINE__, ri));
 
fc = (IAF_MASK << (ri * 4));
-
-   if (core_cputype != PMC_CPU_INTEL_ATOM &&
-   core_cputype != PMC_CPU_INTEL_ATOM_SILVERMONT)
-   fc &= ~IAF_ANY;
 
iafc->pc_iafctrl &= ~fc;
 
___
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: r334310 - head/stand/efi/boot1

2018-05-28 Thread Warner Losh
Author: imp
Date: Tue May 29 03:58:29 2018
New Revision: 334310
URL: https://svnweb.freebsd.org/changeset/base/334310

Log:
  Teach ufs_module.c about bsd labels and probe 'a' partition.
  
  If the check for a UFS partition at offset 0 on the disk fails, check
  to see if there's a BSD disklabel at block 1 (standard) or at offset
  512 (install images assume 512 sector size). If found, probe for UFS
  on the 'a' partition.
  
  This fixes UEFI booting images from a BSD labeled MBR slice when the
  'a' partiton isn't at offset 0. This is a stop-gap fix since we plan
  on removing boot1.efi in FreeBSD 12. We can't easily do that for 11.2,
  however, hence the short MFC window.
  
  Tested by: emaste@
  MFC After: 3 days
  Sponsored by: Netflix
  Differential Revision: https://reviews.freebsd.org/D15598

Modified:
  head/stand/efi/boot1/boot_module.h
  head/stand/efi/boot1/ufs_module.c

Modified: head/stand/efi/boot1/boot_module.h
==
--- head/stand/efi/boot1/boot_module.h  Tue May 29 03:19:56 2018
(r334309)
+++ head/stand/efi/boot1/boot_module.h  Tue May 29 03:58:29 2018
(r334310)
@@ -50,6 +50,7 @@ typedef struct dev_info
EFI_DEVICE_PATH *devpath;
EFI_HANDLE *devhandle;
void *devdata;
+   uint64_t partoff;
BOOLEAN preferred;
struct dev_info *next;
 } dev_info_t;

Modified: head/stand/efi/boot1/ufs_module.c
==
--- head/stand/efi/boot1/ufs_module.c   Tue May 29 03:19:56 2018
(r334309)
+++ head/stand/efi/boot1/ufs_module.c   Tue May 29 03:58:29 2018
(r334310)
@@ -36,10 +36,14 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "boot_module.h"
 
+#define BSD_LABEL_BUFFER   8192
+#define BSD_LABEL_OFFSET   DEV_BSIZE
+
 static dev_info_t *devinfo;
 static dev_info_t *devices;
 
@@ -49,6 +53,7 @@ dskread(void *buf, uint64_t lba, int nblk)
int size;
EFI_STATUS status;
 
+   lba += devinfo->partoff;
lba = lba / (devinfo->dev->Media->BlockSize / DEV_BSIZE);
size = nblk * DEV_BSIZE;
 
@@ -73,11 +78,50 @@ static struct dmadat __dmadat;
 static int
 init_dev(dev_info_t* dev)
 {
+   char buffer[BSD_LABEL_BUFFER];
+   struct disklabel *dl;
+   uint64_t bs;
+   int ok;
 
devinfo = dev;
dmadat = &__dmadat;
 
-   return fsread(0, NULL, 0);
+   /*
+* First try offset 0. This is the typical GPT case where we have no
+* further partitioning (as well as the degenerate MBR case where
+* the bsdlabel has a 0 offset).
+*/
+   devinfo->partoff = 0;
+   ok = fsread(0, NULL, 0);
+   if (ok >= 0)
+   return (ok);
+
+   /*
+* Next, we look for a bsdlabel. This is technically located in sector
+* 1. For 4k sectors, this offset is 4096, for 512b sectors it's
+* 512. However, we have to fall back to 512 here because we create
+* images that assume 512 byte blocks, but these can be put on devices
+* who have 4k (or other) block sizes. If there's a crazy block size, we
+* skip the 'at one sector' and go stright to checking at 512 bytes.
+* There are other offsets that are historic, but we don't probe those
+* since they were never used for MBR disks on FreeBSD on systems that
+* could boot UEFI. UEFI is little endian only, as are BSD labels. We
+* will retry fsread(0) only if there's a label found with a non-zero
+* offset.
+*/
+   if (dskread(buffer, 0, BSD_LABEL_BUFFER / DEV_BSIZE) != 0)
+   return (-1);
+   dl = NULL;
+   bs = devinfo->dev->Media->BlockSize;
+   if (bs != 0 && bs <= BSD_LABEL_BUFFER / 2)
+   dl = (struct disklabel *)&buffer[bs];
+   if (dl == NULL || dl->d_magic != BSD_MAGIC || dl->d_magic2 != BSD_MAGIC)
+   dl = (struct disklabel *)&buffer[BSD_LABEL_OFFSET];
+   if (dl->d_magic != BSD_MAGIC || dl->d_magic2 != BSD_MAGIC ||
+   dl->d_partitions[0].p_offset == 0)
+   return (-1);
+   devinfo->partoff = dl->d_partitions[0].p_offset;
+   return (fsread(0, NULL, 0));
 }
 
 static EFI_STATUS
___
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: r334306 - in head: lib/libc/stdlib share/man/man3

2018-05-28 Thread Bruce Evans

On Tue, 29 May 2018, Eric van Gyzen wrote:


Log:
 Cross-reference abort2(2) from a few man pages

 I didn't know abort2 existed until it was mentioned on a mailing list.
 Mention it in related pages so others can find it easily.

 MFC after: 3 days
 Sponsored by:  Dell EMC

Modified:
 head/lib/libc/stdlib/abort.3
 head/lib/libc/stdlib/exit.3
 head/share/man/man3/assert.3


exit(3) is negatively related.  abort2() exists mainly because it is invalid
to call non-signal-safe functions like exit() from signal handlers.

exit(3) correctly doesn't reference abort(3) or any of the many other
functions that call it, e.g., perror(3) or err(3), or many functions
that it calls.  The references correctly go only towards exit() from
its callers, This is especially interesting for abort() -- since abort()
calls exit(), it is broken as specified and cannot be called from
signal handlers.  Its man page doesn't actually say that it calls
exit(), but says that
- it flushes and closes any open streams
- it is thread-safe
- it is unknown if it is async-signal state
Its reference to exit(3) is the usual nodescript one in the SEE ALSO section
with no hint about why the other man pages might be relevant.  Readers must
read and understand the closure of the tree of cross references to determine
the relevances.

I just remembered that abort() flushing and closing open streams and
possibly calling exit() is not a design error, but just a bug in some OS's
and some versions of POSIX.

In C99, flushing and closing of open streams in abort() is
implementation-defined.  Only systems with primitive signal handling
can hope to flush or close open streams in async-signal handlers
(mostly by not supporting any such handlers).

POSIX might have been such a system, and it required closing open
streams in at least its 1990 and 2001 versions.  These versions also
didn't require abort() to be async-signal-safe.

This is fixed in POSIX in at least its 2007 version.  This version
requires abort() to be async-signal-safe and permits but doesn't require
abort() to fclose() open streams.

[Free]BSD has never been such a system.  Its abort() was async-signal
safe before 1996 when it was broken to POSIX spec at the time.  It
hasn't caught up with 2007 POSIX yet: its implementation still calls
stdio and says in a comment that POSIX requires this, and its man page
still claims to not know what the implementation does.  (The man page
is trying to echo the fuzziness of the C standard for abort(), FreeBSD
should document the non-fuzzy although sometimes broken POSIX behaviour,
and the full C standard requires implementations to document their
choices for implementation details.)

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: r334308 - in head: lib/libc/stdlib share/man/man3

2018-05-28 Thread Eric van Gyzen
Author: vangyzen
Date: Tue May 29 02:41:32 2018
New Revision: 334308
URL: https://svnweb.freebsd.org/changeset/base/334308

Log:
  Bump the date on man pages in r334306
  
  It seems a shame to ruin the patina of the June 4, 1993 date
  on abort.3, especially since it still matched the date of
  the SCCS ID, but those are the rules.
  
  Reported by:  araujo
  MFC after:3 days
  Sponsored by: Dell EMC

Modified:
  head/lib/libc/stdlib/abort.3
  head/lib/libc/stdlib/exit.3
  head/share/man/man3/assert.3

Modified: head/lib/libc/stdlib/abort.3
==
--- head/lib/libc/stdlib/abort.3Tue May 29 01:46:00 2018
(r334307)
+++ head/lib/libc/stdlib/abort.3Tue May 29 02:41:32 2018
(r334308)
@@ -32,7 +32,7 @@
 .\" @(#)abort.38.1 (Berkeley) 6/4/93
 .\" $FreeBSD$
 .\"
-.Dd June 4, 1993
+.Dd May 28, 2018
 .Dt ABORT 3
 .Os
 .Sh NAME

Modified: head/lib/libc/stdlib/exit.3
==
--- head/lib/libc/stdlib/exit.3 Tue May 29 01:46:00 2018(r334307)
+++ head/lib/libc/stdlib/exit.3 Tue May 29 02:41:32 2018(r334308)
@@ -32,7 +32,7 @@
 .\" @(#)exit.3 8.1 (Berkeley) 6/4/93
 .\" $FreeBSD$
 .\"
-.Dd September 9, 2002
+.Dd May 28, 2018
 .Dt EXIT 3
 .Os
 .Sh NAME

Modified: head/share/man/man3/assert.3
==
--- head/share/man/man3/assert.3Tue May 29 01:46:00 2018
(r334307)
+++ head/share/man/man3/assert.3Tue May 29 02:41:32 2018
(r334308)
@@ -28,7 +28,7 @@
 .\" @(#)assert.3   8.1 (Berkeley) 6/9/93
 .\" $FreeBSD$
 .\"
-.Dd January 1, 2018
+.Dd May 28, 2018
 .Dt ASSERT 3
 .Os
 .Sh NAME
___
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: r334302 - head/sys/teken

2018-05-28 Thread Bruce Evans

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


Log:
 teken: Sort DECSCUSR alphabetically

 While here, align columns again.

 Reported by:   bde


This unimproves the formatting of 73 lines to improve it for 1.

The number of lines with msialigned columns remains unchanged at 1,
since the #DECID line still has the old formatting.

Marching to the right reduces the space available for the last field from
15-16 columns to 7-8.  This field is for "Arguments".  No sequences have
too many args to fit in 7-8 columns.  However, the header for this field
takes 9 columns, so no longer fits.  The full header now takes 81 columns,
so is misformatted on terminals with less than 81 or 82 columns.

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"


Re: svn commit: r334291 - head/lib/libc/string

2018-05-28 Thread Bruce Evans

On Mon, 28 May 2018, Ed Maste wrote:


Log:
 strsep.3: don't silently ignore errors

 Reported by:   bde
 MFC with:  r334275


Thanks.


Modified: head/lib/libc/string/strsep.3
==
--- head/lib/libc/string/strsep.3   Mon May 28 17:47:32 2018
(r334290)
+++ head/lib/libc/string/strsep.3   Mon May 28 18:29:15 2018
(r334291)
@@ -86,9 +86,10 @@ to parse a string, and prints each token in separate l
char *token, *string, *tofree;

tofree = string = strdup("abc,def,ghi");
-if (string != NULL)
-   while ((token = strsep(&string, ",")) != NULL)
-   printf("%s\en", token);
+if (string == NULL)
+   err(1, "strdup");
+while ((token = strsep(&string, ",")) != NULL)
+   printf("%s\en", token);

free(tofree);
.Ed


This error handling is now good enough for small utilities.  (I would
normally use xstrdup() and not repeat the comparison and err() in all
callers.  Callers could print a more specific error message, but this
is too much for errors that "can't happen".)

But this example shouldn't be complicated by showing correct style and/or
technique for error handling.  It should only try to show correct style and
technique for using strsep().  It only uses strdup() because it is a contrived
example with a fixed input string.  String literals are const, so strsep()
can't be used directly on them, except in bad examples for compilers that
don't warn about this error.  It uses strdup() to avoid this problem.  Then
it has to worry about error checking, error handling, and freeing for strdup().
The example ends up with more code for strdup() than for strsep().

The example still has a technical error.  It says that the string is parsed
and its tokens are printed.  Actually, this only happens if strdup() didn't
fail.  The description doesn't mention the error handling in any way.

Oops, there are many more technical errors.  printf() can also fail.  It
is more likely than strdup() to fail with ENOMEM.  As usual, errors in it
are silenty ignored by not checking its return value.  Most programs don't
check ferr() on any stdio stream before exit().

This example is followed by another one that is missing all of these
bugs, but has 3 related ones.  Its string is named inputstring and
must be produced elsewhere, but it is declared in the example so it
is literally just uninitialized.  The example doesn't preserve the
string, but writes NULs into it and points argv[] to the resulting
substrings.  The description only gives a hint that the string will
be overwritten and and must live as long as the pointers.  The problem
with not checking for errors from printf() is replaced by silently
ignoring the error of having more tokens than fit in argv[].  argv[]
has a fixed size of 10 elements to avoid complications.

Old versions of the man page have only the second example.

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: r334307 - head/usr.sbin/bhyve

2018-05-28 Thread Marcelo Araujo
Author: araujo
Date: Tue May 29 01:46:00 2018
New Revision: 334307
URL: https://svnweb.freebsd.org/changeset/base/334307

Log:
  Simplify macros EFPRINTF and EFFLUSH. [0]
  Also stdarg(3) says that each invocation of va_start() must be paired
  with a corresponding invocation of va_end() in the same function. [1]
  
  Reported by:  Coverity
  CID:  1194318[0] and 1194332[1]
  Discussed with:   jhb
  MFC after:4 weeks.
  Sponsored by: iXsystems Inc.
  Differential Revision:https://reviews.freebsd.org/D15548

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

Modified: head/usr.sbin/bhyve/acpi.c
==
--- head/usr.sbin/bhyve/acpi.c  Tue May 29 01:16:00 2018(r334306)
+++ head/usr.sbin/bhyve/acpi.c  Tue May 29 01:46:00 2018(r334307)
@@ -118,18 +118,14 @@ struct basl_fio {
 };
 
 #define EFPRINTF(...) \
-   err = fprintf(__VA_ARGS__); if (err < 0) goto err_exit;
+   if (fprintf(__VA_ARGS__) < 0) goto err_exit;
 
 #define EFFLUSH(x) \
-   err = fflush(x); if (err != 0) goto err_exit;
+   if (fflush(x) != 0) goto err_exit;
 
 static int
 basl_fwrite_rsdp(FILE *fp)
 {
-   int err;
-
-   err = 0;
-
EFPRINTF(fp, "/*\n");
EFPRINTF(fp, " * bhyve RSDP template\n");
EFPRINTF(fp, " */\n");
@@ -156,10 +152,6 @@ err_exit:
 static int
 basl_fwrite_rsdt(FILE *fp)
 {
-   int err;
-
-   err = 0;
-
EFPRINTF(fp, "/*\n");
EFPRINTF(fp, " * bhyve RSDT template\n");
EFPRINTF(fp, " */\n");
@@ -196,10 +188,6 @@ err_exit:
 static int
 basl_fwrite_xsdt(FILE *fp)
 {
-   int err;
-
-   err = 0;
-
EFPRINTF(fp, "/*\n");
EFPRINTF(fp, " * bhyve XSDT template\n");
EFPRINTF(fp, " */\n");
@@ -236,11 +224,8 @@ err_exit:
 static int
 basl_fwrite_madt(FILE *fp)
 {
-   int err;
int i;
 
-   err = 0;
-
EFPRINTF(fp, "/*\n");
EFPRINTF(fp, " * bhyve MADT template\n");
EFPRINTF(fp, " */\n");
@@ -326,10 +311,6 @@ err_exit:
 static int
 basl_fwrite_fadt(FILE *fp)
 {
-   int err;
-
-   err = 0;
-
EFPRINTF(fp, "/*\n");
EFPRINTF(fp, " * bhyve FADT template\n");
EFPRINTF(fp, " */\n");
@@ -547,10 +528,6 @@ err_exit:
 static int
 basl_fwrite_hpet(FILE *fp)
 {
-   int err;
-
-   err = 0;
-
EFPRINTF(fp, "/*\n");
EFPRINTF(fp, " * bhyve HPET template\n");
EFPRINTF(fp, " */\n");
@@ -596,8 +573,6 @@ err_exit:
 static int
 basl_fwrite_mcfg(FILE *fp)
 {
-   int err = 0;
-
EFPRINTF(fp, "/*\n");
EFPRINTF(fp, " * bhyve MCFG template\n");
EFPRINTF(fp, " */\n");
@@ -629,10 +604,6 @@ err_exit:
 static int
 basl_fwrite_facs(FILE *fp)
 {
-   int err;
-
-   err = 0;
-
EFPRINTF(fp, "/*\n");
EFPRINTF(fp, " * bhyve FACS template\n");
EFPRINTF(fp, " */\n");
@@ -666,7 +637,6 @@ void
 dsdt_line(const char *fmt, ...)
 {
va_list ap;
-   int err;
 
if (dsdt_error != 0)
return;
@@ -675,8 +645,10 @@ dsdt_line(const char *fmt, ...)
if (dsdt_indent_level != 0)
EFPRINTF(dsdt_fp, "%*c", dsdt_indent_level * 2, ' ');
va_start(ap, fmt);
-   if (vfprintf(dsdt_fp, fmt, ap) < 0)
+   if (vfprintf(dsdt_fp, fmt, ap) < 0) {
+   va_end(ap);
goto err_exit;
+   }
va_end(ap);
}
EFPRINTF(dsdt_fp, "\n");
@@ -735,9 +707,6 @@ dsdt_fixed_mem32(uint32_t base, uint32_t length)
 static int
 basl_fwrite_dsdt(FILE *fp)
 {
-   int err;
-
-   err = 0;
dsdt_fp = fp;
dsdt_error = 0;
dsdt_indent_level = 0;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334306 - in head: lib/libc/stdlib share/man/man3

2018-05-28 Thread Eric van Gyzen
Author: vangyzen
Date: Tue May 29 01:16:00 2018
New Revision: 334306
URL: https://svnweb.freebsd.org/changeset/base/334306

Log:
  Cross-reference abort2(2) from a few man pages
  
  I didn't know abort2 existed until it was mentioned on a mailing list.
  Mention it in related pages so others can find it easily.
  
  MFC after:3 days
  Sponsored by: Dell EMC

Modified:
  head/lib/libc/stdlib/abort.3
  head/lib/libc/stdlib/exit.3
  head/share/man/man3/assert.3

Modified: head/lib/libc/stdlib/abort.3
==
--- head/lib/libc/stdlib/abort.3Tue May 29 00:53:53 2018
(r334305)
+++ head/lib/libc/stdlib/abort.3Tue May 29 01:16:00 2018
(r334306)
@@ -64,6 +64,7 @@ The
 function
 never returns.
 .Sh SEE ALSO
+.Xr abort2 2 ,
 .Xr sigaction 2 ,
 .Xr exit 3
 .Sh STANDARDS

Modified: head/lib/libc/stdlib/exit.3
==
--- head/lib/libc/stdlib/exit.3 Tue May 29 00:53:53 2018(r334305)
+++ head/lib/libc/stdlib/exit.3 Tue May 29 01:16:00 2018(r334306)
@@ -116,6 +116,7 @@ functions
 never return.
 .Sh SEE ALSO
 .Xr _exit 2 ,
+.Xr abort2 2 ,
 .Xr wait 2 ,
 .Xr at_quick_exit 3 ,
 .Xr atexit 3 ,

Modified: head/share/man/man3/assert.3
==
--- head/share/man/man3/assert.3Tue May 29 00:53:53 2018
(r334305)
+++ head/share/man/man3/assert.3Tue May 29 01:16:00 2018
(r334306)
@@ -85,6 +85,7 @@ generates a diagnostic message similar to the followin
 .Pp
 .Dl "Assertion failed: (1 == 0), function main, file assertion.c, line 100."
 .Sh SEE ALSO
+.Xr abort2 2 ,
 .Xr abort 3
 .Sh STANDARDS
 The
___
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: r334305 - head/sys/net

2018-05-28 Thread Matt Macy
Author: mmacy
Date: Tue May 29 00:53:53 2018
New Revision: 334305
URL: https://svnweb.freebsd.org/changeset/base/334305

Log:
  route: fix missed ref adds
   - ensure that we bump the ifa ref whenever we add a reference
   - defer freeing epoch protected references until after the if_purgaddrs
 loop

Modified:
  head/sys/net/if.c
  head/sys/net/route.c

Modified: head/sys/net/if.c
==
--- head/sys/net/if.c   Tue May 29 00:19:23 2018(r334304)
+++ head/sys/net/if.c   Tue May 29 00:53:53 2018(r334305)
@@ -967,7 +967,7 @@ if_purgeaddrs(struct ifnet *ifp)
 {
struct ifaddr *ifa, *next;
 
-   /* XXX cannot hold IF_ADDR_WLOCK over called functions. */
+   NET_EPOCH_ENTER();
CK_STAILQ_FOREACH_SAFE(ifa, &ifp->if_addrhead, ifa_link, next) {
if (ifa->ifa_addr->sa_family == AF_LINK)
continue;
@@ -997,6 +997,7 @@ if_purgeaddrs(struct ifnet *ifp)
IF_ADDR_WUNLOCK(ifp);
ifa_free(ifa);
}
+   NET_EPOCH_EXIT();
 }
 
 /*
@@ -2196,6 +2197,10 @@ link_rtrequest(int cmd, struct rtentry *rt, struct rt_
ifa = ifaof_ifpforaddr(dst, ifp);
if (ifa) {
oifa = rt->rt_ifa;
+   if (oifa != ifa) {
+   ifa_free(oifa);
+   ifa_ref(ifa);
+   }
rt->rt_ifa = ifa;
if (ifa->ifa_rtrequest && ifa->ifa_rtrequest != link_rtrequest)
ifa->ifa_rtrequest(cmd, rt, info);
@@ -3675,10 +3680,8 @@ if_delmulti_ifma_flags(struct ifmultiaddr *ifma, int f
CK_STAILQ_FOREACH(oifp, &V_ifnet, if_link)
if (ifp == oifp)
break;
-   if (ifp != oifp) {
-   printf("%s: ifnet %p disappeared\n", __func__, ifp);
+   if (ifp != oifp)
ifp = NULL;
-   }
IFNET_RUNLOCK_NOSLEEP();
}
 #endif

Modified: head/sys/net/route.c
==
--- head/sys/net/route.cTue May 29 00:19:23 2018(r334304)
+++ head/sys/net/route.cTue May 29 00:53:53 2018(r334305)
@@ -653,6 +653,7 @@ rtredirect_fib(struct sockaddr *dst,
info.rti_info[RTAX_DST] = dst;
info.rti_info[RTAX_GATEWAY] = gateway;
info.rti_info[RTAX_NETMASK] = netmask;
+   ifa_ref(ifa);
info.rti_ifa = ifa;
info.rti_flags = flags;
error = rtrequest1_fib(RTM_ADD, &info, &rt, fibnum);
@@ -899,7 +900,7 @@ rt_exportinfo(struct rtentry *rt, struct rt_addrinfo *
info->rti_flags = rt->rt_flags;
info->rti_ifp = rt->rt_ifp;
info->rti_ifa = rt->rt_ifa;
-
+   ifa_ref(info->rti_ifa);
if (flags & NHR_REF) {
/* Do 'traditional' refcouting */
if_ref(info->rti_ifp);
@@ -1275,12 +1276,14 @@ int
 rt_getifa_fib(struct rt_addrinfo *info, u_int fibnum)
 {
struct ifaddr *ifa;
-   int error = 0;
+   int needref, error;
 
/*
 * ifp may be specified by sockaddr_dl
 * when protocol address is ambiguous.
 */
+   error = 0;
+   needref = (info->rti_ifa == NULL);
NET_EPOCH_ENTER();
if (info->rti_ifp == NULL && ifpaddr != NULL &&
ifpaddr->sa_family == AF_LINK &&
@@ -1303,7 +1306,7 @@ rt_getifa_fib(struct rt_addrinfo *info, u_int fibnum)
info->rti_ifa = ifa_ifwithroute(flags, sa, sa,
fibnum);
}
-   if ((ifa = info->rti_ifa) != NULL) {
+   if (needref && info->rti_ifa != NULL) {
if (info->rti_ifp == NULL)
info->rti_ifp = ifa->ifa_ifp;
ifa_ref(info->rti_ifa);
@@ -1785,6 +1788,7 @@ rtrequest1_fib_change(struct rib_head *rnh, struct rt_
if (rt->rt_ifa->ifa_rtrequest != NULL)
rt->rt_ifa->ifa_rtrequest(RTM_DELETE, rt, info);
ifa_free(rt->rt_ifa);
+   rt->rt_ifa = NULL;
}
/* Update gateway address */
if (info->rti_info[RTAX_GATEWAY] != NULL) {
@@ -1836,8 +1840,10 @@ rtrequest1_fib_change(struct rib_head *rnh, struct rt_
}
 bad:
RT_UNLOCK(rt);
-   if (free_ifa != 0)
+   if (free_ifa != 0) {
ifa_free(info->rti_ifa);
+   info->rti_ifa = NULL;
+   }
return (error);
 }
 
@@ -2052,6 +2058,7 @@ rtinit1(struct ifaddr *ifa, int cmd, int flags, int fi
 * Do the actual request
 */
bzero((caddr_t)&info, sizeof(info));
+   ifa_ref(ifa);
info.rti_ifa = ifa;
info.rti_flags = 

svn commit: r334304 - head/sys/sys

2018-05-28 Thread Matt Macy
Author: mmacy
Date: Tue May 29 00:19:23 2018
New Revision: 334304
URL: https://svnweb.freebsd.org/changeset/base/334304

Log:
  hwpmc: add class field to identify which class a pmc came frome

Modified:
  head/sys/sys/pmc.h

Modified: head/sys/sys/pmc.h
==
--- head/sys/sys/pmc.h  Mon May 28 23:34:23 2018(r334303)
+++ head/sys/sys/pmc.h  Tue May 29 00:19:23 2018(r334304)
@@ -775,6 +775,7 @@ struct pmc {
 */
 
pmc_id_tpm_id;  /* allocated PMC id */
+   enum pmc_class pm_class;
 
/* md extensions */
union pmc_md_pmcpm_md;
___
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: r334303 - head/usr.sbin/sysrc

2018-05-28 Thread Devin Teske
Author: dteske
Date: Mon May 28 23:34:23 2018
New Revision: 334303
URL: https://svnweb.freebsd.org/changeset/base/334303

Log:
  sysrc(8): Test variable names for invalid characters
  
  PR:   bin/187461
  Reported by:  e...@looksharp.net
  MFC after:4 weeks
  X-MFC-to: stable/11 (after 11.2-R)
  Sponsored by: Smule, Inc.

Modified:
  head/usr.sbin/sysrc/sysrc

Modified: head/usr.sbin/sysrc/sysrc
==
--- head/usr.sbin/sysrc/sysrc   Mon May 28 23:20:08 2018(r334302)
+++ head/usr.sbin/sysrc/sysrc   Mon May 28 23:34:23 2018(r334303)
@@ -370,6 +370,18 @@ if [ "$LIST_SERVICE_CONFS" ]; then
 fi
 
 #
+# Validate arguments
+#
+for name in "$@"; do
+   # NB: shell expansion syntax removed first
+   name="${name%%:[+=-]*}"
+   name="${name%%[%#+=-]*}"
+   [ "$name" = "${name#*[!$VALID_VARNAME_CHARS]}" ] || die \
+   "%s: %s: name contains characters not allowed in shell" \
+   "$pgm" "$name"
+done
+
+#
 # Process `-s name' argument
 #
 if [ "$SERVICE" -a ! "${RC_CONFS+set}" ]; then
___
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: r334302 - head/sys/teken

2018-05-28 Thread Jean-Sébastien Pédron
Author: dumbbell
Date: Mon May 28 23:20:08 2018
New Revision: 334302
URL: https://svnweb.freebsd.org/changeset/base/334302

Log:
  teken: Sort DECSCUSR alphabetically
  
  While here, align columns again.
  
  Reported by:  bde

Modified:
  head/sys/teken/sequences

Modified: head/sys/teken/sequences
==
--- head/sys/teken/sequencesMon May 28 23:17:57 2018(r334301)
+++ head/sys/teken/sequencesMon May 28 23:20:08 2018(r334302)
@@ -34,83 +34,83 @@
 #  - `r' regular numeric argument
 #  - `v' means a variable number of arguments
 
-# Abbr NameSequenceArguments
-CBTCursor Backward Tabulation  ^[ [ Z  n
-CHTCursor Forward Tabulation   ^[ [ I  n
-CNLCursor Next Line^[ [ E  n
-CPLCursor Previous Line^[ [ F  n
-CPRCursor Position Report  ^[ [ n  r
-CUBCursor Backward ^[ [ D  n
-CUDCursor Down ^[ [ B  n
-CUDCursor Down ^[ [ e  n
-CUFCursor Forward  ^[ [ C  n
-CUFCursor Forward  ^[ [ a  n
-CUPCursor Position ^[ [ H  n n
-CUPCursor Position ^[ [ f  n n
-CUUCursor Up   ^[ [ A  n
-DECSCUSR   Set Cursor Style^[ [ SP q   r
-DA1Primary Device Attributes   ^[ [ c  r
-DA2Secondary Device Attributes ^[ [ > cr
-DC Delete character^[ [ P  n
-DCSDevice Control String   ^[ P
-DECALN Alignment test  ^[ # 8
-DECDHL Double Height Double Width Line Top ^[ # 3
-DECDHL Double Height Double Width Line Bottom  ^[ # 4
-DECDWL Single Height Double Width Line ^[ # 6
-DECKPAMKeypad application mode ^[ =
-DECKPNMKeypad numeric mode ^[ >
-DECRC  Restore cursor  ^[ 8
-DECRC  Restore cursor  ^[ [ u
-DECRM  Reset DEC mode  ^[ [ ? lr
-DECSC  Save cursor ^[ 7
-DECSC  Save cursor ^[ [ s
-DECSM  Set DEC mode^[ [ ? hr
-DECSTBMSet top and bottom margins  ^[ [ r  r r
-DECSWL Single Height Single Width Line ^[ # 5
-DL Delete line ^[ [ M  n
-DSRDevice Status Report^[ [ ? nr
-ECHErase character ^[ [ X  n
-ED Erase display   ^[ [ J  r
-EL Erase line  ^[ [ K  r
-G0SCS0 G0 SCS Special Graphics ^[ ( 0
-G0SCS1 G0 SCS US ASCII ^[ ( 1
-G0SCS2 G0 SCS Special Graphics ^[ ( 2
-G0SCSA G0 SCS UK National  ^[ ( A
-G0SCSB G0 SCS US ASCII ^[ ( B
-G1SCS0 G1 SCS Special Graphics ^[ ) 0
-G1SCS1 G1 SCS US ASCII ^[ ) 1
-G1SCS2 G1 SCS Special Graphics ^[ ) 2
-G1SCSA G1 SCS UK National  ^[ ) A
-G1SCSB G1 SCS US ASCII ^[ ) B
-HPAHorizontal Position Absolute^[ [ G  n
-HPAHorizontal Position Absolute^[ [ `  n
-HTSHorizontal Tab Set  ^[ H
-ICHInsert character^[ [ @  n
-IL Insert line ^[ [ L  n
-INDIndex   ^[ D
-NELNext line   ^[ E
-OSCOperating System Command^[ ]
-RI Reverse index   ^[ M
-RISReset to Initial State  ^[ c
-RM Reset Mode  ^[ [ l  r
-SD Pan Up  ^[ [ T  n
-SGRSet Graphic Rendition   ^[ [ m  v
-SM Set Mode^[ [ h  r
-ST String Terminator   ^[ \\
-SU Pan Down^[ [ S  n
-TBCTab Clear   ^[ [ g  r
-VPAVertical Position Absolute  ^[ [ d  n
+# Abbr NameSequence
Arguments
+CBTCursor Backward Tabulation  ^[ [ Z  n
+CHTCursor Forward Tabulation   ^[ [ I  n
+CNLCursor Next Line   

svn commit: r334301 - head/sys/dev/hwpmc

2018-05-28 Thread Matt Macy
Author: mmacy
Date: Mon May 28 23:17:57 2018
New Revision: 334301
URL: https://svnweb.freebsd.org/changeset/base/334301

Log:
  hwpmc: make pmc class specification work to enable fixed function counters

Modified:
  head/sys/dev/hwpmc/hwpmc_mod.c

Modified: head/sys/dev/hwpmc/hwpmc_mod.c
==
--- head/sys/dev/hwpmc/hwpmc_mod.c  Mon May 28 23:16:39 2018
(r334300)
+++ head/sys/dev/hwpmc/hwpmc_mod.c  Mon May 28 23:17:57 2018
(r334301)
@@ -3253,7 +3253,17 @@ pmc_stop(struct pmc *pm)
return (error);
 }
 
+static struct pmc_classdep *
+pmc_class_to_classdep(enum pmc_class class)
+{
+   int n;
 
+   for (n = 0; n < md->pmd_nclass; n++)
+   if (md->pmd_classdep[n].pcd_class == class)
+   return (&md->pmd_classdep[n]);
+   return (NULL);
+}
+
 #ifdef HWPMC_DEBUG
 static const char *pmc_op_to_name[] = {
 #undef __PMC_OP
@@ -3816,16 +3826,14 @@ pmc_syscall_handler(struct thread *td, void *syscall_a
caps |= PMC_CAP_INTERRUPT;
 
/* A valid class specifier should have been passed in. */
-   for (n = 0; n < md->pmd_nclass; n++)
-   if (md->pmd_classdep[n].pcd_class == pa.pm_class)
-   break;
-   if (n == md->pmd_nclass) {
+   pcd = pmc_class_to_classdep(pa.pm_class);
+   if (pcd == NULL) {
error = EINVAL;
break;
}
 
/* The requested PMC capabilities should be feasible. */
-   if ((md->pmd_classdep[n].pcd_caps & caps) != caps) {
+   if ((pcd->pcd_caps & caps) != caps) {
error = EOPNOTSUPP;
break;
}
@@ -3852,7 +3860,7 @@ pmc_syscall_handler(struct thread *td, void *syscall_a
 
if (PMC_IS_SYSTEM_MODE(mode)) {
pmc_select_cpu(cpu);
-   for (n = 0; n < (int) md->pmd_npmc; n++) {
+   for (n = pcd->pcd_ri; n < (int) md->pmd_npmc; n++) {
pcd = pmc_ri_to_classdep(md, n, &adjri);
if (pmc_can_allocate_row(n, mode) == 0 &&
pmc_can_allocate_rowindex(
@@ -3865,7 +3873,7 @@ pmc_syscall_handler(struct thread *td, void *syscall_a
}
} else {
/* Process virtual mode */
-   for (n = 0; n < (int) md->pmd_npmc; n++) {
+   for (n = pcd->pcd_ri; n < (int) md->pmd_npmc; n++) {
pcd = pmc_ri_to_classdep(md, n, &adjri);
if (pmc_can_allocate_row(n, mode) == 0 &&
pmc_can_allocate_rowindex(
@@ -3929,6 +3937,7 @@ pmc_syscall_handler(struct thread *td, void *syscall_a
}
 
pmc->pm_state= PMC_STATE_ALLOCATED;
+   pmc->pm_class   = pa.pm_class;
 
/*
 * mark row disposition
___
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: r334300 - head/sys/dev/hwpmc

2018-05-28 Thread Matt Macy
Author: mmacy
Date: Mon May 28 23:16:39 2018
New Revision: 334300
URL: https://svnweb.freebsd.org/changeset/base/334300

Log:
  hwmpc: fix brain-damaged handling of thread descriptor freeing

Modified:
  head/sys/dev/hwpmc/hwpmc_mod.c

Modified: head/sys/dev/hwpmc/hwpmc_mod.c
==
--- head/sys/dev/hwpmc/hwpmc_mod.c  Mon May 28 23:14:38 2018
(r334299)
+++ head/sys/dev/hwpmc/hwpmc_mod.c  Mon May 28 23:16:39 2018
(r334300)
@@ -2351,9 +2351,9 @@ pmc_thread_descriptor_pool_free_task(void *arg __unuse
/* Determine what changes, if any, we need to make. */
mtx_lock_spin(&pmc_threadfreelist_mtx);
delta = pmc_threadfreelist_entries - pmc_threadfreelist_max;
-   while (delta > 0) {
-   pt = LIST_FIRST(&pmc_threadfreelist);
-   MPASS(pt);
+   while (delta > 0 &&
+  (pt = LIST_FIRST(&pmc_threadfreelist)) != NULL) {
+   delta--;
LIST_REMOVE(pt, pt_next);
LIST_INSERT_HEAD(&tmplist, pt, pt_next);
}
@@ -2361,7 +2361,7 @@ pmc_thread_descriptor_pool_free_task(void *arg __unuse
 
/* If there are entries to free, free them. */
while (!LIST_EMPTY(&tmplist)) {
-   pt = LIST_FIRST(&pmc_threadfreelist);
+   pt = LIST_FIRST(&tmplist);
LIST_REMOVE(pt, pt_next);
free(pt, M_PMC);
}
___
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: r334299 - head/sys/kern

2018-05-28 Thread Matt Macy
Author: mmacy
Date: Mon May 28 23:14:38 2018
New Revision: 334299
URL: https://svnweb.freebsd.org/changeset/base/334299

Log:
  witness/hwpmc: fix locking order for pmc locks

Modified:
  head/sys/kern/subr_witness.c

Modified: head/sys/kern/subr_witness.c
==
--- head/sys/kern/subr_witness.cMon May 28 23:12:26 2018
(r334298)
+++ head/sys/kern/subr_witness.cMon May 28 23:14:38 2018
(r334299)
@@ -499,12 +499,12 @@ static struct witness_order_list_entry order_lists[] =
{ "pipe mutex", &lock_class_mtx_sleep },
{ "sigio lock", &lock_class_mtx_sleep },
{ "process group", &lock_class_mtx_sleep },
-   { "process lock", &lock_class_mtx_sleep },
-   { "session", &lock_class_mtx_sleep },
-   { "uidinfo hash", &lock_class_rw },
 #ifdef HWPMC_HOOKS
{ "pmc-sleep", &lock_class_mtx_sleep },
 #endif
+   { "process lock", &lock_class_mtx_sleep },
+   { "session", &lock_class_mtx_sleep },
+   { "uidinfo hash", &lock_class_rw },
{ "time lock", &lock_class_mtx_sleep },
{ NULL, NULL },
/*
@@ -671,9 +671,6 @@ static struct witness_order_list_entry order_lists[] =
{ "uart_hwmtx", &lock_class_mtx_spin },
{ "fast_taskqueue", &lock_class_mtx_spin },
{ "intr table", &lock_class_mtx_spin },
-#ifdef HWPMC_HOOKS
-   { "pmc-per-proc", &lock_class_mtx_spin },
-#endif
{ "process slock", &lock_class_mtx_spin },
{ "syscons video lock", &lock_class_mtx_spin },
{ "sleepq chain", &lock_class_mtx_spin },
@@ -690,6 +687,12 @@ static struct witness_order_list_entry order_lists[] =
 #ifdef __powerpc__
{ "tlb0", &lock_class_mtx_spin },
 #endif
+   { NULL, NULL },
+   { "sched lock", &lock_class_mtx_spin },
+#ifdef HWPMC_HOOKS
+   { "pmc-per-proc", &lock_class_mtx_spin },
+#endif
+   { NULL, NULL },
/*
 * leaf locks
 */
___
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: r334298 - head/sys/dev/hwpmc

2018-05-28 Thread Matt Macy
Author: mmacy
Date: Mon May 28 23:12:26 2018
New Revision: 334298
URL: https://svnweb.freebsd.org/changeset/base/334298

Log:
  hwpmc_logging.c: don't call wakeup_one with thread lock held, don't
  malloc(M_WAITOK) in an epoch section

Modified:
  head/sys/dev/hwpmc/hwpmc_logging.c
  head/sys/dev/hwpmc/hwpmc_mod.c

Modified: head/sys/dev/hwpmc/hwpmc_logging.c
==
--- head/sys/dev/hwpmc/hwpmc_logging.c  Mon May 28 21:05:00 2018
(r334297)
+++ head/sys/dev/hwpmc/hwpmc_logging.c  Mon May 28 23:12:26 2018
(r334298)
@@ -166,13 +166,17 @@ static struct mtx pmc_kthread_mtx;/* sleep lock */
pmclog_release((PO));   
\
} while (0)
 
+#definePMCLOG_DESPATCH_SCHED_LOCK(PO)  
\
+pmclog_release_flags((PO), 0); 
\
+   } while (0)
+
 #definePMCLOG_DESPATCH(PO) 
\
pmclog_release((PO));   
\
spinlock_exit();
\
} while (0)
 
 #definePMCLOG_DESPATCH_SYNC(PO)
\
-   pmclog_schedule_io((PO));   
\
+   pmclog_schedule_io((PO), 1);
\
spinlock_exit();
\
} while (0)
 
@@ -224,7 +228,7 @@ static int pmclog_get_buffer(struct pmc_owner *po);
 static void pmclog_loop(void *arg);
 static void pmclog_release(struct pmc_owner *po);
 static uint32_t *pmclog_reserve(struct pmc_owner *po, int length);
-static void pmclog_schedule_io(struct pmc_owner *po);
+static void pmclog_schedule_io(struct pmc_owner *po, int wakeup);
 static void pmclog_schedule_all(struct pmc_owner *po);
 static void pmclog_stop_kthread(struct pmc_owner *po);
 
@@ -422,7 +426,7 @@ pmclog_loop(void *arg)
break;
 
(void) msleep(po, &pmc_kthread_mtx, PWAIT,
-   "pmcloop", 0);
+   "pmcloop", 250);
continue;
}
 
@@ -504,7 +508,7 @@ pmclog_loop(void *arg)
  */
 
 static void
-pmclog_release(struct pmc_owner *po)
+pmclog_release_flags(struct pmc_owner *po, int wakeup)
 {
struct pmclog_buffer *plb;
 
@@ -518,12 +522,19 @@ pmclog_release(struct pmc_owner *po)
 
/* schedule an I/O if we've filled a buffer */
if (plb->plb_ptr >= plb->plb_fence)
-   pmclog_schedule_io(po);
+   pmclog_schedule_io(po, wakeup);
 
PMCDBG1(LOG,REL,1, "po=%p", po);
 }
 
+static void
+pmclog_release(struct pmc_owner *po)
+{
 
+   pmclog_release_flags(po, 1);
+}
+
+
 /*
  * Attempt to reserve 'length' bytes of space in an owner's log
  * buffer.  The function returns a pointer to 'length' bytes of space
@@ -583,7 +594,7 @@ pmclog_reserve(struct pmc_owner *po, int length)
 * Otherwise, schedule the current buffer for output and get a
 * fresh buffer.
 */
-   pmclog_schedule_io(po);
+   pmclog_schedule_io(po, 0);
 
if (pmclog_get_buffer(po) != 0)
goto fail;
@@ -621,7 +632,7 @@ pmclog_reserve(struct pmc_owner *po, int length)
  */
 
 static void
-pmclog_schedule_io(struct pmc_owner *po)
+pmclog_schedule_io(struct pmc_owner *po, int wakeup)
 {
struct pmclog_buffer *plb;
 
@@ -645,7 +656,8 @@ pmclog_schedule_io(struct pmc_owner *po)
mtx_lock_spin(&po->po_mtx);
TAILQ_INSERT_TAIL(&po->po_logbuffers, plb, plb_next);
mtx_unlock_spin(&po->po_mtx);
-   wakeup_one(po);
+   if (wakeup)
+   wakeup_one(po);
 }
 
 /*
@@ -841,7 +853,7 @@ pmclog_schedule_one_cond(void *arg)
PMC_CALL_HOOK_UNLOCKED(curthread, PMC_FN_DO_SAMPLES, NULL);
plb = po->po_curbuf[curcpu];
if (plb && plb->plb_ptr != plb->plb_base)
-   pmclog_schedule_io(po);
+   pmclog_schedule_io(po, 1);
spinlock_exit();
 }
 
@@ -1048,12 +1060,12 @@ pmclog_process_proccsw(struct pmc *pm, struct pmc_proc
 
po = pm->pm_owner;
 
-   PMCLOG_RESERVE(po, PROCCSW, sizeof(struct pmclog_proccsw));
+   PMCLOG_RESERVE_SAFE(po, PROCCSW, sizeof(struct pmclog_proccsw));
PMCLOG_EMIT32(pm->pm_id);
PMCLOG_EMIT64(v);
PMCLOG_EMIT32(pp->pp_proc->p_pid);
PMCLOG_EMIT32(td->td_tid);
-   PMCLOG_DESPATCH(po);
+   PMCLOG_DESPATCH_SCHED_LOCK(po);
 }
 
 void

Modified: head/sys/dev/hwpmc/hwpmc_mod.c
==
--- head/sys/dev/hwpmc/hwpmc_mod.

svn commit: r334294 - head/sys/dev/usb/net

2018-05-28 Thread Ed Maste
Author: emaste
Date: Mon May 28 20:06:40 2018
New Revision: 334294
URL: https://svnweb.freebsd.org/changeset/base/334294

Log:
  if_muge: Add GMII enable (vs RGMII) bit
  
  The GMII control bit ETH_MAC_CR_GMII_EN_ is not documented in
  LAN78xx datasheets, but from the permissively licensed header provided
  by Microchip it is:
  
   #define ETH_MAC_CR_GMII_EN (0x0008UL ) // GMII/RGMII Selection

Modified:
  head/sys/dev/usb/net/if_mugereg.h

Modified: head/sys/dev/usb/net/if_mugereg.h
==
--- head/sys/dev/usb/net/if_mugereg.h   Mon May 28 19:55:51 2018
(r334293)
+++ head/sys/dev/usb/net/if_mugereg.h   Mon May 28 20:06:40 2018
(r334294)
@@ -207,6 +207,7 @@
 
 /* MAC Control Register */
 #define ETH_MAC_CR 0x100
+#define ETH_MAC_CR_GMII_EN_(0x1U << 19)/* GMII Enable */
 #define ETH_MAC_CR_AUTO_DUPLEX_(0x1U << 12)
 #define ETH_MAC_CR_AUTO_SPEED_ (0x1U << 11)
 
___
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: r334295 - head/sys/arm64/include

2018-05-28 Thread Emmanuel Vadot
Author: manu
Date: Mon May 28 20:29:03 2018
New Revision: 334295
URL: https://svnweb.freebsd.org/changeset/base/334295

Log:
  arm64: Add atomic_fcmpset_8 and atomic_fcmpset_16
  
  Reviewed by:  cognet

Modified:
  head/sys/arm64/include/atomic.h

Modified: head/sys/arm64/include/atomic.h
==
--- head/sys/arm64/include/atomic.h Mon May 28 20:06:40 2018
(r334294)
+++ head/sys/arm64/include/atomic.h Mon May 28 20:29:03 2018
(r334295)
@@ -102,6 +102,54 @@ ATOMIC(subtract, sub)
 
 #defineATOMIC_FCMPSET(bar, a, l)   
\
 static __inline int\
+atomic_fcmpset_##bar##8(volatile uint8_t *p, uint8_t *cmpval,  \
+uint8_t newval)\
+{  \
+   uint8_t tmp;\
+   uint8_t _cmpval = *cmpval;  \
+   int res;\
+   \
+   __asm __volatile(   \
+   "1: mov  %w1, #1\n" \
+   "   ld"#a"xrb %w0, [%2] \n" \
+   "   cmp  %w0, %w3   \n" \
+   "   b.ne 2f \n" \
+   "   st"#l"xrb %w1, %w4, [%2]\n" \
+   "2:"\
+   : "=&r"(tmp), "=&r"(res)\
+   : "r" (p), "r" (_cmpval), "r" (newval)  \
+   : "cc", "memory"\
+   );  \
+   *cmpval = tmp;  \
+   \
+   return (!res);  \
+}  \
+   \
+static __inline int\
+atomic_fcmpset_##bar##16(volatile uint16_t *p, uint16_t *cmpval,   \
+uint8_t newval)\
+{  \
+   uint16_t tmp;   \
+   uint16_t _cmpval = *cmpval; \
+   int res;\
+   \
+   __asm __volatile(   \
+   "1: mov  %w1, #1\n" \
+   "   ld"#a"xh %w0, [%2]  \n" \
+   "   cmp  %w0, %w3   \n" \
+   "   b.ne 2f \n" \
+   "   st"#l"xh %w1, %w4, [%2] \n" \
+   "2:"\
+   : "=&r"(tmp), "=&r"(res)\
+   : "r" (p), "r" (_cmpval), "r" (newval)  \
+   : "cc", "memory"\
+   );  \
+   *cmpval = tmp;  \
+   \
+   return (!res);  \
+}  \
+   \
+static __inline int\
 atomic_fcmpset_##bar##32(volatile uint32_t *p, uint32_t *cmpval,   \
 uint32_t newval)   \
 {  \
___
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: r333713 - in head/sys: dev/usb/net modules/usb/muge

2018-05-28 Thread Ronald Klop

The addition of this driver made me finally buy a RPI3B+.

Thanks a lot!

Regards,
Ronald.


On Thu, 17 May 2018 16:05:00 +0200, Ed Maste  wrote:


Author: emaste
Date: Thu May 17 14:04:59 2018
New Revision: 333713
URL: https://svnweb.freebsd.org/changeset/base/333713

Log:
  Add driver for Microchip LAN78xx USB3-GigE controller
 This driver supports two Microchip USB-Ethernet controllers:
 LAN7800 USB 3.1 to 10/100/1000 Mbps Ethernet
  LAN7515 USB 2 to 10/100/1000 Mbps Ethernet with built-in USB hub
 The LAN7515 is the Ethernet controller on the Raspberry Pi 3B+.
  At present there is no datasheet for the LAN7515, but it is effectively
  a USB 2 hub combined with a LAN7800 controller.  A comprehensive  
LAN7800

  datasheet is at http://www.microchip.com/wwwproducts/en/LAN7800.
 This driver is based on the structure of the smsc(4) driver which
  supports Microchip/SMSC's LAN95xx family.  (Microchip acquired SMSC
  in May 2012.)  The Linux lan78xx driver served as a reference for some
  functionality and registers.
 The 'muge' driver name comes from "Microchip USB Gigabit Ethernet".
  I made some style adjustments and minor edits to Arshan's submission.
  It will be connected to the build after additional review and testing.
 Thanks to Microchip for providing a number of Evaluation Boards (EVBs)
  for development and testing.
 Submitted by:  Arshan Khanifar
  Reviewed by:  hselasky (earlier)
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D15168

Added:
  head/sys/dev/usb/net/if_muge.c   (contents, props changed)
  head/sys/dev/usb/net/if_mugereg.h   (contents, props changed)
  head/sys/modules/usb/muge/
  head/sys/modules/usb/muge/Makefile   (contents, props changed)

Added: head/sys/dev/usb/net/if_muge.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/usb/net/if_muge.c  Thu May 17 14:04:59 2018
(r333713)
@@ -0,0 +1,2199 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (C) 2012 Ben Gray .
+ * Copyright (C) 2018 The FreeBSD Foundation.
+ *
+ * This software was developed by Arshan Khanifar  


+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in  
the
+ *documentation and/or other materials provided with the  
distribution.

+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''  
AND

+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR  
PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE  
LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR  
CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE  
GOODS

+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,  
STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN  
ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY  
OF

+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+/*
+ * USB-To-Ethernet adapter driver for Microchip's LAN78XX and related  
families.

+ *
+ * USB 3.1 to 10/100/1000 Mbps Ethernet
+ * LAN7800 http://www.microchip.com/wwwproducts/en/LAN7800
+ *
+ * USB 2 to 10/100/1000 Mbps Ethernet with built-in USB hub
+ * LAN7515 (no datasheet available, but probes and functions as LAN7800)
+ *
+ * This driver is based on the if_smsc driver, with lan78xx-specific
+ * functionality modelled on Microchip's Linux lan78xx driver.
+ *
+ * UNIMPLEMENTED FEATURES
+ * --
+ * A number of features supported by the lan78xx are not yet  
implemented in

+ * this driver:
+ *
+ * 1. RX/TX checksum offloading: Nothing has been implemented yet for
+ *TX checksumming. RX checksumming works with ICMP messages, but is  
broken

+ *for TCP/UDP packets.
+ * 2. Direct address translation filtering: Implemented but untested.
+ * 3. VLAN tag removal.
+ * 4. Reading MAC address from the device tree: Specific to the RPi 3B+.
+ *Currently, the driver assigns a random MAC address itself.
+ * 5. Support for USB interrupt endpoints.
+ * 6. Latency Tolerance Messaging (LTM) support.
+ * 7. TCP LSO support.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#

svn commit: r334296 - head/sys/security/audit

2018-05-28 Thread Alan Somers
Author: asomers
Date: Mon May 28 20:47:39 2018
New Revision: 334296
URL: https://svnweb.freebsd.org/changeset/base/334296

Log:
  Fix "Bad tailq" panic when auditing auditon(A_SETCLASS, ...)
  
  Due to an oversight in r195280, auditon(A_SETCLASS, ...) would cause a tailq
  element to get added to the tailq twice, resulting in a circular tailq. This
  panics when INVARIANTS are on.
  
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D15381

Modified:
  head/sys/security/audit/audit_bsm.c

Modified: head/sys/security/audit/audit_bsm.c
==
--- head/sys/security/audit/audit_bsm.c Mon May 28 20:29:03 2018
(r334295)
+++ head/sys/security/audit/audit_bsm.c Mon May 28 20:47:39 2018
(r334296)
@@ -427,7 +427,6 @@ audit_sys_auditon(struct audit_record *ar, struct au_r
break;
 
case A_SETCLASS:
-   kau_write(rec, tok);
tok = au_to_arg32(2, "setclass:ec_event",
ar->ar_arg_auditon.au_evclass.ec_number);
kau_write(rec, tok);
___
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: r334293 - head/sys/dev/usb/controller

2018-05-28 Thread Marius Strobl
Author: marius
Date: Mon May 28 19:55:51 2018
New Revision: 334293
URL: https://svnweb.freebsd.org/changeset/base/334293

Log:
  Describe Fresco Logic FL1100 USB 3.0 controllers.

Modified:
  head/sys/dev/usb/controller/xhci_pci.c

Modified: head/sys/dev/usb/controller/xhci_pci.c
==
--- head/sys/dev/usb/controller/xhci_pci.c  Mon May 28 18:34:16 2018
(r334292)
+++ head/sys/dev/usb/controller/xhci_pci.c  Mon May 28 19:55:51 2018
(r334293)
@@ -113,6 +113,8 @@ xhci_pci_match(device_t self)
 
case 0x10001b73:
return ("Fresco Logic FL1000G USB 3.0 controller");
+   case 0x11001b73:
+   return ("Fresco Logic FL1100 USB 3.0 controller");
 
case 0x10421b21:
return ("ASMedia ASM1042 USB 3.0 controller");
___
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: r334297 - head/sys/arm64/include

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

Log:
  arm64: fix atomic_fcmpset_16
  
  newval needs to be uint16_t
  
  Reported by:  andrew

Modified:
  head/sys/arm64/include/atomic.h

Modified: head/sys/arm64/include/atomic.h
==
--- head/sys/arm64/include/atomic.h Mon May 28 20:47:39 2018
(r334296)
+++ head/sys/arm64/include/atomic.h Mon May 28 21:05:00 2018
(r334297)
@@ -127,7 +127,7 @@ atomic_fcmpset_##bar##8(volatile uint8_t *p, uint8_t *
\
 static __inline int\
 atomic_fcmpset_##bar##16(volatile uint16_t *p, uint16_t *cmpval,   \
-uint8_t newval)\
+uint16_t newval)   \
 {  \
uint16_t tmp;   \
uint16_t _cmpval = *cmpval; \
___
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: r334290 - head/sys/sys

2018-05-28 Thread Devin Teske
Author: dteske
Date: Mon May 28 17:47:32 2018
New Revision: 334290
URL: https://svnweb.freebsd.org/changeset/base/334290

Log:
  Bump FreeBSD_version after r333517
  
  Sponsored by: Smule, Inc.

Modified:
  head/sys/sys/param.h

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hMon May 28 17:09:29 2018(r334289)
+++ head/sys/sys/param.hMon May 28 17:47:32 2018(r334290)
@@ -60,7 +60,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1200064  /* Master, propagated to newvers */
+#define __FreeBSD_version 1200065  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334292 - head/sys/dev/usb

2018-05-28 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon May 28 18:34:16 2018
New Revision: 334292
URL: https://svnweb.freebsd.org/changeset/base/334292

Log:
  Change the default USB template from the current 0 to -1.  The reason
  is that current one (mass storage device) doesn't work as it is - it
  needs to be set to 0 after the LUN is configured, which is what the
  cfumass rc script does.  In other words: the current default does not
  work, and to actually make it work it had to be set to -1 in
  /boot/loader.conf.
  
  Reviewed by:  hselasky@
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/dev/usb/usb_device.c

Modified: head/sys/dev/usb/usb_device.c
==
--- head/sys/dev/usb/usb_device.c   Mon May 28 18:29:15 2018
(r334291)
+++ head/sys/dev/usb/usb_device.c   Mon May 28 18:34:16 2018
(r334292)
@@ -118,7 +118,7 @@ static void usb_cdev_free(struct usb_device *);
 #ifdef USB_TEMPLATE
 intusb_template = USB_TEMPLATE;
 #else
-intusb_template;
+intusb_template = -1;
 #endif
 
 SYSCTL_PROC(_hw_usb, OID_AUTO, template,
___
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: r334291 - head/lib/libc/string

2018-05-28 Thread Ed Maste
Author: emaste
Date: Mon May 28 18:29:15 2018
New Revision: 334291
URL: https://svnweb.freebsd.org/changeset/base/334291

Log:
  strsep.3: don't silently ignore errors
  
  Reported by:  bde
  MFC with: r334275

Modified:
  head/lib/libc/string/strsep.3

Modified: head/lib/libc/string/strsep.3
==
--- head/lib/libc/string/strsep.3   Mon May 28 17:47:32 2018
(r334290)
+++ head/lib/libc/string/strsep.3   Mon May 28 18:29:15 2018
(r334291)
@@ -86,9 +86,10 @@ to parse a string, and prints each token in separate l
 char *token, *string, *tofree;
 
 tofree = string = strdup("abc,def,ghi");
-if (string != NULL)
-   while ((token = strsep(&string, ",")) != NULL)
-   printf("%s\en", token);
+if (string == NULL)
+   err(1, "strdup");
+while ((token = strsep(&string, ",")) != NULL)
+   printf("%s\en", token);
 
 free(tofree);
 .Ed
___
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: Deorbiting i386

2018-05-28 Thread Andrew Turner


> On 27 May 2018, at 23:15, Maxim Sobolev  wrote:
> 
> Well, strip extra 32 bits, use slower memory and busses (extra decoding logic 
> etc). Voila, you suddenly have platform that can run 99% of code in wild 
> today with just few hundred mW of power. Try that with arm32, you would be 
> surprised how many software is technically compiling and all that, but has 
> some weird runtime issues with either byte order or unaligned memory 
> accesses. Not even mention performance issues due to the lack of hand-crafted 
> JITs.

If you’re having byte order issues on arm you will have them on x86 as they are 
both little endian, and modern arm (last ~10 years) handles unaligned access.

You’ll also find there is a lot of code designed for use on battery powered Arm 
CPUs, they are used in almost all mobile phones, meaning many popular JITs have 
been ported.

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"


svn commit: r334288 - head/etc/mtree

2018-05-28 Thread Niclas Zeising
Author: zeising (doc,ports committer)
Date: Mon May 28 17:08:37 2018
New Revision: 334288
URL: https://svnweb.freebsd.org/changeset/base/334288

Log:
  Complete removal of lmc(4)
  
  The lmc(4) driver was removed in r333144 and relevant files added to
  ObsoleteFiles.inc, however, include/sys/dev/lmc was not removed from mtree
  and is recreated on every install.  Remove it from mtree.
  
  Reviewed by:  imp, emaste
  Approved by:  emaste
  Differential Revision:https://reviews.freebsd.org/D15590

Modified:
  head/etc/mtree/BSD.include.dist

Modified: head/etc/mtree/BSD.include.dist
==
--- head/etc/mtree/BSD.include.dist Mon May 28 16:23:39 2018
(r334287)
+++ head/etc/mtree/BSD.include.dist Mon May 28 17:08:37 2018
(r334288)
@@ -128,8 +128,6 @@
 ..
 io
 ..
-lmc
-..
 mfi
 ..
 mlx5
___
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: r334289 - head/sys/arm64/arm64

2018-05-28 Thread Andrew Turner
Author: andrew
Date: Mon May 28 17:09:29 2018
New Revision: 334289
URL: https://svnweb.freebsd.org/changeset/base/334289

Log:
  Create a new function to walk the EFI memory table & run a callback for
  each entry. We can then use this to ensure the RunTime data is mapped in
  the DMAP, but not in phys_avail.
  
  Sponsored by: DARPA, AFRL

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

Modified: head/sys/arm64/arm64/machdep.c
==
--- head/sys/arm64/arm64/machdep.c  Mon May 28 17:08:37 2018
(r334288)
+++ head/sys/arm64/arm64/machdep.c  Mon May 28 17:09:29 2018
(r334289)
@@ -720,8 +720,10 @@ typedef struct {
uint64_t attr;
 } EFI_MEMORY_DESCRIPTOR;
 
+typedef void (*efi_map_entry_cb)(struct efi_md *);
+
 static void
-add_efi_map_entries(struct efi_map_header *efihdr)
+foreach_efi_map_entry(struct efi_map_header *efihdr, efi_map_entry_cb cb)
 {
struct efi_md *map, *p;
const char *type;
@@ -797,25 +799,69 @@ add_efi_map_entries(struct efi_map_header *efihdr)
printf("\n");
}
 
-   switch (p->md_type) {
-   case EFI_MD_TYPE_CODE:
-   case EFI_MD_TYPE_DATA:
-   case EFI_MD_TYPE_BS_CODE:
-   case EFI_MD_TYPE_BS_DATA:
-   case EFI_MD_TYPE_FREE:
-   /*
-* We're allowed to use any entry with these types.
-*/
-   break;
-   default:
-   continue;
-   }
+   cb(p);
+   }
+}
 
+static void
+exclude_efi_map_entry(struct efi_md *p)
+{
+
+   switch (p->md_type) {
+   case EFI_MD_TYPE_CODE:
+   case EFI_MD_TYPE_DATA:
+   case EFI_MD_TYPE_BS_CODE:
+   case EFI_MD_TYPE_BS_DATA:
+   case EFI_MD_TYPE_FREE:
+   /*
+* We're allowed to use any entry with these types.
+*/
+   break;
+   default:
+   arm_physmem_exclude_region(p->md_phys, p->md_pages * PAGE_SIZE,
+   EXFLAG_NOALLOC);
+   }
+}
+
+static void
+exclude_efi_map_entries(struct efi_map_header *efihdr)
+{
+
+   foreach_efi_map_entry(efihdr, exclude_efi_map_entry);
+}
+
+static void
+add_efi_map_entry(struct efi_md *p)
+{
+
+   switch (p->md_type) {
+   case EFI_MD_TYPE_RT_DATA:
+   /*
+* Runtime data will be excluded after the DMAP
+* region is created to stop it from being added
+* to phys_avail.
+*/
+   case EFI_MD_TYPE_CODE:
+   case EFI_MD_TYPE_DATA:
+   case EFI_MD_TYPE_BS_CODE:
+   case EFI_MD_TYPE_BS_DATA:
+   case EFI_MD_TYPE_FREE:
+   /*
+* We're allowed to use any entry with these types.
+*/
arm_physmem_hardware_region(p->md_phys,
p->md_pages * PAGE_SIZE);
+   break;
}
 }
 
+static void
+add_efi_map_entries(struct efi_map_header *efihdr)
+{
+
+   foreach_efi_map_entry(efihdr, add_efi_map_entry);
+}
+
 #ifdef FDT
 static void
 try_load_dtb(caddr_t kmdp)
@@ -1001,6 +1047,9 @@ initarm(struct arm64_bootparams *abp)
/* Bootstrap enough of pmap  to enter the kernel proper */
pmap_bootstrap(abp->kern_l0pt, abp->kern_l1pt,
KERNBASE - abp->kern_delta, lastaddr - KERNBASE);
+   /* Exclude entries neexed in teh DMAP region, but not phys_avail */
+   if (efihdr != NULL)
+   exclude_efi_map_entries(efihdr);
arm_physmem_init_kernel_globals();
 
devmap_bootstrap(0, NULL);
___
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: r334287 - head/sys/vm

2018-05-28 Thread Alan Cox
Author: alc
Date: Mon May 28 16:23:39 2018
New Revision: 334287
URL: https://svnweb.freebsd.org/changeset/base/334287

Log:
  Addendum to r334233.  In vm_fault_populate(), since the page lock is held,
  we must use vm_page_xunbusy_maybelocked() rather than vm_page_xunbusy() to
  unbusy the page.
  
  Reviewed by:  kib
  X-MFC with:   r334233

Modified:
  head/sys/vm/vm_fault.c

Modified: head/sys/vm/vm_fault.c
==
--- head/sys/vm/vm_fault.c  Mon May 28 13:31:47 2018(r334286)
+++ head/sys/vm/vm_fault.c  Mon May 28 16:23:39 2018(r334287)
@@ -490,7 +490,7 @@ vm_fault_populate(struct faultstate *fs, vm_prot_t pro
*m_hold = &m[i];
vm_page_hold(&m[i]);
}
-   vm_page_xunbusy(&m[i]);
+   vm_page_xunbusy_maybelocked(&m[i]);
}
if (m_mtx != NULL)
mtx_unlock(m_mtx);
___
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: r334286 - head/sys/netinet

2018-05-28 Thread Michael Tuexen
Author: tuexen
Date: Mon May 28 13:31:47 2018
New Revision: 334286
URL: https://svnweb.freebsd.org/changeset/base/334286

Log:
  Use correct mask.
  Introduced in https://svnweb.freebsd.org/changeset/base/333603.
  Thanks to Irene Ruengler for testing and reporting the issue.
  
  MFC after:1 week
  X-MFC-with:   333603

Modified:
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctputil.c
==
--- head/sys/netinet/sctputil.c Mon May 28 13:12:34 2018(r334285)
+++ head/sys/netinet/sctputil.c Mon May 28 13:31:47 2018(r334286)
@@ -831,7 +831,7 @@ sctp_get_prev_mtu(uint32_t val)
 {
uint32_t i;
 
-   val &= 0x0003;
+   val &= 0xfffc;
if (val <= sctp_mtu_sizes[0]) {
return (val);
}
@@ -857,7 +857,7 @@ sctp_get_next_mtu(uint32_t val)
/* select another MTU that is just bigger than this one */
uint32_t i;
 
-   val &= 0x0003;
+   val &= 0xfffc;
for (i = 0; i < (sizeof(sctp_mtu_sizes) / sizeof(uint32_t)); i++) {
if (val < sctp_mtu_sizes[i]) {
KASSERT((sctp_mtu_sizes[i] & 0x0003) == 0,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r334275 - head/lib/libc/string

2018-05-28 Thread Mariusz Zaborski
Hello Marcelo,

Thanks for working on that :)

>  
>  tofree = string = strdup("abc,def,ghi");
> -assert(string != NULL);
> +if (string != NULL)
> + while ((token = strsep(&string, ",")) != NULL)
> + printf("%s\en", token);
Please notice:
```
If *stringp is initially NULL, strsep() returns NULL.
```
So I even not sure if you need to check strdup() at this point.

>  
> -while ((token = strsep(&string, ",")) != NULL)
> - printf("%s\en", token);
> -
>  free(tofree);
> +free(string);
Here you introduced potential double free.
At the end of loop the 'string' will be equals to NULL so there is no point to
free it. If somebody would use this code as example and he from any other reason
would stop at any other point the string will be pointing to the middle of
'tofree' variable which you already freed.

Thanks,
-- 
Mariusz Zaborski
oshogbo//vx | http://oshogbo.vexillium.org
FreeBSD commiter| https://freebsd.org
Software developer  | http://wheelsystems.com
If it's not broken, let's fix it till it is!!1


signature.asc
Description: PGP signature


svn commit: r334285 - head/sys/dev/bktr

2018-05-28 Thread Eitan Adler
Author: eadler
Date: Mon May 28 13:12:34 2018
New Revision: 334285
URL: https://svnweb.freebsd.org/changeset/base/334285

Log:
  bktr: Support WinFast Tv2000 & PHILIPS FI1216
  
  - Add support for Leadtek WinFast Tv2000 XP bktr card
  - Add support for PHILIPS FI1216
  
  PR:   94369
  Submitted by: Angelescu Ovidiu 
  Submitted on: 2006-03-11 19:30 UTC

Modified:
  head/sys/dev/bktr/bktr_card.c
  head/sys/dev/bktr/bktr_card.h
  head/sys/dev/bktr/bktr_tuner.c
  head/sys/dev/bktr/bktr_tuner.h

Modified: head/sys/dev/bktr/bktr_card.c
==
--- head/sys/dev/bktr/bktr_card.c   Mon May 28 12:50:36 2018
(r334284)
+++ head/sys/dev/bktr/bktr_card.c   Mon May 28 13:12:34 2018
(r334285)
@@ -417,6 +417,18 @@ static const struct CARDTYPE cards[] = {
   0,   /* EEProm size */
   { 0x01, 0x04, 0x01, 0x03, 1 },   /* audio MUX values */
   0x00ff },
+   {  CARD_LEADTEK_WINFAST_2000_XP,/* the card id */
+  "Leadtek Winfast 2000 XP",   /* the 'name' */
+  NULL,/* the tuner */
+  0,   /* the tuner i2c address */
+  0,   /* dbx is optional */
+  0,
+  0,
+  0,   /* EEProm unknown */
+  0,   /* size unknown */
+  { 0x122000, 0x1000, 0x62, 0x, 1 },   /* audio MUX values */
+  0xb33000 },  /* GPIO mask */
+
 };
 
 struct bt848_card_sig bt848_card_signature[1]= {

Modified: head/sys/dev/bktr/bktr_card.h
==
--- head/sys/dev/bktr/bktr_card.h   Mon May 28 12:50:36 2018
(r334284)
+++ head/sys/dev/bktr/bktr_card.h   Mon May 28 13:12:34 2018
(r334285)
@@ -84,7 +84,8 @@
 #define CARD_PIXELVIEW_PLAYTV_PAK  20
 #define CARD_TERRATVALUE   21
 #defineCARD_PIXELVIEW_PLAYTV_PRO_REV_4C22
-#define Bt848_MAX_CARD 23
+#define CARD_LEADTEK_WINFAST_2000_XP23
+#define Bt848_MAX_CARD 24
  
 #define CARD_IO_GV CARD_IO_BCTV2
 

Modified: head/sys/dev/bktr/bktr_tuner.c
==
--- head/sys/dev/bktr/bktr_tuner.c  Mon May 28 12:50:36 2018
(r334284)
+++ head/sys/dev/bktr/bktr_tuner.c  Mon May 28 13:12:34 2018
(r334285)
@@ -301,6 +301,16 @@ static const struct TUNER tuners[] = {
 0x00 },
   { 0x00, 0x00 },  /* band-switch crosspoints */
   { 0xa0, 0x90, 0x30, 0x8e } },/* the band-switch values */
+
+/* PHILIPS FI1216 */
+{ "PHILIPS_FI1216",/* the 'name' */
+  TTYPE_PAL,   /* input type */
+  { TSBH1_FCONTROL,/* control byte for Tuner PLL */
+TSBH1_FCONTROL,
+TSBH1_FCONTROL,
+0x00 },
+  { 0x00, 0x00 },  /* band-switch crosspoints */
+  { 0x01, 0x02, 0x04, 0x00 } },/* the band-switch values */
 };
 
 

Modified: head/sys/dev/bktr/bktr_tuner.h
==
--- head/sys/dev/bktr/bktr_tuner.h  Mon May 28 12:50:36 2018
(r334284)
+++ head/sys/dev/bktr/bktr_tuner.h  Mon May 28 13:12:34 2018
(r334285)
@@ -63,7 +63,8 @@
 #define ALPS_TSBH1 13
 #define TUNER_MT2032   14
 #defineLG_TPI8PSB12P_PAL   15
-#define Bt848_MAX_TUNER16
+#define PHILIPS_FI1216  16
+#define Bt848_MAX_TUNER17
 
 /* experimental code for Automatic Frequency Control */ 
 #define TUNER_AFC
___
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: r334284 - head/share/man/man4

2018-05-28 Thread Eitan Adler
Author: eadler
Date: Mon May 28 12:50:36 2018
New Revision: 334284
URL: https://svnweb.freebsd.org/changeset/base/334284

Log:
  bktr: remove references to removed things
  
  Neither the examples nor the misc/alevt exist anymore.

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

Modified: head/share/man/man4/bktr.4
==
--- head/share/man/man4/bktr.4  Mon May 28 11:26:40 2018(r334283)
+++ head/share/man/man4/bktr.4  Mon May 28 12:50:36 2018(r334284)
@@ -221,16 +221,8 @@ VideoLogic Captivator PCI
 .El
 .Sh FILES
 .Bl -tag -width /usr/share/examples/meteor -compact
-.It Pa /usr/share/examples/meteor
-Examples of what you can do with the (similarly designed) Meteor driver.
 .It Pa /usr/ports/multimedia/fxtv
 A TV and Camera display program utilizing the bktr driver - requires that
-.Em The X Window System
-and
-.Em The Ports Collection
-also be installed.
-.It Pa /usr/ports/misc/alevt
-A program to capture and display Teletext (VideoText) pages - requires that
 .Em The X Window System
 and
 .Em The Ports Collection
___
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: r334283 - head/sys/compat/linuxkpi/common/include/linux

2018-05-28 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 28 11:26:40 2018
New Revision: 334283
URL: https://svnweb.freebsd.org/changeset/base/334283

Log:
  The schedule_timeout_killable() function should listen for signals
  in the LinuxKPI.
  
  Found by: Johannes Lundberg 
  MFC after:1 week
  Sponsored by: Mellanox Technologies

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

Modified: head/sys/compat/linuxkpi/common/include/linux/sched.h
==
--- head/sys/compat/linuxkpi/common/include/linux/sched.h   Mon May 28 
10:55:09 2018(r334282)
+++ head/sys/compat/linuxkpi/common/include/linux/sched.h   Mon May 28 
11:26:40 2018(r334283)
@@ -153,7 +153,7 @@ linux_schedule_get_interrupt_value(struct task_struct 
 #defineschedule_timeout(timeout)   \
linux_schedule_timeout(timeout)
 #defineschedule_timeout_killable(timeout)  \
-   schedule_timeout_uninterruptible(timeout)
+   schedule_timeout_interruptible(timeout)
 #defineschedule_timeout_interruptible(timeout) ({  \
set_current_state(TASK_INTERRUPTIBLE);  \
schedule_timeout(timeout);  \
___
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: r334281 - head/sys/compat/linuxkpi/common/include/linux

2018-05-28 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 28 10:54:24 2018
New Revision: 334281
URL: https://svnweb.freebsd.org/changeset/base/334281

Log:
  Implement wait_event_killable() in the LinuxKPI.
  
  Requested by: Johannes Lundberg 
  MFC after:1 week
  Sponsored by: Mellanox Technologies

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

Modified: head/sys/compat/linuxkpi/common/include/linux/wait.h
==
--- head/sys/compat/linuxkpi/common/include/linux/wait.hMon May 28 
10:51:39 2018(r334280)
+++ head/sys/compat/linuxkpi/common/include/linux/wait.hMon May 28 
10:54:24 2018(r334281)
@@ -170,6 +170,11 @@ int linux_wait_event_common(wait_queue_head_t *, wait_
NULL);  \
 })
 
+#definewait_event_killable(wqh, cond) ({   
\
+   __wait_event_common(wqh, cond, MAX_SCHEDULE_TIMEOUT,\
+   TASK_INTERRUPTIBLE, NULL);  \
+})
+
 #definewait_event_interruptible(wqh, cond) ({  
\
__wait_event_common(wqh, cond, MAX_SCHEDULE_TIMEOUT,\
TASK_INTERRUPTIBLE, NULL);  \
___
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: r334280 - head/sys/compat/linuxkpi/common/src

2018-05-28 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 28 10:51:39 2018
New Revision: 334280
URL: https://svnweb.freebsd.org/changeset/base/334280

Log:
  Allow TASK_PARKED bit being set when going to sleep in the LinuxKPI.
  
  Found by: Johannes Lundberg 
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/src/linux_schedule.c

Modified: head/sys/compat/linuxkpi/common/src/linux_schedule.c
==
--- head/sys/compat/linuxkpi/common/src/linux_schedule.cMon May 28 
09:41:44 2018(r334279)
+++ head/sys/compat/linuxkpi/common/src/linux_schedule.cMon May 28 
10:51:39 2018(r334280)
@@ -47,7 +47,7 @@ linux_add_to_sleepqueue(void *wchan, struct task_struc
 {
int flags, ret;
 
-   MPASS((state & ~TASK_NORMAL) == 0);
+   MPASS((state & ~(TASK_PARKED | TASK_NORMAL)) == 0);
 
flags = SLEEPQ_SLEEP | ((state & TASK_INTERRUPTIBLE) != 0 ?
SLEEPQ_INTERRUPTIBLE : 0);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r334279 - head/usr.sbin/ipfwpcap

2018-05-28 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 28 09:41:44 2018
New Revision: 334279
URL: https://svnweb.freebsd.org/changeset/base/334279

Log:
  Buildfix for GCC after r334277.
  
  MFC after:1 month
  Sponsored by: Mellanox Technologies

Modified:
  head/usr.sbin/ipfwpcap/ipfwpcap.c

Modified: head/usr.sbin/ipfwpcap/ipfwpcap.c
==
--- head/usr.sbin/ipfwpcap/ipfwpcap.c   Mon May 28 09:23:28 2018
(r334278)
+++ head/usr.sbin/ipfwpcap/ipfwpcap.c   Mon May 28 09:41:44 2018
(r334279)
@@ -41,6 +41,8 @@
 #include   /* for IP_MAXPACKET */
 #include /* for IP_MAXPACKET */
 
+#include 
+
 /* XXX normally defined in config.h */
 #define HAVE_STRLCPY 1
 #define HAVE_SNPRINTF 1
___
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: r334278 - head/sys/netipsec

2018-05-28 Thread Andrey V. Elsukov
Author: ae
Date: Mon May 28 09:23:28 2018
New Revision: 334278
URL: https://svnweb.freebsd.org/changeset/base/334278

Log:
  Temporary disable SPDCACHE statistic accounting until proper fix will be
  committed. This fixes the kernel build without option IPSEC.

Modified:
  head/sys/netipsec/key.c

Modified: head/sys/netipsec/key.c
==
--- head/sys/netipsec/key.c Mon May 28 08:12:18 2018(r334277)
+++ head/sys/netipsec/key.c Mon May 28 09:23:28 2018(r334278)
@@ -930,13 +930,13 @@ key_allocsp(struct secpolicyindex *spidx, u_int dir)
if (entry->sp != NULL)
SP_ADDREF(sp);
 
-   IPSECSTAT_INC(ips_spdcache_hits);
+   /* IPSECSTAT_INC(ips_spdcache_hits); */
 
SPDCACHE_UNLOCK(hashv);
goto out;
}
 
-   IPSECSTAT_INC(ips_spdcache_misses);
+   /* IPSECSTAT_INC(ips_spdcache_misses); */
 
sp = key_do_allocsp(spidx, dir);
entry = spdcache_entry_alloc(spidx, sp);
___
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: r334275 - head/lib/libc/string

2018-05-28 Thread Poul-Henning Kamp

In message <20180528155019.w2...@besplex.bde.org>, Bruce Evans writes:

>Note that assert() can't be used in signal handlers since it is required
>to print to stderr due to C not having any output methods except stdio.

That is precisly why I added abort2(2) more than 10 years ago.

-- 
Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
p...@freebsd.org | TCP/IP since RFC 956
FreeBSD committer   | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
___
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: r334275 - head/lib/libc/string

2018-05-28 Thread Bruce Evans

On Mon, 28 May 2018, Marcelo Araujo wrote:


Log:
 Update strsep(3) EXAMPLE section regards the usage of assert(3).

 As many people has pointed out, using assert(3) shall be not the best approach
 to verify if strdup(3) has allocated memory to string.

 Reviewed by:   imp



Modified: head/lib/libc/string/strsep.3
==
--- head/lib/libc/string/strsep.3   Mon May 28 04:38:10 2018
(r334274)
+++ head/lib/libc/string/strsep.3   Mon May 28 05:01:42 2018
(r334275)
@@ -31,7 +31,7 @@
.\"@(#)strsep.38.1 (Berkeley) 6/9/93
.\" $FreeBSD$
.\"
-.Dd December 5, 2008
+.Dd May 28, 2018
.Dt STRSEP 3
.Os
.Sh NAME
@@ -86,12 +86,12 @@ to parse a string, and prints each token in separate l
char *token, *string, *tofree;

tofree = string = strdup("abc,def,ghi");
-assert(string != NULL);
+if (string != NULL)
+   while ((token = strsep(&string, ",")) != NULL)
+   printf("%s\en", token);

-while ((token = strsep(&string, ",")) != NULL)
-   printf("%s\en", token);
-
free(tofree);
+free(string);
.Ed
.Pp
The following uses


This is even worse than before.  Errors are now mishandled in all cases
by silently ignoring them.

On most arches, null pointers are handled better than with assert() by
the default error handling of sending a SIGSEGV to the process; this normally
terminates it and dumps core.

All assert() does is give a message that is only slightly better than nothing
when it work, and then sends a SIGABRT to the process after breaking
restartability by doing this in the non-returning functions abort().  That
is without NDEBUG.  NDEBUG gives the better default error handling.

Note that assert() can't be used in signal handlers since it is required
to print to stderr due to C not having any output methods except stdio.
Even printing to stderr is fragile, especially after malloc() failures,
since stderr might be buffered and delayed allocation of its buffer might
fail.  The FreeBSD implementation falls back to unbuffered then (or fails
in setvbuf()), but the C standard doesn't require this.

malloc() failures "can't happen" anyway, especially for strdup().  I
used to test them using rlimits.  IIRC, ulimit -d and ulimit -m used
to work to restrict malloc() when malloc() used sbrk().  But now
malloc() uses mmap() and limits don't work for it.  Also, malloc()
on at least amd64 now takes more than 2MB before doing anything (2MB
for __je_extents_rtree and a mere few hundred KB for other parts of
malloc()).  malloc() might fail, but hundreds if not thousands of
small strdup()s can probably be done in just the slop required to
fit malloc()'s overhead.

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: r334277 - in head: contrib/libpcap contrib/ofed/usr.lib/3 contrib/pf/pflogd contrib/wpa/src/l2_packet lib lib/libpcap share/mk usr.sbin/cxgbetool

2018-05-28 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 28 08:12:18 2018
New Revision: 334277
URL: https://svnweb.freebsd.org/changeset/base/334277

Log:
  MFV r333789: libpcap 1.9.0 (pre-release)
  
  MFC after:1 month
  Sponsored by: Mellanox Technologies

Replaced:
  head/contrib/libpcap/
 - copied from r333789, vendor/libpcap/dist/
Deleted:
  head/lib/libpcap/pcap-netmap.c
Modified:
  head/contrib/ofed/usr.lib/3/Makefile
  head/contrib/pf/pflogd/pflogd.c
  head/contrib/wpa/src/l2_packet/l2_packet_freebsd.c
  head/lib/Makefile
  head/lib/libpcap/Makefile
  head/lib/libpcap/config.h
  head/share/mk/src.libnames.mk
  head/usr.sbin/cxgbetool/cxgbetool.c

Modified: head/contrib/ofed/usr.lib/3/Makefile
==
--- head/contrib/ofed/usr.lib/3/MakefileMon May 28 06:01:02 2018
(r334276)
+++ head/contrib/ofed/usr.lib/3/MakefileMon May 28 08:12:18 2018
(r334277)
@@ -2,7 +2,8 @@
 
 SUBDIR= \
 ../../libibnetdisc \
-../../opensm/libopensm
+../../opensm/libopensm \
+../../../../lib/libpcap
 
 SUBDIR_PARALLEL=
 

Modified: head/contrib/pf/pflogd/pflogd.c
==
--- head/contrib/pf/pflogd/pflogd.c Mon May 28 06:01:02 2018
(r334276)
+++ head/contrib/pf/pflogd/pflogd.c Mon May 28 08:12:18 2018
(r334277)
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/contrib/wpa/src/l2_packet/l2_packet_freebsd.c
==
--- head/contrib/wpa/src/l2_packet/l2_packet_freebsd.c  Mon May 28 06:01:02 
2018(r334276)
+++ head/contrib/wpa/src/l2_packet/l2_packet_freebsd.c  Mon May 28 08:12:18 
2018(r334277)
@@ -8,7 +8,7 @@
  */
 
 #include "includes.h"
-#if defined(__APPLE__) || defined(__GLIBC__)
+#if defined(__APPLE__) || defined(__GLIBC__) || defined(__FreeBSD__)
 #include 
 #endif /* __APPLE__ */
 #include 

Modified: head/lib/Makefile
==
--- head/lib/Makefile   Mon May 28 06:01:02 2018(r334276)
+++ head/lib/Makefile   Mon May 28 08:12:18 2018(r334277)
@@ -67,7 +67,7 @@ SUBDIR=   ${SUBDIR_BOOTSTRAP} \
libopie \
libpam \
libpathconv \
-   libpcap \
+   ${_libpcap} \
libpjdlog \
${_libproc} \
libprocstat \
@@ -182,6 +182,14 @@ SUBDIR.${MK_PMC}+= libopencsd
 .if ${MACHINE_CPUARCH} == "amd64"
 SUBDIR.${MK_PMC}+= libipt
 SUBDIR.${MK_BHYVE}+=   libvmmapi
+.endif
+
+.if ${MK_OFED} == "no"
+#
+# When OFED is enabled libpcap is built as part of
+# OFED due to library dependencies
+#
+_libpcap=  libpcap
 .endif
 
 .if ${MACHINE_CPUARCH} != "sparc64"

Modified: head/lib/libpcap/Makefile
==
--- head/lib/libpcap/Makefile   Mon May 28 06:01:02 2018(r334276)
+++ head/lib/libpcap/Makefile   Mon May 28 08:12:18 2018(r334277)
@@ -7,16 +7,51 @@ SHLIBDIR?= /lib
 
 PACKAGE=lib${LIB}
 LIB=   pcap
-SRCS=  grammar.y tokdefs.h pcap_version.h pcap-bpf.c \
-   pcap-netmap.c fad-helpers.c \
-   pcap.c pcap-common.c inet.c fad-getad.c gencode.c optimize.c 
nametoaddr.c \
-   etherent.c savefile.c bpf_filter.c bpf_image.c bpf_dump.c \
-   scanner.l sf-pcap.c sf-pcap-ng.c version.c
 
+SRCS=  bpf_dump.c \
+   bpf_filter.c \
+   bpf_image.c \
+   etherent.c \
+   fad-getad.c \
+   fmtutils.c \
+   gencode.c \
+   grammar.y \
+   nametoaddr.c \
+   optimize.c \
+   pcap-bpf.c \
+   pcap-common.c \
+   pcap-netmap.c \
+   pcap-netmap.h \
+   pcap.c \
+   savefile.c \
+   scanner.l \
+   sf-pcap.c \
+   sf-pcapng.c \
+   tokdefs.h
+
 # Old compatibility headers
-INCS=  pcap.h pcap-namedb.h pcap-bpf.h
+INCS=  fmtutils.h \
+   pcap-bpf.h \
+   pcap-namedb.h \
+   pcap-netmap.h \
+   pcap.h
 
-PCAPINCS=  pcap/pcap.h pcap/namedb.h pcap/bpf.h pcap/dlt.h 
pcap/export-defs.h
+PCAPINCS= \
+   pcap/bluetooth.h \
+   pcap/bpf.h \
+   pcap/can_socketcan.h \
+   pcap/compiler-tests.h \
+   pcap/dlt.h \
+   pcap/funcattrs.h \
+   pcap/ipnet.h \
+   pcap/namedb.h \
+   pcap/nflog.h \
+   pcap/pcap-inttypes.h \
+   pcap/pcap.h \
+   pcap/sll.h \
+   pcap/usb.h \
+   pcap/vlan.h
+
 PCAPINCSDIR=   ${INCLUDEDIR}/pcap
 INCSGROUPS=INCS PCAPINCS
 
@@ -40,6 +75,7 @@ MAN=  pcap.3 \
pcap_fileno.3 \
pcap_findalldevs.3 \
pcap_freecode.3 \
+   pcap_get_required_select_timeout.3 \
pcap_get_selectable_fd.3 \
pcap_get_tstamp_precision.3 \
pcap_geterr.3 \
@@ -61,6 +97,7 @@ MAN=  pcap.3 \
pcap_set_datalink.3 \
pcap_set_immediate_mode.3 \
pcap_set_promisc.3 \
+   pcap