Re: svn commit: r292777 - in head: lib/libc/sys sys/kern

2015-12-28 Thread Konstantin Belousov
On Mon, Dec 28, 2015 at 09:35:11AM +1100, Bruce Evans wrote:
> If this causes a panic, then it is from a sanity check detecting the
> invalid conversion later.  A negative value in days breaks the loop
> logic but seems to give premature exit from the loops instead of many
> iterations.
It causes the panic due to out of bound accesses to bin2bcd_data[] array.
The issue affects around twenty rtc drivers, according to the quick grep
for clock_ts_to_ct() usage.  It probably also affects geom raid modules,
but I did not looked there at all.

As I understand, people prefer to have ability to test practically
useless values for the current time, by the cost the unplugged easy
kernel panic, in the production systems ? Am I right ? The commit gave
the immediate relief for the issue. If somebody have the correct fix
for clock_ts_to_ct(), I am happy to see this commit reverted after the
proper fix.
___
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: r292788 - in head/sys: geom/part sys

2015-12-28 Thread Andrey V. Elsukov
On 27.12.15 21:12, Allan Jude wrote:
> Author: allanjude
> Date: Sun Dec 27 18:12:13 2015
> New Revision: 292788
> URL: https://svnweb.freebsd.org/changeset/base/292788
> 
> Log:
>   Add some additional GPT partition types
>   
>   4 ChromeOS GPT types
>   2 Microsoft partition types
>   the new OpenBSD partition type
>   
> Modified: head/sys/geom/part/g_part.h
> ==
> --- head/sys/geom/part/g_part.h   Sun Dec 27 17:58:58 2015
> (r292787)
> +++ head/sys/geom/part/g_part.h   Sun Dec 27 18:12:13 2015
> (r292788)
> @@ -37,12 +37,28 @@
>  
>  enum g_part_alias {
>   G_PART_ALIAS_APPLE_BOOT,/* An Apple boot partition entry. */
> + G_PART_ALIAS_APPLE_CORE_STORAGE,/* An Apple Core Storage partition. */
>   G_PART_ALIAS_APPLE_HFS, /* An HFS+ file system entry. */
>   G_PART_ALIAS_APPLE_LABEL,   /* An Apple label partition entry. */
>   G_PART_ALIAS_APPLE_RAID,/* An Apple RAID partition entry. */
>   G_PART_ALIAS_APPLE_RAID_OFFLINE,/* An Apple RAID (offline) part entry.*/
>   G_PART_ALIAS_APPLE_TV_RECOVERY, /* An Apple TV recovery part entry. */
>   G_PART_ALIAS_APPLE_UFS, /* An Apple UFS partition entry. */
> + G_PART_ALIAS_BIOS_BOOT, /* A GRUB 2 boot partition entry. */
> + G_PART_ALIAS_CHROMEOS_FIRMWARE, /* A ChromeOS firmware part. entry. */
> + G_PART_ALIAS_CHROMEOS_KERNEL,   /* A ChromeOS Kernel part. entry. */
> + G_PART_ALIAS_CHROMEOS_RESERVED, /* ChromeOS. Reserved for future use. */
> + G_PART_ALIAS_CHROMEOS_ROOT, /* A ChromeOS root part. entry. */

This enum could be used by third-party kernel module and in general it
is not good to change the order of elements here. This can break `gpart
show` output for such modules. Just for the future. :)

-- 
WBR, Andrey V. Elsukov



signature.asc
Description: OpenPGP digital signature


svn commit: r292829 - head/usr.sbin/fstyp

2015-12-28 Thread Xin LI
Author: delphij
Date: Mon Dec 28 08:53:31 2015
New Revision: 292829
URL: https://svnweb.freebsd.org/changeset/base/292829

Log:
  Eliminate unneeded includes.
  
  Reviewed by:  allanjude
  Differential Revision:https://reviews.freebsd.org/D4716

Modified:
  head/usr.sbin/fstyp/fstyp.c
  head/usr.sbin/fstyp/geli.c

Modified: head/usr.sbin/fstyp/fstyp.c
==
--- head/usr.sbin/fstyp/fstyp.c Mon Dec 28 05:48:22 2015(r292828)
+++ head/usr.sbin/fstyp/fstyp.c Mon Dec 28 08:53:31 2015(r292829)
@@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 

Modified: head/usr.sbin/fstyp/geli.c
==
--- head/usr.sbin/fstyp/geli.c  Mon Dec 28 05:48:22 2015(r292828)
+++ head/usr.sbin/fstyp/geli.c  Mon Dec 28 08:53:31 2015(r292829)
@@ -29,11 +29,9 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-#include 
 
 #include 
 
___
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: r292831 - in head: sbin/ifconfig sys/net

2015-12-28 Thread Alexander V. Chernikov
Author: melifaro
Date: Mon Dec 28 09:26:07 2015
New Revision: 292831
URL: https://svnweb.freebsd.org/changeset/base/292831

Log:
  Add SFF-8024 Extended Specification Compliance
  
  Submitted by: markb_mellanox.com
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D4666

Modified:
  head/sbin/ifconfig/sfp.c
  head/sys/net/sff8436.h

Modified: head/sbin/ifconfig/sfp.c
==
--- head/sbin/ifconfig/sfp.cMon Dec 28 09:03:29 2015(r292830)
+++ head/sbin/ifconfig/sfp.cMon Dec 28 09:26:07 2015(r292831)
@@ -171,7 +171,7 @@ static struct _nv fc_speed[] = {
 
 /* 10/40G Ethernet compliance codes, byte 128 + 3 */
 static struct _nv eth_1040g[] = {
-   { 0x80, "Reserved" },
+   { 0x80, "Extended" },
{ 0x40, "10GBASE-LRM" },
{ 0x20, "10GBASE-LR" },
{ 0x10, "10GBASE-SR" },
@@ -181,6 +181,38 @@ static struct _nv eth_1040g[] = {
{ 0x01, "40G Active Cable" },
{ 0, NULL }
 };
+#defineSFF_8636_EXT_COMPLIANCE 0x80
+
+/* SFF-8024 Rev. 3.4 table 4.4: Extended Specification Compliance */
+static struct _nv eth_extended_comp[] = {
+   { 0xFF, "Reserved" },
+   { 0x1A, "2 lambda DWDM 100G" },
+   { 0x19, "100G ACC or 25GAUI C2M ACC" },
+   { 0x18, "100G AOC or 25GAUI C2M AOC" },
+   { 0x17, "100G CLR4" },
+   { 0x16, "10GBASE-T with SFI electrical interface" },
+   { 0x15, "G959.1 profile P1L1-2D2" },
+   { 0x14, "G959.1 profile P1S1-2D2" },
+   { 0x13, "G959.1 profile P1I1-2D1" },
+   { 0x12, "40G PSM4 Parallel SMF" },
+   { 0x11, "4 x 10GBASE-SR" },
+   { 0x10, "40GBASE-ER4" },
+   { 0x0F, "Reserved" },
+   { 0x0D, "25GBASE-CR CA-N" },
+   { 0x0C, "25GBASE-CR CA-S" },
+   { 0x0B, "100GBASE-CR4 or 25GBASE-CR CA-L" },
+   { 0x0A, "Reserved" },
+   { 0x09, "100G CWDM4 MSA without FEC" },
+   { 0x08, "100G ACC (Active Copper Cable)" },
+   { 0x07, "100G PSM4 Parallel SMF" },
+   { 0x06, "100G CWDM4 MSA with FEC" },
+   { 0x05, "100GBASE-SR10" },
+   { 0x04, "100GBASE-ER4" },
+   { 0x03, "100GBASE-LR4" },
+   { 0x02, "100GBASE-SR4" },
+   { 0x01, "100G AOC (Active Optical Cable) or 25GAUI C2M ACC" },
+   { 0x00, "Unspecified" }
+};
 
 /* SFF-8636 Rev. 2.5 table 6.3: Revision compliance */
 static struct _nv rev_compl[] = {
@@ -371,9 +403,16 @@ get_qsfp_transceiver_class(struct i2c_in
const char *tech_class;
uint8_t code;
 
-   /* Check 10/40G Ethernet class only */
-   read_i2c(ii, SFF_8436_BASE, SFF_8436_CODE_E1040G, 1, &code);
-   tech_class = find_zero_bit(eth_1040g, code, 1);
+   read_i2c(ii, SFF_8436_BASE, SFF_8436_CODE_E1040100G, 1, &code);
+
+   /* Check for extended specification compliance */
+   if (code & SFF_8636_EXT_COMPLIANCE) {
+   read_i2c(ii, SFF_8436_BASE, SFF_8436_OPTIONS_START, 1, &code);
+   tech_class = find_value(eth_extended_comp, code);
+   } else
+   /* Check 10/40G Ethernet class only */
+   tech_class = find_zero_bit(eth_1040g, code, 1);
+
if (tech_class == NULL)
tech_class = "Unknown";
 
@@ -873,6 +912,7 @@ sfp_status(int s, struct ifreq *ifr, int
switch (id_byte) {
case SFF_8024_ID_QSFP:
case SFF_8024_ID_QSFPPLUS:
+   case SFF_8024_ID_QSFP28:
print_qsfp_status(&ii, verbose);
break;
default:

Modified: head/sys/net/sff8436.h
==
--- head/sys/net/sff8436.h  Mon Dec 28 09:03:29 2015(r292830)
+++ head/sys/net/sff8436.h  Mon Dec 28 09:26:07 2015(r292831)
@@ -131,7 +131,7 @@ enum {
SFF_8436_CONNECTOR  = 130,  /* Connector type (Table 32) */
SFF_8436_TRANS_START= 131,  /* Electric or Optical Compatibility
 * (Table 33) */
-   SFF_8436_CODE_E1040G= 131,  /* 10/40G Ethernet Compliance Code */
+   SFF_8436_CODE_E1040100G = 131,  /* 10/40/100G Ethernet Compliance Code 
*/
SFF_8436_CODE_SONET = 132,  /* SONET Compliance codes */
SFF_8436_CODE_SATA  = 133,  /* SAS/SATA compliance codes */
SFF_8436_CODE_E1G   = 134,  /* Gigabit Ethernet Compliant codes */
___
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: r292777 - in head: lib/libc/sys sys/kern

2015-12-28 Thread Bruce Evans

On Mon, 28 Dec 2015, Konstantin Belousov wrote:


On Mon, Dec 28, 2015 at 09:35:11AM +1100, Bruce Evans wrote:

If this causes a panic, then it is from a sanity check detecting the
invalid conversion later.  A negative value in days breaks the loop
logic but seems to give premature exit from the loops instead of many
iterations.

It causes the panic due to out of bound accesses to bin2bcd_data[] array.
The issue affects around twenty rtc drivers, according to the quick grep
for clock_ts_to_ct() usage.  It probably also affects geom raid modules,
but I did not looked there at all.

As I understand, people prefer to have ability to test practically
useless values for the current time, by the cost the unplugged easy
kernel panic, in the production systems ? Am I right ?


It is not unreasonable to panic when such tests fail, just like for other
settings of unreasonable values.  Only the superuser can make them, and
the superuser should know better than to run them on production systems.

Of course, the correct fix is to fail for unrepresentable values.  Different
subsystems have different limits, so valid negative timevals may become
invalid for certain RTC hardware or software.  Valid positive timevals
may also become invalid.  The RTC might not have a century register, or
one that it has might be unreliable as on x86 (the option USE_RTC_CENTURY
tells atrtc to use the century register, but this is so little used that
it is not a supported option).  We use a hack to translate to a range of
years including the current time.  This used to be done almost correctly.
It gave the range 1970-2069, so the Epoch as representable except in the
Western hemisphere when the RTC is on local time.  Now the range is 1980-
2079, so the Epoch is never representable.  If someone tries to set the
time to the Epoch, they get 2070 instead of 1970.


The commit gave
the immediate relief for the issue. If somebody have the correct fix
for clock_ts_to_ct(), I am happy to see this commit reverted after the
proper fix.


It only avoids for some out of bounds value.  I already pointed out that
negative seconds still occur in the Western hemisphere for times near the
Epoch, etc.

Other overflow bugs are now easier to see.  64-bit time_t's allow really
large times.  The maximum with signed ones is about 292 billion years.
'year' has the wrong type (int) so it cannot represent that many.  I
think the loop to reduce 'days' iterates that many times and 'year'
overflows every 2**32'nd iteration and the result is normally as if
calculated correctly but then assigned to a 32-bit signed int.  It can
overflow to any 32-bit signed value.  Fortunately, the calculation
doesn't overrun a table of leap years.  It just uses a simple rule for
leap years which is expected to work until 2037.  Years larger than
that are not supported elsewhere.  Next, the overflowed year is assigned
to ct->year.  This is also int, so no further overflow occurs.  ct->year
is misnamed (missing a prefix) and has a comment saying that it is a
4-digit year, but the code can produce any value.  Next, ct->year is
trusted by at least the atrtc driver.  This gives an out of bound
accesses to bin2bcd_data[] in about 49.5% of cases if USE_RTC_CENTURY
is not configured, and in almost all cases if USE_RTC_CENTURY is configured:

X   writertc(RTC_YEAR, bin2bcd(ct.year % 100)); /* Write back Year*/
X #ifdef USE_RTC_CENTURY
X   writertc(RTC_CENTURY, bin2bcd(ct.year / 100));  /* ... and Century*/
#endif

ct.year overflows to a negative value in about 50% of the cases.  Then
ct.year % 100 is negative in 99% of the subcases and 0 in 1% of the
subcases.

ct.year / 100 is negative in about 50% of the cases.  When it is positive,
it is too large for the array except for the small range 0- for ct.year.
The comment on ct->year is correct that the year must have only 4 digits.
Anything larger than that takes more than 2 bin2bcd steps and more than
2 bcd registers to represent.  Probably other drivers are sloppy as above,
but they should be able to handle 4 digits by throwing away the century
digits as in the usual case above.

The adjustment to give times between 1980 and 2079 is for the other
direction.  That direction is more careful since the time comes from
untrusted hardware instead of the trusted superuser.  I pointed out
some missing checks on lower bounds in clock_ct_to_ts().  The one
for the month is not missing and is most important since the month
is used as an array index and has base 1.  The month day also has base 1
but is not used as an array index.  Buggy hardware might produce
0 but can't produce a negative value for seconds minutes or hours if it
uses bcd encoding.  This leaves the year as most in need of a lower
bounds check.  The code is accidentally fail-safe for years -- years
before 1970 are converted to 1970 except for the leap year caclulation.

subr_clock.c is a little under-engineered.  subr_fattime.c is grossly
over-engineered, but not enough t

Re: svn commit: r292788 - in head/sys: geom/part sys

2015-12-28 Thread Konstantin Belousov
On Mon, Dec 28, 2015 at 11:32:29AM +0300, Andrey V. Elsukov wrote:
> On 27.12.15 21:12, Allan Jude wrote:
> >  enum g_part_alias {
> > G_PART_ALIAS_APPLE_BOOT,/* An Apple boot partition entry. */
> > +   G_PART_ALIAS_APPLE_CORE_STORAGE,/* An Apple Core Storage partition. */
> > G_PART_ALIAS_APPLE_HFS, /* An HFS+ file system entry. */
> > G_PART_ALIAS_APPLE_LABEL,   /* An Apple label partition entry. */
> > G_PART_ALIAS_APPLE_RAID,/* An Apple RAID partition entry. */
> > G_PART_ALIAS_APPLE_RAID_OFFLINE,/* An Apple RAID (offline) part entry.*/
> > G_PART_ALIAS_APPLE_TV_RECOVERY, /* An Apple TV recovery part entry. */
> > G_PART_ALIAS_APPLE_UFS, /* An Apple UFS partition entry. */
> > +   G_PART_ALIAS_BIOS_BOOT, /* A GRUB 2 boot partition entry. */
> > +   G_PART_ALIAS_CHROMEOS_FIRMWARE, /* A ChromeOS firmware part. entry. */
> > +   G_PART_ALIAS_CHROMEOS_KERNEL,   /* A ChromeOS Kernel part. entry. */
> > +   G_PART_ALIAS_CHROMEOS_RESERVED, /* ChromeOS. Reserved for future use. */
> > +   G_PART_ALIAS_CHROMEOS_ROOT, /* A ChromeOS root part. entry. */
> 
> This enum could be used by third-party kernel module and in general it
> is not good to change the order of elements here. This can break `gpart
> show` output for such modules. Just for the future. :)

If the enum values are considered part of KBI, then explicit assignment
of the enum values is much preferred.
___
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: r292777 - in head: lib/libc/sys sys/kern

2015-12-28 Thread Slawa Olhovchenkov
On Mon, Dec 28, 2015 at 09:17:50PM +1100, Bruce Evans wrote:

> On Mon, 28 Dec 2015, Konstantin Belousov wrote:
> 
> > On Mon, Dec 28, 2015 at 09:35:11AM +1100, Bruce Evans wrote:
> >> If this causes a panic, then it is from a sanity check detecting the
> >> invalid conversion later.  A negative value in days breaks the loop
> >> logic but seems to give premature exit from the loops instead of many
> >> iterations.
> > It causes the panic due to out of bound accesses to bin2bcd_data[] array.
> > The issue affects around twenty rtc drivers, according to the quick grep
> > for clock_ts_to_ct() usage.  It probably also affects geom raid modules,
> > but I did not looked there at all.
> >
> > As I understand, people prefer to have ability to test practically
> > useless values for the current time, by the cost the unplugged easy
> > kernel panic, in the production systems ? Am I right ?
> 
> It is not unreasonable to panic when such tests fail, just like for other
> settings of unreasonable values.  Only the superuser can make them, and
> the superuser should know better than to run them on production systems.

Only one valid reasson for panic may be exist: fatal destruction of
internal structures (impossibility to recovery).
All other reaason must not be caused panic.
Disconnecting USB flash.
Removing floppy discs.
Lost root FS.
All above must not be cused panic.

VAX/VMS don't panic after break half of RAM druing intesive work.
___
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: r292832 - head/usr.sbin/bsdinstall/scripts

2015-12-28 Thread Devin Teske
Author: dteske
Date: Mon Dec 28 17:27:20 2015
New Revision: 292832
URL: https://svnweb.freebsd.org/changeset/base/292832

Log:
  Explicitly set permissions on entropy files
  
  Differential Revision:https://reviews.freebsd.org/D3933
  Submitted by: jmg
  Reviewed by:  delphij, markm
  Approved by:  secteam (delphij)
  MFC after:3 days
  X-MFC-to: stable/10 stable/9

Modified:
  head/usr.sbin/bsdinstall/scripts/entropy

Modified: head/usr.sbin/bsdinstall/scripts/entropy
==
--- head/usr.sbin/bsdinstall/scripts/entropyMon Dec 28 09:26:07 2015
(r292831)
+++ head/usr.sbin/bsdinstall/scripts/entropyMon Dec 28 17:27:20 2015
(r292832)
@@ -26,4 +26,9 @@
 #
 # $FreeBSD$
 
-dd if=/dev/random of=$BSDINSTALL_CHROOT/entropy bs=4096 count=1
+umask 077
+for i in /entropy /boot/entropy; do
+   i="$BSDINSTALL_CHROOT/$i"
+   dd if=/dev/random of="$i" bs=4096 count=1
+   chown 0:0 "$i"
+done
___
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: r292777 - in head: lib/libc/sys sys/kern

2015-12-28 Thread Garrett Cooper

> On Dec 28, 2015, at 02:17, Bruce Evans  wrote:

...

> It is not unreasonable to panic when such tests fail, just like for other
> settings of unreasonable values.  Only the superuser can make them, and
> the superuser should know better than to run them on production systems.

On a development system, this is perfectly reasonable. However, on systems in 
production, dying on asserts or panicking when unexpected input is encountered 
instead of erroring out appropriately is not ideal: it causes unnecessary 
downtime and can confuse others (customers, lower level admins) who are not 
fully aware of how UNIX and FreeBSD works (and in turn generate support calls 
and bug reports).

Thanks,
-NGie
___
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: r292834 - in head/sys/compat/linuxkpi/common: include/linux src

2015-12-28 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Dec 28 18:20:05 2015
New Revision: 292834
URL: https://svnweb.freebsd.org/changeset/base/292834

Log:
  Reduce memory consumption when allocating kobject strings in the
  LinuxKPI. Compute string length before allocating memory instead of
  using fixed size allocations. Make kobject_set_name_vargs() global
  instead of inline to save some bytes when compiling.
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/kobject.h
  head/sys/compat/linuxkpi/common/src/linux_compat.c

Modified: head/sys/compat/linuxkpi/common/include/linux/kobject.h
==
--- head/sys/compat/linuxkpi/common/include/linux/kobject.h Mon Dec 28 
17:50:31 2015(r292833)
+++ head/sys/compat/linuxkpi/common/include/linux/kobject.h Mon Dec 28 
18:20:05 2015(r292834)
@@ -103,29 +103,7 @@ kobject_get(struct kobject *kobj)
return kobj;
 }
 
-static inline int
-kobject_set_name_vargs(struct kobject *kobj, const char *fmt, va_list args)
-{
-   char *old;
-   char *name;
-
-   old = kobj->name;
-
-   if (old && !fmt)
-   return 0;
-
-   name = kzalloc(MAXPATHLEN, GFP_KERNEL);
-   if (!name)
-   return -ENOMEM;
-   vsnprintf(name, MAXPATHLEN, fmt, args);
-   kobj->name = name;
-   kfree(old);
-   for (; *name != '\0'; name++)
-   if (*name == '/')
-   *name = '!';
-   return (0);
-}
-
+intkobject_set_name_vargs(struct kobject *kobj, const char *fmt, va_list);
 intkobject_add(struct kobject *kobj, struct kobject *parent,
const char *fmt, ...);
 

Modified: head/sys/compat/linuxkpi/common/src/linux_compat.c
==
--- head/sys/compat/linuxkpi/common/src/linux_compat.c  Mon Dec 28 17:50:31 
2015(r292833)
+++ head/sys/compat/linuxkpi/common/src/linux_compat.c  Mon Dec 28 18:20:05 
2015(r292834)
@@ -94,7 +94,50 @@ panic_cmp(struct rb_node *one, struct rb
 }
 
 RB_GENERATE(linux_root, rb_node, __entry, panic_cmp);
- 
+
+int
+kobject_set_name_vargs(struct kobject *kobj, const char *fmt, va_list args)
+{
+   va_list tmp_va;
+   int len;
+   char *old;
+   char *name;
+   char dummy;
+
+   old = kobj->name;
+
+   if (old && fmt == NULL)
+   return (0);
+
+   /* compute length of string */
+   va_copy(tmp_va, args);
+   len = vsnprintf(&dummy, 0, fmt, tmp_va);
+   va_end(tmp_va);
+
+   /* account for zero termination */
+   len++;
+
+   /* check for error */
+   if (len < 1)
+   return (-EINVAL);
+
+   /* allocate memory for string */
+   name = kzalloc(len, GFP_KERNEL);
+   if (name == NULL)
+   return (-ENOMEM);
+   vsnprintf(name, len, fmt, args);
+   kobj->name = name;
+
+   /* free old string */
+   kfree(old);
+
+   /* filter new string */
+   for (; *name != '\0'; name++)
+   if (*name == '/')
+   *name = '!';
+   return (0);
+}
+
 int
 kobject_set_name(struct kobject *kobj, const char *fmt, ...)
 {
___
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: r292835 - head/sys/dev/mlx5/mlx5_en

2015-12-28 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Dec 28 18:28:18 2015
New Revision: 292835
URL: https://svnweb.freebsd.org/changeset/base/292835

Log:
  Make the eeprom dump function more readable and rename variables for
  better clarity.
  
  MFC after:1 week
  Submitted by: Daria Genzel 
  Differential Revision:https://reviews.freebsd.org/D4551
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c

Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
==
--- head/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c Mon Dec 28 18:20:05 2015
(r292834)
+++ head/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c Mon Dec 28 18:28:18 2015
(r292835)
@@ -319,34 +319,33 @@ mlx5e_get_eeprom(struct mlx5e_priv *priv
 static void
 mlx5e_print_eeprom(struct mlx5e_eeprom *eeprom)
 {
-   int i, j = 0;
-   int row = 0;
+   int row;
+   int index_in_row;
+   int byte_to_write = 0;
+   int line_length = 16;
 
printf("\nOffset\t\tValues\n");
-   printf("--\t\t--\n");
-   while (row < eeprom->len) {
-   printf("0x%04x\t\t", row);
-   for (i = 0; i < 16; i++) {
-   printf("%02x ", ((u8 *)eeprom->data)[j]);
-   j++;
-   row++;
+   printf("--\t\t--");
+   while (byte_to_write < eeprom->len) {
+   printf("\n0x%04X\t\t", byte_to_write);
+   for (index_in_row = 0; index_in_row < line_length; 
index_in_row++) {
+   printf("%02X ", ((u8 *)eeprom->data)[byte_to_write]);
+   byte_to_write++;
}
-   printf("\n");
}
 
if (eeprom->page_valid) {
row = MLX5E_EEPROM_HIGH_PAGE_OFFSET;
-   printf("\nUpper Page 0x03\n");
+   printf("\n\nUpper Page 0x03\n");
printf("\nOffset\t\tValues\n");
-   printf("--\t\t--\n");
+   printf("--\t\t--");
while (row < MLX5E_EEPROM_PAGE_LENGTH) {
-   printf("0x%04x\t\t", row);
-   for (i = 0; i < 16; i++) {
-   printf("%02x ", ((u8 *)eeprom->data)[j]);
-   j++;
+   printf("\n0x%04X\t\t", row);
+   for (index_in_row = 0; index_in_row < line_length; 
index_in_row++) {
+   printf("%02X ", ((u8 
*)eeprom->data)[byte_to_write]);
+   byte_to_write++;
row++;
}
-   printf("\n");
}
}
 }
___
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: r292836 - head/sys/netinet6

2015-12-28 Thread Garrett Wollman
Author: wollman
Date: Mon Dec 28 18:29:47 2015
New Revision: 292836
URL: https://svnweb.freebsd.org/changeset/base/292836

Log:
  in6_if2idlen: treat bridge(4) interfaces like other Ethernet interfaces
  
  bridge(4) interfaces have an if_type of IFT_BRIDGE, rather than
  IFT_ETHER, even though they only support Ethernet-style links.  This
  caused in6_if2idlen to emit an "unknown link type (209)" warning to
  the console every time it was called.  Add IFT_BRIDGE to the case
  statement in the appropriate place, indicating that it uses the same
  IPv6 address format as other Ethernet-like interfaces.
  
  MFC after:1 week

Modified:
  head/sys/netinet6/in6.c

Modified: head/sys/netinet6/in6.c
==
--- head/sys/netinet6/in6.c Mon Dec 28 18:28:18 2015(r292835)
+++ head/sys/netinet6/in6.c Mon Dec 28 18:29:47 2015(r292836)
@@ -2008,6 +2008,7 @@ in6_if2idlen(struct ifnet *ifp)
case IFT_PROPVIRTUAL:   /* XXX: no RFC. treat it as ether */
case IFT_L2VLAN:/* ditto */
case IFT_IEEE80211: /* ditto */
+   case IFT_BRIDGE:/* bridge(4) only does Ethernet-like links */
case IFT_INFINIBAND:
return (64);
case IFT_FDDI:  /* RFC2467 */
___
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: r292837 - head/sys/dev/mlx5/mlx5_en

2015-12-28 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Dec 28 18:36:00 2015
New Revision: 292837
URL: https://svnweb.freebsd.org/changeset/base/292837

Log:
  Add support for sysctl tunables to 10-stable and older. Pushed through
  head first to simplify driver maintenance.
  
  MFC after:1 week
  Submitted by: Drew Gallatin 
  Differential Revision:https://reviews.freebsd.org/D4552
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c

Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
==
--- head/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c Mon Dec 28 18:29:47 2015
(r292836)
+++ head/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c Mon Dec 28 18:36:00 2015
(r292837)
@@ -58,13 +58,17 @@ mlx5e_ethtool_handler(SYSCTL_HANDLER_ARG
 
PRIV_LOCK(priv);
value = priv->params_ethtool.arg[arg2];
-   error = sysctl_handle_64(oidp, &value, 0, req);
-   if (error || req->newptr == NULL ||
-   value == priv->params_ethtool.arg[arg2])
-   goto done;
+   if (req != NULL) {
+   error = sysctl_handle_64(oidp, &value, 0, req);
+   if (error || req->newptr == NULL ||
+   value == priv->params_ethtool.arg[arg2])
+   goto done;
 
-   /* assign new value */
-   priv->params_ethtool.arg[arg2] = value;
+   /* assign new value */
+   priv->params_ethtool.arg[arg2] = value;
+   } else {
+   error = 0;
+   }
 
/* check if device is gone */
if (priv->gone) {
@@ -483,10 +487,30 @@ mlx5e_create_ethtool(struct mlx5e_priv *
CTLFLAG_MPSAFE, priv, x, &mlx5e_ethtool_handler, 
"QU",
mlx5e_params_desc[2 * x + 1]);
} else {
+#if (__FreeBSD_version < 110)
+   char path[64];
+#endif
+   /*
+* NOTE: In FreeBSD-11 and newer the
+* CTLFLAG_RWTUN flag will take care of
+* loading default sysctl value from the
+* kernel environment, if any:
+*/
SYSCTL_ADD_PROC(&priv->sysctl_ctx, 
SYSCTL_CHILDREN(node), OID_AUTO,
mlx5e_params_desc[2 * x], CTLTYPE_U64 | 
CTLFLAG_RWTUN |
CTLFLAG_MPSAFE, priv, x, &mlx5e_ethtool_handler, 
"QU",
mlx5e_params_desc[2 * x + 1]);
+
+#if (__FreeBSD_version < 110)
+   /* compute path for sysctl */
+   snprintf(path, sizeof(path), "dev.mce.%d.conf.%s",
+   device_get_unit(priv->mdev->pdev->dev.bsddev),
+   mlx5e_params_desc[2 * x]);
+
+   /* try to fetch tunable, if any */
+   if (TUNABLE_QUAD_FETCH(path, 
&priv->params_ethtool.arg[x]))
+   mlx5e_ethtool_handler(NULL, priv, x, NULL);
+#endif
}
}
 
___
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: r292838 - in head/sys/dev/mlx5: . mlx5_en

2015-12-28 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Dec 28 18:50:18 2015
New Revision: 292838
URL: https://svnweb.freebsd.org/changeset/base/292838

Log:
  Add support for CQE zipping. CQE zipping reduces PCI overhead by
  coalescing and zipping multiple CQEs into a single merged CQE. The
  feature is enabled by default and can be disabled by a sysctl.
  
  Implementing this feature mlx5_cqwq_pop() has been separated from
  mlx5e_get_cqe().
  
  MFC after:1 week
  Submitted by: Mark Bloch 
  Differential Revision:https://reviews.freebsd.org/D4598
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/dev/mlx5/device.h
  head/sys/dev/mlx5/mlx5_en/en.h
  head/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
  head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
  head/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c
  head/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
  head/sys/dev/mlx5/mlx5_en/mlx5_en_txrx.c

Modified: head/sys/dev/mlx5/device.h
==
--- head/sys/dev/mlx5/device.h  Mon Dec 28 18:36:00 2015(r292837)
+++ head/sys/dev/mlx5/device.h  Mon Dec 28 18:50:18 2015(r292838)
@@ -1042,6 +1042,7 @@ enum {
MLX5_ESW_VPORT_ADMIN_STATE_UP= 0x1,
MLX5_ESW_VPORT_ADMIN_STATE_AUTO  = 0x2,
 };
+
 /* MLX5 DEV CAPs */
 
 /* TODO: EAT.ME */
@@ -1219,4 +1220,36 @@ struct mlx5_ifc_mcia_reg_bits {
 };
 
 #define MLX5_CMD_OP_QUERY_EEPROM 0x93c
+
+struct mlx5_mini_cqe8 {
+   union {
+   u32 rx_hash_result;
+   u32 checksum;
+   struct {
+   u16 wqe_counter;
+   u8  s_wqe_opcode;
+   u8  reserved;
+   } s_wqe_info;
+   };
+   u32 byte_cnt;
+};
+
+enum {
+   MLX5_NO_INLINE_DATA,
+   MLX5_INLINE_DATA32_SEG,
+   MLX5_INLINE_DATA64_SEG,
+   MLX5_COMPRESSED,
+};
+
+enum mlx5_exp_cqe_zip_recv_type {
+   MLX5_CQE_FORMAT_HASH,
+   MLX5_CQE_FORMAT_CSUM,
+};
+
+#define MLX5E_CQE_FORMAT_MASK 0xc
+static inline int mlx5_get_cqe_format(const struct mlx5_cqe64 *cqe)
+{
+   return (cqe->op_own & MLX5E_CQE_FORMAT_MASK) >> 2;
+}
+
 #endif /* MLX5_DEVICE_H */

Modified: head/sys/dev/mlx5/mlx5_en/en.h
==
--- head/sys/dev/mlx5/mlx5_en/en.h  Mon Dec 28 18:36:00 2015
(r292837)
+++ head/sys/dev/mlx5/mlx5_en/en.h  Mon Dec 28 18:50:18 2015
(r292838)
@@ -370,6 +370,7 @@ struct mlx5e_params {
u16 tx_cq_moderation_pkts;
u16 min_rx_wqes;
boolhw_lro_en;
+   boolcqe_zipping_en;
u32 lro_wqe_sz;
u16 rx_hash_log_tbl_sz;
 };
@@ -390,7 +391,8 @@ struct mlx5e_params {
   m(+1, u64 tx_coalesce_usecs, "tx_coalesce_usecs", "Limit in usec for joining 
tx packets") \
   m(+1, u64 tx_coalesce_pkts, "tx_coalesce_pkts", "Maximum number of tx 
packets to join") \
   m(+1, u64 tx_coalesce_mode, "tx_coalesce_mode", "0: EQE mode 1: CQE mode") \
-  m(+1, u64 hw_lro, "hw_lro", "set to enable hw_lro")
+  m(+1, u64 hw_lro, "hw_lro", "set to enable hw_lro") \
+  m(+1, u64 cqe_zipping, "cqe_zipping", "0 : CQE zipping disabled")
 
 #defineMLX5E_PARAMS_NUM (0 MLX5E_PARAMS(MLX5E_STATS_COUNT))
 

Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
==
--- head/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c Mon Dec 28 18:36:00 2015
(r292837)
+++ head/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c Mon Dec 28 18:50:18 2015
(r292838)
@@ -204,6 +204,18 @@ mlx5e_ethtool_handler(SYSCTL_HANDLER_ARG
priv->params.hw_lro_en = false;
}
 
+   if (&priv->params_ethtool.arg[arg2] ==
+   &priv->params_ethtool.cqe_zipping) {
+   if (priv->params_ethtool.cqe_zipping &&
+   MLX5_CAP_GEN(priv->mdev, cqe_compression)) {
+   priv->params.cqe_zipping_en = true;
+   priv->params_ethtool.cqe_zipping = 1;
+   } else {
+   priv->params.cqe_zipping_en = false;
+   priv->params_ethtool.cqe_zipping = 0;
+   }
+   }
+
if (was_opened)
mlx5e_open_locked(priv->ifp);
 done:
@@ -472,6 +484,7 @@ mlx5e_create_ethtool(struct mlx5e_priv *
priv->params_ethtool.tx_coalesce_usecs = 
priv->params.tx_cq_moderation_usec;
priv->params_ethtool.tx_coalesce_pkts = 
priv->params.tx_cq_moderation_pkts;
priv->params_ethtool.hw_lro = priv->params.hw_lro_en;
+   priv->params_ethtool.cqe_zipping = priv->params.cqe_zipping_en;
 
/* create root node */
node = SYSCTL_ADD_NODE(&priv->sysctl_ctx,

Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==
--- head/sys/dev/mlx5/mlx5_en/mlx5_en_main.cMon Dec 28 18:36:00 2015
(r292837)
+++ head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c 

svn commit: r292839 - head

2015-12-28 Thread Devin Teske
Author: dteske
Date: Mon Dec 28 19:29:05 2015
New Revision: 292839
URL: https://svnweb.freebsd.org/changeset/base/292839

Log:
  Add interests/maintainerships + notes

Modified:
  head/MAINTAINERS

Modified: head/MAINTAINERS
==
--- head/MAINTAINERSMon Dec 28 18:50:18 2015(r292838)
+++ head/MAINTAINERSMon Dec 28 19:29:05 2015(r292839)
@@ -56,7 +56,9 @@ isci(4)   jimharris   Pre-commit review req
 iwm(4) adrian  Pre-commit review requested, send to 
freebsd-wirel...@freebsd.org
 iwn(4) adrian  Pre-commit review requested, send to 
freebsd-wirel...@freebsd.org
 kqueue jmg Pre-commit review requested.  Documentation Required.
+libdpv dteske  Pre-commit review requested. Keep in sync with dpv(1).
 libfetch   des Pre-commit review requested.
+libfigpar  dteske  Pre-commit review requested.
 libpam des Pre-commit review requested.
 linprocfs  des Pre-commit review requested.
 lprgad Pre-commit review requested, particularly for
@@ -85,6 +87,7 @@ sh(1) jilles  Pre-commit review request
compiled in as builtins.
 share/mk   imp, bapt, bdrewery, emaste, sjgMake is hard.
 share/mk/*.test.mk freebsd-testing,ngie (same list as share/mk too)
Pre-commit review requested.
+sys/boot/forth dteske  Pre-commit review requested.
 sys/compat/linuxkpihselaskyIf in doubt, ask.
 sys/dev/e1000  erj Pre-commit phabricator review requested.
 sys/dev/ixgbe  erj Pre-commit phabricator review requested.
@@ -94,5 +97,8 @@ sys/dev/usb   hselaskyIf in doubt, ask.
 sys/netinet/ip_carp.c  glebius Pre-commit review recommended.
 sys/netpfil/pf kp,glebius  Pre-commit review recommended.
 tests  freebsd-testing,ngiePre-commit review requested.
+usr.sbin/bsdconfig dteske  Pre-commit phabricator review requested.
+usr.sbin/dpv   dteske  Pre-commit review requested. Keep in sync with libdpv.
 usr.sbin/pkg   pkg@Please coordinate behavior or flag changes with pkg 
team.
+usr.sbin/sysrc dteske  Pre-commit phabricator review requested. Keep in sync 
with bsdconfig(8) sysrc.subr.
 vmm(4) neel,grehan Pre-commit review requested.
___
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: r292809 - head/lib/libc/stdio

2015-12-28 Thread John Baldwin
On Sunday, December 27, 2015 11:04:12 PM Warner Losh wrote:
> Author: imp
> Date: Sun Dec 27 23:04:11 2015
> New Revision: 292809
> URL: https://svnweb.freebsd.org/changeset/base/292809
> 
> Log:
>   The FILE structure has a mbstate_t in it. This structure needs to be
>   aligned on a int64_t boundary. However, when we allocate the array of
>   these structures, we use ALIGNBYTES which defaults to sizeof(int) on
>   arm, i386 and others. The i386 stuff can handle unaligned accesses
>   seemlessly. However, arm cannot. Take this into account when creating
>   the array of FILEs, and add some comments about why.
>   
>   Differential Revision: https://reviews.freebsd.org/D4708
> 
> Modified:
>   head/lib/libc/stdio/findfp.c
> 
> Modified: head/lib/libc/stdio/findfp.c
> ==
> --- head/lib/libc/stdio/findfp.c  Sun Dec 27 23:04:10 2015
> (r292808)
> +++ head/lib/libc/stdio/findfp.c  Sun Dec 27 23:04:11 2015
> (r292809)
> @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #include 
> @@ -96,11 +97,22 @@ moreglue(int n)
>   struct glue *g;
>   static FILE empty = { ._fl_mutex = PTHREAD_MUTEX_INITIALIZER };
>   FILE *p;
> + size_t align;
>  
> - g = (struct glue *)malloc(sizeof(*g) + ALIGNBYTES + n * sizeof(FILE));
> + /*
> +  * FILE has a mbstate_t variable. This variable tries to be int64_t
> +  * aligned through its definition. int64_t may be larger than void *,
> +  * which is the size traditionally used for ALIGNBYTES.  So, use our own
> +  * rounding instead of the MI ALIGN macros. If for some reason
> +  * ALIGNBYTES is larger than int64_t, respect that too. There appears to
> +  * be no portable way to ask for FILE's alignment requirements other
> +  * than just knowing here.
> +  */
> + align = MAX(ALIGNBYTES, sizeof(int64_t));
> + g = (struct glue *)malloc(sizeof(*g) + align + n * sizeof(FILE));
>   if (g == NULL)
>   return (NULL);
> - p = (FILE *)ALIGN(g + 1);
> + p = (FILE *)roundup((uintptr_t)(g + 1), align);

Can this use posix_memalign() rather than doing the alignment by hand?

-- 
John Baldwin
___
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: r292809 - head/lib/libc/stdio

2015-12-28 Thread Warner Losh
I'll look at that, but I don't think posix_memalign is the right way to go.
The alignment of FILE is more strict than posix_memalign will return. Ian's
idea of __alignof__ is the way to go. We allocate them in one block on
purpose for performance, and posix_memalign would be a one at a time affair.

Warner
On Dec 28, 2015 12:42 PM, "John Baldwin"  wrote:

> On Sunday, December 27, 2015 11:04:12 PM Warner Losh wrote:
> > Author: imp
> > Date: Sun Dec 27 23:04:11 2015
> > New Revision: 292809
> > URL: https://svnweb.freebsd.org/changeset/base/292809
> >
> > Log:
> >   The FILE structure has a mbstate_t in it. This structure needs to be
> >   aligned on a int64_t boundary. However, when we allocate the array of
> >   these structures, we use ALIGNBYTES which defaults to sizeof(int) on
> >   arm, i386 and others. The i386 stuff can handle unaligned accesses
> >   seemlessly. However, arm cannot. Take this into account when creating
> >   the array of FILEs, and add some comments about why.
> >
> >   Differential Revision: https://reviews.freebsd.org/D4708
> >
> > Modified:
> >   head/lib/libc/stdio/findfp.c
> >
> > Modified: head/lib/libc/stdio/findfp.c
> >
> ==
> > --- head/lib/libc/stdio/findfp.c  Sun Dec 27 23:04:10 2015
> (r292808)
> > +++ head/lib/libc/stdio/findfp.c  Sun Dec 27 23:04:11 2015
> (r292809)
> > @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >
> >  #include 
> > @@ -96,11 +97,22 @@ moreglue(int n)
> >   struct glue *g;
> >   static FILE empty = { ._fl_mutex = PTHREAD_MUTEX_INITIALIZER };
> >   FILE *p;
> > + size_t align;
> >
> > - g = (struct glue *)malloc(sizeof(*g) + ALIGNBYTES + n *
> sizeof(FILE));
> > + /*
> > +  * FILE has a mbstate_t variable. This variable tries to be int64_t
> > +  * aligned through its definition. int64_t may be larger than void
> *,
> > +  * which is the size traditionally used for ALIGNBYTES.  So, use
> our own
> > +  * rounding instead of the MI ALIGN macros. If for some reason
> > +  * ALIGNBYTES is larger than int64_t, respect that too. There
> appears to
> > +  * be no portable way to ask for FILE's alignment requirements
> other
> > +  * than just knowing here.
> > +  */
> > + align = MAX(ALIGNBYTES, sizeof(int64_t));
> > + g = (struct glue *)malloc(sizeof(*g) + align + n * sizeof(FILE));
> >   if (g == NULL)
> >   return (NULL);
> > - p = (FILE *)ALIGN(g + 1);
> > + p = (FILE *)roundup((uintptr_t)(g + 1), align);
>
> Can this use posix_memalign() rather than doing the alignment by hand?
>
> --
> John Baldwin
>
___
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: r292840 - head/sys/dev/puc

2015-12-28 Thread Marius Strobl
Author: marius
Date: Mon Dec 28 20:24:08 2015
New Revision: 292840
URL: https://svnweb.freebsd.org/changeset/base/292840

Log:
  - Add an entry for the SIIG Cyber 2SP1 PCIe adapter, which is based
on an Oxford Semiconductor OX16PCI954 but uses only two ports and
a non-default clock rate.
  - Fix style/whitespace
  
  PR:   176407
  MFC after:3 days

Modified:
  head/sys/dev/puc/pucdata.c

Modified: head/sys/dev/puc/pucdata.c
==
--- head/sys/dev/puc/pucdata.c  Mon Dec 28 19:29:05 2015(r292839)
+++ head/sys/dev/puc/pucdata.c  Mon Dec 28 20:24:08 2015(r292840)
@@ -763,6 +763,12 @@ const struct puc_cfg puc_pci_devices[] =
PUC_PORT_4S, 0x10, 0, 8,
},
 
+   {   0x1415, 0x950a, 0x131f, 0x2061,
+   "SIIG Cyber 2SP1 PCIe",
+   DEFAULT_RCLK * 10,
+   PUC_PORT_2S, 0x10, 0, 8,
+   },
+
{   0x1415, 0x950a, 0x, 0,
"Oxford Semiconductor OX16PCI954 UARTs",
DEFAULT_RCLK,
@@ -840,9 +846,9 @@ const struct puc_cfg puc_pci_devices[] =
 */
 
{   0x1415, 0xc11b, 0x, 0,
-"Oxford Semiconductor OXPCIe952 1S1P",
-DEFAULT_RCLK * 0x22,
-PUC_PORT_NONSTANDARD, 0x10, 0, -1,
+   "Oxford Semiconductor OXPCIe952 1S1P",
+   DEFAULT_RCLK * 0x22,
+   PUC_PORT_NONSTANDARD, 0x10, 0, -1,
.config_function = puc_config_oxford_pcie
},
 
@@ -1275,7 +1281,8 @@ puc_config_moxa(struct puc_softc *sc, en
if (cmd == PUC_CFG_GET_OFS) {
const struct puc_cfg *cfg = sc->sc_cfg;
 
-   if (port == 3 && (cfg->device == 0x1045 || cfg->device == 
0x1144))
+   if (port == 3 && (cfg->device == 0x1045 ||
+   cfg->device == 0x1144))
port = 7;
*res = port * 0x200;
 
___
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: r292777 - in head: lib/libc/sys sys/kern

2015-12-28 Thread Bruce Evans

On Mon, 28 Dec 2015, Garrett Cooper wrote:




On Dec 28, 2015, at 02:17, Bruce Evans  wrote:


...


It is not unreasonable to panic when such tests fail, just like for other
settings of unreasonable values.  Only the superuser can make them, and
the superuser should know better than to run them on production systems.


On a development system, this is perfectly reasonable. However, on systems in 
production, dying on asserts or panicking when unexpected input is encountered 
instead of erroring out appropriately is not ideal: it causes unnecessary 
downtime and can confuse others (customers, lower level admins) who are not 
fully aware of how UNIX and FreeBSD works (and in turn generate support calls 
and bug reports).


This is sort of backwards.  Unexpected cases by definition have no code to
handle them.  If you are lucky then they will be detected by an assertion
or a bad pointer and cause a panic before they do further damage.  Bad
pointers works better for this since they cannot be turned off on
production systems.

Out of bounds input that is expected can be handled, but the handling can
still reasonably be to panic.  For example, add assertions at the lowest
level that values are within bounds for the BCD array.  This "handles" the
bad input that is "expected" from buggy upper layers.

Panics for expected cases are easier to avoid (or cause) than for unexpected
cases.  The super user should avoid them.  Malicious users should try to
caus them.  But when the syscall that causes them is privileged, the
malicious users can't get far.

Another easy way to trigger the panic is:
- abuse the adjkerntz sysctl to set a huge negative offset.  utc_offset()
  is normally small, so it can only produce negative times from positive
  times in the Western hemisphere for times near the Epoch.  The
  adjkerntz offset is added in utc_offset() so it can reach 68 years
  back from the current time, i.e., to 1947.

The adjkerntz sysctl, like most sysctls, is correctly implemented with
no bounds checking.  Callers are trusted to know more about the correct
bounds than the kernel.

A not so way way to trigger the panic is:
- set the time in the BIOS to before the Epoch if the BIOS supports that.
  Say 1969/01/01.
- set this time in the kernel by booting if you can do that.  On x86, this
  requires configuring with USE_RTC_CENTURY to prevent 1969 being
  interpreted as 2069.  You now have a negative time.
- find or create an ntp server that supports times before the Epoch, and
  set its time to 1969/01/01
- wait to sync with the ntp server with the fake time.  The dubious
  periodic refresh of the TODR when the time is synced with ntp is not
  even an option and the default period is 1800 seconds.  Also wait
  for the refresh.  resettodr() is then called with a negative time.

ntpd normally uses microadjustments so it is not affected by restrictions
in settime().  I don't know of any other way of trying to write back the
current time, and ntpd with a non-fake time doesn't do it because 1969
can only be in sync with a fake time.

The periodic refresh is dubious because at least on x86 the RTC reading
and setting code is sloppy and has an error of about 1 second each,
and races.  So setting the RTC more accurately than 1-2 seconds is
worse than useless (it rarely helps, and may lose to races).  It can be
kept that accurate by setting it much less often than twice per hour,
except for the initial setting after booting which is best done by
ntpdate.  Everything is best handled in userland.  adjkerntz(8) handles
more complicated things, and the adjkerntz sysctl can be used at any
time for its side effect of calling resettodr().

The badly named machdep.disable_rtc_set sysctl still exists and is still
used by adjkerntz(8) to make resettodr() do nothing.  This is normally
enabled, but adjkerntz(8) disables it transiently to avoid setting the
RTC too often.  This could be disabled more permantly to stop buggy
things like settime() and the ntpd refresh ever setting the RTC.  IIRC,
adjkerntz(8) is fairly careful with this sysctl and restores it to
its previous state after using it.

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: r292846 - head/usr.sbin/pw

2015-12-28 Thread Baptiste Daroussin
Author: bapt
Date: Mon Dec 28 23:57:22 2015
New Revision: 292846
URL: https://svnweb.freebsd.org/changeset/base/292846

Log:
  Restore dryrun support for pw groupmod

Modified:
  head/usr.sbin/pw/pw_group.c

Modified: head/usr.sbin/pw/pw_group.c
==
--- head/usr.sbin/pw/pw_group.c Mon Dec 28 23:32:27 2015(r292845)
+++ head/usr.sbin/pw/pw_group.c Mon Dec 28 23:57:22 2015(r292846)
@@ -664,6 +664,11 @@ pw_group_mod(int argc, char **argv, char
grp_add_members(&grp, newmembers);
}
 
+   if (dryrun) {
+   print_group(grp, pretty);
+   return (EXIT_SUCCESS);
+   }
+
if ((rc = chggrent(name, grp)) != 0) {
if (rc == -1)
errx(EX_IOERR, "group '%s' not available (NIS?)",
___
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: r292847 - head/usr.sbin/pw

2015-12-28 Thread Baptiste Daroussin
Author: bapt
Date: Tue Dec 29 00:02:08 2015
New Revision: 292847
URL: https://svnweb.freebsd.org/changeset/base/292847

Log:
  Remove useless assignement of linelen

Modified:
  head/usr.sbin/pw/pw_vpw.c

Modified: head/usr.sbin/pw/pw_vpw.c
==
--- head/usr.sbin/pw/pw_vpw.c   Mon Dec 28 23:57:22 2015(r292846)
+++ head/usr.sbin/pw/pw_vpw.c   Tue Dec 29 00:02:08 2015(r292847)
@@ -70,7 +70,6 @@ vnextpwent(char const *nam, uid_t uid, i
pw = NULL;
line = NULL;
linecap = 0;
-   linelen = 0;
 
if (pwd_fp != NULL || (pwd_fp = fopen(getpwpath(_MASTERPASSWD), "r")) 
!= NULL) {
while ((linelen = getline(&line, &linecap, pwd_fp)) > 0) {
@@ -153,7 +152,6 @@ vnextgrent(char const *nam, gid_t gid, i
gr = NULL;
line = NULL;
linecap = 0;
-   linelen = 0;
 
if (grp_fp != NULL || (grp_fp = fopen(getgrpath(_GROUP), "r")) != NULL) 
{
while ((linelen = getline(&line, &linecap, grp_fp)) > 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: r292849 - head/usr.sbin/pw

2015-12-28 Thread Baptiste Daroussin
Author: bapt
Date: Tue Dec 29 00:08:32 2015
New Revision: 292849
URL: https://svnweb.freebsd.org/changeset/base/292849

Log:
  Simplify code for parsing extra groups

Modified:
  head/usr.sbin/pw/pw_conf.c

Modified: head/usr.sbin/pw/pw_conf.c
==
--- head/usr.sbin/pw/pw_conf.c  Tue Dec 29 00:04:21 2015(r292848)
+++ head/usr.sbin/pw/pw_conf.c  Tue Dec 29 00:08:32 2015(r292849)
@@ -313,7 +313,7 @@ read_userconfig(char const * file)
? NULL : newstr(q);
break;
case _UC_EXTRAGROUPS:
-   for (i = 0; q != NULL; q = strtok(NULL, toks)) {
+   while ((q = strtok(NULL, toks)) != NULL) {
if (config.groups == NULL)
config.groups = sl_init();
sl_add(config.groups, newstr(q));
___
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: r292858 - head/sys/powerpc/powerpc

2015-12-28 Thread Justin Hibbits
Author: jhibbits
Date: Tue Dec 29 03:31:06 2015
New Revision: 292858
URL: https://svnweb.freebsd.org/changeset/base/292858

Log:
  Update capabilities of e500mc, e5500, e6500.

Modified:
  head/sys/powerpc/powerpc/cpu.c

Modified: head/sys/powerpc/powerpc/cpu.c
==
--- head/sys/powerpc/powerpc/cpu.c  Tue Dec 29 01:21:40 2015
(r292857)
+++ head/sys/powerpc/powerpc/cpu.c  Tue Dec 29 03:31:06 2015
(r292858)
@@ -175,9 +175,12 @@ static const struct cputab models[] = {
 { "Freescale e500v2 core", FSL_E500v2, REVFMT_MAJMIN,
   0, cpu_booke_setup },
{ "Freescale e500mc core",  FSL_E500mc, REVFMT_MAJMIN,
-  0, cpu_booke_setup },
+  PPC_FEATURE_HAS_FPU, cpu_booke_setup },
{ "Freescale e5500 core",   FSL_E5500,  REVFMT_MAJMIN,
-  0, cpu_booke_setup },
+  PPC_FEATURE_64 | PPC_FEATURE_HAS_FPU, cpu_booke_setup },
+   { "Freescale e6500 core",   FSL_E6500,  REVFMT_MAJMIN,
+  PPC_FEATURE_64 | PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU,
+  cpu_booke_setup },
 { "IBM Cell Broadband Engine", IBMCELLBE,  REVFMT_MAJMIN,
   PPC_FEATURE_64 | PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU,
   NULL},
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r292859 - in head/sys/dev/hyperv: include vmbus

2015-12-28 Thread Xin LI
Author: delphij
Date: Tue Dec 29 07:54:55 2015
New Revision: 292859
URL: https://svnweb.freebsd.org/changeset/base/292859

Log:
  hyperv: vmbus: remove the per-channel control_work_queue
  
  Now vmbus_channel_on_offer() -> vmbus_channel_process_offer() can
  safely run on the global hv_vmbus_g_connection.work_queue now.
  
  We remove the per-channel control_work_queue to achieve the proper
  serialization of the message handling.
  
  I removed the bogus TODO in vmbus_channel_on_offer(): a vmbus offer
  can only come from the parent partition, i.e., the host.
  
  PR:   kern/205156
  Submitted by: Dexuan Cui 
  Reviewed by:  Howard Su , delphij
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D4597

Modified:
  head/sys/dev/hyperv/include/hyperv.h
  head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c

Modified: head/sys/dev/hyperv/include/hyperv.h
==
--- head/sys/dev/hyperv/include/hyperv.hTue Dec 29 03:31:06 2015
(r292858)
+++ head/sys/dev/hyperv/include/hyperv.hTue Dec 29 07:54:55 2015
(r292859)
@@ -759,7 +759,6 @@ typedef struct hv_vmbus_channel {
hv_vmbus_ring_buffer_info   inbound;
 
struct mtx  inbound_lock;
-   hv_vmbus_handle control_work_queue;
 
hv_vmbus_pfn_channel_callback   on_channel_callback;
void*   channel_callback_context;

Modified: head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
==
--- head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Dec 29 03:31:06 2015
(r292858)
+++ head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Dec 29 07:54:55 2015
(r292859)
@@ -49,7 +49,6 @@ static void vmbus_channel_on_gpadl_creat
 static void vmbus_channel_on_gpadl_torndown(hv_vmbus_channel_msg_header* hdr);
 static void vmbus_channel_on_offers_delivered(hv_vmbus_channel_msg_header* 
hdr);
 static void vmbus_channel_on_version_response(hv_vmbus_channel_msg_header* 
hdr);
-static void vmbus_channel_process_offer(void *context);
 
 /**
  * Channel message dispatch table
@@ -206,15 +205,6 @@ hv_queue_work_item(
return (taskqueue_enqueue(wq->queue, &w->work));
 }
 
-/**
- * @brief Rescind the offer by initiating a device removal
- */
-static void
-vmbus_channel_process_rescind_offer(void *context)
-{
-   hv_vmbus_channel* channel = (hv_vmbus_channel*) context;
-   hv_vmbus_child_device_unregister(channel->device);
-}
 
 /**
  * @brief Allocate and initialize a vmbus channel object
@@ -237,14 +227,6 @@ hv_vmbus_allocate_channel(void)
 
TAILQ_INIT(&channel->sc_list_anchor);
 
-   channel->control_work_queue = hv_work_queue_create("control");
-
-   if (channel->control_work_queue == NULL) {
-   mtx_destroy(&channel->inbound_lock);
-   free(channel, M_DEVBUF);
-   return (NULL);
-   }
-
return (channel);
 }
 
@@ -255,7 +237,6 @@ static inline void
 ReleaseVmbusChannel(void *context)
 {
hv_vmbus_channel* channel = (hv_vmbus_channel*) context;
-   hv_work_queue_close(channel->control_work_queue);
free(channel, M_DEVBUF);
 }
 
@@ -281,14 +262,12 @@ hv_vmbus_free_vmbus_channel(hv_vmbus_cha
  * associated with this offer
  */
 static void
-vmbus_channel_process_offer(void *context)
+vmbus_channel_process_offer(hv_vmbus_channel *new_channel)
 {
-   hv_vmbus_channel*   new_channel;
boolean_t   f_new;
hv_vmbus_channel*   channel;
int ret;
 
-   new_channel = (hv_vmbus_channel*) context;
f_new = TRUE;
channel = NULL;
 
@@ -521,11 +500,7 @@ vmbus_channel_on_offer(hv_vmbus_channel_
new_channel->monitor_group = (uint8_t) offer->monitor_id / 32;
new_channel->monitor_bit = (uint8_t) offer->monitor_id % 32;
 
-   /* TODO: Make sure the offer comes from our parent partition */
-   hv_queue_work_item(
-   new_channel->control_work_queue,
-   vmbus_channel_process_offer,
-   new_channel);
+   vmbus_channel_process_offer(new_channel);
 }
 
 /**
@@ -546,8 +521,7 @@ vmbus_channel_on_offer_rescind(hv_vmbus_
if (channel == NULL) 
return;
 
-   hv_queue_work_item(channel->control_work_queue,
-   vmbus_channel_process_rescind_offer, channel);
+   hv_vmbus_child_device_unregister(channel->device);
 }
 
 /**
___
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"