Re: svn commit: r302985 - head/sys/geom/label

2016-07-17 Thread Andrey V. Elsukov
On 18.07.16 08:00, Maxim Sobolev wrote:
> Author: sobomax
> Date: Mon Jul 18 05:00:01 2016
> New Revision: 302985
> URL: https://svnweb.freebsd.org/changeset/base/302985
> 
> Log:
>   Relax checking if the privider size matches size recorded in the
>   superblock, allowing provider to be bit bigger, i.e. have some
>   extra padding after the FS image. That in some cases might be
>   a side-effect of using CLOOP format which enforces certain block
>   size and trying to compress image that is not exactly the number
>   of those blocks in size. The UFS itself does not have any issues
>   mounting such padded file systems, so it's what GEOM_LABEL should
>   do.

While you are thinking this is good fix, I expect that this change will
break many installations. This is not first time when this check was
changed.

-- 
WBR, Andrey V. Elsukov



signature.asc
Description: OpenPGP digital signature


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

2016-07-17 Thread Sepherosa Ziehau
Author: sephe
Date: Mon Jul 18 05:36:31 2016
New Revision: 302986
URL: https://svnweb.freebsd.org/changeset/base/302986

Log:
  hyperv/vmbus: Cosmetic vmbus channel open cleanup
  
  MFC after:1 week
  Sponsored by: Microsoft OSTC
  Differential Revision:https://reviews.freebsd.org/D7217

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

Modified: head/sys/dev/hyperv/include/hyperv.h
==
--- head/sys/dev/hyperv/include/hyperv.hMon Jul 18 05:00:01 2016
(r302985)
+++ head/sys/dev/hyperv/include/hyperv.hMon Jul 18 05:36:31 2016
(r302986)
@@ -276,15 +276,9 @@ hv_set_channel_read_state(hv_vmbus_chann
channel->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD;
 }
 
-inthv_vmbus_channel_open(
-   hv_vmbus_channel*   channel,
-   uint32_tsend_ring_buffer_size,
-   uint32_trecv_ring_buffer_size,
-   void*   user_data,
-   uint32_tuser_data_len,
-   vmbus_chan_callback_t   cb,
-   void*cbarg);
-
+inthv_vmbus_channel_open(struct hv_vmbus_channel *chan,
+   int txbr_size, int rxbr_size, const void *udata, int udlen,
+   vmbus_chan_callback_t cb, void *cbarg);
 void   hv_vmbus_channel_close(hv_vmbus_channel *channel);
 
 struct hv_vmbus_channel* vmbus_select_outgoing_channel(struct hv_vmbus_channel 
*promary);

Modified: head/sys/dev/hyperv/vmbus/hv_channel.c
==
--- head/sys/dev/hyperv/vmbus/hv_channel.c  Mon Jul 18 05:00:01 2016
(r302985)
+++ head/sys/dev/hyperv/vmbus/hv_channel.c  Mon Jul 18 05:36:31 2016
(r302986)
@@ -201,93 +201,75 @@ vmbus_chan_sysctl_create(struct hv_vmbus
}
 }
 
-/**
- * @brief Open the specified channel
- */
 int
-hv_vmbus_channel_open(
-   hv_vmbus_channel*   new_channel,
-   uint32_tsend_ring_buffer_size,
-   uint32_trecv_ring_buffer_size,
-   void*   user_data,
-   uint32_tuser_data_len,
-   vmbus_chan_callback_t   cb,
-   void*cbarg)
+hv_vmbus_channel_open(struct hv_vmbus_channel *chan,
+int txbr_size, int rxbr_size, const void *udata, int udlen,
+vmbus_chan_callback_t cb, void *cbarg)
 {
-   struct vmbus_softc *sc = new_channel->vmbus_sc;
+   struct vmbus_softc *sc = chan->vmbus_sc;
const struct vmbus_chanmsg_chopen_resp *resp;
const struct vmbus_message *msg;
struct vmbus_chanmsg_chopen *req;
struct vmbus_msghc *mh;
uint32_t status;
-   int ret = 0;
+   int error;
uint8_t *br;
 
-   if (user_data_len > VMBUS_CHANMSG_CHOPEN_UDATA_SIZE) {
+   if (udlen > VMBUS_CHANMSG_CHOPEN_UDATA_SIZE) {
device_printf(sc->vmbus_dev,
-   "invalid udata len %u for chan%u\n",
-   user_data_len, new_channel->ch_id);
+   "invalid udata len %d for chan%u\n", udlen, chan->ch_id);
return EINVAL;
}
-   KASSERT((send_ring_buffer_size & PAGE_MASK) == 0,
+   KASSERT((txbr_size & PAGE_MASK) == 0,
("send bufring size is not multiple page"));
-   KASSERT((recv_ring_buffer_size & PAGE_MASK) == 0,
+   KASSERT((rxbr_size & PAGE_MASK) == 0,
("recv bufring size is not multiple page"));
 
-   if (atomic_testandset_int(_channel->ch_stflags,
+   if (atomic_testandset_int(>ch_stflags,
VMBUS_CHAN_ST_OPENED_SHIFT))
-   panic("double-open chan%u", new_channel->ch_id);
+   panic("double-open chan%u", chan->ch_id);
 
-   new_channel->ch_cb = cb;
-   new_channel->ch_cbarg = cbarg;
+   chan->ch_cb = cb;
+   chan->ch_cbarg = cbarg;
 
-   vmbus_chan_update_evtflagcnt(sc, new_channel);
+   vmbus_chan_update_evtflagcnt(sc, chan);
 
-   new_channel->ch_tq = VMBUS_PCPU_GET(new_channel->vmbus_sc, event_tq,
-   new_channel->ch_cpuid);
-   if (new_channel->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) {
-   TASK_INIT(_channel->ch_task, 0, vmbus_chan_task,
-   new_channel);
-   } else {
-   TASK_INIT(_channel->ch_task, 0, vmbus_chan_task_nobatch,
-   new_channel);
-   }
+   chan->ch_tq = VMBUS_PCPU_GET(chan->vmbus_sc, event_tq, chan->ch_cpuid);
+   if (chan->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD)
+   TASK_INIT(>ch_task, 0, vmbus_chan_task, chan);
+   else
+  

svn commit: r302985 - head/sys/geom/label

2016-07-17 Thread Maxim Sobolev
Author: sobomax
Date: Mon Jul 18 05:00:01 2016
New Revision: 302985
URL: https://svnweb.freebsd.org/changeset/base/302985

Log:
  Relax checking if the privider size matches size recorded in the
  superblock, allowing provider to be bit bigger, i.e. have some
  extra padding after the FS image. That in some cases might be
  a side-effect of using CLOOP format which enforces certain block
  size and trying to compress image that is not exactly the number
  of those blocks in size. The UFS itself does not have any issues
  mounting such padded file systems, so it's what GEOM_LABEL should
  do.
  
  Submitted by: @mizhka_gmail.com
  Differential Revision:https://reviews.freebsd.org/D6208

Modified:
  head/sys/geom/label/g_label_ufs.c

Modified: head/sys/geom/label/g_label_ufs.c
==
--- head/sys/geom/label/g_label_ufs.c   Mon Jul 18 04:36:18 2016
(r302984)
+++ head/sys/geom/label/g_label_ufs.c   Mon Jul 18 05:00:01 2016
(r302985)
@@ -45,6 +45,15 @@ __FBSDID("$FreeBSD$");
 #defineG_LABEL_UFS_VOLUME  0
 #defineG_LABEL_UFS_ID  1
 
+/*
+ * G_LABEL_UFS_CMP returns true if difference between provider mediasize
+ * and filesystem size is less than G_LABEL_UFS_MAXDIFF sectors
+ */
+#defineG_LABEL_UFS_CMP(prov, fsys, size)   
   \
+   ( abs( ((fsys)->size) - ( (prov)->mediasize / (fsys)->fs_fsize ))  \
+   < G_LABEL_UFS_MAXDIFF )
+#defineG_LABEL_UFS_MAXDIFF 0x100
+
 static const int superblocks[] = SBLOCKSEARCH;
 
 static void
@@ -82,18 +91,35 @@ g_label_ufs_taste_common(struct g_consum
if (fs == NULL)
continue;
/*
-* Check for magic. We also need to check if file system size 
is equal
-* to providers size, because sysinstall(8) used to bogusly put 
first
-* partition at offset 0 instead of 16, and glabel/ufs would 
find file
-* system on slice instead of partition.
+* Check for magic. We also need to check if file system size
+* is almost equal to providers size, because sysinstall(8)
+* used to bogusly put first partition at offset 0
+* instead of 16, and glabel/ufs would find file system on slice
+* instead of partition.
+*
+* In addition, media size can be a bit bigger than file system
+* size. For instance, mkuzip can append bytes to align data
+* to large sector size (it improves compression rates).
 */
+   switch (fs->fs_magic){
+   case FS_UFS1_MAGIC:
+   case FS_UFS2_MAGIC:
+   G_LABEL_DEBUG(1, "%s %s params: %jd, %d, %d, %jd\n",
+   fs->fs_magic == FS_UFS1_MAGIC ? "UFS1" : "UFS2",
+   pp->name, pp->mediasize, fs->fs_fsize,
+   fs->fs_old_size, fs->fs_providersize);
+   break;
+   default:
+   break;
+   }
+
if (fs->fs_magic == FS_UFS1_MAGIC && fs->fs_fsize > 0 &&
-   ((pp->mediasize / fs->fs_fsize == fs->fs_old_size) ||
-   (pp->mediasize / fs->fs_fsize == fs->fs_providersize))) {
+   ( G_LABEL_UFS_CMP(pp, fs, fs_old_size)
+   || G_LABEL_UFS_CMP(pp, fs, fs_providersize))) {
/* Valid UFS1. */
} else if (fs->fs_magic == FS_UFS2_MAGIC && fs->fs_fsize > 0 &&
-   ((pp->mediasize / fs->fs_fsize == fs->fs_size) ||
-   (pp->mediasize / fs->fs_fsize == fs->fs_providersize))) {
+   ( G_LABEL_UFS_CMP(pp, fs, fs_size)
+   || G_LABEL_UFS_CMP(pp, fs, fs_providersize))) {
/* Valid UFS2. */
} else {
g_free(fs);
___
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: r302981 - head/sys/kern

2016-07-17 Thread Konstantin Belousov
Author: kib
Date: Mon Jul 18 04:30:34 2016
New Revision: 302981
URL: https://svnweb.freebsd.org/changeset/base/302981

Log:
  Fix another bug after r302350.
  
  Reported and tested by:   pho
  PR:   210884
  Sponsored by: The FreeBSD Foundation
  MFC after:3 days

Modified:
  head/sys/kern/kern_exit.c

Modified: head/sys/kern/kern_exit.c
==
--- head/sys/kern/kern_exit.c   Mon Jul 18 04:20:26 2016(r302980)
+++ head/sys/kern/kern_exit.c   Mon Jul 18 04:30:34 2016(r302981)
@@ -345,7 +345,7 @@ exit1(struct thread *td, int rval, int s
 * executing, prevent it from rearming itself and let it finish.
 */
if (timevalisset(>p_realtimer.it_value) &&
-   callout_stop(>p_itcallout) == 0) {
+   _callout_stop_safe(>p_itcallout, CS_EXECUTING, NULL) == 0) {
timevalclear(>p_realtimer.it_interval);
msleep(>p_itcallout, >p_mtx, PWAIT, "ritwait", 0);
KASSERT(!timevalisset(>p_realtimer.it_value),
___
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: r302980 - head/sys/vm

2016-07-17 Thread Alan Cox
Author: alc
Date: Mon Jul 18 04:20:26 2016
New Revision: 302980
URL: https://svnweb.freebsd.org/changeset/base/302980

Log:
  Break up vm_fault()'s implementation of the read-ahead and delete-behind
  optimizations into two distinct pieces.  The first piece consists of the
  code that should only be performed once per page fault and requires the map
  to be locked.  The second piece consists of the code that should be
  performed each time a pager is called on an object in the shadow chain.
  (This second piece expects the map to be unlocked.)
  
  Previously, the entire implementation could be executed multiple times.
  Moreover, the second and subsequent executions would occur with the map
  unlocked.  Usually, the ensuing unsynchronized accesses to the map were
  harmless because the map was not changing.  Nonetheless, it was possible for
  a use-after-free error to occur, where vm_fault() wrote to a freed map
  entry.  This change corrects that problem.
  
  Reported by:  avg
  Reviewed by:  kib
  MFC after:3 days
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/vm/vm_fault.c

Modified: head/sys/vm/vm_fault.c
==
--- head/sys/vm/vm_fault.c  Mon Jul 18 04:16:53 2016(r302979)
+++ head/sys/vm/vm_fault.c  Mon Jul 18 04:20:26 2016(r302980)
@@ -291,14 +291,17 @@ vm_fault_hold(vm_map_t map, vm_offset_t 
int hardfault;
struct faultstate fs;
struct vnode *vp;
+   vm_offset_t e_end, e_start;
vm_page_t m;
-   int ahead, behind, cluster_offset, error, locked;
+   int ahead, behind, cluster_offset, error, locked, rv;
+   u_char behavior;
 
hardfault = 0;
growstack = TRUE;
PCPU_INC(cnt.v_vm_faults);
fs.vp = NULL;
faultcount = 0;
+   nera = -1;
 
 RetryFault:;
 
@@ -549,29 +552,25 @@ fast_failed:
 
 readrest:
/*
-* We have either allocated a new page or found an existing
-* page that is only partially valid.
-*
-* Attempt to fault-in the page if there is a chance that the
-* pager has it, and potentially fault in additional pages
-* at the same time.
+* If the pager for the current object might have the page,
+* then determine the number of additional pages to read and
+* potentially reprioritize previously read pages for earlier
+* reclamation.  These operations should only be performed
+* once per page fault.  Even if the current pager doesn't
+* have the page, the number of additional pages to read will
+* apply to subsequent objects in the shadow chain.
 */
-   if (fs.object->type != OBJT_DEFAULT) {
-   int rv;
-   u_char behavior = vm_map_entry_behavior(fs.entry);
-
+   if (fs.object->type != OBJT_DEFAULT && nera == -1 &&
+   !P_KILLED(curproc)) {
+   KASSERT(fs.lookup_still_valid, ("map unlocked"));
era = fs.entry->read_ahead;
-   if (behavior == MAP_ENTRY_BEHAV_RANDOM ||
-   P_KILLED(curproc)) {
-   behind = 0;
+   behavior = vm_map_entry_behavior(fs.entry);
+   if (behavior == MAP_ENTRY_BEHAV_RANDOM) {
nera = 0;
-   ahead = 0;
} else if (behavior == MAP_ENTRY_BEHAV_SEQUENTIAL) {
-   behind = 0;
nera = VM_FAULT_READ_AHEAD_MAX;
-   ahead = nera;
if (vaddr == fs.entry->next_read)
-   vm_fault_dontneed(, vaddr, ahead);
+   vm_fault_dontneed(, vaddr, nera);
} else if (vaddr == fs.entry->next_read) {
/*
 * This is a sequential fault.  Arithmetically
@@ -580,42 +579,51 @@ readrest:
 * number of pages is "# of sequential faults
 * x (read ahead min + 1) + read ahead min"
 */
-   behind = 0;
nera = VM_FAULT_READ_AHEAD_MIN;
if (era > 0) {
nera += era + 1;
if (nera > VM_FAULT_READ_AHEAD_MAX)
nera = VM_FAULT_READ_AHEAD_MAX;
}
-   ahead = nera;
if (era == VM_FAULT_READ_AHEAD_MAX)
-   

svn commit: r302978 - head/sys/x86/x86

2016-07-17 Thread Maxim Sobolev
Author: sobomax
Date: Mon Jul 18 03:59:03 2016
New Revision: 302978
URL: https://svnweb.freebsd.org/changeset/base/302978

Log:
  Don't print same value twice, one in decimal once in hex. This makes
  output more cryptic than it needs to be and wastes cpu cycles and
  console bandwidth.

Modified:
  head/sys/x86/x86/mp_x86.c

Modified: head/sys/x86/x86/mp_x86.c
==
--- head/sys/x86/x86/mp_x86.c   Mon Jul 18 02:13:57 2016(r302977)
+++ head/sys/x86/x86/mp_x86.c   Mon Jul 18 03:59:03 2016(r302978)
@@ -649,12 +649,10 @@ cpu_mp_announce(void)
TOPO_FOREACH(node, _root) {
switch (node->type) {
case TOPO_TYPE_PKG:
-   printf("Package HW ID = %u (%#x)\n",
-   node->hwid, node->hwid);
+   printf("Package HW ID = %u\n", node->hwid);
break;
case TOPO_TYPE_CORE:
-   printf("\tCore HW ID = %u (%#x)\n",
-   node->hwid, node->hwid);
+   printf("\tCore HW ID = %u\n", node->hwid);
break;
case TOPO_TYPE_PU:
if (cpu_info[node->hwid].cpu_hyperthread)
@@ -663,16 +661,14 @@ cpu_mp_announce(void)
hyperthread = "";
 
if (node->subtype == 0)
-   printf("\t\tCPU (AP%s): APIC ID: %u (%#x)"
-   "(disabled)\n", hyperthread, node->hwid,
-   node->hwid);
+   printf("\t\tCPU (AP%s): APIC ID: %u"
+   "(disabled)\n", hyperthread, node->hwid);
else if (node->id == 0)
-   printf("\t\tCPU0 (BSP): APIC ID: %u (%#x)\n",
-   node->hwid, node->hwid);
-   else
-   printf("\t\tCPU%u (AP%s): APIC ID: %u (%#x)\n",
-   node->id, hyperthread, node->hwid,
+   printf("\t\tCPU0 (BSP): APIC ID: %u\n",
node->hwid);
+   else
+   printf("\t\tCPU%u (AP%s): APIC ID: %u\n",
+   node->id, hyperthread, node->hwid);
break;
default:
/* ignored */
___
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: r302977 - head/tools/build

2016-07-17 Thread Will Andrews
Author: will
Date: Mon Jul 18 02:13:57 2016
New Revision: 302977
URL: https://svnweb.freebsd.org/changeset/base/302977

Log:
  Add my beinstall script.
  
  This is meant to install a new BE (boot environment) given a fully built
  world/kernel.  In addition to installing world and kernel in the new BE,
  it also automatically performs /etc updates (using etcupdate or mergemaster)
  and package updates (using pkg).
  
  Because this process is performed in a new BE, it reduces the need for a
  second reboot.  It also means a reboot into a partially updated system (due
  to install or hardware failure) can't happen.
  
  Inspired by and similar in function to Solaris/illumos-style upgrades.

Added:
  head/tools/build/beinstall.sh   (contents, props changed)

Added: head/tools/build/beinstall.sh
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/build/beinstall.sh   Mon Jul 18 02:13:57 2016
(r302977)
@@ -0,0 +1,153 @@
+#!/bin/sh
+#
+# Copyright (c) 2016 Will Andrews
+# All rights reserved.
+#
+# 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 
+#in this position and unchanged.
+# 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 ``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 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$
+#
+##
+# Install a boot environment using the current FreeBSD source tree.
+# Requires a fully built world & kernel.
+#
+# Non-base tools required: beadm, pkg
+#
+# In a sandbox for the new boot environment, this script also runs etcupdate
+# and pkg upgrade automatically in the sandbox.  Upon successful completion,
+# the system will be ready to boot into the new boot environment.  Upon
+# failure, the target boot environment will be destroyed.  In all cases, the
+# running system is left untouched.
+#
+## Usage:
+# beinstall [optional world/kernel flags e.g. KERNCONF]
+#
+## User modifiable variables - set these in the environment if desired.
+# If not empty, 'pkg upgrade' will be skipped.
+NO_PKG_UPGRADE="${NO_PKG_UPGRADE:-""}"
+# Config updater - 'etcupdate' and 'mergemaster' are supported.  Set to an
+# empty string to skip.
+CONFIG_UPDATER="${CONFIG_UPDATER:-"etcupdate"}"
+# Flags for etcupdate if used.
+ETCUPDATE_FLAGS="${ETCUPDATE_FLAGS:-"-F"}"
+# Flags for mergemaster if used.
+MERGEMASTER_FLAGS="${MERGEMASTER_FLAGS:-"-iFU"}"
+
+
+
+## Constants
+ETCUPDATE_CMD="etcupdate"
+MERGEMASTER_CMD="mergemaster"
+
+## Functions
+cleanup() {
+   [ -z "${cleanup_commands}" ] && return
+   echo "Cleaning up ..."
+   for command in ${cleanup_commands}; do
+   ${command}
+   done
+}
+
+errx() {
+   cleanup
+   echo "error: $*"
+   exit 1
+}
+
+rmdir_be() {
+   chflags -R noschg ${BE_MNTPT}
+   rm -rf ${BE_MNTPT}
+}
+
+cleanup_be() {
+   beadm destroy -F ${BENAME}
+}
+
+update_mergemaster() {
+   mergemaster -m $(pwd) -D ${BE_MNTPT} -t ${BE_MM_ROOT} 
${MERGEMASTER_FLAGS}
+}
+
+update_etcupdate() {
+   etcupdate -s $(pwd) -D ${BE_MNTPT} ${ETCUPDATE_FLAGS} || return $?
+   etcupdate resolve -D ${BE_MNTPT}
+}
+
+
+cleanup_commands=""
+trap 'errx "Interrupt caught"' HUP INT TERM
+
+[ "$(whoami)" != "root" ] && errx "Must be run as root"
+
+[ ! -f "Makefile.inc1" ] && errx "Must be in FreeBSD source tree"
+objdir=$(make -V .OBJDIR 2>/dev/null)
+[ ! -d "${objdir}" ] && errx "Must have built FreeBSD from source tree"
+
+if [ -d .git ] ; then
+commit_time=$(git show --format='%ct' 2>/dev/null | head -1)
+[ $? -ne 0 ] && errx "Can't lookup git commit timestamp"
+commit_ts=$(date -r ${commit_time} '+%Y%m%d.%H%M%S')
+elif [ -d .svn ] ; then
+commit_ts=$( svn info | awk '/Last Changed Date/ {print $4 "." $5}' | tr 
-d :- )
+[ $? -ne 0 ] && errx "Can't lookup Subversion commit timestamp"

svn commit: r302976 - head/lib/libkvm

2016-07-17 Thread Will Andrews
Author: will
Date: Mon Jul 18 01:55:25 2016
New Revision: 302976
URL: https://svnweb.freebsd.org/changeset/base/302976

Log:
  libkvm: Improve physical address lookup scaling.
  
  Instead of using a hash table to convert physical page addresses to offsets
  in the sparse page array, cache the number of bits set for each 4MB chunk of
  physical pages.  Upon lookup, find the nearest cached population count, then
  add/subtract the number of bits from that point to the page's PTE bit.
  Then multiply by page size and add to the sparse page map's base offset.
  
  This replaces O(n) worst-case lookup with O(1) (plus a small number of bits
  to scan in the bitmap).  Also, for a 128GB system, a typical kernel core of
  about 8GB will now only require ~4.5MB of RAM for this approach instead of
  ~48MB as with the hash table.
  
  More concretely, /usr/sbin/crashinfo against the same core improves from a
  max RSS of 188MB and wall time of 43.72s (33.25 user 2.94 sys) to 135MB and
  9.43s (2.58 user 1.47 sys).  Running "thread apply all bt" in kgdb has a
  similar RSS improvement, and wall time drops from 4.44s to 1.93s.
  
  Reviewed by:  jhb
  Sponsored by: Backtrace I/O

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

Modified: head/lib/libkvm/kvm.c
==
--- head/lib/libkvm/kvm.c   Mon Jul 18 01:03:39 2016(r302975)
+++ head/lib/libkvm/kvm.c   Mon Jul 18 01:55:25 2016(r302976)
@@ -283,6 +283,8 @@ kvm_close(kvm_t *kd)
free((void *) kd->argspc);
if (kd->argv != 0)
free((void *)kd->argv);
+   if (kd->pt_map != NULL)
+   free(kd->pt_map);
free((void *)kd);
 
return (0);

Modified: head/lib/libkvm/kvm_minidump_aarch64.c
==
--- head/lib/libkvm/kvm_minidump_aarch64.c  Mon Jul 18 01:03:39 2016
(r302975)
+++ head/lib/libkvm/kvm_minidump_aarch64.c  Mon Jul 18 01:55:25 2016
(r302976)
@@ -50,7 +50,6 @@ __FBSDID("$FreeBSD$");
 
 struct vmstate {
struct minidumphdr hdr;
-   struct hpt hpt;
uint64_t *page_map;
 };
 
@@ -67,7 +66,6 @@ _aarch64_minidump_freevtop(kvm_t *kd)
 {
struct vmstate *vm = kd->vmst;
 
-   _kvm_hpt_free(>hpt);
free(vm->page_map);
free(vm);
kd->vmst = NULL;
@@ -77,8 +75,7 @@ static int
 _aarch64_minidump_initvtop(kvm_t *kd)
 {
struct vmstate *vmst;
-   uint64_t *bitmap;
-   off_t off;
+   off_t off, sparse_off;
 
vmst = _kvm_malloc(kd, sizeof(*vmst));
if (vmst == NULL) {
@@ -114,19 +111,12 @@ _aarch64_minidump_initvtop(kvm_t *kd)
/* Skip header and msgbuf */
off = AARCH64_PAGE_SIZE + aarch64_round_page(vmst->hdr.msgbufsize);
 
-   bitmap = _kvm_malloc(kd, vmst->hdr.bitmapsize);
-   if (bitmap == NULL) {
-   _kvm_err(kd, kd->program,
-   "cannot allocate %d bytes for bitmap",
-   vmst->hdr.bitmapsize);
-   return (-1);
-   }
-   if (pread(kd->pmfd, bitmap, vmst->hdr.bitmapsize, off) !=
-   (ssize_t)vmst->hdr.bitmapsize) {
-   _kvm_err(kd, kd->program,
-   "cannot read %d bytes for page bitmap",
-   vmst->hdr.bitmapsize);
-   free(bitmap);
+   /* build physical address lookup table for sparse pages */
+   sparse_off = off + aarch64_round_page(vmst->hdr.bitmapsize) +
+   aarch64_round_page(vmst->hdr.pmapsize);
+   if (_kvm_pt_init(kd, vmst->hdr.bitmapsize, off, sparse_off,
+   AARCH64_PAGE_SIZE, sizeof(uint64_t)) == -1) {
+   _kvm_err(kd, kd->program, "cannot load core bitmap");
return (-1);
}
off += aarch64_round_page(vmst->hdr.bitmapsize);
@@ -136,7 +126,6 @@ _aarch64_minidump_initvtop(kvm_t *kd)
_kvm_err(kd, kd->program,
"cannot allocate %d bytes for page_map",
vmst->hdr.pmapsize);
-   free(bitmap);
return (-1);
}
/* This is the end of the dump, savecore may have truncated it. */
@@ -149,15 +138,9 @@ _aarch64_minidump_initvtop(kvm_t *kd)
AARCH64_PAGE_SIZE) {
_kvm_err(kd, kd->program, "cannot read %d bytes for page_map",
vmst->hdr.pmapsize);
-   free(bitmap);
return (-1);
}
-   off += vmst->hdr.pmapsize;
-
-   /* build physical address hash table for sparse pages */
-   _kvm_hpt_init(kd, >hpt, bitmap, vmst->hdr.bitmapsize, off,
-   AARCH64_PAGE_SIZE, sizeof(*bitmap));
-   free(bitmap);
+  

svn commit: r302975 - head/lib/libkvm

2016-07-17 Thread Will Andrews
Author: will
Date: Mon Jul 18 01:03:39 2016
New Revision: 302975
URL: https://svnweb.freebsd.org/changeset/base/302975

Log:
  libkvm: Bounds check (more) PTE indices.

Modified:
  head/lib/libkvm/kvm_minidump_arm.c
  head/lib/libkvm/kvm_minidump_i386.c
  head/lib/libkvm/kvm_minidump_mips.c

Modified: head/lib/libkvm/kvm_minidump_arm.c
==
--- head/lib/libkvm/kvm_minidump_arm.c  Mon Jul 18 01:02:52 2016
(r302974)
+++ head/lib/libkvm/kvm_minidump_arm.c  Mon Jul 18 01:03:39 2016
(r302975)
@@ -184,6 +184,8 @@ _arm_minidump_kvatop(kvm_t *kd, kvaddr_t
 
if (va >= vm->hdr.kernbase) {
pteindex = (va - vm->hdr.kernbase) >> ARM_PAGE_SHIFT;
+   if (pteindex >= vm->hdr.ptesize / sizeof(*ptemap))
+   goto invalid;
pte = _kvm32toh(kd, ptemap[pteindex]);
if ((pte & ARM_L2_TYPE_MASK) == ARM_L2_TYPE_INV) {
_kvm_err(kd, kd->program,

Modified: head/lib/libkvm/kvm_minidump_i386.c
==
--- head/lib/libkvm/kvm_minidump_i386.c Mon Jul 18 01:02:52 2016
(r302974)
+++ head/lib/libkvm/kvm_minidump_i386.c Mon Jul 18 01:03:39 2016
(r302975)
@@ -162,6 +162,8 @@ _i386_minidump_vatop_pae(kvm_t *kd, kvad
 
if (va >= vm->hdr.kernbase) {
pteindex = (va - vm->hdr.kernbase) >> I386_PAGE_SHIFT;
+   if (pteindex >= vm->hdr.ptesize / sizeof(*ptemap))
+   goto invalid;
pte = le64toh(ptemap[pteindex]);
if ((pte & I386_PG_V) == 0) {
_kvm_err(kd, kd->program,
@@ -207,6 +209,8 @@ _i386_minidump_vatop(kvm_t *kd, kvaddr_t
 
if (va >= vm->hdr.kernbase) {
pteindex = (va - vm->hdr.kernbase) >> I386_PAGE_SHIFT;
+   if (pteindex >= vm->hdr.ptesize / sizeof(*ptemap))
+   goto invalid;
pte = le32toh(ptemap[pteindex]);
if ((pte & I386_PG_V) == 0) {
_kvm_err(kd, kd->program,

Modified: head/lib/libkvm/kvm_minidump_mips.c
==
--- head/lib/libkvm/kvm_minidump_mips.c Mon Jul 18 01:02:52 2016
(r302974)
+++ head/lib/libkvm/kvm_minidump_mips.c Mon Jul 18 01:03:39 2016
(r302975)
@@ -221,9 +221,13 @@ _mips_minidump_kvatop(kvm_t *kd, kvaddr_
if (va >= vm->hdr.kernbase) {
pteindex = (va - vm->hdr.kernbase) >> MIPS_PAGE_SHIFT;
if (vm->pte_size == 64) {
+   if (pteindex >= vm->hdr.ptesize / sizeof(*ptemap64))
+   goto invalid;
pte = _kvm64toh(kd, ptemap64[pteindex]);
a = MIPS64_PTE_TO_PA(pte);
} else {
+   if (pteindex >= vm->hdr.ptesize / sizeof(*ptemap32))
+   goto invalid;
pte = _kvm32toh(kd, ptemap32[pteindex]);
a = MIPS32_PTE_TO_PA(pte);
}
___
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: r302974 - head/lib/libkvm

2016-07-17 Thread Will Andrews
Author: will
Date: Mon Jul 18 01:02:52 2016
New Revision: 302974
URL: https://svnweb.freebsd.org/changeset/base/302974

Log:
  libkvm: Put private kvm routines in kvm_private.c.

Added:
  head/lib/libkvm/kvm_private.c   (contents, props changed)
Modified:
  head/lib/libkvm/Makefile
  head/lib/libkvm/kvm.c

Modified: head/lib/libkvm/Makefile
==
--- head/lib/libkvm/MakefileSun Jul 17 21:49:53 2016(r302973)
+++ head/lib/libkvm/MakefileMon Jul 18 01:02:52 2016(r302974)
@@ -11,7 +11,7 @@ CFLAGS+=-DLIBC_SCCS -I${.CURDIR}
 WARNS?=3
 
 SRCS=  kvm.c kvm_cptime.c kvm_getloadavg.c \
-   kvm_getswapinfo.c kvm_pcpu.c kvm_proc.c kvm_vnet.c \
+   kvm_getswapinfo.c kvm_pcpu.c kvm_private.c kvm_proc.c kvm_vnet.c \
kvm_minidump_aarch64.c \
kvm_amd64.c kvm_minidump_amd64.c \
kvm_arm.c kvm_minidump_arm.c \

Modified: head/lib/libkvm/kvm.c
==
--- head/lib/libkvm/kvm.c   Sun Jul 17 21:49:53 2016(r302973)
+++ head/lib/libkvm/kvm.c   Mon Jul 18 01:02:52 2016(r302974)
@@ -66,114 +66,12 @@ static char sccsid[] = "@(#)kvm.c  8.2 (B
 
 SET_DECLARE(kvm_arch, struct kvm_arch);
 
-/* from src/lib/libc/gen/nlist.c */
-int __fdnlist(int, struct nlist *);
-
-static int
-kvm_fdnlist(kvm_t *kd, struct kvm_nlist *list)
-{
-   kvaddr_t addr;
-   int error, nfail;
-
-   if (kd->resolve_symbol == NULL) {
-   struct nlist *nl;
-   int count, i;
-
-   for (count = 0; list[count].n_name != NULL &&
-list[count].n_name[0] != '\0'; count++)
-   ;
-   nl = calloc(count + 1, sizeof(*nl));
-   for (i = 0; i < count; i++)
-   nl[i].n_name = list[i].n_name;
-   nfail = __fdnlist(kd->nlfd, nl);
-   for (i = 0; i < count; i++) {
-   list[i].n_type = nl[i].n_type;
-   list[i].n_value = nl[i].n_value;
-   }
-   free(nl);
-   return (nfail);
-   }
-
-   nfail = 0;
-   while (list->n_name != NULL && list->n_name[0] != '\0') {
-   error = kd->resolve_symbol(list->n_name, );
-   if (error != 0) {
-   nfail++;
-   list->n_value = 0;
-   list->n_type = 0;
-   } else {
-   list->n_value = addr;
-   list->n_type = N_DATA | N_EXT;
-   }
-   list++;
-   }
-   return (nfail);
-}
-
 char *
 kvm_geterr(kvm_t *kd)
 {
return (kd->errbuf);
 }
 
-#include 
-
-/*
- * Report an error using printf style arguments.  "program" is kd->program
- * on hard errors, and 0 on soft errors, so that under sun error emulation,
- * only hard errors are printed out (otherwise, programs like gdb will
- * generate tons of error messages when trying to access bogus pointers).
- */
-void
-_kvm_err(kvm_t *kd, const char *program, const char *fmt, ...)
-{
-   va_list ap;
-
-   va_start(ap, fmt);
-   if (program != NULL) {
-   (void)fprintf(stderr, "%s: ", program);
-   (void)vfprintf(stderr, fmt, ap);
-   (void)fputc('\n', stderr);
-   } else
-   (void)vsnprintf(kd->errbuf,
-   sizeof(kd->errbuf), fmt, ap);
-
-   va_end(ap);
-}
-
-void
-_kvm_syserr(kvm_t *kd, const char *program, const char *fmt, ...)
-{
-   va_list ap;
-   int n;
-
-   va_start(ap, fmt);
-   if (program != NULL) {
-   (void)fprintf(stderr, "%s: ", program);
-   (void)vfprintf(stderr, fmt, ap);
-   (void)fprintf(stderr, ": %s\n", strerror(errno));
-   } else {
-   char *cp = kd->errbuf;
-
-   (void)vsnprintf(cp, sizeof(kd->errbuf), fmt, ap);
-   n = strlen(cp);
-   (void)snprintf([n], sizeof(kd->errbuf) - n, ": %s",
-   strerror(errno));
-   }
-   va_end(ap);
-}
-
-void *
-_kvm_malloc(kvm_t *kd, size_t n)
-{
-   void *p;
-
-   if ((p = calloc(n, sizeof(char))) == NULL)
-   _kvm_err(kd, kd->program, "can't allocate %zu bytes: %s",
-n, strerror(errno));
-   return (p);
-}
-
 static int
 _kvm_read_kernel_ehdr(kvm_t *kd)
 {
@@ -210,166 +108,6 @@ _kvm_read_kernel_ehdr(kvm_t *kd)
}
 }
 
-int
-_kvm_probe_elf_kernel(kvm_t *kd, int class, int machine)
-{
-
-   return (kd->nlehdr.e_ident[EI_CLASS] == class &&
-   kd->nlehdr.e_type == ET_EXEC &&
-   kd->nlehdr.e_machine == machine);
-}
-
-int
-_kvm_is_minidump(kvm_t *kd)
-{
-   char minihdr[8];
-
-   if (kd->rawdump)
-   return (0);
-   if (pread(kd->pmfd, , 8, 0) == 8 &&
-   memcmp(, "minidump", 8) == 0)
-   return 

svn commit: r302973 - head/usr.bin/sed

2016-07-17 Thread Pedro F. Giffuni
Author: pfg
Date: Sun Jul 17 21:49:53 2016
New Revision: 302973
URL: https://svnweb.freebsd.org/changeset/base/302973

Log:
  sed(1): Fix off by one introduced in r299211.
  
  Detected by running the gsed tests.
  
  Submitted by: Mikhail Teterin
  PR:   195929
  MFC after:3 days

Modified:
  head/usr.bin/sed/process.c

Modified: head/usr.bin/sed/process.c
==
--- head/usr.bin/sed/process.c  Sun Jul 17 20:34:46 2016(r302972)
+++ head/usr.bin/sed/process.c  Sun Jul 17 21:49:53 2016(r302973)
@@ -450,7 +450,7 @@ substitute(struct s_command *cp)
regexec_e(re, ps, REG_NOTBOL, 0, le, psl));
 
/* Did not find the requested number of matches. */
-   if (n > 1)
+   if (n > 0)
return (0);
 
/* Copy the trailing retained string. */
___
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: r302972 - head/usr.sbin/bhyve

2016-07-17 Thread Peter Grehan
Author: grehan
Date: Sun Jul 17 20:34:46 2016
New Revision: 302972
URL: https://svnweb.freebsd.org/changeset/base/302972

Log:
  Disallow interrupt requests on disabled endpoints.
  
  Submitted by: Leon Dang
  MFC after:3 days

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

Modified: head/usr.sbin/bhyve/pci_xhci.c
==
--- head/usr.sbin/bhyve/pci_xhci.c  Sun Jul 17 19:24:28 2016
(r302971)
+++ head/usr.sbin/bhyve/pci_xhci.c  Sun Jul 17 20:34:46 2016
(r302972)
@@ -2537,9 +2537,11 @@ static int
 pci_xhci_dev_intr(struct usb_hci *hci, int epctx)
 {
struct pci_xhci_dev_emu *dev;
+   struct xhci_dev_ctx *dev_ctx;
struct xhci_trb evtrb;
struct pci_xhci_softc   *sc;
struct pci_xhci_portregs *p;
+   struct xhci_endp_ctx*ep_ctx;
int error;
int dir_in;
int epid;
@@ -2578,6 +2580,14 @@ pci_xhci_dev_intr(struct usb_hci *hci, i
goto done;
}
 
+   dev_ctx = dev->dev_ctx;
+   ep_ctx = _ctx->ctx_ep[epid];
+   if ((ep_ctx->dwEpCtx0 & 0x7) == XHCI_ST_EPCTX_DISABLED) {
+   DPRINTF(("xhci device interrupt on disabled endpoint %d\r\n",
+epid));
+   return (0);
+   }
+
DPRINTF(("xhci device interrupt on endpoint %d\r\n", epid));
 
pci_xhci_device_doorbell(sc, hci->hci_port, epid, 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: r302971 - in head/sys/powerpc: booke include

2016-07-17 Thread Justin Hibbits
Author: jhibbits
Date: Sun Jul 17 19:24:28 2016
New Revision: 302971
URL: https://svnweb.freebsd.org/changeset/base/302971

Log:
  Remove booke_enable_l3_cache declaration and remaining definition.
  
  L3 cache is not defined by Book-E, so is platform specific.  Since it was
  already moved for e500-based devices into mpc85xx in r292903, just eliminate 
it
  altogether.  Any device that supports L3 cache should have its own platform
  means to enable it.

Modified:
  head/sys/powerpc/booke/machdep_ppc4xx.c
  head/sys/powerpc/include/machdep.h

Modified: head/sys/powerpc/booke/machdep_ppc4xx.c
==
--- head/sys/powerpc/booke/machdep_ppc4xx.c Sun Jul 17 19:19:50 2016
(r302970)
+++ head/sys/powerpc/booke/machdep_ppc4xx.c Sun Jul 17 19:24:28 2016
(r302971)
@@ -115,11 +115,6 @@ booke_enable_l2_cache(void)
 }
 
 void
-booke_enable_l3_cache(void)
-{
-}
-
-void
 booke_disable_l2_cache(void)
 {
uint32_t ccr1,l2cr0;

Modified: head/sys/powerpc/include/machdep.h
==
--- head/sys/powerpc/include/machdep.h  Sun Jul 17 19:19:50 2016
(r302970)
+++ head/sys/powerpc/include/machdep.h  Sun Jul 17 19:24:28 2016
(r302971)
@@ -32,7 +32,6 @@
 void booke_disable_l2_cache(void);
 void booke_enable_l1_cache(void);
 void booke_enable_l2_cache(void);
-void booke_enable_l3_cache(void);
 void booke_enable_bpred(void);
 void booke_init_tlb(vm_paddr_t);
 
___
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: r302970 - head/sys/powerpc/booke

2016-07-17 Thread Justin Hibbits
Author: jhibbits
Date: Sun Jul 17 19:19:50 2016
New Revision: 302970
URL: https://svnweb.freebsd.org/changeset/base/302970

Log:
  No need to include mpc85xx.h anymore, so remove it.

Modified:
  head/sys/powerpc/booke/booke_machdep.c

Modified: head/sys/powerpc/booke/booke_machdep.c
==
--- head/sys/powerpc/booke/booke_machdep.c  Sun Jul 17 18:33:17 2016
(r302969)
+++ head/sys/powerpc/booke/booke_machdep.c  Sun Jul 17 19:19:50 2016
(r302970)
@@ -142,10 +142,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#if defined(MPC85XX) || defined(QORIQ_DPAA)
-#include 
-#endif
-
 #ifdef DDB
 #include 
 #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: r302966 - head/sys/contrib/libnv

2016-07-17 Thread Mariusz Zaborski
Author: oshogbo
Date: Sun Jul 17 15:36:02 2016
New Revision: 302966
URL: https://svnweb.freebsd.org/changeset/base/302966

Log:
  Fix nvlist array memory leak.
  
  When we change nvl_array_next to NULL it means that we want to destroy or
  take nvlist_array. The nvpair, which stores next nvlist of nvlist_array 
element
  is no longer needed and can be freed.
  
  Submitted by: Adam Starak 
  MFC after:1 week

Modified:
  head/sys/contrib/libnv/nvlist.c

Modified: head/sys/contrib/libnv/nvlist.c
==
--- head/sys/contrib/libnv/nvlist.c Sun Jul 17 15:29:31 2016
(r302965)
+++ head/sys/contrib/libnv/nvlist.c Sun Jul 17 15:36:02 2016
(r302966)
@@ -236,10 +236,12 @@ nvlist_set_array_next(nvlist_t *nvl, nvp
 
NVLIST_ASSERT(nvl);
 
-   if (ele != NULL)
+   if (ele != NULL) {
nvl->nvl_flags |= NV_FLAG_IN_ARRAY;
-   else
+   } else {
nvl->nvl_flags &= ~NV_FLAG_IN_ARRAY;
+   nv_free(nvl->nvl_array_next);
+   }
 
nvl->nvl_array_next = ele;
 }
___
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: r302965 - head/sys/contrib/libnv

2016-07-17 Thread Mariusz Zaborski
Author: oshogbo
Date: Sun Jul 17 15:29:31 2016
New Revision: 302965
URL: https://svnweb.freebsd.org/changeset/base/302965

Log:
  Fix memory leak in the nvlist string array.
  
  Submitted by: Adam Starak 
  MFC after:1 week

Modified:
  head/sys/contrib/libnv/nvpair.c

Modified: head/sys/contrib/libnv/nvpair.c
==
--- head/sys/contrib/libnv/nvpair.c Sun Jul 17 15:23:32 2016
(r302964)
+++ head/sys/contrib/libnv/nvpair.c Sun Jul 17 15:29:31 2016
(r302965)
@@ -1945,6 +1945,7 @@ nvpair_free(nvpair_t *nvp)
case NV_TYPE_STRING_ARRAY:
for (i = 0; i < nvp->nvp_nitems; i++)
nv_free(((char **)(intptr_t)nvp->nvp_data)[i]);
+   nv_free((char **)(intptr_t)nvp->nvp_data);
break;
}
nv_free(nvp);
___
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: r302961 - head/sys/arm/nvidia

2016-07-17 Thread Michal Meloun
Author: mmel
Date: Sun Jul 17 14:45:15 2016
New Revision: 302961
URL: https://svnweb.freebsd.org/changeset/base/302961

Log:
  TEGRA: Subclass Tegra PCIE driver from ofw_pci base driver.
  Remove now redundant code.

Modified:
  head/sys/arm/nvidia/tegra_pcie.c

Modified: head/sys/arm/nvidia/tegra_pcie.c
==
--- head/sys/arm/nvidia/tegra_pcie.cSun Jul 17 14:17:58 2016
(r302960)
+++ head/sys/arm/nvidia/tegra_pcie.cSun Jul 17 14:45:15 2016
(r302961)
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -64,100 +65,13 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include "ofw_bus_if.h"
-#include "pcib_if.h"
-
 #include 
 
-/* --- Move to ofw_pci.c/.h --- */
-
-struct tegra_pci_range {
-   /* parsed phys.hi */
-   int nonrelocatable;
-   int prefetchable;
-   int aliased;
-   int space_code; /* In native format (not shifted)*/
-   int bus;
-   int device;
-   int function;
-   int reg;
-   pci_addr_t  pci_addr;   /* PCI Address */
-   bus_addr_t  host_addr;  /* Host bus address*/
-   bus_size_t  size;   /* Range size */
-};
-
-static int
-tegra_pci_get_ranges(phandle_t node,  struct tegra_pci_range **ranges)
-{
-   int host_address_cells, pci_address_cells, size_cells;
-   cell_t *base_ranges;
-   ssize_t nbase_ranges;
-   int nranges;
-   int i, j, k;
-   uint32_t flags;
-   uint64_t tmp;
-
-   host_address_cells = 1;
-   pci_address_cells = 3;
-   size_cells = 2;
-   OF_getencprop(OF_parent(node), "#address-cells", _address_cells,
-   sizeof(host_address_cells));
-   OF_getencprop(node, "#address-cells", _address_cells,
-   sizeof(pci_address_cells));
-   OF_getencprop(node, "#size-cells", _cells, sizeof(size_cells));
-
-   nbase_ranges = OF_getproplen(node, "ranges");
-   if (nbase_ranges <= 0)
-   return (-1);
-   nranges = nbase_ranges / sizeof(cell_t) /
-   (pci_address_cells + host_address_cells + size_cells);
-
-   *ranges = malloc(nranges * sizeof(struct tegra_pci_range),
-   M_DEVBUF, M_WAITOK);
-   base_ranges = malloc(nbase_ranges, M_DEVBUF, M_WAITOK);
-   OF_getencprop(node, "ranges", base_ranges, nbase_ranges);
-
-   for (i = 0, j = 0; i < nranges; i++) {
-   flags =  base_ranges[j++];
-   (*ranges)[i].nonrelocatable =
-  flags & OFW_PCI_PHYS_HI_NONRELOCATABLE ? 1 : 0;
-   (*ranges)[i].prefetchable =
-  flags & OFW_PCI_PHYS_HI_PREFETCHABLE ? 1 : 0;
-   (*ranges)[i].aliased =
-  flags & OFW_PCI_PHYS_HI_ALIASED ? 1 : 0;
-   (*ranges)[i].space_code = flags & OFW_PCI_PHYS_HI_SPACEMASK;
-   (*ranges)[i].bus = OFW_PCI_PHYS_HI_BUS(flags);
-   (*ranges)[i].device = OFW_PCI_PHYS_HI_DEVICE(flags);
-   (*ranges)[i].function = OFW_PCI_PHYS_HI_FUNCTION(flags);
-   (*ranges)[i].reg = flags & OFW_PCI_PHYS_HI_REGISTERMASK;
-
-   tmp = 0;
-   for (k = 0; k < pci_address_cells - 1; k++) {
-   tmp <<= 32;
-   tmp |= base_ranges[j++];
-   }
-   (*ranges)[i].pci_addr = (pci_addr_t)tmp;
-
-   tmp = 0;
-   for (k = 0; k < host_address_cells; k++) {
-   tmp <<= 32;
-   tmp |= base_ranges[j++];
-   }
-   (*ranges)[i].host_addr = (bus_addr_t)tmp;
-   tmp = 0;
+#include "ofw_bus_if.h"
+#include "pcib_if.h"
 
-   for (k = 0; k < size_cells; k++) {
-   tmp <<= 32;
-   tmp |= base_ranges[j++];
-   }
-   (*ranges)[i].size = (bus_size_t)tmp;
-   }
 
-   free(base_ranges, M_DEVBUF);
-   return (nranges);
-}
 
-/* -- 
*/
 #defineAFI_AXI_BAR0_SZ 0x000
 #defineAFI_AXI_BAR1_SZ 0x004
 #defineAFI_AXI_BAR2_SZ 0x008
@@ -358,12 +272,9 @@ struct tegra_pcib_port {
 
 #defineTEGRA_PCIB_MAX_PORTS3
 struct tegra_pcib_softc {
+   struct ofw_pci_softcofw_pci;
device_tdev;
struct mtx  mtx;
-   struct ofw_bus_iinfopci_iinfo;
-   struct rman pref_mem_rman;
-   struct rman mem_rman;
-   struct rman io_rman;
struct resource *pads_mem_res;
struct resource *afi_mem_res;
struct resource *cfg_mem_res;
@@ -372,18 

svn commit: r302960 - head/sys/cam/ata

2016-07-17 Thread Alexander Motin
Author: mav
Date: Sun Jul 17 14:17:58 2016
New Revision: 302960
URL: https://svnweb.freebsd.org/changeset/base/302960

Log:
  Restore PIM_ATA_EXT flag handling, lost at r300207.
  
  This re-enables NCQ TRIM usage on capable hardware (bhyve).

Modified:
  head/sys/cam/ata/ata_da.c

Modified: head/sys/cam/ata/ata_da.c
==
--- head/sys/cam/ata/ata_da.c   Sun Jul 17 14:16:21 2016(r302959)
+++ head/sys/cam/ata/ata_da.c   Sun Jul 17 14:17:58 2016(r302960)
@@ -1774,6 +1774,8 @@ adaregister(struct cam_periph *periph, v
softc->disk->d_flags |= DISKFLAG_UNMAPPED_BIO;
softc->unmappedio = 1;
}
+   if (cpi.hba_misc & PIM_ATA_EXT)
+   softc->flags |= ADA_FLAG_PIM_ATA_EXT;
strlcpy(softc->disk->d_descr, cgd->ident_data.model,
MIN(sizeof(softc->disk->d_descr), sizeof(cgd->ident_data.model)));
strlcpy(softc->disk->d_ident, cgd->ident_data.serial,
___
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: r302957 - head/usr.sbin/bhyve

2016-07-17 Thread Alexander Motin
Author: mav
Date: Sun Jul 17 14:13:47 2016
New Revision: 302957
URL: https://svnweb.freebsd.org/changeset/base/302957

Log:
  Fix NCQ TRIM emulation.
  
  When this code was written, there was no guests using it to test.

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

Modified: head/usr.sbin/bhyve/pci_ahci.c
==
--- head/usr.sbin/bhyve/pci_ahci.c  Sun Jul 17 14:12:34 2016
(r302956)
+++ head/usr.sbin/bhyve/pci_ahci.c  Sun Jul 17 14:13:47 2016
(r302957)
@@ -837,7 +837,15 @@ next:
done += 8;
if (elen == 0) {
if (done >= len) {
-   ahci_write_fis_d2h(p, slot, cfis, ATA_S_READY | 
ATA_S_DSC);
+   if (ncq) {
+   if (first)
+   ahci_write_fis_d2h_ncq(p, slot);
+   ahci_write_fis_sdb(p, slot, cfis,
+   ATA_S_READY | ATA_S_DSC);
+   } else {
+   ahci_write_fis_d2h(p, slot, cfis,
+   ATA_S_READY | ATA_S_DSC);
+   }
p->pending &= ~(1 << slot);
ahci_check_stopped(p);
if (!first)
@@ -1718,7 +1726,7 @@ ahci_handle_cmd(struct ahci_port *p, int
case ATA_SEND_FPDMA_QUEUED:
if ((cfis[13] & 0x1f) == ATA_SFPDMA_DSM &&
cfis[17] == 0 && cfis[16] == ATA_DSM_TRIM &&
-   cfis[11] == 0 && cfis[13] == 1) {
+   cfis[11] == 0 && cfis[3] == 1) {
ahci_handle_dsm_trim(p, slot, cfis, 0);
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: r302952 - head/sys/dev/ofw

2016-07-17 Thread Michal Meloun
Author: mmel
Date: Sun Jul 17 13:43:46 2016
New Revision: 302952
URL: https://svnweb.freebsd.org/changeset/base/302952

Log:
  OFWPCI: Add support for NEW_PCIB.
  
  MFC after: 3 weeks

Modified:
  head/sys/dev/ofw/ofwpci.c
  head/sys/dev/ofw/ofwpci.h

Modified: head/sys/dev/ofw/ofwpci.c
==
--- head/sys/dev/ofw/ofwpci.c   Sun Jul 17 13:43:00 2016(r302951)
+++ head/sys/dev/ofw/ofwpci.c   Sun Jul 17 13:43:46 2016(r302952)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -145,6 +146,7 @@ ofw_pci_init(device_t dev)
sc = device_get_softc(dev);
sc->sc_initialized = 1;
sc->sc_range = NULL;
+   sc->sc_pci_domain = device_get_unit(dev);
 
cell_info = (struct ofw_pci_cell_info *)malloc(sizeof(*cell_info),
M_DEVBUF, M_WAITOK | M_ZERO);
@@ -336,7 +338,7 @@ ofw_pci_read_ivar(device_t dev, device_t
 
switch (which) {
case PCIB_IVAR_DOMAIN:
-   *result = device_get_unit(dev);
+   *result = sc->sc_pci_domain;
return (0);
case PCIB_IVAR_BUS:
*result = sc->sc_bus;
@@ -409,6 +411,13 @@ ofw_pci_alloc_resource(device_t bus, dev
 
sc = device_get_softc(bus);
 
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
+   if (type ==  PCI_RES_BUS) {
+ return (pci_domain_alloc_bus(sc->sc_pci_domain, child, rid,
+ start, end, count, flags));
+   }
+#endif
+
rm = ofw_pci_get_rman(sc, type, flags);
if (rm == NULL)  {
return (bus_generic_alloc_resource(bus, child, type, rid,
@@ -447,6 +456,12 @@ ofw_pci_release_resource(device_t bus, d
 
sc = device_get_softc(bus);
 
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
+   if (type == PCI_RES_BUS)
+   return (pci_domain_release_bus(sc->sc_pci_domain, child, rid,
+   res));
+#endif
+
rm = ofw_pci_get_rman(sc, type, rman_get_flags(res));
if (rm == NULL) {
return (bus_generic_release_resource(bus, child, type, rid,
@@ -566,6 +581,11 @@ ofw_pci_adjust_resource(device_t bus, de
struct ofw_pci_softc *sc;
 
sc = device_get_softc(bus);
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
+   if (type == PCI_RES_BUS)
+   return (pci_domain_adjust_bus(sc->sc_pci_domain, child, res,
+   start, end));
+#endif
 
rm = ofw_pci_get_rman(sc, type, rman_get_flags(res));
if (rm == NULL) {

Modified: head/sys/dev/ofw/ofwpci.h
==
--- head/sys/dev/ofw/ofwpci.h   Sun Jul 17 13:43:00 2016(r302951)
+++ head/sys/dev/ofw/ofwpci.h   Sun Jul 17 13:43:46 2016(r302952)
@@ -72,6 +72,7 @@ struct ofw_pci_softc {
struct rman sc_pmem_rman;
bus_space_tag_t sc_memt;
bus_dma_tag_t   sc_dmat;
+   int sc_pci_domain;
 
struct ofw_bus_iinfosc_pci_iinfo;
 };
___
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: r302951 - head/sys/dev/ofw

2016-07-17 Thread Michal Meloun
Author: mmel
Date: Sun Jul 17 13:43:00 2016
New Revision: 302951
URL: https://svnweb.freebsd.org/changeset/base/302951

Log:
  OFWPCI: Improve resource handling.
  - add new rman for prefetchable memory. Is used only if given 'ranges'
property contains prefetchable memory range.
  
  - not all ranges in 'ranges' property are subject for rman's filling.
Tegra for example, have two addition records which are used for
'pci 'register' -> 'assigned-address' -> 'ranges' machinery.
Add sc_ranges_mask for masking not rman related ranges.
  
  - consistently pass unknown (not managed at this level) resources
allocation/release/adjust requests to parent.
  
  MFC after: 3 weeks

Modified:
  head/sys/dev/ofw/ofwpci.c
  head/sys/dev/ofw/ofwpci.h

Modified: head/sys/dev/ofw/ofwpci.c
==
--- head/sys/dev/ofw/ofwpci.c   Sun Jul 17 13:33:35 2016(r302950)
+++ head/sys/dev/ofw/ofwpci.c   Sun Jul 17 13:43:00 2016(r302951)
@@ -94,6 +94,7 @@ static phandle_t ofw_pci_get_node(device
  * local methods
  */
 static int ofw_pci_fill_ranges(phandle_t, struct ofw_pci_range *);
+static struct rman *ofw_pci_get_rman(struct ofw_pci_softc *, int, u_int);
 
 /*
  * Driver methods.
@@ -137,7 +138,7 @@ ofw_pci_init(device_t dev)
phandle_t node;
u_int32_t busrange[2];
struct ofw_pci_range *rp;
-   int error;
+   int i, error;
struct ofw_pci_cell_info *cell_info;
 
node = ofw_bus_get_node(dev);
@@ -201,17 +202,27 @@ ofw_pci_init(device_t dev)
}
 
sc->sc_mem_rman.rm_type = RMAN_ARRAY;
-   sc->sc_mem_rman.rm_descr = "PCI Memory";
+   sc->sc_mem_rman.rm_descr = "PCI Non Prefetchable Memory";
error = rman_init(>sc_mem_rman);
if (error != 0) {
device_printf(dev, "rman_init() failed. error = %d\n", error);
goto out;
}
 
-   for (rp = sc->sc_range; rp < sc->sc_range + sc->sc_nrange &&
-   rp->pci_hi != 0; rp++) {
+   sc->sc_pmem_rman.rm_type = RMAN_ARRAY;
+   sc->sc_pmem_rman.rm_descr = "PCI Prefetchable Memory";
+   error = rman_init(>sc_pmem_rman);
+   if (error != 0) {
+   device_printf(dev, "rman_init() failed. error = %d\n", error);
+   goto out;
+   }
+
+   for (i = 0; i < sc->sc_nrange; i++) {
error = 0;
+   rp = sc->sc_range + i;
 
+   if (sc->sc_range_mask & ((uint64_t)1 << i))
+   continue;
switch (rp->pci_hi & OFW_PCI_PHYS_HI_SPACEMASK) {
case OFW_PCI_PHYS_HI_SPACE_CONFIG:
break;
@@ -221,8 +232,14 @@ ofw_pci_init(device_t dev)
break;
case OFW_PCI_PHYS_HI_SPACE_MEM32:
case OFW_PCI_PHYS_HI_SPACE_MEM64:
-   error = rman_manage_region(>sc_mem_rman, rp->pci,
-   rp->pci + rp->size - 1);
+   if (rp->pci_hi & OFW_PCI_PHYS_HI_PREFETCHABLE) {
+   sc->sc_have_pmem = 1;
+   error = rman_manage_region(>sc_pmem_rman,
+   rp->pci, rp->pci + rp->size - 1);
+   } else {
+   error = rman_manage_region(>sc_mem_rman,
+   rp->pci, rp->pci + rp->size - 1);
+   }
break;
}
 
@@ -244,6 +261,7 @@ out:
free(sc->sc_range, M_DEVBUF);
rman_fini(>sc_io_rman);
rman_fini(>sc_mem_rman);
+   rman_fini(>sc_pmem_rman);
 
return (error);
 }
@@ -385,28 +403,16 @@ ofw_pci_alloc_resource(device_t bus, dev
struct rman *rm;
int needactivate;
 
+
needactivate = flags & RF_ACTIVE;
flags &= ~RF_ACTIVE;
 
sc = device_get_softc(bus);
 
-   switch (type) {
-   case SYS_RES_MEMORY:
-   rm = >sc_mem_rman;
-   break;
-
-   case SYS_RES_IOPORT:
-   rm = >sc_io_rman;
-   break;
-
-   case SYS_RES_IRQ:
-   return (bus_alloc_resource(bus, type, rid, start, end, count,
-   flags));
-
-   default:
-   device_printf(bus, "unknown resource request from %s\n",
-   device_get_nameunit(child));
-   return (NULL);
+   rm = ofw_pci_get_rman(sc, type, flags);
+   if (rm == NULL)  {
+   return (bus_generic_alloc_resource(bus, child, type, rid,
+   start, end, count, flags));
}
 
rv = rman_reserve_resource(rm, start, end, count, flags, child);
@@ -435,15 +441,24 @@ static int
 ofw_pci_release_resource(device_t bus, device_t child, int type, int rid,
 struct resource *res)
 {
+   struct ofw_pci_softc *sc;
+   struct rman *rm;
+   int error;
 
-   if (rman_get_flags(res) & 

svn commit: r302950 - head/sys/netinet

2016-07-17 Thread Michael Tuexen
Author: tuexen
Date: Sun Jul 17 13:33:35 2016
New Revision: 302950
URL: https://svnweb.freebsd.org/changeset/base/302950

Log:
  Add a constant required by RFC 7496.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_uio.h

Modified: head/sys/netinet/sctp_uio.h
==
--- head/sys/netinet/sctp_uio.h Sun Jul 17 13:14:51 2016(r302949)
+++ head/sys/netinet/sctp_uio.h Sun Jul 17 13:33:35 2016(r302950)
@@ -259,7 +259,8 @@ struct sctp_snd_all_completes {
 /* The lower four bits is an enumeration of PR-SCTP policies */
 #define SCTP_PR_SCTP_NONE 0x/* Reliable transfer */
 #define SCTP_PR_SCTP_TTL  0x0001/* Time based PR-SCTP */
-#define SCTP_PR_SCTP_BUF  0x0002/* Buffer based PR-SCTP */
+#define SCTP_PR_SCTP_PRIO 0x0002/* Buffer based PR-SCTP */
+#define SCTP_PR_SCTP_BUF  SCTP_PR_SCTP_PRIO/* For backwards compatibility 
*/
 #define SCTP_PR_SCTP_RTX  0x0003/* Number of retransmissions based PR-SCTP */
 #define SCTP_PR_SCTP_MAX  SCTP_PR_SCTP_RTX
 #define SCTP_PR_SCTP_ALL  0x000f/* Used for aggregated stats */
___
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: r302949 - head/sys/netinet

2016-07-17 Thread Michael Tuexen
Author: tuexen
Date: Sun Jul 17 13:14:51 2016
New Revision: 302949
URL: https://svnweb.freebsd.org/changeset/base/302949

Log:
  Fix the PR-SCTP behaviour.
  This is done by rrs@.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_constants.h
  head/sys/netinet/sctp_header.h
  head/sys/netinet/sctp_indata.c
  head/sys/netinet/sctp_output.c

Modified: head/sys/netinet/sctp_constants.h
==
--- head/sys/netinet/sctp_constants.h   Sun Jul 17 13:10:57 2016
(r302948)
+++ head/sys/netinet/sctp_constants.h   Sun Jul 17 13:14:51 2016
(r302949)
@@ -345,6 +345,7 @@ __FBSDID("$FreeBSD$");
 #define SCTP_RTT_FROM_NON_DATA 0
 #define SCTP_RTT_FROM_DATA 1
 
+#define PR_SCTP_UNORDERED_FLAG 0x0001
 
 /* IP hdr (20/40) + 12+2+2 (enet) + sctp common 12 */
 #define SCTP_FIRST_MBUF_RESV 68

Modified: head/sys/netinet/sctp_header.h
==
--- head/sys/netinet/sctp_header.h  Sun Jul 17 13:10:57 2016
(r302948)
+++ head/sys/netinet/sctp_header.h  Sun Jul 17 13:14:51 2016
(r302949)
@@ -397,7 +397,7 @@ struct sctp_strseq {
 
 struct sctp_strseq_mid {
uint16_t stream;
-   uint16_t reserved;
+   uint16_t flags;
uint32_t msg_id;
 };
 

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Sun Jul 17 13:10:57 2016
(r302948)
+++ head/sys/netinet/sctp_indata.c  Sun Jul 17 13:14:51 2016
(r302949)
@@ -5283,10 +5283,11 @@ sctp_kick_prsctp_reorder_queue(struct sc
}
 }
 
+
 static void
 sctp_flush_reassm_for_str_seq(struct sctp_tcb *stcb,
 struct sctp_association *asoc,
-uint16_t stream, uint32_t seq)
+uint16_t stream, uint32_t seq, int ordered, int old)
 {
struct sctp_queued_to_read *control;
struct sctp_stream_in *strm;
@@ -5301,7 +5302,7 @@ sctp_flush_reassm_for_str_seq(struct sct
 * queue.
 */
strm = >strmin[stream];
-   control = find_reasm_entry(strm, (uint32_t) seq, 0, 0);
+   control = find_reasm_entry(strm, (uint32_t) seq, ordered, old);
if (control == NULL) {
/* Not found */
return;
@@ -5433,6 +5434,7 @@ sctp_handle_forward_tsn(struct sctp_tcb 
unsigned int num_str;
uint32_t sequence;
uint16_t stream;
+   uint16_t ordered, flags;
int old;
struct sctp_strseq *stseq, strseqbuf;
struct sctp_strseq_mid *stseq_m, strseqbuf_m;
@@ -5458,6 +5460,12 @@ sctp_handle_forward_tsn(struct sctp_tcb 
}
stream = ntohs(stseq_m->stream);
sequence = ntohl(stseq_m->msg_id);
+   flags = ntohs(stseq_m->flags);
+   if (flags & PR_SCTP_UNORDERED_FLAG) {
+   ordered = 0;
+   } else {
+   ordered = 1;
+   }
} else {
stseq = (struct sctp_strseq *)sctp_m_getptr(m, 
offset,
sizeof(struct sctp_strseq),
@@ -5468,6 +5476,7 @@ sctp_handle_forward_tsn(struct sctp_tcb 
}
stream = ntohs(stseq->stream);
sequence = (uint32_t) ntohs(stseq->sequence);
+   ordered = 1;
}
/* Convert */
 
@@ -5493,7 +5502,7 @@ sctp_handle_forward_tsn(struct sctp_tcb 
asoc->fragmented_delivery_inprogress = 0;
}
strm = >strmin[stream];
-   sctp_flush_reassm_for_str_seq(stcb, asoc, stream, 
sequence);
+   sctp_flush_reassm_for_str_seq(stcb, asoc, stream, 
sequence, ordered, old);
TAILQ_FOREACH(ctl, >sctp_ep->read_queue, next) {
if ((ctl->sinfo_stream == stream) &&
(ctl->sinfo_ssn == sequence)) {

Modified: head/sys/netinet/sctp_output.c
==
--- head/sys/netinet/sctp_output.c  Sun Jul 17 13:10:57 2016
(r302948)
+++ head/sys/netinet/sctp_output.c  Sun Jul 17 13:14:51 2016
(r302949)
@@ -10383,7 +10383,7 @@ sctp_fill_in_rest:
/* no more to look at */
break;
}
-   if (at->rec.data.rcv_flags & SCTP_DATA_UNORDERED) {
+   if ((at->rec.data.rcv_flags & SCTP_DATA_UNORDERED) && 
old) {
   

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

2016-07-17 Thread Andrey A. Chernov
Author: ache
Date: Sun Jul 17 13:10:57 2016
New Revision: 302948
URL: https://svnweb.freebsd.org/changeset/base/302948

Log:
  Reflect pathnames sorting in collation order.

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

Modified: head/lib/libc/gen/glob.3
==
--- head/lib/libc/gen/glob.3Sun Jul 17 12:45:58 2016(r302947)
+++ head/lib/libc/gen/glob.3Sun Jul 17 13:10:57 2016(r302948)
@@ -194,7 +194,7 @@ If
 is set, backslash escaping is disabled.
 .It Dv GLOB_NOSORT
 By default, the pathnames are sorted in ascending
-.Tn ASCII
+collation
 order;
 this flag prevents that sorting (speeding up
 .Fn glob ) .
___
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: r302947 - head/sys/dev/ahci

2016-07-17 Thread Alexander Motin
Author: mav
Date: Sun Jul 17 12:45:58 2016
New Revision: 302947
URL: https://svnweb.freebsd.org/changeset/base/302947

Log:
  In AHCI_IRQ_MODE_AFTER mode do not clear interrupts below.
  
  This is probably a NOP change since IS register is not activery used for
  interrupts below the shared, but it looked odd to clear interrupts we did
  not handle.

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

Modified: head/sys/dev/ahci/ahci.c
==
--- head/sys/dev/ahci/ahci.cSun Jul 17 12:31:31 2016(r302946)
+++ head/sys/dev/ahci/ahci.cSun Jul 17 12:45:58 2016(r302947)
@@ -466,6 +466,7 @@ ahci_intr(void *data)
} else {/* AHCI_IRQ_MODE_AFTER */
unit = irq->r_irq_rid - 1;
is = ATA_INL(ctlr->r_mem, AHCI_IS);
+   is &= (0x << unit);
}
/* CCC interrupt is edge triggered. */
if (ctlr->ccc)
___
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: r302946 - head/sys/dev/ahci

2016-07-17 Thread Alexander Motin
Author: mav
Date: Sun Jul 17 12:31:31 2016
New Revision: 302946
URL: https://svnweb.freebsd.org/changeset/base/302946

Log:
  Do not consider the last interrupt shared if there are enough interrupts
  for all channels.

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

Modified: head/sys/dev/ahci/ahci.c
==
--- head/sys/dev/ahci/ahci.cSun Jul 17 11:43:27 2016(r302945)
+++ head/sys/dev/ahci/ahci.cSun Jul 17 12:31:31 2016(r302946)
@@ -416,7 +416,8 @@ ahci_setup_interrupt(device_t dev)
else if (ctlr->numirqs == 1 || i >= ctlr->channels ||
(ctlr->ccc && i == ctlr->cccv))
ctlr->irqs[i].mode = AHCI_IRQ_MODE_ALL;
-   else if (i == ctlr->numirqs - 1)
+   else if (ctlr->channels > ctlr->numirqs &&
+   i == ctlr->numirqs - 1)
ctlr->irqs[i].mode = AHCI_IRQ_MODE_AFTER;
else
ctlr->irqs[i].mode = AHCI_IRQ_MODE_ONE;
___
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: r302945 - head/usr.bin/netstat

2016-07-17 Thread Michael Tuexen
Author: tuexen
Date: Sun Jul 17 11:43:27 2016
New Revision: 302945
URL: https://svnweb.freebsd.org/changeset/base/302945

Log:
  Don't duplicate code for SCTP, just use the ones used for UDP and TCP.
  
  This fixes a bug with link local addresses. This will require and
  upcoming change in the kernel to bring SCTP to the same behaviour
  as UDP and TCP.
  
  MFC after:3 days

Modified:
  head/usr.bin/netstat/sctp.c

Modified: head/usr.bin/netstat/sctp.c
==
--- head/usr.bin/netstat/sctp.c Sun Jul 17 11:25:24 2016(r302944)
+++ head/usr.bin/netstat/sctp.c Sun Jul 17 11:43:27 2016(r302945)
@@ -104,93 +104,14 @@ struct xraddr_entry {
LIST_ENTRY(xraddr_entry) xraddr_entries;
 };
 
-/*
- * Construct an Internet address representation.
- * If numeric_addr has been supplied, give
- * numeric value, otherwise try for symbolic name.
- */
 #ifdef INET
-static char *
-inetname(struct in_addr *inp)
-{
-   char *cp;
-   static char line[MAXHOSTNAMELEN];
-   struct hostent *hp;
-   struct netent *np;
-
-   cp = 0;
-   if (!numeric_addr && inp->s_addr != INADDR_ANY) {
-   int net = inet_netof(*inp);
-   int lna = inet_lnaof(*inp);
-
-   if (lna == INADDR_ANY) {
-   np = getnetbyaddr(net, AF_INET);
-   if (np)
-   cp = np->n_name;
-   }
-   if (cp == NULL) {
-   hp = gethostbyaddr((char *)inp, sizeof (*inp), AF_INET);
-   if (hp) {
-   cp = hp->h_name;
-   trimdomain(cp, strlen(cp));
-   }
-   }
-   }
-   if (inp->s_addr == INADDR_ANY)
-   strcpy(line, "*");
-   else if (cp) {
-   strlcpy(line, cp, sizeof(line));
-   } else {
-   inp->s_addr = ntohl(inp->s_addr);
-#defineC(x)((u_int)((x) & 0xff))
-   sprintf(line, "%u.%u.%u.%u", C(inp->s_addr >> 24),
-   C(inp->s_addr >> 16), C(inp->s_addr >> 8), C(inp->s_addr));
-   inp->s_addr = htonl(inp->s_addr);
-   }
-   return (line);
-}
+char *
+inetname(struct in_addr *inp);
 #endif
 
 #ifdef INET6
-static char ntop_buf[INET6_ADDRSTRLEN];
-
-static char *
-inet6name(struct in6_addr *in6p)
-{
-   char *cp;
-   static char line[50];
-   struct hostent *hp;
-   static char domain[MAXHOSTNAMELEN];
-   static int first = 1;
-
-   if (first && !numeric_addr) {
-   first = 0;
-   if (gethostname(domain, MAXHOSTNAMELEN) == 0 &&
-   (cp = strchr(domain, '.')))
-   (void) strcpy(domain, cp + 1);
-   else
-   domain[0] = 0;
-   }
-   cp = 0;
-   if (!numeric_addr && !IN6_IS_ADDR_UNSPECIFIED(in6p)) {
-   hp = gethostbyaddr((char *)in6p, sizeof(*in6p), AF_INET6);
-   if (hp) {
-   if ((cp = strchr(hp->h_name, '.')) &&
-   !strcmp(cp + 1, domain))
-   *cp = 0;
-   cp = hp->h_name;
-   }
-   }
-   if (IN6_IS_ADDR_UNSPECIFIED(in6p))
-   strcpy(line, "*");
-   else if (cp)
-   strcpy(line, cp);
-   else
-   sprintf(line, "%s",
-   inet_ntop(AF_INET6, (void *)in6p, ntop_buf,
-   sizeof(ntop_buf)));
-   return (line);
-}
+char *
+inet6name(struct in6_addr *in6p);
 #endif
 
 static void
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2016-07-17 Thread Andrey A. Chernov
Author: ache
Date: Sun Jul 17 11:25:24 2016
New Revision: 302944
URL: https://svnweb.freebsd.org/changeset/base/302944

Log:
  In g_Ctoc() apply CHAR() macro to *str to strip all flags. It gains nothing
  right now, but some architectures theoretically may 64-bit wchar_t and the
  code looks more correct.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cSun Jul 17 09:39:59 2016(r302943)
+++ head/lib/libc/gen/glob.cSun Jul 17 11:25:24 2016(r302944)
@@ -979,14 +979,14 @@ g_Ctoc(const Char *str, char *buf, size_
 
memset(, 0, sizeof(mbs));
while (len >= MB_CUR_MAX) {
-   clen = wcrtomb(buf, *str, );
+   clen = wcrtomb(buf, CHAR(*str), );
if (clen == (size_t)-1) {
/* XXX See initial comment #2. */
-   *buf = (char)*str;
+   *buf = (char)CHAR(*str);
clen = 1;
memset(, 0, sizeof(mbs));
}
-   if (*buf == '\0')
+   if (CHAR(*str) == EOS)
return (0);
str++;
buf += clen;
___
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: r302943 - head/lib/libc/gen

2016-07-17 Thread Andrey A. Chernov
Author: ache
Date: Sun Jul 17 09:39:59 2016
New Revision: 302943
URL: https://svnweb.freebsd.org/changeset/base/302943

Log:
  1) This file full of direct char <-> wchar_t assignment, not converted, cut
  them down. This hack still remains:
   * 2. Illegal byte sequences in filenames are handled by treating them as
   *single-byte characters with a values of such bytes of the sequence
   *cast to wchar_t.
  
  2) Reword the comment in the hack above to reflect implementation.
  
  3) Protect signed wchar_t from sign extension when a signed char is assigned
  to it in the hack above.
  
  3) Corresponding backward hack in g_Ctoc() was not implemented, so all
  pathes with illegal byte sequences are skipped as result, implement it now.
  
  4) globtilde() forget to convert expanded user home dir from multibyte to
  wchar.
  
  5) Protect globtilde() from long expansion truncation.
  
  6) Results was not sorted according to collate as POSIX requires.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cSun Jul 17 08:31:21 2016(r302942)
+++ head/lib/libc/gen/glob.cSun Jul 17 09:39:59 2016(r302943)
@@ -71,7 +71,7 @@ __FBSDID("$FreeBSD$");
  * 1. Patterns with illegal byte sequences match nothing - even if
  *GLOB_NOCHECK is specified.
  * 2. Illegal byte sequences in filenames are handled by treating them as
- *single-byte characters with a value of the first byte of the sequence
+ *single-byte characters with a values of such bytes of the sequence
  *cast to wchar_t.
  * 3. State-dependent encodings are not currently supported.
  */
@@ -113,23 +113,21 @@ struct glob_limit {
size_t  l_string_cnt;
 };
 
-#defineDOLLAR  '$'
-#defineDOT '.'
-#defineEOS '\0'
-#defineLBRACKET'['
-#defineNOT '!'
-#defineQUESTION'?'
-#defineQUOTE   '\\'
-#defineRANGE   '-'
-#defineRBRACKET']'
-#defineSEP '/'
-#defineSTAR'*'
-#defineTILDE   '~'
-#defineUNDERSCORE  '_'
-#defineLBRACE  '{'
-#defineRBRACE  '}'
-#defineSLASH   '/'
-#defineCOMMA   ','
+#defineDOT L'.'
+#defineEOS L'\0'
+#defineLBRACKETL'['
+#defineNOT L'!'
+#defineQUESTIONL'?'
+#defineQUOTE   L'\\'
+#defineRANGE   L'-'
+#defineRBRACKETL']'
+#defineSEP L'/'
+#defineSTARL'*'
+#defineTILDE   L'~'
+#defineLBRACE  L'{'
+#defineRBRACE  L'}'
+#defineSLASH   L'/'
+#defineCOMMA   L','
 
 #ifndef DEBUG
 
@@ -154,12 +152,12 @@ typedef char Char;
 
 #defineCHAR(c) ((Char)((c)_CHAR))
 #defineMETA(c) ((Char)((c)|M_QUOTE))
-#defineM_ALL   META('*')
-#defineM_END   META(']')
-#defineM_NOT   META('!')
-#defineM_ONE   META('?')
-#defineM_RNG   META('-')
-#defineM_SET   META('[')
+#defineM_ALL   META(L'*')
+#defineM_END   META(L']')
+#defineM_NOT   META(L'!')
+#defineM_ONE   META(L'?')
+#defineM_RNG   META(L'-')
+#defineM_SET   META(L'[')
 #defineismeta(c)   (((c)_QUOTE) != 0)
 
 
@@ -233,8 +231,8 @@ glob(const char * __restrict pattern, in
/* Protect the quoted characters. */
memset(, 0, sizeof(mbs));
while (bufend - bufnext >= MB_CUR_MAX) {
-   if (*patnext == QUOTE) {
-   if (*++patnext == EOS) {
+   if (*patnext == '\\') {
+   if (*++patnext == '\0') {
*bufnext++ = QUOTE | M_PROTECT;
continue;
}
@@ -401,9 +399,15 @@ static const Char *
 globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob)
 {
struct passwd *pwd;
-   char *h;
+   char *h, *sc;
const Char *p;
Char *b, *eb;
+   wchar_t wc;
+   wchar_t wbuf[MAXPATHLEN];
+   wchar_t *wbufend, *dc;
+   size_t clen;
+   mbstate_t mbs;
+   int too_long;
 
if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE))
return (pattern);
@@ -412,13 +416,17 @@ globtilde(const Char *pattern, Char *pat
 * Copy up to the end of the string or / 
 */
eb = [patbuf_len - 1];
-   for (p = pattern + 1, h = (char *) patbuf;
-

svn commit: r302942 - head/sys/netinet

2016-07-17 Thread Michael Tuexen
Author: tuexen
Date: Sun Jul 17 08:31:21 2016
New Revision: 302942
URL: https://svnweb.freebsd.org/changeset/base/302942

Log:
  Add missing sctps_reasmusrmsgs counter.
  Joint work with rrs@.
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_indata.c

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Sat Jul 16 19:35:04 2016
(r302941)
+++ head/sys/netinet/sctp_indata.c  Sun Jul 17 08:31:21 2016
(r302942)
@@ -823,6 +823,7 @@ restart:
if (control->on_strm_q) {
TAILQ_REMOVE(>uno_inqueue, 
control, next_instrm);
control->on_strm_q = 0;
+   
SCTP_STAT_INCR_COUNTER64(sctps_reasmusrmsgs);
}
if (control->on_read_q == 0) {
sctp_add_to_readq(stcb->sctp_ep, stcb, 
control,
@@ -1028,6 +1029,7 @@ sctp_deliver_reasm_check(struct sctp_tcb
control, control->on_strm_q);
}
 #endif
+   SCTP_STAT_INCR_COUNTER64(sctps_reasmusrmsgs);
TAILQ_REMOVE(>uno_inqueue, control, 
next_instrm);
control->on_strm_q = 0;
}
@@ -1082,6 +1084,7 @@ done_un:
control, control->on_strm_q);
}
 #endif
+   SCTP_STAT_INCR_COUNTER64(sctps_reasmusrmsgs);
TAILQ_REMOVE(>inqueue, control, 
next_instrm);
control->on_strm_q = 0;
}
@@ -1127,6 +1130,7 @@ deliver_more:
control, 
control->on_strm_q);
}
 #endif
+   
SCTP_STAT_INCR_COUNTER64(sctps_reasmusrmsgs);
TAILQ_REMOVE(>inqueue, control, 
next_instrm);
control->on_strm_q = 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"