svn commit: r350463 - in head/sys: amd64/amd64 arm64/arm64 i386/i386

2019-07-30 Thread Alan Cox
Author: alc
Date: Wed Jul 31 05:38:39 2019
New Revision: 350463
URL: https://svnweb.freebsd.org/changeset/base/350463

Log:
  In pmap_advise(), when we encounter a superpage mapping, we first demote the
  mapping and then destroy one of the 4 KB page mappings so that there is a
  potential trigger for repromotion.  Currently, we destroy the first 4 KB
  page mapping that falls within the (current) superpage mapping or the
  virtual address range [sva, eva).  However, I have found empirically that
  destroying the last 4 KB mapping produces slightly better results,
  specifically, more promotions and fewer failed promotion attempts.
  Accordingly, this revision changes pmap_advise() to destroy the last 4 KB
  page mapping.  It also replaces some nearby uses of boolean_t with bool.
  
  Reviewed by:  kib, markj
  Differential Revision:https://reviews.freebsd.org/D21115

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

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Wed Jul 31 04:19:53 2019(r350462)
+++ head/sys/amd64/amd64/pmap.c Wed Jul 31 05:38:39 2019(r350463)
@@ -7444,7 +7444,7 @@ pmap_advise(pmap_t pmap, vm_offset_t sva, vm_offset_t 
pt_entry_t *pte, PG_A, PG_G, PG_M, PG_RW, PG_V;
vm_offset_t va, va_next;
vm_page_t m;
-   boolean_t anychanged;
+   bool anychanged;
 
if (advice != MADV_DONTNEED && advice != MADV_FREE)
return;
@@ -7463,7 +7463,7 @@ pmap_advise(pmap_t pmap, vm_offset_t sva, vm_offset_t 
PG_M = pmap_modified_bit(pmap);
PG_V = pmap_valid_bit(pmap);
PG_RW = pmap_rw_bit(pmap);
-   anychanged = FALSE;
+   anychanged = false;
pmap_delayed_invl_start();
PMAP_LOCK(pmap);
for (; sva < eva; sva = va_next) {
@@ -7505,17 +7505,25 @@ pmap_advise(pmap_t pmap, vm_offset_t sva, vm_offset_t 
/*
 * Unless the page mappings are wired, remove the
 * mapping to a single page so that a subsequent
-* access may repromote.  Since the underlying page
-* table page is fully populated, this removal never
-* frees a page table page.
+* access may repromote.  Choosing the last page
+* within the address range [sva, min(va_next, eva))
+* generally results in more repromotions.  Since the
+* underlying page table page is fully populated, this
+* removal never frees a page table page.
 */
if ((oldpde & PG_W) == 0) {
-   pte = pmap_pde_to_pte(pde, sva);
+   va = eva;
+   if (va > va_next)
+   va = va_next;
+   va -= PAGE_SIZE;
+   KASSERT(va >= sva,
+   ("pmap_advise: no address gap"));
+   pte = pmap_pde_to_pte(pde, va);
KASSERT((*pte & PG_V) != 0,
("pmap_advise: invalid PTE"));
-   pmap_remove_pte(pmap, pte, sva, *pde, NULL,
+   pmap_remove_pte(pmap, pte, va, *pde, NULL,
);
-   anychanged = TRUE;
+   anychanged = true;
}
if (lock != NULL)
rw_wunlock(lock);
@@ -7547,7 +7555,7 @@ pmap_advise(pmap_t pmap, vm_offset_t sva, vm_offset_t 
if (va == va_next)
va = sva;
} else
-   anychanged = TRUE;
+   anychanged = true;
continue;
 maybe_invlrng:
if (va != va_next) {

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Wed Jul 31 04:19:53 2019(r350462)
+++ head/sys/arm64/arm64/pmap.c Wed Jul 31 05:38:39 2019(r350463)
@@ -4888,15 +4888,23 @@ pmap_advise(pmap_t pmap, vm_offset_t sva, vm_offset_t 
/*
 * Unless the page mappings are wired, remove the
 * mapping to a single page so that a subsequent
-* access may repromote.  Since the underlying page
-* table page is fully populated, this removal never
-* frees a page table page.
+* access may 

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

2019-07-30 Thread Konstantin Belousov
On Tue, Jul 30, 2019 at 08:40:28PM -0700, Bryan Drewery wrote:
> This 2nd change alone (&& count1 == 0) was sufficient to fix the endless
> loop problem.
Good, thank you.

> 
> I am not sure how to test the umtxq_check_susp() change. Do I just need
> to ptrace the process?

No, you should create a situation where the python process ends the endless
loop, as reported.  Then, it should become killable by 9 with the first
chunk only applied.
___
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: r350462 - head/sbin/nvmecontrol

2019-07-30 Thread Alexander Motin
Author: mav
Date: Wed Jul 31 04:19:53 2019
New Revision: 350462
URL: https://svnweb.freebsd.org/changeset/base/350462

Log:
  Tune some commands desctiption.
  
  MFC after:2 weeks

Modified:
  head/sbin/nvmecontrol/devlist.c
  head/sbin/nvmecontrol/firmware.c
  head/sbin/nvmecontrol/format.c
  head/sbin/nvmecontrol/perftest.c
  head/sbin/nvmecontrol/reset.c

Modified: head/sbin/nvmecontrol/devlist.c
==
--- head/sbin/nvmecontrol/devlist.c Wed Jul 31 03:48:48 2019
(r350461)
+++ head/sbin/nvmecontrol/devlist.c Wed Jul 31 04:19:53 2019
(r350462)
@@ -53,7 +53,7 @@ static cmd_fn_t devlist;
 static struct cmd devlist_cmd = {
.name = "devlist",
.fn = devlist,
-   .descr = "Display a list of NVMe controllers and namespaces."
+   .descr = "List NVMe controllers and namespaces"
 };
 
 CMD_COMMAND(devlist_cmd);

Modified: head/sbin/nvmecontrol/firmware.c
==
--- head/sbin/nvmecontrol/firmware.cWed Jul 31 03:48:48 2019
(r350461)
+++ head/sbin/nvmecontrol/firmware.cWed Jul 31 04:19:53 2019
(r350462)
@@ -87,7 +87,7 @@ static const struct args firmware_args[] = {
 static struct cmd firmware_cmd = {
.name = "firmware",
.fn = firmware,
-   .descr = "Download firmware image to controller.",
+   .descr = "Download firmware image to controller",
.ctx_size = sizeof(opt),
.opts = firmware_opts,
.args = firmware_args,

Modified: head/sbin/nvmecontrol/format.c
==
--- head/sbin/nvmecontrol/format.c  Wed Jul 31 03:48:48 2019
(r350461)
+++ head/sbin/nvmecontrol/format.c  Wed Jul 31 04:19:53 2019
(r350462)
@@ -76,19 +76,19 @@ static struct options {
 static const struct opts format_opts[] = {
 #define OPT(l, s, t, opt, addr, desc) { l, s, t, , desc }
OPT("crypto", 'C', arg_none, opt, Cflag,
-   "Crptographically erase user data by forgetting key"),
+   "Crptographic erase"),
OPT("erase", 'E', arg_none, opt, Eflag,
-   "Erase user data"),
+   "User data erase"),
OPT("lbaf", 'f', arg_uint32, opt, lbaf,
-   "Set the LBA Format to apply to the media"),
+   "LBA Format to apply to the media"),
OPT("ms", 'm', arg_uint32, opt, ms,
-   "Slot to activate and/or download format to"),
+   "Metadata settings"),
OPT("pi", 'p', arg_uint32, opt, pi,
-   "Slot to activate and/or download format to"),
+   "Protective information"),
OPT("pil", 'l', arg_uint32, opt, pil,
-   "Slot to activate and/or download format to"),
+   "Protective information location"),
OPT("ses", 's', arg_uint32, opt, ses,
-   "Slot to activate and/or download format to"),
+   "Secure erase settings"),
{ NULL, 0, arg_none, NULL, NULL }
 };
 #undef OPT
@@ -101,7 +101,7 @@ static const struct args format_args[] = {
 static struct cmd format_cmd = {
.name = "format",
.fn = format,
-   .descr = "Format/erase one or all the namespaces.",
+   .descr = "Format/erase one or all the namespaces",
.ctx_size = sizeof(opt),
.opts = format_opts,
.args = format_args,

Modified: head/sbin/nvmecontrol/perftest.c
==
--- head/sbin/nvmecontrol/perftest.cWed Jul 31 03:48:48 2019
(r350461)
+++ head/sbin/nvmecontrol/perftest.cWed Jul 31 04:19:53 2019
(r350462)
@@ -99,7 +99,7 @@ static const struct args perftest_args[] = {
 static struct cmd perftest_cmd = {
.name = "perftest",
.fn = perftest,
-   .descr = "Perform low-level driver performance testing.",
+   .descr = "Perform low-level performance testing",
.ctx_size = sizeof(opt),
.opts = perftest_opts,
.args = perftest_args,

Modified: head/sbin/nvmecontrol/reset.c
==
--- head/sbin/nvmecontrol/reset.c   Wed Jul 31 03:48:48 2019
(r350461)
+++ head/sbin/nvmecontrol/reset.c   Wed Jul 31 04:19:53 2019
(r350462)
@@ -69,7 +69,7 @@ reset(const struct cmd *f, int argc, char *argv[])
 static struct cmd reset_cmd = {
.name = "reset",
.fn = reset,
-   .descr = "Perform a controller-level reset.",
+   .descr = "Perform a controller-level reset",
.args = args,
 };
 
___
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: r350461 - head/sbin/nvmecontrol

2019-07-30 Thread Alexander Motin
Author: mav
Date: Wed Jul 31 03:48:48 2019
New Revision: 350461
URL: https://svnweb.freebsd.org/changeset/base/350461

Log:
  Fix usage printing for nested subcommands.
  
  Instead of `nvmecontrol create` should be `nvmecontrol ns create`, etc.
  
  MFC after:2 weeks

Modified:
  head/sbin/nvmecontrol/comnd.c

Modified: head/sbin/nvmecontrol/comnd.c
==
--- head/sbin/nvmecontrol/comnd.c   Wed Jul 31 00:16:12 2019
(r350460)
+++ head/sbin/nvmecontrol/comnd.c   Wed Jul 31 03:48:48 2019
(r350461)
@@ -50,10 +50,22 @@ __FBSDID("$FreeBSD$");
 static struct cmd top;
 
 static void
+print_tree(const struct cmd *f)
+{
+
+   if (f->parent != NULL)
+   print_tree(f->parent);
+   if (f->name != NULL)
+   fprintf(stderr, " %s", f->name);
+}
+
+static void
 print_usage(const struct cmd *f)
 {
 
-   fprintf(stderr, "%s %-15s - %s\n", getprogname(), f->name, 
f->descr);
+   fprintf(stderr, "%s", getprogname());
+   print_tree(f->parent);
+   fprintf(stderr, " %-15s - %s\n", f->name, f->descr);
 }
 
 static void
@@ -120,7 +132,8 @@ arg_help(int argc __unused, char * const *argv, const 
// XXX walk up the cmd list...
if (argv[optind])
fprintf(stderr, "Unknown argument: %s\n", argv[optind]);
-   fprintf(stderr, "Usage:\n%s %s", getprogname(), argv[0]);
+   fprintf(stderr, "Usage:\n%s", getprogname());
+   print_tree(f);
if (opts)
fprintf(stderr, " ");
if (args) {
___
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: r350005 - head/sys/kern

2019-07-30 Thread Bryan Drewery
On 7/30/19 4:27 PM, Konstantin Belousov wrote:
> On Wed, Jul 31, 2019 at 02:13:02AM +0300, Konstantin Belousov wrote:
>> On Tue, Jul 30, 2019 at 03:04:57PM -0700, Bryan Drewery wrote:
>>> On 7/15/2019 12:18 PM, Konstantin Belousov wrote:
 Author: kib
 Date: Mon Jul 15 19:18:25 2019
 New Revision: 350005
 URL: https://svnweb.freebsd.org/changeset/base/350005

 Log:
   In do_sem2_wait(), balance umtx_key_get() with umtx_key_release() on 
 retry.
   
>>>
>>> Is this also needed in do_sem_wait()? A similar pattern seems to be there.
>> No, I do not think do_sem_wait() has similar issue, because the again label
>> does not re-get the key.
>>
>>>
>>> I ask because of what I referenced on IRC. I have some processes stuck
>>> in here from a 10.4 jail.
>>>
 ~/git/poudriere # procstat -kk 1498
   PIDTID COMMTDNAME  KSTACK
  1498 100710 python2.7   -   mi_switch+0x174 
 sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
 _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
 amd64_syscall+0x2bb fast_syscall_common+0x101
  1498 101575 python2.7   -   mi_switch+0x174 
 sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
 _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
 amd64_syscall+0x2bb fast_syscall_common+0x101
  1498 101657 python2.7   -   
>>> ...
 ~/git/poudriere # procstat -kk 1498
   PIDTID COMMTDNAME  KSTACK
  1498 100710 python2.7   -   mi_switch+0x174 
 sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
 _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
 amd64_syscall+0x2bb fast_syscall_common+0x101
  1498 101575 python2.7   -   mi_switch+0x174 
 sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
 _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
 amd64_syscall+0x2bb fast_syscall_common+0x101
  1498 101657 python2.7   -   do_sem_wait+0x1b6 
 __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101
>>> ...
 ~/git/poudriere # procstat -kk 94392
   PIDTID COMMTDNAME  KSTACK
 94392 101815 python2.7   -   mi_switch+0x174 
 sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
 _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
 amd64_syscall+0x2bb fast_syscall_common+0x101
 94392 101816 python2.7   -   
 __mtx_lock_sleep+0x118 __mtx_lock_flags+0x102 _sleep+0x334 umtxq_busy+0xb7 
 do_sem_wait+0x161 __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb 
 fast_syscall_common+0x101
 94392 102076 python2.7   -   __mtx_lock_flags+0x94 
 do_sem_wait+0x228 __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb 
 fast_syscall_common+0x101
>>
>> Try this.  We should only retry casueword if it failed spuriously.
>>
>> diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
>> index bb998457975..6c914ab6f3e 100644
>> --- a/sys/kern/kern_umtx.c
>> +++ b/sys/kern/kern_umtx.c
>> @@ -3229,7 +3229,8 @@ do_sem_wait(struct thread *td, struct _usem *sem, 
>> struct _umtx_time *timeout)
>>  rv = casueword32(>_has_waiters, 0, , 1);
>>  if (rv == 0)
>>  rv1 = fueword32(>_count, );
>> -if (rv == -1 || (rv == 0 && (rv1 == -1 || count != 0)) || rv == 1) {
>> +if (rv == -1 || (rv == 0 && (rv1 == -1 || count != 0)) ||
>> +(rv == 1 && count1 == 0)) {
>>  umtxq_lock(>uq_key);
>>  umtxq_unbusy(>uq_key);
>>  umtxq_remove(uq);
> 
> I think there is another problem, since even despite our intent of looping
> just because of casueword returned 1, the umtxq_check_susp() should have
> terminated the loop.  I believe the following update would fix that.
> 
> If you have time, can you please apply only the umtxq_check_susp() chunk
> and see if it helps as well ? [Both chunks are needed for correctness, but
> the umtxq_check_susp() is almost impossible to test in combination]
> 
> diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
> index bb998457975..08bdd1a1a9a 100644
> --- a/sys/kern/kern_umtx.c
> +++ b/sys/kern/kern_umtx.c
> @@ -723,13 +723,11 @@ umtxq_check_susp(struct thread *td, bool sleep)
>   error = 0;
>   p = td->td_proc;
>   PROC_LOCK(p);
> - if (P_SHOULDSTOP(p) ||
> - ((p->p_flag & P_TRACED) && (td->td_dbgflags & TDB_SUSPEND))) {
> - if (p->p_flag & P_SINGLE_EXIT)
> - error = EINTR;
> - else
> - error = sleep ? thread_suspend_check(0) : ERESTART;
> - }
> + if (p->p_flag & P_SINGLE_EXIT)
> + 

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

2019-07-30 Thread Bryan Drewery
On 7/30/2019 4:27 PM, Konstantin Belousov wrote:
> On Wed, Jul 31, 2019 at 02:13:02AM +0300, Konstantin Belousov wrote:
>> On Tue, Jul 30, 2019 at 03:04:57PM -0700, Bryan Drewery wrote:
>>> On 7/15/2019 12:18 PM, Konstantin Belousov wrote:
 Author: kib
 Date: Mon Jul 15 19:18:25 2019
 New Revision: 350005
 URL: https://svnweb.freebsd.org/changeset/base/350005

 Log:
   In do_sem2_wait(), balance umtx_key_get() with umtx_key_release() on 
 retry.
   
>>>
>>> Is this also needed in do_sem_wait()? A similar pattern seems to be there.
>> No, I do not think do_sem_wait() has similar issue, because the again label
>> does not re-get the key.
>>
>>>
>>> I ask because of what I referenced on IRC. I have some processes stuck
>>> in here from a 10.4 jail.
>>>
 ~/git/poudriere # procstat -kk 1498
   PIDTID COMMTDNAME  KSTACK
  1498 100710 python2.7   -   mi_switch+0x174 
 sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
 _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
 amd64_syscall+0x2bb fast_syscall_common+0x101
  1498 101575 python2.7   -   mi_switch+0x174 
 sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
 _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
 amd64_syscall+0x2bb fast_syscall_common+0x101
  1498 101657 python2.7   -   
>>> ...
 ~/git/poudriere # procstat -kk 1498
   PIDTID COMMTDNAME  KSTACK
  1498 100710 python2.7   -   mi_switch+0x174 
 sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
 _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
 amd64_syscall+0x2bb fast_syscall_common+0x101
  1498 101575 python2.7   -   mi_switch+0x174 
 sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
 _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
 amd64_syscall+0x2bb fast_syscall_common+0x101
  1498 101657 python2.7   -   do_sem_wait+0x1b6 
 __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101
>>> ...
 ~/git/poudriere # procstat -kk 94392
   PIDTID COMMTDNAME  KSTACK
 94392 101815 python2.7   -   mi_switch+0x174 
 sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
 _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
 amd64_syscall+0x2bb fast_syscall_common+0x101
 94392 101816 python2.7   -   
 __mtx_lock_sleep+0x118 __mtx_lock_flags+0x102 _sleep+0x334 umtxq_busy+0xb7 
 do_sem_wait+0x161 __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb 
 fast_syscall_common+0x101
 94392 102076 python2.7   -   __mtx_lock_flags+0x94 
 do_sem_wait+0x228 __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb 
 fast_syscall_common+0x101
>>
>> Try this.  We should only retry casueword if it failed spuriously.
>>
>> diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
>> index bb998457975..6c914ab6f3e 100644
>> --- a/sys/kern/kern_umtx.c
>> +++ b/sys/kern/kern_umtx.c
>> @@ -3229,7 +3229,8 @@ do_sem_wait(struct thread *td, struct _usem *sem, 
>> struct _umtx_time *timeout)
>>  rv = casueword32(>_has_waiters, 0, , 1);
>>  if (rv == 0)
>>  rv1 = fueword32(>_count, );
>> -if (rv == -1 || (rv == 0 && (rv1 == -1 || count != 0)) || rv == 1) {
>> +if (rv == -1 || (rv == 0 && (rv1 == -1 || count != 0)) ||
>> +(rv == 1 && count1 == 0)) {
>>  umtxq_lock(>uq_key);
>>  umtxq_unbusy(>uq_key);
>>  umtxq_remove(uq);
> 
> I think there is another problem, since even despite our intent of looping
> just because of casueword returned 1, the umtxq_check_susp() should have
> terminated the loop.  I believe the following update would fix that.
> 
> If you have time, can you please apply only the umtxq_check_susp() chunk
> and see if it helps as well ? [Both chunks are needed for correctness, but
> the umtxq_check_susp() is almost impossible to test in combination]

What is the expected "working" test for the umtxq_check_susp() change? I
get the 100% CPU and kill -9 does not kill it.

> ~ # procstat -kk 19150
>   PIDTID COMMTDNAME  KSTACK
> 19150 101524 python2.7   -   do_sem_wait+0x150 
> __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101
> 19150 101553 python2.7   -   mi_switch+0x174 
> sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
> _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x41c __umtx_op_sem_wait+0x6e 
> amd64_syscall+0x2bb fast_syscall_common+0x101
> 19150 101554 python2.7 

svn commit: r350460 - in stable/12: sbin/fsck_ffs sbin/mount sys/sys sys/ufs/ffs sys/ufs/ufs

2019-07-30 Thread Kirk McKusick
Author: mckusick
Date: Wed Jul 31 00:16:12 2019
New Revision: 350460
URL: https://svnweb.freebsd.org/changeset/base/350460

Log:
  MFC of 349589, 350070, 350071, 350096, and 350187
  
  Make filesystem-full messages limited per filesystem rather than systemwide
  Add "untrusted" option to mount command
  FS-14-UFS-3: when untrusted, valididate block pointers
  In fsck_ffs, treat any inode with bad content as unknown

Modified:
  stable/12/sbin/fsck_ffs/pass1.c
  stable/12/sbin/mount/mntopts.h
  stable/12/sbin/mount/mount.8
  stable/12/sbin/mount/mount.c
  stable/12/sys/sys/mount.h
  stable/12/sys/ufs/ffs/ffs_alloc.c
  stable/12/sys/ufs/ffs/ffs_balloc.c
  stable/12/sys/ufs/ffs/ffs_extern.h
  stable/12/sys/ufs/ffs/ffs_softdep.c
  stable/12/sys/ufs/ffs/ffs_subr.c
  stable/12/sys/ufs/ffs/ffs_vfsops.c
  stable/12/sys/ufs/ufs/ufs_bmap.c
  stable/12/sys/ufs/ufs/ufsmount.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/fsck_ffs/pass1.c
==
--- stable/12/sbin/fsck_ffs/pass1.c Tue Jul 30 23:50:49 2019
(r350459)
+++ stable/12/sbin/fsck_ffs/pass1.c Wed Jul 31 00:16:12 2019
(r350460)
@@ -251,7 +251,7 @@ checkinode(ino_t inumber, struct inodesc *idesc, int r
int j, ret, offset;
 
if ((dp = getnextinode(inumber, rebuildcg)) == NULL)
-   return (0);
+   goto unknown;
mode = DIP(dp, di_mode) & IFMT;
if (mode == 0) {
if ((sblock.fs_magic == FS_UFS1_MAGIC &&

Modified: stable/12/sbin/mount/mntopts.h
==
--- stable/12/sbin/mount/mntopts.h  Tue Jul 30 23:50:49 2019
(r350459)
+++ stable/12/sbin/mount/mntopts.h  Wed Jul 31 00:16:12 2019
(r350460)
@@ -58,6 +58,7 @@ struct mntopt {
 #define MOPT_ACLS  { "acls",   0, MNT_ACLS, 0 }
 #define MOPT_NFS4ACLS  { "nfsv4acls",  0, MNT_NFS4ACLS, 0 }
 #define MOPT_AUTOMOUNTED   { "automounted",0, MNT_AUTOMOUNTED, 0 }
+#define MOPT_UNTRUSTED { "untrusted",  0, MNT_UNTRUSTED, 0 }
 
 /* Control flags. */
 #define MOPT_FORCE { "force",  0, MNT_FORCE, 0 }
@@ -93,7 +94,8 @@ struct mntopt {
MOPT_MULTILABEL,\
MOPT_ACLS,  \
MOPT_NFS4ACLS,  \
-   MOPT_AUTOMOUNTED
+   MOPT_AUTOMOUNTED,   \
+   MOPT_UNTRUSTED
 
 void getmntopts(const char *, const struct mntopt *, int *, int *);
 void rmslashes(char *, char *);

Modified: stable/12/sbin/mount/mount.8
==
--- stable/12/sbin/mount/mount.8Tue Jul 30 23:50:49 2019
(r350459)
+++ stable/12/sbin/mount/mount.8Wed Jul 31 00:16:12 2019
(r350460)
@@ -355,6 +355,12 @@ Lookups will be done in the mounted file system first.
 If those operations fail due to a non-existent file the underlying
 directory is then accessed.
 All creates are done in the mounted file system.
+.It Cm untrusted
+The file system is untrusted and the kernel should use more
+extensive checks on the file-system's metadata before using it.
+This option is intended to be used when mounting file systems
+from untrusted media such as USB memory sticks or other
+externally-provided media.
 .El
 .Pp
 Any additional options specific to a file system type that is not

Modified: stable/12/sbin/mount/mount.c
==
--- stable/12/sbin/mount/mount.cTue Jul 30 23:50:49 2019
(r350459)
+++ stable/12/sbin/mount/mount.cWed Jul 31 00:16:12 2019
(r350460)
@@ -118,6 +118,7 @@ static struct opt {
{ MNT_GJOURNAL, "gjournal" },
{ MNT_AUTOMOUNTED,  "automounted" },
{ MNT_VERIFIED, "verified" },
+   { MNT_UNTRUSTED,"untrusted" },
{ 0, NULL }
 };
 
@@ -972,6 +973,7 @@ flags2opts(int flags)
if (flags & MNT_MULTILABEL) res = catopt(res, "multilabel");
if (flags & MNT_ACLS)   res = catopt(res, "acls");
if (flags & MNT_NFS4ACLS)   res = catopt(res, "nfsv4acls");
+   if (flags & MNT_UNTRUSTED)  res = catopt(res, "untrusted");
 
return (res);
 }

Modified: stable/12/sys/sys/mount.h
==
--- stable/12/sys/sys/mount.h   Tue Jul 30 23:50:49 2019(r350459)
+++ stable/12/sys/sys/mount.h   Wed Jul 31 00:16:12 2019(r350460)
@@ -296,6 +296,7 @@ void  __mnt_vnode_markerfree_active(struct vno
 #defineMNT_NOCLUSTERW  0x8000ULL /* disable cluster write 
*/
 #defineMNT_SUJ 0x0001ULL /* using journaled 

svn commit: r350459 - stable/11/sbin/dump

2019-07-30 Thread Kirk McKusick
Author: mckusick
Date: Tue Jul 30 23:50:49 2019
New Revision: 350459
URL: https://svnweb.freebsd.org/changeset/base/350459

Log:
  MFC of 349032
  
  Clarify -r and -R only usable for level 0 dumps.

Modified:
  stable/11/sbin/dump/dump.8
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/dump/dump.8
==
--- stable/11/sbin/dump/dump.8  Tue Jul 30 22:41:25 2019(r350458)
+++ stable/11/sbin/dump/dump.8  Tue Jul 30 23:50:49 2019(r350459)
@@ -29,7 +29,7 @@
 .\" @(#)dump.8 8.3 (Berkeley) 5/1/95
 .\" $FreeBSD$
 .\"
-.Dd October 3, 2016
+.Dd June 13, 2019
 .Dt DUMP 8
 .Os
 .Sh NAME
@@ -266,6 +266,12 @@ used to update a remote copy of a level 0 dump,
 since the date changes for each dump.
 This option sets both dates to the epoch, permitting
 rsync to be much more efficient when transferring a dump file.
+The
+.Fl r
+option can be used only to create level 0 dumps.
+A dump using the
+.Fl r
+option cannot be used as the basis for a later incremental dump.
 .It Fl R
 Be even more rsync-friendly.
 This option disables the storage of the actual inode access time
@@ -277,6 +283,12 @@ The
 .Fl R
 option also sets
 .Fl r .
+The
+.Fl R
+option can be used only to create level 0 dumps.
+A dump using the
+.Fl R
+option cannot be used as the basis for a later incremental dump.
 .It Fl S
 Display an estimate of the backup size and the number of
 tapes required, and exit without actually performing the dump.
___
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: r350005 - head/sys/kern

2019-07-30 Thread Konstantin Belousov
On Wed, Jul 31, 2019 at 02:13:02AM +0300, Konstantin Belousov wrote:
> On Tue, Jul 30, 2019 at 03:04:57PM -0700, Bryan Drewery wrote:
> > On 7/15/2019 12:18 PM, Konstantin Belousov wrote:
> > > Author: kib
> > > Date: Mon Jul 15 19:18:25 2019
> > > New Revision: 350005
> > > URL: https://svnweb.freebsd.org/changeset/base/350005
> > > 
> > > Log:
> > >   In do_sem2_wait(), balance umtx_key_get() with umtx_key_release() on 
> > > retry.
> > >   
> > 
> > Is this also needed in do_sem_wait()? A similar pattern seems to be there.
> No, I do not think do_sem_wait() has similar issue, because the again label
> does not re-get the key.
> 
> > 
> > I ask because of what I referenced on IRC. I have some processes stuck
> > in here from a 10.4 jail.
> > 
> > > ~/git/poudriere # procstat -kk 1498
> > >   PIDTID COMMTDNAME  KSTACK
> > >  1498 100710 python2.7   -   mi_switch+0x174 
> > > sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
> > > _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
> > > amd64_syscall+0x2bb fast_syscall_common+0x101
> > >  1498 101575 python2.7   -   mi_switch+0x174 
> > > sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
> > > _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
> > > amd64_syscall+0x2bb fast_syscall_common+0x101
> > >  1498 101657 python2.7   -   
> > ...
> > > ~/git/poudriere # procstat -kk 1498
> > >   PIDTID COMMTDNAME  KSTACK
> > >  1498 100710 python2.7   -   mi_switch+0x174 
> > > sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
> > > _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
> > > amd64_syscall+0x2bb fast_syscall_common+0x101
> > >  1498 101575 python2.7   -   mi_switch+0x174 
> > > sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
> > > _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
> > > amd64_syscall+0x2bb fast_syscall_common+0x101
> > >  1498 101657 python2.7   -   do_sem_wait+0x1b6 
> > > __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101
> > ...
> > > ~/git/poudriere # procstat -kk 94392
> > >   PIDTID COMMTDNAME  KSTACK
> > > 94392 101815 python2.7   -   mi_switch+0x174 
> > > sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
> > > _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
> > > amd64_syscall+0x2bb fast_syscall_common+0x101
> > > 94392 101816 python2.7   -   
> > > __mtx_lock_sleep+0x118 __mtx_lock_flags+0x102 _sleep+0x334 
> > > umtxq_busy+0xb7 do_sem_wait+0x161 __umtx_op_sem_wait+0x6e 
> > > amd64_syscall+0x2bb fast_syscall_common+0x101
> > > 94392 102076 python2.7   -   
> > > __mtx_lock_flags+0x94 do_sem_wait+0x228 __umtx_op_sem_wait+0x6e 
> > > amd64_syscall+0x2bb fast_syscall_common+0x101
> 
> Try this.  We should only retry casueword if it failed spuriously.
> 
> diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
> index bb998457975..6c914ab6f3e 100644
> --- a/sys/kern/kern_umtx.c
> +++ b/sys/kern/kern_umtx.c
> @@ -3229,7 +3229,8 @@ do_sem_wait(struct thread *td, struct _usem *sem, 
> struct _umtx_time *timeout)
>   rv = casueword32(>_has_waiters, 0, , 1);
>   if (rv == 0)
>   rv1 = fueword32(>_count, );
> - if (rv == -1 || (rv == 0 && (rv1 == -1 || count != 0)) || rv == 1) {
> + if (rv == -1 || (rv == 0 && (rv1 == -1 || count != 0)) ||
> + (rv == 1 && count1 == 0)) {
>   umtxq_lock(>uq_key);
>   umtxq_unbusy(>uq_key);
>   umtxq_remove(uq);

I think there is another problem, since even despite our intent of looping
just because of casueword returned 1, the umtxq_check_susp() should have
terminated the loop.  I believe the following update would fix that.

If you have time, can you please apply only the umtxq_check_susp() chunk
and see if it helps as well ? [Both chunks are needed for correctness, but
the umtxq_check_susp() is almost impossible to test in combination]

diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
index bb998457975..08bdd1a1a9a 100644
--- a/sys/kern/kern_umtx.c
+++ b/sys/kern/kern_umtx.c
@@ -723,13 +723,11 @@ umtxq_check_susp(struct thread *td, bool sleep)
error = 0;
p = td->td_proc;
PROC_LOCK(p);
-   if (P_SHOULDSTOP(p) ||
-   ((p->p_flag & P_TRACED) && (td->td_dbgflags & TDB_SUSPEND))) {
-   if (p->p_flag & P_SINGLE_EXIT)
-   error = EINTR;
-   else
-   error = sleep ? thread_suspend_check(0) : ERESTART;
-   }
+   if (p->p_flag & P_SINGLE_EXIT)
+   error = EINTR;
+   else if 

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

2019-07-30 Thread Konstantin Belousov
On Tue, Jul 30, 2019 at 03:04:57PM -0700, Bryan Drewery wrote:
> On 7/15/2019 12:18 PM, Konstantin Belousov wrote:
> > Author: kib
> > Date: Mon Jul 15 19:18:25 2019
> > New Revision: 350005
> > URL: https://svnweb.freebsd.org/changeset/base/350005
> > 
> > Log:
> >   In do_sem2_wait(), balance umtx_key_get() with umtx_key_release() on 
> > retry.
> >   
> 
> Is this also needed in do_sem_wait()? A similar pattern seems to be there.
No, I do not think do_sem_wait() has similar issue, because the again label
does not re-get the key.

> 
> I ask because of what I referenced on IRC. I have some processes stuck
> in here from a 10.4 jail.
> 
> > ~/git/poudriere # procstat -kk 1498
> >   PIDTID COMMTDNAME  KSTACK
> >  1498 100710 python2.7   -   mi_switch+0x174 
> > sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
> > _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
> > amd64_syscall+0x2bb fast_syscall_common+0x101
> >  1498 101575 python2.7   -   mi_switch+0x174 
> > sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
> > _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
> > amd64_syscall+0x2bb fast_syscall_common+0x101
> >  1498 101657 python2.7   -   
> ...
> > ~/git/poudriere # procstat -kk 1498
> >   PIDTID COMMTDNAME  KSTACK
> >  1498 100710 python2.7   -   mi_switch+0x174 
> > sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
> > _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
> > amd64_syscall+0x2bb fast_syscall_common+0x101
> >  1498 101575 python2.7   -   mi_switch+0x174 
> > sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
> > _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
> > amd64_syscall+0x2bb fast_syscall_common+0x101
> >  1498 101657 python2.7   -   do_sem_wait+0x1b6 
> > __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101
> ...
> > ~/git/poudriere # procstat -kk 94392
> >   PIDTID COMMTDNAME  KSTACK
> > 94392 101815 python2.7   -   mi_switch+0x174 
> > sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
> > _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
> > amd64_syscall+0x2bb fast_syscall_common+0x101
> > 94392 101816 python2.7   -   __mtx_lock_sleep+0x118 
> > __mtx_lock_flags+0x102 _sleep+0x334 umtxq_busy+0xb7 do_sem_wait+0x161 
> > __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101
> > 94392 102076 python2.7   -   __mtx_lock_flags+0x94 
> > do_sem_wait+0x228 __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb 
> > fast_syscall_common+0x101

Try this.  We should only retry casueword if it failed spuriously.

diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
index bb998457975..6c914ab6f3e 100644
--- a/sys/kern/kern_umtx.c
+++ b/sys/kern/kern_umtx.c
@@ -3229,7 +3229,8 @@ do_sem_wait(struct thread *td, struct _usem *sem, struct 
_umtx_time *timeout)
rv = casueword32(>_has_waiters, 0, , 1);
if (rv == 0)
rv1 = fueword32(>_count, );
-   if (rv == -1 || (rv == 0 && (rv1 == -1 || count != 0)) || rv == 1) {
+   if (rv == -1 || (rv == 0 && (rv1 == -1 || count != 0)) ||
+   (rv == 1 && count1 == 0)) {
umtxq_lock(>uq_key);
umtxq_unbusy(>uq_key);
umtxq_remove(uq);
___
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: r350458 - head/sys/sys

2019-07-30 Thread Mark Johnston
Author: markj
Date: Tue Jul 30 22:41:25 2019
New Revision: 350458
URL: https://svnweb.freebsd.org/changeset/base/350458

Log:
  Use VNASSERT() in checked VOP wrappers.
  
  Reviewed by:  kib
  MFC after:3 days
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D21120

Modified:
  head/sys/sys/vnode.h

Modified: head/sys/sys/vnode.h
==
--- head/sys/sys/vnode.hTue Jul 30 20:58:56 2019(r350457)
+++ head/sys/sys/vnode.hTue Jul 30 22:41:25 2019(r350458)
@@ -844,27 +844,30 @@ void  vop_rename_fail(struct vop_rename_args *ap);
 
 #define VOP_LOCK(vp, flags) VOP_LOCK1(vp, flags, __FILE__, __LINE__)
 
-#ifdef INVARIANTS
+#ifdef INVARIANTS
 #defineVOP_ADD_WRITECOUNT_CHECKED(vp, cnt) 
\
 do {   \
int error_; \
\
error_ = VOP_ADD_WRITECOUNT((vp), (cnt));   \
-   MPASS(error_ == 0); \
+   VNASSERT(error_ == 0, (vp), ("VOP_ADD_WRITECOUNT returned %d",  \
+   error_));   \
 } while (0)
 #defineVOP_SET_TEXT_CHECKED(vp)
\
 do {   \
int error_; \
\
error_ = VOP_SET_TEXT((vp));\
-   MPASS(error_ == 0); \
+   VNASSERT(error_ == 0, (vp), ("VOP_SET_TEXT returned %d",\
+   error_));   \
 } while (0)
 #defineVOP_UNSET_TEXT_CHECKED(vp)  
\
 do {   \
int error_; \
\
error_ = VOP_UNSET_TEXT((vp));  \
-   MPASS(error_ == 0); \
+   VNASSERT(error_ == 0, (vp), ("VOP_UNSET_TEXT returned %d",  \
+   error_));   \
 } while (0)
 #else
 #defineVOP_ADD_WRITECOUNT_CHECKED(vp, cnt) 
VOP_ADD_WRITECOUNT((vp), (cnt))
___
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: r350005 - head/sys/kern

2019-07-30 Thread Bryan Drewery
On 7/15/2019 12:18 PM, Konstantin Belousov wrote:
> Author: kib
> Date: Mon Jul 15 19:18:25 2019
> New Revision: 350005
> URL: https://svnweb.freebsd.org/changeset/base/350005
> 
> Log:
>   In do_sem2_wait(), balance umtx_key_get() with umtx_key_release() on retry.
>   

Is this also needed in do_sem_wait()? A similar pattern seems to be there.

I ask because of what I referenced on IRC. I have some processes stuck
in here from a 10.4 jail.

> ~/git/poudriere # procstat -kk 1498
>   PIDTID COMMTDNAME  KSTACK
>  1498 100710 python2.7   -   mi_switch+0x174 
> sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
> _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
> amd64_syscall+0x2bb fast_syscall_common+0x101
>  1498 101575 python2.7   -   mi_switch+0x174 
> sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
> _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
> amd64_syscall+0x2bb fast_syscall_common+0x101
>  1498 101657 python2.7   -   
...
> ~/git/poudriere # procstat -kk 1498
>   PIDTID COMMTDNAME  KSTACK
>  1498 100710 python2.7   -   mi_switch+0x174 
> sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
> _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
> amd64_syscall+0x2bb fast_syscall_common+0x101
>  1498 101575 python2.7   -   mi_switch+0x174 
> sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
> _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
> amd64_syscall+0x2bb fast_syscall_common+0x101
>  1498 101657 python2.7   -   do_sem_wait+0x1b6 
> __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101
...
> ~/git/poudriere # procstat -kk 94392
>   PIDTID COMMTDNAME  KSTACK
> 94392 101815 python2.7   -   mi_switch+0x174 
> sleepq_switch+0x110 sleepq_catch_signals+0x417 sleepq_wait_sig+0xf 
> _sleep+0x2d0 umtxq_sleep+0x153 do_sem_wait+0x42c __umtx_op_sem_wait+0x6e 
> amd64_syscall+0x2bb fast_syscall_common+0x101
> 94392 101816 python2.7   -   __mtx_lock_sleep+0x118 
> __mtx_lock_flags+0x102 _sleep+0x334 umtxq_busy+0xb7 do_sem_wait+0x161 
> __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb fast_syscall_common+0x101
> 94392 102076 python2.7   -   __mtx_lock_flags+0x94 
> do_sem_wait+0x228 __umtx_op_sem_wait+0x6e amd64_syscall+0x2bb 
> fast_syscall_common+0x101




>   Reported by:ler
>   Bisected and reviewed by:   markj
>   Sponsored by:   The FreeBSD Foundation
>   MFC after:  12 days
> 
> Modified:
>   head/sys/kern/kern_umtx.c
> 
> Modified: head/sys/kern/kern_umtx.c
> ==
> --- head/sys/kern/kern_umtx.c Mon Jul 15 17:13:32 2019(r350004)
> +++ head/sys/kern/kern_umtx.c Mon Jul 15 19:18:25 2019(r350005)
> @@ -3316,14 +3316,13 @@ do_sem2_wait(struct thread *td, struct _usem2 *sem, st
>  
>   uq = td->td_umtxq;
>   flags = fuword32(>_flags);
> - error = umtx_key_get(sem, TYPE_SEM, GET_SHARE(flags), >uq_key);
> - if (error != 0)
> - return (error);
> -
>   if (timeout != NULL)
>   abs_timeout_init2(, timeout);
>  
>  again:
> + error = umtx_key_get(sem, TYPE_SEM, GET_SHARE(flags), >uq_key);
> + if (error != 0)
> + return (error);
>   umtxq_lock(>uq_key);
>   umtxq_busy(>uq_key);
>   umtxq_insert(uq);
> 


-- 
Regards,
Bryan Drewery



signature.asc
Description: OpenPGP digital signature


Re: svn commit: r350211 - head/tests/sys/kern

2019-07-30 Thread John Baldwin
On 7/22/19 3:37 AM, Li-Wen Hsu wrote:
> Author: lwhsu
> Date: Mon Jul 22 10:37:56 2019
> New Revision: 350211
> URL: https://svnweb.freebsd.org/changeset/base/350211
> 
> Log:
>   Temporarily skip flakey test case
>   sys.kern.ptrace_test.ptrace__follow_fork_child_detached_unrelated_debugger
>   
>   PR: 239292
>   Sponsored by:   The FreeBSD Foundation

It might be good to try to reach out to folks when opening a PR (e.g. using
svn annotate to see who added the test)?  Looking at the failures, they all
indicate that a read from a pipe is failing in a child process.  It is supposed
to succeed with EOF and is either failing or returning data incorrectly.  This 
is
not flake but probably a real error that needs to be looked at.  I run these
tests fairly often when testing ptrace changes and have never seen this failure.
Can you reproduce it outside of CI?

Also, I see in followups that you disabled several more meaning that I can't
rely on running ptrace_test directly for my own testing via kyua anymore. :(
Is there some kind of flag we can set with kyua to say "run all the tests
because they work everywhere else except our CI setup"?

-- 
John Baldwin
___
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: r350457 - head/sbin/camcontrol

2019-07-30 Thread Alexander Motin
Author: mav
Date: Tue Jul 30 20:58:56 2019
New Revision: 350457
URL: https://svnweb.freebsd.org/changeset/base/350457

Log:
  Make `camcontrol modepage` to use 10 byte commands.
  
  While old devices may not support 10 byte MODE SENSE/MODE SELECT commands,
  new ones may not be able to report all mode pages with 6 byte commands.
  
  This patch makes camcontrol by default start with 10 byte commands and
  fall back to 6 byte on ILLEGAL REQUEST error, or 6 byte can be forced.
  
  MFC after:2 weeks
  Sponsored by: iXsystems, Inc.

Modified:
  head/sbin/camcontrol/camcontrol.8
  head/sbin/camcontrol/camcontrol.c
  head/sbin/camcontrol/camcontrol.h
  head/sbin/camcontrol/modeedit.c

Modified: head/sbin/camcontrol/camcontrol.8
==
--- head/sbin/camcontrol/camcontrol.8   Tue Jul 30 19:55:55 2019
(r350456)
+++ head/sbin/camcontrol/camcontrol.8   Tue Jul 30 20:58:56 2019
(r350457)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 25, 2019
+.Dd July 30, 2019
 .Dt CAMCONTROL 8
 .Os
 .Sh NAME
@@ -122,6 +122,7 @@
 .Ic modepage
 .Op device id
 .Op generic args
+.Op Fl 6
 .Aq Fl m Ar page[,subpage] | Fl l
 .Op Fl P Ar pgctl
 .Op Fl b | Fl e
@@ -723,6 +724,13 @@ The
 .Ic modepage
 command takes several arguments:
 .Bl -tag -width 12n
+.It Fl 6
+Use 6 byte MODE commands instead of default 10 byte.
+Old devices may not support 10 byte MODE commands, while new devices may
+not be able to report all mode pages with 6 byte commands.
+If not specified,
+.Nm
+starts with 10 byte commands and falls back to 6 byte on error.
 .It Fl d
 Disable block descriptors for mode sense.
 .It Fl b

Modified: head/sbin/camcontrol/camcontrol.c
==
--- head/sbin/camcontrol/camcontrol.c   Tue Jul 30 19:55:55 2019
(r350456)
+++ head/sbin/camcontrol/camcontrol.c   Tue Jul 30 20:58:56 2019
(r350457)
@@ -221,7 +221,7 @@ static struct camcontrol_opts option_table[] = {
{"devlist", CAM_CMD_DEVTREE, CAM_ARG_NONE, "-b"},
{"devtype", CAM_CMD_DEVTYPE, CAM_ARG_NONE, ""},
{"periphlist", CAM_CMD_DEVLIST, CAM_ARG_NONE, NULL},
-   {"modepage", CAM_CMD_MODE_PAGE, CAM_ARG_NONE, "bdelm:P:"},
+   {"modepage", CAM_CMD_MODE_PAGE, CAM_ARG_NONE, "6bdelm:P:"},
{"tags", CAM_CMD_TAG, CAM_ARG_NONE, "N:q"},
{"negotiate", CAM_CMD_RATE, CAM_ARG_NONE, negotiate_opts},
{"rate", CAM_CMD_RATE, CAM_ARG_NONE, negotiate_opts},
@@ -4586,18 +4586,25 @@ reassignblocks(struct cam_device *device, u_int32_t *b
 #endif
 
 void
-mode_sense(struct cam_device *device, int dbd, int pc, int page, int subpage,
-  int task_attr, int retry_count, int timeout, u_int8_t *data,
-  int datalen)
+mode_sense(struct cam_device *device, int *cdb_len, int dbd, int pc, int page,
+int subpage, int task_attr, int retry_count, int timeout, u_int8_t *data,
+int datalen)
 {
union ccb *ccb;
-   int retval;
+   int error_code, sense_key, asc, ascq;
 
ccb = cam_getccb(device);
-
if (ccb == NULL)
errx(1, "mode_sense: couldn't allocate CCB");
 
+retry:
+   /*
+* MODE SENSE(6) can't handle more then 255 bytes.  If there are more,
+* device must return error, so we should not get trucated data.
+*/
+   if (*cdb_len == 6 && datalen > 255)
+   datalen = 255;
+
CCB_CLEAR_ALL_EXCEPT_HDR(>csio);
 
scsi_mode_sense_subpage(>csio,
@@ -4610,36 +4617,47 @@ mode_sense(struct cam_device *device, int dbd, int pc,
/* subpage */ subpage,
/* param_buf */ data,
/* param_len */ datalen,
-   /* minimum_cmd_size */ 0,
+   /* minimum_cmd_size */ *cdb_len,
/* sense_len */ SSD_FULL_SIZE,
/* timeout */ timeout ? timeout : 5000);
 
+   /* Record what CDB size the above function really set. */
+   *cdb_len = ccb->csio.cdb_len;
+
if (arglist & CAM_ARG_ERR_RECOVER)
ccb->ccb_h.flags |= CAM_PASS_ERR_RECOVER;
 
/* Disable freezing the device queue */
ccb->ccb_h.flags |= CAM_DEV_QFRZDIS;
 
-   if (((retval = cam_send_ccb(device, ccb)) < 0)
-|| ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)) {
+   if (cam_send_ccb(device, ccb) < 0)
+   err(1, "error sending mode sense command");
+
+   /* In case of ILLEGEL REQUEST try to fall back to 6-byte command. */
+   if (*cdb_len != 6 &&
+   ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_INVALID ||
+(scsi_extract_sense_ccb(ccb, _code, _key, , )
+ && sense_key == SSD_KEY_ILLEGAL_REQUEST))) {
+   *cdb_len = 6;
+   goto retry;
+   }
+
+   if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
if (arglist & 

svn commit: r350453 - head/share/mk

2019-07-30 Thread Alan Somers
Author: asomers
Date: Tue Jul 30 19:34:39 2019
New Revision: 350453
URL: https://svnweb.freebsd.org/changeset/base/350453

Log:
  Add a CXXWARNFLAGS variable
  
  Some warning flags are valid for C++ but not C. GCC 8 complains if you pass
  such flags when building a C file. Using a separate variable for these
  flags allows building both C and C++ files in the same directory (such as
  the fusefs tests) under GCC.
  
  Reviewed by:  cem, emaste
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D21116

Modified:
  head/share/mk/bsd.sys.mk

Modified: head/share/mk/bsd.sys.mk
==
--- head/share/mk/bsd.sys.mkTue Jul 30 17:31:09 2019(r350452)
+++ head/share/mk/bsd.sys.mkTue Jul 30 19:34:39 2019(r350453)
@@ -234,6 +234,8 @@ DEBUG_FILES_CFLAGS?= -g
 .if ${MK_WARNS} != "no"
 CFLAGS+=   ${CWARNFLAGS:M*} ${CWARNFLAGS.${COMPILER_TYPE}}
 CFLAGS+=   ${CWARNFLAGS.${.IMPSRC:T}}
+CXXFLAGS+= ${CXXWARNFLAGS:M*} ${CXXWARNFLAGS.${COMPILER_TYPE}}
+CXXFLAGS+= ${CXXWARNFLAGS.${.IMPSRC:T}}
 .endif
 
 CFLAGS+=${CFLAGS.${COMPILER_TYPE}}
___
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: r350444 - head/stand/efi/loader

2019-07-30 Thread Ruslan Bukin
Hi

No, this is linking-stage fix only.
efinet.c, efihttp.c are still included to the build

I guess we could exclude them from compilation as it makes no sense

Ruslan

On Tue, Jul 30, 2019 at 07:00:34PM +0300, Toomas Soome wrote:
> hi!
> 
> efihttp is also using network, is it intentionally left untouched?
> 
> rgds,
> toomas
> 
> > On 30 Jul 2019, at 17:54, Ruslan Bukin  wrote:
> > 
> > Author: br
> > Date: Tue Jul 30 14:54:18 2019
> > New Revision: 350444
> > URL: https://svnweb.freebsd.org/changeset/base/350444
> > 
> > Log:
> >  Fix EFI loader build when LOADER_NET_SUPPORT=no.
> > 
> >  Sponsored by:  DARPA, AFRL
> > 
> > Modified:
> >  head/stand/efi/loader/conf.c
> > 
> > Modified: head/stand/efi/loader/conf.c
> > ==
> > --- head/stand/efi/loader/conf.cTue Jul 30 14:21:00 2019
> > (r350443)
> > +++ head/stand/efi/loader/conf.cTue Jul 30 14:54:18 2019
> > (r350444)
> > @@ -40,7 +40,9 @@ struct devsw *devsw[] = {
> > _cddev,
> > _hddev,
> > _dev, /* ordering with efinet_dev matters */
> > +#if defined(LOADER_NET_SUPPORT)
> > _dev,
> > +#endif
> > _dev,
> > #ifdef EFI_ZFS_BOOT
> > _dev,
> > @@ -64,7 +66,9 @@ struct fs_ops *file_system[] = {
> > };
> > 
> > struct netif_driver *netif_drivers[] = {
> > +#if defined(LOADER_NET_SUPPORT)
> > ,
> > +#endif
> > NULL
> > };
> > 
> > 
> 
> 

___
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: r350451 - in head/sys: amd64/linux amd64/linux32 arm64/linux conf i386/linux modules/linux64

2019-07-30 Thread Ed Maste
Author: emaste
Date: Tue Jul 30 17:18:31 2019
New Revision: 350451
URL: https://svnweb.freebsd.org/changeset/base/350451

Log:
  linuxulator: rename linux_locore.s to .asm
  
  It is assembled using "${CC} -x assembler-with-cpp", which by convention
  (bsd.suffixes.mk) uses the .asm extension.
  
  This is a portion of the review referenced below (D18344).  That review
  also renamed linux_support.s to .S, but that is a functional change
  (using the compiler's integrated assembler instead of as) and will be
  revisited separately.
  
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D18344

Added:
  head/sys/amd64/linux/linux_locore.asm
 - copied unchanged from r350450, head/sys/amd64/linux/linux_locore.s
  head/sys/amd64/linux32/linux32_locore.asm
 - copied unchanged from r350450, head/sys/amd64/linux32/linux32_locore.s
  head/sys/arm64/linux/linux_locore.asm
 - copied unchanged from r350450, head/sys/arm64/linux/linux_locore.s
  head/sys/i386/linux/linux_locore.asm
 - copied unchanged from r350450, head/sys/i386/linux/linux_locore.s
Deleted:
  head/sys/amd64/linux/linux_locore.s
  head/sys/amd64/linux32/linux32_locore.s
  head/sys/arm64/linux/linux_locore.s
  head/sys/i386/linux/linux_locore.s
Modified:
  head/sys/conf/files.amd64
  head/sys/conf/files.i386
  head/sys/modules/linux64/Makefile

Copied: head/sys/amd64/linux/linux_locore.asm (from r350450, 
head/sys/amd64/linux/linux_locore.s)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/amd64/linux/linux_locore.asm   Tue Jul 30 17:18:31 2019
(r350451, copy of r350450, head/sys/amd64/linux/linux_locore.s)
@@ -0,0 +1,108 @@
+/* $FreeBSD$ */
+
+#include "linux_assym.h"   /* system definitions */
+#include   /* miscellaneous asm macros */
+
+#include  /* system call numbers */
+
+   .data
+
+   .globl linux_platform
+linux_platform:
+   .asciz "x86_64"
+
+
+   .text
+/*
+ * To avoid excess stack frame the signal trampoline code emulates
+ * the 'call' instruction.
+ */
+NON_GPROF_ENTRY(linux_rt_sigcode)
+   movq%rsp, %rbx  /* preserve sigframe */
+   call.getip
+.getip:
+   popq%rax
+   add $.startrtsigcode-.getip, %rax   /* ret address */
+   pushq   %rax
+   jmp *LINUX_RT_SIGF_HANDLER(%rbx)
+.startrtsigcode:
+   movq$LINUX_SYS_linux_rt_sigreturn,%rax   /* linux_rt_sigreturn() */
+   syscall /* enter kernel with args */
+   hlt
+.endrtsigcode:
+0: jmp 0b
+
+NON_GPROF_ENTRY(__vdso_clock_gettime)
+   movq$LINUX_SYS_linux_clock_gettime,%rax
+   syscall
+   ret
+.weak clock_gettime
+.set clock_gettime, __vdso_clock_gettime
+
+NON_GPROF_ENTRY(__vdso_time)
+   movq$LINUX_SYS_linux_time,%rax
+   syscall
+   ret
+.weak time
+.set time, __vdso_time
+
+NON_GPROF_ENTRY(__vdso_gettimeofday)
+   movq$LINUX_SYS_gettimeofday,%rax
+   syscall
+   ret
+.weak gettimeofday
+.set gettimeofday, __vdso_gettimeofday
+
+NON_GPROF_ENTRY(__vdso_getcpu)
+   movq$-38,%rax   /* not implemented */
+   ret
+.weak getcpu
+.set getcpu, __vdso_getcpu
+
+#if 0
+   .section .note.Linux, "a",@note
+   .long 2f - 1f   /* namesz */
+   .balign 4
+   .long 4f - 3f   /* descsz */
+   .long 0
+1:
+   .asciz "Linux"
+2:
+   .balign 4
+3:
+   .long LINUX_VERSION_CODE
+4:
+   .balign 4
+   .previous
+#endif
+
+   .section .eh_frame,"a",@progbits
+.LSTARTFRAMEDLSI0:
+   .long .LENDCIEDLSI0-.LSTARTCIEDLSI0
+.LSTARTCIEDLSI0:
+   .long 0 /* CIE ID */
+   .byte 1 /* Version number */
+   .string "zR"/* NULL-terminated
+* augmentation string
+*/
+   .uleb128 1  /* Code alignment factor */
+   .sleb128 -4 /* Data alignment factor */
+   .byte 8 /* Return address register 
column */
+   .uleb128 1  /* Augmentation value length */
+   .byte 0x1b  /* 
DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
+   .byte 0x0c  /* DW_CFA_def_cfa */
+   .uleb128 4
+   .uleb128 4
+   .byte 0x88  /* DW_CFA_offset, column 0x8 */
+   .uleb128 1
+   .align 4
+.LENDCIEDLSI0:
+   .long .LENDFDEDLSI0-.LSTARTFDEDLSI0 /* Length FDE */
+.LSTARTFDEDLSI0:
+   .long .LSTARTFDEDLSI0-.LSTARTFRAMEDLSI0 /* CIE pointer */
+   .long .startrtsigcode-. /* PC-relative start 

svn commit: r350450 - head/sys/kern

2019-07-30 Thread Mark Johnston
Author: markj
Date: Tue Jul 30 17:09:58 2019
New Revision: 350450
URL: https://svnweb.freebsd.org/changeset/base/350450

Log:
  Enable witness(4) blessings.
  
  witness has long had a facility to "bless" designated lock pairs.  Lock
  order reversals between a pair of blessed locks are not reported upon.
  We have a number of long-standing false positive LOR reports; start
  marking well-understood LORs as blessed.
  
  This change hides reports about UFS vnode locks and the UFS dirhash
  lock, and UFS vnode locks and buffer locks, since those are the two that
  I observe most often.  In the long term it would be preferable to be
  able to limit blessings to a specific site where a lock is acquired,
  and/or extend witness to understand why some lock order reversals are
  valid (for example, if code paths with conflicting lock orders are
  serialized by a third lock), but in the meantime the false positives
  frequently confuse users and generate bug reports.
  
  Reviewed by:  cem, kib, mckusick
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D21039

Modified:
  head/sys/kern/subr_witness.c

Modified: head/sys/kern/subr_witness.c
==
--- head/sys/kern/subr_witness.cTue Jul 30 16:40:33 2019
(r350449)
+++ head/sys/kern/subr_witness.cTue Jul 30 17:09:58 2019
(r350450)
@@ -132,9 +132,6 @@ __FBSDID("$FreeBSD$");
 #defineLI_EXCLUSIVE0x0001  /* Exclusive lock instance. */
 #defineLI_NORELEASE0x0002  /* Lock not allowed to be 
released. */
 
-/* Define this to check for blessed mutexes */
-#undef BLESSING
-
 #ifndef WITNESS_COUNT
 #defineWITNESS_COUNT   1536
 #endif
@@ -278,12 +275,10 @@ struct witness_lock_order_hash {
u_int   wloh_count;
 };
 
-#ifdef BLESSING
 struct witness_blessed {
const char  *b_lock1;
const char  *b_lock2;
 };
-#endif
 
 struct witness_pendhelp {
const char  *wh_type;
@@ -318,9 +313,7 @@ witness_lock_order_key_equal(const struct witness_lock
 static int _isitmyx(struct witness *w1, struct witness *w2, int rmask,
const char *fname);
 static voidadopt(struct witness *parent, struct witness *child);
-#ifdef BLESSING
 static int blessed(struct witness *, struct witness *);
-#endif
 static voiddepart(struct witness *w);
 static struct witness  *enroll(const char *description,
struct lock_class *lock_class);
@@ -726,14 +719,25 @@ static struct witness_order_list_entry order_lists[] =
{ NULL, NULL }
 };
 
-#ifdef BLESSING
 /*
- * Pairs of locks which have been blessed
- * Don't complain about order problems with blessed locks
+ * Pairs of locks which have been blessed.  Witness does not complain about
+ * order problems with blessed lock pairs.  Please do not add an entry to the
+ * table without an explanatory comment.
  */
 static struct witness_blessed blessed_list[] = {
+   /*
+* See the comment in ufs_dirhash.c.  Basically, a vnode lock serializes
+* both lock orders, so a deadlock cannot happen as a result of this
+* LOR.
+*/
+   { "dirhash","bufwait" },
+
+   /*
+* A UFS vnode may be locked in vget() while a buffer belonging to the
+* parent directory vnode is locked.
+*/
+   { "ufs","bufwait" },
 };
-#endif
 
 /*
  * This global is set to 0 once it becomes safe to use the witness code.
@@ -1339,7 +1343,6 @@ witness_checkorder(struct lock_object *lock, int flags
 * We have a lock order violation, check to see if it
 * is allowed or has already been yelled about.
 */
-#ifdef BLESSING
 
/*
 * If the lock order is blessed, just bail.  We don't
@@ -1348,7 +1351,6 @@ witness_checkorder(struct lock_object *lock, int flags
 */
if (blessed(w, w1))
goto out;
-#endif
 
/* Bail if this violation is known */
if (w_rmatrix[w1->w_index][w->w_index] & 
WITNESS_REVERSAL)
@@ -2084,7 +2086,6 @@ isitmydescendant(struct witness *ancestor, struct witn
__func__));
 }
 
-#ifdef BLESSING
 static int
 blessed(struct witness *w1, struct witness *w2)
 {
@@ -2104,7 +2105,6 @@ blessed(struct witness *w1, struct witness *w2)
}
return (0);
 }
-#endif
 
 static struct witness *
 witness_get(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: r350449 - head

2019-07-30 Thread Ed Maste
Author: emaste
Date: Tue Jul 30 16:40:33 2019
New Revision: 350449
URL: https://svnweb.freebsd.org/changeset/base/350449

Log:
  cirrus.yml: stop fetching OVMF.fd now that we're using the pkg
  
  Missed in r350302
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/.cirrus.yml

Modified: head/.cirrus.yml
==
--- head/.cirrus.ymlTue Jul 30 16:01:16 2019(r350448)
+++ head/.cirrus.ymlTue Jul 30 16:40:33 2019(r350449)
@@ -12,7 +12,6 @@ task:
   timeout_in: 90m
   install_script:
   - pkg install -y qemu-devel uefi-edk2-qemu-x86_64
-  - fetch https://people.freebsd.org/~emaste/OVMF.fd
   script:
   - make -j$(sysctl -n hw.ncpu) WITHOUT_TOOLCHAIN=yes buildworld buildkernel
   test_script:
___
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: r350444 - head/stand/efi/loader

2019-07-30 Thread Toomas Soome via svn-src-all
hi!

efihttp is also using network, is it intentionally left untouched?

rgds,
toomas

> On 30 Jul 2019, at 17:54, Ruslan Bukin  wrote:
> 
> Author: br
> Date: Tue Jul 30 14:54:18 2019
> New Revision: 350444
> URL: https://svnweb.freebsd.org/changeset/base/350444
> 
> Log:
>  Fix EFI loader build when LOADER_NET_SUPPORT=no.
> 
>  Sponsored by:DARPA, AFRL
> 
> Modified:
>  head/stand/efi/loader/conf.c
> 
> Modified: head/stand/efi/loader/conf.c
> ==
> --- head/stand/efi/loader/conf.c  Tue Jul 30 14:21:00 2019
> (r350443)
> +++ head/stand/efi/loader/conf.c  Tue Jul 30 14:54:18 2019
> (r350444)
> @@ -40,7 +40,9 @@ struct devsw *devsw[] = {
>   _cddev,
>   _hddev,
>   _dev, /* ordering with efinet_dev matters */
> +#if defined(LOADER_NET_SUPPORT)
>   _dev,
> +#endif
>   _dev,
> #ifdef EFI_ZFS_BOOT
>   _dev,
> @@ -64,7 +66,9 @@ struct fs_ops *file_system[] = {
> };
> 
> struct netif_driver *netif_drivers[] = {
> +#if defined(LOADER_NET_SUPPORT)
>   ,
> +#endif
>   NULL
> };
> 
> 

___
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: r350448 - head/sys/kern

2019-07-30 Thread Mark Johnston
Author: markj
Date: Tue Jul 30 16:01:16 2019
New Revision: 350448
URL: https://svnweb.freebsd.org/changeset/base/350448

Log:
  Regenerate after r350447.

Modified:
  head/sys/kern/init_sysent.c

Modified: head/sys/kern/init_sysent.c
==
--- head/sys/kern/init_sysent.c Tue Jul 30 15:59:44 2019(r350447)
+++ head/sys/kern/init_sysent.c Tue Jul 30 16:01:16 2019(r350448)
@@ -618,5 +618,5 @@ struct sysent sysent[] = {
{ AS(fhlinkat_args), (sy_call_t *)sys_fhlinkat, AUE_NULL, NULL, 0, 0, 
0, SY_THR_STATIC },   /* 566 = fhlinkat */
{ AS(fhreadlink_args), (sy_call_t *)sys_fhreadlink, AUE_NULL, NULL, 0, 
0, 0, SY_THR_STATIC },   /* 567 = fhreadlink */
{ AS(funlinkat_args), (sy_call_t *)sys_funlinkat, AUE_UNLINKAT, NULL, 
0, 0, SYF_CAPENABLED, SY_THR_STATIC },/* 568 = funlinkat */
-   { AS(copy_file_range_args), (sy_call_t *)sys_copy_file_range, AUE_NULL, 
NULL, 0, 0, 0, SY_THR_STATIC }, /* 569 = copy_file_range */
+   { AS(copy_file_range_args), (sy_call_t *)sys_copy_file_range, AUE_NULL, 
NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC },/* 569 = copy_file_range */
 };
___
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: r350447 - head/sys/kern

2019-07-30 Thread Mark Johnston
Author: markj
Date: Tue Jul 30 15:59:44 2019
New Revision: 350447
URL: https://svnweb.freebsd.org/changeset/base/350447

Log:
  Enable copy_file_range(2) in capability mode.
  
  copy_file_range() operates on a pair of file descriptors; it requires
  CAP_READ for the source descriptor and CAP_WRITE for the destination
  descriptor.
  
  Reviewed by:  kevans, oshogbo
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D21113

Modified:
  head/sys/kern/capabilities.conf

Modified: head/sys/kern/capabilities.conf
==
--- head/sys/kern/capabilities.conf Tue Jul 30 15:57:31 2019
(r350446)
+++ head/sys/kern/capabilities.conf Tue Jul 30 15:59:44 2019
(r350447)
@@ -133,6 +133,11 @@ closefrom
 connectat
 
 ##
+## copy_file_range(2) reads from one descriptor and writes to the other.
+##
+copy_file_range
+
+##
 ## cpuset(2) and related calls are limited to caller's own process/thread.
 ##
 #cpuset
___
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: r350446 - head/sys/sys

2019-07-30 Thread Mark Johnston
Author: markj
Date: Tue Jul 30 15:57:31 2019
New Revision: 350446
URL: https://svnweb.freebsd.org/changeset/base/350446

Log:
  Handle refcount(9) wraparound.
  
  Attempt to mitigate the security risks around refcount overflows by
  introducing a "saturated" state for the counter.  Once a counter reaches
  INT_MAX+1, subsequent acquire and release operations will blindly set
  the counter value to INT_MAX + INT_MAX/2, ensuring that the protected
  resource will not be freed; instead, it will merely be leaked.
  
  The approach introduces a small race: if a refcount value reaches
  INT_MAX+1, a subsequent release will cause the releasing thread to set
  the counter to the saturation value after performing the decrement.  If
  in the intervening window INT_MAX refcount releases are performed by a
  different thread, a use-after-free is possible.  This is very difficult
  to trigger in practice, and any situation where it could be triggered
  would likely be vulnerable to reference count wraparound problems
  to begin with.  An alternative would be to use atomic_cmpset to acquire
  and release references, but this would introduce a larger performance
  penalty, particularly when the counter is contended.
  
  Note that refcount_acquire_checked(9) maintains its previous behaviour;
  code which must accurately track references should use it instead of
  refcount_acquire(9).
  
  Reviewed by:  kib, mjg
  MFC after:3 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D21089

Modified:
  head/sys/sys/refcount.h

Modified: head/sys/sys/refcount.h
==
--- head/sys/sys/refcount.h Tue Jul 30 15:51:28 2019(r350445)
+++ head/sys/sys/refcount.h Tue Jul 30 15:57:31 2019(r350446)
@@ -30,7 +30,6 @@
 #ifndef __SYS_REFCOUNT_H__
 #define __SYS_REFCOUNT_H__
 
-#include 
 #include 
 
 #ifdef _KERNEL
@@ -40,19 +39,41 @@
 #defineKASSERT(exp, msg)   /* */
 #endif
 
+#defineREFCOUNT_SATURATED(val) (((val) & (1U << 31)) != 0)
+#defineREFCOUNT_SATURATION_VALUE   (3U << 30)
+
+/*
+ * Attempt to handle reference count overflow and underflow.  Force the counter
+ * to stay at the saturation value so that a counter overflow cannot trigger
+ * destruction of the containing object and instead leads to a less harmful
+ * memory leak.
+ */
 static __inline void
-refcount_init(volatile u_int *count, u_int value)
+_refcount_update_saturated(volatile u_int *count)
 {
+#ifdef INVARIANTS
+   panic("refcount %p wraparound", count);
+#else
+   atomic_store_int(count, REFCOUNT_SATURATION_VALUE);
+#endif
+}
 
+static __inline void
+refcount_init(volatile u_int *count, u_int value)
+{
+   KASSERT(!REFCOUNT_SATURATED(value),
+   ("invalid initial refcount value %u", value));
*count = value;
 }
 
 static __inline void
 refcount_acquire(volatile u_int *count)
 {
+   u_int old;
 
-   KASSERT(*count < UINT_MAX, ("refcount %p overflowed", count));
-   atomic_add_int(count, 1);
+   old = atomic_fetchadd_int(count, 1);
+   if (__predict_false(REFCOUNT_SATURATED(old)))
+   _refcount_update_saturated(count);
 }
 
 static __inline __result_use_check bool
@@ -61,7 +82,7 @@ refcount_acquire_checked(volatile u_int *count)
u_int lcount;
 
for (lcount = *count;;) {
-   if (__predict_false(lcount + 1 < lcount))
+   if (__predict_false(REFCOUNT_SATURATED(lcount + 1)))
return (false);
if (__predict_true(atomic_fcmpset_int(count, ,
lcount + 1) == 1))
@@ -76,7 +97,15 @@ refcount_release(volatile u_int *count)
 
atomic_thread_fence_rel();
old = atomic_fetchadd_int(count, -1);
-   KASSERT(old > 0, ("refcount %p is zero", count));
+   if (__predict_false(old == 0 || REFCOUNT_SATURATED(old))) {
+   /*
+* Avoid multiple destructor invocations if underflow occurred.
+* This is not perfect since the memory backing the containing
+* object may already have been reallocated.
+*/
+   _refcount_update_saturated(count);
+   return (false);
+   }
if (old > 1)
return (false);
 
@@ -84,7 +113,7 @@ refcount_release(volatile u_int *count)
 * Last reference.  Signal the user to call the destructor.
 *
 * Ensure that the destructor sees all updates.  The fence_rel
-* at the start of the function synchronized with this fence.
+* at the start of the function synchronizes with this fence.
 */
atomic_thread_fence_acq();
return (true);
@@ -101,9 +130,10 @@ refcount_acquire_if_not_zero(volatile u_int *count)
 
old = *count;
for (;;) {
-   KASSERT(old < UINT_MAX, ("refcount %p overflowed", count));
 

svn commit: r350445 - head/etc/mtree

2019-07-30 Thread Ian Lepore
Author: ian
Date: Tue Jul 30 15:51:28 2019
New Revision: 350445
URL: https://svnweb.freebsd.org/changeset/base/350445

Log:
  Create the /var/account dir with mode 0750; this is a followup to r349974.
  
  The rc.d/account script contains code to create the /var/account dir, so
  it hadn't occurred to me that it is normally created via mtree; thanks to
  jilles@ for pointing it out.

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

Modified: head/etc/mtree/BSD.var.dist
==
--- head/etc/mtree/BSD.var.dist Tue Jul 30 14:54:18 2019(r350444)
+++ head/etc/mtree/BSD.var.dist Tue Jul 30 15:51:28 2019(r350445)
@@ -5,7 +5,7 @@
 
 /set type=dir uname=root gname=wheel mode=0755 tags=package=runtime
 .
-account
+account mode=0750
 ..
 at
 /set uname=daemon
___
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: r350444 - head/stand/efi/loader

2019-07-30 Thread Ruslan Bukin
Author: br
Date: Tue Jul 30 14:54:18 2019
New Revision: 350444
URL: https://svnweb.freebsd.org/changeset/base/350444

Log:
  Fix EFI loader build when LOADER_NET_SUPPORT=no.
  
  Sponsored by: DARPA, AFRL

Modified:
  head/stand/efi/loader/conf.c

Modified: head/stand/efi/loader/conf.c
==
--- head/stand/efi/loader/conf.cTue Jul 30 14:21:00 2019
(r350443)
+++ head/stand/efi/loader/conf.cTue Jul 30 14:54:18 2019
(r350444)
@@ -40,7 +40,9 @@ struct devsw *devsw[] = {
_cddev,
_hddev,
_dev, /* ordering with efinet_dev matters */
+#if defined(LOADER_NET_SUPPORT)
_dev,
+#endif
_dev,
 #ifdef EFI_ZFS_BOOT
_dev,
@@ -64,7 +66,9 @@ struct fs_ops *file_system[] = {
 };
 
 struct netif_driver *netif_drivers[] = {
+#if defined(LOADER_NET_SUPPORT)
,
+#endif
NULL
 };
 
___
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: r350443 - head/sys/dev/mmc/host

2019-07-30 Thread Ruslan Bukin
Author: br
Date: Tue Jul 30 14:21:00 2019
New Revision: 350443
URL: https://svnweb.freebsd.org/changeset/base/350443

Log:
  Fix MMCCAM kernel build.
  
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/dev/mmc/host/dwmmc_altera.c

Modified: head/sys/dev/mmc/host/dwmmc_altera.c
==
--- head/sys/dev/mmc/host/dwmmc_altera.cTue Jul 30 14:19:18 2019
(r350442)
+++ head/sys/dev/mmc/host/dwmmc_altera.cTue Jul 30 14:21:00 2019
(r350443)
@@ -41,6 +41,8 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+#include "opt_mmccam.h"
+
 static struct ofw_compat_data compat_data[] = {
{"altr,socfpga-dw-mshc",1},
{NULL,  0},
___
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: r350442 - stable/11/usr.sbin/mptutil

2019-07-30 Thread Ed Maste
Author: emaste
Date: Tue Jul 30 14:19:18 2019
New Revision: 350442
URL: https://svnweb.freebsd.org/changeset/base/350442

Log:
  MFC r350215: mptutil: emit a warning on big-endian architectures
  
  It is known to be broken.
  
  PR:   162513
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/11/usr.sbin/mptutil/mptutil.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/mptutil/mptutil.c
==
--- stable/11/usr.sbin/mptutil/mptutil.cTue Jul 30 14:18:05 2019
(r350441)
+++ stable/11/usr.sbin/mptutil/mptutil.cTue Jul 30 14:19:18 2019
(r350442)
@@ -112,6 +112,10 @@ main(int ac, char **av)
if (ac == 0)
usage();
 
+#if BYTE_ORDER == BIG_ENDIAN
+   warnx("mptutil is known to be broken on big-endian architectures");
+#endif
+
SET_FOREACH(cmd, MPT_DATASET(top)) {
if (strcmp((*cmd)->name, av[0]) == 0) {
if ((*cmd)->handler(ac, av))
___
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: r350441 - stable/12/usr.sbin/mptutil

2019-07-30 Thread Ed Maste
Author: emaste
Date: Tue Jul 30 14:18:05 2019
New Revision: 350441
URL: https://svnweb.freebsd.org/changeset/base/350441

Log:
  MFC r350215: mptutil: emit a warning on big-endian architectures
  
  It is known to be broken.
  
  PR:   162513
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/usr.sbin/mptutil/mptutil.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/mptutil/mptutil.c
==
--- stable/12/usr.sbin/mptutil/mptutil.cTue Jul 30 12:51:14 2019
(r350440)
+++ stable/12/usr.sbin/mptutil/mptutil.cTue Jul 30 14:18:05 2019
(r350441)
@@ -114,6 +114,10 @@ main(int ac, char **av)
if (ac == 0)
usage();
 
+#if BYTE_ORDER == BIG_ENDIAN
+   warnx("mptutil is known to be broken on big-endian architectures");
+#endif
+
SET_FOREACH(cmd, MPT_DATASET(top)) {
if (strcmp((*cmd)->name, av[0]) == 0) {
if ((*cmd)->handler(ac, av))
___
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: r350440 - in head/sys: arm64/conf conf dev/mmc/host

2019-07-30 Thread Ruslan Bukin
Author: br
Date: Tue Jul 30 12:51:14 2019
New Revision: 350440
URL: https://svnweb.freebsd.org/changeset/base/350440

Log:
  Add support for the SD/MMC controller found in Terasic DE10-Pro
  (an Intel Stratix 10 GX/SX FPGA Development Kit).
  
  Set the bus speed manually due to lack of clock management support.
  
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/arm64/conf/GENERIC
  head/sys/conf/files.arm64
  head/sys/dev/mmc/host/dwmmc_altera.c

Modified: head/sys/arm64/conf/GENERIC
==
--- head/sys/arm64/conf/GENERIC Tue Jul 30 12:17:11 2019(r350439)
+++ head/sys/arm64/conf/GENERIC Tue Jul 30 12:51:14 2019(r350440)
@@ -189,6 +189,7 @@ device  aw_mmc  # Allwinner 
SD/MMC controller
 device mmc # mmc/sd bus
 device mmcsd   # mmc/sd flash cards
 device dwmmc
+device dwmmc_altera
 device rk_emmcphy
 
 # Serial (COM) ports

Modified: head/sys/conf/files.arm64
==
--- head/sys/conf/files.arm64   Tue Jul 30 12:17:11 2019(r350439)
+++ head/sys/conf/files.arm64   Tue Jul 30 12:51:14 2019(r350440)
@@ -221,6 +221,7 @@ dev/hwpmc/hwpmc_arm64.c optionalhwpmc
 dev/hwpmc/hwpmc_arm64_md.c optionalhwpmc
 dev/mbox/mbox_if.m optionalsoc_brcm_bcm2837
 dev/mmc/host/dwmmc.c   optionaldwmmc fdt
+dev/mmc/host/dwmmc_altera.coptionaldwmmc fdt dwmmc_altera
 dev/mmc/host/dwmmc_hisi.c  optionaldwmmc fdt soc_hisi_hi6220
 dev/mmc/host/dwmmc_rockchip.c  optionaldwmmc fdt soc_rockchip_rk3328
 dev/neta/if_mvneta_fdt.c   optionalneta fdt

Modified: head/sys/dev/mmc/host/dwmmc_altera.c
==
--- head/sys/dev/mmc/host/dwmmc_altera.cTue Jul 30 12:17:11 2019
(r350439)
+++ head/sys/dev/mmc/host/dwmmc_altera.cTue Jul 30 12:51:14 2019
(r350440)
@@ -66,9 +66,17 @@ static int
 altera_dwmmc_attach(device_t dev)
 {
struct dwmmc_softc *sc;
+   phandle_t root;
 
sc = device_get_softc(dev);
sc->hwtype = HWTYPE_ALTERA;
+
+   root = OF_finddevice("/");
+
+   if (ofw_bus_node_is_compatible(root, "altr,socfpga-stratix10")) {
+   sc->bus_hz = 2400;
+   sc->use_pio = 1;
+   }
 
return (dwmmc_attach(dev));
 }
___
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: r350439 - stable/12/sys/arm64/arm64

2019-07-30 Thread Ganbold Tsagaankhuu
Author: ganbold
Date: Tue Jul 30 12:17:11 2019
New Revision: 350439
URL: https://svnweb.freebsd.org/changeset/base/350439

Log:
  MFC r346993
  Add a hw.model sysctl oid for arm64 which reports the CPU model similar to 
armv6/7.

Modified:
  stable/12/sys/arm64/arm64/identcpu.c

Modified: stable/12/sys/arm64/arm64/identcpu.c
==
--- stable/12/sys/arm64/arm64/identcpu.cTue Jul 30 08:53:03 2019
(r350438)
+++ stable/12/sys/arm64/arm64/identcpu.cTue Jul 30 12:17:11 2019
(r350439)
@@ -52,6 +52,10 @@ char machine[] = "arm64";
 SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0,
 "Machine class");
 
+static char cpu_model[64];
+SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD,
+   cpu_model, sizeof(cpu_model), "Machine model");
+
 /*
  * Per-CPU affinity as provided in MPIDR_EL1
  * Indexed by CPU number in logical order selected by the system.
@@ -1292,6 +1296,10 @@ identify_cpu(void)
 
cpu_desc[cpu].cpu_revision = CPU_REV(midr);
cpu_desc[cpu].cpu_variant = CPU_VAR(midr);
+
+   snprintf(cpu_model, sizeof(cpu_model), "%s %s r%dp%d",
+   cpu_desc[cpu].cpu_impl_name, cpu_desc[cpu].cpu_part_name,
+   cpu_desc[cpu].cpu_variant, cpu_desc[cpu].cpu_revision);
 
/* Save affinity for current CPU */
cpu_desc[cpu].mpidr = get_mpidr();
___
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: r350436 - in head/sys: amd64/conf arm/arm conf i386/conf kern sys

2019-07-30 Thread Poul-Henning Kamp

In message <201907300513.x6u5dgjs004...@repo.freebsd.org>, Xin LI writes:

>URL: https://svnweb.freebsd.org/changeset/base/350436
>
>Log:
>  Remove gzip'ed a.out support.

Backstory:

http://phk.freebsd.dk/sagas/gzipaout/

-- 
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-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: r350438 - head/lib/libcasper/services/cap_fileargs

2019-07-30 Thread Mariusz Zaborski
Author: oshogbo
Date: Tue Jul 30 08:53:03 2019
New Revision: 350438
URL: https://svnweb.freebsd.org/changeset/base/350438

Log:
  fileargs: fix formating in EXAMPLES
  
  PR:   239523
  Submitted by: mikael.uran...@gmail.com

Modified:
  head/lib/libcasper/services/cap_fileargs/cap_fileargs.3

Modified: head/lib/libcasper/services/cap_fileargs/cap_fileargs.3
==
--- head/lib/libcasper/services/cap_fileargs/cap_fileargs.3 Tue Jul 30 
05:14:28 2019(r350437)
+++ head/lib/libcasper/services/cap_fileargs/cap_fileargs.3 Tue Jul 30 
08:53:03 2019(r350438)
@@ -247,7 +247,7 @@ for (i = 0; i < argc; i++) {
fd = fileargs_open(fa, argv[i]);
if (fd < 0)
err(1, "unable to open file %s", argv[i]);
-   printf("File %s opened in capability mode\n", argv[i]);
+   printf("File %s opened in capability mode\en", argv[i]);
close(fd);
 }
 
___
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"