svn commit: r302881 - head/sys/dev/hyperv/vmbus

2016-07-15 Thread Sepherosa Ziehau
Author: sephe
Date: Fri Jul 15 07:07:17 2016
New Revision: 302881
URL: https://svnweb.freebsd.org/changeset/base/302881

Log:
  hyperv/vmbus: Cleanup channel sending
  
  MFC after:1 week
  Sponsored by: Microsoft OSTC
  Differential Revision:https://reviews.freebsd.org/D7178

Modified:
  head/sys/dev/hyperv/vmbus/hv_channel.c

Modified: head/sys/dev/hyperv/vmbus/hv_channel.c
==
--- head/sys/dev/hyperv/vmbus/hv_channel.c  Fri Jul 15 06:58:21 2016
(r302880)
+++ head/sys/dev/hyperv/vmbus/hv_channel.c  Fri Jul 15 07:07:17 2016
(r302881)
@@ -621,55 +621,37 @@ hv_vmbus_channel_close(struct hv_vmbus_c
hv_vmbus_channel_close_internal(chan);
 }
 
-/**
- * @brief Send the specified buffer on the given channel
- */
 int
-hv_vmbus_channel_send_packet(
-   hv_vmbus_channel*   channel,
-   void*   buffer,
-   uint32_tbuffer_len,
-   uint64_trequest_id,
-   uint16_ttype,
-   uint16_tflags)
+hv_vmbus_channel_send_packet(struct hv_vmbus_channel *chan,
+void *data, uint32_t dlen, uint64_t xactid, uint16_t type, uint16_t flags)
 {
-   int ret = 0;
struct vmbus_chanpkt pkt;
-   uint32_tpacket_len;
-   uint64_taligned_data;
-   uint32_tpacket_len_aligned;
-   boolean_t   need_sig;
-   struct ioveciov[3];
-
-   packet_len = sizeof(pkt) + buffer_len;
-   packet_len_aligned = roundup2(packet_len, VMBUS_CHANPKT_SIZE_ALIGN);
-   aligned_data = 0;
+   int pktlen, pad_pktlen, hlen, error;
+   uint64_t pad = 0;
+   struct iovec iov[3];
+   boolean_t send_evt;
+
+   hlen = sizeof(pkt);
+   pktlen = hlen + dlen;
+   pad_pktlen = roundup2(pktlen, VMBUS_CHANPKT_SIZE_ALIGN);
 
-   /*
-* Setup channel packet.
-*/
pkt.cp_hdr.cph_type = type;
pkt.cp_hdr.cph_flags = flags;
-   pkt.cp_hdr.cph_data_ofs = sizeof(pkt) >> VMBUS_CHANPKT_SIZE_SHIFT;
-   pkt.cp_hdr.cph_len = packet_len_aligned >> VMBUS_CHANPKT_SIZE_SHIFT;
-   pkt.cp_hdr.cph_xactid = request_id;
+   pkt.cp_hdr.cph_data_ofs = hlen >> VMBUS_CHANPKT_SIZE_SHIFT;
+   pkt.cp_hdr.cph_len = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT;
+   pkt.cp_hdr.cph_xactid = xactid;
 
iov[0].iov_base = &pkt;
-   iov[0].iov_len = sizeof(pkt);
-
-   iov[1].iov_base = buffer;
-   iov[1].iov_len = buffer_len;
+   iov[0].iov_len = hlen;
+   iov[1].iov_base = data;
+   iov[1].iov_len = dlen;
+   iov[2].iov_base = &pad;
+   iov[2].iov_len = pad_pktlen - pktlen;
 
-   iov[2].iov_base = &aligned_data;
-   iov[2].iov_len = packet_len_aligned - packet_len;
-
-   ret = hv_ring_buffer_write(&channel->outbound, iov, 3, &need_sig);
-
-   /* TODO: We should determine if this is optional */
-   if (ret == 0 && need_sig)
-   vmbus_chan_send_event(channel);
-
-   return (ret);
+   error = hv_ring_buffer_write(&chan->outbound, iov, 3, &send_evt);
+   if (!error && send_evt)
+   vmbus_chan_send_event(chan);
+   return error;
 }
 
 int
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302882 - in head/sys/dev/hyperv: include netvsc storvsc utilities vmbus

2016-07-15 Thread Sepherosa Ziehau
Author: sephe
Date: Fri Jul 15 07:16:46 2016
New Revision: 302882
URL: https://svnweb.freebsd.org/changeset/base/302882

Log:
  hyperv/vmbus: Function rename
  
  And reorder the error prone parameters list.
  
  MFC after:1 week
  Sponsored by: Microsoft OSTC
  Differential Revision:https://reviews.freebsd.org/D7191

Modified:
  head/sys/dev/hyperv/include/hyperv.h
  head/sys/dev/hyperv/include/vmbus.h
  head/sys/dev/hyperv/netvsc/hv_net_vsc.c
  head/sys/dev/hyperv/netvsc/hv_rndis_filter.c
  head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
  head/sys/dev/hyperv/utilities/hv_heartbeat.c
  head/sys/dev/hyperv/utilities/hv_kvp.c
  head/sys/dev/hyperv/utilities/hv_shutdown.c
  head/sys/dev/hyperv/utilities/hv_timesync.c
  head/sys/dev/hyperv/vmbus/hv_channel.c

Modified: head/sys/dev/hyperv/include/hyperv.h
==
--- head/sys/dev/hyperv/include/hyperv.hFri Jul 15 07:07:17 2016
(r302881)
+++ head/sys/dev/hyperv/include/hyperv.hFri Jul 15 07:16:46 2016
(r302882)
@@ -323,14 +323,6 @@ inthv_vmbus_channel_open(
 
 void   hv_vmbus_channel_close(hv_vmbus_channel *channel);
 
-inthv_vmbus_channel_send_packet(
-   hv_vmbus_channel*   channel,
-   void*   buffer,
-   uint32_tbuffer_len,
-   uint64_trequest_id,
-   uint16_ttype,
-   uint16_tflags);
-
 inthv_vmbus_channel_establish_gpadl(
hv_vmbus_channel*   channel,
/* must be phys and virt contiguous */

Modified: head/sys/dev/hyperv/include/vmbus.h
==
--- head/sys/dev/hyperv/include/vmbus.h Fri Jul 15 07:07:17 2016
(r302881)
+++ head/sys/dev/hyperv/include/vmbus.h Fri Jul 15 07:16:46 2016
(r302882)
@@ -59,6 +59,8 @@ struct vmbus_gpa {
 
 struct hv_vmbus_channel;
 
+intvmbus_chan_send(struct hv_vmbus_channel *chan, uint16_t type,
+   uint16_t flags, void *data, int dlen, uint64_t xactid);
 intvmbus_chan_send_sglist(struct hv_vmbus_channel *chan,
struct vmbus_gpa sg[], int sglen, void *data, int dlen,
uint64_t xactid);

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.c
==
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Jul 15 07:07:17 2016
(r302881)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Jul 15 07:16:46 2016
(r302882)
@@ -183,9 +183,9 @@ hv_nv_init_rx_buffer_with_net_vsp(struct
 
/* Send the gpadl notification request */
 
-   ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt,
-   sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt,
-   VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC);
+   ret = vmbus_chan_send(sc->hn_prichan,
+   VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC,
+   init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt);
if (ret != 0) {
goto cleanup;
}
@@ -276,9 +276,9 @@ hv_nv_init_send_buffer_with_net_vsp(stru
 
/* Send the gpadl notification request */
 
-   ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt,
-   sizeof(nvsp_msg), (uint64_t)init_pkt,
-   VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC);
+   ret = vmbus_chan_send(sc->hn_prichan,
+   VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC,
+   init_pkt, sizeof(nvsp_msg), (uint64_t)init_pkt);
if (ret != 0) {
goto cleanup;
}
@@ -335,10 +335,9 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_
revoke_pkt->msgs.vers_1_msgs.revoke_rx_buf.id =
NETVSC_RECEIVE_BUFFER_ID;
 
-   ret = hv_vmbus_channel_send_packet(net_dev->sc->hn_prichan,
-   revoke_pkt, sizeof(nvsp_msg),
-   (uint64_t)(uintptr_t)revoke_pkt,
-   VMBUS_CHANPKT_TYPE_INBAND, 0);
+   ret = vmbus_chan_send(net_dev->sc->hn_prichan,
+   VMBUS_CHANPKT_TYPE_INBAND, 0, revoke_pkt, sizeof(nvsp_msg),
+   (uint64_t)(uintptr_t)revoke_pkt);
 
/*
 * If we failed here, we might as well return and have a leak 
@@ -403,10 +402,10 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne
revoke_pkt->msgs.vers_1_msgs.revoke_send_buf.id =
NETVSC_SEND_BUFFER_ID;
 
-   ret = hv_vmbus_channel_send_packet(net_dev->sc->hn_prichan,
+   ret = vmbus_chan_send(net_dev->sc->hn_prichan,
+   VMBUS_CHANPKT_TYPE_INBAND, 0,
revoke_pkt, 

svn commit: r302883 - head/sys/dev/hyperv/vmbus

2016-07-15 Thread Sepherosa Ziehau
Author: sephe
Date: Fri Jul 15 07:26:31 2016
New Revision: 302883
URL: https://svnweb.freebsd.org/changeset/base/302883

Log:
  hyperv/vmbus: Field rename
  
  MFC after:1 week
  Sponsored by: Microsoft OSTC
  Differential Revision:https://reviews.freebsd.org/D7193

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

Modified: head/sys/dev/hyperv/vmbus/hv_channel.c
==
--- head/sys/dev/hyperv/vmbus/hv_channel.c  Fri Jul 15 07:16:46 2016
(r302882)
+++ head/sys/dev/hyperv/vmbus/hv_channel.c  Fri Jul 15 07:26:31 2016
(r302883)
@@ -637,8 +637,8 @@ vmbus_chan_send(struct hv_vmbus_channel 
 
pkt.cp_hdr.cph_type = type;
pkt.cp_hdr.cph_flags = flags;
-   pkt.cp_hdr.cph_data_ofs = hlen >> VMBUS_CHANPKT_SIZE_SHIFT;
-   pkt.cp_hdr.cph_len = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT;
+   pkt.cp_hdr.cph_hlen = hlen >> VMBUS_CHANPKT_SIZE_SHIFT;
+   pkt.cp_hdr.cph_tlen = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT;
pkt.cp_hdr.cph_xactid = xactid;
 
iov[0].iov_base = &pkt;
@@ -673,8 +673,8 @@ vmbus_chan_send_sglist(struct hv_vmbus_c
 
pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA;
pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC;
-   pkt.cp_hdr.cph_data_ofs = hlen >> VMBUS_CHANPKT_SIZE_SHIFT;
-   pkt.cp_hdr.cph_len = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT;
+   pkt.cp_hdr.cph_hlen = hlen >> VMBUS_CHANPKT_SIZE_SHIFT;
+   pkt.cp_hdr.cph_tlen = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT;
pkt.cp_hdr.cph_xactid = xactid;
pkt.cp_rsvd = 0;
pkt.cp_gpa_cnt = sglen;
@@ -715,8 +715,8 @@ vmbus_chan_send_prplist(struct hv_vmbus_
 
pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA;
pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC;
-   pkt.cp_hdr.cph_data_ofs = hlen >> VMBUS_CHANPKT_SIZE_SHIFT;
-   pkt.cp_hdr.cph_len = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT;
+   pkt.cp_hdr.cph_hlen = hlen >> VMBUS_CHANPKT_SIZE_SHIFT;
+   pkt.cp_hdr.cph_tlen = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT;
pkt.cp_hdr.cph_xactid = xactid;
pkt.cp_rsvd = 0;
pkt.cp_range_cnt = 1;

Modified: head/sys/dev/hyperv/vmbus/vmbus_reg.h
==
--- head/sys/dev/hyperv/vmbus/vmbus_reg.h   Fri Jul 15 07:16:46 2016
(r302882)
+++ head/sys/dev/hyperv/vmbus/vmbus_reg.h   Fri Jul 15 07:26:31 2016
(r302883)
@@ -117,8 +117,8 @@ CTASSERT(sizeof(struct vmbus_mnf) == PAG
 
 struct vmbus_chanpkt_hdr {
uint16_tcph_type;
-   uint16_tcph_data_ofs;   /* in 8 bytes */
-   uint16_tcph_len;/* in 8 bytes */
+   uint16_tcph_hlen;   /* header len, in 8 bytes */
+   uint16_tcph_tlen;   /* total len, in 8 bytes */
uint16_tcph_flags;
uint64_tcph_xactid;
 } __packed;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302884 - head/sys/dev/hyperv/vmbus

2016-07-15 Thread Sepherosa Ziehau
Author: sephe
Date: Fri Jul 15 07:35:01 2016
New Revision: 302884
URL: https://svnweb.freebsd.org/changeset/base/302884

Log:
  hyperv/vmbus: Factor out macros to do channel packet length conversion.
  
  MFC after:1 week
  Sponsored by: Microsoft OSTC
  Differential Revision:https://reviews.freebsd.org/D7194

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

Modified: head/sys/dev/hyperv/vmbus/hv_channel.c
==
--- head/sys/dev/hyperv/vmbus/hv_channel.c  Fri Jul 15 07:26:31 2016
(r302883)
+++ head/sys/dev/hyperv/vmbus/hv_channel.c  Fri Jul 15 07:35:01 2016
(r302884)
@@ -633,12 +633,12 @@ vmbus_chan_send(struct hv_vmbus_channel 
 
hlen = sizeof(pkt);
pktlen = hlen + dlen;
-   pad_pktlen = roundup2(pktlen, VMBUS_CHANPKT_SIZE_ALIGN);
+   pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen);
 
pkt.cp_hdr.cph_type = type;
pkt.cp_hdr.cph_flags = flags;
-   pkt.cp_hdr.cph_hlen = hlen >> VMBUS_CHANPKT_SIZE_SHIFT;
-   pkt.cp_hdr.cph_tlen = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT;
+   VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_hlen, hlen);
+   VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_tlen, pad_pktlen);
pkt.cp_hdr.cph_xactid = xactid;
 
iov[0].iov_base = &pkt;
@@ -669,12 +669,12 @@ vmbus_chan_send_sglist(struct hv_vmbus_c
 
hlen = __offsetof(struct vmbus_chanpkt_sglist, cp_gpa[sglen]);
pktlen = hlen + dlen;
-   pad_pktlen = roundup2(pktlen, VMBUS_CHANPKT_SIZE_ALIGN);
+   pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen);
 
pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA;
pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC;
-   pkt.cp_hdr.cph_hlen = hlen >> VMBUS_CHANPKT_SIZE_SHIFT;
-   pkt.cp_hdr.cph_tlen = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT;
+   VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_hlen, hlen);
+   VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_tlen, pad_pktlen);
pkt.cp_hdr.cph_xactid = xactid;
pkt.cp_rsvd = 0;
pkt.cp_gpa_cnt = sglen;
@@ -711,12 +711,12 @@ vmbus_chan_send_prplist(struct hv_vmbus_
hlen = __offsetof(struct vmbus_chanpkt_prplist,
cp_range[0].gpa_page[prp_cnt]);
pktlen = hlen + dlen;
-   pad_pktlen = roundup2(pktlen, VMBUS_CHANPKT_SIZE_ALIGN);
+   pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen);
 
pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA;
pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC;
-   pkt.cp_hdr.cph_hlen = hlen >> VMBUS_CHANPKT_SIZE_SHIFT;
-   pkt.cp_hdr.cph_tlen = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT;
+   VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_hlen, hlen);
+   VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_tlen, pad_pktlen);
pkt.cp_hdr.cph_xactid = xactid;
pkt.cp_rsvd = 0;
pkt.cp_range_cnt = 1;

Modified: head/sys/dev/hyperv/vmbus/vmbus_reg.h
==
--- head/sys/dev/hyperv/vmbus/vmbus_reg.h   Fri Jul 15 07:26:31 2016
(r302883)
+++ head/sys/dev/hyperv/vmbus/vmbus_reg.h   Fri Jul 15 07:35:01 2016
(r302884)
@@ -115,6 +115,14 @@ CTASSERT(sizeof(struct vmbus_mnf) == PAG
 #define VMBUS_CHANPKT_SIZE_SHIFT   3
 #define VMBUS_CHANPKT_SIZE_ALIGN   (1 << VMBUS_CHANPKT_SIZE_SHIFT)
 
+#define VMBUS_CHANPKT_SETLEN(pktlen, len)  \
+do {   \
+   (pktlen) = (len) >> VMBUS_CHANPKT_SIZE_SHIFT;   \
+} while (0)
+
+#define VMBUS_CHANPKT_TOTLEN(tlen) \
+   roundup2((tlen), VMBUS_CHANPKT_SIZE_ALIGN)
+
 struct vmbus_chanpkt_hdr {
uint16_tcph_type;
uint16_tcph_hlen;   /* header len, in 8 bytes */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302885 - in head/sys/dev/hyperv: include storvsc utilities vmbus

2016-07-15 Thread Sepherosa Ziehau
Author: sephe
Date: Fri Jul 15 07:45:30 2016
New Revision: 302885
URL: https://svnweb.freebsd.org/changeset/base/302885

Log:
  hyperv/vmbus: Cleanup channel receiving.
  
  MFC after:1 week
  Sponsored by: Microsoft OSTC
  Differential Revision:https://reviews.freebsd.org/D7202

Modified:
  head/sys/dev/hyperv/include/hyperv.h
  head/sys/dev/hyperv/include/vmbus.h
  head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
  head/sys/dev/hyperv/utilities/hv_heartbeat.c
  head/sys/dev/hyperv/utilities/hv_kvp.c
  head/sys/dev/hyperv/utilities/hv_shutdown.c
  head/sys/dev/hyperv/utilities/hv_timesync.c
  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.hFri Jul 15 07:35:01 2016
(r302884)
+++ head/sys/dev/hyperv/include/hyperv.hFri Jul 15 07:45:30 2016
(r302885)
@@ -298,13 +298,6 @@ hv_set_channel_read_state(hv_vmbus_chann
channel->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD;
 }
 
-inthv_vmbus_channel_recv_packet(
-   hv_vmbus_channel*   channel,
-   void*   buffer,
-   uint32_tbuffer_len,
-   uint32_t*   buffer_actual_len,
-   uint64_t*   request_id);
-
 inthv_vmbus_channel_recv_packet_raw(
hv_vmbus_channel*   channel,
void*   buffer,

Modified: head/sys/dev/hyperv/include/vmbus.h
==
--- head/sys/dev/hyperv/include/vmbus.h Fri Jul 15 07:35:01 2016
(r302884)
+++ head/sys/dev/hyperv/include/vmbus.h Fri Jul 15 07:45:30 2016
(r302885)
@@ -59,6 +59,9 @@ struct vmbus_gpa {
 
 struct hv_vmbus_channel;
 
+intvmbus_chan_recv(struct hv_vmbus_channel *chan, void *data, int *dlen,
+   uint64_t *xactid);
+
 intvmbus_chan_send(struct hv_vmbus_channel *chan, uint16_t type,
uint16_t flags, void *data, int dlen, uint64_t xactid);
 intvmbus_chan_send_sglist(struct hv_vmbus_channel *chan,

Modified: head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.cFri Jul 15 
07:35:01 2016(r302884)
+++ head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.cFri Jul 15 
07:45:30 2016(r302885)
@@ -778,12 +778,10 @@ hv_storvsc_on_channel_callback(void *xch
struct hv_storvsc_request *request;
struct vstor_packet *vstor_packet;
 
-   ret = hv_vmbus_channel_recv_packet(
-   channel,
-   packet,
-   roundup2(VSTOR_PKT_SIZE, 8),
-   &bytes_recvd,
-   &request_id);
+   bytes_recvd = roundup2(VSTOR_PKT_SIZE, 8);
+   ret = vmbus_chan_recv(channel, packet, &bytes_recvd, &request_id);
+   KASSERT(ret != ENOBUFS, ("storvsc recvbuf is not large enough"));
+   /* XXX check bytes_recvd to make sure that it contains enough data */
 
while ((ret == 0) && (bytes_recvd > 0)) {
request = (struct hv_storvsc_request *)(uintptr_t)request_id;
@@ -817,12 +815,16 @@ hv_storvsc_on_channel_callback(void *xch
break;
}   
}
-   ret = hv_vmbus_channel_recv_packet(
-   channel,
-   packet,
-   roundup2(VSTOR_PKT_SIZE, 8),
-   &bytes_recvd,
-   &request_id);
+
+   bytes_recvd = roundup2(VSTOR_PKT_SIZE, 8),
+   ret = vmbus_chan_recv(channel, packet, &bytes_recvd,
+   &request_id);
+   KASSERT(ret != ENOBUFS,
+   ("storvsc recvbuf is not large enough"));
+   /*
+* XXX check bytes_recvd to make sure that it contains
+* enough data
+*/
}
 }
 

Modified: head/sys/dev/hyperv/utilities/hv_heartbeat.c
==
--- head/sys/dev/hyperv/utilities/hv_heartbeat.cFri Jul 15 07:35:01 
2016(r302884)
+++ head/sys/dev/hyperv/utilities/hv_heartbeat.cFri Jul 15 07:45:30 
2016(r302885)
@@ -52,7 +52,7 @@ hv_heartbeat_cb(void *context)
 {
uint8_t*buf;
hv_vmbus_channel*   channel;
-   uint32_trecvlen;
+   int recvlen;
uint64_trequestid;
 

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

2016-07-15 Thread Sepherosa Ziehau
Author: sephe
Date: Fri Jul 15 07:53:45 2016
New Revision: 302886
URL: https://svnweb.freebsd.org/changeset/base/302886

Log:
  hyperv/vmbus: Cleanup channel packet receiving.
  
  MFC after:1 week
  Sponsored by: Microsoft OSTC
  Differential Revision:https://reviews.freebsd.org/D7204

Modified:
  head/sys/dev/hyperv/include/hyperv.h
  head/sys/dev/hyperv/include/vmbus.h
  head/sys/dev/hyperv/netvsc/hv_net_vsc.c
  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.hFri Jul 15 07:45:30 2016
(r302885)
+++ head/sys/dev/hyperv/include/hyperv.hFri Jul 15 07:53:45 2016
(r302886)
@@ -90,28 +90,6 @@ struct hyperv_guid {
 
 inthyperv_guid2str(const struct hyperv_guid *, char *, size_t);
 
-typedef struct {
-   uint16_t type;
-   uint16_t data_offset8;
-   uint16_t length8;
-   uint16_t flags;
-   uint64_t transaction_id;
-} __packed hv_vm_packet_descriptor;
-
-typedef struct {
-   uint32_t byte_count;
-   uint32_t byte_offset;
-} __packed hv_vm_transfer_page;
-
-typedef struct {
-   hv_vm_packet_descriptor d;
-   uint16_ttransfer_page_set_id;
-   hv_bool_uint8_t sender_owns_set;
-   uint8_t reserved;
-   uint32_trange_count;
-   hv_vm_transfer_page ranges[1];
-} __packed hv_vm_transfer_page_packet_header;
-
 #define HW_MACADDR_LEN 6
 
 /*
@@ -298,13 +276,6 @@ hv_set_channel_read_state(hv_vmbus_chann
channel->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD;
 }
 
-inthv_vmbus_channel_recv_packet_raw(
-   hv_vmbus_channel*   channel,
-   void*   buffer,
-   uint32_tbuffer_len,
-   uint32_t*   buffer_actual_len,
-   uint64_t*   request_id);
-
 inthv_vmbus_channel_open(
hv_vmbus_channel*   channel,
uint32_tsend_ring_buffer_size,

Modified: head/sys/dev/hyperv/include/vmbus.h
==
--- head/sys/dev/hyperv/include/vmbus.h Fri Jul 15 07:45:30 2016
(r302885)
+++ head/sys/dev/hyperv/include/vmbus.h Fri Jul 15 07:53:45 2016
(r302886)
@@ -47,6 +47,19 @@ struct vmbus_gpa {
uint64_tgpa_page;
 } __packed;
 
+#define VMBUS_CHANPKT_SIZE_SHIFT   3
+
+#define VMBUS_CHANPKT_GETLEN(pktlen)   \
+   (((int)(pktlen)) << VMBUS_CHANPKT_SIZE_SHIFT)
+
+struct vmbus_chanpkt_hdr {
+   uint16_tcph_type;   /* VMBUS_CHANPKT_TYPE_ */
+   uint16_tcph_hlen;   /* header len, in 8 bytes */
+   uint16_tcph_tlen;   /* total len, in 8 bytes */
+   uint16_tcph_flags;  /* VMBUS_CHANPKT_FLAG_ */
+   uint64_tcph_xactid;
+} __packed;
+
 #define VMBUS_CHANPKT_TYPE_INBAND  0x0006
 #define VMBUS_CHANPKT_TYPE_RXBUF   0x0007
 #define VMBUS_CHANPKT_TYPE_GPA 0x0009
@@ -54,6 +67,23 @@ struct vmbus_gpa {
 
 #define VMBUS_CHANPKT_FLAG_RC  0x0001  /* report completion */
 
+#define VMBUS_CHANPKT_CONST_DATA(pkt)  \
+   (const void *)((const uint8_t *)(pkt) + \
+   VMBUS_CHANPKT_GETLEN((pkt)->cph_hlen))
+
+struct vmbus_rxbuf_desc {
+   uint32_trb_len;
+   uint32_trb_ofs;
+} __packed;
+
+struct vmbus_chanpkt_rxbuf {
+   struct vmbus_chanpkt_hdr cp_hdr;
+   uint16_tcp_rxbuf_id;
+   uint16_tcp_rsvd;
+   uint32_tcp_rxbuf_cnt;
+   struct vmbus_rxbuf_desc cp_rxbuf[];
+} __packed;
+
 #define VMBUS_CHAN_SGLIST_MAX  32
 #define VMBUS_CHAN_PRPLIST_MAX 32
 
@@ -61,6 +91,8 @@ struct hv_vmbus_channel;
 
 intvmbus_chan_recv(struct hv_vmbus_channel *chan, void *data, int *dlen,
uint64_t *xactid);
+intvmbus_chan_recv_pkt(struct hv_vmbus_channel *chan,
+   struct vmbus_chanpkt_hdr *pkt, int *pktlen);
 
 intvmbus_chan_send(struct hv_vmbus_channel *chan, uint16_t type,
uint16_t flags, void *data, int dlen, uint64_t xactid);

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.c
==
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Jul 15 07:45:30 2016
(r302885)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Jul 15 07:53:45 2016
(r302886)
@@ -64,12 +64,12 @@ static int  hv_nv_destroy_send_buffer(ne
 static int  hv_nv_destroy_rx_buffer(netvsc_dev *net_dev);
 static int  hv_nv_connect_to_vsp(struct hn_softc *sc);
 static void hv_nv_on_send_completion(netvsc_dev *net_dev,
-struct hv_vmbus_chan

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

2016-07-15 Thread Sepherosa Ziehau
Author: sephe
Date: Fri Jul 15 08:06:48 2016
New Revision: 302887
URL: https://svnweb.freebsd.org/changeset/base/302887

Log:
  hyperv/hn: Busdma-fy rxbuf and chimney sending buffer
  
  Nuke unused channel GPADL API.
  
  MFC after:1 week
  Sponsored by: Microsoft OSTC
  Differential Revision:https://reviews.freebsd.org/D7211

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

Modified: head/sys/dev/hyperv/include/hyperv.h
==
--- head/sys/dev/hyperv/include/hyperv.hFri Jul 15 07:53:45 2016
(r302886)
+++ head/sys/dev/hyperv/include/hyperv.hFri Jul 15 08:06:48 2016
(r302887)
@@ -287,14 +287,6 @@ inthv_vmbus_channel_open(
 
 void   hv_vmbus_channel_close(hv_vmbus_channel *channel);
 
-inthv_vmbus_channel_establish_gpadl(
-   hv_vmbus_channel*   channel,
-   /* must be phys and virt contiguous */
-   void*   contig_buffer,
-   /*  page-size multiple  */
-   uint32_tsize,
-   uint32_t*   gpadl_handle);
-
 inthv_vmbus_channel_teardown_gpdal(
hv_vmbus_channel*   channel,
uint32_tgpadl_handle);

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.c
==
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Jul 15 07:53:45 2016
(r302886)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Jul 15 08:06:48 2016
(r302887)
@@ -152,19 +152,27 @@ hv_nv_init_rx_buffer_with_net_vsp(struct
return (ENODEV);
}
 
-   net_dev->rx_buf = contigmalloc(net_dev->rx_buf_size, M_NETVSC,
-   M_ZERO, 0UL, BUS_SPACE_MAXADDR, PAGE_SIZE, 0);
+   net_dev->rx_buf = hyperv_dmamem_alloc(bus_get_dma_tag(sc->hn_dev),
+   PAGE_SIZE, 0, net_dev->rx_buf_size, &net_dev->rxbuf_dma,
+   BUS_DMA_WAITOK | BUS_DMA_ZERO);
+   if (net_dev->rx_buf == NULL) {
+   device_printf(sc->hn_dev, "allocate rxbuf failed\n");
+   return ENOMEM;
+   }
 
/*
-* Establish the GPADL handle for this buffer on this channel.
-* Note:  This call uses the vmbus connection rather than the
-* channel to establish the gpadl handle. 
-* GPADL:  Guest physical address descriptor list.
-*/
-   ret = hv_vmbus_channel_establish_gpadl(
-   sc->hn_prichan, net_dev->rx_buf,
-   net_dev->rx_buf_size, &net_dev->rx_buf_gpadl_handle);
+* Connect the RXBUF GPADL to the primary channel.
+*
+* NOTE:
+* Only primary channel has RXBUF connected to it.  Sub-channels
+* just share this RXBUF.
+*/
+   ret = vmbus_chan_gpadl_connect(sc->hn_prichan,
+   net_dev->rxbuf_dma.hv_paddr, net_dev->rx_buf_size,
+   &net_dev->rx_buf_gpadl_handle);
if (ret != 0) {
+   device_printf(sc->hn_dev, "rxbuf gpadl connect failed: %d\n",
+   ret);
goto cleanup;
}

@@ -243,22 +251,27 @@ hv_nv_init_send_buffer_with_net_vsp(stru
return (ENODEV);
}
 
-   net_dev->send_buf  = contigmalloc(net_dev->send_buf_size, M_NETVSC,
-   M_ZERO, 0UL, BUS_SPACE_MAXADDR, PAGE_SIZE, 0);
+   net_dev->send_buf = hyperv_dmamem_alloc(bus_get_dma_tag(sc->hn_dev),
+   PAGE_SIZE, 0, net_dev->send_buf_size, &net_dev->txbuf_dma,
+   BUS_DMA_WAITOK | BUS_DMA_ZERO);
if (net_dev->send_buf == NULL) {
-   ret = ENOMEM;
-   goto cleanup;
+   device_printf(sc->hn_dev, "allocate chimney txbuf failed\n");
+   return ENOMEM;
}
 
/*
-* Establish the gpadl handle for this buffer on this channel.
-* Note:  This call uses the vmbus connection rather than the
-* channel to establish the gpadl handle. 
+* Connect chimney sending buffer GPADL to the primary channel.
+*
+* NOTE:
+* Only primary channel has chimney sending buffer connected to it.
+* Sub-channels just share this chimney sending buffer.
 */
-   ret = hv_vmbus_channel_establish_gpadl(sc->hn_prichan,
-   net_dev->send_buf, net_dev->send_buf_size,
+   ret = vmbus_chan_gpadl_connect(sc->hn_prichan,
+   net_dev->txbuf_dma.hv_paddr, net_dev->send_buf_size,
&net_dev->send_buf_gpadl_handle);
if (ret != 0) {
+   device_printf(sc->hn_dev, "chimney sending buffer gpadl "
+   "connect faile

svn commit: r302888 - in head/sys/dev/hyperv: include netvsc storvsc vmbus

2016-07-15 Thread Sepherosa Ziehau
Author: sephe
Date: Fri Jul 15 08:08:13 2016
New Revision: 302888
URL: https://svnweb.freebsd.org/changeset/base/302888

Log:
  hyperv/hn: Busdma-fy rxbuf and chimney sending buffer
  
  Nuke unused channel GPADL API.
  
  MFC after:1 week
  Sponsored by: Microsoft OSTC
  Differential Revision:https://reviews.freebsd.org/D7211

Modified:
  head/sys/dev/hyperv/include/hyperv.h
  head/sys/dev/hyperv/include/vmbus.h
  head/sys/dev/hyperv/netvsc/hv_net_vsc.c
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
  head/sys/dev/hyperv/vmbus/hv_channel.c

Modified: head/sys/dev/hyperv/include/hyperv.h
==
--- head/sys/dev/hyperv/include/hyperv.hFri Jul 15 08:06:48 2016
(r302887)
+++ head/sys/dev/hyperv/include/hyperv.hFri Jul 15 08:08:13 2016
(r302888)
@@ -287,22 +287,8 @@ inthv_vmbus_channel_open(
 
 void   hv_vmbus_channel_close(hv_vmbus_channel *channel);
 
-inthv_vmbus_channel_teardown_gpdal(
-   hv_vmbus_channel*   channel,
-   uint32_tgpadl_handle);
-
-intvmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan,
-   bus_addr_t paddr, int size, uint32_t *gpadl);
-
 struct hv_vmbus_channel* vmbus_select_outgoing_channel(struct hv_vmbus_channel 
*promary);
 
-void   vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu);
-void   vmbus_channel_cpu_rr(struct hv_vmbus_channel *chan);
-struct hv_vmbus_channel **
-   vmbus_get_subchan(struct hv_vmbus_channel *pri_chan, int 
subchan_cnt);
-void   vmbus_rel_subchan(struct hv_vmbus_channel **subchan, int 
subchan_cnt);
-void   vmbus_drain_subchan(struct hv_vmbus_channel *pri_chan);
-
 /**
  * @brief Get physical address from virtual
  */

Modified: head/sys/dev/hyperv/include/vmbus.h
==
--- head/sys/dev/hyperv/include/vmbus.h Fri Jul 15 08:06:48 2016
(r302887)
+++ head/sys/dev/hyperv/include/vmbus.h Fri Jul 15 08:08:13 2016
(r302888)
@@ -89,6 +89,20 @@ struct vmbus_chanpkt_rxbuf {
 
 struct hv_vmbus_channel;
 
+intvmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan,
+   bus_addr_t paddr, int size, uint32_t *gpadl);
+intvmbus_chan_gpadl_disconnect(struct hv_vmbus_channel *chan,
+   uint32_t gpadl);
+
+void   vmbus_chan_cpu_set(struct hv_vmbus_channel *chan, int cpu);
+void   vmbus_chan_cpu_rr(struct hv_vmbus_channel *chan);
+
+struct hv_vmbus_channel **
+   vmbus_subchan_get(struct hv_vmbus_channel *pri_chan, int subchan_cnt);
+void   vmbus_subchan_rel(struct hv_vmbus_channel **subchan, int subchan_cnt);
+void   vmbus_subchan_drain(struct hv_vmbus_channel *pri_chan);
+
+
 intvmbus_chan_recv(struct hv_vmbus_channel *chan, void *data, int *dlen,
uint64_t *xactid);
 intvmbus_chan_recv_pkt(struct hv_vmbus_channel *chan,

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.c
==
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Jul 15 08:06:48 2016
(r302887)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Jul 15 08:08:13 2016
(r302888)
@@ -363,7 +363,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_

/* Tear down the gpadl on the vsp end */
if (net_dev->rx_buf_gpadl_handle) {
-   ret = hv_vmbus_channel_teardown_gpdal(net_dev->sc->hn_prichan,
+   ret = vmbus_chan_gpadl_disconnect(net_dev->sc->hn_prichan,
net_dev->rx_buf_gpadl_handle);
/*
 * If we failed here, we might as well return and have a leak 
@@ -430,7 +430,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne

/* Tear down the gpadl on the vsp end */
if (net_dev->send_buf_gpadl_handle) {
-   ret = hv_vmbus_channel_teardown_gpdal(net_dev->sc->hn_prichan,
+   ret = vmbus_chan_gpadl_disconnect(net_dev->sc->hn_prichan,
net_dev->send_buf_gpadl_handle);
 
/*

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Fri Jul 15 08:06:48 
2016(r302887)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Fri Jul 15 08:08:13 
2016(r302888)
@@ -1586,7 +1586,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
}
 
/* Wait for subchannels to be destroyed */
-   vmbus_drain_subchan(sc->hn_prichan);
+   vmbus_subchan_drain(sc->hn_prichan);
 
error = hv_rf_on_device_add(sc, &device_info,
sc->hn_rx_ring_inuse);
@@ -2950,7 +2

svn commit: r302889 - in head/sys/dev/hyperv: include netvsc storvsc vmbus

2016-07-15 Thread Sepherosa Ziehau
Author: sephe
Date: Fri Jul 15 08:13:44 2016
New Revision: 302889
URL: https://svnweb.freebsd.org/changeset/base/302889

Log:
  hyperv/vmbus: Back out r302888 temporarily
  
  Committed by accident w/ duplicated commit log
  
  MFC after:1 week
  Sponsored by: Microsoft OSTC

Modified:
  head/sys/dev/hyperv/include/hyperv.h
  head/sys/dev/hyperv/include/vmbus.h
  head/sys/dev/hyperv/netvsc/hv_net_vsc.c
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
  head/sys/dev/hyperv/vmbus/hv_channel.c

Modified: head/sys/dev/hyperv/include/hyperv.h
==
--- head/sys/dev/hyperv/include/hyperv.hFri Jul 15 08:08:13 2016
(r302888)
+++ head/sys/dev/hyperv/include/hyperv.hFri Jul 15 08:13:44 2016
(r302889)
@@ -287,8 +287,22 @@ inthv_vmbus_channel_open(
 
 void   hv_vmbus_channel_close(hv_vmbus_channel *channel);
 
+inthv_vmbus_channel_teardown_gpdal(
+   hv_vmbus_channel*   channel,
+   uint32_tgpadl_handle);
+
+intvmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan,
+   bus_addr_t paddr, int size, uint32_t *gpadl);
+
 struct hv_vmbus_channel* vmbus_select_outgoing_channel(struct hv_vmbus_channel 
*promary);
 
+void   vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu);
+void   vmbus_channel_cpu_rr(struct hv_vmbus_channel *chan);
+struct hv_vmbus_channel **
+   vmbus_get_subchan(struct hv_vmbus_channel *pri_chan, int 
subchan_cnt);
+void   vmbus_rel_subchan(struct hv_vmbus_channel **subchan, int 
subchan_cnt);
+void   vmbus_drain_subchan(struct hv_vmbus_channel *pri_chan);
+
 /**
  * @brief Get physical address from virtual
  */

Modified: head/sys/dev/hyperv/include/vmbus.h
==
--- head/sys/dev/hyperv/include/vmbus.h Fri Jul 15 08:08:13 2016
(r302888)
+++ head/sys/dev/hyperv/include/vmbus.h Fri Jul 15 08:13:44 2016
(r302889)
@@ -89,20 +89,6 @@ struct vmbus_chanpkt_rxbuf {
 
 struct hv_vmbus_channel;
 
-intvmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan,
-   bus_addr_t paddr, int size, uint32_t *gpadl);
-intvmbus_chan_gpadl_disconnect(struct hv_vmbus_channel *chan,
-   uint32_t gpadl);
-
-void   vmbus_chan_cpu_set(struct hv_vmbus_channel *chan, int cpu);
-void   vmbus_chan_cpu_rr(struct hv_vmbus_channel *chan);
-
-struct hv_vmbus_channel **
-   vmbus_subchan_get(struct hv_vmbus_channel *pri_chan, int subchan_cnt);
-void   vmbus_subchan_rel(struct hv_vmbus_channel **subchan, int subchan_cnt);
-void   vmbus_subchan_drain(struct hv_vmbus_channel *pri_chan);
-
-
 intvmbus_chan_recv(struct hv_vmbus_channel *chan, void *data, int *dlen,
uint64_t *xactid);
 intvmbus_chan_recv_pkt(struct hv_vmbus_channel *chan,

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.c
==
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Jul 15 08:08:13 2016
(r302888)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Jul 15 08:13:44 2016
(r302889)
@@ -363,7 +363,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_

/* Tear down the gpadl on the vsp end */
if (net_dev->rx_buf_gpadl_handle) {
-   ret = vmbus_chan_gpadl_disconnect(net_dev->sc->hn_prichan,
+   ret = hv_vmbus_channel_teardown_gpdal(net_dev->sc->hn_prichan,
net_dev->rx_buf_gpadl_handle);
/*
 * If we failed here, we might as well return and have a leak 
@@ -430,7 +430,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne

/* Tear down the gpadl on the vsp end */
if (net_dev->send_buf_gpadl_handle) {
-   ret = vmbus_chan_gpadl_disconnect(net_dev->sc->hn_prichan,
+   ret = hv_vmbus_channel_teardown_gpdal(net_dev->sc->hn_prichan,
net_dev->send_buf_gpadl_handle);
 
/*

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Fri Jul 15 08:08:13 
2016(r302888)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Fri Jul 15 08:13:44 
2016(r302889)
@@ -1586,7 +1586,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
}
 
/* Wait for subchannels to be destroyed */
-   vmbus_subchan_drain(sc->hn_prichan);
+   vmbus_drain_subchan(sc->hn_prichan);
 
error = hv_rf_on_device_add(sc, &device_info,
sc->hn_rx_ring_inuse);
@@ -2950,7 +2950,7 @@ hn_channel_attach(struct hn_softc *sc, s
}
 

svn commit: r302890 - in head/sys/dev/hyperv: include netvsc storvsc vmbus

2016-07-15 Thread Sepherosa Ziehau
Author: sephe
Date: Fri Jul 15 08:23:33 2016
New Revision: 302890
URL: https://svnweb.freebsd.org/changeset/base/302890

Log:
  hyperv/vmbus: Function rename
  
  MFC after:1 week
  Sponsored by: Microsoft OSTC
  Differential Revision:https://reviews.freebsd.org/D7212

Modified:
  head/sys/dev/hyperv/include/hyperv.h
  head/sys/dev/hyperv/include/vmbus.h
  head/sys/dev/hyperv/netvsc/hv_net_vsc.c
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
  head/sys/dev/hyperv/vmbus/hv_channel.c

Modified: head/sys/dev/hyperv/include/hyperv.h
==
--- head/sys/dev/hyperv/include/hyperv.hFri Jul 15 08:13:44 2016
(r302889)
+++ head/sys/dev/hyperv/include/hyperv.hFri Jul 15 08:23:33 2016
(r302890)
@@ -287,22 +287,8 @@ inthv_vmbus_channel_open(
 
 void   hv_vmbus_channel_close(hv_vmbus_channel *channel);
 
-inthv_vmbus_channel_teardown_gpdal(
-   hv_vmbus_channel*   channel,
-   uint32_tgpadl_handle);
-
-intvmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan,
-   bus_addr_t paddr, int size, uint32_t *gpadl);
-
 struct hv_vmbus_channel* vmbus_select_outgoing_channel(struct hv_vmbus_channel 
*promary);
 
-void   vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu);
-void   vmbus_channel_cpu_rr(struct hv_vmbus_channel *chan);
-struct hv_vmbus_channel **
-   vmbus_get_subchan(struct hv_vmbus_channel *pri_chan, int 
subchan_cnt);
-void   vmbus_rel_subchan(struct hv_vmbus_channel **subchan, int 
subchan_cnt);
-void   vmbus_drain_subchan(struct hv_vmbus_channel *pri_chan);
-
 /**
  * @brief Get physical address from virtual
  */

Modified: head/sys/dev/hyperv/include/vmbus.h
==
--- head/sys/dev/hyperv/include/vmbus.h Fri Jul 15 08:13:44 2016
(r302889)
+++ head/sys/dev/hyperv/include/vmbus.h Fri Jul 15 08:23:33 2016
(r302890)
@@ -89,6 +89,20 @@ struct vmbus_chanpkt_rxbuf {
 
 struct hv_vmbus_channel;
 
+intvmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan,
+   bus_addr_t paddr, int size, uint32_t *gpadl);
+intvmbus_chan_gpadl_disconnect(struct hv_vmbus_channel *chan,
+   uint32_t gpadl);
+
+void   vmbus_chan_cpu_set(struct hv_vmbus_channel *chan, int cpu);
+void   vmbus_chan_cpu_rr(struct hv_vmbus_channel *chan);
+
+struct hv_vmbus_channel **
+   vmbus_subchan_get(struct hv_vmbus_channel *pri_chan, int subchan_cnt);
+void   vmbus_subchan_rel(struct hv_vmbus_channel **subchan, int subchan_cnt);
+void   vmbus_subchan_drain(struct hv_vmbus_channel *pri_chan);
+
+
 intvmbus_chan_recv(struct hv_vmbus_channel *chan, void *data, int *dlen,
uint64_t *xactid);
 intvmbus_chan_recv_pkt(struct hv_vmbus_channel *chan,

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.c
==
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Jul 15 08:13:44 2016
(r302889)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Jul 15 08:23:33 2016
(r302890)
@@ -363,7 +363,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_

/* Tear down the gpadl on the vsp end */
if (net_dev->rx_buf_gpadl_handle) {
-   ret = hv_vmbus_channel_teardown_gpdal(net_dev->sc->hn_prichan,
+   ret = vmbus_chan_gpadl_disconnect(net_dev->sc->hn_prichan,
net_dev->rx_buf_gpadl_handle);
/*
 * If we failed here, we might as well return and have a leak 
@@ -430,7 +430,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne

/* Tear down the gpadl on the vsp end */
if (net_dev->send_buf_gpadl_handle) {
-   ret = hv_vmbus_channel_teardown_gpdal(net_dev->sc->hn_prichan,
+   ret = vmbus_chan_gpadl_disconnect(net_dev->sc->hn_prichan,
net_dev->send_buf_gpadl_handle);
 
/*

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Fri Jul 15 08:13:44 
2016(r302889)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Fri Jul 15 08:23:33 
2016(r302890)
@@ -1586,7 +1586,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
}
 
/* Wait for subchannels to be destroyed */
-   vmbus_drain_subchan(sc->hn_prichan);
+   vmbus_subchan_drain(sc->hn_prichan);
 
error = hv_rf_on_device_add(sc, &device_info,
sc->hn_rx_ring_inuse);
@@ -2950,7 +2950,7 @@ hn_channel_attach(struct hn_softc *sc, s
}

svn commit: r302891 - head/sys/dev/hyperv/vmbus

2016-07-15 Thread Sepherosa Ziehau
Author: sephe
Date: Fri Jul 15 08:31:53 2016
New Revision: 302891
URL: https://svnweb.freebsd.org/changeset/base/302891

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

Modified:
  head/sys/dev/hyperv/vmbus/hv_channel.c

Modified: head/sys/dev/hyperv/vmbus/hv_channel.c
==
--- head/sys/dev/hyperv/vmbus/hv_channel.c  Fri Jul 15 08:23:33 2016
(r302890)
+++ head/sys/dev/hyperv/vmbus/hv_channel.c  Fri Jul 15 08:31:53 2016
(r302891)
@@ -505,41 +505,45 @@ vmbus_chan_gpadl_disconnect(struct hv_vm
 }
 
 static void
-hv_vmbus_channel_close_internal(hv_vmbus_channel *channel)
+vmbus_chan_close_internal(struct hv_vmbus_channel *chan)
 {
-   struct vmbus_softc *sc = channel->vmbus_sc;
+   struct vmbus_softc *sc = chan->vmbus_sc;
struct vmbus_msghc *mh;
struct vmbus_chanmsg_chclose *req;
-   struct taskqueue *tq = channel->ch_tq;
+   struct taskqueue *tq = chan->ch_tq;
int error;
 
/* TODO: stringent check */
-   atomic_clear_int(&channel->ch_stflags, VMBUS_CHAN_ST_OPENED);
-
-   sysctl_ctx_free(&channel->ch_sysctl_ctx);
+   atomic_clear_int(&chan->ch_stflags, VMBUS_CHAN_ST_OPENED);
 
/*
-* Set ch_tq to NULL to avoid more requests be scheduled
+* Free this channel's sysctl tree attached to its device's
+* sysctl tree.
 */
-   channel->ch_tq = NULL;
-   taskqueue_drain(tq, &channel->ch_task);
-   channel->ch_cb = NULL;
+   sysctl_ctx_free(&chan->ch_sysctl_ctx);
 
-   /**
-* Send a closing message
+   /*
+* Set ch_tq to NULL to avoid more requests be scheduled.
+* XXX pretty broken; need rework.
 */
+   chan->ch_tq = NULL;
+   taskqueue_drain(tq, &chan->ch_task);
+   chan->ch_cb = NULL;
 
+   /*
+* Close this channel.
+*/
mh = vmbus_msghc_get(sc, sizeof(*req));
if (mh == NULL) {
device_printf(sc->vmbus_dev,
"can not get msg hypercall for chclose(chan%u)\n",
-   channel->ch_id);
+   chan->ch_id);
return;
}
 
req = vmbus_msghc_dataptr(mh);
req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHCLOSE;
-   req->chm_chanid = channel->ch_id;
+   req->chm_chanid = chan->ch_id;
 
error = vmbus_msghc_exec_noresult(mh);
vmbus_msghc_put(sc, mh);
@@ -547,29 +551,28 @@ hv_vmbus_channel_close_internal(hv_vmbus
if (error) {
device_printf(sc->vmbus_dev,
"chclose(chan%u) msg hypercall exec failed: %d\n",
-   channel->ch_id, error);
+   chan->ch_id, error);
return;
} else if (bootverbose) {
-   device_printf(sc->vmbus_dev, "close chan%u\n",
-   channel->ch_id);
+   device_printf(sc->vmbus_dev, "close chan%u\n", chan->ch_id);
}
 
-   /* Tear down the gpadl for the channel's ring buffer */
-   if (channel->ch_bufring_gpadl) {
-   vmbus_chan_gpadl_disconnect(channel, channel->ch_bufring_gpadl);
-   channel->ch_bufring_gpadl = 0;
+   /*
+* Disconnect the TX+RX bufrings from this channel.
+*/
+   if (chan->ch_bufring_gpadl) {
+   vmbus_chan_gpadl_disconnect(chan, chan->ch_bufring_gpadl);
+   chan->ch_bufring_gpadl = 0;
}
 
-   /* TODO: Send a msg to release the childRelId */
-
-   /* cleanup the ring buffers for this channel */
-   hv_ring_buffer_cleanup(&channel->outbound);
-   hv_ring_buffer_cleanup(&channel->inbound);
-
-   if (channel->ch_bufring != NULL) {
-   hyperv_dmamem_free(&channel->ch_bufring_dma,
-   channel->ch_bufring);
-   channel->ch_bufring = NULL;
+   /*
+* Destroy the TX+RX bufrings.
+*/
+   hv_ring_buffer_cleanup(&chan->outbound);
+   hv_ring_buffer_cleanup(&chan->inbound);
+   if (chan->ch_bufring != NULL) {
+   hyperv_dmamem_free(&chan->ch_bufring_dma, chan->ch_bufring);
+   chan->ch_bufring = NULL;
}
 }
 
@@ -601,12 +604,12 @@ hv_vmbus_channel_close(struct hv_vmbus_c
 
subchan = vmbus_subchan_get(chan, subchan_cnt);
for (i = 0; i < subchan_cnt; ++i)
-   hv_vmbus_channel_close_internal(subchan[i]);
+   vmbus_chan_close_internal(subchan[i]);
vmbus_subchan_rel(subchan, subchan_cnt);
}
 
/* Then close the primary channel. */
-   hv_vmbus_channel_close_internal(chan);
+   vmbus_chan_close_internal(chan);
 }
 
 int
___
svn-src-all@freebsd.org mailing list
https://lists.fr

svn commit: r302892 - head/sys/dev/hyperv/vmbus

2016-07-15 Thread Sepherosa Ziehau
Author: sephe
Date: Fri Jul 15 08:40:22 2016
New Revision: 302892
URL: https://svnweb.freebsd.org/changeset/base/302892

Log:
  hyperv/vmbus: Cleanup channel sysctl tree creation
  
  MFC after:1 week
  Sponsored by: Microsoft OSTC
  Differential Revision:https://reviews.freebsd.org/D7214

Modified:
  head/sys/dev/hyperv/vmbus/hv_channel.c

Modified: head/sys/dev/hyperv/vmbus/hv_channel.c
==
--- head/sys/dev/hyperv/vmbus/hv_channel.c  Fri Jul 15 08:31:53 2016
(r302891)
+++ head/sys/dev/hyperv/vmbus/hv_channel.c  Fri Jul 15 08:40:22 2016
(r302892)
@@ -99,88 +99,106 @@ vmbus_chan_send_event(hv_vmbus_channel *
 }
 
 static int
-vmbus_channel_sysctl_monalloc(SYSCTL_HANDLER_ARGS)
+vmbus_chan_sysctl_mnf(SYSCTL_HANDLER_ARGS)
 {
struct hv_vmbus_channel *chan = arg1;
-   int alloc = 0;
+   int mnf = 0;
 
if (chan->ch_flags & VMBUS_CHAN_FLAG_HASMNF)
-   alloc = 1;
-   return sysctl_handle_int(oidp, &alloc, 0, req);
+   mnf = 1;
+   return sysctl_handle_int(oidp, &mnf, 0, req);
 }
 
 static void
-vmbus_channel_sysctl_create(hv_vmbus_channel* channel)
+vmbus_chan_sysctl_create(struct hv_vmbus_channel *chan)
 {
-   device_t dev;
-   struct sysctl_oid *devch_sysctl;
-   struct sysctl_oid *devch_id_sysctl, *devch_sub_sysctl;
-   struct sysctl_oid *devch_id_in_sysctl, *devch_id_out_sysctl;
+   struct sysctl_oid *ch_tree, *chid_tree, *br_tree;
struct sysctl_ctx_list *ctx;
uint32_t ch_id;
-   uint16_t sub_ch_id;
char name[16];
-   
-   hv_vmbus_channel* primary_ch = channel->ch_prichan;
 
-   if (primary_ch == NULL) {
-   dev = channel->ch_dev;
-   ch_id = channel->ch_id;
-   } else {
-   dev = primary_ch->ch_dev;
-   ch_id = primary_ch->ch_id;
-   sub_ch_id = channel->ch_subidx;
-   }
-   ctx = &channel->ch_sysctl_ctx;
+   /*
+* Add sysctl nodes related to this channel to this
+* channel's sysctl ctx, so that they can be destroyed
+* independently upon close of this channel, which can
+* happen even if the device is not detached.
+*/
+   ctx = &chan->ch_sysctl_ctx;
sysctl_ctx_init(ctx);
-   /* This creates dev.DEVNAME.DEVUNIT.channel tree */
-   devch_sysctl = SYSCTL_ADD_NODE(ctx,
-   SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-   OID_AUTO, "channel", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
-   /* This creates dev.DEVNAME.DEVUNIT.channel.CHANID tree */
+
+   /*
+* Create dev.NAME.UNIT.channel tree.
+*/
+   ch_tree = SYSCTL_ADD_NODE(ctx,
+   SYSCTL_CHILDREN(device_get_sysctl_tree(chan->ch_dev)),
+   OID_AUTO, "channel", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
+   if (ch_tree == NULL)
+   return;
+
+   /*
+* Create dev.NAME.UNIT.channel.CHANID tree.
+*/
+   if (VMBUS_CHAN_ISPRIMARY(chan))
+   ch_id = chan->ch_id;
+   else
+   ch_id = chan->ch_prichan->ch_id;
snprintf(name, sizeof(name), "%d", ch_id);
-   devch_id_sysctl = SYSCTL_ADD_NODE(ctx,
-   SYSCTL_CHILDREN(devch_sysctl),
-   OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
-
-   if (primary_ch != NULL) {
-   devch_sub_sysctl = SYSCTL_ADD_NODE(ctx,
-   SYSCTL_CHILDREN(devch_id_sysctl),
-   OID_AUTO, "sub", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
-   snprintf(name, sizeof(name), "%d", sub_ch_id);
-   devch_id_sysctl = SYSCTL_ADD_NODE(ctx,
-   SYSCTL_CHILDREN(devch_sub_sysctl),
-   OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
-
-   SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(devch_id_sysctl),
-   OID_AUTO, "chanid", CTLFLAG_RD,
-   &channel->ch_id, 0, "channel id");
-   }
-   SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(devch_id_sysctl), OID_AUTO,
-   "cpu", CTLFLAG_RD, &channel->ch_cpuid, 0, "owner CPU id");
-   SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(devch_id_sysctl), OID_AUTO,
-   "monitor_allocated", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE,
-   channel, 0, vmbus_channel_sysctl_monalloc, "I",
-   "is monitor allocated to this channel");
-
-   devch_id_in_sysctl = SYSCTL_ADD_NODE(ctx,
-SYSCTL_CHILDREN(devch_id_sysctl),
-OID_AUTO,
-   "in",
-   CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
-   devch_id_out_sysctl = SYSCTL_ADD_NODE(ctx,
-SYSCTL_CHILDREN(devch_id_sysctl),
-OID_AUTO,
-   "out",
-   CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
-   hv_ring_buffer_stat(ctx,
-   SYSCTL_CHILDREN

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

2016-07-15 Thread Bruce Evans


On Fri, 15 Jul 2016, Alexey Dokuchaev wrote:


On Fri, Jul 15, 2016 at 07:19:22AM +1000, Bruce Evans wrote:

On Fri, 15 Jul 2016, Bruce Evans wrote:

Log:
 Let DDB's buf printer handle NULL pointers in the buf page array.


I noticed some other bugs in this code:


Oops, that was supposed to be a private reply.


I'm glad it leaked: %p abuse is unfortunately not that rare, and getting
developers' attention is a good thing.  E.g., every time I do kldstat(8)
on my PowerPC box I sigh:

% kldstat
Id Refs AddressSize Name
17 0x10 e0c378   kernel
21 0xd20dd000 1d000tmpfs.ko
32 0xd2114000 18000geom_sched.ko
41 0xd2131000 13000gsched_rr.ko


I think some mail program further broke the formatting -- it omitted leading
spaces so nothing lines up.  After fixing this, only the narrow Address for
Id 1 messes up the alignment.

Output on amd64 shows another problem.  All kernel pointers are above
0xf000, so %p prints them all with the same width, but this
width is is too wide -- the 'f's  provide no useful info.  Also, kldstat
hard-codes the i386 width of 2+8 in the header, so the Size and Name
columns are consistently misaligned on amd64.

%p is more usable in the kernel.  One of its undocumented features
there is that field widths work with it.  This is sometimes used to
avoid the above bug.  Kernel ddb used to use %8p for all pointers.
The 8 in this is hard-coded for 32-bit arches, so was wrong in another
way.  ddb now uses %p and hard-codes the width of this in the header
as 2+8 or 2+16 depending on __LP64__ and is more broken than before
for small pointer values.  The only important table where this is
used is in ps.  Spaces in this table is wasted to print just 1
pointer -- the relatively useless wchan.

I sometimes compress kernel pointers in output and trace buffers by
omitting leading 1 or 0 bits and trailing 0 bits as well as leading
0x.

User ps is documented to trim even non-redundant leading parts of the
address for *wchan (0x80324000 -> 324000 in the example), but the code
hasn't matched the man page since 2001.  In 4.4BSD-Lite2, this as
implemented using &~ KERNBASE.  That wasn't portable.  The first fix
replaced the 32-bit %08lx format.  Now the format is %0lx.  This moves
the bugs much as in ddb ps, except it doesn't use %p and doesn't print
the 0x prefix.

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


Re: svn commit: r302324 - head/lib/libc/locale

2016-07-15 Thread Baptiste Daroussin
On Fri, Jul 15, 2016 at 02:19:41AM -0400, Jung-uk Kim wrote:
> On 07/03/16 11:00 AM, Baptiste Daroussin wrote:
> > Author: bapt
> > Date: Sun Jul  3 15:00:12 2016
> > New Revision: 302324
> > URL: https://svnweb.freebsd.org/changeset/base/302324
> > 
> > Log:
> >   Fix a bad test resulting in a segfault with ISO-8859-5 locales
> >   
> >   Reported by:  Lauri Tirkkonen from Illumos
> >   Approved by:  re@ (gjb)
> > 
> > Modified:
> >   head/lib/libc/locale/collate.c
> > 
> > Modified: head/lib/libc/locale/collate.c
> > ==
> > --- head/lib/libc/locale/collate.c  Sun Jul  3 11:45:54 2016
> > (r302323)
> > +++ head/lib/libc/locale/collate.c  Sun Jul  3 15:00:12 2016
> > (r302324)
> > @@ -310,7 +310,7 @@ _collate_lookup(struct xlocale_collate *
> > if ((sptr = *state) != NULL) {
> > *pri = *sptr;
> > sptr++;
> > -   if ((sptr == *state) || (sptr == NULL))
> > +   if ((sptr == *state) || (*sptr == 0))
> > *state = NULL;
> > else
> > *state = sptr;
> 
> I had a serious regression with ko_KR.UTF-8 locale after this commit.
> MATE is unusable because mate-panel is busy looping and eating 100% CPU.
>  GNOME 3 does not start at all, i.e., nothing but mouse cursor on black
> screen.  After reverting this commit, everything is back to normal.
> Please investigate.  IMHO, this must be fixed before 11.0-BETA2 build.
> 
> Thanks,
> 
> Jung-uk Kim
> 

Yes sorry about that, I'm aware of it and working on a fix...

Bapt


signature.asc
Description: PGP signature


svn commit: r302893 - head/sys/kern

2016-07-15 Thread Konstantin Belousov
Author: kib
Date: Fri Jul 15 09:23:18 2016
New Revision: 302893
URL: https://svnweb.freebsd.org/changeset/base/302893

Log:
  Do not allow creation of char or block special nodes with VNOVAL dev_t.
  
  As was reported on http://seclists.org/oss-sec/2016/q3/68, tmpfs code
  contains assertion that rdev != VNOVAL.  On FreeBSD, there is no other
  consequences except triggering the assert.  To be compatible with
  systems where device nodes have some significance, reject mknod(2)
  call with dev == VNOVAL at the syscall level.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/kern/vfs_syscalls.c

Modified: head/sys/kern/vfs_syscalls.c
==
--- head/sys/kern/vfs_syscalls.cFri Jul 15 08:40:22 2016
(r302892)
+++ head/sys/kern/vfs_syscalls.cFri Jul 15 09:23:18 2016
(r302893)
@@ -1167,6 +1167,8 @@ kern_mknodat(struct thread *td, int fd, 
case S_IFCHR:
case S_IFBLK:
error = priv_check(td, PRIV_VFS_MKNOD_DEV);
+   if (error == 0 && dev == VNOVAL)
+   error = EINVAL;
break;
case S_IFMT:
error = priv_check(td, PRIV_VFS_MKNOD_BAD);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302894 - head/sys/kern

2016-07-15 Thread Gleb Smirnoff
Author: glebius
Date: Fri Jul 15 09:28:32 2016
New Revision: 302894
URL: https://svnweb.freebsd.org/changeset/base/302894

Log:
  Fix regression introduced by r302350. The change of return value for a
  callout that wasn't scheduled at all was unintentional and yielded in
  several panics.
  
  PR:   210884

Modified:
  head/sys/kern/kern_timeout.c

Modified: head/sys/kern/kern_timeout.c
==
--- head/sys/kern/kern_timeout.cFri Jul 15 09:23:18 2016
(r302893)
+++ head/sys/kern/kern_timeout.cFri Jul 15 09:28:32 2016
(r302894)
@@ -1381,7 +1381,7 @@ again:
CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p",
c, c->c_func, c->c_arg);
CC_UNLOCK(cc);
-   return (cancelled);
+   return (0);
}
 
c->c_iflags &= ~CALLOUT_PENDING;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302895 - in stable/11/sys: amd64/include i386/include x86/x86 x86/xen

2016-07-15 Thread Roger Pau Monné
Author: royger
Date: Fri Jul 15 09:44:48 2016
New Revision: 302895
URL: https://svnweb.freebsd.org/changeset/base/302895

Log:
  MFC r302635:
  
  xen: automatically disable MSI-X interrupt migration
  
  Approved by:  re (kib)

Modified:
  stable/11/sys/amd64/include/intr_machdep.h
  stable/11/sys/i386/include/intr_machdep.h
  stable/11/sys/x86/x86/msi.c
  stable/11/sys/x86/xen/hvm.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/amd64/include/intr_machdep.h
==
--- stable/11/sys/amd64/include/intr_machdep.h  Fri Jul 15 09:28:32 2016
(r302894)
+++ stable/11/sys/amd64/include/intr_machdep.h  Fri Jul 15 09:44:48 2016
(r302895)
@@ -149,6 +149,8 @@ extern cpuset_t intr_cpus;
 extern struct mtx icu_lock;
 extern int elcr_found;
 
+extern int msix_disable_migration;
+
 #ifndef DEV_ATPIC
 void   atpic_reset(void);
 #endif

Modified: stable/11/sys/i386/include/intr_machdep.h
==
--- stable/11/sys/i386/include/intr_machdep.h   Fri Jul 15 09:28:32 2016
(r302894)
+++ stable/11/sys/i386/include/intr_machdep.h   Fri Jul 15 09:44:48 2016
(r302895)
@@ -140,6 +140,8 @@ extern cpuset_t intr_cpus;
 extern struct mtx icu_lock;
 extern int elcr_found;
 
+extern int msix_disable_migration;
+
 #ifndef DEV_ATPIC
 void   atpic_reset(void);
 #endif

Modified: stable/11/sys/x86/x86/msi.c
==
--- stable/11/sys/x86/x86/msi.c Fri Jul 15 09:28:32 2016(r302894)
+++ stable/11/sys/x86/x86/msi.c Fri Jul 15 09:44:48 2016(r302895)
@@ -149,12 +149,16 @@ struct pic msi_pic = {
.pic_reprogram_pin = NULL,
 };
 
-/*
+/**
  * Xen hypervisors prior to 4.6.0 do not properly handle updates to
  * enabled MSI-X table entries.  Allow migration of MSI-X interrupts
- * to be disabled via a tunable.
+ * to be disabled via a tunable. Values have the following meaning:
+ *
+ * -1: automatic detection by FreeBSD
+ *  0: enable migration
+ *  1: disable migration
  */
-static int msix_disable_migration = 0;
+int msix_disable_migration = -1;
 SYSCTL_INT(_machdep, OID_AUTO, disable_msix_migration, CTLFLAG_RDTUN,
 &msix_disable_migration, 0,
 "Disable migration of MSI-X interrupts between CPUs");
@@ -312,6 +316,11 @@ msi_init(void)
return;
}
 
+   if (msix_disable_migration == -1) {
+   /* The default is to allow migration of MSI-X interrupts. */
+   msix_disable_migration = 0;
+   }
+
msi_enabled = 1;
intr_register_pic(&msi_pic);
mtx_init(&msi_lock, "msi", NULL, MTX_DEF);

Modified: stable/11/sys/x86/xen/hvm.c
==
--- stable/11/sys/x86/xen/hvm.c Fri Jul 15 09:28:32 2016(r302894)
+++ stable/11/sys/x86/xen/hvm.c Fri Jul 15 09:44:48 2016(r302895)
@@ -134,9 +134,29 @@ xen_hvm_init_hypercall_stubs(enum xen_hv
return (ENXIO);
 
if (init_type == XEN_HVM_INIT_COLD) {
+   int major, minor;
+
do_cpuid(base + 1, regs);
-   printf("XEN: Hypervisor version %d.%d detected.\n",
-   regs[0] >> 16, regs[0] & 0x);
+
+   major = regs[0] >> 16;
+   minor = regs[0] & 0x;
+   printf("XEN: Hypervisor version %d.%d detected.\n", major,
+   minor);
+
+   if (((major < 4) || (major == 4 && minor <= 5)) &&
+   msix_disable_migration == -1) {
+   /*
+* Xen hypervisors prior to 4.6.0 do not properly
+* handle updates to enabled MSI-X table entries,
+* so disable MSI-X interrupt migration in that
+* case.
+*/
+   if (bootverbose)
+   printf(
+"Disabling MSI-X interrupt migration due to Xen hypervisor bug.\n"
+"Set machdep.msix_disable_migration=0 to forcefully enable it.\n");
+   msix_disable_migration = 1;
+   }
}
 
/*
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302896 - head/sys/arm64/arm64

2016-07-15 Thread Andrew Turner
Author: andrew
Date: Fri Jul 15 13:25:47 2016
New Revision: 302896
URL: https://svnweb.freebsd.org/changeset/base/302896

Log:
  Implement bus_print_child to print the resources used by the ITS driver.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

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

Modified: head/sys/arm64/arm64/gic_v3_fdt.c
==
--- head/sys/arm64/arm64/gic_v3_fdt.c   Fri Jul 15 09:44:48 2016
(r302895)
+++ head/sys/arm64/arm64/gic_v3_fdt.c   Fri Jul 15 13:25:47 2016
(r302896)
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
  */
 static int gic_v3_fdt_probe(device_t);
 static int gic_v3_fdt_attach(device_t);
+static int gic_v3_fdt_print_child(device_t, device_t);
 
 static struct resource *gic_v3_ofw_bus_alloc_res(device_t, device_t, int, int 
*,
 rman_res_t, rman_res_t, rman_res_t, u_int);
@@ -64,6 +65,7 @@ static device_method_t gic_v3_fdt_method
DEVMETHOD(device_attach,gic_v3_fdt_attach),
 
/* Bus interface */
+   DEVMETHOD(bus_print_child,  gic_v3_fdt_print_child),
DEVMETHOD(bus_alloc_resource,   gic_v3_ofw_bus_alloc_res),
DEVMETHOD(bus_activate_resource,bus_generic_activate_resource),
 
@@ -183,6 +185,20 @@ struct gic_v3_ofw_devinfo {
struct resource_listdi_rl;
 };
 
+static int
+gic_v3_fdt_print_child(device_t bus, device_t child)
+{
+   struct gic_v3_ofw_devinfo *di = device_get_ivars(child);
+   struct resource_list *rl = &di->di_rl;
+   int retval = 0;
+
+   retval += bus_print_child_header(bus, child);
+   retval += resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#jx");
+   retval += bus_print_child_footer(bus, child);
+
+   return (retval);
+}
+
 static const struct ofw_bus_devinfo *
 gic_v3_ofw_get_devinfo(device_t bus __unused, device_t child)
 {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2016-07-15 Thread Hans Petter Selasky

On 07/15/16 11:28, Gleb Smirnoff wrote:

Author: glebius
Date: Fri Jul 15 09:28:32 2016
New Revision: 302894
URL: https://svnweb.freebsd.org/changeset/base/302894

Log:
  Fix regression introduced by r302350. The change of return value for a
  callout that wasn't scheduled at all was unintentional and yielded in
  several panics.

  PR:   210884

Modified:
  head/sys/kern/kern_timeout.c

Modified: head/sys/kern/kern_timeout.c
==
--- head/sys/kern/kern_timeout.cFri Jul 15 09:23:18 2016
(r302893)
+++ head/sys/kern/kern_timeout.cFri Jul 15 09:28:32 2016
(r302894)
@@ -1381,7 +1381,7 @@ again:
CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p",
c, c->c_func, c->c_arg);
CC_UNLOCK(cc);
-   return (cancelled);
+   return (0);
}

c->c_iflags &= ~CALLOUT_PENDING;




Hi,

I think r302894 and r302350 changes the return value of the following 
case, which is not described in the commit message? Is this also a 
regression?


In this revision:

https://svnweb.freebsd.org/base/head/sys/kern/kern_timeout.c?view=markup&pathrev=296320


Assume we enter _callout_stop_safe() having the following assertions:

(c->c_iflags & CALLOUT_PENDING) == 0 (satisfied)
cc_exec_curr(cc, direct) != c (satisfied)

Then we exit returning (-1).

In this revision:

https://svnweb.freebsd.org/base/head/sys/kern/kern_timeout.c?view=markup&pathrev=296320#l1253


After your changes, entering the same function under the same conditions:

cc_exec_curr(cc, direct) == c (not satisifed)
(c->c_iflags & CALLOUT_PENDING) == 0 (satisfied)

Then we exit returning (0).


https://svnweb.freebsd.org/base/head/sys/kern/kern_timeout.c?revision=302894&view=markup#l1384


If we call callout_stop() on a never scheduled callout, we now get a 
return value of 0 instead of -1, which by manual page definition is 
wrong 



Am I wrong? Do others see this too?


--HPS

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


Re: svn commit: r272484 - in head: . cddl/lib/libzfs cddl/lib/libzpool

2016-07-15 Thread Alan Somers
On Fri, Oct 3, 2014 at 2:36 PM, Xin LI  wrote:
> Author: delphij
> Date: Fri Oct  3 20:36:09 2014
> New Revision: 272484
> URL: https://svnweb.freebsd.org/changeset/base/272484
>
> Log:
>   Add dependencies to various libraries to libzfs and libzpool.
>
>   Submitted by: sef
>
> Modified:
>   head/Makefile.inc1
>   head/cddl/lib/libzfs/Makefile
>   head/cddl/lib/libzpool/Makefile
>
> Modified: head/Makefile.inc1
> ==
> --- head/Makefile.inc1  Fri Oct  3 20:34:55 2014(r272483)
> +++ head/Makefile.inc1  Fri Oct  3 20:36:09 2014(r272484)
> @@ -1531,7 +1531,9 @@ _prebuild_libs=   ${_kerberos5_lib_libasn1
> lib/ncurses/ncurses lib/ncurses/ncursesw \
> lib/libopie lib/libpam ${_lib_libthr} \
> lib/libradius lib/libsbuf lib/libtacplus \
> +   lib/libgeom \
> ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
> +   ${_cddl_lib_libuutil} \
> ${_cddl_lib_libavl} \
> ${_cddl_lib_libzfs_core} \
> lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun 
> \
> @@ -1543,6 +1545,8 @@ gnu/lib/libstdc++__L: lib/msun__L
>  gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
>  .endif
>
> +lib/libgeom__L: lib/libexpat__L
> +
>  .if defined(WITH_ATF) || ${MK_TESTS} != "no"
>  .if !defined(WITH_ATF)
>  # Ensure that the ATF libraries will be built during make libraries, even
> @@ -1580,9 +1584,11 @@ lib/libopie__L lib/libtacplus__L: lib/li
>  _cddl_lib_libumem= cddl/lib/libumem
>  _cddl_lib_libnvpair= cddl/lib/libnvpair
>  _cddl_lib_libavl= cddl/lib/libavl
> +_cddl_lib_libuutil= cddl/lib/libuutil
>  _cddl_lib_libzfs_core= cddl/lib/libzfs_core
>  _cddl_lib= cddl/lib
>  cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
> +cddl/lib/libzfs__L: lib/libgeom__L
>  .endif
>
>  .if ${MK_CRYPT} != "no"
>

Is there a reason that lib/libgeom__L doesn't depend on
lib/libsbuf__L, or was that an oversight?  Also, ldd shows that
libzfs.so has a lot of dependencies that aren't listed here: libmd,
libumem, libuutil, etc.  Should they be added?  I apologize if I'm
being dumb; I don't have a good understanding of how the prebuilt libs
works.

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


svn commit: r302897 - head/usr.sbin/bsdinstall/scripts

2016-07-15 Thread Bartek Rutkowski
Author: robak (ports committer)
Date: Fri Jul 15 15:07:24 2016
New Revision: 302897
URL: https://svnweb.freebsd.org/changeset/base/302897

Log:
  Add new System Hardening menu and options to bsdinstall.
  
  This patch add new 'hardening' file responsible for new bsdinstall
  'System Hardening' menu allowing users to set some sane and carefully
  picked system security options (like random process id's, hiding
  other users/groups processes and others).
  
  All options are OFF by default in this patch due to POLA principle
  with intention to turn change some of them to ON by default in future.
  
  Reviewed by:  adrian, allanjude, bdrewery, nwhitehorn
  Approved by:  adrian, allanjude
  MFC after:7 days

Added:
  head/usr.sbin/bsdinstall/scripts/hardening   (contents, props changed)
Modified:
  head/usr.sbin/bsdinstall/scripts/Makefile
  head/usr.sbin/bsdinstall/scripts/auto
  head/usr.sbin/bsdinstall/scripts/config

Modified: head/usr.sbin/bsdinstall/scripts/Makefile
==
--- head/usr.sbin/bsdinstall/scripts/Makefile   Fri Jul 15 13:25:47 2016
(r302896)
+++ head/usr.sbin/bsdinstall/scripts/Makefile   Fri Jul 15 15:07:24 2016
(r302897)
@@ -1,6 +1,6 @@
 # $FreeBSD$
 
-SCRIPTS= auto adduser checksum config docsinstall entropy hostname jail \
+SCRIPTS= auto adduser checksum config docsinstall entropy hardening hostname 
jail \
 keymap mirrorselect mount netconfig netconfig_ipv4 netconfig_ipv6 \
 rootpass script services time umount wlanconfig zfsboot
 BINDIR= ${LIBEXECDIR}/bsdinstall

Modified: head/usr.sbin/bsdinstall/scripts/auto
==
--- head/usr.sbin/bsdinstall/scripts/auto   Fri Jul 15 13:25:47 2016
(r302896)
+++ head/usr.sbin/bsdinstall/scripts/auto   Fri Jul 15 15:07:24 2016
(r302897)
@@ -385,6 +385,7 @@ if [ "$NETCONFIG_DONE" != yes ]; then
 fi
 bsdinstall time
 bsdinstall services
+bsdinstall hardening
 
 dialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \
 "Would you like to add users to the installed system now?" 0 0 && \
@@ -401,6 +402,7 @@ finalconfig() {
"Hostname" "Set system hostname" \
"Network" "Networking configuration" \
"Services" "Set daemons to run on startup" \
+   "System Hardening" "Set security options" \
"Time Zone" "Set system timezone" \
"Handbook" "Install FreeBSD Handbook (requires network)" 2>&1 
1>&3)
exec 3>&-
@@ -426,6 +428,10 @@ finalconfig() {
bsdinstall services
finalconfig
;;
+   "System Hardening")
+   bsdinstall hardening
+   finalconfig
+   ;;
"Time Zone")
bsdinstall time
finalconfig

Modified: head/usr.sbin/bsdinstall/scripts/config
==
--- head/usr.sbin/bsdinstall/scripts/config Fri Jul 15 13:25:47 2016
(r302896)
+++ head/usr.sbin/bsdinstall/scripts/config Fri Jul 15 15:07:24 2016
(r302897)
@@ -32,6 +32,9 @@
 cat $BSDINSTALL_TMPETC/rc.conf.* >> $BSDINSTALL_TMPETC/rc.conf
 rm $BSDINSTALL_TMPETC/rc.conf.*
 
+cat $BSDINSTALL_CHROOT/etc/sysctl.conf 
$BSDINSTALL_TMPETC/sysctl.conf.hardening >> $BSDINSTALL_TMPETC/sysctl.conf
+rm $BSDINSTALL_TMPETC/sysctl.conf.*
+
 cp $BSDINSTALL_TMPETC/* $BSDINSTALL_CHROOT/etc
 
 cat $BSDINSTALL_TMPBOOT/loader.conf.* >> $BSDINSTALL_TMPBOOT/loader.conf

Added: head/usr.sbin/bsdinstall/scripts/hardening
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/bsdinstall/scripts/hardening  Fri Jul 15 15:07:24 2016
(r302897)
@@ -0,0 +1,79 @@
+#!/bin/sh
+#-
+# Copyright (c) 2016 Bartek Rutkowski
+# 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.
+# 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
+# 

svn commit: r302898 - head

2016-07-15 Thread Cy Schubert
Author: cy
Date: Fri Jul 15 15:09:48 2016
New Revision: 302898
URL: https://svnweb.freebsd.org/changeset/base/302898

Log:
  Revert r302865 and it's sister r302866 as r302865 causes some breakage.
  
  Reported by:  Guy Yur 

Modified:
  head/Makefile.inc1
  head/UPDATING

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Fri Jul 15 15:07:24 2016(r302897)
+++ head/Makefile.inc1  Fri Jul 15 15:09:48 2016(r302898)
@@ -1140,8 +1140,6 @@ BUILDKERNELS+=${_kernel}
 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
 INSTALLKERNEL= ${_kernel}
 .endif
-.else
-.error Missing KERNCONF ${KERNCONFDIR}/${_kernel}
 .endif
 .endfor
 

Modified: head/UPDATING
==
--- head/UPDATING   Fri Jul 15 15:07:24 2016(r302897)
+++ head/UPDATING   Fri Jul 15 15:09:48 2016(r302898)
@@ -31,14 +31,6 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
-20160714:
-   As of r302865 when building multiple kernels using KERNCONF,
-   non-existent KERNCONF files will produce an error and buildkernel
-   will fail. Previous to r302865 missing KERNCONF files silently
-   failed giving no indication as to why, only to subsequently discover
-   during installkernel that the desired kernel was never built in the
-   first place.
-
 20160622:
The libc stub for the pipe(2) system call has been replaced with
a wrapper which calls the pipe2(2) system call and the pipe(2) is now
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302899 - in head: lib/libc/sys share/man/man3 share/man/man4

2016-07-15 Thread John Baldwin
Author: jhb
Date: Fri Jul 15 15:12:56 2016
New Revision: 302899
URL: https://svnweb.freebsd.org/changeset/base/302899

Log:
  Add documentation for the sigevent structure.
  
  - Add a sigevent(3) manpage to give a general overview of the sigevent
structure and the available notification mechanisms.
  - Document that AIO requests contain a nested sigevent structure that can
be used to request completion notification.
  - Expand the sigevent details in other manuals to note details such as
the extra values stored in a queued signal's information or in a posted
kevent.
  
  Reviewed by:  kib
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D7122

Added:
  head/share/man/man3/sigevent.3   (contents, props changed)
Modified:
  head/lib/libc/sys/aio_fsync.2
  head/lib/libc/sys/aio_mlock.2
  head/lib/libc/sys/aio_read.2
  head/lib/libc/sys/aio_write.2
  head/lib/libc/sys/lio_listio.2
  head/lib/libc/sys/mq_notify.2
  head/lib/libc/sys/timer_create.2
  head/share/man/man3/Makefile
  head/share/man/man4/aio.4

Modified: head/lib/libc/sys/aio_fsync.2
==
--- head/lib/libc/sys/aio_fsync.2   Fri Jul 15 15:09:48 2016
(r302898)
+++ head/lib/libc/sys/aio_fsync.2   Fri Jul 15 15:12:56 2016
(r302899)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 27, 2013
+.Dd July 15, 2016
 .Dt AIO_FSYNC 2
 .Os
 .Sh NAME
@@ -71,6 +71,29 @@ while it is in progress.
 .Pp
 If the request could not be enqueued (generally due to invalid arguments),
 the call returns without having enqueued the request.
+.Pp
+The
+.Fa iocb->aio_sigevent
+structure can be used to request notification of the request's
+completion as described in
+.Xr aio 4 .
+.Sh RESTRICTIONS
+The asynchronous I/O Control Block structure pointed to by
+.Fa iocb
+must remain valid until the
+operation has completed.
+For this reason, use of auto (stack) variables
+for these objects is discouraged.
+.Pp
+The asynchronous I/O control buffer
+.Fa iocb
+should be zeroed before the
+.Fn aio_fsync
+call to avoid passing bogus context information to the kernel.
+.Pp
+Modifications of the Asynchronous I/O Control Block structure or the
+buffer contents after the request has been enqueued, but before the
+request has completed, are not allowed.
 .Sh RETURN VALUES
 .Rv -std aio_fsync
 .Sh ERRORS
@@ -80,6 +103,10 @@ system call will fail if:
 .Bl -tag -width Er
 .It Bq Er EAGAIN
 The request was not queued because of system resource limitations.
+.It Bq Er EINVAL
+The asynchronous notification method in
+.Fa iocb->aio_sigevent.sigev_notify
+is invalid or not supported.
 .It Bq Er ENOSYS
 The
 .Fn aio_fsync
@@ -138,6 +165,7 @@ system calls.
 .Xr aio_waitcomplete 2 ,
 .Xr aio_write 2 ,
 .Xr fsync 2 ,
+.Xr sigevent 3 ,
 .Xr siginfo 3 ,
 .Xr aio 4
 .Sh STANDARDS

Modified: head/lib/libc/sys/aio_mlock.2
==
--- head/lib/libc/sys/aio_mlock.2   Fri Jul 15 15:09:48 2016
(r302898)
+++ head/lib/libc/sys/aio_mlock.2   Fri Jul 15 15:12:56 2016
(r302899)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 3, 2013
+.Dd July 15, 2016
 .Dt AIO_MLOCK 2
 .Os
 .Sh NAME
@@ -64,6 +64,12 @@ If the request could not be enqueued (ge
 .Xr aio 4
 limits),
 then the call returns without having enqueued the request.
+.Pp
+The
+.Fa iocb->aio_sigevent
+structure can be used to request notification of the request's
+completion as described in
+.Xr aio 4 .
 .Sh RESTRICTIONS
 The Asynchronous I/O Control Block structure pointed to by
 .Fa iocb
@@ -92,6 +98,10 @@ system call will fail if:
 .Bl -tag -width Er
 .It Bq Er EAGAIN
 The request was not queued because of system resource limitations.
+.It Bq Er EINVAL
+The asynchronous notification method in
+.Fa iocb->aio_sigevent.sigev_notify
+is invalid or not supported.
 .It Bq Er ENOSYS
 The
 .Fn aio_mlock
@@ -116,6 +126,7 @@ if the request was explicitly cancelled 
 .Xr aio_error 2 ,
 .Xr aio_return 2 ,
 .Xr mlock 2 ,
+.Xr sigevent 3 ,
 .Xr aio 4
 .Sh PORTABILITY
 The

Modified: head/lib/libc/sys/aio_read.2
==
--- head/lib/libc/sys/aio_read.2Fri Jul 15 15:09:48 2016
(r302898)
+++ head/lib/libc/sys/aio_read.2Fri Jul 15 15:12:56 2016
(r302899)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 17, 1998
+.Dd July 15, 2016
 .Dt AIO_READ 2
 .Os
 .Sh NAME
@@ -79,6 +79,12 @@ If the request is successfully enqueued,
 .Fa iocb->aio_offset
 can be modified during the request as context, so this value must
 not be referenced after the request is enqueued.
+.Pp
+The
+.Fa iocb->aio_sigevent
+structure can be used to request notification of the request's
+completion as described in
+.Xr aio 4 .
 .Sh RESTRICTIONS
 The Asynchronous I/O Control Block structure pointed to by
 .Fa iocb
@@ -115,6 +121,10 @@ system call will fail 

svn commit: r302900 - head/tests/sys/kern

2016-07-15 Thread John Baldwin
Author: jhb
Date: Fri Jul 15 15:28:33 2016
New Revision: 302900
URL: https://svnweb.freebsd.org/changeset/base/302900

Log:
  Add a test for user signal delivery.
  
  This test verifies we get the correct ptrace event details when a signal
  is posted to a traced process from userland.
  
  Reviewed by:  kib (part of D7044)

Modified:
  head/tests/sys/kern/ptrace_test.c

Modified: head/tests/sys/kern/ptrace_test.c
==
--- head/tests/sys/kern/ptrace_test.c   Fri Jul 15 15:12:56 2016
(r302899)
+++ head/tests/sys/kern/ptrace_test.c   Fri Jul 15 15:28:33 2016
(r302900)
@@ -1355,6 +1355,67 @@ ATF_TC_BODY(ptrace__lwp_events_exec, tc)
ATF_REQUIRE(errno == ECHILD);
 }
 
+static void
+handler(int sig __unused)
+{
+}
+
+static void
+signal_main(void)
+{
+
+   signal(SIGINFO, handler);
+   raise(SIGINFO);
+   exit(0);
+}
+
+/*
+ * Verify that the expected ptrace event is reported for a signal.
+ */
+ATF_TC_WITHOUT_HEAD(ptrace__siginfo);
+ATF_TC_BODY(ptrace__siginfo, tc)
+{
+   struct ptrace_lwpinfo pl;
+   pid_t fpid, wpid;
+   int status;
+
+   ATF_REQUIRE((fpid = fork()) != -1);
+   if (fpid == 0) {
+   trace_me();
+   signal_main();
+   }
+
+   /* The first wait() should report the stop from SIGSTOP. */
+   wpid = waitpid(fpid, &status, 0);
+   ATF_REQUIRE(wpid == fpid);
+   ATF_REQUIRE(WIFSTOPPED(status));
+   ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP);
+
+   ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0);
+
+   /* The next event should be for the SIGINFO. */
+   wpid = waitpid(fpid, &status, 0);
+   ATF_REQUIRE(WIFSTOPPED(status));
+   ATF_REQUIRE(WSTOPSIG(status) == SIGINFO);
+
+   ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl, sizeof(pl)) != -1);
+   ATF_REQUIRE(pl.pl_event == PL_EVENT_SIGNAL);
+   ATF_REQUIRE(pl.pl_flags & PL_FLAG_SI);
+   ATF_REQUIRE(pl.pl_siginfo.si_code == SI_LWP);
+   ATF_REQUIRE(pl.pl_siginfo.si_pid == wpid);
+
+   ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0);
+
+   /* The last event should be for the child process's exit. */
+   wpid = waitpid(fpid, &status, 0);
+   ATF_REQUIRE(WIFEXITED(status));
+   ATF_REQUIRE(WEXITSTATUS(status) == 0);
+
+   wpid = wait(&status);
+   ATF_REQUIRE(wpid == -1);
+   ATF_REQUIRE(errno == ECHILD);
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 
@@ -1376,6 +1437,7 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, ptrace__new_child_pl_syscall_code_thread);
ATF_TP_ADD_TC(tp, ptrace__lwp_events);
ATF_TP_ADD_TC(tp, ptrace__lwp_events_exec);
+   ATF_TP_ADD_TC(tp, ptrace__siginfo);
 
return (atf_no_error());
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302901 - stable/10/sys/dev/e1000

2016-07-15 Thread Sean Bruno
Author: sbruno
Date: Fri Jul 15 15:30:09 2016
New Revision: 302901
URL: https://svnweb.freebsd.org/changeset/base/302901

Log:
  MFC r297187
  
  Support checksum offloading for TCP/IPV6 and UDP/IPV6.
  Support SCTP checksum offloading for SCTP/IPV6.
  Support SCTP checksum offloading on all controllers except 82575.
  
  Differential Revision:https://reviews.freebsd.org/D7215

Modified:
  stable/10/sys/dev/e1000/if_igb.c
  stable/10/sys/dev/e1000/if_igb.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/e1000/if_igb.c
==
--- stable/10/sys/dev/e1000/if_igb.cFri Jul 15 15:28:33 2016
(r302900)
+++ stable/10/sys/dev/e1000/if_igb.cFri Jul 15 15:30:09 2016
(r302901)
@@ -1169,10 +1169,27 @@ igb_ioctl(struct ifnet *ifp, u_long comm
}
}
 #endif
+#if __FreeBSD_version >= 100
+   /* HW cannot turn these on/off separately */
+   if (mask & (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6)) {
+   ifp->if_capenable ^= IFCAP_RXCSUM;
+   ifp->if_capenable ^= IFCAP_RXCSUM_IPV6;
+   reinit = 1;
+   }
+   if (mask & IFCAP_TXCSUM) {
+   ifp->if_capenable ^= IFCAP_TXCSUM;
+   reinit = 1;
+   }
+   if (mask & IFCAP_TXCSUM_IPV6) {
+   ifp->if_capenable ^= IFCAP_TXCSUM_IPV6;
+   reinit = 1;
+   }
+#else
if (mask & IFCAP_HWCSUM) {
ifp->if_capenable ^= IFCAP_HWCSUM;
reinit = 1;
}
+#endif
if (mask & IFCAP_TSO4) {
ifp->if_capenable ^= IFCAP_TSO4;
reinit = 1;
@@ -1251,14 +1268,26 @@ igb_init_locked(struct adapter *adapter)
/* Set hardware offload abilities */
ifp->if_hwassist = 0;
if (ifp->if_capenable & IFCAP_TXCSUM) {
+#if __FreeBSD_version >= 100
+   ifp->if_hwassist |= (CSUM_IP_TCP | CSUM_IP_UDP);
+   if (adapter->hw.mac.type != e1000_82575)
+   ifp->if_hwassist |= CSUM_IP_SCTP;
+#else
ifp->if_hwassist |= (CSUM_TCP | CSUM_UDP);
 #if __FreeBSD_version >= 80
-   if ((adapter->hw.mac.type == e1000_82576) ||
-   (adapter->hw.mac.type == e1000_82580))
+   if (adapter->hw.mac.type != e1000_82575)
ifp->if_hwassist |= CSUM_SCTP;
 #endif
+#endif
}
 
+#if __FreeBSD_version >= 100
+   if (ifp->if_capenable & IFCAP_TXCSUM_IPV6) {
+   ifp->if_hwassist |= (CSUM_IP6_TCP | CSUM_IP6_UDP);
+   if (adapter->hw.mac.type != e1000_82575)
+   ifp->if_hwassist |= CSUM_IP6_SCTP;
+   }
+#endif
if (ifp->if_capenable & IFCAP_TSO)
ifp->if_hwassist |= CSUM_TSO;
 
@@ -3064,6 +3093,9 @@ igb_setup_interface(device_t dev, struct
ifp->if_capabilities = ifp->if_capenable = 0;
 
ifp->if_capabilities = IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM;
+#if __FreeBSD_version >= 100
+   ifp->if_capabilities |= IFCAP_HWCSUM_IPV6;
+#endif
ifp->if_capabilities |= IFCAP_TSO;
ifp->if_capabilities |= IFCAP_JUMBO_MTU;
ifp->if_capenable = ifp->if_capabilities;
@@ -3837,17 +3869,29 @@ igb_tx_ctx_setup(struct tx_ring *txr, st
 
switch (ipproto) {
case IPPROTO_TCP:
+#if __FreeBSD_version >= 100
+   if (mp->m_pkthdr.csum_flags & (CSUM_IP_TCP | 
CSUM_IP6_TCP))
+#else
if (mp->m_pkthdr.csum_flags & CSUM_TCP)
+#endif
type_tucmd_mlhl |= E1000_ADVTXD_TUCMD_L4T_TCP;
break;
case IPPROTO_UDP:
+#if __FreeBSD_version >= 100
+   if (mp->m_pkthdr.csum_flags & (CSUM_IP_UDP | 
CSUM_IP6_UDP))
+#else
if (mp->m_pkthdr.csum_flags & CSUM_UDP)
+#endif
type_tucmd_mlhl |= E1000_ADVTXD_TUCMD_L4T_UDP;
break;
 
 #if __FreeBSD_version >= 80
case IPPROTO_SCTP:
+#if __FreeBSD_version >= 100
+   if (mp->m_pkthdr.csum_flags & (CSUM_IP_SCTP | 
CSUM_IP6_SCTP))
+#else
if (mp->m_pkthdr.csum_flags & CSUM_SCTP)
+#endif
type_tucmd_mlhl |= E1000_ADVTXD_TUCMD_L4T_SCTP;
break;
 #endif
@@ -4534,8 +4578,7 @@ igb_initialize_receive_units(struct adap
rxcsum |= E1000_RXCSUM_PCSD;
 #if __FreeBSD_version >= 80
/* For SCTP Offload */
-   if (((hw->mac.type == e1000_82576) ||
-(hw->mac.type == e1000_82580)) &&
+   if ((hw->mac.type != e1000_82575) &&
(ifp->if_capenable

svn commit: r302902 - in head: lib/libc/sys sys/kern sys/sys tests/sys/kern

2016-07-15 Thread John Baldwin
Author: jhb
Date: Fri Jul 15 15:32:09 2016
New Revision: 302902
URL: https://svnweb.freebsd.org/changeset/base/302902

Log:
  Add a mask of optional ptrace() events.
  
  ptrace() now stores a mask of optional events in p_ptevents.  Currently
  this mask is a single integer, but it can be expanded into an array of
  integers in the future.
  
  Two new ptrace requests can be used to manipulate the event mask:
  PT_GET_EVENT_MASK fetches the current event mask and PT_SET_EVENT_MASK
  sets the current event mask.
  
  The current set of events include:
  - PTRACE_EXEC: trace calls to execve().
  - PTRACE_SCE: trace system call entries.
  - PTRACE_SCX: trace syscam call exits.
  - PTRACE_FORK: trace forks and auto-attach to new child processes.
  - PTRACE_LWP: trace LWP events.
  
  The S_PT_SCX and S_PT_SCE events in the procfs p_stops flags have
  been replaced by PTRACE_SCE and PTRACE_SCX.  PTRACE_FORK replaces
  P_FOLLOW_FORK and PTRACE_LWP replaces P2_LWP_EVENTS.
  
  The PT_FOLLOW_FORK and PT_LWP_EVENTS ptrace requests remain for
  compatibility but now simply toggle corresponding flags in the
  event mask.
  
  While here, document that PT_SYSCALL, PT_TO_SCE, and PT_TO_SCX both
  modify the event mask and continue the traced process.
  
  Reviewed by:  kib
  MFC after:1 month
  Differential Revision:https://reviews.freebsd.org/D7044

Modified:
  head/lib/libc/sys/ptrace.2
  head/sys/kern/kern_exec.c
  head/sys/kern/kern_exit.c
  head/sys/kern/kern_fork.c
  head/sys/kern/kern_sig.c
  head/sys/kern/kern_thr.c
  head/sys/kern/subr_syscall.c
  head/sys/kern/sys_process.c
  head/sys/sys/proc.h
  head/sys/sys/ptrace.h
  head/tests/sys/kern/ptrace_test.c

Modified: head/lib/libc/sys/ptrace.2
==
--- head/lib/libc/sys/ptrace.2  Fri Jul 15 15:30:09 2016(r302901)
+++ head/lib/libc/sys/ptrace.2  Fri Jul 15 15:32:09 2016(r302902)
@@ -2,7 +2,7 @@
 .\"$NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $
 .\"
 .\" This file is in the public domain.
-.Dd December 29, 2015
+.Dd July 15, 2016
 .Dt PTRACE 2
 .Os
 .Sh NAME
@@ -58,8 +58,9 @@ The signal may be a normal process signa
 traced process behavior, or use of the
 .Xr kill 2
 system call; alternatively, it may be generated by the tracing facility
-as a result of attaching, system calls, or stepping by the tracing
-process.
+as a result of attaching, stepping by the tracing
+process,
+or an event in the traced process.
 The tracing process may choose to intercept the signal, using it to
 observe process behavior (such as
 .Dv SIGTRAP ) ,
@@ -69,6 +70,111 @@ The
 system call
 is the mechanism by which all this happens.
 .Pp
+A traced process may report additional signal stops corresponding to
+events in the traced process.
+These additional signal stops are reported as
+.Dv SIGTRAP
+signals.
+The tracing process can use the
+.Dv PT_LWPINFO
+request to determine which events are associated with a
+.Dv SIGTRAP
+signal.
+Note that multiple events may be associated with a single signal.
+For example, events indicated by the
+.Dv PL_FLAG_BORN ,
+.Dv PL_FLAG_FORKED ,
+and
+.Dv PL_FLAG_EXEC
+flags are also reported as a system call exit event
+.Pq Dv PL_FLAG_SCX .
+.Pp
+Each traced process has a tracing event mask.
+An event in the traced process only reports a
+.Dv SIGTRAP
+signal stop if the corresponding flag is set in the tracing event mask.
+The current set of tracing event flags include:
+.Bl -tag -width ".Dv PTRACE_SYSCALL"
+.It Dv PTRACE_EXEC
+Report a stop for a successful invocation of
+.Xr execve 2 .
+This event is indicated by the
+.Dv PL_FLAG_EXEC
+flag in the
+.Va pl_flags
+member of
+.Vt "struct ptrace_lwpinfo" .
+.It Dv PTRACE_SCE
+Report a stop on each system call entry.
+This event is indicated by the
+.Dv PL_FLAG_SCE
+flag in the
+.Va pl_flags
+member of
+.Vt "struct ptrace_lwpinfo" .
+.It Dv PTRACE_SCX
+Report a stop on each system call exit.
+This event is indicated by the
+.Dv PL_FLAG_SCX
+flag in the
+.Va pl_flags
+member of
+.Vt "struct ptrace_lwpinfo" .
+.It Dv PTRACE_SYSCALL
+Report stops for both system call entry and exit.
+.It Dv PTRACE_FORK
+This event flag controls tracing for new child processes of a traced process.
+.Pp
+When this event flag is enabled,
+new child processes will enable tracing and stop before executing their
+first instruction.
+The new child process will include the
+.Dv PL_FLAG_CHILD
+flag in the
+.Va pl_flags
+member of
+.Vt "struct ptrace_lwpinfo" .
+The traced process will report a stop that includes the
+.Dv PL_FLAG_FORKED
+flag.
+The process ID of the new child process will also be present in the
+.Va pl_child_pid
+member of
+.Vt "struct ptrace_lwpinfo" .
+Note that new child processes will be attached with the default
+tracing event mask;
+they do not inherit the event mask of the traced process.
+.Pp
+When this event flag is not enabled,
+new child processes will execute without tracing enabled.
+.It Dv PTRACE

svn commit: r302903 - head/usr.bin/mail

2016-07-15 Thread Pedro F. Giffuni
Author: pfg
Date: Fri Jul 15 15:37:54 2016
New Revision: 302903
URL: https://svnweb.freebsd.org/changeset/base/302903

Log:
  mail(1): Update more prototypes.
  
  Also rename delete and undelete_messages to deletecmd and undeletecmd
  respectively in an attempt to sync with other BSDs.
  
  Obtained from:OpenBSD

Modified:
  head/usr.bin/mail/cmd1.c
  head/usr.bin/mail/cmd2.c
  head/usr.bin/mail/cmd3.c
  head/usr.bin/mail/cmdtab.c
  head/usr.bin/mail/extern.h
  head/usr.bin/mail/names.c

Modified: head/usr.bin/mail/cmd1.c
==
--- head/usr.bin/mail/cmd1.cFri Jul 15 15:32:09 2016(r302902)
+++ head/usr.bin/mail/cmd1.cFri Jul 15 15:37:54 2016(r302903)
@@ -44,8 +44,6 @@ __FBSDID("$FreeBSD$");
  * User commands.
  */
 
-extern const struct cmd cmdtab[];
-
 /*
  * Print the current active headings.
  * Don't change dot if invoker didn't give an argument.
@@ -54,8 +52,9 @@ extern const struct cmd cmdtab[];
 static int screen;
 
 int
-headers(int *msgvec)
+headers(void *v)
 {
+   int *msgvec = v;
int n, mesg, flag, size;
struct message *mp;
 
@@ -93,8 +92,9 @@ headers(int *msgvec)
  * Scroll to the next/previous screen
  */
 int
-scroll(char arg[])
+scroll(void *v)
 {
+   char *arg = v;
int s, size;
int cur[1];
 
@@ -146,8 +146,9 @@ screensize(void)
  * in the passed message list.
  */
 int
-from(int *msgvec)
+from(void *v)
 {
+   int *msgvec = v;
int *ip;
 
for (ip = msgvec; *ip != 0; ip++)
@@ -220,6 +221,7 @@ pdot(void)
 int
 pcmdlist(void)
 {
+   extern const struct cmd cmdtab[];
const struct cmd *cp;
int cc;
 
@@ -242,8 +244,9 @@ pcmdlist(void)
  * Paginate messages, honor ignored fields.
  */
 int
-more(int *msgvec)
+more(void *v)
 {
+   int *msgvec = v;
 
return (type1(msgvec, 1, 1));
 }
@@ -252,8 +255,9 @@ more(int *msgvec)
  * Paginate messages, even printing ignored fields.
  */
 int
-More(int *msgvec)
+More(void *v)
 {
+   int *msgvec = v;
 
return (type1(msgvec, 0, 1));
 }
@@ -262,8 +266,9 @@ More(int *msgvec)
  * Type out messages, honor ignored fields.
  */
 int
-type(int *msgvec)
+type(void *v)
 {
+   int *msgvec = v;
 
return (type1(msgvec, 1, 0));
 }
@@ -272,8 +277,9 @@ type(int *msgvec)
  * Type out messages, even printing ignored fields.
  */
 int
-Type(int *msgvec)
+Type(void *v)
 {
+   int *msgvec = v;
 
return (type1(msgvec, 0, 0));
 }
@@ -355,8 +361,9 @@ brokpipe(int signo __unused)
  * and defaults to 5.
  */
 int
-top(int *msgvec)
+top(void *v)
 {
+   int *msgvec = v;
int *ip;
struct message *mp;
int c, topl, lines, lineb;
@@ -396,8 +403,9 @@ top(int *msgvec)
  * get mboxed.
  */
 int
-stouch(int msgvec[])
+stouch(void *v)
 {
+   int *msgvec = v;
int *ip;
 
for (ip = msgvec; *ip != 0; ip++) {
@@ -412,8 +420,9 @@ stouch(int msgvec[])
  * Make sure all passed messages get mboxed.
  */
 int
-mboxit(int msgvec[])
+mboxit(void *v)
 {
+   int *msgvec = v;
int *ip;
 
for (ip = msgvec; *ip != 0; ip++) {

Modified: head/usr.bin/mail/cmd2.c
==
--- head/usr.bin/mail/cmd2.cFri Jul 15 15:32:09 2016(r302902)
+++ head/usr.bin/mail/cmd2.cFri Jul 15 15:37:54 2016(r302903)
@@ -53,9 +53,10 @@ extern int wait_status;
  * If given as first command with no arguments, print first message.
  */
 int
-next(int *msgvec)
+next(void *v)
 {
struct message *mp;
+   int *msgvec = v;
int *ip, *ip2, list[2], mdot;
 
if (*msgvec != 0) {
@@ -210,8 +211,9 @@ save1(char str[], int mark, const char *
  * file name, minus header and trailing blank line.
  */
 int
-swrite(char str[])
+swrite(void *v)
 {
+   char *str = v;
 
return (save1(str, 1, "write", ignoreall));
 }
@@ -226,7 +228,7 @@ swrite(char str[])
  */
 
 char *
-snarf(char linebuf[], int *flag)
+snarf(char *linebuf, int *flag)
 {
char *cp;
 
@@ -262,8 +264,9 @@ snarf(char linebuf[], int *flag)
  * Delete messages.
  */
 int
-delete(int msgvec[])
+deletecmd(void *v)
 {
+   int *msgvec = v;
 
delm(msgvec);
return (0);
@@ -273,8 +276,9 @@ delete(int msgvec[])
  * Delete messages, then type the new dot.
  */
 int
-deltype(int msgvec[])
+deltype(void *v)
 {
+   int *msgvec = v;
int list[2];
int lastdot;
 
@@ -335,10 +339,11 @@ delm(int *msgvec)
  * Undelete the indicated messages.
  */
 int
-undelete_messages(int *msgvec)
+undeletecmd(void *v)
 {
-   struct message *mp;
+   int *msgvec = v;
int *ip;
+   struct message *mp;
 
for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) {
mp = &message[*ip - 1];
@@ -412,8 +417,9 @@ clob1(int n)
  * If no arguments, print the current list of retained fields.
  */
 int
-retfield(char *list[])
+retfield(void *v

Re: svn commit: r302782 - in head/sys: dev/acpica i386/isa

2016-07-15 Thread Bruce Evans

On Wed, 13 Jul 2016, Jung-uk Kim wrote:


Log:
 Remove a tunable and always reset system clock while resuming with ACPI.

 Requested by:  bde (long ago)


Thanks.


Modified:
 head/sys/dev/acpica/acpi.c
 head/sys/i386/isa/pmtimer.c


This also prevents the reset by pmtimer if acpi is active.  This leaves
pmtimer doing nothing if acpi is active.  pmtimer is supposed to do a
much more complete reset (reset more accurately, and fix up callouts),
but the callout code has not compiled since before it was committed.  It
is too broken to have ever been in conf/options* or conf/NOTES, so this
bug is not normally noticed.

i386 with acpi should be work without pmtimer now.  Non-{amd64,i386} with
acpi but with pmtimer non implemented might work now.

pmtimer is in i386's GENERIC, but this is probably not needed now

When the clock is not reset on resume, the system time is off by about
the length of the suspension.  It can be reset from userland using much
the same sequence as for booting, except the error will be larger so
more forceful stepping is required (kill ntpd and then use ntpdate;
submit a bug report if the threatened removal of ntpdate is implemented).
The large step from this is harmful to running programs and is better
done in the kernel before letting them run, but letting them run before
the step is harmful, and doing this in userland at least gets the step
right.  The standard /etc/resume script is clueless about this (and
about almost everything -- it is empty except for about 2 hints for
old hardware.  An active ntpd is also clueless about such large steps,
at least for the old version that I use.

When the clock is reset by pmtimer on resume, the system time is off by
about 0-1 seconds plus the drift of the RTC while suspended.

When the clock is reset by pmtimer on resume, the system time is off by
about 0-2 seconds plus the drift of the RTC while suspended.

The extra accuracy provided by pmtimer is not very useful, since an error
of more than a few milliseconds is enough to confuse ntpd, at least for
the old version of ntpd that I use.  Smaller errors are actually more
harmful unless they are fairly small, since ntpd will slew the clock for
all errors.  I used to use -x to force it to slew the clock for all errors.
This is worse than useless for recovery after suspension.  A documented,
it takes 14 days to recover from an error of just 600 seconds.  In the
old version, it was not limited to 600 seconds.  It was also broken (it
competed with the kernel part of itself to slew the clock, and made a
mess), but I fixed that.  In the current version, it is limited to 600
seconds and the fix is apparently to turn off the kernel time discipline.
So I no longer use -x.  This didn't work for long suspends either.  ntpd
was confused and aborted because the necessary step was considered
preposterous.  I can't find the threshold for this.  Initially it is 900
seconds.

Long callouts are also broken by suspensions.  E.g., "sleep 86400" sleeps
for 1 day plus the accumulated suspension time, not for 1 day as specified,
because its misimplemented using something like a callout.  If callouts
worked then the error would be limited to the accumulated leap seconds
adjustment.  The uncompilable code in pmtimer tries to fix this.  This
has nothing to do with pmtimer, except that the error is largest after
suspension and the KPI doesn't allow telling upper layers to do it for
only some clock adjustments.

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


svn commit: r302904 - head/usr.bin/netstat

2016-07-15 Thread Michael Tuexen
Author: tuexen
Date: Fri Jul 15 15:55:36 2016
New Revision: 302904
URL: https://svnweb.freebsd.org/changeset/base/302904

Log:
  Fix a bug which results in a core dump when running netstat with
  the -W option and having a listening SCTP socket.
  The bug was introduced in r279122 when adding support for libxo.
  
  MFC after:3 days

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

Modified: head/usr.bin/netstat/sctp.c
==
--- head/usr.bin/netstat/sctp.c Fri Jul 15 15:37:54 2016(r302903)
+++ head/usr.bin/netstat/sctp.c Fri Jul 15 15:55:36 2016(r302904)
@@ -529,7 +529,7 @@ retry:
"{:state/CLOSED}", " ");
} else {
xo_emit("{P:/%-45.45s} "
-   "{:state:LISTEN}", " ");
+   "{:state/LISTEN}", " ");
}
} else {
if (process_closed) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r302782 - in head/sys: dev/acpica i386/isa

2016-07-15 Thread Warner Losh
On Fri, Jul 15, 2016 at 9:09 AM, Bruce Evans  wrote:
> pmtimer is in i386's GENERIC, but this is probably not needed now

I think it's time to relegate pmtimer to the apm power stuff and make sure that
ACPI has the right hooks to do anything it currently isn't doing
correctly. pmtimer
was originally written for apm and was never really brought forward into the
ACPI era...

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


svn commit: r302906 - head/sys/netinet6

2016-07-15 Thread Andrey V. Elsukov
Author: ae
Date: Fri Jul 15 17:09:30 2016
New Revision: 302906
URL: https://svnweb.freebsd.org/changeset/base/302906

Log:
  Add net.inet6.ip6.intr_queue_maxlen sysctl. It can be used to
  change netisr queue limit for IPv6 at runtime.
  
  Obtained from:Yandex LLC
  MFC after:2 weeks
  Sponsored by: Yandex LLC

Modified:
  head/sys/netinet6/in6.h
  head/sys/netinet6/ip6_input.c

Modified: head/sys/netinet6/in6.h
==
--- head/sys/netinet6/in6.h Fri Jul 15 16:37:36 2016(r302905)
+++ head/sys/netinet6/in6.h Fri Jul 15 17:09:30 2016(r302906)
@@ -637,7 +637,10 @@ struct ip6_mtuinfo {
 * receiving IF. */
 #defineIPV6CTL_RFC6204W3   50  /* Accept defroute even when 
forwarding
   enabled */
-#defineIPV6CTL_MAXID   51
+#defineIPV6CTL_INTRQMAXLEN 51  /* max length of IPv6 netisr 
queue */
+#defineIPV6CTL_INTRDQMAXLEN52  /* max length of direct IPv6 
netisr
+* queue */
+#defineIPV6CTL_MAXID   53
 #endif /* __BSD_VISIBLE */
 
 /*

Modified: head/sys/netinet6/ip6_input.c
==
--- head/sys/netinet6/ip6_input.c   Fri Jul 15 16:37:36 2016
(r302905)
+++ head/sys/netinet6/ip6_input.c   Fri Jul 15 17:09:30 2016
(r302906)
@@ -86,6 +86,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -145,6 +146,24 @@ static struct netisr_handler ip6_nh = {
 #endif
 };
 
+static int
+sysctl_netinet6_intr_queue_maxlen(SYSCTL_HANDLER_ARGS)
+{
+   int error, qlimit;
+
+   netisr_getqlimit(&ip6_nh, &qlimit);
+   error = sysctl_handle_int(oidp, &qlimit, 0, req);
+   if (error || !req->newptr)
+   return (error);
+   if (qlimit < 1)
+   return (EINVAL);
+   return (netisr_setqlimit(&ip6_nh, qlimit));
+}
+SYSCTL_DECL(_net_inet6_ip6);
+SYSCTL_PROC(_net_inet6_ip6, IPV6CTL_INTRQMAXLEN, intr_queue_maxlen,
+CTLTYPE_INT|CTLFLAG_RW, 0, 0, sysctl_netinet6_intr_queue_maxlen, "I",
+"Maximum size of the IPv6 input queue");
+
 #ifdef RSS
 static struct netisr_handler ip6_direct_nh = {
.nh_name = "ip6_direct",
@@ -154,6 +173,24 @@ static struct netisr_handler ip6_direct_
.nh_policy = NETISR_POLICY_CPU,
.nh_dispatch = NETISR_DISPATCH_HYBRID,
 };
+
+static int
+sysctl_netinet6_intr_direct_queue_maxlen(SYSCTL_HANDLER_ARGS)
+{
+   int error, qlimit;
+
+   netisr_getqlimit(&ip6_direct_nh, &qlimit);
+   error = sysctl_handle_int(oidp, &qlimit, 0, req);
+   if (error || !req->newptr)
+   return (error);
+   if (qlimit < 1)
+   return (EINVAL);
+   return (netisr_setqlimit(&ip6_direct_nh, qlimit));
+}
+SYSCTL_PROC(_net_inet6_ip6, IPV6CTL_INTRDQMAXLEN, intr_direct_queue_maxlen,
+CTLTYPE_INT|CTLFLAG_RW, 0, 0, sysctl_netinet6_intr_direct_queue_maxlen,
+"I", "Maximum size of the IPv6 direct input queue");
+
 #endif
 
 VNET_DEFINE(struct pfil_head, inet6_pfil_hook);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302907 - head/usr.bin/netstat

2016-07-15 Thread Michael Tuexen
Author: tuexen
Date: Fri Jul 15 17:40:34 2016
New Revision: 302907
URL: https://svnweb.freebsd.org/changeset/base/302907

Log:
  When calling netstat -Laptcp the local address values are not aligned
  with the corresponding entry in the table header.
  r295136 increased the value width from 14 to 32 without the corresponding
  change to the table header. This commit adds the change to the table
  header width.
  
  MFC after:3 days

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

Modified: head/usr.bin/netstat/inet.c
==
--- head/usr.bin/netstat/inet.c Fri Jul 15 17:09:30 2016(r302906)
+++ head/usr.bin/netstat/inet.c Fri Jul 15 17:40:34 2016(r302907)
@@ -418,10 +418,10 @@ protopr(u_long off, const char *name, in
"Tcpcb");
if (Lflag)
xo_emit((Aflag && !Wflag) ?
-   "{T:/%-5.5s} {T:/%-14.14s} {T:/%-18.18s}" :
+   "{T:/%-5.5s} {T:/%-32.32s} {T:/%-18.18s}" :
((!Wflag || af1 == AF_INET) ?
-   "{T:/%-5.5s} {T:/%-14.14s} {T:/%-22.22s}" :
-   "{T:/%-5.5s} {T:/%-14.14s} {T:/%-45.45s}"),
+   "{T:/%-5.5s} {T:/%-32.32s} {T:/%-22.22s}" :
+   "{T:/%-5.5s} {T:/%-32.32s} {T:/%-45.45s}"),
"Proto", "Listen", "Local Address");
else if (Tflag)
xo_emit((Aflag && !Wflag) ?
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302908 - head/libexec/rtld-elf

2016-07-15 Thread Bryan Drewery
Author: bdrewery
Date: Fri Jul 15 19:07:00 2016
New Revision: 302908
URL: https://svnweb.freebsd.org/changeset/base/302908

Log:
  Fix dlsym(RTLD_NEXT) handling to only return the next library in last library 
cases.
  
  The root of the problem here is that TAILQ_FOREACH_FROM will default to
  the head of the list if passed NULL, which will be the case if there are
  no libraries loaded after this one.  Thus all libraries, including the
  current, were iterated in that case rather than none.
  
  This was broken in r294373.
  
  Reviewed by:  markj (earlier version), cem, kib, ngie
  MFC after:1 week
  Sponsored by: EMC / Isilon Storage Division
  Differential Revision:https://reviews.freebsd.org/D7216

Modified:
  head/libexec/rtld-elf/rtld.c

Modified: head/libexec/rtld-elf/rtld.c
==
--- head/libexec/rtld-elf/rtld.cFri Jul 15 17:40:34 2016
(r302907)
+++ head/libexec/rtld-elf/rtld.cFri Jul 15 19:07:00 2016
(r302908)
@@ -3291,7 +3291,7 @@ do_dlsym(void *handle, const char *name,
   handle == RTLD_SELF) { /* ... caller included */
if (handle == RTLD_NEXT)
obj = globallist_next(obj);
-   TAILQ_FOREACH_FROM(obj, &obj_list, next) {
+   for (; obj != NULL; obj = TAILQ_NEXT(obj, next)) {
if (obj->marker)
continue;
res = symlook_obj(&req, obj);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302909 - stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace

2016-07-15 Thread Mark Johnston
Author: markj
Date: Fri Jul 15 19:10:32 2016
New Revision: 302909
URL: https://svnweb.freebsd.org/changeset/base/302909

Log:
  MFC r302507:
  Avoid truncating the return value of DTrace predicates.

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c   Fri Jul 
15 19:07:00 2016(r302908)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c   Fri Jul 
15 19:10:32 2016(r302909)
@@ -7288,7 +7288,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t a
 
if (pred != NULL) {
dtrace_difo_t *dp = pred->dtp_difo;
-   int rval;
+   uint64_t rval;
 
rval = dtrace_dif_emulate(dp, &mstate, vstate, state);
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r302782 - in head/sys: dev/acpica i386/isa

2016-07-15 Thread Bruce Evans

On Fri, 15 Jul 2016, Warner Losh wrote:


On Fri, Jul 15, 2016 at 9:09 AM, Bruce Evans  wrote:

pmtimer is in i386's GENERIC, but this is probably not needed now


I think it's time to relegate pmtimer to the apm power stuff and make sure that
ACPI has the right hooks to do anything it currently isn't doing
correctly. pmtimer
was originally written for apm and was never really brought forward into the
ACPI era...


I thought that pmtimer was only for apm.  Since it not mentioned in
any man page, it is not clear what it is for.  However, it is documented
in i386/conf/NOTES as "Adjust system timer at wakeup time".  According
to that, it is a bug for acpi to do its own adjustment and not use
pmtimer.  However, pmtimer only exists on i386 with isa and it doesn't
actually adjust _the_ system timer there or have any dependencies on
i386 or isa except for foot shooting.  What it actually does is:
- restore all hardware timers using blind calls between dummy device
  drivers.  This is broken if an attached driver calls an unattached
  one, but usually on x86, all the drivers are attached so this reduces
  to spelling boolean true using only 100-200 lines of driver code.
  The i386 and isa dependencies in pm are only needed to spell true
  there.  This spelling of true depends on i386 requiring isa.  That
  is: true := isa_parent_is_attached().
- restore the system (software) timer using MI code
- try to fix up callups using broken ifdefed out MI code.

The recent commit makes the comment not match the code in another way.
Now the conditon for using pmtimer is 'if (true || !acpi_is_attached())'.

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


svn commit: r302910 - stable/9/sys/cddl/contrib/opensolaris/uts/common/dtrace

2016-07-15 Thread Mark Johnston
Author: markj
Date: Fri Jul 15 19:14:28 2016
New Revision: 302910
URL: https://svnweb.freebsd.org/changeset/base/302910

Log:
  MFC r302507:
  Avoid truncating the return value of DTrace predicates.

Modified:
  stable/9/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
Directory Properties:
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)

Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
==
--- stable/9/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.cFri Jul 
15 19:10:32 2016(r302909)
+++ stable/9/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.cFri Jul 
15 19:14:28 2016(r302910)
@@ -6336,7 +6336,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t a
 
if (pred != NULL) {
dtrace_difo_t *dp = pred->dtp_difo;
-   int rval;
+   uint64_t rval;
 
rval = dtrace_dif_emulate(dp, &mstate, vstate, state);
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302911 - head/usr.bin/mail

2016-07-15 Thread Pedro F. Giffuni
Author: pfg
Date: Fri Jul 15 19:43:24 2016
New Revision: 302911
URL: https://svnweb.freebsd.org/changeset/base/302911

Log:
  mail(1): Avoid closing negative file descriptors.
  
  CID:  1008105, 1008106
  MFC after:1 week

Modified:
  head/usr.bin/mail/quit.c
  head/usr.bin/mail/v7.local.c

Modified: head/usr.bin/mail/quit.c
==
--- head/usr.bin/mail/quit.cFri Jul 15 19:14:28 2016(r302910)
+++ head/usr.bin/mail/quit.cFri Jul 15 19:43:24 2016(r302911)
@@ -228,7 +228,8 @@ quit(void)
return;
}
(void)Fclose(obuf);
-   (void)close(open(mbox, O_CREAT | O_TRUNC | O_WRONLY, 0600));
+   if ((fd = open(mbox, O_CREAT | O_TRUNC | O_WRONLY, 0600)) >= 0)
+   (void)close(fd);
if ((obuf = Fopen(mbox, "r+")) == NULL) {
warn("%s", mbox);
(void)Fclose(ibuf);

Modified: head/usr.bin/mail/v7.local.c
==
--- head/usr.bin/mail/v7.local.cFri Jul 15 19:14:28 2016
(r302910)
+++ head/usr.bin/mail/v7.local.cFri Jul 15 19:43:24 2016
(r302911)
@@ -68,9 +68,12 @@ findmail(char *user, char *buf, int bufl
 void
 demail(void)
 {
+   int fd;
 
if (value("keep") != NULL || rm(mailname) < 0)
-   (void)close(open(mailname, O_CREAT | O_TRUNC | O_WRONLY, 0600));
+   if ((fd = open(mailname, O_CREAT | O_TRUNC | O_WRONLY, 0600)) >=
+   0)
+   (void)close(fd);
 }
 
 /*
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302912 - in stable/11/usr.sbin: etcupdate mergemaster

2016-07-15 Thread Bryan Drewery
Author: bdrewery
Date: Fri Jul 15 19:58:05 2016
New Revision: 302912
URL: https://svnweb.freebsd.org/changeset/base/302912

Log:
  MFC r302674:
  
META_MODE: Don't require filemon(4) for mergemaster(8)/etcupdate(8)
  
  Approved by:  re (gjb)

Modified:
  stable/11/usr.sbin/etcupdate/etcupdate.sh
  stable/11/usr.sbin/mergemaster/mergemaster.sh
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/etcupdate/etcupdate.sh
==
--- stable/11/usr.sbin/etcupdate/etcupdate.sh   Fri Jul 15 19:43:24 2016
(r302911)
+++ stable/11/usr.sbin/etcupdate/etcupdate.sh   Fri Jul 15 19:58:05 2016
(r302912)
@@ -184,7 +184,7 @@ build_tree()
 {
local destdir dir file make
 
-   make="make $MAKE_OPTIONS"
+   make="make $MAKE_OPTIONS -DNO_FILEMON"
 
log "Building tree at $1 with $make"
mkdir -p $1/usr/obj >&3 2>&1

Modified: stable/11/usr.sbin/mergemaster/mergemaster.sh
==
--- stable/11/usr.sbin/mergemaster/mergemaster.sh   Fri Jul 15 19:43:24 
2016(r302911)
+++ stable/11/usr.sbin/mergemaster/mergemaster.sh   Fri Jul 15 19:58:05 
2016(r302912)
@@ -486,7 +486,7 @@ fi
 SOURCEDIR=$(realpath "$SOURCEDIR")
 
 # Setup make to use system files from SOURCEDIR
-MM_MAKE="make ${ARCHSTRING} -m ${SOURCEDIR}/share/mk"
+MM_MAKE="make ${ARCHSTRING} -m ${SOURCEDIR}/share/mk -DNO_FILEMON"
 
 # Check DESTDIR against the mergemaster mtree database to see what
 # files the user changed from the reference files.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2016-07-15 Thread Ngie Cooper
On Fri, Jul 15, 2016 at 8:32 AM, John Baldwin  wrote:
> Author: jhb
> Date: Fri Jul 15 15:32:09 2016
> New Revision: 302902
> URL: https://svnweb.freebsd.org/changeset/base/302902
>
> Log:
>   Add a mask of optional ptrace() events.
>
>   ptrace() now stores a mask of optional events in p_ptevents.  Currently
>   this mask is a single integer, but it can be expanded into an array of
>   integers in the future.
>
>   Two new ptrace requests can be used to manipulate the event mask:
>   PT_GET_EVENT_MASK fetches the current event mask and PT_SET_EVENT_MASK
>   sets the current event mask.
>
>   The current set of events include:
>   - PTRACE_EXEC: trace calls to execve().
>   - PTRACE_SCE: trace system call entries.
>   - PTRACE_SCX: trace syscam call exits.
>   - PTRACE_FORK: trace forks and auto-attach to new child processes.
>   - PTRACE_LWP: trace LWP events.
>
>   The S_PT_SCX and S_PT_SCE events in the procfs p_stops flags have
>   been replaced by PTRACE_SCE and PTRACE_SCX.  PTRACE_FORK replaces
>   P_FOLLOW_FORK and PTRACE_LWP replaces P2_LWP_EVENTS.
>
>   The PT_FOLLOW_FORK and PT_LWP_EVENTS ptrace requests remain for
>   compatibility but now simply toggle corresponding flags in the
>   event mask.
>
>   While here, document that PT_SYSCALL, PT_TO_SCE, and PT_TO_SCX both
>   modify the event mask and continue the traced process.
>
>   Reviewed by:  kib
>   MFC after:1 month
>   Differential Revision:https://reviews.freebsd.org/D7044

This broke linux(4): https://jenkins.freebsd.org/job/FreeBSD_HEAD_i386/3597/ .
Thanks,
-Ngie
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302913 - stable/11/sys/cddl/contrib/opensolaris/uts/common/dtrace

2016-07-15 Thread Mark Johnston
Author: markj
Date: Fri Jul 15 20:26:28 2016
New Revision: 302913
URL: https://svnweb.freebsd.org/changeset/base/302913

Log:
  MFC r302507:
  Avoid truncating the return value of DTrace predicates.
  
  Approved by:  re (gjb)

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c   Fri Jul 
15 19:58:05 2016(r302912)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c   Fri Jul 
15 20:26:28 2016(r302913)
@@ -7348,7 +7348,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t a
 
if (pred != NULL) {
dtrace_difo_t *dp = pred->dtp_difo;
-   int rval;
+   uint64_t rval;
 
rval = dtrace_dif_emulate(dp, &mstate, vstate, state);
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302914 - head/usr.bin/mail

2016-07-15 Thread Pedro F. Giffuni
Author: pfg
Date: Fri Jul 15 20:27:21 2016
New Revision: 302914
URL: https://svnweb.freebsd.org/changeset/base/302914

Log:
  mail(1): Minor declaration updates.
  
  Missing from r302903.

Modified:
  head/usr.bin/mail/util.c

Modified: head/usr.bin/mail/util.c
==
--- head/usr.bin/mail/util.cFri Jul 15 20:26:28 2016(r302913)
+++ head/usr.bin/mail/util.cFri Jul 15 20:27:21 2016(r302914)
@@ -214,7 +214,7 @@ gethfield(FILE *f, char linebuf[], int r
  */
 
 char*
-ishfield(char linebuf[], char *colon, const char *field)
+ishfield(char *linebuf, char *colon, const char *field)
 {
char *cp = colon;
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302915 - in stable/11/sys/arm: conf lpc samsung/exynos

2016-07-15 Thread Ian Lepore
Author: ian
Date: Fri Jul 15 21:30:19 2016
New Revision: 302915
URL: https://svnweb.freebsd.org/changeset/base/302915

Log:
  MFC r302502, r302505:
  
Consolidate debugging options from all arm kernel configs to std.arm[v6].
  
Correct syntax errors that only show up when compiled with INVARIANTS.
  
  Approved by:  re (gjb)

Modified:
  stable/11/sys/arm/conf/A10
  stable/11/sys/arm/conf/ALLWINNER
  stable/11/sys/arm/conf/ALPINE
  stable/11/sys/arm/conf/AML8726
  stable/11/sys/arm/conf/ARMADA38X
  stable/11/sys/arm/conf/ARMADAXP
  stable/11/sys/arm/conf/ATMEL
  stable/11/sys/arm/conf/AVILA
  stable/11/sys/arm/conf/BEAGLEBONE
  stable/11/sys/arm/conf/BWCT
  stable/11/sys/arm/conf/CAMBRIA
  stable/11/sys/arm/conf/CNS11XXNAS
  stable/11/sys/arm/conf/CRB
  stable/11/sys/arm/conf/DB-78XXX
  stable/11/sys/arm/conf/DB-88F5XXX
  stable/11/sys/arm/conf/DB-88F6XXX
  stable/11/sys/arm/conf/DOCKSTAR
  stable/11/sys/arm/conf/DREAMPLUG-1001
  stable/11/sys/arm/conf/EA3250
  stable/11/sys/arm/conf/EB9200
  stable/11/sys/arm/conf/EFIKA_MX
  stable/11/sys/arm/conf/ETHERNUT5
  stable/11/sys/arm/conf/EXYNOS5.common
  stable/11/sys/arm/conf/GUMSTIX
  stable/11/sys/arm/conf/HL200
  stable/11/sys/arm/conf/HL201
  stable/11/sys/arm/conf/IMX53
  stable/11/sys/arm/conf/IMX6
  stable/11/sys/arm/conf/KB920X
  stable/11/sys/arm/conf/NSLU
  stable/11/sys/arm/conf/PANDABOARD
  stable/11/sys/arm/conf/QILA9G20
  stable/11/sys/arm/conf/RK3188
  stable/11/sys/arm/conf/RPI-B
  stable/11/sys/arm/conf/RPI2
  stable/11/sys/arm/conf/SAM9260EK
  stable/11/sys/arm/conf/SAM9G20EK
  stable/11/sys/arm/conf/SAM9X25EK
  stable/11/sys/arm/conf/SHEEVAPLUG
  stable/11/sys/arm/conf/SN9G45
  stable/11/sys/arm/conf/SOCKIT.common
  stable/11/sys/arm/conf/TEGRA124
  stable/11/sys/arm/conf/TS7800
  stable/11/sys/arm/conf/VERSATILEPB
  stable/11/sys/arm/conf/VIRT
  stable/11/sys/arm/conf/VYBRID
  stable/11/sys/arm/conf/ZEDBOARD
  stable/11/sys/arm/conf/std.arm
  stable/11/sys/arm/conf/std.armv6
  stable/11/sys/arm/lpc/if_lpe.c
  stable/11/sys/arm/samsung/exynos/chrome_kb.c

Modified: stable/11/sys/arm/conf/A10
==
--- stable/11/sys/arm/conf/A10  Fri Jul 15 20:27:21 2016(r302914)
+++ stable/11/sys/arm/conf/A10  Fri Jul 15 21:30:19 2016(r302915)
@@ -32,21 +32,6 @@ options  SCHED_4BSD  # 4BSD scheduler
 optionsPLATFORM
 optionsMULTIDELAY
 
-# Debugging for use in -current
-makeoptionsDEBUG=-g# Build kernel with gdb(1) debug symbols
-optionsALT_BREAK_TO_DEBUGGER
-#options   VERBOSE_SYSINIT # Enable verbose sysinit messages
-optionsKDB # Enable kernel debugger support
-# For minimum debugger support (stable branch) use:
-#options   KDB_TRACE   # Print a stack trace for a panic
-# For full debugger support use this instead:
-optionsDDB # Enable the kernel debugger
-optionsINVARIANTS  # Enable calls of extra sanity checking
-optionsINVARIANT_SUPPORT   # Extra sanity checks of internal 
structures, required by INVARIANTS
-optionsWITNESS # Enable checks to detect deadlocks and 
cycles
-optionsWITNESS_SKIPSPIN# Don't run witness on spinlocks for 
speed
-#options   DIAGNOSTIC
-
 # NFS root from boopt/dhcp
 #options   BOOTP
 #options   BOOTP_NFSROOT
@@ -94,9 +79,6 @@ devicepass# Passthrough 
device (dir
 # USB support
 optionsUSB_HOST_ALIGN=64   # Align usb buffers to cache line size.
 device usb
-optionsUSB_DEBUG
-#options   USB_REQ_DEBUG
-#options   USB_VERBOSE
 #deviceuhci
 device ohci
 device ehci

Modified: stable/11/sys/arm/conf/ALLWINNER
==
--- stable/11/sys/arm/conf/ALLWINNERFri Jul 15 20:27:21 2016
(r302914)
+++ stable/11/sys/arm/conf/ALLWINNERFri Jul 15 21:30:19 2016
(r302915)
@@ -39,21 +39,6 @@ options  PLATFORM
 optionsPLATFORM_SMP
 optionsMULTIDELAY
 
-# Debugging for use in -current
-makeoptionsDEBUG=-g# Build kernel with gdb(1) debug symbols
-optionsALT_BREAK_TO_DEBUGGER
-#options   VERBOSE_SYSINIT # Enable verbose sysinit messages
-optionsKDB # Enable kernel debugger support
-# For minimum debugger support (stable branch) use:
-#options   KDB_TRACE   # Print a stack trace for a panic
-# For full debugger support use this instead:
-optionsDDB # Enable the kernel debugger
-optionsINVARIANTS  # Enable calls of extra sanity checking
-optionsINVARIANT_SUPPORT   # Extra sanity checks of internal 
structures, required by INVARIANTS
-optionsWITNESS # Enable c

svn commit: r302916 - head/lib/libc/locale

2016-07-15 Thread Baptiste Daroussin
Author: bapt
Date: Fri Jul 15 23:03:20 2016
New Revision: 302916
URL: https://svnweb.freebsd.org/changeset/base/302916

Log:
  Revert 302324 and properly fix the crash with ISO-8859-5 locales
  
  PR:   211135
  Reported by:  jkim
  Tested by:jkim
  MFC after:2 days

Modified:
  head/lib/libc/locale/collate.c

Modified: head/lib/libc/locale/collate.c
==
--- head/lib/libc/locale/collate.c  Fri Jul 15 21:30:19 2016
(r302915)
+++ head/lib/libc/locale/collate.c  Fri Jul 15 23:03:20 2016
(r302916)
@@ -310,7 +310,7 @@ _collate_lookup(struct xlocale_collate *
if ((sptr = *state) != NULL) {
*pri = *sptr;
sptr++;
-   if ((sptr == *state) || (*sptr == 0))
+   if ((sptr == *state) || (sptr == NULL))
*state = NULL;
else
*state = sptr;
@@ -451,6 +451,7 @@ _collate_wxfrm(struct xlocale_collate *t
errno = EINVAL;
goto fail;
}
+   state = NULL;
pri = COLLATE_MAX_PRIORITY;
}
if (room) {
@@ -469,6 +470,7 @@ _collate_wxfrm(struct xlocale_collate *t
errno = EINVAL;
goto fail;
}
+   state = NULL;
continue;
}
if (room) {
@@ -597,6 +599,7 @@ _collate_sxfrm(struct xlocale_collate *t
errno = EINVAL;
goto fail;
}
+   state = NULL;
pri = COLLATE_MAX_PRIORITY;
}
 
@@ -622,6 +625,7 @@ _collate_sxfrm(struct xlocale_collate *t
errno = EINVAL;
goto fail;
}
+   state = NULL;
continue;
}
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302917 - head/usr.bin/netstat

2016-07-15 Thread Michael Tuexen
Author: tuexen
Date: Fri Jul 15 23:13:57 2016
New Revision: 302917
URL: https://svnweb.freebsd.org/changeset/base/302917

Log:
  Ensure that the -a, -W, -L options for SCTP behave similar
  as for 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 Fri Jul 15 23:03:20 2016(r302916)
+++ head/usr.bin/netstat/sctp.c Fri Jul 15 23:13:57 2016(r302917)
@@ -447,7 +447,8 @@ sctp_process_inpcb(struct xsctp_inpcb *x
first = 0;
}
xladdr = (struct xsctp_laddr *)(buf + *offset);
-   if (Lflag && !is_listening) {
+   if ((!aflag && is_listening) ||
+   (Lflag && !is_listening)) {
sctp_skip_xinpcb_ifneed(buf, buflen, offset);
return;
}
@@ -513,8 +514,10 @@ retry:
xo_open_instance("local-address");
 
if (xladdr_total == 0) {
-   xo_emit("{:protocol/%-6.6s/%s} {:type/%-5.5s/%s} ",
-   pname, tname);
+   if (!Lflag) {
+   xo_emit("{:protocol/%-6.6s/%s} "
+   "{:type/%-5.5s/%s} ", pname, tname);
+   }
} else {
xo_emit("\n");
xo_emit(Lflag ? "{P:/%-21.21s} " : "{P:/%-12.12s} ",
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302918 - head/lib/libc/tests/string

2016-07-15 Thread Baptiste Daroussin
Author: bapt
Date: Fri Jul 15 23:24:00 2016
New Revision: 302918
URL: https://svnweb.freebsd.org/changeset/base/302918

Log:
  Add a regression test about the crash with strxfrm and ISO8859-5 locales

Added:
  head/lib/libc/tests/string/strxfrm_test.c   (contents, props changed)
Modified:
  head/lib/libc/tests/string/Makefile

Modified: head/lib/libc/tests/string/Makefile
==
--- head/lib/libc/tests/string/Makefile Fri Jul 15 23:13:57 2016
(r302917)
+++ head/lib/libc/tests/string/Makefile Fri Jul 15 23:24:00 2016
(r302918)
@@ -5,6 +5,7 @@ ATF_TESTS_C+=   stpncpy_test
 ATF_TESTS_C+=  strerror2_test
 ATF_TESTS_C+=  wcscasecmp_test
 ATF_TESTS_C+=  wcsnlen_test
+ATF_TESTS_C+=  strxfrm_test
 
 # TODO: popcount, stresep
 

Added: head/lib/libc/tests/string/strxfrm_test.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libc/tests/string/strxfrm_test.c   Fri Jul 15 23:24:00 2016
(r302918)
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 2016 Baptiste Daroussin 
+ * 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.
+ * 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 
+
+ATF_TC_WITHOUT_HEAD(iso_8859_5);
+ATF_TC_BODY(iso_8859_5, tc)
+{
+   char s1[8];
+   const char s2[] = { 0xa1, 0 };
+
+   setlocale(LC_ALL, "ru_RU.ISO8859-5");
+   strxfrm(s1, s2, 0x8);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+   ATF_TP_ADD_TC(tp, iso_8859_5);
+
+   return (atf_no_error());
+}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302919 - head/sys/kern

2016-07-15 Thread Konstantin Belousov
Author: kib
Date: Fri Jul 15 23:26:33 2016
New Revision: 302919
URL: https://svnweb.freebsd.org/changeset/base/302919

Log:
  In ptrace_vm_entry(), do not call vmspace_free() while owning a vm
  object lock.
  
  The vmspace_free() operations might need to lock map, object etc on
  last dereference.  Postpone the free until object's inspection is
  done.
  
  Reported and tested by:   will
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/kern/sys_process.c

Modified: head/sys/kern/sys_process.c
==
--- head/sys/kern/sys_process.c Fri Jul 15 23:24:00 2016(r302918)
+++ head/sys/kern/sys_process.c Fri Jul 15 23:26:33 2016(r302919)
@@ -433,7 +433,6 @@ ptrace_vm_entry(struct thread *td, struc
} while (0);
 
vm_map_unlock_read(map);
-   vmspace_free(vm);
 
pve->pve_fsid = VNOVAL;
pve->pve_fileid = VNOVAL;
@@ -478,6 +477,7 @@ ptrace_vm_entry(struct thread *td, struc
free(freepath, M_TEMP);
}
}
+   vmspace_free(vm);
if (error == 0)
CTR3(KTR_PTRACE, "PT_VM_ENTRY: pid %d, entry %d, start %p",
p->p_pid, pve->pve_entry, pve->pve_start);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302920 - head/lib/libc/tests/string

2016-07-15 Thread Baptiste Daroussin
Author: bapt
Date: Fri Jul 15 23:43:23 2016
New Revision: 302920
URL: https://svnweb.freebsd.org/changeset/base/302920

Log:
  Add a regression test to make sure the Russian collation is actually working
  
  when importing collation support from Dragonfly/Illumos amdmi3@ tested the
  collation branch and reported an issue with Russian collation. John Marino 
fixed
  the issue in Dragonfly and I merged it back to FreeBSD.
  
  Now that Illumos is working on merging our fixes they (Lauri Tirkkonen) found
  issues with the commit that fixes the russian collation in UTF-8 that resulted
  in a crash with strxfrm(3) and the ISO-8859-5 locale (fixed in FreeBSD 
r302916).
  This small test was written to ensure we do not bring back the old issue with
  russian collation while fixing the other issue.

Added:
  head/lib/libc/tests/string/wcscoll_test.c   (contents, props changed)
Modified:
  head/lib/libc/tests/string/Makefile

Modified: head/lib/libc/tests/string/Makefile
==
--- head/lib/libc/tests/string/Makefile Fri Jul 15 23:26:33 2016
(r302919)
+++ head/lib/libc/tests/string/Makefile Fri Jul 15 23:43:23 2016
(r302920)
@@ -6,6 +6,7 @@ ATF_TESTS_C+=   strerror2_test
 ATF_TESTS_C+=  wcscasecmp_test
 ATF_TESTS_C+=  wcsnlen_test
 ATF_TESTS_C+=  strxfrm_test
+ATF_TESTS_C+=  wcscoll_test
 
 # TODO: popcount, stresep
 

Added: head/lib/libc/tests/string/wcscoll_test.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libc/tests/string/wcscoll_test.c   Fri Jul 15 23:43:23 2016
(r302920)
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2016 Baptiste Daroussin 
+ * 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.
+ * 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 
+
+static int
+cmp(const void *a, const void *b)
+{
+   const wchar_t wa[2] = { *(const wchar_t *)a, 0 };
+   const wchar_t wb[2] = { *(const wchar_t *)b, 0 };
+
+   return (wcscoll(wa, wb));
+}
+
+ATF_TC_WITHOUT_HEAD(russian_collation);
+ATF_TC_BODY(russian_collation, tc)
+{
+   wchar_t c[] = 
L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzЁАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяё";
+   wchar_t res[] = 
L"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZаАбБвВгГдДеЕёЁжЖзЗиИйЙкКлЛмМнНоОпПрРсСтТуУфФхХцЦчЧшШщЩъЪыЫьЬэЭюЮяЯ";
+
+   ATF_CHECK_MSG(setlocale(LC_ALL, "ru_RU.UTF-8") != NULL,
+   "Fail to set locale to \"ru_RU.UTF-8\"");
+   qsort(c, wcslen(c), sizeof(wchar_t), cmp);
+   ATF_CHECK_MSG(wcscmp(c, res) == 0,
+   "Bad collation, expected: '%ls' got '%ls'", res, c);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+   ATF_TP_ADD_TC(tp, russian_collation);
+
+   return (atf_no_error());
+}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

svn commit: r302921 - head/sys/i386/linux

2016-07-15 Thread John Baldwin
Author: jhb
Date: Sat Jul 16 00:54:46 2016
New Revision: 302921
URL: https://svnweb.freebsd.org/changeset/base/302921

Log:
  Rename PTRACE_SYSCALL to LINUX_PTRACE_SYSCALL.
  
  Suggested by: kib

Modified:
  head/sys/i386/linux/linux_ptrace.c

Modified: head/sys/i386/linux/linux_ptrace.c
==
--- head/sys/i386/linux/linux_ptrace.c  Fri Jul 15 23:43:23 2016
(r302920)
+++ head/sys/i386/linux/linux_ptrace.c  Sat Jul 16 00:54:46 2016
(r302921)
@@ -69,7 +69,7 @@ __FBSDID("$FreeBSD$");
 #define PTRACE_ATTACH  16
 #define PTRACE_DETACH  17
 
-#definePTRACE_SYSCALL  24
+#defineLINUX_PTRACE_SYSCALL24
 
 #define PTRACE_GETREGS 12
 #define PTRACE_SETREGS 13
@@ -473,7 +473,7 @@ linux_ptrace(struct thread *td, struct l
 
break;
}
-   case PTRACE_SYSCALL:
+   case LINUX_PTRACE_SYSCALL:
/* fall through */
default:
printf("linux: ptrace(%u, ...) not implemented\n",
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302922 - stable/10/sys/vm

2016-07-15 Thread Mark Johnston
Author: markj
Date: Sat Jul 16 02:47:56 2016
New Revision: 302922
URL: https://svnweb.freebsd.org/changeset/base/302922

Log:
  MFC r301210:
  Don't preserve the page's object linkage in vm_page_insert_after().

Modified:
  stable/10/sys/vm/vm_page.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/vm/vm_page.c
==
--- stable/10/sys/vm/vm_page.c  Sat Jul 16 00:54:46 2016(r302921)
+++ stable/10/sys/vm/vm_page.c  Sat Jul 16 02:47:56 2016(r302922)
@@ -981,8 +981,6 @@ static int
 vm_page_insert_after(vm_page_t m, vm_object_t object, vm_pindex_t pindex,
 vm_page_t mpred)
 {
-   vm_pindex_t sidx;
-   vm_object_t sobj;
vm_page_t msucc;
 
VM_OBJECT_ASSERT_WLOCKED(object);
@@ -1003,8 +1001,6 @@ vm_page_insert_after(vm_page_t m, vm_obj
/*
 * Record the object/offset pair in this page
 */
-   sobj = m->object;
-   sidx = m->pindex;
m->object = object;
m->pindex = pindex;
 
@@ -1012,8 +1008,8 @@ vm_page_insert_after(vm_page_t m, vm_obj
 * Now link into the object's ordered list of backed pages.
 */
if (vm_radix_insert(&object->rtree, m)) {
-   m->object = sobj;
-   m->pindex = sidx;
+   m->object = NULL;
+   m->pindex = 0;
return (1);
}
vm_page_insert_radixdone(m, object, mpred);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302923 - stable/10/sys/vm

2016-07-15 Thread Mark Johnston
Author: markj
Date: Sat Jul 16 02:49:02 2016
New Revision: 302923
URL: https://svnweb.freebsd.org/changeset/base/302923

Log:
  MFC r301212:
  Reset the page busy lock state after failing to insert into the object.

Modified:
  stable/10/sys/vm/vm_page.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/vm/vm_page.c
==
--- stable/10/sys/vm/vm_page.c  Sat Jul 16 02:47:56 2016(r302922)
+++ stable/10/sys/vm/vm_page.c  Sat Jul 16 02:49:02 2016(r302923)
@@ -1636,6 +1636,7 @@ vm_page_alloc(vm_object_t object, vm_pin
}
m->object = NULL;
m->oflags = VPO_UNMANAGED;
+   m->busy_lock = VPB_UNBUSIED;
vm_page_free(m);
return (NULL);
}
@@ -1838,6 +1839,7 @@ retry:
m->object = NULL;
m->oflags |= VPO_UNMANAGED;
}
+   m->busy_lock = VPB_UNBUSIED;
vm_page_free(m);
}
return (NULL);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302924 - stable/10/usr.bin/mkimg

2016-07-15 Thread Mark Johnston
Author: markj
Date: Sat Jul 16 02:53:52 2016
New Revision: 302924
URL: https://svnweb.freebsd.org/changeset/base/302924

Log:
  MFC r301090:
  mkimg: Indicate that input file pages are unlikely to be reused.

Modified:
  stable/10/usr.bin/mkimg/image.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.bin/mkimg/image.c
==
--- stable/10/usr.bin/mkimg/image.c Sat Jul 16 02:49:02 2016
(r302923)
+++ stable/10/usr.bin/mkimg/image.c Sat Jul 16 02:53:52 2016
(r302924)
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -315,6 +316,8 @@ image_file_unmap(void *buffer, size_t sz
 
unit = (secsz > image_swap_pgsz) ? secsz : image_swap_pgsz;
sz = (sz + unit - 1) & ~(unit - 1);
+   if (madvise(buffer, sz, MADV_DONTNEED) != 0)
+   warn("madvise");
munmap(buffer, sz);
return (0);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302925 - stable/10/sys/kern

2016-07-15 Thread Mark Johnston
Author: markj
Date: Sat Jul 16 02:55:02 2016
New Revision: 302925
URL: https://svnweb.freebsd.org/changeset/base/302925

Log:
  MFC r302346:
  Ensure that spinlock sections are balanced even after a panic.

Modified:
  stable/10/sys/kern/kern_mutex.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/kern_mutex.c
==
--- stable/10/sys/kern/kern_mutex.c Sat Jul 16 02:53:52 2016
(r302924)
+++ stable/10/sys/kern/kern_mutex.c Sat Jul 16 02:55:02 2016
(r302925)
@@ -658,8 +658,15 @@ thread_lock_flags_(struct thread *td, in
i = 0;
tid = (uintptr_t)curthread;
 
-   if (SCHEDULER_STOPPED())
+   if (SCHEDULER_STOPPED()) {
+   /*
+* Ensure that spinlock sections are balanced even when the
+* scheduler is stopped, since we may otherwise inadvertently
+* re-enable interrupts while dumping core.
+*/
+   spinlock_enter();
return;
+   }
 
 #ifdef KDTRACE_HOOKS
spin_time -= lockstat_nsecs(&td->td_lock->lock_object);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302926 - stable/10/sys/ofed/include/linux

2016-07-15 Thread Mark Johnston
Author: markj
Date: Sat Jul 16 02:57:37 2016
New Revision: 302926
URL: https://svnweb.freebsd.org/changeset/base/302926

Log:
  MFC r301877:
  Add a missing error check for a malloc() call in idr_get().

Modified:
  stable/10/sys/ofed/include/linux/linux_idr.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/ofed/include/linux/linux_idr.c
==
--- stable/10/sys/ofed/include/linux/linux_idr.cSat Jul 16 02:55:02 
2016(r302925)
+++ stable/10/sys/ofed/include/linux/linux_idr.cSat Jul 16 02:57:37 
2016(r302926)
@@ -267,7 +267,8 @@ idr_get(struct idr *idr)
return (il);
}
il = malloc(sizeof(*il), M_IDR, M_ZERO | M_NOWAIT);
-   bitmap_fill(&il->bitmap, IDR_SIZE);
+   if (il != NULL)
+   bitmap_fill(&il->bitmap, IDR_SIZE);
return (il);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302927 - stable/11/sys/netpfil/ipfw

2016-07-15 Thread Don Lewis
Author: truckman
Date: Sat Jul 16 06:41:02 2016
New Revision: 302927
URL: https://svnweb.freebsd.org/changeset/base/302927

Log:
  MFC r302667
  
  Fix problems in the FQ-PIE AQM cleanup code that could leak memory or
  cause a crash.
  
  Because dummynet calls pie_cleanup() while holding a mutex, pie_cleanup()
  is not able to use callout_drain() to make sure that all callouts are
  finished before it returns, and callout_stop() is not sufficient to make
  that guarantee.  After pie_cleanup() returns, dummynet will free a
  structure that any remaining callouts will want to access.
  
  Fix these problems by allocating a separate structure to contain the
  data used by the callouts.  In pie_cleanup(), call callout_reset_sbt()
  to replace the normal callout with a cleanup callout that does the cleanup
  work for each sub-queue.  The instance of the cleanup callout that
  destroys the last flow will also free the extra allocated block of memory.
  Protect the reference count manipulation in the cleanup callout with
  DN_BH_WLOCK() to be consistent with all of the other usage of the reference
  count where this lock is held by the dummynet code.
  
  Submitted by: Rasool Al-Saadi 
  Approved by:  re (gjb)
  Differential Revision:https://reviews.freebsd.org/D7174

Modified:
  stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.c
==
--- stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.cSat Jul 16 02:57:37 
2016(r302926)
+++ stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.cSat Jul 16 06:41:02 
2016(r302927)
@@ -111,7 +111,7 @@ struct fq_pie_flow {
int deficit;
int active; /* 1: flow is active (in a list) */
struct pie_status pst;  /* pie status variables */
-   struct fq_pie_si *psi;  /* parent scheduler instance */
+   struct fq_pie_si_extra *psi_extra;
STAILQ_ENTRY(fq_pie_flow) flowchain;
 };
 
@@ -120,23 +120,30 @@ struct fq_pie_schk {
struct dn_sch_fq_pie_parms cfg;
 };
 
+
+/* fq_pie scheduler instance extra state vars.
+ * The purpose of separation this structure is to preserve number of active
+ * sub-queues and the flows array pointer even after the scheduler instance
+ * is destroyed.
+ * Preserving these varaiables allows freeing the allocated memory by
+ * fqpie_callout_cleanup() independently from fq_pie_free_sched().
+ */
+struct fq_pie_si_extra {
+   uint32_t nr_active_q;   /* number of active queues */
+   struct fq_pie_flow *flows;  /* array of flows (queues) */
+   };
+
 /* fq_pie scheduler instance */
 struct fq_pie_si {
-   struct dn_sch_inst _si; /* standard scheduler instance */
+   struct dn_sch_inst _si; /* standard scheduler instance. SHOULD BE FIRST 
*/ 
struct dn_queue main_q; /* main queue is after si directly */
-   uint32_t nr_active_q;
-   struct fq_pie_flow *flows;  /* array of flows (queues) */
uint32_t perturbation;  /* random value */
struct fq_pie_list newflows;/* list of new queues */
struct fq_pie_list oldflows;/* list of old queues */
+   struct fq_pie_si_extra *si_extra; /* extra state vars*/
 };
 
 
-struct mem_to_free {
-   void *mem_flows;
-   void *mem_callout;
-};
-static struct mtx freemem_mtx;
 static struct dn_alg fq_pie_desc;
 
 /*  Default FQ-PIE parameters including PIE */
@@ -371,22 +378,6 @@ fq_calculate_drop_prob(void *x)
int64_t p, prob, oldprob;
aqm_time_t now;
 
-   /* dealing with race condition */
-   if (callout_pending(&pst->aqm_pie_callout)) {
-   /* callout was reset */
-   mtx_unlock(&pst->lock_mtx);
-   return;
-   }
-
-   if (!callout_active(&pst->aqm_pie_callout)) {
-   /* callout was stopped */
-   mtx_unlock(&pst->lock_mtx);
-   mtx_destroy(&pst->lock_mtx);
-   q->psi->nr_active_q--;
-   return;
-   }
-   callout_deactivate(&pst->aqm_pie_callout);
-
now = AQM_UNOW;
pprms = pst->parms;
prob = pst->drop_prob;
@@ -524,20 +515,17 @@ fq_deactivate_pie(struct pie_status *pst
   * Initialize PIE for sub-queue 'q'
   */
 static int
-pie_init(struct fq_pie_flow *q)
+pie_init(struct fq_pie_flow *q, struct fq_pie_schk *fqpie_schk)
 {
struct pie_status *pst=&q->pst;
struct dn_aqm_pie_parms *pprms = pst->parms;
-   struct fq_pie_schk *fqpie_schk;
-   
-   fqpie_schk = (struct fq_pie_schk *)(q->psi->_si.sched+1);
-   int err = 0;
 
+   int err = 0;
if (!pprms){
D("AQM_PIE is not configured");
err = EINVAL;
} else {
-   q->psi->nr_active_q++;
+   q->psi_extra->nr_active_q++;
 
/* For speed optimization, we caculate 1/3 queue size on