svn commit: r350437 - head/sys/sys

2019-07-29 Thread Xin LI
Author: delphij
Date: Tue Jul 30 05:14:28 2019
New Revision: 350437
URL: https://svnweb.freebsd.org/changeset/base/350437

Log:
  Bump __FreeBSD_version after removal of gzip'ed a.out support.

Modified:
  head/sys/sys/param.h

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hTue Jul 30 05:13:16 2019(r350436)
+++ head/sys/sys/param.hTue Jul 30 05:14:28 2019(r350437)
@@ -60,7 +60,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1300037  /* Master, propagated to newvers */
+#define __FreeBSD_version 1300038  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
___
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: r350436 - in head/sys: amd64/conf arm/arm conf i386/conf kern sys

2019-07-29 Thread Xin LI
Author: delphij
Date: Tue Jul 30 05:13:16 2019
New Revision: 350436
URL: https://svnweb.freebsd.org/changeset/base/350436

Log:
  Remove gzip'ed a.out support.
  
  The current implementation of gzipped a.out support was based
  on a very old version of InfoZIP which ships with an ancient
  modified version of zlib, and was removed from the GENERIC
  kernel in 1999 when we moved to an ELF world.
  
  PR:   205822
  Reviewed by:  imp, kib, emaste, Yoshihiro Ota 
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D21099

Deleted:
  head/sys/arm/arm/elf_trampoline.c
  head/sys/kern/imgact_gzip.c
  head/sys/kern/subr_inflate.c
  head/sys/sys/inflate.h
Modified:
  head/sys/amd64/conf/NOTES
  head/sys/conf/files
  head/sys/conf/files.amd64
  head/sys/conf/files.i386
  head/sys/i386/conf/NOTES

Modified: head/sys/amd64/conf/NOTES
==
--- head/sys/amd64/conf/NOTES   Tue Jul 30 04:17:36 2019(r350435)
+++ head/sys/amd64/conf/NOTES   Tue Jul 30 05:13:16 2019(r350436)
@@ -127,7 +127,6 @@ device  nvram   # Access to rtc cmos 
via /dev/nvram
 device speaker #Play IBM BASIC-style noises out your speaker
 hint.speaker.0.at="isa"
 hint.speaker.0.port="0x61"
-device gzip#Exec gzipped a.out's.  REQUIRES COMPAT_AOUT!
 
 
 #

Modified: head/sys/conf/files
==
--- head/sys/conf/files Tue Jul 30 04:17:36 2019(r350435)
+++ head/sys/conf/files Tue Jul 30 05:13:16 2019(r350436)
@@ -3814,7 +3814,6 @@ kern/subr_firmware.c  optional firmware
 kern/subr_gtaskqueue.c standard
 kern/subr_hash.c   standard
 kern/subr_hints.c  standard
-kern/subr_inflate.coptional gzip
 kern/subr_kdb.cstandard
 kern/subr_kobj.c   standard
 kern/subr_lock.c   standard

Modified: head/sys/conf/files.amd64
==
--- head/sys/conf/files.amd64   Tue Jul 30 04:17:36 2019(r350435)
+++ head/sys/conf/files.amd64   Tue Jul 30 05:13:16 2019(r350436)
@@ -633,7 +633,6 @@ isa/syscons_isa.c   optionalsc
 isa/vga_isa.c  optionalvga
 kern/kern_clocksource.cstandard
 kern/imgact_aout.c optional compat_aout
-kern/imgact_gzip.c optional gzip
 kern/link_elf_obj.cstandard
 libkern/x86/crc32_sse42.c  standard
 #

Modified: head/sys/conf/files.i386
==
--- head/sys/conf/files.i386Tue Jul 30 04:17:36 2019(r350435)
+++ head/sys/conf/files.i386Tue Jul 30 05:13:16 2019(r350436)
@@ -529,7 +529,6 @@ isa/syscons_isa.c   optional sc
 isa/vga_isa.c  optional vga
 kern/kern_clocksource.cstandard
 kern/imgact_aout.c optional compat_aout
-kern/imgact_gzip.c optional gzip
 kern/subr_sfbuf.c  standard
 libkern/divdi3.c   standard
 libkern/ffsll.cstandard

Modified: head/sys/i386/conf/NOTES
==
--- head/sys/i386/conf/NOTESTue Jul 30 04:17:36 2019(r350435)
+++ head/sys/i386/conf/NOTESTue Jul 30 05:13:16 2019(r350436)
@@ -275,7 +275,6 @@ device  nvram   # Access to rtc cmos 
via /dev/nvram
 device speaker #Play IBM BASIC-style noises out your speaker
 hint.speaker.0.at="isa"
 hint.speaker.0.port="0x61"
-device gzip#Exec gzipped a.out's.  REQUIRES COMPAT_AOUT!
 device apm_saver   # Requires APM
 
 
___
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: r350433 - head/sys/dev/sound/pci/hda

2019-07-29 Thread Marcelo Araujo
Author: araujo
Date: Tue Jul 30 02:01:49 2019
New Revision: 350433
URL: https://svnweb.freebsd.org/changeset/base/350433

Log:
  Fix sound on headset jack for ALC255 and ALC256 codec.
  
  PR:   219350 [1], [2]
  Submitted by: Masachika ISHIZUKA (ish_at_amail.plala.or.jp) [1]
Neel Chauhan (neel_at_neelc.org) [2]
uri Momotyuk (yurkis_at_gmail.com) [3]
  Reported by:  miwi
  Reviewed by:  mav
  Obtained from:https://github.com/trueos/trueos/pull/279 [3]
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D19017

Modified:
  head/sys/dev/sound/pci/hda/hdaa_patches.c
  head/sys/dev/sound/pci/hda/hdac.h

Modified: head/sys/dev/sound/pci/hda/hdaa_patches.c
==
--- head/sys/dev/sound/pci/hda/hdaa_patches.c   Mon Jul 29 22:07:43 2019
(r350432)
+++ head/sys/dev/sound/pci/hda/hdaa_patches.c   Tue Jul 30 02:01:49 2019
(r350433)
@@ -425,12 +425,21 @@ hdac_pin_patch(struct hdaa_widget *w)
} else if (id == HDA_CODEC_ALC298 && subid == DELL_XPS9560_SUBVENDOR) {
switch (nid) {
case 24:
-   config  = 0x01a1913c;
+   config = 0x01a1913c;
break;
case 26:
-   config  = 0x01a1913d;
+   config = 0x01a1913d;
break;
}
+   } else if (id == HDA_CODEC_ALC256 && subid == DELL_I7577_SUBVENDOR ) {
+   switch (nid) {
+   case 20:
+   patch = "as=1 seq=0";
+   break;
+   case 33:
+   patch = "as=1 seq=15";
+   break;
+   }
}
 
if (patch != NULL)
@@ -768,6 +777,10 @@ hdaa_patch_direct(struct hdaa_devinfo *devinfo)
hdaa_write_coef(dev, 0x20, 0x07, 0x7cb);
}
break;
+   }
+   if (id == HDA_CODEC_ALC255 || id == HDA_CODEC_ALC256) {
+   val = hdaa_read_coef(dev, 0x20, 0x46);
+   hdaa_write_coef(dev, 0x20, 0x46, val|0x3000);
}
if (subid == APPLE_INTEL_MAC)
hda_command(dev, HDA_CMD_12BIT(0, devinfo->nid,

Modified: head/sys/dev/sound/pci/hda/hdac.h
==
--- head/sys/dev/sound/pci/hda/hdac.h   Mon Jul 29 22:07:43 2019
(r350432)
+++ head/sys/dev/sound/pci/hda/hdac.h   Tue Jul 30 02:01:49 2019
(r350433)
@@ -203,6 +203,7 @@
 #define DELL_XPSM1210_SUBVENDORHDA_MODEL_CONSTRUCT(DELL, 0x01d7)
 #define DELL_OPLX745_SUBVENDOR HDA_MODEL_CONSTRUCT(DELL, 0x01da)
 #define DELL_XPS9560_SUBVENDOR HDA_MODEL_CONSTRUCT(DELL, 0x07be)
+#define DELL_I7577_SUBVENDOR   HDA_MODEL_CONSTRUCT(DELL, 0x0802)
 #define DELL_ALL_SUBVENDOR HDA_MODEL_CONSTRUCT(DELL, 0x)
 
 /* Clevo */
___
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: r350420 - in head: include lib/libc/stdio

2019-07-29 Thread Mark Johnston
On Mon, Jul 29, 2019 at 06:38:42PM -0400, Shawn Webb wrote:
> On Mon, Jul 29, 2019 at 07:02:16PM +, Mark Johnston wrote:
> > Author: markj
> > Date: Mon Jul 29 19:02:16 2019
> > New Revision: 350420
> > URL: https://svnweb.freebsd.org/changeset/base/350420
> > 
> > Log:
> >   Add mkostempsat(3).
> >   
> >   This is a variant of mkostemps() which takes a directory descriptor and
> >   returns a descriptor for a tempfile relative to that directory.  Unlike
> >   the other mktemp functions, mkostempsat() can be used in capability
> >   mode.
> 
> Out of curiosity, is __FreeBSD_version typically bumped when a new
> public symbol is added to libc?

I don't think so, unless there's some specific reason to do so.  The
function was added for use in Capsicumizing some code in the base system
so I had no need to bump __FreeBSD_version.
___
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: r350420 - in head: include lib/libc/stdio

2019-07-29 Thread Shawn Webb
On Mon, Jul 29, 2019 at 07:02:16PM +, Mark Johnston wrote:
> Author: markj
> Date: Mon Jul 29 19:02:16 2019
> New Revision: 350420
> URL: https://svnweb.freebsd.org/changeset/base/350420
> 
> Log:
>   Add mkostempsat(3).
>   
>   This is a variant of mkostemps() which takes a directory descriptor and
>   returns a descriptor for a tempfile relative to that directory.  Unlike
>   the other mktemp functions, mkostempsat() can be used in capability
>   mode.

Out of curiosity, is __FreeBSD_version typically bumped when a new
public symbol is added to libc?

Thanks,

-- 
Shawn Webb
Cofounder / Security Engineer
HardenedBSD

Tor-ified Signal:+1 443-546-8752
Tor+XMPP+OTR:latt...@is.a.hacker.sx
GPG Key ID:  0xFF2E67A277F8E1FA
GPG Key Fingerprint: D206 BB45 15E0 9C49 0CF9  3633 C85B 0AF8 AB23 0FB2


signature.asc
Description: PGP signature


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

2019-07-29 Thread Mark Johnston
Author: markj
Date: Mon Jul 29 22:07:43 2019
New Revision: 350432
URL: https://svnweb.freebsd.org/changeset/base/350432

Log:
  Merge r3778 and r3779 from ELFToolchain.
  
  Modify strip(1) to not accept multiple input files when an output
  file is specified.  There is no good way to handle this combination,
  and the change is compatible with binutils.
  
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation

Modified:
  head/contrib/elftoolchain/elfcopy/main.c
  head/contrib/elftoolchain/elfcopy/strip.1

Modified: head/contrib/elftoolchain/elfcopy/main.c
==
--- head/contrib/elftoolchain/elfcopy/main.cMon Jul 29 22:01:28 2019
(r350431)
+++ head/contrib/elftoolchain/elfcopy/main.cMon Jul 29 22:07:43 2019
(r350432)
@@ -1187,6 +1187,12 @@ strip_main(struct elfcopy *ecp, int argc, char **argv)
ecp->strip = STRIP_ALL;
if (optind == argc)
strip_usage();
+   /*
+* Only accept a single input file if an output file had been
+* specified.
+*/
+   if (outfile != NULL && argc != (optind + 1))
+   strip_usage();
 
for (i = optind; i < argc; i++)
create_file(ecp, argv[i], outfile);

Modified: head/contrib/elftoolchain/elfcopy/strip.1
==
--- head/contrib/elftoolchain/elfcopy/strip.1   Mon Jul 29 22:01:28 2019
(r350431)
+++ head/contrib/elftoolchain/elfcopy/strip.1   Mon Jul 29 22:07:43 2019
(r350432)
@@ -23,7 +23,7 @@
 .\"
 .\" $Id: strip.1 3642 2018-10-14 14:24:28Z jkoshy $
 .\"
-.Dd September 17, 2011
+.Dd July 27, 2019
 .Dt STRIP 1
 .Os
 .Sh NAME
@@ -51,8 +51,16 @@
 .Sh DESCRIPTION
 The
 .Nm
-utility is used to discard information from ELF objects.
+utility is used to discard information from the ELF objects
+specified by the arguments
+.Ar .
 .Pp
+If an explicit output file name is not specified using the
+.Fl o
+option, the
+.Nm
+utility will modify its input arguments in-place.
+.Pp
 The
 .Nm
 utility supports the following options:
@@ -65,8 +73,9 @@ Print a help message and exit.
 Remove all content except that which would be used for debugging.
 .It Fl o Ar outputfile | Fl -output-file= Ns Ar outputfile
 Write the stripped object to file
-.Ar outputfile .
-The default behaviour is to modify objects in place.
+.Ar outputfile
+instead of modifying the input in-place.
+Only a single input object should be specified if this option is used.
 .It Fl p | Fl -preserve-dates
 Preserve the object's access and modification times.
 .It Fl s | Fl -strip-all
___
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: r350431 - in head/sys: kern vm

2019-07-29 Thread Mark Johnston
Author: markj
Date: Mon Jul 29 22:01:28 2019
New Revision: 350431
URL: https://svnweb.freebsd.org/changeset/base/350431

Log:
  Centralize the logic in vfs_vmio_unwire() and sendfile_free_page().
  
  Both of these functions atomically unwire a page, optionally attempt
  to free the page, and enqueue or requeue the page.  Add functions
  vm_page_release() and vm_page_release_locked() to perform the same task.
  The latter must be called with the page's object lock held.
  
  As a side effect of this refactoring, the buffer cache will no longer
  attempt to free mapped pages when completing direct I/O.  This is
  consistent with the handling of pages by sendfile(SF_NOCACHE).
  
  Reviewed by:  alc, kib
  MFC after:2 weeks
  Sponsored by: Netflix
  Differential Revision:https://reviews.freebsd.org/D20986

Modified:
  head/sys/kern/kern_sendfile.c
  head/sys/kern/vfs_bio.c
  head/sys/vm/vm_page.c
  head/sys/vm/vm_page.h

Modified: head/sys/kern/kern_sendfile.c
==
--- head/sys/kern/kern_sendfile.c   Mon Jul 29 21:53:02 2019
(r350430)
+++ head/sys/kern/kern_sendfile.c   Mon Jul 29 22:01:28 2019
(r350431)
@@ -121,76 +121,22 @@ sfstat_sysctl(SYSCTL_HANDLER_ARGS)
 SYSCTL_PROC(_kern_ipc, OID_AUTO, sfstat, CTLTYPE_OPAQUE | CTLFLAG_RW,
 NULL, 0, sfstat_sysctl, "I", "sendfile statistics");
 
-/*
- * Detach mapped page and release resources back to the system.  Called
- * by mbuf(9) code when last reference to a page is freed.
- */
 static void
-sendfile_free_page(vm_page_t pg, bool nocache)
-{
-   bool freed;
-
-   vm_page_lock(pg);
-   /*
-* In either case check for the object going away on us.  This can
-* happen since we don't hold a reference to it.  If so, we're
-* responsible for freeing the page.  In 'noncache' case try to free
-* the page, but only if it is cheap to.
-*/
-   if (vm_page_unwire_noq(pg)) {
-   vm_object_t obj;
-
-   if ((obj = pg->object) == NULL)
-   vm_page_free(pg);
-   else {
-   freed = false;
-   if (nocache && !vm_page_xbusied(pg) &&
-   VM_OBJECT_TRYWLOCK(obj)) {
-   /* Only free unmapped pages. */
-   if (obj->ref_count == 0 ||
-   !pmap_page_is_mapped(pg))
-   /*
-* The busy test before the object is
-* locked cannot be relied upon.
-*/
-   freed = vm_page_try_to_free(pg);
-   VM_OBJECT_WUNLOCK(obj);
-   }
-   if (!freed) {
-   /*
-* If we were asked to not cache the page, place
-* it near the head of the inactive queue so
-* that it is reclaimed sooner.  Otherwise,
-* maintain LRU.
-*/
-   if (nocache)
-   vm_page_deactivate_noreuse(pg);
-   else if (vm_page_active(pg))
-   vm_page_reference(pg);
-   else
-   vm_page_deactivate(pg);
-   }
-   }
-   }
-   vm_page_unlock(pg);
-}
-
-static void
 sendfile_free_mext(struct mbuf *m)
 {
struct sf_buf *sf;
vm_page_t pg;
-   bool nocache;
+   int flags;
 
KASSERT(m->m_flags & M_EXT && m->m_ext.ext_type == EXT_SFBUF,
("%s: m %p !M_EXT or !EXT_SFBUF", __func__, m));
 
sf = m->m_ext.ext_arg1;
pg = sf_buf_page(sf);
-   nocache = m->m_ext.ext_flags & EXT_FLAG_NOCACHE;
+   flags = (m->m_ext.ext_flags & EXT_FLAG_NOCACHE) != 0 ? VPR_TRYFREE : 0;
 
sf_buf_free(sf);
-   sendfile_free_page(pg, nocache);
+   vm_page_release(pg, flags);
 
if (m->m_ext.ext_flags & EXT_FLAG_SYNC) {
struct sendfile_sync *sfs = m->m_ext.ext_arg2;
@@ -208,21 +154,21 @@ sendfile_free_mext_pg(struct mbuf *m)
 {
struct mbuf_ext_pgs *ext_pgs;
vm_page_t pg;
-   int i;
-   bool nocache, cache_last;
+   int flags, i;
+   bool cache_last;
 
KASSERT(m->m_flags & M_EXT && m->m_ext.ext_type == EXT_PGS,
("%s: m %p !M_EXT or !EXT_PGS", __func__, m));
 
-   nocache = m->m_ext.ext_flags & EXT_FLAG_NOCACHE;
cache_last = m->m_ext.ext_flags & EXT_FLAG_CACHE_LAST;
ext_pgs = m->m_ext.ext_pgs;
+   flags = (m->m_ext.ext_flags & EXT_FLAG_NOCACHE) != 0 ? VPR_TRYFREE : 0;
 

svn commit: r350430 - in head: share/man/man9 sys/sys

2019-07-29 Thread Mariusz Zaborski
Author: oshogbo
Date: Mon Jul 29 21:53:02 2019
New Revision: 350430
URL: https://svnweb.freebsd.org/changeset/base/350430

Log:
  seqc: add man page
  
  Reviewed by:  markj
  Earlier version reviewed by:  emaste, mjg, bcr, 0mp
  Differential Revision:https://reviews.freebsd.org/D16744

Added:
  head/share/man/man9/seqc.9   (contents, props changed)
Modified:
  head/share/man/man9/Makefile
  head/sys/sys/seqc.h

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileMon Jul 29 21:42:57 2019
(r350429)
+++ head/share/man/man9/MakefileMon Jul 29 21:53:02 2019
(r350430)
@@ -289,6 +289,7 @@ MAN=accept_filter.9 \
securelevel_gt.9 \
selrecord.9 \
sema.9 \
+   seqc.9 \
sf_buf.9 \
sglist.9 \
shm_map.9 \
@@ -1825,6 +1826,10 @@ MLINKS+=sema.9 sema_destroy.9 \
sema.9 sema_trywait.9 \
sema.9 sema_value.9 \
sema.9 sema_wait.9
+MLINKS+=seqc.9 seqc_consistent.9 \
+   seqc.9 seqc_read.9 \
+   seqc.9 seqc_write_begin.9 \
+   seqc.9 seqc_write_end.9
 MLINKS+=sf_buf.9 sf_buf_alloc.9 \
sf_buf.9 sf_buf_free.9 \
sf_buf.9 sf_buf_kva.9 \

Added: head/share/man/man9/seqc.9
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/man/man9/seqc.9  Mon Jul 29 21:53:02 2019(r350430)
@@ -0,0 +1,138 @@
+.\"
+.\" Copyright (C) 2019 Mariusz Zaborski 
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"notice(s), this list of conditions and the following disclaimer as
+.\"the first lines of this file unmodified other than the possible
+.\"addition of one or more copyright notices.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice(s), this list of conditions and the following disclaimer in the
+.\"documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
+.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+.\" DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+.\" DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd July 29, 2019
+.Dt SEQC 9
+.Os
+.Sh NAME
+.Nm seqc_consistent ,
+.Nm seqc_read ,
+.Nm seqc_write_begin ,
+.Nm seqc_write_end
+.Nd "lockless read algorithm"
+.Sh SYNOPSIS
+.In sys/seqc.h
+.Ft void
+.Fn seqc_write_begin "seqc_t *seqcp"
+.Ft void
+.Fn seqc_write_end "seqc_t *seqcp"
+.Ft seqc_t
+.Fn seqc_read "seqc_t *seqcp"
+.Ft seqc_t
+.Fn seqc_consistent "const seqc_t *seqcp" "seqc_t oldseqc"
+.Sh DESCRIPTION
+The
+.Nm seqc
+allows zero or more readers and zero or one writer to concurrently access
+an object, providing a consistent snapshot of the object for readers.
+No mutual exclusion between readers and writers is required,
+but readers may be starved indefinitely by writers.
+.Pp
+The functions
+.Fn seqc_write_begin
+and
+.Fn seqc_write_end
+are used to create a transaction for writer, and notify the readers that the
+object will be modified.
+.Pp
+The
+.Fn seqc_read
+function returns the current sequence number.
+If a writer has started a transaction, this function will spin until the
+transaction has ended.
+.Pp
+The
+.Fn seqc_consistent
+function compares the sequence number with a previously fetched value.
+The
+.Fa oldseqc
+variable should contain a sequence number from the beginning of read
+transaction.
+.Pp
+The reader at the end of a transaction checks if the sequence number has
+changed.
+If the sequence number didn't change the object wasn't modified, and fetched
+variables are valid.
+If the sequence number changed the object was modified and the fetch should be
+repeated.
+In case when sequence number is odd the object change is in progress and the
+reader will wait until the write will the sequence number will become even.
+.Sh EXAMPLES
+The following example for a writer changees the
+.Va var1
+and
+.Va var2
+variables in the
+.Va obj
+structure:
+.Bd -literal
+lock_exclusive(>lock);
+seqc_write_begin(>seqc);
+obj->var1 = 1;
+obj->var2 = 2;
+seqc_write_end(>seqc);

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

2019-07-29 Thread Mariusz Zaborski
Author: oshogbo
Date: Mon Jul 29 21:42:57 2019
New Revision: 350429
URL: https://svnweb.freebsd.org/changeset/base/350429

Log:
  proc: make clear_orphan an public API
  
  This will be useful for other patches with process descriptors.
  Change its name as well.
  
  Reviewed by:  markj, kib

Modified:
  head/sys/kern/kern_exit.c
  head/sys/sys/proc.h

Modified: head/sys/kern/kern_exit.c
==
--- head/sys/kern/kern_exit.c   Mon Jul 29 21:26:26 2019(r350428)
+++ head/sys/kern/kern_exit.c   Mon Jul 29 21:42:57 2019(r350429)
@@ -167,8 +167,8 @@ reaper_clear(struct proc *p)
proc_id_clear(PROC_ID_REAP, p->p_reapsubtree);
 }
 
-static void
-clear_orphan(struct proc *p)
+void
+proc_clear_orphan(struct proc *p)
 {
struct proc *p1;
 
@@ -522,7 +522,7 @@ exit1(struct thread *td, int rval, int signo)
 * list due to present P_TRACED flag. Clear
 * orphan link for q now while q is locked.
 */
-   clear_orphan(q);
+   proc_clear_orphan(q);
q->p_flag &= ~(P_TRACED | P_STOPPED_TRACE);
q->p_flag2 &= ~P2_PTRACE_FSTP;
q->p_ptevents = 0;
@@ -556,7 +556,7 @@ exit1(struct thread *td, int rval, int signo)
kern_psignal(q, q->p_pdeathsig);
CTR2(KTR_PTRACE, "exit: pid %d, clearing orphan %d", p->p_pid,
q->p_pid);
-   clear_orphan(q);
+   proc_clear_orphan(q);
PROC_UNLOCK(q);
}
 
@@ -912,7 +912,7 @@ proc_reap(struct thread *td, struct proc *p, int *stat
reaper_clear(p);
proc_id_clear(PROC_ID_PID, p->p_pid);
PROC_LOCK(p);
-   clear_orphan(p);
+   proc_clear_orphan(p);
PROC_UNLOCK(p);
leavepgrp(p);
if (p->p_procdesc != NULL)
@@ -1372,7 +1372,7 @@ proc_reparent(struct proc *child, struct proc *parent,
LIST_REMOVE(child, p_sibling);
LIST_INSERT_HEAD(>p_children, child, p_sibling);
 
-   clear_orphan(child);
+   proc_clear_orphan(child);
if (child->p_flag & P_TRACED) {
if (LIST_EMPTY(>p_pptr->p_orphans)) {
child->p_treeflag |= P_TREE_FIRST_ORPHAN;

Modified: head/sys/sys/proc.h
==
--- head/sys/sys/proc.h Mon Jul 29 21:26:26 2019(r350428)
+++ head/sys/sys/proc.h Mon Jul 29 21:42:57 2019(r350429)
@@ -1074,6 +1074,7 @@ void  proc_wkilled(struct proc *p);
 struct pstats *pstats_alloc(void);
 void   pstats_fork(struct pstats *src, struct pstats *dst);
 void   pstats_free(struct pstats *ps);
+void   proc_clear_orphan(struct proc *p);
 void   reaper_abandon_children(struct proc *p, bool exiting);
 intsecurelevel_ge(struct ucred *cr, int level);
 intsecurelevel_gt(struct ucred *cr, int level);
___
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: r350428 - head/lib/libcasper/libcasper

2019-07-29 Thread Mariusz Zaborski
Author: oshogbo
Date: Mon Jul 29 21:26:26 2019
New Revision: 350428
URL: https://svnweb.freebsd.org/changeset/base/350428

Log:
  libcasper: remove reference to deprecated system.random

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

Modified: head/lib/libcasper/libcasper/libcasper.3
==
--- head/lib/libcasper/libcasper/libcasper.3Mon Jul 29 21:21:53 2019
(r350427)
+++ head/lib/libcasper/libcasper/libcasper.3Mon Jul 29 21:26:26 2019
(r350428)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 5, 2018
+.Dd July 29, 2019
 .Dt LIBCASPER 3
 .Os
 .Sh NAME
@@ -212,9 +212,6 @@ compatible API
 provides
 .Xr getpwent 3
 compatible API
-.It system.random
-allows to obtain entropy from
-.Pa /dev/random
 .It system.sysctl
 provides
 .Xr sysctlbyname 3
___
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: r350427 - head/sys/arm64/arm64

2019-07-29 Thread Mark Johnston
Author: markj
Date: Mon Jul 29 21:21:53 2019
New Revision: 350427
URL: https://svnweb.freebsd.org/changeset/base/350427

Log:
  Have arm64's pmap_fault() handle WnR faults on dirty PTEs.
  
  If we take a WnR permission fault on a managed, writeable and dirty
  PTE, simply return success without calling the main fault handler.  This
  situation can occur if multiple threads simultaneously access a clean
  writeable mapping and trigger WnR faults; losers of the race to mark the
  PTE dirty would end up calling the main fault handler, which had no work
  to do.
  
  Reported by:  alc
  Reviewed by:  alc
  MFC with: r350004
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D21097

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

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Mon Jul 29 20:50:26 2019(r350426)
+++ head/sys/arm64/arm64/pmap.c Mon Jul 29 21:21:53 2019(r350427)
@@ -5743,7 +5743,7 @@ pmap_sync_icache(pmap_t pmap, vm_offset_t va, vm_size_
 int
 pmap_fault(pmap_t pmap, uint64_t esr, uint64_t far)
 {
-   pt_entry_t *pte;
+   pt_entry_t pte, *ptep;
register_t intr;
uint64_t ec, par;
int lvl, rv;
@@ -5767,9 +5767,9 @@ pmap_fault(pmap_t pmap, uint64_t esr, uint64_t far)
case ISS_DATA_DFSC_AFF_L2:
case ISS_DATA_DFSC_AFF_L3:
PMAP_LOCK(pmap);
-   pte = pmap_pte(pmap, far, );
-   if (pte != NULL) {
-   pmap_set_bits(pte, ATTR_AF);
+   ptep = pmap_pte(pmap, far, );
+   if (ptep != NULL) {
+   pmap_set_bits(ptep, ATTR_AF);
rv = KERN_SUCCESS;
/*
 * XXXMJ as an optimization we could mark the entry
@@ -5785,12 +5785,13 @@ pmap_fault(pmap_t pmap, uint64_t esr, uint64_t far)
(esr & ISS_DATA_WnR) == 0)
return (rv);
PMAP_LOCK(pmap);
-   pte = pmap_pte(pmap, far, );
-   if (pte != NULL &&
-   (pmap_load(pte) & (ATTR_AP_RW_BIT | ATTR_SW_DBM)) ==
-   (ATTR_AP(ATTR_AP_RO) | ATTR_SW_DBM)) {
-   pmap_clear_bits(pte, ATTR_AP_RW_BIT);
-   pmap_invalidate_page(pmap, far);
+   ptep = pmap_pte(pmap, far, );
+   if (ptep != NULL &&
+   ((pte = pmap_load(ptep)) & ATTR_SW_DBM) != 0) {
+   if ((pte & ATTR_AP_RW_BIT) == ATTR_AP(ATTR_AP_RO)) {
+   pmap_clear_bits(ptep, ATTR_AP_RW_BIT);
+   pmap_invalidate_page(pmap, far);
+   }
rv = KERN_SUCCESS;
}
PMAP_UNLOCK(pmap);
___
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: r350426 - head/sys/kern

2019-07-29 Thread Alan Somers
Author: asomers
Date: Mon Jul 29 20:50:26 2019
New Revision: 350426
URL: https://svnweb.freebsd.org/changeset/base/350426

Log:
  sendfile: don't panic when VOP_GETPAGES_ASYNC returns an error
  
  This is a partial merge of 350144 from projects/fuse2
  
  PR:   236466
  Reviewed by:  markj
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D21095

Modified:
  head/sys/kern/kern_sendfile.c
Directory Properties:
  head/   (props changed)

Modified: head/sys/kern/kern_sendfile.c
==
--- head/sys/kern/kern_sendfile.c   Mon Jul 29 20:43:07 2019
(r350425)
+++ head/sys/kern/kern_sendfile.c   Mon Jul 29 20:50:26 2019
(r350426)
@@ -347,13 +347,13 @@ sendfile_iodone(void *arg, vm_page_t *pg, int count, i
  * Iterate through pages vector and request paging for non-valid pages.
  */
 static int
-sendfile_swapin(vm_object_t obj, struct sf_io *sfio, off_t off, off_t len,
-int npages, int rhpages, int flags)
+sendfile_swapin(vm_object_t obj, struct sf_io *sfio, int *nios, off_t off,
+off_t len, int npages, int rhpages, int flags)
 {
vm_page_t *pa = sfio->pa;
-   int grabbed, nios;
+   int grabbed;
 
-   nios = 0;
+   *nios = 0;
flags = (flags & SF_NODISKIO) ? VM_ALLOC_NOWAIT : 0;
 
/*
@@ -372,7 +372,7 @@ sendfile_swapin(vm_object_t obj, struct sf_io *sfio, o
}
 
for (int i = 0; i < npages;) {
-   int j, a, count, rv __unused;
+   int j, a, count, rv;
 
/* Skip valid pages. */
if (vm_page_is_valid(pa[i], vmoff(i, off) & PAGE_MASK,
@@ -435,6 +435,17 @@ sendfile_swapin(vm_object_t obj, struct sf_io *sfio, o
rv = vm_pager_get_pages_async(obj, pa + i, count, NULL,
i + count == npages ?  : NULL,
_iodone, sfio);
+   if (rv != VM_PAGER_OK) {
+   for (j = i; j < i + count; j++) {
+   if (pa[j] != bogus_page) {
+   vm_page_lock(pa[j]);
+   vm_page_unwire(pa[j], PQ_INACTIVE);
+   vm_page_unlock(pa[j]);
+   }
+   }
+   VM_OBJECT_WUNLOCK(obj);
+   return (EIO);
+   }
KASSERT(rv == VM_PAGER_OK, ("%s: pager fail obj %p page %p",
__func__, obj, pa[i]));
 
@@ -456,15 +467,15 @@ sendfile_swapin(vm_object_t obj, struct sf_io *sfio, o
 
}
i += count;
-   nios++;
+   (*nios)++;
}
 
VM_OBJECT_WUNLOCK(obj);
 
-   if (nios == 0 && npages != 0)
+   if (*nios == 0 && npages != 0)
SFSTAT_INC(sf_noiocnt);
 
-   return (nios);
+   return (0);
 }
 
 static int
@@ -788,8 +799,14 @@ retry_space:
sfio->so = so;
sfio->error = 0;
 
-   nios = sendfile_swapin(obj, sfio, off, space, npages, rhpages,
-   flags);
+   error = sendfile_swapin(obj, sfio, , off, space, npages,
+   rhpages, flags);
+   if (error != 0) {
+   if (vp != NULL)
+   VOP_UNLOCK(vp, 0);
+   free(sfio, M_TEMP);
+   goto done;
+   }
 
/*
 * Loop and construct maximum sized mbuf chain to be bulk
___
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: r350425 - head/usr.bin/printf

2019-07-29 Thread Jilles Tjoelker
Author: jilles
Date: Mon Jul 29 20:43:07 2019
New Revision: 350425
URL: https://svnweb.freebsd.org/changeset/base/350425

Log:
  printf(1): Note that \c only works in %b strings
  
  PR:   238313
  Reported by:  Andras Farkas
  MFC after:1 week

Modified:
  head/usr.bin/printf/printf.1

Modified: head/usr.bin/printf/printf.1
==
--- head/usr.bin/printf/printf.1Mon Jul 29 20:41:11 2019
(r350424)
+++ head/usr.bin/printf/printf.1Mon Jul 29 20:43:07 2019
(r350425)
@@ -31,7 +31,7 @@
 .\"@(#)printf.18.1 (Berkeley) 6/6/93
 .\" $FreeBSD$
 .\"
-.Dd April 21, 2014
+.Dd July 29, 2019
 .Dt PRINTF 1
 .Os
 .Sh NAME
@@ -87,8 +87,6 @@ are as follows:
 Write a  character.
 .It Cm \eb
 Write a  character.
-.It Cm \ec
-Ignore remaining characters in this string.
 .It Cm \ef
 Write a  character.
 .It Cm \en
@@ -289,7 +287,12 @@ The permitted escape sequences are slightly different 
 octal escapes are
 .Cm \e0 Ns Ar num
 instead of
-.Cm \e Ns Ar num .
+.Cm \e Ns Ar num
+and that an additional escape sequence
+.Cm \ec
+stops further output from this
+.Nm
+invocation.
 .It Cm n$
 Allows reordering of the output according to
 .Ar argument .
___
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: r350424 - head/sbin/camcontrol

2019-07-29 Thread Alexander Motin
Author: mav
Date: Mon Jul 29 20:41:11 2019
New Revision: 350424
URL: https://svnweb.freebsd.org/changeset/base/350424

Log:
  Use present now scsi_mode_sense_subpage().
  
  MFC after:2 weeks

Modified:
  head/sbin/camcontrol/timestamp.c

Modified: head/sbin/camcontrol/timestamp.c
==
--- head/sbin/camcontrol/timestamp.cMon Jul 29 20:37:04 2019
(r350423)
+++ head/sbin/camcontrol/timestamp.cMon Jul 29 20:41:11 2019
(r350424)
@@ -79,7 +79,6 @@ set_restore_flags(struct cam_device *device, uint8_t *
int error = 0;
struct scsi_control_ext_page *control_page = NULL;
struct scsi_mode_header_10 *mode_hdr = NULL;
-   struct scsi_mode_sense_10 *cdb = NULL;
union ccb *ccb = NULL;
unsigned long mode_buf_size = sizeof(struct scsi_mode_header_10) +
sizeof(struct scsi_mode_blk_desc) +
@@ -96,25 +95,19 @@ set_restore_flags(struct cam_device *device, uint8_t *
 * Get the control extension subpage, we'll send it back modified to
 * enable SCSI control over the tape drive's timestamp
 */
-   scsi_mode_sense_len(>csio,
+   scsi_mode_sense_subpage(>csio,
/*retries*/ retry_count,
/*cbfcnp*/ NULL,
/*tag_action*/ task_attr,
/*dbd*/ 0,
/*page_control*/ SMS_PAGE_CTRL_CURRENT,
/*page*/ SCEP_PAGE_CODE,
+   /*subpage*/ SCEP_SUBPAGE_CODE,
/*param_buf*/ _buf[0],
/*param_len*/ mode_buf_size,
/*minimum_cmd_size*/ 10,
/*sense_len*/ SSD_FULL_SIZE,
/*timeout*/ timeout ? timeout : 5000);
-   /*
-* scsi_mode_sense_len does not have a subpage argument at the moment,
-* so we have to manually set the subpage code before calling
-* cam_send_ccb().
-*/
-   cdb = (struct scsi_mode_sense_10 *)ccb->csio.cdb_io.cdb_bytes;
-   cdb->subpage = SCEP_SUBPAGE_CODE;
 
ccb->ccb_h.flags |= CAM_DEV_QFRZDIS;
if (retry_count > 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: r350423 - head/lib/libarchive/tests

2019-07-29 Thread Mark Johnston
Author: markj
Date: Mon Jul 29 20:37:04 2019
New Revision: 350423
URL: https://svnweb.freebsd.org/changeset/base/350423

Log:
  Remove a duplicate file listing in the libarchive tests.
  
  MFC after:3 days

Modified:
  head/lib/libarchive/tests/Makefile

Modified: head/lib/libarchive/tests/Makefile
==
--- head/lib/libarchive/tests/Makefile  Mon Jul 29 20:31:28 2019
(r350422)
+++ head/lib/libarchive/tests/Makefile  Mon Jul 29 20:37:04 2019
(r350423)
@@ -581,7 +581,6 @@ ${PACKAGE}FILES+=   test_read_format_zip_jar.jar.uu
 ${PACKAGE}FILES+=  test_read_format_zip_length_at_end.zip.uu
 ${PACKAGE}FILES+=  test_read_format_zip_lzma_alone_leak.zipx.uu
 ${PACKAGE}FILES+=  test_read_format_zip_lzma.zipx.uu
-${PACKAGE}FILES+=  test_read_format_zip_lzma.zipx.uu
 ${PACKAGE}FILES+=  test_read_format_zip_lzma_multi.zipx.uu
 ${PACKAGE}FILES+=  test_read_format_zip_mac_metadata.zip.uu
 ${PACKAGE}FILES+=  test_read_format_zip_malformed1.zip.uu
___
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: r350422 - head/sys/arm64/arm64

2019-07-29 Thread Mark Johnston
Author: markj
Date: Mon Jul 29 20:31:28 2019
New Revision: 350422
URL: https://svnweb.freebsd.org/changeset/base/350422

Log:
  Remove an unneeded trunc_page() in pmap_fault().
  
  Reported by:  alc
  MFC with: r350004
  Sponsored by: The FreeBSD Foundation

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

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Mon Jul 29 20:26:01 2019(r350421)
+++ head/sys/arm64/arm64/pmap.c Mon Jul 29 20:31:28 2019(r350422)
@@ -5790,7 +5790,7 @@ pmap_fault(pmap_t pmap, uint64_t esr, uint64_t far)
(pmap_load(pte) & (ATTR_AP_RW_BIT | ATTR_SW_DBM)) ==
(ATTR_AP(ATTR_AP_RO) | ATTR_SW_DBM)) {
pmap_clear_bits(pte, ATTR_AP_RW_BIT);
-   pmap_invalidate_page(pmap, trunc_page(far));
+   pmap_invalidate_page(pmap, far);
rv = KERN_SUCCESS;
}
PMAP_UNLOCK(pmap);
___
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: r350421 - in head/sys: compat/freebsd32 dev/bhnd/nvram dev/drm2 fs/devfs fs/ext2fs fs/fuse kern mips/broadcom rpc

2019-07-29 Thread Mark Johnston
Author: markj
Date: Mon Jul 29 20:26:01 2019
New Revision: 350421
URL: https://svnweb.freebsd.org/changeset/base/350421

Log:
  Avoid relying on header pollution from sys/refcount.h.
  
  MFC after:3 days
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/compat/freebsd32/freebsd32_capability.c
  head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c
  head/sys/dev/bhnd/nvram/bhnd_nvram_store.c
  head/sys/dev/bhnd/nvram/bhnd_nvram_value.c
  head/sys/dev/bhnd/nvram/bhnd_nvram_value_prf.c
  head/sys/dev/drm2/drmP.h
  head/sys/fs/devfs/devfs_vnops.c
  head/sys/fs/ext2fs/ext2_vnops.c
  head/sys/fs/fuse/fuse_vnops.c
  head/sys/kern/kern_event.c
  head/sys/kern/kern_sig.c
  head/sys/kern/sys_process.c
  head/sys/kern/uipc_shm.c
  head/sys/mips/broadcom/bhnd_nexus.c
  head/sys/rpc/svc_vc.c

Modified: head/sys/compat/freebsd32/freebsd32_capability.c
==
--- head/sys/compat/freebsd32/freebsd32_capability.cMon Jul 29 19:02:16 
2019(r350420)
+++ head/sys/compat/freebsd32/freebsd32_capability.cMon Jul 29 20:26:01 
2019(r350421)
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c
==
--- head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c   Mon Jul 29 19:02:16 
2019(r350420)
+++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c   Mon Jul 29 20:26:01 
2019(r350421)
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
 #ifdef _KERNEL
 #include 
 #include 
+#include 
 #include 
 #include 
 #else /* !_KERNEL */

Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_store.c
==
--- head/sys/dev/bhnd/nvram/bhnd_nvram_store.c  Mon Jul 29 19:02:16 2019
(r350420)
+++ head/sys/dev/bhnd/nvram/bhnd_nvram_store.c  Mon Jul 29 20:26:01 2019
(r350421)
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 #include 
 
 #ifdef _KERNEL

Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_value.c
==
--- head/sys/dev/bhnd/nvram/bhnd_nvram_value.c  Mon Jul 29 19:02:16 2019
(r350420)
+++ head/sys/dev/bhnd/nvram/bhnd_nvram_value.c  Mon Jul 29 20:26:01 2019
(r350421)
@@ -31,6 +31,7 @@
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
 #include 
 
 #ifdef _KERNEL

Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_value_prf.c
==
--- head/sys/dev/bhnd/nvram/bhnd_nvram_value_prf.c  Mon Jul 29 19:02:16 
2019(r350420)
+++ head/sys/dev/bhnd/nvram/bhnd_nvram_value_prf.c  Mon Jul 29 20:26:01 
2019(r350421)
@@ -31,6 +31,7 @@
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
 #include 
 
 #ifdef _KERNEL

Modified: head/sys/dev/drm2/drmP.h
==
--- head/sys/dev/drm2/drmP.hMon Jul 29 19:02:16 2019(r350420)
+++ head/sys/dev/drm2/drmP.hMon Jul 29 20:26:01 2019(r350421)
@@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/sys/fs/devfs/devfs_vnops.c
==
--- head/sys/fs/devfs/devfs_vnops.c Mon Jul 29 19:02:16 2019
(r350420)
+++ head/sys/fs/devfs/devfs_vnops.c Mon Jul 29 20:26:01 2019
(r350421)
@@ -52,6 +52,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/sys/fs/ext2fs/ext2_vnops.c
==
--- head/sys/fs/ext2fs/ext2_vnops.c Mon Jul 29 19:02:16 2019
(r350420)
+++ head/sys/fs/ext2fs/ext2_vnops.c Mon Jul 29 20:26:01 2019
(r350421)
@@ -51,6 +51,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/sys/fs/fuse/fuse_vnops.c
==
--- head/sys/fs/fuse/fuse_vnops.c   Mon Jul 29 19:02:16 2019
(r350420)
+++ head/sys/fs/fuse/fuse_vnops.c   Mon Jul 29 20:26:01 2019
(r350421)
@@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/sys/kern/kern_event.c
==
--- head/sys/kern/kern_event.c  Mon Jul 29 19:02:16 2019(r350420)
+++ head/sys/kern/kern_event.c  Mon Jul 29 20:26:01 2019(r350421)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/sys/kern/kern_sig.c

svn commit: r350420 - in head: include lib/libc/stdio

2019-07-29 Thread Mark Johnston
Author: markj
Date: Mon Jul 29 19:02:16 2019
New Revision: 350420
URL: https://svnweb.freebsd.org/changeset/base/350420

Log:
  Add mkostempsat(3).
  
  This is a variant of mkostemps() which takes a directory descriptor and
  returns a descriptor for a tempfile relative to that directory.  Unlike
  the other mktemp functions, mkostempsat() can be used in capability
  mode.
  
  Reviewed by:  cem
  Discussed with:   brooks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D21031

Modified:
  head/include/stdlib.h
  head/lib/libc/stdio/Makefile.inc
  head/lib/libc/stdio/Symbol.map
  head/lib/libc/stdio/mktemp.3
  head/lib/libc/stdio/mktemp.c

Modified: head/include/stdlib.h
==
--- head/include/stdlib.h   Mon Jul 29 18:02:48 2019(r350419)
+++ head/include/stdlib.h   Mon Jul 29 19:02:16 2019(r350420)
@@ -297,6 +297,7 @@ int  mergesort_b(void *, size_t, size_t, int (^)(const
 #endif
 int mkostemp(char *, int);
 int mkostemps(char *, int, int);
+int mkostempsat(int, char *, int, int);
 voidqsort_r(void *, size_t, size_t, void *,
int (*)(void *, const void *, const void *));
 int radixsort(const unsigned char **, int, const unsigned char *,

Modified: head/lib/libc/stdio/Makefile.inc
==
--- head/lib/libc/stdio/Makefile.incMon Jul 29 18:02:48 2019
(r350419)
+++ head/lib/libc/stdio/Makefile.incMon Jul 29 19:02:16 2019
(r350420)
@@ -63,7 +63,7 @@ MLINKS+=getc.3 fgetc.3 getc.3 getc_unlocked.3 getc.3 g
 MLINKS+=getline.3 getdelim.3
 MLINKS+=getwc.3 fgetwc.3 getwc.3 getwchar.3
 MLINKS+=mktemp.3 mkdtemp.3 mktemp.3 mkstemp.3 mktemp.3 mkstemps.3 \
-   mktemp.3 mkostemp.3 mktemp.3 mkostemps.3
+   mktemp.3 mkostemp.3 mktemp.3 mkostemps.3 mktemp.3 mkostempsat.3
 MLINKS+=open_memstream.3 open_wmemstream.3
 MLINKS+=printf.3 asprintf.3 printf.3 dprintf.3 printf.3 fprintf.3 \
printf.3 snprintf.3 printf.3 sprintf.3 \

Modified: head/lib/libc/stdio/Symbol.map
==
--- head/lib/libc/stdio/Symbol.map  Mon Jul 29 18:02:48 2019
(r350419)
+++ head/lib/libc/stdio/Symbol.map  Mon Jul 29 19:02:16 2019
(r350420)
@@ -171,6 +171,10 @@ FBSD_1.5 {
gets_s;
 };
 
+FBSD_1.6 {
+   mkostempsat;
+};
+
 FBSDprivate_1.0 {
_flockfile;
_flockfile_debug_stub;

Modified: head/lib/libc/stdio/mktemp.3
==
--- head/lib/libc/stdio/mktemp.3Mon Jul 29 18:02:48 2019
(r350419)
+++ head/lib/libc/stdio/mktemp.3Mon Jul 29 19:02:16 2019
(r350420)
@@ -28,7 +28,7 @@
 .\" @(#)mktemp.3   8.1 (Berkeley) 6/4/93
 .\" $FreeBSD$
 .\"
-.Dd August 8, 2013
+.Dd July 29, 2019
 .Dt MKTEMP 3
 .Os
 .Sh NAME
@@ -46,6 +46,8 @@
 .Fn mkostemp "char *template" "int oflags"
 .Ft int
 .Fn mkostemps "char *template" "int suffixlen" "int oflags"
+.Ft int
+.Fn mkostempsat "int dfd" "char *template" "int suffixlen" "int oflags"
 .Ft char *
 .Fn mkdtemp "char *template"
 .In unistd.h
@@ -126,6 +128,21 @@ function
 are told the length of the suffix string.
 .Pp
 The
+.Fn mkostempsat
+function acts the same as
+.Fn mkostemps
+but takes an additional directory descriptor as a parameter.
+The temporary file is created relative to the corresponding
+directory, or to the current working directory if the special
+value
+.Dv AT_FDCWD
+is specified.
+If the template path is an absolute path, the
+.Fa dfd
+parameter is ignored and the behavior is identical to
+.Fn mkostemps .
+.Pp
+The
 .Fn mkdtemp
 function makes the same replacement to the template as in
 .Fn mktemp
@@ -262,9 +279,10 @@ and is not specified by
 .St -p1003.1-2008 .
 The
 .Fn mkostemp ,
-.Fn mkstemps
-and
+.Fn mkstemps ,
 .Fn mkostemps
+and
+.Fn mkostempsat
 functions do not conform to any standard.
 .Sh HISTORY
 A
@@ -293,6 +311,10 @@ and
 .Fn mkostemps
 functions appeared in
 .Fx 10.0 .
+The
+.Fn mkostempsat
+function appeared in
+.Fx 13.0 .
 .Sh BUGS
 This family of functions produces filenames which can be guessed,
 though the risk is minimized when large numbers of
@@ -308,10 +330,11 @@ and opening it for use
 (later in the user application)
 particularly dangerous from a security perspective.
 Whenever it is possible,
-.Fn mkstemp
-or
+.Fn mkstemp ,
 .Fn mkostemp
-should be used instead, since it does not have the race condition.
+or
+.Fn mkostempsat
+should be used instead, since they do not have the race condition.
 If
 .Fn mkstemp
 cannot be used, the filename created by

Modified: head/lib/libc/stdio/mktemp.c
==
--- head/lib/libc/stdio/mktemp.cMon Jul 29 18:02:48 2019
(r350419)
+++ 

svn commit: r350418 - in head/sys: arm64/conf conf dev/altera/dwc

2019-07-29 Thread Ruslan Bukin
Author: br
Date: Mon Jul 29 16:32:23 2019
New Revision: 350418
URL: https://svnweb.freebsd.org/changeset/base/350418

Log:
  Add glue driver for Altera SOCFPGA Ethernet MAC (EMAC) found in
  Terasic DE10-Pro (an Intel Stratix 10 GX/SX FPGA Development Kit).
  
  The Altera EMAC is an instance of Synopsys DesignWare Gigabit MAC.
  
  This driver sets correct clock range for MDIO interface on Intel Stratix 10
  platform.
  
  This is required due to lack of support for clock manager device for
  this platform that could tell us the clock frequency value for ethernet
  clock domain.
  
  Sponsored by: DARPA, AFRL

Added:
  head/sys/dev/altera/dwc/
  head/sys/dev/altera/dwc/if_dwc_socfpga.c   (contents, props changed)
Modified:
  head/sys/arm64/conf/GENERIC
  head/sys/conf/files.arm64

Modified: head/sys/arm64/conf/GENERIC
==
--- head/sys/arm64/conf/GENERIC Mon Jul 29 15:09:12 2019(r350417)
+++ head/sys/arm64/conf/GENERIC Mon Jul 29 16:32:23 2019(r350418)
@@ -162,6 +162,7 @@ device  smc # SMSC LAN91C111
 device vnic# Cavium ThunderX NIC
 device al_eth  # Annapurna Alpine Ethernet NIC
 device dwc_rk  # Rockchip Designware
+device dwc_socfpga # Altera SOCFPGA Ethernet MAC
 
 # Etherswitch devices
 device etherswitch # Enable etherswitch support

Modified: head/sys/conf/files.arm64
==
--- head/sys/conf/files.arm64   Mon Jul 29 15:09:12 2019(r350417)
+++ head/sys/conf/files.arm64   Mon Jul 29 16:32:23 2019(r350418)
@@ -206,6 +206,7 @@ dev/acpica/acpi_pci_link.c  optionalacpi pci
 dev/acpica/acpi_pcib.c optionalacpi pci
 dev/acpica/acpi_pxm.c  optionalacpi
 dev/ahci/ahci_generic.coptionalahci
+dev/altera/dwc/if_dwc_socfpga.coptionalfdt dwc_socfpga
 dev/axgbe/if_axgbe.c   optionalaxgbe
 dev/axgbe/xgbe-desc.c  optionalaxgbe
 dev/axgbe/xgbe-dev.c   optionalaxgbe

Added: head/sys/dev/altera/dwc/if_dwc_socfpga.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/altera/dwc/if_dwc_socfpga.cMon Jul 29 16:32:23 2019
(r350418)
@@ -0,0 +1,113 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019 Ruslan Bukin 
+ *
+ * This software was developed by SRI International and the University of
+ * Cambridge Computer Laboratory (Department of Computer Science and
+ * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the
+ * DARPA SSITH research programme.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "if_dwc_if.h"
+
+static int
+if_dwc_socfpga_probe(device_t dev)
+{
+
+   if (!ofw_bus_status_okay(dev))
+   return (ENXIO);
+
+   if (!ofw_bus_is_compatible(dev, "altr,socfpga-stmmac"))
+   return (ENXIO);
+
+   device_set_desc(dev, "Altera SOCFPGA Ethernet MAC");
+
+   return (BUS_PROBE_DEFAULT);
+}
+
+static int
+if_dwc_socfpga_init(device_t dev)
+{
+
+   return (0);
+}
+
+static int
+if_dwc_socfpga_mac_type(device_t dev)
+{
+
+   return (DWC_GMAC);
+}
+
+static int
+if_dwc_socfpga_mii_clk(device_t dev)
+{
+   phandle_t root;
+
+   root = OF_finddevice("/");
+
+   if (ofw_bus_node_is_compatible(root, 

svn commit: r350417 - head/sys/netpfil/ipfw

2019-07-29 Thread Andrey V. Elsukov
Author: ae
Date: Mon Jul 29 15:09:12 2019
New Revision: 350417
URL: https://svnweb.freebsd.org/changeset/base/350417

Log:
  dd ipfw_get_action() function to get the pointer to action opcode.
  
  ACTION_PTR() returns pointer to the start of rule action section,
  but rule can keep several rule modifiers like O_LOG, O_TAG and O_ALTQ,
  and only then real action opcode is stored.
  
  ipfw_get_action() function inspects the rule action section, skips
  all modifiers and returns action opcode.
  
  Use this function in ipfw_reset_eaction() and flush_nat_ptrs().
  
  MFC after:1 week
  Sponsored by: Yandex LLC

Modified:
  head/sys/netpfil/ipfw/ip_fw_eaction.c
  head/sys/netpfil/ipfw/ip_fw_nat.c
  head/sys/netpfil/ipfw/ip_fw_private.h
  head/sys/netpfil/ipfw/ip_fw_sockopt.c

Modified: head/sys/netpfil/ipfw/ip_fw_eaction.c
==
--- head/sys/netpfil/ipfw/ip_fw_eaction.c   Mon Jul 29 14:59:14 2019
(r350416)
+++ head/sys/netpfil/ipfw/ip_fw_eaction.c   Mon Jul 29 15:09:12 2019
(r350417)
@@ -377,33 +377,30 @@ ipfw_reset_eaction(struct ip_fw_chain *ch, struct ip_f
 uint16_t eaction_id, uint16_t default_id, uint16_t instance_id)
 {
ipfw_insn *cmd, *icmd;
-   int l, cmdlen;
+   int l;
 
IPFW_UH_WLOCK_ASSERT(ch);
IPFW_WLOCK_ASSERT(ch);
 
-   cmd = ACTION_PTR(rule);
-   l = rule->cmd_len - rule->act_ofs;
-   while (l > 0) {
-   cmdlen = F_LEN(cmd);
-   l -= cmdlen;
-   if (cmd->opcode == O_EXTERNAL_ACTION || l <= 0)
-   break;
-   cmd += cmdlen;
-   }
/*
 * Return if there is not O_EXTERNAL_ACTION or its id is
 * different.
 */
+   cmd = ipfw_get_action(rule);
if (cmd->opcode != O_EXTERNAL_ACTION ||
cmd->arg1 != eaction_id)
return (0);
/*
 * If instance_id is specified, we need to truncate the
 * rule length. Check if there is O_EXTERNAL_INSTANCE opcode.
+*
+* NOTE: F_LEN(cmd) must be 1 for O_EXTERNAL_ACTION opcode,
+*  and rule length should be enough to keep O_EXTERNAL_INSTANCE
+*  opcode, thus we do check for l > 1.
 */
-   if (instance_id != 0 && l > 0) {
-   MPASS(cmdlen == 1);
+   l = rule->cmd + rule->cmd_len - cmd;
+   if (instance_id != 0 && l > 1) {
+   MPASS(F_LEN(cmd) == 1);
icmd = cmd + 1;
if (icmd->opcode != O_EXTERNAL_INSTANCE ||
icmd->arg1 != instance_id)
@@ -415,8 +412,9 @@ ipfw_reset_eaction(struct ip_fw_chain *ch, struct ip_f
 * opcode.
 */
EACTION_DEBUG("truncate rule %d: len %u -> %u",
-   rule->rulenum, rule->cmd_len, rule->cmd_len - l);
-   rule->cmd_len -= l;
+   rule->rulenum, rule->cmd_len,
+   rule->cmd_len - F_LEN(icmd));
+   rule->cmd_len -= F_LEN(icmd);
MPASS(((uint32_t *)icmd -
(uint32_t *)rule->cmd) == rule->cmd_len);
}

Modified: head/sys/netpfil/ipfw/ip_fw_nat.c
==
--- head/sys/netpfil/ipfw/ip_fw_nat.c   Mon Jul 29 14:59:14 2019
(r350416)
+++ head/sys/netpfil/ipfw/ip_fw_nat.c   Mon Jul 29 15:09:12 2019
(r350417)
@@ -140,13 +140,12 @@ ifaddr_change(void *arg __unused, struct ifnet *ifp)
 static void
 flush_nat_ptrs(struct ip_fw_chain *chain, const int ix)
 {
-   int i;
ipfw_insn_nat *cmd;
+   int i;
 
IPFW_WLOCK_ASSERT(chain);
for (i = 0; i < chain->n_rules; i++) {
-   cmd = (ipfw_insn_nat *)ACTION_PTR(chain->map[i]);
-   /* XXX skip log and the like ? */
+   cmd = (ipfw_insn_nat *)ipfw_get_action(chain->map[i]);
if (cmd->o.opcode == O_NAT && cmd->nat != NULL &&
(ix < 0 || cmd->nat->id == ix))
cmd->nat = NULL;

Modified: head/sys/netpfil/ipfw/ip_fw_private.h
==
--- head/sys/netpfil/ipfw/ip_fw_private.h   Mon Jul 29 14:59:14 2019
(r350416)
+++ head/sys/netpfil/ipfw/ip_fw_private.h   Mon Jul 29 15:09:12 2019
(r350417)
@@ -665,6 +665,7 @@ struct ip_fw *ipfw_alloc_rule(struct ip_fw_chain *chai
 void ipfw_free_rule(struct ip_fw *rule);
 int ipfw_match_range(struct ip_fw *rule, ipfw_range_tlv *rt);
 int ipfw_mark_object_kidx(uint32_t *bmask, uint16_t etlv, uint16_t kidx);
+ipfw_insn *ipfw_get_action(struct ip_fw *);
 
 typedef int (sopt_handler_f)(struct ip_fw_chain *ch,
 ip_fw3_opheader *op3, struct sockopt_data *sd);

Modified: head/sys/netpfil/ipfw/ip_fw_sockopt.c
==
--- 

svn commit: r350416 - head/sys/riscv/riscv

2019-07-29 Thread Kristof Provost
Author: kp
Date: Mon Jul 29 14:59:14 2019
New Revision: 350416
URL: https://svnweb.freebsd.org/changeset/base/350416

Log:
  riscv: Fix copyin/copyout
  
  r343275 introduced a performance optimisation to the copyin/copyout
  routines by attempting to copy word-per-word rather than byte-per-byte
  where possible.
  
  This optimisation failed to account for cases where the buffer is longer
  than XLEN_BYTES, but due to misalignment does not not allow for any
  word-sized copies. E.g. a 9 byte buffer (with XLEN_BYTES == 8) which is
  misaligned by 2 bytes. The code nevertheless did a single full-word
  copy, which meant we copied too much data. This potentially clobbered
  other data.
  
  This is most easily demonstrated by a simple `sysctl -a`.
  
  Fix it by not assuming that we'll always have at least one full-word
  copy to do, but instead checking the remaining length first.
  
  Reviewed by:  markj@, mhorne@, br@ (previous version)
  MFC after:1 week
  Sponsored by: Axiado
  Differential Revision:https://reviews.freebsd.org/D21100

Modified:
  head/sys/riscv/riscv/copyinout.S

Modified: head/sys/riscv/riscv/copyinout.S
==
--- head/sys/riscv/riscv/copyinout.SMon Jul 29 14:58:29 2019
(r350415)
+++ head/sys/riscv/riscv/copyinout.SMon Jul 29 14:59:14 2019
(r350416)
@@ -65,7 +65,7 @@ END(copyio_fault)
ENTER_USER_ACCESS(a7)
 
li  t2, XLEN_BYTES
-   blt a2, t2, 3f  /* Byte-copy if len < XLEN_BYTES */
+   blt a2, t2, 4f  /* Byte-copy if len < XLEN_BYTES */
 
/*
 * Compare lower bits of src and dest.
@@ -73,7 +73,7 @@ END(copyio_fault)
 */
andit0, a0, (XLEN_BYTES-1)  /* Low bits of src */
andit1, a1, (XLEN_BYTES-1)  /* Low bits of dest */
-   bne t0, t1, 3f  /* Misaligned. Go to byte copy */
+   bne t0, t1, 4f  /* Misaligned. Go to byte copy */
beqzt0, 2f  /* Already word-aligned, skip ahead */
 
/* Byte copy until the first word-aligned address */
@@ -84,6 +84,7 @@ END(copyio_fault)
addia2, a2, -1  /* len-- */
andit0, a0, (XLEN_BYTES-1)
bnezt0, 1b
+   j   3f
 
/* Copy words */
 2: ld  a4, 0(a0)   /* Load word from src */
@@ -91,20 +92,20 @@ END(copyio_fault)
sd  a4, 0(a1)   /* Store word in dest */
addia1, a1, XLEN_BYTES
addia2, a2, -XLEN_BYTES /* len -= XLEN_BYTES */
-   bgeua2, t2, 2b  /* Again if len >= XLEN_BYTES */
+3: bgeua2, t2, 2b  /* Again if len >= XLEN_BYTES */
 
/* Check if we're finished */
-   beqza2, 4f
+   beqza2, 5f
 
/* Copy any remaining bytes */
-3: lb  a4, 0(a0)   /* Load byte from src */
+4: lb  a4, 0(a0)   /* Load byte from src */
addia0, a0, 1
sb  a4, 0(a1)   /* Store byte in dest */
addia1, a1, 1
addia2, a2, -1  /* len-- */
-   bneza2, 3b
+   bneza2, 4b
 
-4: EXIT_USER_ACCESS(a7)
+5: EXIT_USER_ACCESS(a7)
SET_FAULT_HANDLER(x0, a7)   /* Clear the handler */
.endm
 
___
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: r350415 - head/sys/dev/mii

2019-07-29 Thread Ruslan Bukin
Author: br
Date: Mon Jul 29 14:58:29 2019
New Revision: 350415
URL: https://svnweb.freebsd.org/changeset/base/350415

Log:
  Find the correct node of PHY chip using "phy-handle" property of
  ethernet MAC node.
  
  This fixes operation on Terasic DE10-Pro (Intel Stratix 10 GX/SX
  FPGA Development Kit).
  
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/dev/mii/micphy.c

Modified: head/sys/dev/mii/micphy.c
==
--- head/sys/dev/mii/micphy.c   Mon Jul 29 13:21:31 2019(r350414)
+++ head/sys/dev/mii/micphy.c   Mon Jul 29 14:58:29 2019(r350415)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2014 Ruslan Bukin 
+ * Copyright (c) 2014,2019 Ruslan Bukin 
  * All rights reserved.
  *
  * This software was developed by SRI International and the University of
@@ -32,7 +32,7 @@
 __FBSDID("$FreeBSD$");
 
 /*
- * Micrel KSZ9021 Gigabit Ethernet Transceiver
+ * Micrel KSZ8081/KSZ9021/KSZ9031 Gigabit Ethernet Transceiver
  */
 
 #include 
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #defineMII_KSZPHY_EXTREG   0x0b
 #define KSZPHY_EXTREG_WRITE(1 << 15)
@@ -251,6 +252,7 @@ micphy_probe(device_t dev)
 static int
 micphy_attach(device_t dev)
 {
+   mii_fdt_phy_config_t *cfg;
struct mii_softc *sc;
phandle_t node;
device_t miibus;
@@ -271,10 +273,12 @@ micphy_attach(device_t dev)
if ((node = ofw_bus_get_node(parent)) == -1)
return (ENXIO);
 
+   cfg = mii_fdt_get_config(dev);
+
if (sc->mii_mpd_model == MII_MODEL_MICREL_KSZ9031)
-   ksz9031_load_values(sc, node);
+   ksz9031_load_values(sc, cfg->phynode);
else
-   ksz9021_load_values(sc, node);
+   ksz9021_load_values(sc, cfg->phynode);
 
return (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: r350414 - head/sys/netpfil/pf

2019-07-29 Thread Kristof Provost
Author: kp
Date: Mon Jul 29 13:21:31 2019
New Revision: 350414
URL: https://svnweb.freebsd.org/changeset/base/350414

Log:
  pf: Remove partial RFC2675 support
  
  Remove our (very partial) support for RFC2675 Jumbograms. They're not
  used, not actually supported and not a good idea.
  
  Reviewed by:  thj@
  Differential Revision:https://reviews.freebsd.org/D21086

Modified:
  head/sys/netpfil/pf/pf.c
  head/sys/netpfil/pf/pf_norm.c

Modified: head/sys/netpfil/pf/pf.c
==
--- head/sys/netpfil/pf/pf.cMon Jul 29 12:55:48 2019(r350413)
+++ head/sys/netpfil/pf/pf.cMon Jul 29 13:21:31 2019(r350414)
@@ -6351,9 +6351,8 @@ pf_test6(int dir, int pflags, struct ifnet *ifp, struc
m = *m0;/* pf_normalize messes with m0 */
h = mtod(m, struct ip6_hdr *);
 
-#if 1
/*
-* we do not support jumbogram yet.  if we keep going, zero ip6_plen
+* we do not support jumbogram.  if we keep going, zero ip6_plen
 * will do something bad, so drop the packet for now.
 */
if (htons(h->ip6_plen) == 0) {
@@ -6361,7 +6360,6 @@ pf_test6(int dir, int pflags, struct ifnet *ifp, struc
REASON_SET(, PFRES_NORM);/*XXX*/
goto done;
}
-#endif
 
pd.src = (struct pf_addr *)>ip6_src;
pd.dst = (struct pf_addr *)>ip6_dst;

Modified: head/sys/netpfil/pf/pf_norm.c
==
--- head/sys/netpfil/pf/pf_norm.c   Mon Jul 29 12:55:48 2019
(r350413)
+++ head/sys/netpfil/pf/pf_norm.c   Mon Jul 29 13:21:31 2019
(r350414)
@@ -1139,9 +1139,8 @@ pf_normalize_ip6(struct mbuf **m0, int dir, struct pfi
int  off;
struct ip6_ext   ext;
struct ip6_opt   opt;
-   struct ip6_opt_jumbo jumbo;
struct ip6_frag  frag;
-   u_int32_tjumbolen = 0, plen;
+   u_int32_tplen;
int  optend;
int  ooff;
u_int8_t proto;
@@ -1185,6 +1184,11 @@ pf_normalize_ip6(struct mbuf **m0, int dir, struct pfi
if (sizeof(struct ip6_hdr) + IPV6_MAXPACKET < m->m_pkthdr.len)
goto drop;
 
+   plen = ntohs(h->ip6_plen);
+   /* jumbo payload option not supported */
+   if (plen == 0)
+   goto drop;
+
extoff = 0;
off = sizeof(struct ip6_hdr);
proto = h->ip6_nxt;
@@ -1228,26 +1232,8 @@ pf_normalize_ip6(struct mbuf **m0, int dir, struct pfi
goto shortpkt;
if (ooff + sizeof(opt) + opt.ip6o_len > optend)
goto drop;
-   switch (opt.ip6o_type) {
-   case IP6OPT_JUMBO:
-   if (h->ip6_plen != 0)
-   goto drop;
-   if (!pf_pull_hdr(m, ooff, ,
-   sizeof(jumbo), NULL, NULL,
-   AF_INET6))
-   goto shortpkt;
-   memcpy(, jumbo.ip6oj_jumbo_len,
-   sizeof(jumbolen));
-   jumbolen = ntohl(jumbolen);
-   if (jumbolen <= IPV6_MAXPACKET)
-   goto drop;
-   if (sizeof(struct ip6_hdr) + jumbolen !=
-   m->m_pkthdr.len)
-   goto drop;
-   break;
-   default:
-   break;
-   }
+   if (opt.ip6o_type == IP6OPT_JUMBO)
+   goto drop;
ooff += sizeof(opt) + opt.ip6o_len;
} while (ooff < optend);
 
@@ -1260,13 +1246,6 @@ pf_normalize_ip6(struct mbuf **m0, int dir, struct pfi
}
} while (!terminal);
 
-   /* jumbo payload option must be present, or plen > 0 */
-   if (ntohs(h->ip6_plen) == 0)
-   plen = jumbolen;
-   else
-   plen = ntohs(h->ip6_plen);
-   if (plen == 0)
-   goto drop;
if (sizeof(struct ip6_hdr) + plen > m->m_pkthdr.len)
goto shortpkt;
 
@@ -1275,10 +1254,6 @@ pf_normalize_ip6(struct mbuf **m0, int dir, struct pfi
return (PF_PASS);
 
  fragment:
-   /* Jumbo payload packets cannot be fragmented. */
-   plen = ntohs(h->ip6_plen);
-   if (plen == 0 || 

svn commit: r350413 - head/sys/netpfil/ipfw

2019-07-29 Thread Andrey V. Elsukov
Author: ae
Date: Mon Jul 29 12:55:48 2019
New Revision: 350413
URL: https://svnweb.freebsd.org/changeset/base/350413

Log:
  Avoid possible lock leaking.
  
  After r343619 ipfw uses own locking for packets flow. PULLUP_LEN() macro
  is used in ipfw_chk() to make m_pullup(). When m_pullup() fails, it just
  returns via `goto pullup_failed`. There are two places where PULLUP_LEN()
  is called with IPFW_PF_RLOCK() held.
  
  Add PULLUP_LEN_LOCKED() macro to use in these places to be able release
  the lock, when m_pullup() fails.
  
  Sponsored by: Yandex LLC

Modified:
  head/sys/netpfil/ipfw/ip_fw2.c

Modified: head/sys/netpfil/ipfw/ip_fw2.c
==
--- head/sys/netpfil/ipfw/ip_fw2.c  Mon Jul 29 10:44:04 2019
(r350412)
+++ head/sys/netpfil/ipfw/ip_fw2.c  Mon Jul 29 12:55:48 2019
(r350413)
@@ -1442,9 +1442,9 @@ ipfw_chk(struct ip_fw_args *args)
  * pointer might become stale after other pullups (but we never use it
  * this way).
  */
-#define PULLUP_TO(_len, p, T)  PULLUP_LEN(_len, p, sizeof(T))
+#definePULLUP_TO(_len, p, T)   PULLUP_LEN(_len, p, sizeof(T))
 #defineEHLEN   (eh != NULL ? ((char *)ip - (char *)eh) : 0)
-#define PULLUP_LEN(_len, p, T) \
+#define_PULLUP_LOCKED(_len, p, T, unlock)  \
 do {   \
int x = (_len) + T + EHLEN; \
if (mem) {  \
@@ -1453,12 +1453,18 @@ do {
\
} else {\
if (__predict_false((m)->m_len < x)) {  \
args->m = m = m_pullup(m, x);   \
-   if (m == NULL)  \
+   if (m == NULL) {\
+   unlock; \
goto pullup_failed; \
+   }   \
}   \
p = mtod(m, char *) + (_len) + EHLEN;   \
}   \
 } while (0)
+
+#definePULLUP_LEN(_len, p, T)  _PULLUP_LOCKED(_len, p, T, )
+#definePULLUP_LEN_LOCKED(_len, p, T)   \
+_PULLUP_LOCKED(_len, p, T, IPFW_PF_RUNLOCK(chain))
 /*
  * In case pointers got stale after pullups, update them.
  */
@@ -2310,7 +2316,7 @@ do {  
\
 
case O_TCPOPTS:
if (proto == IPPROTO_TCP && offset == 0 && ulp){
-   PULLUP_LEN(hlen, ulp,
+   PULLUP_LEN_LOCKED(hlen, ulp,
(TCP(ulp)->th_off << 2));
match = tcpopts_match(TCP(ulp), cmd);
}
@@ -2335,7 +2341,7 @@ do {  
\
uint16_t mss, *p;
int i;
 
-   PULLUP_LEN(hlen, ulp,
+   PULLUP_LEN_LOCKED(hlen, ulp,
(TCP(ulp)->th_off << 2));
if ((tcpopts_parse(TCP(ulp), ) &
IP_FW_TCPOPT_MSS) == 0)
@@ -3182,6 +3188,7 @@ do {  
\
 
}   /* end of inner loop, scan opcodes */
 #undef PULLUP_LEN
+#undef PULLUP_LEN_LOCKED
 
if (done)
break;
___
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: r350410 - head/sys/arm/ti/cpsw

2019-07-29 Thread Emmanuel Vadot
Author: manu
Date: Mon Jul 29 10:42:15 2019
New Revision: 350410
URL: https://svnweb.freebsd.org/changeset/base/350410

Log:
  arm: ti: cpsw: Check the new slave node address
  
  Since DTS from >= Linux 5.0 the slave address are relative to the parent
  node address and aren't the full ones.
  Check both so the cpsw driver can find the phy id.

Modified:
  head/sys/arm/ti/cpsw/if_cpsw.c

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==
--- head/sys/arm/ti/cpsw/if_cpsw.c  Mon Jul 29 10:41:21 2019
(r350409)
+++ head/sys/arm/ti/cpsw/if_cpsw.c  Mon Jul 29 10:42:15 2019
(r350410)
@@ -755,7 +755,9 @@ cpsw_get_fdt_data(struct cpsw_softc *sc, int port)
continue;
}
OF_prop_free(name);
-   if (mdio_child_addr != slave_mdio_addr[port])
+
+   if (mdio_child_addr != slave_mdio_addr[port] &&
+   mdio_child_addr != (slave_mdio_addr[port] & 0xFFF))
continue;
 
if (fdt_get_phyaddr(child, NULL, , NULL) != 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: r350408 - head/sys/arm/ti

2019-07-29 Thread Emmanuel Vadot
Author: manu
Date: Mon Jul 29 10:40:51 2019
New Revision: 350408
URL: https://svnweb.freebsd.org/changeset/base/350408

Log:
  arm: ti: Get the hwmods property either from the node or the parent
  
  r350229 changed the code to lookup the ti,hwmods property in the parent
  as it's now like that in the DTS from >= Linux 5.0, allow the property
  to be also in the node itself so we can boot with an older DTB.
  
  Reported by:  "Dr. Rolf Jansen" 

Modified:
  head/sys/arm/ti/ti_hwmods.c

Modified: head/sys/arm/ti/ti_hwmods.c
==
--- head/sys/arm/ti/ti_hwmods.c Mon Jul 29 09:34:47 2019(r350407)
+++ head/sys/arm/ti/ti_hwmods.c Mon Jul 29 10:40:51 2019(r350408)
@@ -97,6 +97,16 @@ struct hwmod ti_hwmods[] = {
{NULL,  0}
 };
 
+static inline int
+ti_get_hwmods_prop(phandle_t node, void **name)
+{
+   int len;
+
+   if ((len = OF_getprop_alloc(node, "ti,hwmods", name)) > 0)
+   return (len);
+   return (OF_getprop_alloc(OF_parent(node), "ti,hwmods", name));
+}
+
 clk_ident_t
 ti_hwmods_get_clock(device_t dev)
 {
@@ -110,7 +120,7 @@ ti_hwmods_get_clock(device_t dev)
if ((node = ofw_bus_get_node(dev)) == 0)
return (INVALID_CLK_IDENT);
 
-   if ((len = OF_getprop_alloc(OF_parent(node), "ti,hwmods", 
(void**))) <= 0)
+   if ((len = ti_get_hwmods_prop(node, (void **))) <= 0)
return (INVALID_CLK_IDENT);
 
buf = name;
@@ -148,7 +158,7 @@ int ti_hwmods_contains(device_t dev, const char *hwmod
if ((node = ofw_bus_get_node(dev)) == 0)
return (0);
 
-   if ((len = OF_getprop_alloc(OF_parent(node), "ti,hwmods", 
(void**))) <= 0)
+   if ((len = ti_get_hwmods_prop(node, (void **))) <= 0)
return (0);
 
buf = name;
@@ -182,7 +192,7 @@ ti_hwmods_get_unit(device_t dev, const char *hwmod)
if ((node = ofw_bus_get_node(dev)) == 0)
return (0);
 
-   if ((len = OF_getprop_alloc(OF_parent(node), "ti,hwmods", 
(void**))) <= 0)
+   if ((len = ti_get_hwmods_prop(node, (void **))) <= 0)
return (0);
 
buf = name;
___
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: r350404 - head/sys/netinet/cc

2019-07-29 Thread Michael Tuexen
Author: tuexen
Date: Mon Jul 29 09:19:48 2019
New Revision: 350404
URL: https://svnweb.freebsd.org/changeset/base/350404

Log:
  When performing after_idle() or post_recovery(), don't disable the
  DCTCP specific methods. Also fallthrough NewReno for non ECN capable
  TCP connections and improve the integer arithmetic.
  
  Obtained from:Richard Scheffenegger
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D20550

Modified:
  head/sys/netinet/cc/cc_dctcp.c

Modified: head/sys/netinet/cc/cc_dctcp.c
==
--- head/sys/netinet/cc/cc_dctcp.c  Mon Jul 29 08:50:35 2019
(r350403)
+++ head/sys/netinet/cc/cc_dctcp.c  Mon Jul 29 09:19:48 2019
(r350404)
@@ -123,7 +123,7 @@ dctcp_ack_received(struct cc_var *ccv, uint16_t type)
newreno_cc_algo.ack_received(ccv, type);
 
if (type == CC_DUPACK)
-   bytes_acked = CCV(ccv, t_maxseg);
+   bytes_acked = min(ccv->bytes_this_ack, CCV(ccv, 
t_maxseg));
 
if (type == CC_ACK)
bytes_acked = ccv->bytes_this_ack;
@@ -133,6 +133,8 @@ dctcp_ack_received(struct cc_var *ccv, uint16_t type)
 
/* Update total marked bytes. */
if (dctcp_data->ece_curr) {
+   //XXRMS: For fluid-model DCTCP, update
+   //cwnd here during for RTT fairness
if (!dctcp_data->ece_prev
&& bytes_acked > CCV(ccv, t_maxseg)) {
dctcp_data->bytes_ecn +=
@@ -166,18 +168,20 @@ dctcp_after_idle(struct cc_var *ccv)
 {
struct dctcp *dctcp_data;
 
-   dctcp_data = ccv->cc_data;
+   if (CCV(ccv, t_flags) & TF_ECN_PERMIT) {
+   dctcp_data = ccv->cc_data;
 
-   /* Initialize internal parameters after idle time */
-   dctcp_data->bytes_ecn = 0;
-   dctcp_data->bytes_total = 0;
-   dctcp_data->save_sndnxt = CCV(ccv, snd_nxt);
-   dctcp_data->alpha = V_dctcp_alpha;
-   dctcp_data->ece_curr = 0;
-   dctcp_data->ece_prev = 0;
-   dctcp_data->num_cong_events = 0;
+   /* Initialize internal parameters after idle time */
+   dctcp_data->bytes_ecn = 0;
+   dctcp_data->bytes_total = 0;
+   dctcp_data->save_sndnxt = CCV(ccv, snd_nxt);
+   dctcp_data->alpha = V_dctcp_alpha;
+   dctcp_data->ece_curr = 0;
+   dctcp_data->ece_prev = 0;
+   dctcp_data->num_cong_events = 0;
+   }
 
-   dctcp_cc_algo.after_idle = newreno_cc_algo.after_idle;
+   newreno_cc_algo.after_idle(ccv);
 }
 
 static void
@@ -228,63 +232,66 @@ static void
 dctcp_cong_signal(struct cc_var *ccv, uint32_t type)
 {
struct dctcp *dctcp_data;
-   u_int win, mss;
+   u_int cwin, mss;
 
-   dctcp_data = ccv->cc_data;
-   win = CCV(ccv, snd_cwnd);
-   mss = CCV(ccv, t_maxseg);
+   if (CCV(ccv, t_flags) & TF_ECN_PERMIT) {
+   dctcp_data = ccv->cc_data;
+   cwin = CCV(ccv, snd_cwnd);
+   mss = CCV(ccv, t_maxseg);
 
-   switch (type) {
-   case CC_NDUPACK:
-   if (!IN_FASTRECOVERY(CCV(ccv, t_flags))) {
+   switch (type) {
+   case CC_NDUPACK:
+   if (!IN_FASTRECOVERY(CCV(ccv, t_flags))) {
+   if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) {
+   CCV(ccv, snd_ssthresh) =
+   max(cwin / 2, 2 * mss);
+   dctcp_data->num_cong_events++;
+   } else {
+   /* cwnd has already updated as 
congestion
+* recovery. Reverse cwnd value using
+* snd_cwnd_prev and recalculate 
snd_ssthresh
+*/
+   cwin = CCV(ccv, snd_cwnd_prev);
+   CCV(ccv, snd_ssthresh) =
+   max(cwin / 2, 2 * mss);
+   }
+   ENTER_RECOVERY(CCV(ccv, t_flags));
+   }
+   break;
+   case CC_ECN:
+   /*
+* Save current snd_cwnd when the host encounters both
+* congestion recovery and fast recovery.
+*/
+   CCV(ccv, snd_cwnd_prev) = cwin;
if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) {
-   CCV(ccv, snd_ssthresh) = mss *
-   max(win / 2 / mss, 2);
-   

svn commit: r350403 - in head: share/man/man4 sys/netinet/cc

2019-07-29 Thread Michael Tuexen
Author: tuexen
Date: Mon Jul 29 08:50:35 2019
New Revision: 350403
URL: https://svnweb.freebsd.org/changeset/base/350403

Log:
  * Improve input validation of sysctl parameters for DCTPC.
  * Initialize the alpha parameter to a conservative value (like Linux)
  * Improve handling of arithmetic.
  * Improve man-page
  
  Obtained from:Richard Scheffenegger
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D20549

Modified:
  head/share/man/man4/cc_dctcp.4
  head/sys/netinet/cc/cc_dctcp.c

Modified: head/share/man/man4/cc_dctcp.4
==
--- head/share/man/man4/cc_dctcp.4  Mon Jul 29 08:23:15 2019
(r350402)
+++ head/share/man/man4/cc_dctcp.4  Mon Jul 29 08:50:35 2019
(r350403)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 12, 2015
+.Dd July 29, 2019
 .Dt CC_DCTCP 4
 .Os
 .Sh NAME
@@ -60,7 +60,7 @@ In addition, when classic ECN is used as sender and DC
 receiver, DCTCP avoids to mirror back ACKs only when the CWR flag is
 set in the incoming packet.
 .Pp
-The other specifications are based on the paper and Internet Draft referenced
+The other specifications are based on the paper and the RFC referenced
 in the
 .Sx SEE ALSO
 section below.
@@ -70,16 +70,27 @@ The algorithm exposes the following tunable variables 
 branch of the
 .Xr sysctl 3
 MIB:
-.Bl -tag -width ".Va alpha"
+.Bl -tag -width ".Va slowstart"
 .It Va alpha
-An initial estimator of the congestion on the link.
-Default is 0.
-.It Va dctcp_shift_g
-An estimation gain in the alpha calculation.
-Default is 16.
+The initial value to estimate the congestion on the link.
+The valid range is from 0 to 1024, where 1024 reduces the congestion
+window to half, if a CE is observed in the first window and
+.Va alpha
+could not yet adjust to the congestion level on that path.
+Default is 1024.
+.It Va shift_g
+An estimation gain in the
+.Va alpha
+calculation.
+This influences the responsiveness when adjusting alpha
+to the most recent observed window.
+Valid range from 0 to 10, the default is 4, resulting in an effective
+gain of 1 / ( 2 ^
+.Va shift_g
+), or 1/16th.
 .It Va slowstart
-A trigger to halve congestion window after slow start.
-Default does nothing to halve window.
+A flag if the congestion window should be reduced by one half after slow start.
+Valid settings 0 and 1, default 0.
 .El
 .Sh SEE ALSO
 .Xr cc_chd 4 ,
@@ -108,10 +119,12 @@ Default does nothing to halve window.
 .Re
 .Rs
 .%A "Stephen Bensley"
-.%A "Lars Eggert"
 .%A "Dave Thaler"
-.%T "Microsoft's Datacenter TCP (DCTCP): TCP Congestion Control for 
Datacenters"
-.%U "http://tools.ietf.org/html/draft-bensley-tcpm-dctcp-01;
+.%A "Praveen Balasubramanian"
+.%A "Lars Eggert"
+.%A "Glenn Judd"
+.%T "Data Center TCP (DCTCP): TCP Congestion Control for Data Centers"
+.%U "https://tools.ietf.org/html/rfc8257;
 .Re
 .Sh HISTORY
 The

Modified: head/sys/netinet/cc/cc_dctcp.c
==
--- head/sys/netinet/cc/cc_dctcp.c  Mon Jul 29 08:23:15 2019
(r350402)
+++ head/sys/netinet/cc/cc_dctcp.c  Mon Jul 29 08:50:35 2019
(r350403)
@@ -56,8 +56,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#define MAX_ALPHA_VALUE 1024
-VNET_DEFINE_STATIC(uint32_t, dctcp_alpha) = 0;
+#define DCTCP_SHIFT 10
+#define MAX_ALPHA_VALUE (1bytes_total, 1);
 
/*
-* Update alpha: alpha = (1 - g) * alpha + g * F.
+* Update alpha: alpha = (1 - g) * alpha + g * M.
 * Here:
 * g is weight factor
 *  recommaded to be set to 1/16
 *  small g = slow convergence between competitive DCTCP flows
 *  large g = impacts low utilization of bandwidth at switches
-* F is fraction of marked segments in last RTT
+* M is fraction of marked segments in last RTT
 *  updated every RTT
 * Alpha must be round to 0 - MAX_ALPHA_VALUE.
 */
-   dctcp_data->alpha = min(alpha_prev - (alpha_prev >> V_dctcp_shift_g) +
-   (dctcp_data->bytes_ecn << (10 - V_dctcp_shift_g)) /
+   dctcp_data->alpha = ulmin(alpha_prev - (alpha_prev >> V_dctcp_shift_g) +
+   ((uint64_t)dctcp_data->bytes_ecn << (DCTCP_SHIFT - 
V_dctcp_shift_g)) /
dctcp_data->bytes_total, MAX_ALPHA_VALUE);
 
/* Initialize internal parameters for next alpha calculation */
@@ -398,14 +399,10 @@ dctcp_alpha_handler(SYSCTL_HANDLER_ARGS)
new = V_dctcp_alpha;
error = sysctl_handle_int(oidp, , 0, req);
if (error == 0 && req->newptr != NULL) {
-   if (new > 1)
+   if (new > MAX_ALPHA_VALUE)
error = EINVAL;
-   else {
-   if (new > MAX_ALPHA_VALUE)
-   V_dctcp_alpha = MAX_ALPHA_VALUE;
-   else
-