svn commit: r325706 - head/sys/kern

2017-11-11 Thread Mateusz Guzik
Author: mjg
Date: Sat Nov 11 09:34:11 2017
New Revision: 325706
URL: https://svnweb.freebsd.org/changeset/base/325706

Log:
  rwlock: use fcmpset for setting RW_LOCK_WRITE_SPINNER

Modified:
  head/sys/kern/kern_rwlock.c

Modified: head/sys/kern/kern_rwlock.c
==
--- head/sys/kern/kern_rwlock.c Sat Nov 11 07:21:49 2017(r325705)
+++ head/sys/kern/kern_rwlock.c Sat Nov 11 09:34:11 2017(r325706)
@@ -929,9 +929,8 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v, ui
if ((v & RW_LOCK_READ) && RW_READERS(v) &&
spintries < rowner_retries) {
if (!(v & RW_LOCK_WRITE_SPINNER)) {
-   if (!atomic_cmpset_ptr(&rw->rw_lock, v,
+   if (!atomic_fcmpset_ptr(&rw->rw_lock, &v,
v | RW_LOCK_WRITE_SPINNER)) {
-   v = RW_READ_VALUE(rw);
continue;
}
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325707 - head/sys/compat/linuxkpi/common/include/linux

2017-11-11 Thread Hans Petter Selasky
Author: hselasky
Date: Sat Nov 11 10:46:12 2017
New Revision: 325707
URL: https://svnweb.freebsd.org/changeset/base/325707

Log:
  Mask away return codes from del_timer() and del_timer_sync() because
  they are not the same like in Linux.
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

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

Modified: head/sys/compat/linuxkpi/common/include/linux/timer.h
==
--- head/sys/compat/linuxkpi/common/include/linux/timer.h   Sat Nov 11 
09:34:11 2017(r325706)
+++ head/sys/compat/linuxkpi/common/include/linux/timer.h   Sat Nov 11 
10:46:12 2017(r325707)
@@ -69,8 +69,8 @@ extern void mod_timer(struct timer_list *, int);
 extern void add_timer(struct timer_list *);
 extern void add_timer_on(struct timer_list *, int cpu);
 
-#definedel_timer(timer)callout_stop(&(timer)->timer_callout)
-#definedel_timer_sync(timer)   callout_drain(&(timer)->timer_callout)
+#definedel_timer(timer)
(void)callout_stop(&(timer)->timer_callout)
+#definedel_timer_sync(timer)   
(void)callout_drain(&(timer)->timer_callout)
 #definetimer_pending(timer)callout_pending(&(timer)->timer_callout)
 #defineround_jiffies(j)\
((int)(((j) + linux_timer_hz_mask) & ~linux_timer_hz_mask))
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325708 - in head/sys/compat/linuxkpi/common: include/linux src

2017-11-11 Thread Hans Petter Selasky
Author: hselasky
Date: Sat Nov 11 11:01:50 2017
New Revision: 325708
URL: https://svnweb.freebsd.org/changeset/base/325708

Log:
  Remove release and acquire semantics when accessing the "state" field of the
  LinuxKPI task struct. Change type of "state" variable from "int" to
  "atomic_t" to simplify code and avoid unneccessary casting.
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/sched.h
  head/sys/compat/linuxkpi/common/src/linux_current.c
  head/sys/compat/linuxkpi/common/src/linux_schedule.c

Modified: head/sys/compat/linuxkpi/common/include/linux/sched.h
==
--- head/sys/compat/linuxkpi/common/include/linux/sched.h   Sat Nov 11 
10:46:12 2017(r325707)
+++ head/sys/compat/linuxkpi/common/include/linux/sched.h   Sat Nov 11 
11:01:50 2017(r325708)
@@ -67,7 +67,7 @@ struct task_struct {
void   *task_data;
int task_ret;
atomic_t usage;
-   int state;
+   atomic_t state;
atomic_t kthread_flags;
pid_t   pid;/* BSD thread ID */
const char*comm;
@@ -92,9 +92,8 @@ struct task_struct {
 #defineput_pid(x)  do { } while (0)
 #definecurrent_euid()  (curthread->td_ucred->cr_uid)
 
-#defineset_task_state(task, x) \
-   atomic_store_rel_int((volatile int *)&task->state, (x))
-#define__set_task_state(task, x)   (task->state = (x))
+#defineset_task_state(task, x) atomic_set(&(task)->state, (x))
+#define__set_task_state(task, x)   ((task)->state.counter = (x))
 #defineset_current_state(x)set_task_state(current, x)
 #define__set_current_state(x)  __set_task_state(current, x)
 

Modified: head/sys/compat/linuxkpi/common/src/linux_current.c
==
--- head/sys/compat/linuxkpi/common/src/linux_current.c Sat Nov 11 10:46:12 
2017(r325707)
+++ head/sys/compat/linuxkpi/common/src/linux_current.c Sat Nov 11 11:01:50 
2017(r325708)
@@ -68,7 +68,7 @@ linux_alloc_current(struct thread *td, int flags)
ts->comm = td->td_name;
ts->pid = td->td_tid;
atomic_set(&ts->usage, 1);
-   ts->state = TASK_RUNNING;
+   atomic_set(&ts->state, TASK_RUNNING);
init_completion(&ts->parked);
init_completion(&ts->exited);
 

Modified: head/sys/compat/linuxkpi/common/src/linux_schedule.c
==
--- head/sys/compat/linuxkpi/common/src/linux_schedule.cSat Nov 11 
10:46:12 2017(r325707)
+++ head/sys/compat/linuxkpi/common/src/linux_schedule.cSat Nov 11 
11:01:50 2017(r325708)
@@ -78,7 +78,7 @@ wake_up_task(struct task_struct *task, unsigned int st
 
ret = wakeup_swapper = 0;
sleepq_lock(task);
-   if ((atomic_load_acq_int(&task->state) & state) != 0) {
+   if ((atomic_read(&task->state) & state) != 0) {
set_task_state(task, TASK_WAKING);
wakeup_swapper = sleepq_signal(task, SLEEPQ_SLEEP, 0, 0);
ret = 1;
@@ -234,7 +234,7 @@ linux_wait_event_common(wait_queue_head_t *wqh, wait_q
 */
PHOLD(task->task_thread->td_proc);
sleepq_lock(task);
-   if (atomic_load_acq_int(&task->state) != TASK_WAKING) {
+   if (atomic_read(&task->state) != TASK_WAKING) {
ret = linux_add_to_sleepqueue(task, "wevent", timeout, state);
} else {
sleepq_release(task);
@@ -269,7 +269,7 @@ linux_schedule_timeout(int timeout)
DROP_GIANT();
 
sleepq_lock(task);
-   state = atomic_load_acq_int(&task->state);
+   state = atomic_read(&task->state);
if (state != TASK_WAKING)
(void)linux_add_to_sleepqueue(task, "sched", timeout, state);
else
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325713 - in head/contrib/zstd: . contrib/gen_html contrib/pzstd contrib/pzstd/test contrib/pzstd/utils contrib/pzstd/utils/test contrib/seekable_format doc doc/educational_decoder lib ...

2017-11-11 Thread Baptiste Daroussin
Author: bapt
Date: Sat Nov 11 13:54:37 2017
New Revision: 325713
URL: https://svnweb.freebsd.org/changeset/base/325713

Log:
  Update to zstd 1.3.2

Added:
  head/contrib/zstd/COPYING
 - copied unchanged from r325712, vendor/zstd/dist/COPYING
  head/contrib/zstd/contrib/seekable_format/
 - copied from r325712, vendor/zstd/dist/contrib/seekable_format/
  head/contrib/zstd/doc/educational_decoder/Makefile
 - copied unchanged from r325712, 
vendor/zstd/dist/doc/educational_decoder/Makefile
  head/contrib/zstd/lib/compress/zstd_compress.h
 - copied unchanged from r325712, 
vendor/zstd/dist/lib/compress/zstd_compress.h
  head/contrib/zstd/lib/compress/zstd_double_fast.c
 - copied unchanged from r325712, 
vendor/zstd/dist/lib/compress/zstd_double_fast.c
  head/contrib/zstd/lib/compress/zstd_double_fast.h
 - copied unchanged from r325712, 
vendor/zstd/dist/lib/compress/zstd_double_fast.h
  head/contrib/zstd/lib/compress/zstd_fast.c
 - copied unchanged from r325712, vendor/zstd/dist/lib/compress/zstd_fast.c
  head/contrib/zstd/lib/compress/zstd_fast.h
 - copied unchanged from r325712, vendor/zstd/dist/lib/compress/zstd_fast.h
  head/contrib/zstd/lib/compress/zstd_lazy.c
 - copied unchanged from r325712, vendor/zstd/dist/lib/compress/zstd_lazy.c
  head/contrib/zstd/lib/compress/zstd_lazy.h
 - copied unchanged from r325712, vendor/zstd/dist/lib/compress/zstd_lazy.h
  head/contrib/zstd/lib/compress/zstd_ldm.c
 - copied unchanged from r325712, vendor/zstd/dist/lib/compress/zstd_ldm.c
  head/contrib/zstd/lib/compress/zstd_ldm.h
 - copied unchanged from r325712, vendor/zstd/dist/lib/compress/zstd_ldm.h
  head/contrib/zstd/lib/compress/zstd_opt.c
 - copied unchanged from r325712, vendor/zstd/dist/lib/compress/zstd_opt.c
  head/contrib/zstd/tests/fuzz/block_decompress.c
 - copied unchanged from r325712, 
vendor/zstd/dist/tests/fuzz/block_decompress.c
  head/contrib/zstd/tests/fuzz/block_round_trip.c
 - copied unchanged from r325712, 
vendor/zstd/dist/tests/fuzz/block_round_trip.c
  head/contrib/zstd/tests/fuzz/default.options
 - copied unchanged from r325712, 
vendor/zstd/dist/tests/fuzz/default.options
  head/contrib/zstd/tests/fuzz/fuzz.py
 - copied unchanged from r325712, vendor/zstd/dist/tests/fuzz/fuzz.py
  head/contrib/zstd/tests/fuzz/zstd_helpers.c
 - copied unchanged from r325712, vendor/zstd/dist/tests/fuzz/zstd_helpers.c
  head/contrib/zstd/tests/fuzz/zstd_helpers.h
 - copied unchanged from r325712, vendor/zstd/dist/tests/fuzz/zstd_helpers.h
Deleted:
  head/contrib/zstd/LICENSE-examples
Modified:
  head/contrib/zstd/Makefile
  head/contrib/zstd/NEWS
  head/contrib/zstd/appveyor.yml
  head/contrib/zstd/circle.yml
  head/contrib/zstd/contrib/gen_html/Makefile
  head/contrib/zstd/contrib/gen_html/gen_html.cpp
  head/contrib/zstd/contrib/pzstd/ErrorHolder.h
  head/contrib/zstd/contrib/pzstd/Logging.h
  head/contrib/zstd/contrib/pzstd/Makefile
  head/contrib/zstd/contrib/pzstd/Options.cpp
  head/contrib/zstd/contrib/pzstd/Options.h
  head/contrib/zstd/contrib/pzstd/Pzstd.cpp
  head/contrib/zstd/contrib/pzstd/Pzstd.h
  head/contrib/zstd/contrib/pzstd/SkippableFrame.cpp
  head/contrib/zstd/contrib/pzstd/SkippableFrame.h
  head/contrib/zstd/contrib/pzstd/main.cpp
  head/contrib/zstd/contrib/pzstd/test/OptionsTest.cpp
  head/contrib/zstd/contrib/pzstd/test/PzstdTest.cpp
  head/contrib/zstd/contrib/pzstd/test/RoundTrip.h
  head/contrib/zstd/contrib/pzstd/test/RoundTripTest.cpp
  head/contrib/zstd/contrib/pzstd/utils/Buffer.h
  head/contrib/zstd/contrib/pzstd/utils/FileSystem.h
  head/contrib/zstd/contrib/pzstd/utils/Likely.h
  head/contrib/zstd/contrib/pzstd/utils/Range.h
  head/contrib/zstd/contrib/pzstd/utils/ResourcePool.h
  head/contrib/zstd/contrib/pzstd/utils/ScopeGuard.h
  head/contrib/zstd/contrib/pzstd/utils/ThreadPool.h
  head/contrib/zstd/contrib/pzstd/utils/WorkQueue.h
  head/contrib/zstd/contrib/pzstd/utils/test/BufferTest.cpp
  head/contrib/zstd/contrib/pzstd/utils/test/RangeTest.cpp
  head/contrib/zstd/contrib/pzstd/utils/test/ResourcePoolTest.cpp
  head/contrib/zstd/contrib/pzstd/utils/test/ScopeGuardTest.cpp
  head/contrib/zstd/contrib/pzstd/utils/test/ThreadPoolTest.cpp
  head/contrib/zstd/contrib/pzstd/utils/test/WorkQueueTest.cpp
  head/contrib/zstd/doc/educational_decoder/harness.c
  head/contrib/zstd/doc/educational_decoder/zstd_decompress.c
  head/contrib/zstd/doc/educational_decoder/zstd_decompress.h
  head/contrib/zstd/doc/zstd_manual.html
  head/contrib/zstd/lib/.gitignore
  head/contrib/zstd/lib/Makefile
  head/contrib/zstd/lib/README.md
  head/contrib/zstd/lib/common/bitstream.h
  head/contrib/zstd/lib/common/compiler.h
  head/contrib/zstd/lib/common/error_private.c
  head/contrib/zstd/lib/common/error_private.h
  head/contrib/zstd/lib/common/fse.h
  head/contrib/zstd/lib/common/huf.h
  head/contrib/zstd/lib/common/mem.h
  head/contrib/zstd/lib/common/pool.c
  head/contrib/zstd/lib/common/pool.h
  head/contrib/zstd/lib/

svn commit: r325714 - head/lib/libzstd

2017-11-11 Thread Baptiste Daroussin
Author: bapt
Date: Sat Nov 11 13:57:30 2017
New Revision: 325714
URL: https://svnweb.freebsd.org/changeset/base/325714

Log:
  Follow up on zstd update

Modified:
  head/lib/libzstd/Makefile

Modified: head/lib/libzstd/Makefile
==
--- head/lib/libzstd/Makefile   Sat Nov 11 13:54:37 2017(r325713)
+++ head/lib/libzstd/Makefile   Sat Nov 11 13:57:30 2017(r325714)
@@ -19,7 +19,12 @@ SRCS=entropy_common.c \
zbuff_decompress.c \
cover.c \
divsufsort.c \
-   zdict.c
+   zdict.c \
+   zstd_fast.c \
+   zstd_lazy.c \
+   zstd_ldm.c \
+   zstd_opt.c \
+   zstd_double_fast.c
 WARNS= 2
 INCS=  zstd.h
 CFLAGS+=   -I${ZSTDDIR}/lib -I${ZSTDDIR}/lib/common -DXXH_NAMESPACE=ZSTD_ \
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325715 - head/usr.bin/vmstat

2017-11-11 Thread Allan Jude
Author: allanjude
Date: Sat Nov 11 14:02:21 2017
New Revision: 325715
URL: https://svnweb.freebsd.org/changeset/base/325715

Log:
  vmstat: fix duplicate key in libxo output
  
  In the libxo output from vmstat, the number of pages that have been
  paged out uses the same key name as the number of times pages have been
  paged. Appears to have been a typo or copy-pasto.
  
  PR:   222198
  Submitted by: Yavuz Tanriverdi 
  Reviewed by:  phil, garga
  Differential Revision:https://reviews.freebsd.org/D12395

Modified:
  head/usr.bin/vmstat/vmstat.c

Modified: head/usr.bin/vmstat/vmstat.c
==
--- head/usr.bin/vmstat/vmstat.cSat Nov 11 13:57:30 2017
(r325714)
+++ head/usr.bin/vmstat/vmstat.cSat Nov 11 14:02:21 2017
(r325715)
@@ -1059,7 +1059,7 @@ dosum(void)
sum.v_vnodepgsin);
xo_emit("{:vnode-page-outs/%9u} {N:vnode pager pageouts}\n",
sum.v_vnodeout);
-   xo_emit("{:vnode-page-outs/%9u} {N:vnode pager pages paged out}\n",
+   xo_emit("{:vnode-page-out-pages/%9u} {N:vnode pager pages paged out}\n",
sum.v_vnodepgsout);
xo_emit("{:page-daemon-wakeups/%9u} {N:page daemon wakeups}\n",
sum.v_pdwakeups);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325716 - head/lib/libutil

2017-11-11 Thread Baptiste Daroussin
Author: bapt
Date: Sat Nov 11 14:39:13 2017
New Revision: 325716
URL: https://svnweb.freebsd.org/changeset/base/325716

Log:
  Fix some nroff style issue
  
  MFC after:3 days

Modified:
  head/lib/libutil/hexdump.3

Modified: head/lib/libutil/hexdump.3
==
--- head/lib/libutil/hexdump.3  Sat Nov 11 14:02:21 2017(r325715)
+++ head/lib/libutil/hexdump.3  Sat Nov 11 14:39:13 2017(r325716)
@@ -42,14 +42,9 @@
 The
 .Fn hexdump
 function prints an array of bytes to standard out in hexadecimal form,
-along with the
-.Tn ASCII
-representation of the bytes, if possible.
-By default, each line of
-output will start with an offset count, followed by 16 hexadecimal values,
-followed by 16
-.Tn ASCII
-characters.
+along with the ASCII representation of the bytes, if possible.
+By default, each line of output will start with an offset count, followed by 16
+hexadecimal values, followed by 16 ASCII characters.
 .Bl -tag -width indent
 .It Fa ptr
 Pointer to the array of bytes to print.
@@ -73,12 +68,10 @@ Flags for controlling the formatting of the output.
 Integer value of the number of bytes to display on each line.
 A value of 0 implies that the default value of 16 will be used.
 .It Bits 8-15
-Character
-.Tn ASCII
-value to use as the separator for the hexadecimal output.
+Character ASCII value to use as the separator for the hexadecimal output.
 A value of 0 implies that the default value of 32
-.Tn ( ASCII
-space) will be used.
+.Pq ASCII space
+will be used.
 .It Dv HD_OMIT_COUNT
 Do not print the offset column at the beginning of each line.
 .It Dv HD_OMIT_HEX
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r325693 - in head: . share/mk sys/boot sys/boot/geli sys/boot/i386/gptboot sys/boot/i386/gptzfsboot sys/boot/i386/libi386 sys/boot/i386/loader sys/boot/i386/zfsboot sys/boot/i386/zfslo

2017-11-11 Thread Shawn Webb
On Fri, Nov 10, 2017 at 11:54:48PM +, Warner Losh wrote:
> Author: imp
> Date: Fri Nov 10 23:54:48 2017
> New Revision: 325693
> URL: https://svnweb.freebsd.org/changeset/base/325693
> 
> Log:
>   Move LOADER_{NO,}_GELI_SUPPORT to MK_LOADER_GELI
>   
>   Transition to WITH/WITHOUT_LOADER_GELI to flag support or not of GELI
>   in the boot loaders. Add HAVE_GELI so components can flag they need
>   support (since it's too large to include everywhere). Add temporary
>   warnings for the old forms to ease transition.
>   
>   Also, update test script to build without GELI on x86.
>   
>   Sponsored by: Netflix
> 
> Added:
>   head/tools/build/options/WITHOUT_LOADER_GEIL   (contents, props changed)

Should this be tools/build/options/WITHOUT_LOADER_GELI instead?

Thanks,

-- 
Shawn Webb
Cofounder and Security Engineer
HardenedBSD

GPG Key ID:  0x6A84658F52456EEE
GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89  3D9E 6A84 658F 5245 6EEE


signature.asc
Description: PGP signature


svn commit: r325717 - head/usr.bin/rctl

2017-11-11 Thread Baptiste Daroussin
Author: bapt
Date: Sat Nov 11 15:18:25 2017
New Revision: 325717
URL: https://svnweb.freebsd.org/changeset/base/325717

Log:
  Remove __unused attributed on arguments that are actually used
  
  MFC after:3 days

Modified:
  head/usr.bin/rctl/rctl.c

Modified: head/usr.bin/rctl/rctl.c
==
--- head/usr.bin/rctl/rctl.cSat Nov 11 14:39:13 2017(r325716)
+++ head/usr.bin/rctl/rctl.cSat Nov 11 15:18:25 2017(r325717)
@@ -586,7 +586,7 @@ usage(void)
 }
 
 int
-main(int argc __unused, char **argv __unused)
+main(int argc, char **argv)
 {
int ch, aflag = 0, hflag = 0, nflag = 0, lflag = 0, rflag = 0,
uflag = 0;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r325693 - in head: . share/mk sys/boot sys/boot/geli sys/boot/i386/gptboot sys/boot/i386/gptzfsboot sys/boot/i386/libi386 sys/boot/i386/loader sys/boot/i386/zfsboot sys/boot/i386/zfslo

2017-11-11 Thread Warner Losh
On Sat, Nov 11, 2017 at 7:47 AM, Shawn Webb 
wrote:

> On Fri, Nov 10, 2017 at 11:54:48PM +, Warner Losh wrote:
> > Author: imp
> > Date: Fri Nov 10 23:54:48 2017
> > New Revision: 325693
> > URL: https://svnweb.freebsd.org/changeset/base/325693
> >
> > Log:
> >   Move LOADER_{NO,}_GELI_SUPPORT to MK_LOADER_GELI
> >
> >   Transition to WITH/WITHOUT_LOADER_GELI to flag support or not of GELI
> >   in the boot loaders. Add HAVE_GELI so components can flag they need
> >   support (since it's too large to include everywhere). Add temporary
> >   warnings for the old forms to ease transition.
> >
> >   Also, update test script to build without GELI on x86.
> >
> >   Sponsored by: Netflix
> >
> > Added:
> >   head/tools/build/options/WITHOUT_LOADER_GEIL   (contents, props
> changed)
>
> Should this be tools/build/options/WITHOUT_LOADER_GELI instead?
>

Yes.

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


svn commit: r325718 - head/tools/build/options

2017-11-11 Thread Warner Losh
Author: imp
Date: Sat Nov 11 16:09:20 2017
New Revision: 325718
URL: https://svnweb.freebsd.org/changeset/base/325718

Log:
  Fix typo in filename.
  
  Noticed by: Shawn Webb

Added:
  head/tools/build/options/WITHOUT_LOADER_GELI   (contents, props changed)
 - copied, changed from r325694, 
head/tools/build/options/WITHOUT_LOADER_GEIL
Deleted:
  head/tools/build/options/WITHOUT_LOADER_GEIL

Copied and modified: head/tools/build/options/WITHOUT_LOADER_GELI (from 
r325694, head/tools/build/options/WITHOUT_LOADER_GEIL)
==
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r325705 - head/secure

2017-11-11 Thread Bryan Drewery
On 11/10/17 11:21 PM, Eitan Adler wrote:
> Author: eadler
> Date: Sat Nov 11 07:21:49 2017
> New Revision: 325705
> URL: https://svnweb.freebsd.org/changeset/base/325705
> 
> Log:
>   secure: chase removal of pkg_install
> 
> Modified:
>   head/secure/Makefile
> 
> Modified: head/secure/Makefile
> ==
> --- head/secure/Makefile  Sat Nov 11 07:20:14 2017(r325704)
> +++ head/secure/Makefile  Sat Nov 11 07:21:49 2017(r325705)
> @@ -11,7 +11,7 @@ SUBDIR.${MK_TESTS}+= tests
>  # These are the programs which depend on crypto, but not Kerberos.
>  SPROGS=  lib/libfetch lib/libpam lib/libradius lib/libtelnet \
>   bin/ed libexec/telnetd usr.bin/fetch usr.bin/telnet \
> - usr.sbin/pkg_install usr.sbin/ppp usr.sbin/tcpdump/tcpdump
> + usr.sbin/ppp usr.sbin/tcpdump/tcpdump
>  .if ${MK_SENDMAIL} != "no"
>  SPROGS+=usr.sbin/sendmail
>  .endif
> 

This whole list and target seems outdated. IMHO it should all be removed.

-- 
Regards,
Bryan Drewery



signature.asc
Description: OpenPGP digital signature


svn commit: r325719 - head/sys/kern

2017-11-11 Thread Mateusz Guzik
Author: mjg
Date: Sat Nov 11 18:02:23 2017
New Revision: 325719
URL: https://svnweb.freebsd.org/changeset/base/325719

Log:
  Remove useless proc lookup from sysctl_out_proc

Modified:
  head/sys/kern/kern_proc.c

Modified: head/sys/kern/kern_proc.c
==
--- head/sys/kern/kern_proc.c   Sat Nov 11 16:09:20 2017(r325718)
+++ head/sys/kern/kern_proc.c   Sat Nov 11 18:02:23 2017(r325719)
@@ -1369,16 +1369,12 @@ kern_proc_out(struct proc *p, struct sbuf *sb, int fla
 }
 
 static int
-sysctl_out_proc(struct proc *p, struct sysctl_req *req, int flags,
-int doingzomb)
+sysctl_out_proc(struct proc *p, struct sysctl_req *req, int flags)
 {
struct sbuf sb;
struct kinfo_proc ki;
-   struct proc *np;
int error, error2;
-   pid_t pid;
 
-   pid = p->p_pid;
sbuf_new_for_sysctl(&sb, (char *)&ki, sizeof(ki), req);
sbuf_clear_flags(&sb, SBUF_INCLUDENUL);
error = kern_proc_out(p, &sb, flags);
@@ -1388,20 +1384,6 @@ sysctl_out_proc(struct proc *p, struct sysctl_req *req
return (error);
else if (error2 != 0)
return (error2);
-   if (doingzomb)
-   np = zpfind(pid);
-   else {
-   if (pid == 0)
-   return (0);
-   np = pfind(pid);
-   }
-   if (np == NULL)
-   return (ESRCH);
-   if (np != p) {
-   PROC_UNLOCK(np);
-   return (ESRCH);
-   }
-   PROC_UNLOCK(np);
return (0);
 }
 
@@ -1435,7 +1417,7 @@ sysctl_kern_proc(SYSCTL_HANDLER_ARGS)
sx_slock(&proctree_lock);
error = pget((pid_t)name[0], PGET_CANSEE, &p);
if (error == 0)
-   error = sysctl_out_proc(p, req, flags, 0);
+   error = sysctl_out_proc(p, req, flags);
sx_sunlock(&proctree_lock);
return (error);
}
@@ -1566,7 +1548,7 @@ sysctl_kern_proc(SYSCTL_HANDLER_ARGS)
 
}
 
-   error = sysctl_out_proc(p, req, flags, doingzomb);
+   error = sysctl_out_proc(p, req, flags);
if (error) {
sx_sunlock(&allproc_lock);
sx_sunlock(&proctree_lock);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325720 - head/sys/kern

2017-11-11 Thread Mateusz Guzik
Author: mjg
Date: Sat Nov 11 18:03:26 2017
New Revision: 325720
URL: https://svnweb.freebsd.org/changeset/base/325720

Log:
  Avoid allproc lock in pfind if curproc->pid == pid

Modified:
  head/sys/kern/kern_proc.c

Modified: head/sys/kern/kern_proc.c
==
--- head/sys/kern/kern_proc.c   Sat Nov 11 18:02:23 2017(r325719)
+++ head/sys/kern/kern_proc.c   Sat Nov 11 18:03:26 2017(r325720)
@@ -342,6 +342,11 @@ pfind(pid_t pid)
 {
struct proc *p;
 
+   p = curproc;
+   if (p->p_pid == pid) {
+   PROC_LOCK(p);
+   return (p);
+   }
sx_slock(&allproc_lock);
p = pfind_locked(pid);
sx_sunlock(&allproc_lock);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325721 - in head/sys: kern sys

2017-11-11 Thread Mateusz Guzik
Author: mjg
Date: Sat Nov 11 18:04:39 2017
New Revision: 325721
URL: https://svnweb.freebsd.org/changeset/base/325721

Log:
  Add pfind_any
  
  It looks for both regular and zombie processes. This avoids allproc relocking
  previously seen with pfind -> zpfind calls.

Modified:
  head/sys/kern/kern_event.c
  head/sys/kern/kern_proc.c
  head/sys/kern/kern_sig.c
  head/sys/sys/proc.h

Modified: head/sys/kern/kern_event.c
==
--- head/sys/kern/kern_event.c  Sat Nov 11 18:03:26 2017(r325720)
+++ head/sys/kern/kern_event.c  Sat Nov 11 18:04:39 2017(r325721)
@@ -406,16 +406,15 @@ filt_procattach(struct knote *kn)
bool exiting, immediate;
 
exiting = immediate = false;
-   p = pfind(kn->kn_id);
-   if (p == NULL && (kn->kn_sfflags & NOTE_EXIT)) {
-   p = zpfind(kn->kn_id);
-   exiting = true;
-   } else if (p != NULL && (p->p_flag & P_WEXIT)) {
-   exiting = true;
-   }
-
+   if (kn->kn_sfflags & NOTE_EXIT)
+   p = pfind_any(kn->kn_id);
+   else
+   p = pfind(kn->kn_id);
if (p == NULL)
return (ESRCH);
+   if (p->p_flag & P_WEXIT)
+   exiting = true;
+
if ((error = p_cansee(curthread, p))) {
PROC_UNLOCK(p);
return (error);

Modified: head/sys/kern/kern_proc.c
==
--- head/sys/kern/kern_proc.c   Sat Nov 11 18:03:26 2017(r325720)
+++ head/sys/kern/kern_proc.c   Sat Nov 11 18:04:39 2017(r325721)
@@ -353,6 +353,23 @@ pfind(pid_t pid)
return (p);
 }
 
+/*
+ * Same as pfind but allow zombies.
+ */
+struct proc *
+pfind_any(pid_t pid)
+{
+   struct proc *p;
+
+   sx_slock(&allproc_lock);
+   p = pfind_locked(pid);
+   if (p == NULL)
+   p = zpfind_locked(pid);
+   sx_sunlock(&allproc_lock);
+
+   return (p);
+}
+
 static struct proc *
 pfind_tid_locked(pid_t tid)
 {

Modified: head/sys/kern/kern_sig.c
==
--- head/sys/kern/kern_sig.cSat Nov 11 18:03:26 2017(r325720)
+++ head/sys/kern/kern_sig.cSat Nov 11 18:04:39 2017(r325721)
@@ -1765,10 +1765,8 @@ sys_kill(struct thread *td, struct kill_args *uap)
 
if (uap->pid > 0) {
/* kill single process */
-   if ((p = pfind(uap->pid)) == NULL) {
-   if ((p = zpfind(uap->pid)) == NULL)
-   return (ESRCH);
-   }
+   if ((p = pfind_any(uap->pid)) == NULL)
+   return (ESRCH);
AUDIT_ARG_PROCESS(p);
error = p_cansignal(td, p, uap->signum);
if (error == 0 && uap->signum)

Modified: head/sys/sys/proc.h
==
--- head/sys/sys/proc.h Sat Nov 11 18:03:26 2017(r325720)
+++ head/sys/sys/proc.h Sat Nov 11 18:04:39 2017(r325721)
@@ -954,6 +954,7 @@ extern struct proc *initproc, *pageproc; /* Process sl
 extern struct uma_zone *proc_zone;
 
 struct proc *pfind(pid_t); /* Find process by id. */
+struct proc *pfind_any(pid_t); /* Find (zombie) process by id. */
 struct proc *pfind_locked(pid_t pid);
 struct pgrp *pgfind(pid_t);/* Find process group by id. */
 struct proc *zpfind(pid_t);/* Find zombie process by id. */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r325705 - head/secure

2017-11-11 Thread Eitan Adler
On 11 November 2017 at 09:21, Bryan Drewery  wrote:
> On 11/10/17 11:21 PM, Eitan Adler wrote:
>> Author: eadler
>> Date: Sat Nov 11 07:21:49 2017
>> New Revision: 325705
>> URL: https://svnweb.freebsd.org/changeset/base/325705
>>
>> Log:
>>   secure: chase removal of pkg_install
>>
>> Modified:
>>   head/secure/Makefile
>>
>> Modified: head/secure/Makefile
>> ==
>> --- head/secure/Makefile  Sat Nov 11 07:20:14 2017(r325704)
>> +++ head/secure/Makefile  Sat Nov 11 07:21:49 2017(r325705)
>> @@ -11,7 +11,7 @@ SUBDIR.${MK_TESTS}+= tests
>>  # These are the programs which depend on crypto, but not Kerberos.
>>  SPROGS=  lib/libfetch lib/libpam lib/libradius lib/libtelnet \
>>   bin/ed libexec/telnetd usr.bin/fetch usr.bin/telnet \
>> - usr.sbin/pkg_install usr.sbin/ppp usr.sbin/tcpdump/tcpdump
>> + usr.sbin/ppp usr.sbin/tcpdump/tcpdump
>>  .if ${MK_SENDMAIL} != "no"
>>  SPROGS+=usr.sbin/sendmail
>>  .endif
>>
>
> This whole list and target seems outdated. IMHO it should all be removed.

Not opposed but given chesterson's fence I wanted to be more minimal
right now.  Feel free to go further than I did :)



-- 
Eitan Adler
Source, Ports, Doc committer
Bugmeister, Ports Security teams
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325722 - in head/sys: compat/linux kern

2017-11-11 Thread Mateusz Guzik
Author: mjg
Date: Sat Nov 11 18:10:09 2017
New Revision: 325722
URL: https://svnweb.freebsd.org/changeset/base/325722

Log:
  Use pfind_any in linux_rt_sigqueueinfo and kern_sigqueue

Modified:
  head/sys/compat/linux/linux_signal.c
  head/sys/kern/kern_sig.c

Modified: head/sys/compat/linux/linux_signal.c
==
--- head/sys/compat/linux/linux_signal.cSat Nov 11 18:04:39 2017
(r325721)
+++ head/sys/compat/linux/linux_signal.cSat Nov 11 18:10:09 2017
(r325722)
@@ -748,8 +748,7 @@ linux_rt_sigqueueinfo(struct thread *td, struct linux_
sig = linux_to_bsd_signal(args->sig);
 
error = ESRCH;
-   if ((p = pfind(args->pid)) != NULL ||
-   (p = zpfind(args->pid)) != NULL) {
+   if ((p = pfind_any(args->pid)) != NULL) {
error = p_cansignal(td, p, sig);
if (error != 0) {
PROC_UNLOCK(p);

Modified: head/sys/kern/kern_sig.c
==
--- head/sys/kern/kern_sig.cSat Nov 11 18:04:39 2017(r325721)
+++ head/sys/kern/kern_sig.cSat Nov 11 18:10:09 2017(r325722)
@@ -1870,10 +1870,8 @@ kern_sigqueue(struct thread *td, pid_t pid, int signum
if (pid <= 0)
return (EINVAL);
 
-   if ((p = pfind(pid)) == NULL) {
-   if ((p = zpfind(pid)) == NULL)
-   return (ESRCH);
-   }
+   if ((p = pfind_any(pid)) == NULL)
+   return (ESRCH);
error = p_cansignal(td, p, signum);
if (error == 0 && signum != 0) {
ksiginfo_init(&ksi);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325723 - head/usr.bin/find

2017-11-11 Thread Xin LI
Author: delphij
Date: Sat Nov 11 19:18:47 2017
New Revision: 325723
URL: https://svnweb.freebsd.org/changeset/base/325723

Log:
  find(1): Don't treat statfs() error as fatal in f_fstype, which can happen
  when a directory is removed in the middle of find.
  
  Instead of a full err(), allow find to continue, plus print a warning with
  exitstatus set when appropriate.
  
  Reported by:  100.chksetuid via gordon
  Reviewed by:  jilles
  MFC after:1 month
  Differential Revision:https://reviews.freebsd.org/D13024

Modified:
  head/usr.bin/find/function.c

Modified: head/usr.bin/find/function.c
==
--- head/usr.bin/find/function.cSat Nov 11 18:10:09 2017
(r325722)
+++ head/usr.bin/find/function.cSat Nov 11 19:18:47 2017
(r325723)
@@ -902,8 +902,13 @@ f_fstype(PLAN *plan, FTSENT *entry)
} else
p = NULL;
 
-   if (statfs(entry->fts_accpath, &sb))
-   err(1, "%s", entry->fts_accpath);
+   if (statfs(entry->fts_accpath, &sb)) {
+   if (!ignore_readdir_race || errno != ENOENT) {
+   warn("statfs: %s", entry->fts_accpath);
+   exitstatus = 1;
+   }
+   return 0;
+   }
 
if (p) {
p[0] = save[0];
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r325702 - in head: . share/man/man5 share/man/man7 usr.bin/mail

2017-11-11 Thread Rodney W. Grimes
> Author: eadler
> Date: Sat Nov 11 07:00:40 2017
> New Revision: 325702
> URL: https://svnweb.freebsd.org/changeset/base/325702
> 
> Log:
>   mailaddr(7): wave goodbye
>   
>   The information here is somewhere between ancient to obsolete.

20% of the information here is somewhat obsolete, 80% of it is 
valid, can you please tell me what part of the following main
body of the page are either ancient or obsolete:

Begin man page sectoin
DESCRIPTION
 Mail addresses are based on the Internet protocol listed at the end of
 this manual page.  These addresses are in the general format

   user@domain

 where a domain is a hierarchical dot separated list of subdomains.  For
 example, a valid address is:

   e...@cs.berkeley.edu

 Unlike some other forms of addressing, domains do not imply any routing.
 Thus, although this address is specified as an Internet address, it might
 travel by an alternate route if that were more convenient or efficient.
 For example, at Berkeley, the associated message would probably go
 directly to CS over the Ethernet rather than going via the Berkeley
 Internet gateway.

   Abbreviation.
 Under certain circumstances it may not be necessary to type the entire
 domain name.  In general, anything following the first dot may be omitted
 if it is the same as the domain from which you are sending the message.
 For example, a user on ``calder.berkeley.edu'' could send to ``eric@CS''
 without adding the ``berkeley.edu'' since it is the same on both sending
 and receiving hosts.

End man page secton.


>   It refers to a time in the internet's history when manual routing
>   was still useful, talks about UUCP as if its modern, and refers
>   to documents which I had trouble tracking down.

A TINY part of it refered to UUCP and berknet, so rather than simply
correct the 20% of the one file you removed the 80% valid information
and touched  5 other files.  Thus, imho, does not move the state of
FreeBSD forward.
>   
>   It seems unlikely that a manual page in this form would be useful, so
>   just remove it.

I think the information that was correct would be usefull to a new
person to internet mail address formats.   I think even bdrewey
commented in the Differential that he learned a lot from reading
this man page.  

>   
>   Reviewed By: imp, tsoome, bdrewery(?)
>   Differential Revision: https://reviews.freebsd.org/D12924

You might of wanted to get a docs/manpage reviewer before commit.

> 
> Deleted:
>   head/share/man/man7/mailaddr.7
> Modified:
>   head/ObsoleteFiles.inc
>   head/share/man/man5/forward.5
>   head/share/man/man7/Makefile
>   head/share/man/man7/hostname.7
>   head/usr.bin/mail/mail.1
> 
> Modified: head/ObsoleteFiles.inc


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


svn commit: r325724 - head/sys/dev/vt

2017-11-11 Thread Hans Petter Selasky
Author: hselasky
Date: Sat Nov 11 20:12:48 2017
New Revision: 325724
URL: https://svnweb.freebsd.org/changeset/base/325724

Log:
  Implement missing KDGETMODE IOCTL in VT.
  
  Obtained from:Johannes Lundberg 
  Sponsored by: Mellanox Technologies
  MFC after:1 week

Modified:
  head/sys/dev/vt/vt_core.c

Modified: head/sys/dev/vt/vt_core.c
==
--- head/sys/dev/vt/vt_core.c   Sat Nov 11 19:18:47 2017(r325723)
+++ head/sys/dev/vt/vt_core.c   Sat Nov 11 20:12:48 2017(r325724)
@@ -2161,6 +2161,10 @@ skip_thunk:
 
return (error);
}
+   case KDGETMODE:
+   *(int *)data = (vw->vw_flags & VWF_GRAPHICS) ?
+   KD_GRAPHICS : KD_TEXT;
+   return (0);
case KDGKBMODE: {
error = 0;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325725 - head/sys/kern

2017-11-11 Thread Mateusz Guzik
Author: mjg
Date: Sat Nov 11 21:50:36 2017
New Revision: 325725
URL: https://svnweb.freebsd.org/changeset/base/325725

Log:
  sysctl: try to avoid malloc in name2oid
  
  name2oid is called all the time and passed names are almost always very short
  (< 16 characters).

Modified:
  head/sys/kern/kern_sysctl.c

Modified: head/sys/kern/kern_sysctl.c
==
--- head/sys/kern/kern_sysctl.c Sat Nov 11 20:12:48 2017(r325724)
+++ head/sys/kern/kern_sysctl.c Sat Nov 11 21:50:36 2017(r325725)
@@ -1209,17 +1209,21 @@ sysctl_sysctl_name2oid(SYSCTL_HANDLER_ARGS)
int error, oid[CTL_MAXNAME], len = 0;
struct sysctl_oid *op = NULL;
struct rm_priotracker tracker;
+   char buf[32];
 
if (!req->newlen) 
return (ENOENT);
if (req->newlen >= MAXPATHLEN)  /* XXX arbitrary, undocumented */
return (ENAMETOOLONG);
 
-   p = malloc(req->newlen+1, M_SYSCTL, M_WAITOK);
+   p = buf;
+   if (req->newlen >= sizeof(buf))
+   p = malloc(req->newlen+1, M_SYSCTL, M_WAITOK);
 
error = SYSCTL_IN(req, p, req->newlen);
if (error) {
-   free(p, M_SYSCTL);
+   if (p != buf)
+   free(p, M_SYSCTL);
return (error);
}
 
@@ -1229,7 +1233,8 @@ sysctl_sysctl_name2oid(SYSCTL_HANDLER_ARGS)
error = name2oid(p, oid, &len, &op);
SYSCTL_RUNLOCK(&tracker);
 
-   free(p, M_SYSCTL);
+   if (p != buf)
+   free(p, M_SYSCTL);
 
if (error)
return (error);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2017-11-11 Thread Hans Petter Selasky

On 11/11/17 22:50, Mateusz Guzik wrote:

Author: mjg
Date: Sat Nov 11 21:50:36 2017
New Revision: 325725
URL: https://svnweb.freebsd.org/changeset/base/325725

Log:
   sysctl: try to avoid malloc in name2oid
   
   name2oid is called all the time and passed names are almost always very short

   (< 16 characters).



Might be good to MFC.

--HPS

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


svn commit: r325726 - head/sys/kern

2017-11-11 Thread Mateusz Guzik
Author: mjg
Date: Sat Nov 11 22:39:33 2017
New Revision: 325726
URL: https://svnweb.freebsd.org/changeset/base/325726

Log:
  Avoid locking and refing in sysctl_kern_proc_args if possible.
  
  Turns out the sysctl is called a lot e.g. by pkg-static.

Modified:
  head/sys/kern/kern_proc.c

Modified: head/sys/kern/kern_proc.c
==
--- head/sys/kern/kern_proc.c   Sat Nov 11 21:50:36 2017(r325725)
+++ head/sys/kern/kern_proc.c   Sat Nov 11 22:39:33 2017(r325726)
@@ -1909,14 +1909,27 @@ sysctl_kern_proc_args(SYSCTL_HANDLER_ARGS)
struct proc *p;
struct sbuf sb;
int flags, error = 0, error2;
+   pid_t pid;
 
if (namelen != 1)
return (EINVAL);
 
+   pid = (pid_t)name[0];
+   /*
+* If the query is for this process and it is single-threaded, there
+* is nobody to modify pargs, thus we can just read.
+*/
+   p = curproc;
+   if (pid == p->p_pid && p->p_numthreads == 1 && req->newptr == NULL) {
+   if ((pa = p->p_args) != NULL)
+   error = SYSCTL_OUT(req, pa->ar_args, pa->ar_length);
+   return (error);
+   }
+
flags = PGET_CANSEE;
if (req->newptr != NULL)
flags |= PGET_ISCURRENT;
-   error = pget((pid_t)name[0], flags, &p);
+   error = pget(pid, flags, &p);
if (error)
return (error);
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2017-11-11 Thread Bartek Rutkowski
Author: robak (ports committer)
Date: Sat Nov 11 22:50:14 2017
New Revision: 325727
URL: https://svnweb.freebsd.org/changeset/base/325727

Log:
  bhyve: avoid applying capsicum capabilities to file that was not opened
  
  When using -l option targeting file that can't be opened (ie. nmdm module
  is not loaded and /dev/nmdm* is specified) bhyve tries to apply capsicum
  capabilities to a file that was not opened.
  
  Enclose that code in an if statement and only run it on correctly opened
  descriptor also providing meaningful message in case of an error.
  
  Submitted by: Pawel Biernacki 
  Reviewed by:  grehan, emaste
  Sponsoied by: Mysterious Code Ltd.
  Differential Revision:D12985

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

Modified: head/usr.sbin/bhyve/uart_emul.c
==
--- head/usr.sbin/bhyve/uart_emul.c Sat Nov 11 22:39:33 2017
(r325726)
+++ head/usr.sbin/bhyve/uart_emul.c Sat Nov 11 22:50:14 2017
(r325727)
@@ -678,20 +678,24 @@ uart_set_backend(struct uart_softc *sc, const char *op
if (retval == 0)
retval = fcntl(sc->tty.fd, F_SETFL, O_NONBLOCK);
 
+   if (retval == 0) {
 #ifndef WITHOUT_CAPSICUM
-   cap_rights_init(&rights, CAP_EVENT, CAP_IOCTL, CAP_READ, CAP_WRITE);
-   if (cap_rights_limit(sc->tty.fd, &rights) == -1 && errno != ENOSYS)
-   errx(EX_OSERR, "Unable to apply rights for sandbox");
-   if (cap_ioctls_limit(sc->tty.fd, cmds, nitems(cmds)) == -1 && errno != 
ENOSYS)
-   errx(EX_OSERR, "Unable to apply rights for sandbox");
-   if (!uart_stdio) {
-   if (caph_limit_stdin() == -1 && errno != ENOSYS)
+   cap_rights_init(&rights, CAP_EVENT, CAP_IOCTL, CAP_READ,
+   CAP_WRITE);
+   if (cap_rights_limit(sc->tty.fd, &rights) == -1 &&
+   errno != ENOSYS)
errx(EX_OSERR, "Unable to apply rights for sandbox");
-   }
+   if (cap_ioctls_limit(sc->tty.fd, cmds, nitems(cmds)) == -1 &&
+   errno != ENOSYS)
+   errx(EX_OSERR, "Unable to apply rights for sandbox");
+   if (!uart_stdio) {
+   if (caph_limit_stdin() == -1 && errno != ENOSYS)
+   errx(EX_OSERR,
+   "Unable to apply rights for sandbox");
+   }
 #endif
-
-   if (retval == 0)
uart_opentty(sc);
+   }
 
return (retval);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325728 - head/lib/libkvm

2017-11-11 Thread Will Andrews
Author: will
Date: Sat Nov 11 23:30:58 2017
New Revision: 325728
URL: https://svnweb.freebsd.org/changeset/base/325728

Log:
  libkvm: add kvm_walk_pages API.
  
  This API allows callers to enumerate all known pages, including any
  direct map & kernel map virtual addresses, physical addresses, size,
  offset into the core, & protection configured.
  
  For architectures that support direct map addresses, also generate pages
  for any direct map only addresses that are not associated with kernel
  map addresses.
  
  Fix page size portability issue left behind from previous kvm page table
  lookup interface.
  
  Reviewed by:  jhb
  Sponsored by: Backtrace I/O
  Differential Revision:https://reviews.freebsd.org/D12279

Modified:
  head/lib/libkvm/kvm.c
  head/lib/libkvm/kvm.h
  head/lib/libkvm/kvm_aarch64.h
  head/lib/libkvm/kvm_arm.h
  head/lib/libkvm/kvm_i386.h
  head/lib/libkvm/kvm_minidump_aarch64.c
  head/lib/libkvm/kvm_minidump_amd64.c
  head/lib/libkvm/kvm_minidump_arm.c
  head/lib/libkvm/kvm_minidump_i386.c
  head/lib/libkvm/kvm_minidump_mips.c
  head/lib/libkvm/kvm_mips.h
  head/lib/libkvm/kvm_private.c
  head/lib/libkvm/kvm_private.h

Modified: head/lib/libkvm/kvm.c
==
--- head/lib/libkvm/kvm.c   Sat Nov 11 22:50:14 2017(r325727)
+++ head/lib/libkvm/kvm.c   Sat Nov 11 23:30:58 2017(r325728)
@@ -49,6 +49,7 @@ static char sccsid[] = "@(#)kvm.c 8.2 (Berkeley) 2/13/
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -299,6 +300,10 @@ kvm_close(kvm_t *kd)
free((void *)kd->argv);
if (kd->pt_map != NULL)
free(kd->pt_map);
+   if (kd->page_map != NULL)
+   free(kd->page_map);
+   if (kd->sparse_map != MAP_FAILED)
+   munmap(kd->sparse_map, kd->pt_sparse_size);
free((void *)kd);
 
return (error);
@@ -486,4 +491,14 @@ kvm_native(kvm_t *kd)
if (ISALIVE(kd))
return (1);
return (kd->arch->ka_native(kd));
+}
+
+int
+kvm_walk_pages(kvm_t *kd, kvm_walk_pages_cb_t *cb, void *closure)
+{
+
+   if (kd->arch->ka_walk_pages == NULL)
+   return (0);
+
+   return (kd->arch->ka_walk_pages(kd, cb, closure));
 }

Modified: head/lib/libkvm/kvm.h
==
--- head/lib/libkvm/kvm.h   Sat Nov 11 22:50:14 2017(r325727)
+++ head/lib/libkvm/kvm.h   Sat Nov 11 23:30:58 2017(r325728)
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* Default version symbol. */
 #defineVRS_SYM "_version"
@@ -73,7 +74,19 @@ struct kvm_swap {
u_int   ksw_reserved2;
 };
 
+struct kvm_page {
+   unsigned int version;
+   u_long paddr;
+   u_long kmap_vaddr;
+   u_long dmap_vaddr;
+   vm_prot_t prot;
+   u_long offset;
+   size_t len;
+   /* end of version 1 */
+};
+
 #define SWIF_DEV_PREFIX0x0002
+#defineLIBKVM_WALK_PAGES_VERSION   1
 
 __BEGIN_DECLS
 int  kvm_close(kvm_t *);
@@ -104,6 +117,9 @@ ssize_t   kvm_read(kvm_t *, unsigned long, void *, siz
 ssize_t  kvm_read_zpcpu(kvm_t *, unsigned long, void *, size_t, int);
 ssize_t  kvm_read2(kvm_t *, kvaddr_t, void *, size_t);
 ssize_t  kvm_write(kvm_t *, unsigned long, const void *, size_t);
+
+typedef int kvm_walk_pages_cb_t(struct kvm_page *, void *);
+int kvm_walk_pages(kvm_t *, kvm_walk_pages_cb_t *, void *);
 __END_DECLS
 
 #endif /* !_KVM_H_ */

Modified: head/lib/libkvm/kvm_aarch64.h
==
--- head/lib/libkvm/kvm_aarch64.h   Sat Nov 11 22:50:14 2017
(r325727)
+++ head/lib/libkvm/kvm_aarch64.h   Sat Nov 11 23:30:58 2017
(r325728)
@@ -40,7 +40,13 @@ typedef uint64_t aarch64_pte_t;
 #defineAARCH64_PAGE_SIZE   (1 << AARCH64_PAGE_SHIFT)
 #defineAARCH64_PAGE_MASK   (AARCH64_PAGE_SIZE - 1)
 
+/* Source: arm64/include/pte.h */
 #defineAARCH64_ATTR_MASK   0xfff00fff
+#defineAARCH64_ATTR_UXN(1UL << 54)
+#defineAARCH64_ATTR_PXN(1UL << 53)
+#defineAARCH64_ATTR_XN (AARCH64_ATTR_PXN | AARCH64_ATTR_UXN)
+#defineAARCH64_ATTR_AP(x)  ((x) << 6)
+#defineAARCH64_ATTR_AP_RO  (1 << 1)
 
 #defineAARCH64_ATTR_DESCR_MASK 3
 

Modified: head/lib/libkvm/kvm_arm.h
==
--- head/lib/libkvm/kvm_arm.h   Sat Nov 11 22:50:14 2017(r325727)
+++ head/lib/libkvm/kvm_arm.h   Sat Nov 11 23:30:58 2017(r325728)
@@ -53,6 +53,19 @@ typedef uint32_t arm_pt_entry_t;
 #defineARM_L2_S_OFFSET (ARM_L2_S_SIZE - 1)
 #defineARM_L2_S_FRAME  (~ARM_L2_S_OFFSET)
 #defineARM_L2_S_SHIFT  12
+#defineARM_L2_TEX1 0x0080
+#define   

svn commit: r325729 - head/lib/libkvm

2017-11-11 Thread Will Andrews
Author: will
Date: Sun Nov 12 00:00:38 2017
New Revision: 325729
URL: https://svnweb.freebsd.org/changeset/base/325729

Log:
  libkvm: fix 'index' shadowing.

Modified:
  head/lib/libkvm/kvm_private.c

Modified: head/lib/libkvm/kvm_private.c
==
--- head/lib/libkvm/kvm_private.c   Sat Nov 11 23:30:58 2017
(r325728)
+++ head/lib/libkvm/kvm_private.c   Sun Nov 12 00:00:38 2017
(r325729)
@@ -261,9 +261,9 @@ popcount_bytes(uint64_t *addr, uint32_t bit0, uint32_t
 }
 
 void *
-_kvm_pmap_get(kvm_t *kd, u_long index, size_t len)
+_kvm_pmap_get(kvm_t *kd, u_long idx, size_t len)
 {
-   off_t off = index * len;
+   off_t off = idx * len;
 
if (off >= kd->pt_sparse_off)
return (NULL);
@@ -699,10 +699,10 @@ again:
 }
 
 int
-_kvm_bitmap_init(struct kvm_bitmap *bm, u_long bitmapsize, u_long *index)
+_kvm_bitmap_init(struct kvm_bitmap *bm, u_long bitmapsize, u_long *idx)
 {
 
-   *index = ULONG_MAX;
+   *idx = ULONG_MAX;
bm->map = calloc(bitmapsize, sizeof *bm->map);
if (bm->map == NULL)
return (0);
@@ -720,23 +720,23 @@ _kvm_bitmap_set(struct kvm_bitmap *bm, u_long pa, unsi
 }
 
 int
-_kvm_bitmap_next(struct kvm_bitmap *bm, u_long *index)
+_kvm_bitmap_next(struct kvm_bitmap *bm, u_long *idx)
 {
u_long first_invalid = bm->size * CHAR_BIT;
 
-   if (*index == ULONG_MAX)
-   *index = 0;
+   if (*idx == ULONG_MAX)
+   *idx = 0;
else
-   (*index)++;
+   (*idx)++;
 
-   /* Find the next valid index. */
-   for (; *index < first_invalid; (*index)++) {
-   unsigned int mask = *index % CHAR_BIT;
-   if ((bm->map[*index * CHAR_BIT] & mask) == 0)
+   /* Find the next valid idx. */
+   for (; *idx < first_invalid; (*idx)++) {
+   unsigned int mask = *idx % CHAR_BIT;
+   if ((bm->map[*idx * CHAR_BIT] & mask) == 0)
break;
}
 
-   return (*index < first_invalid);
+   return (*idx < first_invalid);
 }
 
 void
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325732 - head/lib/libkvm

2017-11-11 Thread Will Andrews
Author: will
Date: Sun Nov 12 01:36:48 2017
New Revision: 325732
URL: https://svnweb.freebsd.org/changeset/base/325732

Log:
  libkvm: fix build failures

Modified:
  head/lib/libkvm/kvm.h
  head/lib/libkvm/kvm_aarch64.h
  head/lib/libkvm/kvm_amd64.c
  head/lib/libkvm/kvm_amd64.h
  head/lib/libkvm/kvm_minidump_aarch64.c
  head/lib/libkvm/kvm_minidump_amd64.c
  head/lib/libkvm/kvm_minidump_arm.c
  head/lib/libkvm/kvm_minidump_i386.c
  head/lib/libkvm/kvm_minidump_mips.c
  head/lib/libkvm/kvm_private.c

Modified: head/lib/libkvm/kvm.h
==
--- head/lib/libkvm/kvm.h   Sun Nov 12 01:28:20 2017(r325731)
+++ head/lib/libkvm/kvm.h   Sun Nov 12 01:36:48 2017(r325732)
@@ -36,7 +36,14 @@
 #include 
 #include 
 #include 
-#include 
+
+/*
+ * Including vm/vm.h causes namespace pollution issues.  For the
+ * most part, only things using kvm_walk_pages() need to #include it.
+ */
+#ifndef VM_H
+typedef u_char vm_prot_t;
+#endif
 
 /* Default version symbol. */
 #defineVRS_SYM "_version"

Modified: head/lib/libkvm/kvm_aarch64.h
==
--- head/lib/libkvm/kvm_aarch64.h   Sun Nov 12 01:28:20 2017
(r325731)
+++ head/lib/libkvm/kvm_aarch64.h   Sun Nov 12 01:36:48 2017
(r325732)
@@ -42,8 +42,8 @@ typedef uint64_t  aarch64_pte_t;
 
 /* Source: arm64/include/pte.h */
 #defineAARCH64_ATTR_MASK   0xfff00fff
-#defineAARCH64_ATTR_UXN(1UL << 54)
-#defineAARCH64_ATTR_PXN(1UL << 53)
+#defineAARCH64_ATTR_UXN(1ULL << 54)
+#defineAARCH64_ATTR_PXN(1ULL << 53)
 #defineAARCH64_ATTR_XN (AARCH64_ATTR_PXN | AARCH64_ATTR_UXN)
 #defineAARCH64_ATTR_AP(x)  ((x) << 6)
 #defineAARCH64_ATTR_AP_RO  (1 << 1)

Modified: head/lib/libkvm/kvm_amd64.c
==
--- head/lib/libkvm/kvm_amd64.c Sun Nov 12 01:28:20 2017(r325731)
+++ head/lib/libkvm/kvm_amd64.c Sun Nov 12 01:36:48 2017(r325732)
@@ -51,6 +51,7 @@ static char sccsid[] = "@(#)kvm_hp300.c   8.1 (Berkeley)
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 

Modified: head/lib/libkvm/kvm_amd64.h
==
--- head/lib/libkvm/kvm_amd64.h Sun Nov 12 01:28:20 2017(r325731)
+++ head/lib/libkvm/kvm_amd64.h Sun Nov 12 01:36:48 2017(r325732)
@@ -55,7 +55,9 @@ typedef   uint64_tamd64_pml4e_t;
 #defineAMD64_NPML4EPG  (AMD64_PAGE_SIZE / 
sizeof(amd64_pml4e_t))
 #defineAMD64_PML4SHIFT 39
 
+#defineAMD64_PG_NX (1ULL << 63)
 #defineAMD64_PG_V  0x001
+#defineAMD64_PG_RW 0x002
 #defineAMD64_PG_PS 0x080
 #defineAMD64_PG_FRAME  (0x000ff000)
 #defineAMD64_PG_PS_FRAME   (0x000fffe0)

Modified: head/lib/libkvm/kvm_minidump_aarch64.c
==
--- head/lib/libkvm/kvm_minidump_aarch64.c  Sun Nov 12 01:28:20 2017
(r325731)
+++ head/lib/libkvm/kvm_minidump_aarch64.c  Sun Nov 12 01:36:48 2017
(r325732)
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "../../sys/arm64/include/minidump.h"

Modified: head/lib/libkvm/kvm_minidump_amd64.c
==
--- head/lib/libkvm/kvm_minidump_amd64.cSun Nov 12 01:28:20 2017
(r325731)
+++ head/lib/libkvm/kvm_minidump_amd64.cSun Nov 12 01:36:48 2017
(r325732)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "../../sys/amd64/include/minidump.h"
@@ -59,9 +60,9 @@ _amd64_entry_to_prot(uint64_t entry)
 {
vm_prot_t prot = VM_PROT_READ;
 
-   if ((entry & PG_RW) != 0)
+   if ((entry & AMD64_PG_RW) != 0)
prot |= VM_PROT_WRITE;
-   if ((entry & PG_NX) == 0)
+   if ((entry & AMD64_PG_NX) == 0)
prot |= VM_PROT_EXECUTE;
return prot;
 }
@@ -351,12 +352,12 @@ _amd64_minidump_walk_pages(kvm_t *kd, kvm_walk_pages_c
return (0);
 
for (pdeindex = 0; pdeindex < npdes; pdeindex++) {
-   pd_entry_t pde = _amd64_pde_get(kd, pdeindex);
-   pt_entry_t *ptes;
+   amd64_pde_t pde = _amd64_pde_get(kd, pdeindex);
+   amd64_pte_t *ptes;
u_long i;
 
va = vm->hdr.kernbase + (pdeindex << AMD64_PDRSHIFT);
-   if ((pde & PG_V) == 0)
+   if ((pde & AMD64_PG_V) == 0)
continue;
 
if ((pde & AMD64_PG_PS) != 0) {

svn commit: r325733 - head/sys/kern

2017-11-11 Thread Mateusz Guzik
Author: mjg
Date: Sun Nov 12 02:34:33 2017
New Revision: 325733
URL: https://svnweb.freebsd.org/changeset/base/325733

Log:
  Use passed thread pointer instead of curthread in sys_sched_yield
  
  No functional changes.

Modified:
  head/sys/kern/p1003_1b.c

Modified: head/sys/kern/p1003_1b.c
==
--- head/sys/kern/p1003_1b.cSun Nov 12 01:36:48 2017(r325732)
+++ head/sys/kern/p1003_1b.cSun Nov 12 02:34:33 2017(r325733)
@@ -292,8 +292,8 @@ int
 sys_sched_yield(struct thread *td, struct sched_yield_args *uap)
 {
 
-   sched_relinquish(curthread);
-   return 0;
+   sched_relinquish(td);
+   return (0);
 }
 
 int
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r325728 - head/lib/libkvm

2017-11-11 Thread Matt Joras
On 11/11/2017 15:30, Will Andrews wrote:
> Author: will
> Date: Sat Nov 11 23:30:58 2017
> New Revision: 325728
> URL: https://svnweb.freebsd.org/changeset/base/325728
>
> Log:
>   libkvm: add kvm_walk_pages API.
>   
>   This API allows callers to enumerate all known pages, including any
>   direct map & kernel map virtual addresses, physical addresses, size,
>   offset into the core, & protection configured.
>   
>   For architectures that support direct map addresses, also generate pages
>   for any direct map only addresses that are not associated with kernel
>   map addresses.
>   
>   Fix page size portability issue left behind from previous kvm page table
>   lookup interface.
>   
>   Reviewed by:jhb
>   Sponsored by:   Backtrace I/O
>   Differential Revision:  https://reviews.freebsd.org/D12279

This broke powerpc, riscv64, sparc64:

*23:36:15* /usr/src/lib/libkvm/kvm_private.c: In function '_kvm_bitmap_init':
*23:36:15* /usr/src/lib/libkvm/kvm_private.c:702: warning: declaration of 
'index' shadows a global declaration
*23:36:15* /usr/obj/usr/src/powerpc.powerpc/tmp/usr/include/strings.h:60: 
warning: shadowed declaration is here
*23:36:15* /usr/src/lib/libkvm/kvm_private.c: In function '_kvm_bitmap_next':
*23:36:15* /usr/src/lib/libkvm/kvm_private.c:723: warning: declaration of 
'index' shadows a global declaration
*23:36:15* /usr/obj/usr/src/powerpc.powerpc/tmp/usr/include/strings.h:60: 
warning: shadowed declaration is here
*23:36:15* *** [kvm_private.o] Error code 1

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


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

2017-11-11 Thread Mateusz Guzik
Author: mjg
Date: Sun Nov 12 03:13:01 2017
New Revision: 325734
URL: https://svnweb.freebsd.org/changeset/base/325734

Log:
  amd64: stop nesting preemption counter in spinlock_enter
  
  Discussed with:   jhb

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

Modified: head/sys/amd64/amd64/machdep.c
==
--- head/sys/amd64/amd64/machdep.c  Sun Nov 12 02:34:33 2017
(r325733)
+++ head/sys/amd64/amd64/machdep.c  Sun Nov 12 03:13:01 2017
(r325734)
@@ -1853,9 +1853,9 @@ spinlock_enter(void)
flags = intr_disable();
td->td_md.md_spinlock_count = 1;
td->td_md.md_saved_flags = flags;
+   critical_enter();
} else
td->td_md.md_spinlock_count++;
-   critical_enter();
 }
 
 void
@@ -1865,11 +1865,12 @@ spinlock_exit(void)
register_t flags;
 
td = curthread;
-   critical_exit();
flags = td->td_md.md_saved_flags;
td->td_md.md_spinlock_count--;
-   if (td->td_md.md_spinlock_count == 0)
+   if (td->td_md.md_spinlock_count == 0) {
+   critical_exit();
intr_restore(flags);
+   }
 }
 
 /*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325735 - head/lib/libkvm

2017-11-11 Thread Will Andrews
Author: will
Date: Sun Nov 12 03:28:47 2017
New Revision: 325735
URL: https://svnweb.freebsd.org/changeset/base/325735

Log:
  libkvm: fix lib32 build.

Modified:
  head/lib/libkvm/kvm_i386.c

Modified: head/lib/libkvm/kvm_i386.c
==
--- head/lib/libkvm/kvm_i386.c  Sun Nov 12 03:13:01 2017(r325734)
+++ head/lib/libkvm/kvm_i386.c  Sun Nov 12 03:28:47 2017(r325735)
@@ -51,6 +51,7 @@ static char sccsid[] = "@(#)kvm_hp300.c   8.1 (Berkeley)
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #ifdef __i386__
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r325721 - in head/sys: kern sys

2017-11-11 Thread Mark Johnston
On Sat, Nov 11, 2017 at 06:04:40PM +, Mateusz Guzik wrote:
> Author: mjg
> Date: Sat Nov 11 18:04:39 2017
> New Revision: 325721
> URL: https://svnweb.freebsd.org/changeset/base/325721
> 
> Log:
>   Add pfind_any
>   
>   It looks for both regular and zombie processes. This avoids allproc 
> relocking
>   previously seen with pfind -> zpfind calls.
> 
> Modified:
>   head/sys/kern/kern_event.c
>   head/sys/kern/kern_proc.c
>   head/sys/kern/kern_sig.c
>   head/sys/sys/proc.h
> 
> Modified: head/sys/kern/kern_proc.c
> ==
> --- head/sys/kern/kern_proc.c Sat Nov 11 18:03:26 2017(r325720)
> +++ head/sys/kern/kern_proc.c Sat Nov 11 18:04:39 2017(r325721)
> @@ -353,6 +353,23 @@ pfind(pid_t pid)
>   return (p);
>  }
>  
> +/*
> + * Same as pfind but allow zombies.
> + */
> +struct proc *
> +pfind_any(pid_t pid)
> +{
> + struct proc *p;
> +
> + sx_slock(&allproc_lock);
> + p = pfind_locked(pid);
> + if (p == NULL)
> + p = zpfind_locked(pid);
> + sx_sunlock(&allproc_lock);
> +
> + return (p);
> +}

Can't this be written as pget(pid, 0, &p)?
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r325721 - in head/sys: kern sys

2017-11-11 Thread Mateusz Guzik
On Sun, Nov 12, 2017 at 5:32 AM, Mark Johnston  wrote:

> On Sat, Nov 11, 2017 at 06:04:40PM +, Mateusz Guzik wrote:
> > Author: mjg
> > Date: Sat Nov 11 18:04:39 2017
> > New Revision: 325721
> > URL: https://svnweb.freebsd.org/changeset/base/325721
> >
> > Log:
> >   Add pfind_any
> >
> >   It looks for both regular and zombie processes. This avoids allproc
> relocking
> >   previously seen with pfind -> zpfind calls.
> >
> > +/*
> > + * Same as pfind but allow zombies.
> > + */
> > +struct proc *
> > +pfind_any(pid_t pid)
> > +{
> > + struct proc *p;
> > +
> > + sx_slock(&allproc_lock);
> > + p = pfind_locked(pid);
> > + if (p == NULL)
> > + p = zpfind_locked(pid);
> > + sx_sunlock(&allproc_lock);
> > +
> > + return (p);
> > +}
>
> Can't this be written as pget(pid, 0, &p)?
>

It can, but at the expense of avoidable branch-fest. pget is rarely called
in comparison
anyway.

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


Re: svn commit: r325734 - head/sys/amd64/amd64

2017-11-11 Thread Bruce Evans

On Sun, 12 Nov 2017, Mateusz Guzik wrote:


Log:
 amd64: stop nesting preemption counter in spinlock_enter

 Discussed with:jhb


This seems to break it.  i386 still has the old code.

It also moves the critical section a little, so that it is inconsistent
for enter/exit.  I think the critical section placement was harmlessly
wrong, and moving it further fixes the new bugs too.


Modified: head/sys/amd64/amd64/machdep.c
==
--- head/sys/amd64/amd64/machdep.c  Sun Nov 12 02:34:33 2017
(r325733)
+++ head/sys/amd64/amd64/machdep.c  Sun Nov 12 03:13:01 2017
(r325734)
@@ -1853,9 +1853,9 @@ spinlock_enter(void)
flags = intr_disable();
td->td_md.md_spinlock_count = 1;
td->td_md.md_saved_flags = flags;
+   critical_enter();
} else
td->td_md.md_spinlock_count++;
-   critical_enter();
}

void


The main broken case is:
- both levels initially 0
- disable interrupts
- raise spinlock count to 1
- bad race window until critical_enter() is called.  Disabling hardware
  interrupts doesn't prevent exceptions like debugger traps or NMIs.
  Debuuger trap handlers shouldn't use critical sections or (spin)
  mutexes, but NMI handlers might.  When an exception handler calls
  spinlock_enter(), this no longer gives a critical section and bad
  things like context switches occur if the handler calls critical_enter/
  exit().

The main old race is:
- as above, except the race is not so bad (I think it is harmless).
  Nested calls to spinlock_enter() can still occur, but at all levels,
  spinlock_enter() never returns without entering a critical section,
  so callers aren't affected.  I think the worst that happens is a
  when nested spinlock_exit() lowers the critical level to 0, context
  switches may occur.  This isn't a large problem since higher spinlock_
  enter() levels are still entering -- they have disabled interrupts,
  but nothing depends on this.

See r214835 for larger bugs related to the old race.  Exceptions cannot
be prevented, and r214835 defends against them only for the spinlock
context.

Defending against preemption is even easier.  Just move the critical_enter()
to before disabling interrupts.


@@ -1865,11 +1865,12 @@ spinlock_exit(void)
register_t flags;

td = curthread;
-   critical_exit();
flags = td->td_md.md_saved_flags;
td->td_md.md_spinlock_count--;
-   if (td->td_md.md_spinlock_count == 0)
+   if (td->td_md.md_spinlock_count == 0) {
+   critical_exit();
intr_restore(flags);
+   }
}

/*


This used to call critical_exit() at the beginning.  This corresponds to
calling critical_enter() at the end of spinlock_enter(), and gives the
same race.

Now it calls critical_exit() after lowering the spinlock count.  This closes
only half of the old race window.

After moving the call to critical_enter() earlier, moving the call to
critical_exit() later to match closes all of the old race window.

The new bug only affects spinlock entry.  For exit, there is just the old
race with a reduced window.

I don't like this change.  The nested counting is easier to understand,
and the nested case is very rare and the critical section part of it is
very efficient (then critical_exit() is just lowering the level).  Old
versions of these functions were written to try to reduce branches and
other bad scheduling for the usual non-nested case.  Perhaps this isn't
done right.  It is intentionally not obfuscated with __predict_*().
spinlock_exit() ended up without the optimization(?) of avoiding the
decrement in the usual case, where spinlock_enter() uses special 0/1
logic for the usual case and needs extra code for the increment in the
unusual case.  Since the slow parts are probably the critical_*() function
calls and the flags changes, perhaps those should be optimized instead.
The old version tried to do this for the function calls by doing them
unconditionally.  This should have worked best for the call in
critical_exit() since the call is first (but should be last).  The order
is critical, and the flags changes use volatile asms which force the order
more than elsewhere.

I think the nested case is only for recursive spinlocks.  So NMI handlers
should not use any spinlocks and the new bug is small (NMI handlers should
not use non-recursive spinlocks since they would deadlock, and should not
use recursive spinlocks since they don't work).  NMI handlers aren't that
careful.  They call printf(), and even the message buffer has been broken
to use non-recursive spinlocks.

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


Re: svn commit: r325734 - head/sys/amd64/amd64

2017-11-11 Thread Bruce Evans

On Sun, 12 Nov 2017, Bruce Evans wrote:


On Sun, 12 Nov 2017, Mateusz Guzik wrote:


Log:
 amd64: stop nesting preemption counter in spinlock_enter

 Discussed with:jhb


This seems to break it.  i386 still has the old code.
...
The main broken case is:
- both levels initially 0
- disable interrupts
- raise spinlock count to 1
- bad race window until critical_enter() is called.  Disabling hardware
 interrupts doesn't prevent exceptions like debugger traps or NMIs.
 Debuuger trap handlers shouldn't use critical sections or (spin)
 mutexes, but NMI handlers might.  When an exception handler calls
 spinlock_enter(), this no longer gives a critical section and bad
 things like context switches occur if the handler calls critical_enter/
 exit().
...
I don't like this change.  The nested counting is easier to understand,
and the nested case is very rare and the critical section part of it is
very efficient (then critical_exit() is just lowering the level).  Old
...
I think the nested case is only for recursive spinlocks.  So NMI handlers
should not use any spinlocks and the new bug is small (NMI handlers should
not use non-recursive spinlocks since they would deadlock, and should not
use recursive spinlocks since they don't work).  NMI handlers aren't that
careful.  They call printf(), and even the message buffer has been broken
to use non-recursive spinlocks.


Actually, it is valid for NMI handlers to use spinlocks via mtx_trylock_spin()
in the non-kdb non-panic case, and that is what my fixes for printf() do.

I had confused "nesting preemption counter" (td_critnest) with interrupt
nesting (the bogus td_intr_nesting_level).  td_critnest was incremented
for every concurrently held spinlock, so it could grow quite large without
any interrupt/exception recursion.  So the micro-optimization of td_critnest
is useful if it is faster and fixed to work.

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


svn commit: r325736 - in head: lib/libcasper/libcasper sbin/ping

2017-11-11 Thread Mariusz Zaborski
Author: oshogbo
Date: Sun Nov 12 07:18:10 2017
New Revision: 325736
URL: https://svnweb.freebsd.org/changeset/base/325736

Log:
  We return a pointer when we are using cap_init() or cap_service_open()
  function, so check if cap_chanel_t is NULL is not enough.
  Casper with a normal libc will still fail in capability mote so let's not
  enter capability mode without casper support when we need to resolve DNS.
  
  Reviewed by:  cem
  Differential Revision:https://reviews.freebsd.org/D12823

Modified:
  head/lib/libcasper/libcasper/libcasper.h
  head/sbin/ping/ping.c

Modified: head/lib/libcasper/libcasper/libcasper.h
==
--- head/lib/libcasper/libcasper/libcasper.hSun Nov 12 03:28:47 2017
(r325735)
+++ head/lib/libcasper/libcasper/libcasper.hSun Nov 12 07:18:10 2017
(r325736)
@@ -56,11 +56,13 @@ typedef struct nvlist nvlist_t;
 struct cap_channel;
 
 typedef struct cap_channel cap_channel_t;
+#defineCASPER_SUPPORT  (1)
 #else
 struct cap_channel {
int cch_fd;
 };
 typedef struct cap_channel cap_channel_t;
+#defineCASPER_SUPPORT  (0)
 #endif /* ! WITH_CASPER */
 #endif /* ! _CAP_CHANNEL_T_DECLARED */
 

Modified: head/sbin/ping/ping.c
==
--- head/sbin/ping/ping.c   Sun Nov 12 03:28:47 2017(r325735)
+++ head/sbin/ping/ping.c   Sun Nov 12 07:18:10 2017(r325736)
@@ -709,7 +709,7 @@ main(int argc, char *const *argv)
if (options & F_NUMERIC)
cansandbox = true;
else if (capdns != NULL)
-   cansandbox = true;
+   cansandbox = CASPER_SUPPORT;
else
cansandbox = false;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"