Re: svn commit: r278737 - head/usr.sbin/flowctl

2015-02-14 Thread John-Mark Gurney
Bruce Evans wrote this message on Sun, Feb 15, 2015 at 17:53 +1100:
 On Sat, 14 Feb 2015, Pedro Giffuni wrote:
 
  On 02/14/15 13:33, Ian Lepore wrote:
  On Sat, 2015-02-14 at 21:15 +0300, Gleb Smirnoff wrote:
  On Sat, Feb 14, 2015 at 08:46:58PM +1100, Bruce Evans wrote:
  B Using VLAs and also the C99 feature of declarations anwhere, and 
  extensions
  B like __aligned(), we can almost implement a full alloca() using the 
  fixed
  B version of this change:
  B
  B /*
  B   * XXX need extended statement-expression so that __buf doesn't go out
  B   * of scope after the right brace.
  B   */
  B #definemy_alloca(n) __extension__ ({
  B/* XXX need unique name. */ \
  Bchar __buf[__roundup2((n), MUMBLE)] __aligned(MUMBLE);  \
  B\
  B(void *)__buf;  \
  B })
  
  I like this idea. But would this exact code work? The life of
  __buf is limited by the code block, and we exit the block
  immediately. Wouldn't the allocation be overwritten if we
  enter any function or block later?

Could this just be changed to something like:
struct ng_mesg ng_mesg[(SORCVBUF_SIZE + sizeof(struct ng_mesg) - 1) /
sizeof(struct ng_mesg)];

It might allocate a few extra bytes, but no more than 55, and gets
alignment correct w/o lots of other hacks...

-- 
  John-Mark Gurney  Voice: +1 415 225 5579

 All that I will do, has been done, All that I have, has not.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r278737 - head/usr.sbin/flowctl

2015-02-14 Thread Bruce Evans

On Sun, 15 Feb 2015, Bruce Evans wrote:


On Sat, 14 Feb 2015, Pedro Giffuni wrote:

_
...
BUGS
The alloca() function is machine and compiler dependent; its use is dis-
couraged.


This became out of date with VLAs in C99.  Except for scopes, compilers
must have slightly more complications to support VLAs than alloca().
They might still not support alloca().  But FreeBSD never used ones that
don't.  That it would never use them was not so clear when this man page
was written.


I found this interesting related problem on the web: inline functions
with alloca() in them may blow out the stack.

But this is only with broken compilers.  For inline functions to work,
they must have the same semantics as when they aren't inlined,
especially when they are automatically inlined.  This means that any
alloca()'ed space in an inline function must be freed at the end of
that function, not at the end of its caller.

clang handles this correctly by doing requested inlining, and freeing
in the right place.  gcc documents the problem and normally refuse to
do requested inlining in functions that call alloca().  However, gcc
can be broken by forcing the inlining using __always_inline.  gcc-4.2
silently produces the stack-blowing code.  gcc-4.8 warns that the
forced inlining might be wrong.

alloca() in any macro would have this problem, unlike a [VL]A in a
compound statement in a macro.

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


Re: svn commit: r278737 - head/usr.sbin/flowctl

2015-02-14 Thread Bruce Evans

On Fri, 13 Feb 2015, Gleb Smirnoff wrote:


Author: glebius
Date: Fri Feb 13 23:57:20 2015
New Revision: 278737
URL: https://svnweb.freebsd.org/changeset/base/278737

Log:
 Use less ugly code to allocate buffer of SORCVBUF_SIZE.


Less ugly, but wrong.  The version that used alloca() was correct.


Modified: head/usr.sbin/flowctl/flowctl.c
==
--- head/usr.sbin/flowctl/flowctl.c Fri Feb 13 23:43:59 2015
(r278736)
+++ head/usr.sbin/flowctl/flowctl.c Fri Feb 13 23:57:20 2015
(r278737)
@@ -222,10 +222,12 @@ ctl_show(int argc, char **argv)
static void
do_show(int version, void (*func)(struct ngnf_show_header *))
{
-   struct ng_mesg ng_mesg[SORCVBUF_SIZE];
+   char buf[SORCVBUF_SIZE];


alloca(), like malloc(), gave a buffer suitably aligned for any object.
This only gives a buffer suitably aligned for char objects.  It may
accidentally be suitably aligned for other objects.  The accident often
happens because objects on the stack are usually given larger alignment
than necessary.  Depending on this is unportable at best.


+   struct ng_mesg *ng_mesg;
struct ngnf_show_header req, *resp;
int token, nread;

+   ng_mesg = (struct ng_mesg *)buf;


The new bug is detected at high warning levels.  WARNS = 4 gives
-Wcast-align unless the MK option to break this warning is configured.
The bug is detected by -Wcast0align even on amd64.

The bug is not detected by default because flowctl has many other
warnings at the default WARNS of 6 (mainly -Wcast-align and
-Wsign-compare ones), so it breaks the warnings using WARNGS?=2.

I think arches with strict alignment requirements have a warning about
this without -Wcast-align, but couldn't find one on ia64.  Certainly,
related warnings turned up on ia64 when they didn't on amd64 with the
same WARNS.

The runtime bug can be fixed using __aligned(__ALIGN_MUMBLE).  This
exposes a bug in -Wcast-align -- it still warns although the char buffer
is obviously aligned.  Compilers should also know that the buffer is
suitably aligned when they just allocated it on the stack and the
alignment happens to be enough.  But in this case, compilers should
also know that the suitable alignment is only accidental, and still
warn unless portability warnings are supressed.

This and the non-spurious warning can be broken using another cast:

ng_mesg = (struct ng_mesg *)(void *)buf;

This depends on the compiler being too stupid to remember the alignment
of the original char buffer.

This fixed version is still worse than the old one using alloca(),
because it is longer and more complicated.  alloca(), like malloc(),
returns a void * so that the compiler cannot know the alignment of the buffer
  (except it can for alloca() because it just allocated the buffer -- it
   must do a (void *) cast internally and forget the actual alignment,
   just like the above cast does but with more intentional forgetfulness).
We are basically using a home made alloca(N) for the easier case where N
is constant.

Using VLAs and also the C99 feature of declarations anwhere, and extensions
like __aligned(), we can almost implement a full alloca() using the fixed
version of this change:

/*
 * XXX need extended statement-expression so that __buf doesn't go out
 * of scope after the right brace.
 */
#define my_alloca(n) __extension__ ({
/* XXX need unique name. */ \
char __buf[__roundup2((n), MUMBLE)] __aligned(MUMBLE);  \
\
(void *)__buf;  \
})

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


Re: svn commit: r278739 - head/lib/libc/regex

2015-02-14 Thread Bruce Evans

On Fri, 13 Feb 2015, Bryan Drewery wrote:


On 2/13/2015 6:37 PM, Bryan Drewery wrote:

On 2/13/2015 6:23 PM, Xin LI wrote:

Author: delphij
Date: Sat Feb 14 00:23:53 2015
New Revision: 278739
URL: https://svnweb.freebsd.org/changeset/base/278739

Log:
  Disallow pattern spaces which would cause intermediate calculations to
  overflow size_t.
...
Modified: head/lib/libc/regex/regcomp.c
==
--- head/lib/libc/regex/regcomp.c   Sat Feb 14 00:03:43 2015
(r278738)
+++ head/lib/libc/regex/regcomp.c   Sat Feb 14 00:23:53 2015
(r278739)
@@ -192,6 +192,7 @@ regcomp(regex_t * __restrict preg,
struct parse *p = pa;
int i;
size_t len;
+   size_t maxlen;
 #ifdef REDEBUG
 #  define  GOODFLAGS(f)(f)
 #else
@@ -213,7 +214,23 @@ regcomp(regex_t * __restrict preg,
g = (struct re_guts *)malloc(sizeof(struct re_guts));
if (g == NULL)
return(REG_ESPACE);
+   /*
+* Limit the pattern space to avoid a 32-bit overflow on buffer
+* extension.  Also avoid any signed overflow in case of conversion
+* so make the real limit based on a 31-bit overflow.
+*
+* Likely not applicable on 64-bit systems but handle the case
+* generically (who are we to stop people from using ~715MB+
+* patterns?).
+*/
+   maxlen = ((size_t)-1  1) / sizeof(sop) * 2 / 3;
+   if (len = maxlen) {
+   free((char *)g);


I was planning to submit a patch for review to remove all of this
casting / and discuss.


To be clear, I only mean in free(3) calls.


But they are least bogus for the free() calls.


In this example the malloc is casted to struct re_gets* but the free is
casted to char *. Why different and why cast in free at all?


Because this code attempted to be portable to KR compilers (including
broken ones, but with no standard it was hard to tell what was broken).

With no prototypes, the arg to free() had to be cast.
  (Except, all pointers have the same representation except on exotic
  machines, so the cast was rarely necessary then or now.)
With no void * in KR1, free() took a char * arg and the cast had to be
to that.  STDC have the grandfather kludge of requiring char * and void *
to be almost interchangable, so you can probably cast to either.  I
forget if it requires char * and void * to have the same representation,
so that you can certainly cast to either.  Even more than the same
representation is required -- they must be passed in the same way.

Old programs cast the result of malloc() to break warnings about malloc()
not being declared, or possibly for portability to broken compilers
which require the cast.  Actually, it was unclear if they were broken --
before void * existed, malloc() returned char *, and it is not so clear
for old char * as for not so old void * that automatic conversion from
char * to any pointer type does or should happen (without a warning).
New C++ programs require the cast even for void *.  I don't like this.

I also don't like the spelling of the sizeof arg in:

g = (struct re_guts *)malloc(sizeof(struct re_guts));

It is clearer to write:

g = malloc(sizeof(*g));

This works for any pointer g.

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


svn commit: r278751 - in head/lib: libc/gen libc/include libc/sys libthr/thread

2015-02-14 Thread Konstantin Belousov
Author: kib
Date: Sat Feb 14 11:47:40 2015
New Revision: 278751
URL: https://svnweb.freebsd.org/changeset/base/278751

Log:
  Properly interpose libc spinlocks, was missed in r276630.  In
  particular, stdio locking was affected.
  
  Reported and tested by:   Matthew D. Fuller fulle...@over-yonder.net
  Sponsored by: The FreeBSD Foundation
  MFC after:3 days

Modified:
  head/lib/libc/gen/_spinlock_stub.c
  head/lib/libc/include/libc_private.h
  head/lib/libc/sys/interposing_table.c
  head/lib/libthr/thread/thr_private.h
  head/lib/libthr/thread/thr_spinlock.c
  head/lib/libthr/thread/thr_syscalls.c

Modified: head/lib/libc/gen/_spinlock_stub.c
==
--- head/lib/libc/gen/_spinlock_stub.c  Sat Feb 14 10:56:03 2015
(r278750)
+++ head/lib/libc/gen/_spinlock_stub.c  Sat Feb 14 11:47:40 2015
(r278751)
@@ -33,51 +33,48 @@ __FBSDID($FreeBSD$);
 #include stdio.h
 
 #include spinlock.h
+#include libc_private.h
 
 long _atomic_lock_stub(volatile long *);
 void _spinlock_stub(spinlock_t *);
 void _spinunlock_stub(spinlock_t *);
 void _spinlock_debug_stub(spinlock_t *, char *, int);
 
-/*
- * Declare weak definitions in case the application is not linked
- * with libpthread.
- */
 __weak_reference(_atomic_lock_stub, _atomic_lock);
-__weak_reference(_spinlock_stub, _spinlock);
-__weak_reference(_spinunlock_stub, _spinunlock);
-__weak_reference(_spinlock_debug_stub, _spinlock_debug);
-
-/*
- * This function is a stub for the _atomic_lock function in libpthread.
- */
+
 long
 _atomic_lock_stub(volatile long *lck __unused)
 {
return (0L);
 }
 
+__weak_reference(_spinlock, _spinlock_debug);
+#pragma weak _spinlock
+void
+_spinlock(spinlock_t *lck)
+{
+
+   ((void (*)(spinlock_t *lck))__libc_interposing[INTERPOS_spinlock])
+   (lck);
 
-/*
- * This function is a stub for the spinlock function in libpthread.
- */
+}
+
+#pragma weak _spinlock
 void
-_spinlock_stub(spinlock_t *lck __unused)
+_spinunlock(spinlock_t *lck)
 {
+
+   ((void (*)(spinlock_t *lck))__libc_interposing[INTERPOS_spinunlock])
+   (lck);
+
 }
 
-/*
- * This function is a stub for the spinunlock function in libpthread.
- */
 void
-_spinunlock_stub(spinlock_t *lck __unused)
+__libc_spinlock_stub(spinlock_t *lck __unused)
 {
 }
 
-/*
- * This function is a stub for the debug spinlock function in libpthread.
- */
 void
-_spinlock_debug_stub(spinlock_t *lck __unused, char *fname __unused, int 
lineno __unused)
+__libc_spinunlock_stub(spinlock_t *lck __unused)
 {
 }

Modified: head/lib/libc/include/libc_private.h
==
--- head/lib/libc/include/libc_private.hSat Feb 14 10:56:03 2015
(r278750)
+++ head/lib/libc/include/libc_private.hSat Feb 14 11:47:40 2015
(r278751)
@@ -95,6 +95,9 @@ do {  \
_SPINUNLOCK(__stdio_thread_lock);  \
 } while (0)
 
+void   __libc_spinlock_stub(struct _spinlock *);
+void   __libc_spinunlock_stub(struct _spinlock *);
+
 /*
  * Indexes into the pthread jump table.
  *
@@ -216,6 +219,8 @@ enum {
INTERPOS_write,
INTERPOS_writev,
INTERPOS__pthread_mutex_init_calloc_cb,
+   INTERPOS_spinlock,
+   INTERPOS_spinunlock,
INTERPOS_MAX
 };
 

Modified: head/lib/libc/sys/interposing_table.c
==
--- head/lib/libc/sys/interposing_table.c   Sat Feb 14 10:56:03 2015
(r278750)
+++ head/lib/libc/sys/interposing_table.c   Sat Feb 14 11:47:40 2015
(r278751)
@@ -73,6 +73,8 @@ interpos_func_t __libc_interposing[INTER
SLOT(write, __sys_write),
SLOT(writev, __sys_writev),
SLOT(_pthread_mutex_init_calloc_cb, _pthread_mutex_init_calloc_cb_stub),
+   SLOT(spinlock, __libc_spinlock_stub),
+   SLOT(spinunlock, __libc_spinunlock_stub),
 };
 #undef SLOT
 

Modified: head/lib/libthr/thread/thr_private.h
==
--- head/lib/libthr/thread/thr_private.hSat Feb 14 10:56:03 2015
(r278750)
+++ head/lib/libthr/thread/thr_private.hSat Feb 14 11:47:40 2015
(r278751)
@@ -928,6 +928,10 @@ int __thr_sigwait(const sigset_t *set, i
 int __thr_sigwaitinfo(const sigset_t *set, siginfo_t *info);
 int __thr_swapcontext(ucontext_t *oucp, const ucontext_t *ucp);
 
+struct _spinlock;
+void __thr_spinunlock(struct _spinlock *lck);
+void __thr_spinlock(struct _spinlock *lck);
+
 struct tcb *_tcb_ctor(struct pthread *, int);
 void   _tcb_dtor(struct tcb *);
 

Modified: head/lib/libthr/thread/thr_spinlock.c
==
--- head/lib/libthr/thread/thr_spinlock.c   Sat Feb 14 10:56:03 2015
(r278750)
+++ 

svn commit: r278758 - head/lib/libc/gen

2015-02-14 Thread Tijl Coosemans
Author: tijl
Date: Sat Feb 14 15:14:41 2015
New Revision: 278758
URL: https://svnweb.freebsd.org/changeset/base/278758

Log:
  The ld(1) flag is -Bsymbolic not -Wsymbolic.

Modified:
  head/lib/libc/gen/dlopen.3

Modified: head/lib/libc/gen/dlopen.3
==
--- head/lib/libc/gen/dlopen.3  Sat Feb 14 14:13:00 2015(r278757)
+++ head/lib/libc/gen/dlopen.3  Sat Feb 14 15:14:41 2015(r278758)
@@ -32,7 +32,7 @@
 .\ @(#) dlopen.3 1.6 90/01/31 SMI
 .\ $FreeBSD$
 .\
-.Dd December 21, 2011
+.Dd February 14, 2015
 .Dt DLOPEN 3
 .Os
 .Sh NAME
@@ -236,7 +236,7 @@ as follows, in the given order:
 The referencing object itself (or the object from which the call to
 .Fn dlsym
 is made), if that object was linked using the
-.Fl Wsymbolic
+.Fl Bsymbolic
 option to
 .Xr ld 1 .
 .It
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: Phabricator + 'Reviewed by' [was Re: svn commit: r278472 - in head/sys: netinet netinet6]

2015-02-14 Thread Steven Hartland


On 13/02/2015 23:56, Bryan Drewery wrote:

On 2/9/2015 3:45 PM, Bjoern A. Zeeb wrote:

  Commented upon by hiren and sbruno
  See Phabricator D1777 for more details.

  Commented upon by hiren and sbruno
  Reviewed by:  adrian, jhb and bz

I have not reviewed this;  as a matter of fact you are aware that I still 
wanted to do that.


Something about Phabricator is not jiving with our commit terminology.
This has happened before as well with other commits. I'm sure everyone
is good-intentioned as well.

There's not 1 person on D1777 who has 'accepted' it. That is what
warrants a 'Reviewed by' to me.

It's clear to me, but seems unclear to others. I really think the
reviewer list needs to be split up. Rather than using icons, use
separate lists. Reviewers requested: accepted: commented: changes
requested:.
I don't think it needs to be split up, that feels unnecessary, if 
someone hasn't accepted it then they haven't review it period IMO.

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


svn commit: r278759 - head/sys/contrib/dev/ath/ath_hal/ar9300

2015-02-14 Thread Adrian Chadd
Author: adrian
Date: Sat Feb 14 16:23:04 2015
New Revision: 278759
URL: https://svnweb.freebsd.org/changeset/base/278759

Log:
  Remove the reserved pin 11 from the HAL check.
  
  The QCA9565 can have RFKILL on GPIO Pin 11, and thus we need to configure
  it up correctly or the NIC may not function.
  
  I'm not sure why the AR9382 can't use GPIO 8 / GPIO 11 ; it's likely
  hooked up to some external LNA or filter.  The real solution is to
  make it only block pin 8 / pin 11 for AR9382, but the AR9382 probes
  like an AR9380.  Sigh.
  
  Submitted by: Anthony Jenkins scoobi_...@yahoo.com

Modified:
  head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_gpio.c

Modified: head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_gpio.c
==
--- head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_gpio.c   Sat Feb 14 
15:14:41 2015(r278758)
+++ head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_gpio.c   Sat Feb 14 
16:23:04 2015(r278759)
@@ -162,7 +162,6 @@ ar9300_gpio_cfg_output(
 
 HALASSERT(gpio  AH_PRIVATE(ah)-ah_caps.halNumGpioPins);
 if ((gpio == AR9382_GPIO_PIN_8_RESERVED)  ||
-(gpio == AR9382_GPIO_PIN_11_RESERVED) ||
 (gpio == AR9382_GPIO_9_INPUT_ONLY))
 {
 return AH_FALSE;
@@ -348,7 +347,6 @@ ar9300_gpio_cfg_input(struct ath_hal *ah
 
 HALASSERT(gpio  AH_PRIVATE(ah)-ah_caps.halNumGpioPins);
 if ((gpio == AR9382_GPIO_PIN_8_RESERVED)  ||
-(gpio == AR9382_GPIO_PIN_11_RESERVED) ||
 (gpio  AR9382_MAX_GPIO_INPUT_PIN_NUM))
 {
 return AH_FALSE;
@@ -378,7 +376,6 @@ ar9300_gpio_set(struct ath_hal *ah, u_in
 {
 HALASSERT(gpio  AH_PRIVATE(ah)-ah_caps.halNumGpioPins);
 if ((gpio == AR9382_GPIO_PIN_8_RESERVED)  ||
-(gpio == AR9382_GPIO_PIN_11_RESERVED) ||
 (gpio == AR9382_GPIO_9_INPUT_ONLY))
 {
 return AH_FALSE;
@@ -397,8 +394,7 @@ ar9300_gpio_get(struct ath_hal *ah, u_in
 {
 u_int32_t gpio_in;
 HALASSERT(gpio  AH_PRIVATE(ah)-ah_caps.halNumGpioPins);
-if ((gpio == AR9382_GPIO_PIN_8_RESERVED) ||
-(gpio == AR9382_GPIO_PIN_11_RESERVED))
+if ((gpio == AR9382_GPIO_PIN_8_RESERVED))
 {
 return 0x;
 }
@@ -453,7 +449,6 @@ ar9300_gpio_set_intr(struct ath_hal *ah,
 HALASSERT(gpio  AH_PRIVATE(ah)-ah_caps.halNumGpioPins);
 
 if ((gpio == AR9382_GPIO_PIN_8_RESERVED) ||
-(gpio == AR9382_GPIO_PIN_11_RESERVED) ||
 (gpio  AR9382_MAX_GPIO_INPUT_PIN_NUM))
 {
 return;
@@ -549,8 +544,7 @@ ar9300_gpio_get_mask(struct ath_hal *ah)
 
 if (AH_PRIVATE(ah)-ah_devid == AR9300_DEVID_AR9380_PCIE) {
 mask = (1  AR9382_MAX_GPIO_PIN_NUM) - 1;
-mask = ~(1  AR9382_GPIO_PIN_8_RESERVED |
-  1  AR9382_GPIO_PIN_11_RESERVED);
+mask = ~(1  AR9382_GPIO_PIN_8_RESERVED);
 }
 return mask;
 }
@@ -562,8 +556,7 @@ ar9300_gpio_set_mask(struct ath_hal *ah,
 
 if (AH_PRIVATE(ah)-ah_devid == AR9300_DEVID_AR9380_PCIE) {
 invalid = ~((1  AR9382_MAX_GPIO_PIN_NUM) - 1);
-invalid |= 1  AR9382_GPIO_PIN_8_RESERVED |
-   1  AR9382_GPIO_PIN_11_RESERVED;
+invalid |= 1  AR9382_GPIO_PIN_8_RESERVED;
 }
 if (mask  invalid) {
 ath_hal_printf(ah, %s: invalid GPIO mask 0x%x\n, __func__, mask);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


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

2015-02-14 Thread Gleb Smirnoff
On Sat, Feb 14, 2015 at 05:02:51PM +, John Baldwin wrote:
J Author: jhb
J Date: Sat Feb 14 17:02:51 2015
J New Revision: 278760
J URL: https://svnweb.freebsd.org/changeset/base/278760
J 
J Log:
J   Add two new counters for vnode life cycle events:
J   - vfs.recycles counts the number of vnodes forcefully recycled to avoid
J exceeding kern.maxvnodes.
J   - vfs.vnodes_created counts the number of vnodes created by successful
J calls to getnewvnode().
J   
J   Differential Revision: https://reviews.freebsd.org/D1671
J   Reviewed by:   kib
J   MFC after: 1 week

Why don't use counter(9) for that? Would avoid atomics.


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


Re: svn commit: r278737 - head/usr.sbin/flowctl

2015-02-14 Thread Ian Lepore
On Sat, 2015-02-14 at 21:15 +0300, Gleb Smirnoff wrote:
   Bruce,
 
 On Sat, Feb 14, 2015 at 08:46:58PM +1100, Bruce Evans wrote:
 B Using VLAs and also the C99 feature of declarations anwhere, and extensions
 B like __aligned(), we can almost implement a full alloca() using the fixed
 B version of this change:
 B 
 B /*
 B   * XXX need extended statement-expression so that __buf doesn't go out
 B   * of scope after the right brace.
 B   */
 B #definemy_alloca(n) __extension__ ({
 B/* XXX need unique name. */ \
 Bchar __buf[__roundup2((n), MUMBLE)] __aligned(MUMBLE);  \
 B\
 B(void *)__buf;  \
 B })
 
 I like this idea. But would this exact code work? The life of
 __buf is limited by the code block, and we exit the block
 immediately. Wouldn't the allocation be overwritten if we
 enter any function or block later?
 

Why put any effort into avoiding alloca() in the first place?  Is it
inefficient on some platforms?  On arm it's like 5 instructions, it just
adjusts the size to keep the stack dword-aligned and subtracts the
result from sp, done.

-- Ian

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


svn commit: r278776 - head/bin/pkill/tests

2015-02-14 Thread Garrett Cooper
Author: ngie
Date: Sat Feb 14 19:21:04 2015
New Revision: 278776
URL: https://svnweb.freebsd.org/changeset/base/278776

Log:
  Refactor pkill-j_test to reflect the relevant changes done to pgrep-j_test
  
  r278742:
  
  Simplify jail_name_to_jid and try to be more fault tolerant when scanning for
  the jail ID (poll up to 10 times for the jail IDs to become available)
  
  If the scan fails, the code will fall through and fail as it does with Jenkins
  today
  
  r278636:
  
  Parameterize out the amount of sleep done in each test
  
  Set the value in each test to a different amount to avoid potential
  side-effects with other instances of the test (or lingering processes) still
  being present on the system
  
  r278633:
  
  Refactor the tests
  
  1. `id -u` - 0 is now only checked once; the entire test script is now 
skipped
 if this assertion is violated
  2. De-dent whitespace, based on 1.
  3. Only setup the symlink for $sleep once at the top of the script, and tear 
it
 down once at the bottom of the script

Modified:
  head/bin/pkill/tests/pkill-j_test.sh

Modified: head/bin/pkill/tests/pkill-j_test.sh
==
--- head/bin/pkill/tests/pkill-j_test.shSat Feb 14 19:18:56 2015
(r278775)
+++ head/bin/pkill/tests/pkill-j_test.shSat Feb 14 19:21:04 2015
(r278776)
@@ -4,99 +4,90 @@
 jail_name_to_jid()
 {
local check_name=$1
-   (
-   line=$(jls -n 2 /dev/null | grep  name=$check_name  )
-   for nv in $line; do
-   local name=${nv%=*}
-   if [ ${name} = jid ]; then
-   eval $nv
-   echo $jid
-   break
-   fi
-   done
-   )
+   jls -j $check_name -s 2/dev/null | tr ' ' '\n' | grep jid= | sed -e 
's/.*=//g'
 }
 
 base=pkill_j_test
 
+if [ `id -u` -ne 0 ]; then
+   echo 1..0 # skip Test needs uid 0.
+   exit 0
+fi
+
 echo 1..3
 
+sleep=$(pwd)/sleep.txt
+ln -sf /bin/sleep $sleep
+
 name=pkill -j jid
-if [ `id -u` -eq 0 ]; then
-   sleep=$(pwd)/sleep.txt
-   ln -sf /bin/sleep $sleep
-jail -c path=/ name=${base}_1_1 ip4.addr=127.0.0.1 \
-command=daemon -p ${PWD}/${base}_1_1.pid $sleep 5 
+sleep_amount=5
+jail -c path=/ name=${base}_1_1 ip4.addr=127.0.0.1 \
+command=daemon -p ${PWD}/${base}_1_1.pid $sleep $sleep_amount 
+
+jail -c path=/ name=${base}_1_2 ip4.addr=127.0.0.1 \
+command=daemon -p ${PWD}/${base}_1_2.pid $sleep $sleep_amount 
 
-jail -c path=/ name=${base}_1_2 ip4.addr=127.0.0.1 \
-command=daemon -p ${PWD}/${base}_1_2.pid $sleep 5 
+$sleep $sleep_amount 
 
-   $sleep 5 
-   sleep 0.5
+for i in `seq 1 10`; do
jid1=$(jail_name_to_jid ${base}_1_1)
jid2=$(jail_name_to_jid ${base}_1_2)
jid=${jid1},${jid2}
-   if pkill -f -j $jid $sleep  sleep 0.5 
-   ! -f ${PWD}/${base}_1_1.pid 
-   ! -f ${PWD}/${base}_1_2.pid ; then
-   echo ok 1 - $name
-   else
-   echo not ok 1 - $name
-   fi 2/dev/null
-   rm -f $sleep
-   [ -f ${PWD}/${base}_1_1.pid ]  kill $(cat ${PWD}/${base}_1_1.pid)
-   [ -f ${PWD}/${base}_1_2.pid ]  kill $(cat ${PWD}/${base}_1_2.pid)
-   wait
+   case $jid in
+   [0-9]+,[0-9]+)
+   break
+   ;;
+   esac
+   sleep 0.1
+done
+
+if pkill -f -j $jid $sleep  sleep 0.5 
+! -f ${PWD}/${base}_1_1.pid 
+! -f ${PWD}/${base}_1_2.pid ; then
+   echo ok 1 - $name
 else
-   echo ok 1 - $name # skip Test needs uid 0.
-fi
+   echo not ok 1 - $name
+fi 2/dev/null
+[ -f ${PWD}/${base}_1_1.pid ]  kill $(cat ${PWD}/${base}_1_1.pid)
+[ -f ${PWD}/${base}_1_2.pid ]  kill $(cat ${PWD}/${base}_1_2.pid)
+wait
 
 name=pkill -j any
-if [ `id -u` -eq 0 ]; then
-   sleep=$(pwd)/sleep.txt
-   ln -sf /bin/sleep $sleep
-jail -c path=/ name=${base}_2_1 ip4.addr=127.0.0.1 \
-command=daemon -p ${PWD}/${base}_2_1.pid $sleep 5 
-
-jail -c path=/ name=${base}_2_2 ip4.addr=127.0.0.1 \
-command=daemon -p ${PWD}/${base}_2_2.pid $sleep 5 
-
-   $sleep 5 
-   sleep 0.5
-   chpid3=$!
-   if pkill -f -j any $sleep  sleep 0.5 
-   [ ! -f ${PWD}/${base}_2_1.pid -a
- ! -f ${PWD}/${base}_2_2.pid ]  kill $chpid3; then
-   echo ok 2 - $name
-   else
-   echo not ok 2 - $name
-   fi 2/dev/null
-   rm -f $sleep
-   [ -f ${PWD}/${base}_2_1.pid ]  kill $(cat ${PWD}/${base}_2_1.pid)
-   [ -f ${PWD}/${base}_2_2.pid ]  kill $(cat ${PWD}/${base}_2_2.pid)
-   wait
+sleep_amount=6
+jail -c path=/ name=${base}_2_1 ip4.addr=127.0.0.1 \
+command=daemon -p ${PWD}/${base}_2_1.pid $sleep $sleep_amount 
+
+jail -c path=/ name=${base}_2_2 ip4.addr=127.0.0.1 \
+command=daemon -p 

svn commit: r278764 - head/sys/dev/wpi

2015-02-14 Thread Adrian Chadd
Author: adrian
Date: Sat Feb 14 17:45:53 2015
New Revision: 278764
URL: https://svnweb.freebsd.org/changeset/base/278764

Log:
  More fixes to wpi(4), again not by me! Woo!
  
  - Use IEEE80211_F_DATAPAD;
  - (c-ic_flags  IEEE80211_CHAN_PASSIVE) - IEEE80211_IS_CHAN_PASSIVE(c);
  - Convert ackfailcnt to int (there is dereference to *(int *) in 
ieee80211_ratectl_tx_complete());
  - Fix  move cleanup to the end in wpi_rx_done();
  - Add missed lock in wpi_update_beacon();
  - Try to fix powersave.
  
  PR:   kern/197143
  Submitted by:  Andriy Voskoboinyk s3er...@gmail.com

Modified:
  head/sys/dev/wpi/if_wpi.c
  head/sys/dev/wpi/if_wpireg.h

Modified: head/sys/dev/wpi/if_wpi.c
==
--- head/sys/dev/wpi/if_wpi.c   Sat Feb 14 17:44:24 2015(r278763)
+++ head/sys/dev/wpi/if_wpi.c   Sat Feb 14 17:45:53 2015(r278764)
@@ -42,7 +42,7 @@ __FBSDID($FreeBSD$);
  *
  * A similar thing happens with the tx rings. The difference is the firmware
  * stop processing buffers once the queue is full and until confirmation
- * of a successful transmition (tx_intr) has occurred.
+ * of a successful transmition (tx_done) has occurred.
  *
  * The command ring operates in the same manner as the tx queues.
  *
@@ -447,6 +447,8 @@ wpi_attach(device_t dev)
ic-ic_cryptocaps =
  IEEE80211_CRYPTO_AES_CCM;
 
+   ic-ic_flags |= IEEE80211_F_DATAPAD;
+
/*
 * Read in the eeprom and also setup the channels for
 * net80211. We don't set the rates as net80211 does this for us
@@ -1378,8 +1380,7 @@ wpi_read_eeprom_band(struct wpi_softc *s
adding chan %d (%dMHz) flags=0x%x maxpwr=%d passive=%d,
 offset %d\n, chan, c-ic_freq,
channels[i].flags, sc-maxpwr[chan],
-   (c-ic_flags  IEEE80211_CHAN_PASSIVE) != 0,
-   ic-ic_nchans);
+   IEEE80211_IS_CHAN_PASSIVE(c), ic-ic_nchans);
}
 }
 
@@ -1695,8 +1696,7 @@ wpi_rx_done(struct wpi_softc *sc, struct
 
if (stat-len  WPI_STAT_MAXLEN) {
device_printf(sc-sc_dev, invalid RX statistic header\n);
-   if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
-   return;
+   goto fail1;
}
 
bus_dmamap_sync(ring-data_dmat, data-map, BUS_DMASYNC_POSTREAD);
@@ -1714,23 +1714,20 @@ wpi_rx_done(struct wpi_softc *sc, struct
if ((flags  WPI_RX_NOERROR) != WPI_RX_NOERROR) {
DPRINTF(sc, WPI_DEBUG_RECV, %s: RX flags error %x\n,
__func__, flags);
-   if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
-   return;
+   goto fail1;
}
/* Discard frames that are too short. */
if (len  sizeof (*wh)) {
DPRINTF(sc, WPI_DEBUG_RECV, %s: frame too short: %d\n,
__func__, len);
-   if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
-   return;
+   goto fail1;
}
 
m1 = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, MJUMPAGESIZE);
if (m1 == NULL) {
DPRINTF(sc, WPI_DEBUG_ANY, %s: no mbuf to restock ring\n,
__func__);
-   if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
-   return;
+   goto fail1;
}
bus_dmamap_unload(ring-data_dmat, data-map);
 
@@ -1752,8 +1749,7 @@ wpi_rx_done(struct wpi_softc *sc, struct
ring-desc[ring-cur] = htole32(paddr);
bus_dmamap_sync(ring-data_dmat, ring-desc_dma.map,
BUS_DMASYNC_PREWRITE);
-   if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
-   return;
+   goto fail1;
}
 
m = data-m;
@@ -1777,18 +1773,14 @@ wpi_rx_done(struct wpi_softc *sc, struct
if ((wh-i_fc[1]  IEEE80211_FC1_PROTECTED) 
!IEEE80211_IS_MULTICAST(wh-i_addr1) 
cip != NULL  cip-ic_cipher == IEEE80211_CIPHER_AES_CCM) {
-   if ((flags  WPI_RX_CIPHER_MASK) != WPI_RX_CIPHER_CCMP) {
-   if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
-   m_freem(m);
-   return;
-   }
+   if ((flags  WPI_RX_CIPHER_MASK) != WPI_RX_CIPHER_CCMP)
+   goto fail2;
+
/* Check whether decryption was successful or not. */
if ((flags  WPI_RX_DECRYPT_MASK) != WPI_RX_DECRYPT_OK) {
DPRINTF(sc, WPI_DEBUG_RECV,
CCMP decryption failed 0x%x\n, flags);
-   if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
-   m_freem(m);
-   return;
+   goto fail2;
}
m-m_flags |= M_WEP;
}
@@ -1817,6 +1809,13 @@ wpi_rx_done(struct wpi_softc *sc, struct
(void)ieee80211_input_all(ic, m, 

Re: svn commit: r278737 - head/usr.sbin/flowctl

2015-02-14 Thread Gleb Smirnoff
  Bruce,

On Sat, Feb 14, 2015 at 08:46:58PM +1100, Bruce Evans wrote:
B Using VLAs and also the C99 feature of declarations anwhere, and extensions
B like __aligned(), we can almost implement a full alloca() using the fixed
B version of this change:
B 
B /*
B   * XXX need extended statement-expression so that __buf doesn't go out
B   * of scope after the right brace.
B   */
B #define  my_alloca(n) __extension__ ({
B  /* XXX need unique name. */ \
B  char __buf[__roundup2((n), MUMBLE)] __aligned(MUMBLE);  \
B  \
B  (void *)__buf;  \
B })

I like this idea. But would this exact code work? The life of
__buf is limited by the code block, and we exit the block
immediately. Wouldn't the allocation be overwritten if we
enter any function or block later?

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


svn commit: r278766 - head/sys/net

2015-02-14 Thread Hiroki Sato
Author: hrs
Date: Sat Feb 14 18:15:14 2015
New Revision: 278766
URL: https://svnweb.freebsd.org/changeset/base/278766

Log:
  Fix a panic when tearing down a vnet on a VIMAGE-enabled kernel.
  There was a race that bridge_ifdetach() could be called via
  ifnet_departure event handler after vnet_bridge_uninit().
  
  PR:   195859
  Reported by:  Danilo Egea Gondolfo

Modified:
  head/sys/net/if_bridge.c

Modified: head/sys/net/if_bridge.c
==
--- head/sys/net/if_bridge.cSat Feb 14 18:14:45 2015(r278765)
+++ head/sys/net/if_bridge.cSat Feb 14 18:15:14 2015(r278766)
@@ -228,7 +228,7 @@ struct bridge_softc {
 
 static VNET_DEFINE(struct mtx, bridge_list_mtx);
 #defineV_bridge_list_mtx   VNET(bridge_list_mtx)
-eventhandler_tag   bridge_detach_cookie = NULL;
+static eventhandler_tag bridge_detach_cookie;
 
 intbridge_rtable_prune_period = BRIDGE_RTABLE_PRUNE_PERIOD;
 
@@ -538,6 +538,7 @@ vnet_bridge_uninit(const void *unused __
 {
 
if_clone_detach(V_bridge_cloner);
+   V_bridge_cloner = NULL;
BRIDGE_LIST_LOCK_DESTROY();
 }
 VNET_SYSUNINIT(vnet_bridge_uninit, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY,
@@ -1797,7 +1798,13 @@ bridge_ifdetach(void *arg __unused, stru
 
if (ifp-if_flags  IFF_RENAMING)
return;
-
+   if (V_bridge_cloner == NULL) {
+   /*
+* This detach handler can be called after
+* vnet_bridge_uninit().  Just return in that case.
+*/
+   return;
+   }
/* Check if the interface is a bridge member */
if (sc != NULL) {
BRIDGE_LOCK(sc);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r278765 - head/sys/dev/ath

2015-02-14 Thread Adrian Chadd
Author: adrian
Date: Sat Feb 14 18:14:45 2015
New Revision: 278765
URL: https://svnweb.freebsd.org/changeset/base/278765

Log:
  Move the lock destruction/creation to earlier in the process - if
  interrupts are enabled and the NIC is awake (think: loading a module)
  then there's a not-quite-zero window where we'll get an interrupt
  for the device before the attach method is called to finish setting
  up the hardware.
  
  Since I grab locks in ath_intr() to check various things, the locks
  need to be ready much earlier.

Modified:
  head/sys/dev/ath/if_ath_pci.c

Modified: head/sys/dev/ath/if_ath_pci.c
==
--- head/sys/dev/ath/if_ath_pci.c   Sat Feb 14 17:45:53 2015
(r278764)
+++ head/sys/dev/ath/if_ath_pci.c   Sat Feb 14 18:14:45 2015
(r278765)
@@ -279,6 +279,13 @@ ath_pci_attach(device_t dev)
 */
sc-sc_invalid = 1;
 
+   ATH_LOCK_INIT(sc);
+   ATH_PCU_LOCK_INIT(sc);
+   ATH_RX_LOCK_INIT(sc);
+   ATH_TX_LOCK_INIT(sc);
+   ATH_TX_IC_LOCK_INIT(sc);
+   ATH_TXSTATUS_LOCK_INIT(sc);
+
/*
 * Arrange interrupt line.
 */
@@ -329,7 +336,7 @@ ath_pci_attach(device_t dev)
if (fw == NULL) {
device_printf(dev, %s: couldn't find firmware\n,
__func__);
-   goto bad3;
+   goto bad4;
}
 
device_printf(dev, %s: EEPROM firmware @ %p\n,
@@ -339,30 +346,20 @@ ath_pci_attach(device_t dev)
if (! sc-sc_eepromdata) {
device_printf(dev, %s: can't malloc eepromdata\n,
__func__);
-   goto bad3;
+   goto bad4;
}
memcpy(sc-sc_eepromdata, fw-data, fw-datasize);
firmware_put(fw, 0);
}
 #endif /* ATH_EEPROM_FIRMWARE */
 
-   ATH_LOCK_INIT(sc);
-   ATH_PCU_LOCK_INIT(sc);
-   ATH_RX_LOCK_INIT(sc);
-   ATH_TX_LOCK_INIT(sc);
-   ATH_TX_IC_LOCK_INIT(sc);
-   ATH_TXSTATUS_LOCK_INIT(sc);
-
error = ath_attach(pci_get_device(dev), sc);
if (error == 0) /* success */
return 0;
 
-   ATH_TXSTATUS_LOCK_DESTROY(sc);
-   ATH_PCU_LOCK_DESTROY(sc);
-   ATH_RX_LOCK_DESTROY(sc);
-   ATH_TX_IC_LOCK_DESTROY(sc);
-   ATH_TX_LOCK_DESTROY(sc);
-   ATH_LOCK_DESTROY(sc);
+#ifdef ATH_EEPROM_FIRMWARE
+bad4:
+#endif
bus_dma_tag_destroy(sc-sc_dmat);
 bad3:
bus_teardown_intr(dev, psc-sc_irq, psc-sc_ih);
@@ -370,6 +367,14 @@ bad2:
bus_release_resource(dev, SYS_RES_IRQ, 0, psc-sc_irq);
 bad1:
bus_release_resource(dev, SYS_RES_MEMORY, BS_BAR, psc-sc_sr);
+
+   ATH_TXSTATUS_LOCK_DESTROY(sc);
+   ATH_PCU_LOCK_DESTROY(sc);
+   ATH_RX_LOCK_DESTROY(sc);
+   ATH_TX_IC_LOCK_DESTROY(sc);
+   ATH_TX_LOCK_DESTROY(sc);
+   ATH_LOCK_DESTROY(sc);
+
 bad:
return (error);
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r278760 - head/sys/kern

2015-02-14 Thread John Baldwin
Author: jhb
Date: Sat Feb 14 17:02:51 2015
New Revision: 278760
URL: https://svnweb.freebsd.org/changeset/base/278760

Log:
  Add two new counters for vnode life cycle events:
  - vfs.recycles counts the number of vnodes forcefully recycled to avoid
exceeding kern.maxvnodes.
  - vfs.vnodes_created counts the number of vnodes created by successful
calls to getnewvnode().
  
  Differential Revision:https://reviews.freebsd.org/D1671
  Reviewed by:  kib
  MFC after:1 week

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cSat Feb 14 16:23:04 2015(r278759)
+++ head/sys/kern/vfs_subr.cSat Feb 14 17:02:51 2015(r278760)
@@ -122,6 +122,10 @@ static unsigned long   numvnodes;
 SYSCTL_ULONG(_vfs, OID_AUTO, numvnodes, CTLFLAG_RD, numvnodes, 0,
 Number of vnodes in existence);
 
+static u_long vnodes_created;
+SYSCTL_ULONG(_vfs, OID_AUTO, vnodes_created, CTLFLAG_RD, vnodes_created,
+0, Number of vnodes created by getnewvnode);
+
 /*
  * Conversion tables for conversion from vnode types to inode formats
  * and back.
@@ -156,6 +160,10 @@ static int vlru_allow_cache_src;
 SYSCTL_INT(_vfs, OID_AUTO, vlru_allow_cache_src, CTLFLAG_RW,
 vlru_allow_cache_src, 0, Allow vlru to reclaim source vnode);
 
+static u_long recycles_count;
+SYSCTL_ULONG(_vfs, OID_AUTO, recycles, CTLFLAG_RD, recycles_count, 0,
+Number of vnodes recycled to avoid exceding kern.maxvnodes);
+
 /*
  * Various variables used for debugging the new implementation of
  * reassignbuf().
@@ -788,6 +796,7 @@ vlrureclaim(struct mount *mp)
}
KASSERT((vp-v_iflag  VI_DOOMED) == 0,
(VI_DOOMED unexpectedly detected in vlrureclaim()));
+   atomic_add_long(recycles_count, 1);
vgonel(vp);
VOP_UNLOCK(vp, 0);
vdropl(vp);
@@ -988,8 +997,10 @@ vtryrecycle(struct vnode *vp)
__func__, vp);
return (EBUSY);
}
-   if ((vp-v_iflag  VI_DOOMED) == 0)
+   if ((vp-v_iflag  VI_DOOMED) == 0) {
+   atomic_add_long(recycles_count, 1);
vgonel(vp);
+   }
VOP_UNLOCK(vp, LK_INTERLOCK);
vn_finished_write(vnmp);
return (0);
@@ -1093,6 +1104,7 @@ getnewvnode(const char *tag, struct moun
atomic_add_long(numvnodes, 1);
mtx_unlock(vnode_free_list_mtx);
 alloc:
+   atomic_add_long(vnodes_created, 1);
vp = (struct vnode *) uma_zalloc(vnode_zone, M_WAITOK|M_ZERO);
/*
 * Setup locks.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r278762 - head/sys/contrib/dev/ath/ath_hal/ar9300

2015-02-14 Thread Adrian Chadd
Author: adrian
Date: Sat Feb 14 17:43:54 2015
New Revision: 278762
URL: https://svnweb.freebsd.org/changeset/base/278762

Log:
  Quieten a clang warning.

Modified:
  head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_gpio.c

Modified: head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_gpio.c
==
--- head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_gpio.c   Sat Feb 14 
17:12:31 2015(r278761)
+++ head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_gpio.c   Sat Feb 14 
17:43:54 2015(r278762)
@@ -394,7 +394,7 @@ ar9300_gpio_get(struct ath_hal *ah, u_in
 {
 u_int32_t gpio_in;
 HALASSERT(gpio  AH_PRIVATE(ah)-ah_caps.halNumGpioPins);
-if ((gpio == AR9382_GPIO_PIN_8_RESERVED))
+if (gpio == AR9382_GPIO_PIN_8_RESERVED)
 {
 return 0x;
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r278767 - head/usr.sbin/pw/tests

2015-02-14 Thread Brad Davis
Author: brd (doc committer)
Date: Sat Feb 14 18:22:31 2015
New Revision: 278767
URL: https://svnweb.freebsd.org/changeset/base/278767

Log:
  Remove an extra curly bracket that was causing intermittent failures.
  
  PR:   197612
  Submitted by: Robert O'Niel oneil...@gmail.com
  Approved by:  will

Modified:
  head/usr.sbin/pw/tests/pw_usernext.sh

Modified: head/usr.sbin/pw/tests/pw_usernext.sh
==
--- head/usr.sbin/pw/tests/pw_usernext.sh   Sat Feb 14 18:15:14 2015
(r278766)
+++ head/usr.sbin/pw/tests/pw_usernext.sh   Sat Feb 14 18:22:31 2015
(r278767)
@@ -32,7 +32,7 @@ usernext_assigned_group_body() {
atf_check -s exit:0 ${PW} useradd -n test$var0 -g 0
var0=`expr $var0 + 1`
done
-   atf_check -s exit:0 -o match:100${LIMIT}:1001} \
+   atf_check -s exit:0 -o match:100${LIMIT}:1001 \
${PW} usernext
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


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

2015-02-14 Thread Mateusz Guzik
On Sat, Feb 14, 2015 at 05:02:51PM +, John Baldwin wrote:
 +SYSCTL_ULONG(_vfs, OID_AUTO, vnodes_created, CTLFLAG_RD, vnodes_created,
 +0, Number of vnodes created by getnewvnode);
 +
[..]
 +static u_long recycles_count;
 +SYSCTL_ULONG(_vfs, OID_AUTO, recycles, CTLFLAG_RD, recycles_count, 0,
 +Number of vnodes recycled to avoid exceding kern.maxvnodes);
 +

CTLFLAG_MPSAFE?

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


svn commit: r278770 - head/sys/arm/arm

2015-02-14 Thread Ian Lepore
Author: ian
Date: Sat Feb 14 18:54:52 2015
New Revision: 278770
URL: https://svnweb.freebsd.org/changeset/base/278770

Log:
  Add logic for handling new-style ARM cpu ID info.
  
  Submitted by: Michal Meloun mel...@miracle.cz

Modified:
  head/sys/arm/arm/cpuinfo.c

Modified: head/sys/arm/arm/cpuinfo.c
==
--- head/sys/arm/arm/cpuinfo.c  Sat Feb 14 18:45:43 2015(r278769)
+++ head/sys/arm/arm/cpuinfo.c  Sat Feb 14 18:54:52 2015(r278770)
@@ -58,9 +58,13 @@ cpuinfo_init(void)
/* ARMv4T CPU */
cpuinfo.architecture = 1;
cpuinfo.revision = (cpuinfo.midr  16)  0x7F;
-   } 
+   } else {
+   /* ARM new id scheme */
+   cpuinfo.architecture = (cpuinfo.midr  16)  0x0F;
+   cpuinfo.revision = (cpuinfo.midr  20)  0x0F;
+   }
} else {
-   /* must be new id scheme */
+   /* non ARM - must be new id scheme */
cpuinfo.architecture = (cpuinfo.midr  16)  0x0F;
cpuinfo.revision = (cpuinfo.midr  20)  0x0F;
}   
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r278774 - head/sys/dev/netmap

2015-02-14 Thread Luigi Rizzo
Author: luigi
Date: Sat Feb 14 19:03:11 2015
New Revision: 278774
URL: https://svnweb.freebsd.org/changeset/base/278774

Log:
  two minor changes from the master netmap version:
  1. handle errors from nm_config(), if any (none of the FreeBSD drivers
 currently returns an error on this function, so this change
 is a no-op at this time
  2. use a full memory barrier on ioctls

Modified:
  head/sys/dev/netmap/netmap.c

Modified: head/sys/dev/netmap/netmap.c
==
--- head/sys/dev/netmap/netmap.cSat Feb 14 18:59:31 2015
(r278773)
+++ head/sys/dev/netmap/netmap.cSat Feb 14 19:03:11 2015
(r278774)
@@ -656,9 +656,8 @@ netmap_update_config(struct netmap_adapt
u_int txr, txd, rxr, rxd;
 
txr = txd = rxr = rxd = 0;
-   if (na-nm_config) {
-   na-nm_config(na, txr, txd, rxr, rxd);
-   } else {
+   if (na-nm_config == NULL ||
+   na-nm_config(na, txr, txd, rxr, rxd)) {
/* take whatever we had at init time */
txr = na-num_tx_rings;
txd = na-num_tx_desc;
@@ -2168,7 +2167,7 @@ netmap_ioctl(struct cdev *dev, u_long cm
error = ENXIO;
break;
}
-   rmb(); /* make sure following reads are not from cache */
+   mb(); /* make sure following reads are not from cache */
 
na = priv-np_na;  /* we have a reference */
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r278761 - in head: sys/kern usr.bin/gcore

2015-02-14 Thread John Baldwin
Author: jhb
Date: Sat Feb 14 17:12:31 2015
New Revision: 278761
URL: https://svnweb.freebsd.org/changeset/base/278761

Log:
  Include OBJT_PHYS VM objects in ELF core dumps. In particular this
  includes the shared page allowing debuggers to use the signal trampoline
  code to identify signal frames in core dumps.
  
  Differential Revision:https://reviews.freebsd.org/D1828
  Reviewed by:  alc, kib
  MFC after:1 week

Modified:
  head/sys/kern/imgact_elf.c
  head/usr.bin/gcore/elfcore.c

Modified: head/sys/kern/imgact_elf.c
==
--- head/sys/kern/imgact_elf.c  Sat Feb 14 17:02:51 2015(r278760)
+++ head/sys/kern/imgact_elf.c  Sat Feb 14 17:12:31 2015(r278761)
@@ -1401,7 +1401,8 @@ each_writable_segment(td, func, closure)
object = backing_object;
}
ignore_entry = object-type != OBJT_DEFAULT 
-   object-type != OBJT_SWAP  object-type != OBJT_VNODE;
+   object-type != OBJT_SWAP  object-type != OBJT_VNODE 
+   object-type != OBJT_PHYS;
VM_OBJECT_RUNLOCK(object);
if (ignore_entry)
continue;

Modified: head/usr.bin/gcore/elfcore.c
==
--- head/usr.bin/gcore/elfcore.cSat Feb 14 17:02:51 2015
(r278760)
+++ head/usr.bin/gcore/elfcore.cSat Feb 14 17:12:31 2015
(r278761)
@@ -511,7 +511,8 @@ readmap(pid_t pid)
((pflags  PFLAGS_FULL) == 0 
kve-kve_type != KVME_TYPE_DEFAULT 
kve-kve_type != KVME_TYPE_VNODE 
-   kve-kve_type != KVME_TYPE_SWAP))
+   kve-kve_type != KVME_TYPE_SWAP 
+   kve-kve_type != KVME_TYPE_PHYS))
continue;
 
ent = calloc(1, sizeof(*ent));
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r278763 - head/sys/contrib/dev/ath/ath_hal/ar9300

2015-02-14 Thread Adrian Chadd
Author: adrian
Date: Sat Feb 14 17:44:24 2015
New Revision: 278763
URL: https://svnweb.freebsd.org/changeset/base/278763

Log:
  Comment out a double declaration of this particular function name.
  It trips up gcc builds.
  
  Pointy-hat-from:  jenkins, kib

Modified:
  head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h

Modified: head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h
==
--- head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300.hSat Feb 14 17:43:54 
2015(r278762)
+++ head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300.hSat Feb 14 17:44:24 
2015(r278763)
@@ -1239,7 +1239,9 @@ extern  HAL_BOOL ar9300_set_mac_address(
 extern  void ar9300_get_bss_id_mask(struct ath_hal *ah, u_int8_t *mac);
 extern  HAL_BOOL ar9300_set_bss_id_mask(struct ath_hal *, const u_int8_t *);
 extern  HAL_STATUS ar9300_select_ant_config(struct ath_hal *ah, u_int32_t cfg);
+#if 0
 extern  u_int32_t ar9300_ant_ctrl_common_get(struct ath_hal *ah, HAL_BOOL 
is_2ghz);
+#endif
 extern HAL_BOOL ar9300_ant_swcom_sel(struct ath_hal *ah, u_int8_t ops,
 u_int32_t *common_tbl1, u_int32_t 
*common_tbl2);
 extern  HAL_BOOL ar9300_set_regulatory_domain(struct ath_hal *ah,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r278773 - head/sys/dev/netmap

2015-02-14 Thread Luigi Rizzo
Author: luigi
Date: Sat Feb 14 18:59:31 2015
New Revision: 278773
URL: https://svnweb.freebsd.org/changeset/base/278773

Log:
  whitespace change:
  clarify the role of MAKEDEV_ETERNAL_KLD, and remove an old
  #ifdef __FreeBSD__ since the code is valid on all platforms.

Modified:
  head/sys/dev/netmap/netmap.c

Modified: head/sys/dev/netmap/netmap.c
==
--- head/sys/dev/netmap/netmap.cSat Feb 14 18:57:02 2015
(r278772)
+++ head/sys/dev/netmap/netmap.cSat Feb 14 18:59:31 2015
(r278773)
@@ -3071,16 +3071,14 @@ netmap_init(void)
error = netmap_mem_init();
if (error != 0)
goto fail;
-   /* XXX could use make_dev_credv() to get error number */
-#ifdef __FreeBSD__
-   /* support for the 'eternal' flag */
+   /*
+* MAKEDEV_ETERNAL_KLD avoids an expensive check on syscalls
+* when the module is compiled in.
+* XXX could use make_dev_credv() to get error number
+*/
netmap_dev = make_dev_credf(MAKEDEV_ETERNAL_KLD,
netmap_cdevsw, 0, NULL, UID_ROOT, GID_WHEEL, 0600,
  netmap);
-#else
-   netmap_dev = make_dev(netmap_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
- netmap);
-#endif
if (!netmap_dev)
goto fail;
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r278737 - head/usr.sbin/flowctl

2015-02-14 Thread Pedro Giffuni


On 02/14/15 13:33, Ian Lepore wrote:

On Sat, 2015-02-14 at 21:15 +0300, Gleb Smirnoff wrote:

   Bruce,

On Sat, Feb 14, 2015 at 08:46:58PM +1100, Bruce Evans wrote:
B Using VLAs and also the C99 feature of declarations anwhere, and extensions
B like __aligned(), we can almost implement a full alloca() using the fixed
B version of this change:
B
B /*
B   * XXX need extended statement-expression so that __buf doesn't go out
B   * of scope after the right brace.
B   */
B #define   my_alloca(n) __extension__ ({
B   /* XXX need unique name. */ \
B   char __buf[__roundup2((n), MUMBLE)] __aligned(MUMBLE);  \
B   \
B   (void *)__buf;  \
B })

I like this idea. But would this exact code work? The life of
__buf is limited by the code block, and we exit the block
immediately. Wouldn't the allocation be overwritten if we
enter any function or block later?


Why put any effort into avoiding alloca() in the first place?  Is it
inefficient on some platforms?  On arm it's like 5 instructions, it just
adjusts the size to keep the stack dword-aligned and subtracts the
result from sp, done.


Because it's non-standard and the alloca(3) man page discourages it:
_
...
BUGS
The alloca() function is machine and compiler dependent; its use is dis-
couraged.



It is not disappearing anytime soon though, some even say the man
page is wrong.

Pedro.

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


Re: Phabricator + 'Reviewed by' [was Re: svn commit: r278472 - in head/sys: netinet netinet6]

2015-02-14 Thread Bryan Drewery
On 2/14/2015 9:17 AM, Steven Hartland wrote:
 
 On 13/02/2015 23:56, Bryan Drewery wrote:
 On 2/9/2015 3:45 PM, Bjoern A. Zeeb wrote:
   Commented upon by hiren and sbruno
   See Phabricator D1777 for more details.

   Commented upon by hiren and sbruno
   Reviewed by:adrian, jhb and bz
 I have not reviewed this;  as a matter of fact you are aware that I
 still wanted to do that.

 Something about Phabricator is not jiving with our commit terminology.
 This has happened before as well with other commits. I'm sure everyone
 is good-intentioned as well.

 There's not 1 person on D1777 who has 'accepted' it. That is what
 warrants a 'Reviewed by' to me.

 It's clear to me, but seems unclear to others. I really think the
 reviewer list needs to be split up. Rather than using icons, use
 separate lists. Reviewers requested: accepted: commented: changes
 requested:.
 I don't think it needs to be split up, that feels unnecessary, if
 someone hasn't accepted it then they haven't review it period IMO.

Yes I too think it's obvious, yet I've seen at least 2 commits where the
reviewed by line was essentially a lie. It's in SVN forever now with
those names stamped as reviewers.

-- 
Regards,
Bryan Drewery



signature.asc
Description: OpenPGP digital signature


svn commit: r278780 - head/sys/kern

2015-02-14 Thread Davide Italiano
Author: davide
Date: Sat Feb 14 20:00:57 2015
New Revision: 278780
URL: https://svnweb.freebsd.org/changeset/base/278780

Log:
  Don't access sockbuf fields directly, use accessor functions instead.
  It is safe to move the call to socantsendmore_locked() after
  sbdrop_locked() as long as we hold the sockbuf lock across the two
  calls.
  
  CR:   D1805
  Reviewed by:  adrian, kmacy, julian, rwatson

Modified:
  head/sys/kern/uipc_socket.c

Modified: head/sys/kern/uipc_socket.c
==
--- head/sys/kern/uipc_socket.c Sat Feb 14 19:41:26 2015(r278779)
+++ head/sys/kern/uipc_socket.c Sat Feb 14 20:00:57 2015(r278780)
@@ -3439,11 +3439,9 @@ soisdisconnecting(struct socket *so)
SOCKBUF_LOCK(so-so_rcv);
so-so_state = ~SS_ISCONNECTING;
so-so_state |= SS_ISDISCONNECTING;
-   so-so_rcv.sb_state |= SBS_CANTRCVMORE;
-   sorwakeup_locked(so);
+   socantrcvmore_locked(so);
SOCKBUF_LOCK(so-so_snd);
-   so-so_snd.sb_state |= SBS_CANTSENDMORE;
-   sowwakeup_locked(so);
+   socantsendmore_locked(so);
wakeup(so-so_timeo);
 }
 
@@ -3458,12 +3456,10 @@ soisdisconnected(struct socket *so)
SOCKBUF_LOCK(so-so_rcv);
so-so_state = ~(SS_ISCONNECTING|SS_ISCONNECTED|SS_ISDISCONNECTING);
so-so_state |= SS_ISDISCONNECTED;
-   so-so_rcv.sb_state |= SBS_CANTRCVMORE;
-   sorwakeup_locked(so);
+   socantrcvmore_locked(so);
SOCKBUF_LOCK(so-so_snd);
-   so-so_snd.sb_state |= SBS_CANTSENDMORE;
sbdrop_locked(so-so_snd, sbused(so-so_snd));
-   sowwakeup_locked(so);
+   socantsendmore_locked(so);
wakeup(so-so_timeo);
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: Phabricator + 'Reviewed by' [was Re: svn commit: r278472 - in head/sys: netinet netinet6]

2015-02-14 Thread Ian Lepore
On Sat, 2015-02-14 at 13:59 -0600, Bryan Drewery wrote:
 On 2/14/2015 9:17 AM, Steven Hartland wrote:
  
  On 13/02/2015 23:56, Bryan Drewery wrote:
  On 2/9/2015 3:45 PM, Bjoern A. Zeeb wrote:
Commented upon by hiren and sbruno
See Phabricator D1777 for more details.
 
Commented upon by hiren and sbruno
Reviewed by:adrian, jhb and bz
  I have not reviewed this;  as a matter of fact you are aware that I
  still wanted to do that.
 
  Something about Phabricator is not jiving with our commit terminology.
  This has happened before as well with other commits. I'm sure everyone
  is good-intentioned as well.
 
  There's not 1 person on D1777 who has 'accepted' it. That is what
  warrants a 'Reviewed by' to me.
 
  It's clear to me, but seems unclear to others. I really think the
  reviewer list needs to be split up. Rather than using icons, use
  separate lists. Reviewers requested: accepted: commented: changes
  requested:.
  I don't think it needs to be split up, that feels unnecessary, if
  someone hasn't accepted it then they haven't review it period IMO.
 
 Yes I too think it's obvious, yet I've seen at least 2 commits where the
 reviewed by line was essentially a lie. It's in SVN forever now with
 those names stamped as reviewers.
 

You make that sound like some sort of huge crisis, but we have glitches
in commit messages (occasionally even a missing/empty message) from time
to time, and life goes on.  Phabricator is supposed to be a tool to make
our lives better and easier, but it could all too easily turn into a
stick to hit people with, and the first step on that path is making a
bunch of rigid formal rules and procedures.

-- Ian


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


svn commit: r278787 - head/sys/dev/atkbdc

2015-02-14 Thread Michael Gmelin
Author: grembo (ports committer)
Date: Sat Feb 14 22:12:17 2015
New Revision: 278787
URL: https://svnweb.freebsd.org/changeset/base/278787

Log:
  Quirk based support of Chromebook keyboard found in Acer C720
  
  This probably supports other devices based on SeaBIOS, which need
  to be added to the smbios based quirks table.
  
  The functionality has been ported from DragonFlyBSD and adapted
  to FreeBSD's more general purpose environment.
  
  Devices not covered by a quirk shouldn't be affected at all. Thanks
  to jhb and kostikbel for reviewing the code.
  
  Reviewed by:  kostikbel, jhb
  Approved by:  jhb, kostikbel
  Differential Revision: https://reviews.freebsd.org/D1802

Modified:
  head/sys/dev/atkbdc/atkbd.c
  head/sys/dev/atkbdc/atkbdc.c
  head/sys/dev/atkbdc/atkbdcreg.h
  head/sys/dev/atkbdc/psm.c

Modified: head/sys/dev/atkbdc/atkbd.c
==
--- head/sys/dev/atkbdc/atkbd.c Sat Feb 14 21:16:19 2015(r278786)
+++ head/sys/dev/atkbdc/atkbd.c Sat Feb 14 22:12:17 2015(r278787)
@@ -77,6 +77,10 @@ typedef struct atkbd_state {
 
 static voidatkbd_timeout(void *arg);
 static voidatkbd_shutdown_final(void *v);
+static int atkbd_reset(KBDC kbdc, int flags, int c);
+
+#define HAS_QUIRK(p, q)(((atkbdc_softc_t *)(p))-quirks  q)
+#define ALLOW_DISABLE_KBD(kbdc)!HAS_QUIRK(kbdc, 
KBDC_QUIRK_KEEP_ACTIVATED)
 
 int
 atkbd_probe_unit(device_t dev, int irq, int flags)
@@ -1095,6 +1099,39 @@ atkbd_shutdown_final(void *v)
 #endif
 }
 
+static int
+atkbd_reset(KBDC kbdc, int flags, int c)
+{
+   /* reset keyboard hardware */
+   if (!(flags  KB_CONF_NO_RESET)  !reset_kbd(kbdc)) {
+   /*
+* KEYBOARD ERROR
+* Keyboard reset may fail either because the keyboard
+* doen't exist, or because the keyboard doesn't pass
+* the self-test, or the keyboard controller on the
+* motherboard and the keyboard somehow fail to shake hands.
+* It is just possible, particularly in the last case,
+* that the keyboard controller may be left in a hung state.
+* test_controller() and test_kbd_port() appear to bring
+* the keyboard controller back (I don't know why and how,
+* though.)
+*/
+   empty_both_buffers(kbdc, 10);
+   test_controller(kbdc);
+   test_kbd_port(kbdc);
+   /*
+* We could disable the keyboard port and interrupt... but, 
+* the keyboard may still exist (see above). 
+*/
+   set_controller_command_byte(kbdc,
+   ALLOW_DISABLE_KBD(kbdc) ? 0xff : KBD_KBD_CONTROL_BITS, c);
+   if (bootverbose)
+   printf(atkbd: failed to reset the keyboard.\n);
+   return (EIO);
+   }
+   return (0);
+}
+
 /* local functions */
 
 static int
@@ -1250,13 +1287,14 @@ probe_keyboard(KBDC kbdc, int flags)
kbdc_set_device_mask(kbdc, m | KBD_KBD_CONTROL_BITS);
} else {
/* try to restore the command byte as before */
-   set_controller_command_byte(kbdc, 0xff, c);
+   set_controller_command_byte(kbdc,
+   ALLOW_DISABLE_KBD(kbdc) ? 0xff : KBD_KBD_CONTROL_BITS, c);
kbdc_set_device_mask(kbdc, m);
}
 #endif
 
kbdc_lock(kbdc, FALSE);
-   return err;
+   return (HAS_QUIRK(kbdc, KBDC_QUIRK_IGNORE_PROBE_RESULT) ? 0 : err);
 }
 
 static int
@@ -1299,6 +1337,12 @@ init_keyboard(KBDC kbdc, int *type, int 
return EIO;
}
 
+   if (HAS_QUIRK(kbdc, KBDC_QUIRK_RESET_AFTER_PROBE) 
+   atkbd_reset(kbdc, flags, c)) {
+   kbdc_lock(kbdc, FALSE);
+   return EIO;
+   }
+
/* 
 * Check if we have an XT keyboard before we attempt to reset it. 
 * The procedure assumes that the keyboard and the controller have 
@@ -1343,31 +1387,9 @@ init_keyboard(KBDC kbdc, int *type, int 
if (bootverbose)
printf(atkbd: keyboard ID 0x%x (%d)\n, id, *type);
 
-   /* reset keyboard hardware */
-   if (!(flags  KB_CONF_NO_RESET)  !reset_kbd(kbdc)) {
-   /*
-* KEYBOARD ERROR
-* Keyboard reset may fail either because the keyboard
-* doen't exist, or because the keyboard doesn't pass
-* the self-test, or the keyboard controller on the
-* motherboard and the keyboard somehow fail to shake hands.
-* It is just possible, particularly in the last case,
-* that the keyboard controller may be left in a hung state.
-* test_controller() and test_kbd_port() appear to bring
-* the keyboard controller back 

svn commit: r278790 - head/sys/fs/ext2fs

2015-02-14 Thread Pedro F. Giffuni
Author: pfg
Date: Sun Feb 15 01:12:15 2015
New Revision: 278790
URL: https://svnweb.freebsd.org/changeset/base/278790

Log:
  Initialize the allocation of variables related to the ext2 allocator.
  
  The e2fs_gd struct was not being initialized and garbage was
  being used for hinting the ext2 allocator variant.
  Use malloc to clear the values and also initialize e2fs_contigdirs
  during allocation to keep consistency.
  
  While here clean up small style issues.
  
  Reported by:  Clang static analyser
  MFC after:1 week

Modified:
  head/sys/fs/ext2fs/ext2_vfsops.c

Modified: head/sys/fs/ext2fs/ext2_vfsops.c
==
--- head/sys/fs/ext2fs/ext2_vfsops.cSat Feb 14 23:28:09 2015
(r278789)
+++ head/sys/fs/ext2fs/ext2_vfsops.cSun Feb 15 01:12:15 2015
(r278790)
@@ -355,7 +355,7 @@ compute_sb_data(struct vnode *devvp, str
}
 
fs-e2fs_ipb = fs-e2fs_bsize / EXT2_INODE_SIZE(fs);
-   fs-e2fs_itpg = fs-e2fs_ipg /fs-e2fs_ipb;
+   fs-e2fs_itpg = fs-e2fs_ipg / fs-e2fs_ipb;
/* s_resuid / s_resgid ? */
fs-e2fs_gcount = (es-e2fs_bcount - es-e2fs_first_dblock +
EXT2_BLOCKS_PER_GROUP(fs) - 1) / EXT2_BLOCKS_PER_GROUP(fs);
@@ -363,9 +363,9 @@ compute_sb_data(struct vnode *devvp, str
db_count = (fs-e2fs_gcount + e2fs_descpb - 1) / e2fs_descpb;
fs-e2fs_gdbcount = db_count;
fs-e2fs_gd = malloc(db_count * fs-e2fs_bsize,
-   M_EXT2MNT, M_WAITOK);
+   M_EXT2MNT, M_WAITOK | M_ZERO);
fs-e2fs_contigdirs = malloc(fs-e2fs_gcount *
-   sizeof(*fs-e2fs_contigdirs), M_EXT2MNT, M_WAITOK);
+   sizeof(*fs-e2fs_contigdirs), M_EXT2MNT, M_WAITOK | M_ZERO);
 
/*
 * Adjust logic_sb_block.
@@ -390,11 +390,11 @@ compute_sb_data(struct vnode *devvp, str
brelse(bp);
bp = NULL;
}
+   /* Initialization for the ext2 Orlov allocator variant. */
fs-e2fs_total_dir = 0;
-   for (i=0; i  fs-e2fs_gcount; i++){
+   for (i = 0; i  fs-e2fs_gcount; i++)
fs-e2fs_total_dir += fs-e2fs_gd[i].ext2bgd_ndirs;
-   fs-e2fs_contigdirs[i] = 0;
-   }
+
if (es-e2fs_rev == E2FS_REV0 ||
!EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_LARGEFILE))
fs-e2fs_maxfilesize = 0x7fff;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r278791 - head/sys/fs/ext2fs

2015-02-14 Thread Pedro F. Giffuni
Author: pfg
Date: Sun Feb 15 01:34:00 2015
New Revision: 278791
URL: https://svnweb.freebsd.org/changeset/base/278791

Log:
  Reuse value of cursize instead of recalculating.
  
  Reported by:  Clang static checker
  MFC after:1 week

Modified:
  head/sys/fs/ext2fs/ext2_htree.c

Modified: head/sys/fs/ext2fs/ext2_htree.c
==
--- head/sys/fs/ext2fs/ext2_htree.c Sun Feb 15 01:12:15 2015
(r278790)
+++ head/sys/fs/ext2fs/ext2_htree.c Sun Feb 15 01:34:00 2015
(r278791)
@@ -861,7 +861,7 @@ ext2_htree_add_entry(struct vnode *dvp, 
ext2_htree_split_dirblock((char *)bp-b_data, newdirblock, blksize,
fs-e3fs_hash_seed, hash_version, split_hash, entry);
cursize = roundup(ip-i_size, blksize);
-   dirsize = roundup(ip-i_size, blksize) + blksize;
+   dirsize = cursize + blksize;
blknum = dirsize / blksize - 1;
 
/* Add index entry for the new directory block */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r276747 - head/sys/netpfil/pf

2015-02-14 Thread Craig Rodrigues
On Thu, Jan 22, 2015 at 2:23 PM, Gleb Smirnoff gleb...@freebsd.org wrote:

 On Thu, Jan 22, 2015 at 10:09:41PM +0100, Nikos Vassiliadis wrote:
 N  Sorry guys, I backed this out due to broken kldunload of pf module,
 which
 N  is critical when you are working with pf bugs.
 N
 N For sure. 100% understood.
 N
 N  I had to backout r276746 as well, since it has numerous build
 breakages,
 N  that are addressed by later revisions.
 N 
 N  That's my fault that I don't review in time, and I will try to improve
 N  the situation.
 N 
 N  Can you please replay r276746 again, addressing all the build problems
 N  and send the patch to me? You can user reviews.freebsd.org if you
 want.
 N 
 N  I'd like to get this in, but in a better quality.
 N
 N I'd like to get involved again and help you fixing pf. Craig could you
 N replay 276746?




I wish you could have fixed the pf unload problem without backing out
all these changes.  I took all these changes from your projects/pf branch,
which was starting to bitrot because it was not being sync'd with head.

I got confirmation from several people that the fixes as they were (after
the build break fixes),
actually fixed their issues with PF and VIMAGE, which have been pending for
several
years now with no visible progress made.

Most regular users of PF don't really kldunload it once it is used.
For development use, I've been testing inside bhyve VM's, which doesn't
solve the kldunload problem but allows testing and forward progress.

Why do you want me to replay 276746 and give you a patch?

Why don't you just do it yourself?






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


svn commit: r278749 - in head/sys/x86: acpica include

2015-02-14 Thread Konstantin Belousov
Author: kib
Date: Sat Feb 14 09:00:12 2015
New Revision: 278749
URL: https://svnweb.freebsd.org/changeset/base/278749

Log:
  Detect whether x2APIC on VMWare is usable without interrupt
  redirection support.  Older versions of the hypervisor mis-interpret
  the cpuid format in ioapic registers when x2APIC is turned on, but IR
  is not used by the guest OS.
  
  Based on: Linux commit 4cca6ea04d31c22a7d0436949c072b27bde41f86
  Tested by:markj
  Sponsored by: The FreeBSD Foundation
  MFC after:2 months

Modified:
  head/sys/x86/acpica/madt.c
  head/sys/x86/include/vmware.h

Modified: head/sys/x86/acpica/madt.c
==
--- head/sys/x86/acpica/madt.c  Sat Feb 14 08:52:52 2015(r278748)
+++ head/sys/x86/acpica/madt.c  Sat Feb 14 09:00:12 2015(r278749)
@@ -31,6 +31,7 @@ __FBSDID($FreeBSD$);
 #include sys/systm.h
 #include sys/bus.h
 #include sys/kernel.h
+#include sys/limits.h
 #include sys/malloc.h
 #include sys/smp.h
 #include vm/vm.h
@@ -40,6 +41,7 @@ __FBSDID($FreeBSD$);
 #include machine/intr_machdep.h
 #include x86/apicvar.h
 #include machine/md_var.h
+#include x86/vmware.h
 
 #include contrib/dev/acpica/include/acpi.h
 #include contrib/dev/acpica/include/actables.h
@@ -130,6 +132,7 @@ madt_setup_local(void)
 {
ACPI_TABLE_DMAR *dmartbl;
vm_paddr_t dmartbl_physaddr;
+   u_int p[4];
 
madt = pmap_mapbios(madt_physaddr, madt_length);
if ((cpu_feature2  CPUID2_X2APIC) != 0) {
@@ -146,6 +149,16 @@ madt_setup_local(void)
}
acpi_unmap_table(dmartbl);
}
+   if (vm_guest == VM_GUEST_VMWARE) {
+   vmware_hvcall(VMW_HVCMD_GETVCPU_INFO, p);
+   if ((p[0]  VMW_VCPUINFO_VCPU_RESERVED) != 0 ||
+   (p[0]  VMW_VCPUINFO_LEGACY_X2APIC) == 0) {
+   x2apic_mode = 0;
+   if (bootverbose)
+   printf(
+   x2APIC available but disabled inside VMWare without intr 
redirection\n);
+   }
+   }
TUNABLE_INT_FETCH(hw.x2apic_enable, x2apic_mode);
}
 

Modified: head/sys/x86/include/vmware.h
==
--- head/sys/x86/include/vmware.h   Sat Feb 14 08:52:52 2015
(r278748)
+++ head/sys/x86/include/vmware.h   Sat Feb 14 09:00:12 2015
(r278749)
@@ -31,8 +31,13 @@
 
 #defineVMW_HVMAGIC 0x564d5868
 #defineVMW_HVPORT  0x5658
+
 #defineVMW_HVCMD_GETVERSION10
 #defineVMW_HVCMD_GETHZ 45
+#defineVMW_HVCMD_GETVCPU_INFO  68
+
+#defineVMW_VCPUINFO_LEGACY_X2APIC  (1  3)
+#defineVMW_VCPUINFO_VCPU_RESERVED  (1  31)
 
 static __inline void
 vmware_hvcall(u_int cmd, u_int *p)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r278737 - head/usr.sbin/flowctl

2015-02-14 Thread Bruce Evans

On Sat, 14 Feb 2015, Pedro Giffuni wrote:


On 02/14/15 13:33, Ian Lepore wrote:

On Sat, 2015-02-14 at 21:15 +0300, Gleb Smirnoff wrote:

On Sat, Feb 14, 2015 at 08:46:58PM +1100, Bruce Evans wrote:
B Using VLAs and also the C99 feature of declarations anwhere, and 
extensions
B like __aligned(), we can almost implement a full alloca() using the 
fixed

B version of this change:
B
B /*
B   * XXX need extended statement-expression so that __buf doesn't go out
B   * of scope after the right brace.
B   */
B #define   my_alloca(n) __extension__ ({
B   /* XXX need unique name. */ \
B   char __buf[__roundup2((n), MUMBLE)] __aligned(MUMBLE);  \
B   \
B   (void *)__buf;  \
B })

I like this idea. But would this exact code work? The life of
__buf is limited by the code block, and we exit the block
immediately. Wouldn't the allocation be overwritten if we
enter any function or block later?


I don't know how to do it.  The comment describes the problem.  C99
doesn't require the block, but the statement-expression does.

There is another scope problem with alloca().  I think the storage
allocated by it is live until the end of the function, so it doesn't
go out of scope if alloca() is called in an inner block.

  (This is not properly documented in the FreeBSD manpage.  It is
  stated that the space is freed on return, but it is not stated that
  the space is not freed earlier.

  This is not properly documented in a Linux manpage found on the web.
  This manpage has an almost identical DESCRIPTION section.  Then it
  is better, except it doesn't spell RETURN VALUES' name with an S.

  FreeBSD's RETURN VALUES section is seriously broken.  It says that
  NULL is returned on failure.  But that is only for the extern libc
  version which is almost unreachable.  Normally the builtin is used.
  The Linux man page states only the behaviour on error of the builtin.
  It is that the behaviour is undefined on stack overflow.

  The Linux manpage then has much larger STANDARDS and HISTORY sections
  (spelled CONFORMING TO and NOTES).  These also deprecate it, and give
  some reasons.)

VLAs and macros cannot duplicate alloca()'s scope behaviour if the
macro or declaration is placed in an inner block.  This is not a problem
for FreeBSD, since style(9) forbids placing declarations in inner
blocks and no one would break that rule :-).  'ptr = alloca(n);' isn't
a declaration, but placing it in the outermost block is even more
useful for making ptr and its related space visible.


Why put any effort into avoiding alloca() in the first place?  Is it
inefficient on some platforms?  On arm it's like 5 instructions, it just
adjusts the size to keep the stack dword-aligned and subtracts the
result from sp, done.


It should be more like 0 instructions relative to a local array.  It
does take 0 more on x86 with clang, but not with gcc.  Even gcc48 on
amd64 still does pessimal stack alignment and more for alloca().
Tested with 'void test(void *);' and:

test(alloca(2048));
vs
int arr[1024]; test(arr);

gcc produces an extra instruction or 2 to align the stack.  Hmm, the
clang code is actually broken, at least on i386.  It needs to do the
stack alignment even more than clang, due to to its non-pessimal
alignment for the usual case.  Apparently, the stack is always 16-byte
aligned on amd64 although this is excessive.  On i386, the stack is
16-byte aligned by default for gcc although this is pessimal.  This
can be changed by -mpreferred-stack boundary=N.  For clang, the
stack is only 4-byte aligned, and -mpreferred-stack-boundary is
broken (not supported).  clang is supposed to do alignment as necessary.
That is, almost never.  It does the stack adjustment for doubles, but
not for alloca() or even for long doubles:

double d; test(d); /* adjusted */
test(alloca(8));/* broken */
long double d; test(d);/* broken */

On i386, gcc depends on the default for doubles and long doubles (and
more importantly, for alignment directives and SSE variables), so it
never needs to adjust for alloca(), the same as on amd64,  but always
does it.

The stack allocation for multiple alloca()s or declarations (even ones
in inner blocks), should be coalesced and done at the start of a
function.  gcc but not clang pessimizes this too.  For alloca(8);
alloca(8); on both amd64 and i386, gcc generates 2 separate allocations
of 32 (?) bytes each with null (?) adjustments for each.

Of course, variable stack allocations cannot be coalesced before the
variables are known.  Handling the stack for this case requires more
care.  For example, the original stack pointer must be saved, since
subtraction to restore it cannot be used.  Similarly if the stack is
adjusted using andl.  Allocations may be intentionally delayed to
avoid wasting stack space, but this doesn't work for alloca()