svn commit: r352890 - stable/12/sys/kern

2019-09-29 Thread Xin LI
Author: delphij
Date: Mon Sep 30 06:38:34 2019
New Revision: 352890
URL: https://svnweb.freebsd.org/changeset/base/352890

Log:
  MFC r351417: r351417: INVARIANTS: treat LA_LOCKED as the same of LA_XLOCKED
  in mtx_assert.

Modified:
  stable/12/sys/kern/kern_mutex.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/kern_mutex.c
==
--- stable/12/sys/kern/kern_mutex.c Mon Sep 30 06:09:32 2019
(r352889)
+++ stable/12/sys/kern/kern_mutex.c Mon Sep 30 06:38:34 2019
(r352890)
@@ -176,6 +176,21 @@ void
 assert_mtx(const struct lock_object *lock, int what)
 {
 
+   /*
+* Treat LA_LOCKED as if LA_XLOCKED was asserted.
+*
+* Some callers of lc_assert uses LA_LOCKED to indicate that either
+* a shared lock or write lock was held, while other callers uses
+* the more strict LA_XLOCKED (used as MA_OWNED).
+*
+* Mutex is the only lock class that can not be shared, as a result,
+* we can reasonably consider the caller really intends to assert
+* LA_XLOCKED when they are asserting LA_LOCKED on a mutex object.
+*/
+   if (what & LA_LOCKED) {
+   what &= ~LA_LOCKED;
+   what |= LA_XLOCKED;
+   }
mtx_assert((const struct mtx *)lock, what);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352889 - stable/12/usr.bin/top

2019-09-29 Thread Dimitry Andric
Author: dim
Date: Mon Sep 30 06:09:32 2019
New Revision: 352889
URL: https://svnweb.freebsd.org/changeset/base/352889

Log:
  MFC r352804:
  
  Correct the final argument name in the top(1) manpage.
  
  The description talks about 'number', while the final argument was
  'count'.  Since 'count' is already used for the count of displays,
  change the final argument name to 'number'.
  
  MFC r352818:
  
  Make fractional delays for top(1) work for interactive mode.
  
  In r334906, the -s option was changed to allow fractional times, but
  this only functioned correctly for batch mode.  In interactive mode, any
  delay below 1.0 would get floored to zero.  This would put top(1) into a
  tight loop, which could be difficult to interrupt.
  
  Fix this by storing the -s option value (after validation) into a struct
  timeval, and using that struct consistently for delaying with select(2).
  
  Next up is to allow interactive entry of a fractional delay value.
  
  MFC r352819:
  
  Allow entering fractional delays in top(1) interactive mode.
  
  This uses the same logic as with the -s option, first validating the
  entered value, then storing the result in a struct timeval.

Modified:
  stable/12/usr.bin/top/top.1
  stable/12/usr.bin/top/top.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.bin/top/top.1
==
--- stable/12/usr.bin/top/top.1 Mon Sep 30 06:04:22 2019(r352888)
+++ stable/12/usr.bin/top/top.1 Mon Sep 30 06:09:32 2019(r352889)
@@ -15,7 +15,7 @@
 .Op Fl s Ar time
 .Op Fl o Ar field
 .Op Fl p Ar pid
-.Op Ar count
+.Op Ar number
 .Sh DESCRIPTION
 .Nm
 displays the top
@@ -144,7 +144,7 @@ no information is available about the percentage of ti
 .It Fl s Ar time
 Set the delay between screen updates to
 .Ar time
-seconds.
+seconds, which may be fractional.
 The default delay between updates is 1 second.
 .It Fl o Ar field
 Sort the process display area on the specified field.

Modified: stable/12/usr.bin/top/top.c
==
--- stable/12/usr.bin/top/top.c Mon Sep 30 06:04:22 2019(r352888)
+++ stable/12/usr.bin/top/top.c Mon Sep 30 06:09:32 2019(r352889)
@@ -232,7 +232,7 @@ main(int argc, const char *argv[])
 static char tempbuf2[50];
sigset_t old_sigmask, new_sigmask;
 int topn = Infinity;
-double delay = 2;
+struct timeval delay = { 2, 0 };
 int displays = 0;  /* indicates unspecified */
 int sel_ret = 0;
 time_t curr_time;
@@ -371,21 +371,27 @@ main(int argc, const char *argv[])
break;
  }
 
- case 's':
-   delay = strtod(optarg, &nptr);
-   if (nptr == optarg) {
-   warnx("warning: invalid delay");
-   delay = 2;
-   warnings++;
-   }
-   if (delay < 0) {
-   warnx("warning: seconds delay should be 
positive -- using default");
-   delay = 2;
-   warnings++;
-   }
+ case 's':
+ {
+ double delay_d = strtod(optarg, &nptr);
+ if (nptr == optarg)
+ {
+ warnx("warning: invalid delay");
+ warnings++;
+ }
+ else if (delay_d <= 0)
+ {
+ warnx("warning: seconds delay should be positive -- using 
default");
+ warnings++;
+ }
+ else
+ {
+ delay.tv_sec = delay_d;
+ delay.tv_usec = (delay_d - delay.tv_sec) * 1e6;
+ }
+ break;
+ }
 
-   break;
-
  case 'q': /* be quick about it */
errno = 0;
i = setpriority(PRIO_PROCESS, 0, PRIO_MIN);
@@ -698,7 +704,8 @@ restart:
no_command = true;
if (!interactive)
{
-   usleep(delay * 1e6);
+   timeout = delay;
+   select(0, NULL, NULL, NULL, &timeout);
if (leaveflag) {
end_screen();
exit(0);
@@ -712,8 +719,7 @@ restart:
/* set up arguments for select with timeout */
FD_ZERO(&readfds);
FD_SET(0, &readfds);/* for standard input */
-   timeout.tv_sec  = delay;
-   timeout.tv_usec = 0;
+   timeout = delay;
 
if (leaveflag) {
end_screen();
@@ -874,14 +880,22 @@ restart:
 
case CMD_delay: /* new seconds delay */
 

svn commit: r352888 - stable/12/sys/contrib/zlib

2019-09-29 Thread Xin LI
Author: delphij
Date: Mon Sep 30 06:04:22 2019
New Revision: 352888
URL: https://svnweb.freebsd.org/changeset/base/352888

Log:
  MFC r351501: MFV r351500: Fix CLEAR_HASH macro to be usable as a single
  statement.

Modified:
  stable/12/sys/contrib/zlib/deflate.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/contrib/zlib/deflate.c
==
--- stable/12/sys/contrib/zlib/deflate.cMon Sep 30 05:43:57 2019
(r352887)
+++ stable/12/sys/contrib/zlib/deflate.cMon Sep 30 06:04:22 2019
(r352888)
@@ -190,8 +190,11 @@ local const config configuration_table[10] = {
  * prev[] will be initialized on the fly.
  */
 #define CLEAR_HASH(s) \
-s->head[s->hash_size-1] = NIL; \
-zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
+do { \
+s->head[s->hash_size-1] = NIL; \
+zmemzero((Bytef *)s->head, \
+ (unsigned)(s->hash_size-1)*sizeof(*s->head)); \
+} while (0)
 
 /* ===
  * Slide the hash table when sliding the window down (could be avoided with 32
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352887 - stable/12/sbin/newfs_msdos

2019-09-29 Thread Xin LI
Author: delphij
Date: Mon Sep 30 05:43:57 2019
New Revision: 352887
URL: https://svnweb.freebsd.org/changeset/base/352887

Log:
  MFC r351382:
  
  When creating a new FAT32 filesystem, use "unknown" (0x) for
  FSI_Nxt_Free instead of providing a wrong value.
  
  With this change, fsck_msdosfs would no longer complain about invalid
  FSInfo information.

Modified:
  stable/12/sbin/newfs_msdos/mkfs_msdos.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/newfs_msdos/mkfs_msdos.c
==
--- stable/12/sbin/newfs_msdos/mkfs_msdos.c Mon Sep 30 04:54:02 2019
(r352886)
+++ stable/12/sbin/newfs_msdos/mkfs_msdos.c Mon Sep 30 05:43:57 2019
(r352887)
@@ -717,7 +717,7 @@ mkfs_msdos(const char *fname, const char *dtype, const
mk4(img, 0x41615252);
mk4(img + MINBPS - 28, 0x61417272);
mk4(img + MINBPS - 24, 0x);
-   mk4(img + MINBPS - 20, bpb.bpbRootClust);
+   mk4(img + MINBPS - 20, 0x);
mk2(img + MINBPS - 2, DOSMAGIC);
} else if (lsn >= bpb.bpbResSectors && lsn < dir &&
   !((lsn - bpb.bpbResSectors) %
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352886 - releng/12.1/sys/netinet

2019-09-29 Thread Michael Tuexen
Author: tuexen
Date: Mon Sep 30 04:54:02 2019
New Revision: 352886
URL: https://svnweb.freebsd.org/changeset/base/352886

Log:
  MFS r352508:
  Don't write to memory outside of the allocated array for SACK blocks.
  
  PR:   240837
  Approved by:  re (delphij@)
  Obtained from:rrs@
  Sponsored by: Netflix, Inc.

Modified:
  releng/12.1/sys/netinet/tcp_sack.c
Directory Properties:
  releng/12.1/   (props changed)

Modified: releng/12.1/sys/netinet/tcp_sack.c
==
--- releng/12.1/sys/netinet/tcp_sack.c  Mon Sep 30 03:35:48 2019
(r352885)
+++ releng/12.1/sys/netinet/tcp_sack.c  Mon Sep 30 04:54:02 2019
(r352886)
@@ -235,7 +235,7 @@ tcp_update_dsack_list(struct tcpcb *tp, tcp_seq rcv_st
saved_blks[n].start = mid_blk.start;
saved_blks[n++].end = mid_blk.end;
}
-   for (j = 0; (j < tp->rcv_numsacks) && (j < MAX_SACK_BLKS-1); j++) {
+   for (j = 0; (j < tp->rcv_numsacks) && (n < MAX_SACK_BLKS); j++) {
if (((SEQ_LT(tp->sackblks[j].end, mid_blk.start) ||
  SEQ_GT(tp->sackblks[j].start, mid_blk.end)) &&
(SEQ_GT(tp->sackblks[j].start, tp->rcv_nxt
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352885 - releng/12.1/share/timedef

2019-09-29 Thread Li-Wen Hsu
Author: lwhsu
Date: Mon Sep 30 03:35:48 2019
New Revision: 352885
URL: https://svnweb.freebsd.org/changeset/base/352885

Log:
  MFC r349225:
  
  Finsh readding Big5 in r317204, which was reverting r315568.  This commit
  reverts r315569.
  
  Reported by:  Ting-Wei Lan 
  Discussed with:   kevlo
  Sponsored by: The FreeBSD Foundation
  
  Approved by:  re (delphij)

Added:
  releng/12.1/share/timedef/zh_TW.Big5.src
 - copied unchanged from r352879, stable/12/share/timedef/zh_TW.Big5.src
Modified:
  releng/12.1/share/timedef/Makefile
Directory Properties:
  releng/12.1/   (props changed)

Modified: releng/12.1/share/timedef/Makefile
==
--- releng/12.1/share/timedef/Makefile  Mon Sep 30 02:32:51 2019
(r352884)
+++ releng/12.1/share/timedef/Makefile  Mon Sep 30 03:35:48 2019
(r352885)
@@ -128,6 +128,7 @@ LOCALES+=   zh_CN.GBK
 LOCALES+=  zh_CN.UTF-8
 LOCALES+=  zh_CN.eucCN
 LOCALES+=  zh_HK.UTF-8
+LOCALES+=  zh_TW.Big5
 LOCALES+=  zh_TW.UTF-8
 
 

Copied: releng/12.1/share/timedef/zh_TW.Big5.src (from r352879, 
stable/12/share/timedef/zh_TW.Big5.src)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ releng/12.1/share/timedef/zh_TW.Big5.srcMon Sep 30 03:35:48 2019
(r352885, copy of r352879, stable/12/share/timedef/zh_TW.Big5.src)
@@ -0,0 +1,87 @@
+# Warning: Do not edit. This file is automatically generated from the
+# tools in /usr/src/tools/tools/locale. The data is obtained from the
+# CLDR project, obtained from http://cldr.unicode.org/
+# -
+#
+# Short month names
+�@
+�@
+�@
+�@
+�@
+�@
+�@
+�@
+�@
+��
+��
+��
+#
+# Long month names (as in a date)
+1��
+2��
+3��
+4��
+5��
+6��
+7��
+8��
+9��
+10��
+11��
+12��
+#
+# Short weekday names
+�g��
+�g�@
+�g�G
+�g�T
+�g�|
+�g��
+�g��
+#
+# Long weekday names
+�P
+�P���@
+�P���G
+�P���T
+�P���|
+�P
+�P
+#
+# X_fmt
+%H��%M��%S��
+#
+# x_fmt
+%Y/%m/%d
+#
+# c_fmt
+%a %b/%e %T %Y
+#
+# AM/PM
+�W��
+�U��
+#
+# date_fmt
+%Y�~%_m��%e�� %A %X %Z
+#
+# Long month names (without case ending)
+1��
+2��
+3��
+4��
+5��
+6��
+7��
+8��
+9��
+10��
+11��
+12��
+#
+# md_order
+md
+#
+# ampm_fmt
+%I:%M:%S %p
+# EOF
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352884 - in stable: 10/contrib/ipfilter/man 11/contrib/ipfilter/man 12/contrib/ipfilter/man

2019-09-29 Thread Cy Schubert
Author: cy
Date: Mon Sep 30 02:32:51 2019
New Revision: 352884
URL: https://svnweb.freebsd.org/changeset/base/352884

Log:
  MFC r352783:
  
  Fix a typo.

Modified:
  stable/10/contrib/ipfilter/man/ippool.8
Directory Properties:
  stable/10/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/contrib/ipfilter/man/ippool.8
  stable/12/contrib/ipfilter/man/ippool.8
Directory Properties:
  stable/11/   (props changed)
  stable/12/   (props changed)

Modified: stable/10/contrib/ipfilter/man/ippool.8
==
--- stable/10/contrib/ipfilter/man/ippool.8 Mon Sep 30 01:59:27 2019
(r352883)
+++ stable/10/contrib/ipfilter/man/ippool.8 Mon Sep 30 02:32:51 2019
(r352884)
@@ -108,7 +108,7 @@ Sets the hashing seed to the number specified.  Only f
 type pools.
 .TP
 .B -t 
-Sets the type of pool being defined.  Myst be one of
+Sets the type of pool being defined.  Must be one of
 .B tree,
 .B hash,
 .B group-map.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352884 - in stable: 10/contrib/ipfilter/man 11/contrib/ipfilter/man 12/contrib/ipfilter/man

2019-09-29 Thread Cy Schubert
Author: cy
Date: Mon Sep 30 02:32:51 2019
New Revision: 352884
URL: https://svnweb.freebsd.org/changeset/base/352884

Log:
  MFC r352783:
  
  Fix a typo.

Modified:
  stable/11/contrib/ipfilter/man/ippool.8
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/10/contrib/ipfilter/man/ippool.8
  stable/12/contrib/ipfilter/man/ippool.8
Directory Properties:
  stable/10/   (props changed)
  stable/12/   (props changed)

Modified: stable/11/contrib/ipfilter/man/ippool.8
==
--- stable/11/contrib/ipfilter/man/ippool.8 Mon Sep 30 01:59:27 2019
(r352883)
+++ stable/11/contrib/ipfilter/man/ippool.8 Mon Sep 30 02:32:51 2019
(r352884)
@@ -108,7 +108,7 @@ Sets the hashing seed to the number specified.  Only f
 type pools.
 .TP
 .B -t 
-Sets the type of pool being defined.  Myst be one of
+Sets the type of pool being defined.  Must be one of
 .B tree,
 .B hash,
 .B group-map.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352884 - in stable: 10/contrib/ipfilter/man 11/contrib/ipfilter/man 12/contrib/ipfilter/man

2019-09-29 Thread Cy Schubert
Author: cy
Date: Mon Sep 30 02:32:51 2019
New Revision: 352884
URL: https://svnweb.freebsd.org/changeset/base/352884

Log:
  MFC r352783:
  
  Fix a typo.

Modified:
  stable/12/contrib/ipfilter/man/ippool.8
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/10/contrib/ipfilter/man/ippool.8
  stable/11/contrib/ipfilter/man/ippool.8
Directory Properties:
  stable/10/   (props changed)
  stable/11/   (props changed)

Modified: stable/12/contrib/ipfilter/man/ippool.8
==
--- stable/12/contrib/ipfilter/man/ippool.8 Mon Sep 30 01:59:27 2019
(r352883)
+++ stable/12/contrib/ipfilter/man/ippool.8 Mon Sep 30 02:32:51 2019
(r352884)
@@ -108,7 +108,7 @@ Sets the hashing seed to the number specified.  Only f
 type pools.
 .TP
 .B -t 
-Sets the type of pool being defined.  Myst be one of
+Sets the type of pool being defined.  Must be one of
 .B tree,
 .B hash,
 .B group-map.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352883 - stable/12/sys/dev/nvme

2019-09-29 Thread Warner Losh
Author: imp
Date: Mon Sep 30 01:59:27 2019
New Revision: 352883
URL: https://svnweb.freebsd.org/changeset/base/352883

Log:
  MFC r351828:
  
Support doorbell strides != 0.

Modified:
  stable/12/sys/dev/nvme/nvme_ctrlr.c
  stable/12/sys/dev/nvme/nvme_private.h
  stable/12/sys/dev/nvme/nvme_qpair.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/nvme/nvme_ctrlr.c
==
--- stable/12/sys/dev/nvme/nvme_ctrlr.c Mon Sep 30 01:25:37 2019
(r352882)
+++ stable/12/sys/dev/nvme/nvme_ctrlr.c Mon Sep 30 01:59:27 2019
(r352883)
@@ -90,19 +90,25 @@ nvme_ctrlr_construct_io_qpairs(struct nvme_controller 
struct nvme_qpair   *qpair;
uint32_tcap_lo;
uint16_tmqes;
-   int i, error, num_entries, num_trackers;
+   int i, error, num_entries, num_trackers, 
max_entries;
 
-   num_entries = NVME_IO_ENTRIES;
-   TUNABLE_INT_FETCH("hw.nvme.io_entries", &num_entries);
-
/*
-* NVMe spec sets a hard limit of 64K max entries, but
-*  devices may specify a smaller limit, so we need to check
-*  the MQES field in the capabilities register.
+* NVMe spec sets a hard limit of 64K max entries, but devices may
+* specify a smaller limit, so we need to check the MQES field in the
+* capabilities register. We have to cap the number of entries to the
+* current stride allows for in BAR 0/1, otherwise the remainder entries
+* are inaccessable. MQES should reflect this, and this is just a
+* fail-safe.
 */
+   max_entries =
+   (rman_get_size(ctrlr->resource) - nvme_mmio_offsetof(doorbell[0])) /
+   (1 << (ctrlr->dstrd + 1));
+   num_entries = NVME_IO_ENTRIES;
+   TUNABLE_INT_FETCH("hw.nvme.io_entries", &num_entries);
cap_lo = nvme_mmio_read_4(ctrlr, cap_lo);
mqes = NVME_CAP_LO_MQES(cap_lo);
num_entries = min(num_entries, mqes + 1);
+   num_entries = min(num_entries, max_entries);
 
num_trackers = NVME_IO_TRACKERS;
TUNABLE_INT_FETCH("hw.nvme.io_trackers", &num_trackers);
@@ -110,9 +116,9 @@ nvme_ctrlr_construct_io_qpairs(struct nvme_controller 
num_trackers = max(num_trackers, NVME_MIN_IO_TRACKERS);
num_trackers = min(num_trackers, NVME_MAX_IO_TRACKERS);
/*
-* No need to have more trackers than entries in the submit queue.
-*  Note also that for a queue size of N, we can only have (N-1)
-*  commands outstanding, hence the "-1" here.
+* No need to have more trackers than entries in the submit queue.  Note
+* also that for a queue size of N, we can only have (N-1) commands
+* outstanding, hence the "-1" here.
 */
num_trackers = min(num_trackers, (num_entries-1));
 
@@ -1120,7 +1126,6 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, de
uint32_tcap_lo;
uint32_tcap_hi;
uint32_tto;
-   uint8_t dstrd;
uint8_t mpsmin;
int status, timeout_period;
 
@@ -1128,14 +1133,8 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, de
 
mtx_init(&ctrlr->lock, "nvme ctrlr lock", NULL, MTX_DEF);
 
-   /*
-* Software emulators may set the doorbell stride to something
-*  other than zero, but this driver is not set up to handle that.
-*/
cap_hi = nvme_mmio_read_4(ctrlr, cap_hi);
-   dstrd = NVME_CAP_HI_DSTRD(cap_hi);
-   if (dstrd != 0)
-   return (ENXIO);
+   ctrlr->dstrd = NVME_CAP_HI_DSTRD(cap_hi) + 2;
 
mpsmin = NVME_CAP_HI_MPSMIN(cap_hi);
ctrlr->min_page_size = 1 << (12 + mpsmin);

Modified: stable/12/sys/dev/nvme/nvme_private.h
==
--- stable/12/sys/dev/nvme/nvme_private.h   Mon Sep 30 01:25:37 2019
(r352882)
+++ stable/12/sys/dev/nvme/nvme_private.h   Mon Sep 30 01:59:27 2019
(r352883)
@@ -297,6 +297,9 @@ struct nvme_controller {
/** timeout period in seconds */
uint32_ttimeout_period;
 
+   /** doorbell stride */
+   uint32_tdstrd;
+
struct nvme_qpair   adminq;
struct nvme_qpair   *ioq;
 

Modified: stable/12/sys/dev/nvme/nvme_qpair.c
==
--- stable/12/sys/dev/nvme/nvme_qpair.c Mon Sep 30 01:25:37 2019
(r352882)
+++ stable/12/sys/dev/nvme/nvme_qpair.c Mon Sep 30 01:59:27 2019
(r352883)
@@ -622,8 +622,8 @@ nvme_qpair_process_completions(struct nvme_qpair *qpai
qpair->phase = !qpair->phase;   /* 3 */
}
 
-   nvme_mmio_write_4(qpair->ctrlr, doorbell[qpair->id].cq_hdbl,

svn commit: r352882 - in stable/12/sys/cddl/dev/dtrace: amd64 i386

2019-09-29 Thread Mark Johnston
Author: markj
Date: Mon Sep 30 01:25:37 2019
New Revision: 352882
URL: https://svnweb.freebsd.org/changeset/base/352882

Log:
  MFC r352627:
  Implement x86 dtrace_invop_(un)init() in C.

Modified:
  stable/12/sys/cddl/dev/dtrace/amd64/dtrace_asm.S
  stable/12/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
  stable/12/sys/cddl/dev/dtrace/i386/dtrace_asm.S
  stable/12/sys/cddl/dev/dtrace/i386/dtrace_subr.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/cddl/dev/dtrace/amd64/dtrace_asm.S
==
--- stable/12/sys/cddl/dev/dtrace/amd64/dtrace_asm.SMon Sep 30 01:25:14 
2019(r352881)
+++ stable/12/sys/cddl/dev/dtrace/amd64/dtrace_asm.SMon Sep 30 01:25:37 
2019(r352882)
@@ -150,22 +150,6 @@ bp_ret:
END(dtrace_invop_start)
 
 /*
-void dtrace_invop_init(void)
-*/
-   ENTRY(dtrace_invop_init)
-   movq$dtrace_invop_start, dtrace_invop_jump_addr(%rip)
-   ret
-   END(dtrace_invop_init)
-
-/*
-void dtrace_invop_uninit(void)
-*/
-   ENTRY(dtrace_invop_uninit)
-   movq$0, dtrace_invop_jump_addr(%rip)
-   ret
-   END(dtrace_invop_uninit)
-
-/*
 greg_t dtrace_getfp(void)
 */
ENTRY(dtrace_getfp)

Modified: stable/12/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
==
--- stable/12/sys/cddl/dev/dtrace/amd64/dtrace_subr.c   Mon Sep 30 01:25:14 
2019(r352881)
+++ stable/12/sys/cddl/dev/dtrace/amd64/dtrace_subr.c   Mon Sep 30 01:25:37 
2019(r352882)
@@ -48,8 +48,12 @@
 #include 
 
 extern void dtrace_getnanotime(struct timespec *tsp);
+extern int (*dtrace_invop_jump_addr)(struct trapframe *);
 
-int dtrace_invop(uintptr_t, struct trapframe *, uintptr_t);
+intdtrace_invop(uintptr_t, struct trapframe *, uintptr_t);
+intdtrace_invop_start(struct trapframe *frame);
+void   dtrace_invop_init(void);
+void   dtrace_invop_uninit(void);
 
 typedef struct dtrace_invop_hdlr {
int (*dtih_func)(uintptr_t, struct trapframe *, uintptr_t);
@@ -107,6 +111,20 @@ dtrace_invop_remove(int (*func)(uintptr_t, struct trap
}
 
kmem_free(hdlr, 0);
+}
+
+void
+dtrace_invop_init(void)
+{
+
+   dtrace_invop_jump_addr = dtrace_invop_start;
+}
+
+void
+dtrace_invop_uninit(void)
+{
+
+   dtrace_invop_jump_addr = NULL;
 }
 
 /*ARGSUSED*/

Modified: stable/12/sys/cddl/dev/dtrace/i386/dtrace_asm.S
==
--- stable/12/sys/cddl/dev/dtrace/i386/dtrace_asm.S Mon Sep 30 01:25:14 
2019(r352881)
+++ stable/12/sys/cddl/dev/dtrace/i386/dtrace_asm.S Mon Sep 30 01:25:37 
2019(r352882)
@@ -135,22 +135,6 @@ invop_nop:
END(dtrace_invop_start)
 
 /*
-void dtrace_invop_init(void)
-*/
-   ENTRY(dtrace_invop_init)
-   movl$dtrace_invop_start, dtrace_invop_jump_addr
-   ret
-   END(dtrace_invop_init)
-
-/*
-void dtrace_invop_uninit(void)
-*/
-   ENTRY(dtrace_invop_uninit)
-   movl$0, dtrace_invop_jump_addr
-   ret
-   END(dtrace_invop_uninit)
-
-/*
 greg_t dtrace_getfp(void)
 */
 

Modified: stable/12/sys/cddl/dev/dtrace/i386/dtrace_subr.c
==
--- stable/12/sys/cddl/dev/dtrace/i386/dtrace_subr.cMon Sep 30 01:25:14 
2019(r352881)
+++ stable/12/sys/cddl/dev/dtrace/i386/dtrace_subr.cMon Sep 30 01:25:37 
2019(r352882)
@@ -51,8 +51,12 @@
 extern uintptr_t   kernelbase;
 
 extern void dtrace_getnanotime(struct timespec *tsp);
+extern int (*dtrace_invop_jump_addr)(struct trapframe *);
 
-int dtrace_invop(uintptr_t, struct trapframe *, uintptr_t);
+intdtrace_invop(uintptr_t, struct trapframe *, uintptr_t);
+intdtrace_invop_start(struct trapframe *frame);
+void   dtrace_invop_init(void);
+void   dtrace_invop_uninit(void);
 
 typedef struct dtrace_invop_hdlr {
int (*dtih_func)(uintptr_t, struct trapframe *, uintptr_t);
@@ -110,6 +114,20 @@ dtrace_invop_remove(int (*func)(uintptr_t, struct trap
}
 
kmem_free(hdlr, 0);
+}
+
+void
+dtrace_invop_init(void)
+{
+
+   dtrace_invop_jump_addr = dtrace_invop_start;
+}
+
+void
+dtrace_invop_uninit(void)
+{
+
+   dtrace_invop_jump_addr = NULL;
 }
 
 void
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352880 - stable/12/sys/dev/jme

2019-09-29 Thread Mark Johnston
Author: markj
Date: Mon Sep 30 01:24:44 2019
New Revision: 352880
URL: https://svnweb.freebsd.org/changeset/base/352880

Log:
  MFC r352626:
  Fix a harmless typo.

Modified:
  stable/12/sys/dev/jme/if_jme.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/jme/if_jme.c
==
--- stable/12/sys/dev/jme/if_jme.c  Mon Sep 30 00:01:54 2019
(r352879)
+++ stable/12/sys/dev/jme/if_jme.c  Mon Sep 30 01:24:44 2019
(r352880)
@@ -569,7 +569,7 @@ jme_map_intr_vector(struct jme_softc *sc)
MSINUM_INTR_SOURCE(2, N_INTR_TXQ3_COMP);
map[MSINUM_REG_INDEX(N_INTR_TXQ4_COMP)] |=
MSINUM_INTR_SOURCE(2, N_INTR_TXQ4_COMP);
-   map[MSINUM_REG_INDEX(N_INTR_TXQ4_COMP)] |=
+   map[MSINUM_REG_INDEX(N_INTR_TXQ5_COMP)] |=
MSINUM_INTR_SOURCE(2, N_INTR_TXQ5_COMP);
map[MSINUM_REG_INDEX(N_INTR_TXQ6_COMP)] |=
MSINUM_INTR_SOURCE(2, N_INTR_TXQ6_COMP);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352881 - stable/12/sys/amd64/amd64

2019-09-29 Thread Mark Johnston
Author: markj
Date: Mon Sep 30 01:25:14 2019
New Revision: 352881
URL: https://svnweb.freebsd.org/changeset/base/352881

Log:
  MFC r352624:
  Set NX on some non-leaf direct map page table entries.

Modified:
  stable/12/sys/amd64/amd64/pmap.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/amd64/amd64/pmap.c
==
--- stable/12/sys/amd64/amd64/pmap.cMon Sep 30 01:24:44 2019
(r352880)
+++ stable/12/sys/amd64/amd64/pmap.cMon Sep 30 01:25:14 2019
(r352881)
@@ -1544,13 +1544,13 @@ create_pagetables(vm_paddr_t *firstaddr)
}
for (j = 0; i < ndmpdp; i++, j++) {
pdp_p[i] = DMPDphys + ptoa(j);
-   pdp_p[i] |= X86_PG_RW | X86_PG_V;
+   pdp_p[i] |= X86_PG_RW | X86_PG_V | pg_nx;
}
 
/*
 * Instead of using a 1G page for the memory containing the kernel,
-* use 2M pages with appropriate permissions. (If using 1G pages,
-* this will partially overwrite the PDPEs above.)
+* use 2M pages with read-only and no-execute permissions.  (If using 1G
+* pages, this will partially overwrite the PDPEs above.)
 */
if (ndm1g) {
pd_p = (pd_entry_t *)DMPDkernphys;
@@ -1560,7 +1560,7 @@ create_pagetables(vm_paddr_t *firstaddr)
bootaddr_rwx(i << PDRSHIFT);
for (i = 0; i < nkdmpde; i++)
pdp_p[i] = (DMPDkernphys + ptoa(i)) | X86_PG_RW |
-   X86_PG_V;
+   X86_PG_V | pg_nx;
}
 
/* And recursively map PML4 to itself in order to get PTmap */
@@ -1571,7 +1571,7 @@ create_pagetables(vm_paddr_t *firstaddr)
/* Connect the Direct Map slot(s) up to the PML4. */
for (i = 0; i < ndmpdpphys; i++) {
p4_p[DMPML4I + i] = DMPDPphys + ptoa(i);
-   p4_p[DMPML4I + i] |= X86_PG_RW | X86_PG_V;
+   p4_p[DMPML4I + i] |= X86_PG_RW | X86_PG_V | pg_nx;
}
 
/* Connect the KVA slots up to the PML4 */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352879 - stable/12/share/timedef

2019-09-29 Thread Li-Wen Hsu
Author: lwhsu
Date: Mon Sep 30 00:01:54 2019
New Revision: 352879
URL: https://svnweb.freebsd.org/changeset/base/352879

Log:
  MFC r349225:
  
  Finsh readding Big5 in r317204, which was reverting r315568.  This commit
  reverts r315569.
  
  Reported by:  Ting-Wei Lan 
  Discussed with:   kevlo
  Sponsored by: The FreeBSD Foundation

Added:
  stable/12/share/timedef/zh_TW.Big5.src
 - copied unchanged from r349225, head/share/timedef/zh_TW.Big5.src
Modified:
  stable/12/share/timedef/Makefile
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/share/timedef/Makefile
==
--- stable/12/share/timedef/MakefileSun Sep 29 23:47:23 2019
(r352878)
+++ stable/12/share/timedef/MakefileMon Sep 30 00:01:54 2019
(r352879)
@@ -128,6 +128,7 @@ LOCALES+=   zh_CN.GBK
 LOCALES+=  zh_CN.UTF-8
 LOCALES+=  zh_CN.eucCN
 LOCALES+=  zh_HK.UTF-8
+LOCALES+=  zh_TW.Big5
 LOCALES+=  zh_TW.UTF-8
 
 

Copied: stable/12/share/timedef/zh_TW.Big5.src (from r349225, 
head/share/timedef/zh_TW.Big5.src)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/12/share/timedef/zh_TW.Big5.src  Mon Sep 30 00:01:54 2019
(r352879, copy of r349225, head/share/timedef/zh_TW.Big5.src)
@@ -0,0 +1,87 @@
+# Warning: Do not edit. This file is automatically generated from the
+# tools in /usr/src/tools/tools/locale. The data is obtained from the
+# CLDR project, obtained from http://cldr.unicode.org/
+# -
+#
+# Short month names
+�@
+�@
+�@
+�@
+�@
+�@
+�@
+�@
+�@
+��
+��
+��
+#
+# Long month names (as in a date)
+1��
+2��
+3��
+4��
+5��
+6��
+7��
+8��
+9��
+10��
+11��
+12��
+#
+# Short weekday names
+�g��
+�g�@
+�g�G
+�g�T
+�g�|
+�g��
+�g��
+#
+# Long weekday names
+�P
+�P���@
+�P���G
+�P���T
+�P���|
+�P
+�P
+#
+# X_fmt
+%H��%M��%S��
+#
+# x_fmt
+%Y/%m/%d
+#
+# c_fmt
+%a %b/%e %T %Y
+#
+# AM/PM
+�W��
+�U��
+#
+# date_fmt
+%Y�~%_m��%e�� %A %X %Z
+#
+# Long month names (without case ending)
+1��
+2��
+3��
+4��
+5��
+6��
+7��
+8��
+9��
+10��
+11��
+12��
+#
+# md_order
+md
+#
+# ampm_fmt
+%I:%M:%S %p
+# EOF
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352878 - head/contrib/elftoolchain/elfcopy

2019-09-29 Thread Aleksandr Rybalko
Author: ray
Date: Sun Sep 29 23:47:23 2019
New Revision: 352878
URL: https://svnweb.freebsd.org/changeset/base/352878

Log:
  Initialize baseaddr to suppres warning.
  
  Pointy hat to:ray

Modified:
  head/contrib/elftoolchain/elfcopy/binary.c

Modified: head/contrib/elftoolchain/elfcopy/binary.c
==
--- head/contrib/elftoolchain/elfcopy/binary.c  Sun Sep 29 22:41:06 2019
(r352877)
+++ head/contrib/elftoolchain/elfcopy/binary.c  Sun Sep 29 23:47:23 2019
(r352878)
@@ -58,6 +58,7 @@ create_binary(int ifd, int ofd)
errx(EXIT_FAILURE, "elf_begin() failed: %s",
elf_errmsg(-1));
 
+   baseaddr = 0;
baseoff = 0;
if (lseek(ofd, baseoff, SEEK_SET) < 0)
err(EXIT_FAILURE, "lseek failed");
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352877 - stable/12/sys/amd64/amd64

2019-09-29 Thread Mark Johnston
Author: markj
Date: Sun Sep 29 22:41:06 2019
New Revision: 352877
URL: https://svnweb.freebsd.org/changeset/base/352877

Log:
  MFC r351728, r352581 (by kib), r352606 (by kib):
  Add a sysctl to dump kernel mappings and their properties on amd64.

Modified:
  stable/12/sys/amd64/amd64/pmap.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/amd64/amd64/pmap.c
==
--- stable/12/sys/amd64/amd64/pmap.cSun Sep 29 22:37:59 2019
(r352876)
+++ stable/12/sys/amd64/amd64/pmap.cSun Sep 29 22:41:06 2019
(r352877)
@@ -124,6 +124,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2083,6 +2084,41 @@ pmap_cache_mask(pmap_t pmap, boolean_t is_pde)
return (mask);
 }
 
+static int
+pmap_pat_index(pmap_t pmap, pt_entry_t pte, bool is_pde)
+{
+   int pat_flag, pat_idx;
+
+   pat_idx = 0;
+   switch (pmap->pm_type) {
+   case PT_X86:
+   case PT_RVI:
+   /* The PAT bit is different for PTE's and PDE's. */
+   pat_flag = is_pde ? X86_PG_PDE_PAT : X86_PG_PTE_PAT;
+
+   if ((pte & pat_flag) != 0)
+   pat_idx |= 0x4;
+   if ((pte & PG_NC_PCD) != 0)
+   pat_idx |= 0x2;
+   if ((pte & PG_NC_PWT) != 0)
+   pat_idx |= 0x1;
+   break;
+   case PT_EPT:
+   if ((pte & EPT_PG_IGNORE_PAT) != 0)
+   panic("EPT PTE %#lx has no PAT memory type", pte);
+   pat_idx = (pte & EPT_PG_MEMORY_TYPE(0x7)) >> 3;
+   break;
+   }
+
+   /* See pmap_init_pat(). */
+   if (pat_idx == 4)
+   pat_idx = 0;
+   if (pat_idx == 7)
+   pat_idx = 3;
+
+   return (pat_idx);
+}
+
 bool
 pmap_ps_enabled(pmap_t pmap)
 {
@@ -9907,6 +9943,271 @@ pmap_pkru_clear(pmap_t pmap, vm_offset_t sva, vm_offse
return (error);
 }
 
+/*
+ * Track a range of the kernel's virtual address space that is contiguous
+ * in various mapping attributes.
+ */
+struct pmap_kernel_map_range {
+   vm_offset_t sva;
+   pt_entry_t attrs;
+   int ptes;
+   int pdes;
+   int pdpes;
+};
+
+static void
+sysctl_kmaps_dump(struct sbuf *sb, struct pmap_kernel_map_range *range,
+vm_offset_t eva)
+{
+   const char *mode;
+   int i, pat_idx;
+
+   if (eva <= range->sva)
+   return;
+
+   pat_idx = pmap_pat_index(kernel_pmap, range->attrs, true);
+   for (i = 0; i < PAT_INDEX_SIZE; i++)
+   if (pat_index[i] == pat_idx)
+   break;
+
+   switch (i) {
+   case PAT_WRITE_BACK:
+   mode = "WB";
+   break;
+   case PAT_WRITE_THROUGH:
+   mode = "WT";
+   break;
+   case PAT_UNCACHEABLE:
+   mode = "UC";
+   break;
+   case PAT_UNCACHED:
+   mode = "U-";
+   break;
+   case PAT_WRITE_PROTECTED:
+   mode = "WP";
+   break;
+   case PAT_WRITE_COMBINING:
+   mode = "WC";
+   break;
+   default:
+   printf("%s: unknown PAT mode %#x for range 0x%016lx-0x%016lx\n",
+   __func__, pat_idx, range->sva, eva);
+   mode = "??";
+   break;
+   }
+
+   sbuf_printf(sb, "0x%016lx-0x%016lx r%c%c%c%c %s %d %d %d\n",
+   range->sva, eva,
+   (range->attrs & X86_PG_RW) != 0 ? 'w' : '-',
+   (range->attrs & pg_nx) != 0 ? '-' : 'x',
+   (range->attrs & X86_PG_U) != 0 ? 'u' : 's',
+   (range->attrs & X86_PG_G) != 0 ? 'g' : '-',
+   mode, range->pdpes, range->pdes, range->ptes);
+
+   /* Reset to sentinel value. */
+   range->sva = KVADDR(NPML4EPG - 1, NPDPEPG - 1, NPDEPG - 1, NPTEPG - 1);
+}
+
+/*
+ * Determine whether the attributes specified by a page table entry match those
+ * being tracked by the current range.  This is not quite as simple as a direct
+ * flag comparison since some PAT modes have multiple representations.
+ */
+static bool
+sysctl_kmaps_match(struct pmap_kernel_map_range *range, pt_entry_t attrs)
+{
+   pt_entry_t diff, mask;
+
+   mask = X86_PG_G | X86_PG_RW | X86_PG_U | X86_PG_PDE_CACHE | pg_nx;
+   diff = (range->attrs ^ attrs) & mask;
+   if (diff == 0)
+   return (true);
+   if ((diff & ~X86_PG_PDE_PAT) == 0 &&
+   pmap_pat_index(kernel_pmap, range->attrs, true) ==
+   pmap_pat_index(kernel_pmap, attrs, true))
+   return (true);
+   return (false);
+}
+
+static void
+sysctl_kmaps_reinit(struct pmap_kernel_map_range *range, vm_offset_t va,
+pt_entry_t attrs)
+{
+
+   memset(range, 0, sizeof(*range));
+   range->sva = va;
+   range->attrs = attrs;
+}
+
+/*
+ * Given a leaf PTE, derive the mapping's attributes.  If

svn commit: r352876 - stable/12/share/man/man9

2019-09-29 Thread Mark Johnston
Author: markj
Date: Sun Sep 29 22:37:59 2019
New Revision: 352876
URL: https://svnweb.freebsd.org/changeset/base/352876

Log:
  MFC r351628, r351744:
  Update and clean up the UMA man page.

Modified:
  stable/12/share/man/man9/Makefile
  stable/12/share/man/man9/zone.9
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/share/man/man9/Makefile
==
--- stable/12/share/man/man9/Makefile   Sun Sep 29 22:34:01 2019
(r352875)
+++ stable/12/share/man/man9/Makefile   Sun Sep 29 22:37:59 2019
(r352876)
@@ -2273,15 +2273,27 @@ MLINKS+=zone.9 uma.9 \
zone.9 uma_zalloc.9 \
zone.9 uma_zalloc_arg.9 \
zone.9 uma_zalloc_domain.9 \
+   zone.9 uma_zalloc_pcpu.9 \
+   zone.9 uma_zalloc_pcpu_arg.9 \
+   zone.9 uma_zcache_create.9 \
zone.9 uma_zcreate.9 \
zone.9 uma_zdestroy.9 \
zone.9 uma_zfree.9 \
zone.9 uma_zfree_arg.9 \
zone.9 uma_zfree_domain.9 \
+   zone.9 uma_zfree_pcpu.9 \
+   zone.9 uma_zfree_pcpu_arg.9 \
zone.9 uma_zone_get_cur.9 \
zone.9 uma_zone_get_max.9 \
+   zone.9 uma_zone_prealloc.9 \
+   zone.9 uma_zone_reserve.9 \
+   zone.9 uma_zone_reserve_kva.9 \
+   zone.9 uma_zone_set_allocf.9 \
+   zone.9 uma_zone_set_freef.9 \
zone.9 uma_zone_set_max.9 \
+   zone.9 uma_zone_set_maxaction.9 \
+   zone.9 uma_zone_set_maxcache.9 \
zone.9 uma_zone_set_warning.9 \
-   zone.9 uma_zone_set_maxaction.9
+   zone.9 uma_zsecond_create.9
 
 .include 

Modified: stable/12/share/man/man9/zone.9
==
--- stable/12/share/man/man9/zone.9 Sun Sep 29 22:34:01 2019
(r352875)
+++ stable/12/share/man/man9/zone.9 Sun Sep 29 22:37:59 2019
(r352876)
@@ -25,40 +25,62 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 13, 2018
-.Dt ZONE 9
+.Dd August 30, 2019
+.Dt UMA 9
 .Os
 .Sh NAME
-.Nm uma_zcreate ,
-.Nm uma_zalloc ,
-.Nm uma_zalloc_arg ,
-.Nm uma_zalloc_domain ,
-.Nm uma_zfree ,
-.Nm uma_zfree_arg ,
-.Nm uma_zfree_domain ,
-.Nm uma_zdestroy ,
-.Nm uma_zone_set_max ,
-.Nm uma_zone_get_max ,
-.Nm uma_zone_get_cur ,
-.Nm uma_zone_set_warning ,
-.Nm uma_zone_set_maxaction
-.Nd zone allocator
+.Nm UMA
+.Nd general-purpose kernel object allocator
 .Sh SYNOPSIS
 .In sys/param.h
 .In sys/queue.h
 .In vm/uma.h
+.Cd "options UMA_FIRSTTOUCH"
+.Cd "options UMA_XDOMAIN"
+.Bd -literal
+typedef int (*uma_ctor)(void *mem, int size, void *arg, int flags);
+typedef void (*uma_dtor)(void *mem, int size, void *arg);
+typedef int (*uma_init)(void *mem, int size, int flags);
+typedef void (*uma_fini)(void *mem, int size);
+typedef int (*uma_import)(void *arg, void **store, int count, int domain,
+int flags);
+typedef void (*uma_release)(void *arg, void **store, int count);
+typedef void *(*uma_alloc)(uma_zone_t zone, vm_size_t size, int domain,
+uint8_t *pflag, int wait);
+typedef void (*uma_free)(void *item, vm_size_t size, uint8_t pflag);
+
+.Ed
 .Ft uma_zone_t
 .Fo uma_zcreate
 .Fa "char *name" "int size"
-.Fa "uma_ctor ctor" "uma_dtor dtor" "uma_init uminit" "uma_fini fini"
+.Fa "uma_ctor ctor" "uma_dtor dtor" "uma_init zinit" "uma_fini zfini"
 .Fa "int align" "uint16_t flags"
 .Fc
+.Ft uma_zone_t
+.Fo uma_zcache_create
+.Fa "char *name" "int size"
+.Fa "uma_ctor ctor" "uma_dtor dtor" "uma_init zinit" "uma_fini zfini"
+.Fa "uma_import zimport" "uma_release zrelease"
+.Fa "void *arg" "int flags"
+.Fc
+.Ft uma_zone_t
+.Fo uma_zsecond_create
+.Fa "char *name"
+.Fa "uma_ctor ctor" "uma_dtor dtor" "uma_init zinit" "uma_fini zfini"
+.Fa "uma_zone_t master"
+.Fc
+.Ft void
+.Fn uma_zdestroy "uma_zone_t zone"
 .Ft "void *"
 .Fn uma_zalloc "uma_zone_t zone" "int flags"
 .Ft "void *"
 .Fn uma_zalloc_arg "uma_zone_t zone" "void *arg" "int flags"
 .Ft "void *"
 .Fn uma_zalloc_domain "uma_zone_t zone" "void *arg" "int domain" "int flags"
+.Ft "void *"
+.Fn uma_zalloc_pcpu "uma_zone_t zone" "int flags"
+.Ft "void *"
+.Fn uma_zalloc_pcpu_arg "uma_zone_t zone" "void *arg" "int flags"
 .Ft void
 .Fn uma_zfree "uma_zone_t zone" "void *item"
 .Ft void
@@ -66,10 +88,24 @@
 .Ft void
 .Fn uma_zfree_domain "uma_zone_t zone" "void *item" "void *arg"
 .Ft void
-.Fn uma_zdestroy "uma_zone_t zone"
+.Fn uma_zfree_pcpu "uma_zone_t zone" "void *item"
+.Ft void
+.Fn uma_zfree_pcpu_arg "uma_zone_t zone" "void *item" "void *arg"
+.Ft void
+.Fn uma_prealloc "uma_zone_t zone" "int nitems"
+.Ft void
+.Fn uma_zone_reserve "uma_zone_t zone" "int nitems"
+.Ft void
+.Fn uma_zone_reserve_kva "uma_zone_t zone" "int nitems"
+.Ft void
+.Fn uma_zone_set_allocf "uma_zone_t zone" "uma_alloc allocf"
+.Ft void
+.Fn uma_zone_set_freef "uma_zone_t zone" "uma_free freef"
 .Ft int
 .Fn uma_zone_set_max "uma_zone_t zone" "int nitems"
 .Ft int
+.Fn uma_zone_set_maxcache "uma_zone_t zone" "int nitems"
+.Ft int
 .Fn uma_zone_get_max "uma_zone_t zone"
 .Ft int
 

Re: svn commit: r352875 - head/contrib/elftoolchain/elfcopy

2019-09-29 Thread Oleksandr Rybalko
Should be "Put sections into expected offset in binary format."
Sorry.

пн, 30 вер. 2019 о 01:34 Aleksandr Rybalko  пише:

> Author: ray
> Date: Sun Sep 29 22:34:01 2019
> New Revision: 352875
> URL: https://svnweb.freebsd.org/changeset/base/352875
>
> Log:
>   ections into expected offset in binary format.
>   Calculate binary file offset using address field, bacause software know
> only offset to known data, not where to load segment.
>   With that patch, kernel .data section can have any alignment/offset -
> kernel boor fine.
>
>   PR:   235391
>   Reviewed by:  markj
>   MFC after:1 month
>   Differential Revision:D21827
>
> Modified:
>   head/contrib/elftoolchain/elfcopy/binary.c
>
> Modified: head/contrib/elftoolchain/elfcopy/binary.c
>
> ==
> --- head/contrib/elftoolchain/elfcopy/binary.c  Sun Sep 29 20:44:13 2019
>   (r352874)
> +++ head/contrib/elftoolchain/elfcopy/binary.c  Sun Sep 29 22:34:01 2019
>   (r352875)
> @@ -49,22 +49,23 @@ create_binary(int ifd, int ofd)
> Elf *e;
> Elf_Scn *scn;
> Elf_Data *d;
> +   Elf64_Addr baseaddr;
> GElf_Shdr sh;
> -   off_t base, off;
> +   off_t baseoff, off;
> int elferr;
>
> if ((e = elf_begin(ifd, ELF_C_READ, NULL)) == NULL)
> errx(EXIT_FAILURE, "elf_begin() failed: %s",
> elf_errmsg(-1));
>
> -   base = 0;
> -   if (lseek(ofd, base, SEEK_SET) < 0)
> +   baseoff = 0;
> +   if (lseek(ofd, baseoff, SEEK_SET) < 0)
> err(EXIT_FAILURE, "lseek failed");
>
> /*
>  * Find base offset in the first iteration.
>  */
> -   base = -1;
> +   baseoff = -1;
> scn = NULL;
> while ((scn = elf_nextscn(e, scn)) != NULL) {
> if (gelf_getshdr(scn, &sh) == NULL) {
> @@ -76,14 +77,16 @@ create_binary(int ifd, int ofd)
> sh.sh_type == SHT_NOBITS ||
> sh.sh_size == 0)
> continue;
> -   if (base == -1 || (off_t) sh.sh_offset < base)
> -   base = sh.sh_offset;
> +   if (baseoff == -1 || (off_t) sh.sh_offset < baseoff) {
> +   baseoff = sh.sh_offset;
> +   baseaddr = sh.sh_addr;
> +   }
> }
> elferr = elf_errno();
> if (elferr != 0)
> warnx("elf_nextscn failed: %s", elf_errmsg(elferr));
>
> -   if (base == -1)
> +   if (baseoff == -1)
> return;
>
> /*
> @@ -110,8 +113,8 @@ create_binary(int ifd, int ofd)
> if (d->d_buf == NULL || d->d_size == 0)
> continue;
>
> -   /* lseek to section offset relative to `base'. */
> -   off = sh.sh_offset - base;
> +   /* lseek to section offset relative to `baseaddr'. */
> +   off = sh.sh_addr - baseaddr;
> if (lseek(ofd, off, SEEK_SET) < 0)
> err(EXIT_FAILURE, "lseek failed");
>
>

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


svn commit: r352875 - head/contrib/elftoolchain/elfcopy

2019-09-29 Thread Aleksandr Rybalko
Author: ray
Date: Sun Sep 29 22:34:01 2019
New Revision: 352875
URL: https://svnweb.freebsd.org/changeset/base/352875

Log:
  ections into expected offset in binary format.
  Calculate binary file offset using address field, bacause software know only 
offset to known data, not where to load segment.
  With that patch, kernel .data section can have any alignment/offset - kernel 
boor fine.
  
  PR:   235391
  Reviewed by:  markj
  MFC after:1 month
  Differential Revision:D21827

Modified:
  head/contrib/elftoolchain/elfcopy/binary.c

Modified: head/contrib/elftoolchain/elfcopy/binary.c
==
--- head/contrib/elftoolchain/elfcopy/binary.c  Sun Sep 29 20:44:13 2019
(r352874)
+++ head/contrib/elftoolchain/elfcopy/binary.c  Sun Sep 29 22:34:01 2019
(r352875)
@@ -49,22 +49,23 @@ create_binary(int ifd, int ofd)
Elf *e;
Elf_Scn *scn;
Elf_Data *d;
+   Elf64_Addr baseaddr;
GElf_Shdr sh;
-   off_t base, off;
+   off_t baseoff, off;
int elferr;
 
if ((e = elf_begin(ifd, ELF_C_READ, NULL)) == NULL)
errx(EXIT_FAILURE, "elf_begin() failed: %s",
elf_errmsg(-1));
 
-   base = 0;
-   if (lseek(ofd, base, SEEK_SET) < 0)
+   baseoff = 0;
+   if (lseek(ofd, baseoff, SEEK_SET) < 0)
err(EXIT_FAILURE, "lseek failed");
 
/*
 * Find base offset in the first iteration.
 */
-   base = -1;
+   baseoff = -1;
scn = NULL;
while ((scn = elf_nextscn(e, scn)) != NULL) {
if (gelf_getshdr(scn, &sh) == NULL) {
@@ -76,14 +77,16 @@ create_binary(int ifd, int ofd)
sh.sh_type == SHT_NOBITS ||
sh.sh_size == 0)
continue;
-   if (base == -1 || (off_t) sh.sh_offset < base)
-   base = sh.sh_offset;
+   if (baseoff == -1 || (off_t) sh.sh_offset < baseoff) {
+   baseoff = sh.sh_offset;
+   baseaddr = sh.sh_addr;
+   }
}
elferr = elf_errno();
if (elferr != 0)
warnx("elf_nextscn failed: %s", elf_errmsg(elferr));
 
-   if (base == -1)
+   if (baseoff == -1)
return;
 
/*
@@ -110,8 +113,8 @@ create_binary(int ifd, int ofd)
if (d->d_buf == NULL || d->d_size == 0)
continue;
 
-   /* lseek to section offset relative to `base'. */
-   off = sh.sh_offset - base;
+   /* lseek to section offset relative to `baseaddr'. */
+   off = sh.sh_addr - baseaddr;
if (lseek(ofd, off, SEEK_SET) < 0)
err(EXIT_FAILURE, "lseek failed");
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2019-09-29 Thread Mateusz Guzik
Author: mjg
Date: Sun Sep 29 20:44:13 2019
New Revision: 352874
URL: https://svnweb.freebsd.org/changeset/base/352874

Log:
  amd64 pmap: batch chunk removal in pmap_remove_pages
  
  pv list lock is the main bottleneck during poudriere -j 104 and
  pmap_remove_pages is the most impactful consumer. It frees chunks with the 
lock
  held even though it plays no role in correctness. Moreover chunks are often
  freed in groups, sample counts during buildkernel (0-sized frees removed):
  
  value  - Distribution - count
0 | 0
1 | 8
2 |@@@  19329
4 |@@   58517
8 | 1085
   16 | 71
   32 |@@   24919
   64 | 899
  128 | 7
  256 | 2
  512 | 0
  
  Thus:
  1. batch freeing
  2. move it past unlocking pv list
  
  Reviewed by:  alc (previous version), markj (previous version), kib
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D21832

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

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Sun Sep 29 20:08:14 2019(r352873)
+++ head/sys/amd64/amd64/pmap.c Sun Sep 29 20:44:13 2019(r352874)
@@ -1105,7 +1105,10 @@ static caddr_t crashdumpmap;
 #defineMAPDEV_FLUSHCACHE   0x001   /* Flush cache after 
mapping. */
 #defineMAPDEV_SETATTR  0x002   /* Modify existing 
attrs. */
 
+TAILQ_HEAD(pv_chunklist, pv_chunk);
+
 static voidfree_pv_chunk(struct pv_chunk *pc);
+static voidfree_pv_chunk_batch(struct pv_chunklist *batch);
 static voidfree_pv_entry(pmap_t pmap, pv_entry_t pv);
 static pv_entry_t get_pv_entry(pmap_t pmap, struct rwlock **lockp);
 static int popcnt_pc_map_pq(uint64_t *map);
@@ -4248,13 +4251,10 @@ free_pv_entry(pmap_t pmap, pv_entry_t pv)
 }
 
 static void
-free_pv_chunk(struct pv_chunk *pc)
+free_pv_chunk_dequeued(struct pv_chunk *pc)
 {
vm_page_t m;
 
-   mtx_lock(&pv_chunks_mutex);
-   TAILQ_REMOVE(&pv_chunks, pc, pc_lru);
-   mtx_unlock(&pv_chunks_mutex);
PV_STAT(atomic_subtract_int(&pv_entry_spare, _NPCPV));
PV_STAT(atomic_subtract_int(&pc_chunk_count, 1));
PV_STAT(atomic_add_int(&pc_chunk_frees, 1));
@@ -4265,6 +4265,35 @@ free_pv_chunk(struct pv_chunk *pc)
vm_page_free(m);
 }
 
+static void
+free_pv_chunk(struct pv_chunk *pc)
+{
+
+   mtx_lock(&pv_chunks_mutex);
+   TAILQ_REMOVE(&pv_chunks, pc, pc_lru);
+   mtx_unlock(&pv_chunks_mutex);
+   free_pv_chunk_dequeued(pc);
+}
+
+static void
+free_pv_chunk_batch(struct pv_chunklist *batch)
+{
+   struct pv_chunk *pc, *npc;
+
+   if (TAILQ_EMPTY(batch))
+   return;
+
+   mtx_lock(&pv_chunks_mutex);
+   TAILQ_FOREACH(pc, batch, pc_list) {
+   TAILQ_REMOVE(&pv_chunks, pc, pc_lru);
+   }
+   mtx_unlock(&pv_chunks_mutex);
+
+   TAILQ_FOREACH_SAFE(pc, batch, pc_list, npc) {
+   free_pv_chunk_dequeued(pc);
+   }
+}
+
 /*
  * Returns a new PV entry, allocating a new PV chunk from the system when
  * needed.  If this PV chunk allocation fails and a PV list lock pointer was
@@ -6865,6 +6894,7 @@ pmap_remove_pages(pmap_t pmap)
pt_entry_t *pte, tpte;
pt_entry_t PG_M, PG_RW, PG_V;
struct spglist free;
+   struct pv_chunklist free_chunks;
vm_page_t m, mpte, mt;
pv_entry_t pv;
struct md_page *pvh;
@@ -6900,6 +6930,7 @@ pmap_remove_pages(pmap_t pmap)
PG_V = pmap_valid_bit(pmap);
PG_RW = pmap_rw_bit(pmap);
 
+   TAILQ_INIT(&free_chunks);
SLIST_INIT(&free);
PMAP_LOCK(pmap);
TAILQ_FOREACH_SAFE(pc, &pmap->pm_pvchunk, pc_list, npc) {
@@ -7027,13 +7058,14 @@ pmap_remove_pages(pmap_t pmap)
PV_STAT(atomic_subtract_long(&pv_entry_count, freed));
if (allfree) {
TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list);
-   free_pv_chunk(pc);
+   TAILQ_INSERT_TAIL(&free_chunks, pc, pc_list);
}
}
if (lock != NULL)
rw_wunlock(lock);
pmap_invalidate_all(pmap);
pmap_pkru_deassign_all(pmap);
+   free_pv_chunk_batch(&free_chunks);
PMAP_UNLOCK(pmap);
vm_page_free_pages_toq(&free, true);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freeb

svn commit: r352873 - stable/11/sbin/fsck_msdosfs

2019-09-29 Thread Xin LI
Author: delphij
Date: Sun Sep 29 20:08:14 2019
New Revision: 352873
URL: https://svnweb.freebsd.org/changeset/base/352873

Log:
  MFC r351802:
  
  Correct overflow logic in fullpath().
  
  Obtained from:OpenBSD

Modified:
  stable/11/sbin/fsck_msdosfs/dir.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/fsck_msdosfs/dir.c
==
--- stable/11/sbin/fsck_msdosfs/dir.c   Sun Sep 29 20:05:48 2019
(r352872)
+++ stable/11/sbin/fsck_msdosfs/dir.c   Sun Sep 29 20:08:14 2019
(r352873)
@@ -168,20 +168,24 @@ fullpath(struct dosDirEntry *dir)
char *cp, *np;
int nl;
 
-   cp = namebuf + sizeof namebuf - 1;
-   *cp = '\0';
-   do {
+   cp = namebuf + sizeof namebuf;
+   *--cp = '\0';
+
+   for(;;) {
np = dir->lname[0] ? dir->lname : dir->name;
nl = strlen(np);
-   if ((cp -= nl) <= namebuf + 1)
+   if (cp <= namebuf + 1 + nl) {
+   *--cp = '?';
break;
+   }
+   cp -= nl;
memcpy(cp, np, nl);
+   dir = dir->parent;
+   if (!dir)
+   break;
*--cp = '/';
-   } while ((dir = dir->parent) != NULL);
-   if (dir)
-   *--cp = '?';
-   else
-   cp++;
+   }
+
return cp;
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352872 - stable/12/sbin/fsck_msdosfs

2019-09-29 Thread Xin LI
Author: delphij
Date: Sun Sep 29 20:05:48 2019
New Revision: 352872
URL: https://svnweb.freebsd.org/changeset/base/352872

Log:
  MFC r351802:
  
  Correct overflow logic in fullpath().
  
  Obtained from:OpenBSD

Modified:
  stable/12/sbin/fsck_msdosfs/dir.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/fsck_msdosfs/dir.c
==
--- stable/12/sbin/fsck_msdosfs/dir.c   Sun Sep 29 18:33:29 2019
(r352871)
+++ stable/12/sbin/fsck_msdosfs/dir.c   Sun Sep 29 20:05:48 2019
(r352872)
@@ -168,20 +168,24 @@ fullpath(struct dosDirEntry *dir)
char *cp, *np;
int nl;
 
-   cp = namebuf + sizeof namebuf - 1;
-   *cp = '\0';
-   do {
+   cp = namebuf + sizeof namebuf;
+   *--cp = '\0';
+
+   for(;;) {
np = dir->lname[0] ? dir->lname : dir->name;
nl = strlen(np);
-   if ((cp -= nl) <= namebuf + 1)
+   if (cp <= namebuf + 1 + nl) {
+   *--cp = '?';
break;
+   }
+   cp -= nl;
memcpy(cp, np, nl);
+   dir = dir->parent;
+   if (!dir)
+   break;
*--cp = '/';
-   } while ((dir = dir->parent) != NULL);
-   if (dir)
-   *--cp = '?';
-   else
-   cp++;
+   }
+
return cp;
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352871 - releng/12.1/sys/arm/freescale/imx

2019-09-29 Thread Ian Lepore
Author: ian
Date: Sun Sep 29 18:33:29 2019
New Revision: 352871
URL: https://svnweb.freebsd.org/changeset/base/352871

Log:
  MFC r352363:
  
  Apply a runtime patch to the FDT data for imx6 to fix iomuxc problems.
  
  The latest imported FDT data defines a node for an iomuxc-gpr device,
  which we don't support (or need, right now) in addition to the usual
  iomuxc device.  Unfortunately, the dts improperly assigns overlapping
  ranges of mmio space to both devices.  The -gpr device is also a syscon
  and simple_mfd device.
  
  At runtime the simple_mfd driver attaches for the iomuxc-gpr node, then
  when the real iomuxc driver comes along later, it fails to attach because
  it tries to allocate its register space, and it's already partially in
  use by the bogus instance of simple_mfd.
  
  This change works around the problem by simply disabling the node for
  the iomuxc-gpr device, since we don't need it for anything.
  
  Approved by:  re@ (gjb)

Modified:
  releng/12.1/sys/arm/freescale/imx/imx6_machdep.c
Directory Properties:
  releng/12.1/   (props changed)

Modified: releng/12.1/sys/arm/freescale/imx/imx6_machdep.c
==
--- releng/12.1/sys/arm/freescale/imx/imx6_machdep.cSun Sep 29 17:30:10 
2019(r352870)
+++ releng/12.1/sys/arm/freescale/imx/imx6_machdep.cSun Sep 29 18:33:29 
2019(r352871)
@@ -148,12 +148,43 @@ fix_fdt_interrupt_data(void)
OF_setprop(socnode, "interrupt-parent", &gicxref, sizeof(gicxref));
 }
 
+static void
+fix_fdt_iomuxc_data(void)
+{
+   phandle_t node;
+
+   /*
+* The linux dts defines two nodes with the same mmio address range,
+* iomuxc-gpr and the regular iomuxc.  The -grp node is a simple_mfd and
+* a syscon, but it only has access to a small subset of the iomuxc
+* registers, so it can't serve as the accessor for the iomuxc driver's
+* register IO.  But right now, the simple_mfd driver attaches first,
+* preventing the real iomuxc driver from allocating its mmio register
+* range because it partially overlaps with the -gpr range.
+*
+* For now, by far the easiest thing to do to keep imx6 working is to
+* just disable the iomuxc-gpr node because we don't have a driver for
+* it anyway, we just need to prevent attachment of simple_mfd.
+*
+* If we ever write a -gpr driver, this code should probably switch to
+* modifying the reg property so that the range covers all the iomuxc
+* regs, then the -gpr driver can be a regular syscon driver that iomuxc
+* uses for register access.
+*/
+   node = OF_finddevice("/soc/aips-bus@200/iomuxc-gpr@20e");
+   if (node != -1)
+   OF_setprop(node, "status", "disabled", sizeof("disabled"));
+}
+
 static int
 imx6_attach(platform_t plat)
 {
 
/* Fix soc interrupt-parent property. */
fix_fdt_interrupt_data();
+
+   /* Fix iomuxc-gpr and iomuxc nodes both using the same mmio range. */
+   fix_fdt_iomuxc_data();
 
/* Inform the MPCore timer driver that its clock is variable. */
arm_tmr_change_frequency(ARM_TMR_FREQUENCY_VARIES);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352870 - head/lib/libc/sys

2019-09-29 Thread Kyle Evans
Author: kevans
Date: Sun Sep 29 17:30:10 2019
New Revision: 352870
URL: https://svnweb.freebsd.org/changeset/base/352870

Log:
  memfd_create(3): Don't actually force hugetlb size with MFD_HUGETLB
  
  The size flags are only required to select a size on systems that support
  multiple sizes. MFD_HUGETLB by itself is valid.

Modified:
  head/lib/libc/sys/shm_open.c

Modified: head/lib/libc/sys/shm_open.c
==
--- head/lib/libc/sys/shm_open.cSun Sep 29 15:17:58 2019
(r352869)
+++ head/lib/libc/sys/shm_open.cSun Sep 29 17:30:10 2019
(r352870)
@@ -88,9 +88,6 @@ memfd_create(const char *name, unsigned int flags)
if ((flags & ~(MFD_CLOEXEC | MFD_ALLOW_SEALING | MFD_HUGETLB |
MFD_HUGE_MASK)) != 0)
return (EINVAL);
-   /* HUGETLB set with no size specified. */
-   if ((flags & MFD_HUGETLB) != 0 && (flags & MFD_HUGE_MASK) == 0)
-   return (EINVAL);
/* Size specified but no HUGETLB. */
if ((flags & MFD_HUGE_MASK) != 0 && (flags & MFD_HUGETLB) == 0)
return (EINVAL);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352869 - in head: contrib/netbsd-tests/lib/libc/sys tests/sys/posixshm tests/sys/vm

2019-09-29 Thread Jilles Tjoelker
Author: jilles
Date: Sun Sep 29 15:17:58 2019
New Revision: 352869
URL: https://svnweb.freebsd.org/changeset/base/352869

Log:
  Adjust tests after page fault changes in r352807
  
  Commit r352807 fixed various signal numbers and codes from page faults;
  adjust the tests so they expect the fixes to be present.
  
  PR:   211924

Modified:
  head/contrib/netbsd-tests/lib/libc/sys/t_mmap.c
  head/tests/sys/posixshm/posixshm_test.c
  head/tests/sys/vm/page_fault_signal.c

Modified: head/contrib/netbsd-tests/lib/libc/sys/t_mmap.c
==
--- head/contrib/netbsd-tests/lib/libc/sys/t_mmap.c Sun Sep 29 10:45:13 
2019(r352868)
+++ head/contrib/netbsd-tests/lib/libc/sys/t_mmap.c Sun Sep 29 15:17:58 
2019(r352869)
@@ -480,10 +480,6 @@ ATF_TC_BODY(mmap_truncate_signal, tc)
int fd, sta;
pid_t pid;
 
-#ifdef __FreeBSD__
-   atf_tc_expect_fail("testcase fails with SIGSEGV on FreeBSD; bug # 
211924");
-#endif
-
fd = open(path, O_RDWR | O_CREAT, 0700);
 
if (fd < 0)

Modified: head/tests/sys/posixshm/posixshm_test.c
==
--- head/tests/sys/posixshm/posixshm_test.c Sun Sep 29 10:45:13 2019
(r352868)
+++ head/tests/sys/posixshm/posixshm_test.c Sun Sep 29 15:17:58 2019
(r352869)
@@ -697,7 +697,7 @@ ATF_TC_BODY(object_resize, tc)
/*
 * The previous ftruncate(2) shrunk the backing object
 * so that this address is no longer valid, so reading
-* from it should trigger a SIGSEGV.
+* from it should trigger a SIGBUS.
 */
c = page[pagesize];
fprintf(stderr, "child: page 1: '%c'\n", c);
@@ -707,7 +707,7 @@ ATF_TC_BODY(object_resize, tc)
if (wait(&status) < 0)
atf_tc_fail("wait failed; errno=%d", errno);
 
-   if (!WIFSIGNALED(status) || WTERMSIG(status) != SIGSEGV)
+   if (!WIFSIGNALED(status) || WTERMSIG(status) != SIGBUS)
atf_tc_fail("child terminated with status %x", status);
 
/* Grow the object back to 2 pages. */

Modified: head/tests/sys/vm/page_fault_signal.c
==
--- head/tests/sys/vm/page_fault_signal.c   Sun Sep 29 10:45:13 2019
(r352868)
+++ head/tests/sys/vm/page_fault_signal.c   Sun Sep 29 15:17:58 2019
(r352869)
@@ -129,7 +129,6 @@ ATF_TC_BODY(page_fault_signal__bus_objerr_1, tc)
int fd;
int sz;
 
-   atf_tc_expect_fail("bug 211924");
sz = getpagesize();
fd = shm_open(SHM_ANON, O_RDWR | O_CREAT, 0600);
ATF_REQUIRE(fd != -1);
@@ -153,7 +152,6 @@ ATF_TC_BODY(page_fault_signal__bus_objerr_2, tc)
int r;
int sz;
 
-   atf_tc_expect_fail("bug 211924");
sz = getpagesize();
fd = shm_open(SHM_ANON, O_RDWR | O_CREAT, 0600);
ATF_REQUIRE(fd != -1);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r352846 - head/lib/libc/sys

2019-09-29 Thread Bruce Evans

On Sun, 29 Sep 2019, Konstantin Belousov wrote:


On Sat, Sep 28, 2019 at 05:15:48PM +, Warner Losh wrote:

Author: imp
Date: Sat Sep 28 17:15:48 2019
New Revision: 352846
URL: https://svnweb.freebsd.org/changeset/base/352846

Log:
  Revert the mode_t -> int changes and add a warning in the BUGS section 
instead.

  While FreeBSD's implementation of these expect an int inside of libc, that's 
an
  implementation detail that we can hide from the user as it's the natural
  promotion of the current mode_t type and before it is used in the kernel, it's
  converted back to the narrower type that's the current definition of mode_t. 
As
  such, documenting int is at best confusing and at worst misleading. Instead 
add
  a note that these args are variadic and as such calling conventions may differ
  from non-variadic arguments.

Modified:
  head/lib/libc/sys/mq_open.2
  head/lib/libc/sys/open.2

Modified: head/lib/libc/sys/mq_open.2
==
--- head/lib/libc/sys/mq_open.2 Sat Sep 28 14:20:28 2019(r352845)
+++ head/lib/libc/sys/mq_open.2 Sat Sep 28 17:15:48 2019(r352846)
@@ -37,7 +37,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 15, 2014
+.Dd September 28, 2019
 .Dt MQ_OPEN 2
 .Os
 .Sh NAME
@@ -133,7 +133,7 @@ Create a message queue.
 It requires two additional arguments:
 .Fa mode ,
 which is of type
-.Vt int ,
+.Vt mode_t ,
 and
 .Fa attr ,
 which is a pointer to an
@@ -317,6 +317,13 @@ This implementation places strict requirements on the
 it must begin with a slash
 .Pq Ql /
 and contain no other slash characters.
+.Pp
+The
+.Fa mode
+and
+.Fa attr
+arguments are variadic and may result in different calling conventions
+than might otherwise be expected.
 .Sh COPYRIGHT
 Portions of this text are reprinted and reproduced in electronic form
 from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --

Modified: head/lib/libc/sys/open.2
==
--- head/lib/libc/sys/open.2Sat Sep 28 14:20:28 2019(r352845)
+++ head/lib/libc/sys/open.2Sat Sep 28 17:15:48 2019(r352846)
@@ -28,7 +28,7 @@
 .\" @(#)open.28.2 (Berkeley) 11/16/93
 .\" $FreeBSD$
 .\"
-.Dd September 17, 2019
+.Dd September 28, 2019
 .Dt OPEN 2
 .Os
 .Sh NAME
@@ -61,7 +61,7 @@ In this case
 and
 .Fn openat
 require an additional argument
-.Fa "int mode" ,
+.Fa "mode_t mode" ,
 and the file is created with mode
 .Fa mode
 as described in
@@ -615,3 +615,8 @@ permits searches.
 The present implementation of the
 .Fa openat
 checks the current permissions of directory instead.
+.Pp
+The
+.Fa mode
+argument is variadic and may result in different calling conventions
+than might otherwise be expected.

This note is also very confusing.

Assume that somebody knows calling conventions and then see this note.
Now she would be equally misdirected because it is completely not clear
what different conventions are mentioned there, esp. because there are no.

Also, as I noted before, this note in whatever form does not belongs to
BUSS section.


I was going to say "Indeed.  The man page already gives the type mode_t
for the mode, so the fix should be to remind the reader that since open()
is variadic, the caller MUST supply an arg whose type is the default
promotion of mode_t [and this is most easily done by starting with or
casting to an arg whose type is precisely mode_t].

POSIX gets this wronger.  It says "the file mode shall be set to the
value of the argument following the oflag argument taken as type
mode_t".  It never defines the actual type of this arg.  Since open()
is variadic, the actual type is the default promotion of whatever the
caller passes.  Nothing forbids the caller passing a long long or even
a long double, or even any type with any encoding.  Literally, this
requires the implementation to "take" the arg as a mode_t using an
unspecified conversion method after using magic beyond va_arg() to
determine the type and value of the arg.  POSIX give an example where
the arg type is precisely mode_t, but this is just an example of one
arg type that works.  All this was in the 2001 version of POSIX and
remains unfixed in the 2018 version.

So the man page was wrong after all.  It was not bug for bug compatible
with POSIX, since it says that the additional argument is "mode_t mode"
but POSIX allows any type that can be "taken" as a mode_t.

This shouldn't change the fix.  The BUGS section is not the place to
document bugs in POSIX.

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


svn commit: r352868 - in head/sys/netinet: . tcp_stacks

2019-09-29 Thread Michael Tuexen
Author: tuexen
Date: Sun Sep 29 10:45:13 2019
New Revision: 352868
URL: https://svnweb.freebsd.org/changeset/base/352868

Log:
  RFC 7112 requires a host to put the complete IP header chain
  including the TCP header in the first IP packet.
  Enforce this in tcp_output(). In addition make sure that at least
  one byte payload fits in the TCP segement to allow making progress.
  Without this check, a kernel with INVARIANTS will panic.
  This issue was found by running an instance of syzkaller.
  
  Reviewed by:  jtl@
  MFC after:3 days
  Sponsored by: Netflix, Inc.
  Differential Revision:https://reviews.freebsd.org/D21665

Modified:
  head/sys/netinet/tcp_output.c
  head/sys/netinet/tcp_stacks/bbr.c
  head/sys/netinet/tcp_stacks/rack.c

Modified: head/sys/netinet/tcp_output.c
==
--- head/sys/netinet/tcp_output.c   Sun Sep 29 06:12:51 2019
(r352867)
+++ head/sys/netinet/tcp_output.c   Sun Sep 29 10:45:13 2019
(r352868)
@@ -941,6 +941,20 @@ send:
if (tp->t_flags & TF_NEEDFIN)
sendalot = 1;
} else {
+   if (optlen + ipoptlen >= tp->t_maxseg) {
+   /*
+* Since we don't have enough space to put
+* the IP header chain and the TCP header in
+* one packet as required by RFC 7112, don't
+* send it. Also ensure that at least one
+* byte of the payload can be put into the
+* TCP segment.
+*/
+   SOCKBUF_UNLOCK(&so->so_snd);
+   error = EMSGSIZE;
+   sack_rxmit = 0;
+   goto out;
+   }
len = tp->t_maxseg - optlen - ipoptlen;
sendalot = 1;
if (dont_sendalot)

Modified: head/sys/netinet/tcp_stacks/bbr.c
==
--- head/sys/netinet/tcp_stacks/bbr.c   Sun Sep 29 06:12:51 2019
(r352867)
+++ head/sys/netinet/tcp_stacks/bbr.c   Sun Sep 29 10:45:13 2019
(r352868)
@@ -13343,12 +13343,14 @@ send:
}
} else {
/* Not doing TSO */
-   if (optlen + ipoptlen > tp->t_maxseg) {
+   if (optlen + ipoptlen >= tp->t_maxseg) {
/*
 * Since we don't have enough space to put
 * the IP header chain and the TCP header in
 * one packet as required by RFC 7112, don't
-* send it.
+* send it. Also ensure that at least one
+* byte of the payload can be put into the
+* TCP segment.
 */
SOCKBUF_UNLOCK(&so->so_snd);
error = EMSGSIZE;

Modified: head/sys/netinet/tcp_stacks/rack.c
==
--- head/sys/netinet/tcp_stacks/rack.c  Sun Sep 29 06:12:51 2019
(r352867)
+++ head/sys/netinet/tcp_stacks/rack.c  Sun Sep 29 10:45:13 2019
(r352868)
@@ -9200,12 +9200,14 @@ send:
sendalot = 1;
 
} else {
-   if (optlen + ipoptlen > tp->t_maxseg) {
+   if (optlen + ipoptlen >= tp->t_maxseg) {
/*
 * Since we don't have enough space to put
 * the IP header chain and the TCP header in
 * one packet as required by RFC 7112, don't
-* send it.
+* send it. Also ensure that at least one
+* byte of the payload can be put into the
+* TCP segment.
 */
SOCKBUF_UNLOCK(&so->so_snd);
error = EMSGSIZE;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r352846 - head/lib/libc/sys

2019-09-29 Thread Konstantin Belousov
On Sat, Sep 28, 2019 at 05:15:48PM +, Warner Losh wrote:
> Author: imp
> Date: Sat Sep 28 17:15:48 2019
> New Revision: 352846
> URL: https://svnweb.freebsd.org/changeset/base/352846
> 
> Log:
>   Revert the mode_t -> int changes and add a warning in the BUGS section 
> instead.
>   
>   While FreeBSD's implementation of these expect an int inside of libc, 
> that's an
>   implementation detail that we can hide from the user as it's the natural
>   promotion of the current mode_t type and before it is used in the kernel, 
> it's
>   converted back to the narrower type that's the current definition of 
> mode_t. As
>   such, documenting int is at best confusing and at worst misleading. Instead 
> add
>   a note that these args are variadic and as such calling conventions may 
> differ
>   from non-variadic arguments.
> 
> Modified:
>   head/lib/libc/sys/mq_open.2
>   head/lib/libc/sys/open.2
> 
> Modified: head/lib/libc/sys/mq_open.2
> ==
> --- head/lib/libc/sys/mq_open.2   Sat Sep 28 14:20:28 2019
> (r352845)
> +++ head/lib/libc/sys/mq_open.2   Sat Sep 28 17:15:48 2019
> (r352846)
> @@ -37,7 +37,7 @@
>  .\"
>  .\" $FreeBSD$
>  .\"
> -.Dd September 15, 2014
> +.Dd September 28, 2019
>  .Dt MQ_OPEN 2
>  .Os
>  .Sh NAME
> @@ -133,7 +133,7 @@ Create a message queue.
>  It requires two additional arguments:
>  .Fa mode ,
>  which is of type
> -.Vt int ,
> +.Vt mode_t ,
>  and
>  .Fa attr ,
>  which is a pointer to an
> @@ -317,6 +317,13 @@ This implementation places strict requirements on the 
>  it must begin with a slash
>  .Pq Ql /
>  and contain no other slash characters.
> +.Pp
> +The
> +.Fa mode
> +and
> +.Fa attr
> +arguments are variadic and may result in different calling conventions
> +than might otherwise be expected.
>  .Sh COPYRIGHT
>  Portions of this text are reprinted and reproduced in electronic form
>  from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
> 
> Modified: head/lib/libc/sys/open.2
> ==
> --- head/lib/libc/sys/open.2  Sat Sep 28 14:20:28 2019(r352845)
> +++ head/lib/libc/sys/open.2  Sat Sep 28 17:15:48 2019(r352846)
> @@ -28,7 +28,7 @@
>  .\" @(#)open.2   8.2 (Berkeley) 11/16/93
>  .\" $FreeBSD$
>  .\"
> -.Dd September 17, 2019
> +.Dd September 28, 2019
>  .Dt OPEN 2
>  .Os
>  .Sh NAME
> @@ -61,7 +61,7 @@ In this case
>  and
>  .Fn openat
>  require an additional argument
> -.Fa "int mode" ,
> +.Fa "mode_t mode" ,
>  and the file is created with mode
>  .Fa mode
>  as described in
> @@ -615,3 +615,8 @@ permits searches.
>  The present implementation of the
>  .Fa openat
>  checks the current permissions of directory instead.
> +.Pp
> +The
> +.Fa mode
> +argument is variadic and may result in different calling conventions
> +than might otherwise be expected.
This note is also very confusing.

Assume that somebody knows calling conventions and then see this note.
Now she would be equally misdirected because it is completely not clear
what different conventions are mentioned there, esp. because there are no.

Also, as I noted before, this note in whatever form does not belongs to
BUSS section.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"