Re: svn commit: r326095 - head/usr.sbin/bsdinstall/scripts

2017-11-22 Thread Emmanuel Vadot

On 2017-11-22 17:38, Ian Lepore wrote:

On Wed, 2017-11-22 at 15:27 +, Emmanuel Vadot wrote:

Author: manu
Date: Wed Nov 22 15:27:47 2017
New Revision: 326095
URL: https://svnweb.freebsd.org/changeset/base/326095

Log:
  bsdinstall: Add ntpdate option
  
  When you install a computer for the first time, the date in the CMOS 
sometimes
  not accurate and you need to ntpdate as ntpd will fail a the time 
difference

  is too big.
  Add an option in bsdinstall to enable ntpdate that will do that for 
us.

  
  Reviewed by:  allanjude
  Differential Revision:https://reviews.freebsd.org/D13149

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

Modified: head/usr.sbin/bsdinstall/scripts/services
==
--- head/usr.sbin/bsdinstall/scripts/services	Wed Nov 22 15:18:11 
2017	(r326094)
+++ head/usr.sbin/bsdinstall/scripts/services	Wed Nov 22 15:27:47 
2017	(r326095)

@@ -46,6 +46,8 @@ DAEMONS=$( dialog --backtitle "FreeBSD Installer" \
 	local_unbound "Local caching validating resolver" 
${local_unbound:-off} \

    sshd"Secure shell daemon" ${sshd_enable:-off} \
    moused  "PS/2 mouse pointer on console" ${moused_enable:-off} \
+   ntpdate "Synchronize system and network time at bootime" \
+   ${ntpdate_enable:-off} \
    ntpd"Synchronize system and network time" ${ntpd_enable:-off} \
    powerd  "Adjust CPU frequency dynamically if supported" \
    ${powerd_enable:-off} \



The right way to enable a time-step at boot is to set the rc conf
variable ntpd_sync_on_start to YES.  ntpdate has been deprecated for
*years*.

-- Ian


 Hi Ian,

 Thanks I didn't know about option -g (nor ntpd_sync_on_start), this 
bring a few questions :


 - Is there any reason to not always use -g for ntpd ? As a lambda user 
I just want my time to be set, no matter what.

 - Should we remove ntpdate in -current before 12 if it's deprecated ?

 I'll make the necessary changes according to your (or others) answers.

 Cheers,

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


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

2017-11-22 Thread Andrey V. Elsukov
Author: ae
Date: Thu Nov 23 07:05:25 2017
New Revision: 326117
URL: https://svnweb.freebsd.org/changeset/base/326117

Log:
  Check that address family of state matches address family of packet.
  
  If it is not matched avoid comparing other state fields.
  
  Obtained from:Yandex LLC
  MFC after:1 week
  Sponsored by: Yandex LLC

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

Modified: head/sys/netpfil/ipfw/ip_fw_dynamic.c
==
--- head/sys/netpfil/ipfw/ip_fw_dynamic.c   Thu Nov 23 06:04:57 2017
(r326116)
+++ head/sys/netpfil/ipfw/ip_fw_dynamic.c   Thu Nov 23 07:05:25 2017
(r326117)
@@ -609,6 +609,9 @@ lookup_dyn_rule_locked(struct ipfw_flow_id *pkt, int i
if (q->dyn_type == O_LIMIT_PARENT)
continue;
 
+   if (pkt->addr_type != q->id.addr_type)
+   continue;
+
if (pkt->proto != q->id.proto)
continue;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2017-11-22 Thread Andrey V. Elsukov
Author: ae
Date: Thu Nov 23 06:04:57 2017
New Revision: 326116
URL: https://svnweb.freebsd.org/changeset/base/326116

Log:
  Move ipfw_send_pkt() from ip_fw_dynamic.c into ip_fw2.c.
  It is not specific for dynamic states function and called also from
  generic code.
  
  Obtained from:Yandex LLC
  MFC after:1 week
  Sponsored by: Yandex LLC

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

Modified: head/sys/netpfil/ipfw/ip_fw2.c
==
--- head/sys/netpfil/ipfw/ip_fw2.c  Thu Nov 23 05:55:53 2017
(r326115)
+++ head/sys/netpfil/ipfw/ip_fw2.c  Thu Nov 23 06:04:57 2017
(r326116)
@@ -468,6 +468,155 @@ verify_path(struct in_addr src, struct ifnet *ifp, u_i
 #endif /* __FreeBSD__ */
 }
 
+/*
+ * Generate a TCP packet, containing either a RST or a keepalive.
+ * When flags & TH_RST, we are sending a RST packet, because of a
+ * "reset" action matched the packet.
+ * Otherwise we are sending a keepalive, and flags & TH_
+ * The 'replyto' mbuf is the mbuf being replied to, if any, and is required
+ * so that MAC can label the reply appropriately.
+ */
+struct mbuf *
+ipfw_send_pkt(struct mbuf *replyto, struct ipfw_flow_id *id, u_int32_t seq,
+u_int32_t ack, int flags)
+{
+   struct mbuf *m = NULL;  /* stupid compiler */
+   struct ip *h = NULL;/* stupid compiler */
+#ifdef INET6
+   struct ip6_hdr *h6 = NULL;
+#endif
+   struct tcphdr *th = NULL;
+   int len, dir;
+
+   MGETHDR(m, M_NOWAIT, MT_DATA);
+   if (m == NULL)
+   return (NULL);
+
+   M_SETFIB(m, id->fib);
+#ifdef MAC
+   if (replyto != NULL)
+   mac_netinet_firewall_reply(replyto, m);
+   else
+   mac_netinet_firewall_send(m);
+#else
+   (void)replyto;  /* don't warn about unused arg */
+#endif
+
+   switch (id->addr_type) {
+   case 4:
+   len = sizeof(struct ip) + sizeof(struct tcphdr);
+   break;
+#ifdef INET6
+   case 6:
+   len = sizeof(struct ip6_hdr) + sizeof(struct tcphdr);
+   break;
+#endif
+   default:
+   /* XXX: log me?!? */
+   FREE_PKT(m);
+   return (NULL);
+   }
+   dir = ((flags & (TH_SYN | TH_RST)) == TH_SYN);
+
+   m->m_data += max_linkhdr;
+   m->m_flags |= M_SKIP_FIREWALL;
+   m->m_pkthdr.len = m->m_len = len;
+   m->m_pkthdr.rcvif = NULL;
+   bzero(m->m_data, len);
+
+   switch (id->addr_type) {
+   case 4:
+   h = mtod(m, struct ip *);
+
+   /* prepare for checksum */
+   h->ip_p = IPPROTO_TCP;
+   h->ip_len = htons(sizeof(struct tcphdr));
+   if (dir) {
+   h->ip_src.s_addr = htonl(id->src_ip);
+   h->ip_dst.s_addr = htonl(id->dst_ip);
+   } else {
+   h->ip_src.s_addr = htonl(id->dst_ip);
+   h->ip_dst.s_addr = htonl(id->src_ip);
+   }
+
+   th = (struct tcphdr *)(h + 1);
+   break;
+#ifdef INET6
+   case 6:
+   h6 = mtod(m, struct ip6_hdr *);
+
+   /* prepare for checksum */
+   h6->ip6_nxt = IPPROTO_TCP;
+   h6->ip6_plen = htons(sizeof(struct tcphdr));
+   if (dir) {
+   h6->ip6_src = id->src_ip6;
+   h6->ip6_dst = id->dst_ip6;
+   } else {
+   h6->ip6_src = id->dst_ip6;
+   h6->ip6_dst = id->src_ip6;
+   }
+
+   th = (struct tcphdr *)(h6 + 1);
+   break;
+#endif
+   }
+
+   if (dir) {
+   th->th_sport = htons(id->src_port);
+   th->th_dport = htons(id->dst_port);
+   } else {
+   th->th_sport = htons(id->dst_port);
+   th->th_dport = htons(id->src_port);
+   }
+   th->th_off = sizeof(struct tcphdr) >> 2;
+
+   if (flags & TH_RST) {
+   if (flags & TH_ACK) {
+   th->th_seq = htonl(ack);
+   th->th_flags = TH_RST;
+   } else {
+   if (flags & TH_SYN)
+   seq++;
+   th->th_ack = htonl(seq);
+   th->th_flags = TH_RST | TH_ACK;
+   }
+   } else {
+   /*
+* Keepalive - use caller provided sequence numbers
+*/
+   th->th_seq = htonl(seq);
+   th->th_ack = htonl(ack);
+   th->th_flags = TH_ACK;
+   }
+
+   switch (id->addr_type) {
+   case 4:
+   th->th_sum = in_cksum(m, len);
+
+   /* finish the ip header */
+   h->ip_v = 4;
+   h->ip_hl = sizeof(*h) >> 2;
+   h->ip_tos = IPTOS_LOWDELAY;
+   

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

2017-11-22 Thread Andrey V. Elsukov
Author: ae
Date: Thu Nov 23 05:55:53 2017
New Revision: 326115
URL: https://svnweb.freebsd.org/changeset/base/326115

Log:
  Rework rule ranges matching. Use comparison rule id with UINT32_MAX to
  match all rules with the same rule number.
  
  Obtained from:Yandex LLC
  MFC after:1 week
  Sponsored by: Yandex LLC

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

Modified: head/sys/netpfil/ipfw/ip_fw_sockopt.c
==
--- head/sys/netpfil/ipfw/ip_fw_sockopt.c   Thu Nov 23 05:54:04 2017
(r326114)
+++ head/sys/netpfil/ipfw/ip_fw_sockopt.c   Thu Nov 23 05:55:53 2017
(r326115)
@@ -1021,10 +1021,9 @@ delete_range(struct ip_fw_chain *chain, ipfw_range_tlv
if ((rt->flags & IPFW_RCFLAG_RANGE) != 0) {
start = ipfw_find_rule(chain, rt->start_rule, 0);
 
-   end = ipfw_find_rule(chain, rt->end_rule, 0);
-   if (rt->end_rule != IPFW_DEFAULT_RULE)
-   while (chain->map[end]->rulenum == rt->end_rule)
-   end++;
+   if (rt->end_rule >= IPFW_DEFAULT_RULE)
+   rt->end_rule = IPFW_DEFAULT_RULE - 1;
+   end = ipfw_find_rule(chain, rt->end_rule, UINT32_MAX);
}
 
/* Allocate new map of the same size */
@@ -2401,9 +2400,9 @@ dump_config(struct ip_fw_chain *chain, ip_fw3_opheader
if ((rnum = hdr->start_rule) > IPFW_DEFAULT_RULE)
rnum = IPFW_DEFAULT_RULE;
da.b = ipfw_find_rule(chain, rnum, 0);
-   rnum = hdr->end_rule;
-   rnum = (rnum < IPFW_DEFAULT_RULE) ? rnum+1 : IPFW_DEFAULT_RULE;
-   da.e = ipfw_find_rule(chain, rnum, 0) + 1;
+   rnum = (hdr->end_rule < IPFW_DEFAULT_RULE) ?
+   hdr->end_rule + 1: IPFW_DEFAULT_RULE;
+   da.e = ipfw_find_rule(chain, rnum, UINT32_MAX) + 1;
}
 
if (hdr->flags & IPFW_CFG_GET_STATIC) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326114 - in head/sys/arm/allwinner: a83t clkng

2017-11-22 Thread Kyle Evans
Author: kevans
Date: Thu Nov 23 05:54:04 2017
New Revision: 326114
URL: https://svnweb.freebsd.org/changeset/base/326114

Log:
  Allwinner a83t: add ccung bits
  
  Upstream DTS has switched to using CCU rather than /clocks nodes. Add a CCU
  driver for the a83t to bring us closer to upstream, but don't yet attach it
  to ccu node.
  
  Reviewed by:  manu
  Approved by:  emaste (mentor)
  Differential Revision:https://reviews.freebsd.org/D12843

Added:
  head/sys/arm/allwinner/clkng/ccu_a83t.c   (contents, props changed)
  head/sys/arm/allwinner/clkng/ccu_a83t.h   (contents, props changed)
Modified:
  head/sys/arm/allwinner/a83t/files.a83t

Modified: head/sys/arm/allwinner/a83t/files.a83t
==
--- head/sys/arm/allwinner/a83t/files.a83t  Thu Nov 23 05:43:44 2017
(r326113)
+++ head/sys/arm/allwinner/a83t/files.a83t  Thu Nov 23 05:54:04 2017
(r326114)
@@ -1,4 +1,5 @@
 # $FreeBSD$
 
+arm/allwinner/clkng/ccu_a83t.c standard
 arm/allwinner/a83t/a83t_padconf.c  standard
 arm/allwinner/a83t/a83t_r_padconf.cstandard

Added: head/sys/arm/allwinner/clkng/ccu_a83t.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/allwinner/clkng/ccu_a83t.c Thu Nov 23 05:54:04 2017
(r326114)
@@ -0,0 +1,779 @@
+/*-
+ * Copyright (c) 2017 Kyle Evans 
+ * 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 ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "ccu_a83t.h"
+
+/* Non-exported resets */
+/*
+#defineRST_BUS_SCR 53
+*/
+
+/* Non-exported clocks */
+
+#defineCLK_PLL_C0CPUX  0
+#defineCLK_PLL_C1CPUX  1
+#defineCLK_PLL_AUDIO   2
+#defineCLK_PLL_VIDEO0  3
+#defineCLK_PLL_VE  4
+#defineCLK_PLL_DDR 5
+
+#defineCLK_PLL_GPU 7
+#defineCLK_PLL_HSIC8
+#defineCLK_PLL_VIDEO1  10
+
+#defineCLK_AXI013
+#defineCLK_AXI114
+#defineCLK_AHB115
+#defineCLK_APB116
+#defineCLK_APB217
+#defineCLK_AHB218
+
+#defineCLK_CCI400  58
+
+#define CLK_DRAM   82
+
+#defineCLK_MBUS95
+
+/* Non-exported fixed clocks */
+#define CLK_OSC_12M150
+
+
+static struct aw_ccung_reset a83t_ccu_resets[] = {
+   CCU_RESET(RST_USB_PHY0, 0xcc, 0)
+   CCU_RESET(RST_USB_PHY1, 0xcc, 1)
+   CCU_RESET(RST_USB_HSIC, 0xcc, 2)
+
+   CCU_RESET(RST_DRAM, 0xf4, 31)
+   CCU_RESET(RST_MBUS, 0xfc, 31)
+
+   CCU_RESET(RST_BUS_MIPI_DSI, 0x2c0, 1)
+   CCU_RESET(RST_BUS_SS, 0x2c0, 5)
+   CCU_RESET(RST_BUS_DMA, 0x2c0, 6)
+   CCU_RESET(RST_BUS_MMC0, 0x2c0, 8)
+   CCU_RESET(RST_BUS_MMC1, 0x2c0, 9)
+   CCU_RESET(RST_BUS_MMC2, 0x2c0, 10)
+   CCU_RESET(RST_BUS_NAND, 0x2c0, 13)
+   CCU_RESET(RST_BUS_DRAM, 0x2c0, 14)
+   CCU_RESET(RST_BUS_EMAC, 0x2c0, 17)
+   CCU_RESET(RST_BUS_HSTIMER, 0x2c0, 19)
+   CCU_RESET(RST_BUS_SPI0, 0x2c0, 20)
+   CCU_RESET(RST_BUS_SPI1, 0x2c0, 21)
+   CCU_RESET(RST_BUS_OTG, 0x2c0, 24)
+   CCU_RESET(RST_BUS_EHCI0, 0x2c0, 26)
+   CCU_RESET(RST_BUS_EHCI1, 0x2c0, 27)
+   CCU_RESET(RST_BUS_OHCI0, 0x2c0, 29)
+
+   CCU_RESET(RST_BUS_VE, 0x2c4, 0)
+   CCU_RESET(RST_BUS_TCON0, 0

svn commit: r326113 - head/sys/arm/allwinner/clkng

2017-11-22 Thread Kyle Evans
Author: kevans
Date: Thu Nov 23 05:43:44 2017
New Revision: 326113
URL: https://svnweb.freebsd.org/changeset/base/326113

Log:
  aw_ccung: changes to accommodate upcoming a83t support
  
  Add a means to specify mask/value for the prediv condition instead of
  shift/width/value for clocks that have a more complex mux scenario.
  
  Specifically, ahb1 on the a83t has the prediv applied if mux is either b10
  or b11.
  
  Reviewed by:  manu
  Approved by:  emaste (mentor)
  Differential Revision:https://reviews.freebsd.org/D12851

Modified:
  head/sys/arm/allwinner/clkng/aw_clk.h
  head/sys/arm/allwinner/clkng/aw_clk_prediv_mux.c

Modified: head/sys/arm/allwinner/clkng/aw_clk.h
==
--- head/sys/arm/allwinner/clkng/aw_clk.h   Thu Nov 23 03:40:51 2017
(r326112)
+++ head/sys/arm/allwinner/clkng/aw_clk.h   Thu Nov 23 05:43:44 2017
(r326113)
@@ -48,6 +48,7 @@ Periph clocks:
 
 Clock Source/Divider N/Divider M
 Clock Source/Divider N/Divider M/2
+Clock Source*N/(Divider M+1)/(Divider P+1)
 
  */
 
@@ -389,6 +390,36 @@ aw_clk_factor_get_value(struct aw_clk_factor *factor, 
.prediv.flags = _prediv_flags,  \
.prediv.cond_shift = _prediv_cond_shift,\
.prediv.cond_width = _prediv_cond_width,\
+   .prediv.cond_value = _prediv_cond_value,\
+   }
+
+#define PREDIV_CLK_WITH_MASK(_clkname, _id, _name, _pnames,\
+  _offset, \
+  _mux_shift, _mux_width,  \
+  _div_shift, _div_width, _div_value, _div_flags,  \
+  _prediv_shift, _prediv_width, _prediv_value, _prediv_flags,  \
+  _prediv_cond_mask, _prediv_cond_value)   \
+   static struct aw_clk_prediv_mux_def _clkname = {\
+   .clkdef = { \
+   .id = _id,  \
+   .name = _name,  \
+   .parent_names = _pnames,\
+   .parent_cnt = nitems(_pnames),  \
+   },  \
+   .offset = _offset,  \
+   .mux_shift = _mux_shift,\
+   .mux_width = _mux_width,\
+   .div.shift = _div_shift,\
+   .div.width = _div_width,\
+   .div.value = _div_value,\
+   .div.flags = _div_flags,\
+   .prediv.shift = _prediv_shift,  \
+   .prediv.width = _prediv_width,  \
+   .prediv.value = _prediv_value,  \
+   .prediv.flags = _prediv_flags,  \
+   .prediv.cond_shift = 0, \
+   .prediv.cond_width = 0, \
+   .prediv.cond_mask = _prediv_cond_mask,  \
.prediv.cond_value = _prediv_cond_value,\
}
 

Modified: head/sys/arm/allwinner/clkng/aw_clk_prediv_mux.c
==
--- head/sys/arm/allwinner/clkng/aw_clk_prediv_mux.cThu Nov 23 03:40:51 
2017(r326112)
+++ head/sys/arm/allwinner/clkng/aw_clk_prediv_mux.cThu Nov 23 05:43:44 
2017(r326113)
@@ -157,7 +157,10 @@ aw_clk_prediv_mux_register(struct clkdom *clkdom, stru
sc->prediv.mask = ((1 << clkdef->prediv.width) - 1) << sc->prediv.shift;
sc->prediv.value = clkdef->prediv.value;
sc->prediv.cond_shift = clkdef->prediv.cond_shift;
-   sc->prediv.cond_mask = ((1 << clkdef->prediv.cond_width) - 1) << 
sc->prediv.shift;
+   if (clkdef->prediv.cond_width != 0)
+   sc->prediv.cond_mask = ((1 << clkdef->prediv.cond_width) - 1) 
<< sc->prediv.shift;
+   else
+   sc->prediv.cond_mask = clkdef->prediv.cond_mask;
sc->prediv.cond_value = clkdef->prediv.cond_value;
sc->prediv.flags = clkdef->prediv.flags;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r326107 - in head/sys: kern sys

2017-11-22 Thread Mateusz Guzik
oops, fixed in r326107

On Thu, Nov 23, 2017 at 4:17 AM, Shawn Webb 
wrote:

> On Wed, Nov 22, 2017 at 10:04:04PM +, Mateusz Guzik wrote:
> > Author: mjg
> > Date: Wed Nov 22 22:04:04 2017
> > New Revision: 326107
> > URL: https://svnweb.freebsd.org/changeset/base/326107
> >
> > Log:
> >   locks: pass the found lock value to unlock slow path
> >
> >   This avoids an explicit read later.
> >
> >   While here whack the cheaply obtainable 'tid' argument.
> >
> > Modified:
> >   head/sys/kern/kern_mutex.c
> >   head/sys/kern/kern_rwlock.c
> >   head/sys/kern/kern_sx.c
> >   head/sys/sys/mutex.h
> >   head/sys/sys/rwlock.h
> >   head/sys/sys/sx.h
>
> This breaks ZFS:
> https://gist.github.com/lattera/93faa9c47ccc985ebda039ab31641c2c
>
> Thanks,
>
> --
> Shawn Webb
> Cofounder and Security Engineer
> HardenedBSD
>
> GPG Key ID:  0x6A84658F52456EEE
> GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89  3D9E 6A84 658F 5245 6EEE
>



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


svn commit: r326112 - head/sys/kern

2017-11-22 Thread Mateusz Guzik
Author: mjg
Date: Thu Nov 23 03:40:51 2017
New Revision: 326112
URL: https://svnweb.freebsd.org/changeset/base/326112

Log:
  sx: unbreak debug after r326107
  
  An assertion was modified to use the found value, but it was not updated to
  handle a race where blocked threads appear after the entrance to the func.
  
  Move the assertion down to the area protected with sleepq lock where the
  lock is read anyway. This does not affect coverage of the assertion and
  is consistent with what rw locks are doing.
  
  Reported by:  Shawn Webb

Modified:
  head/sys/kern/kern_sx.c

Modified: head/sys/kern/kern_sx.c
==
--- head/sys/kern/kern_sx.c Thu Nov 23 03:20:12 2017(r326111)
+++ head/sys/kern/kern_sx.c Thu Nov 23 03:40:51 2017(r326112)
@@ -828,12 +828,12 @@ _sx_xunlock_hard(struct sx *sx, uintptr_t x LOCK_FILE_
atomic_cmpset_rel_ptr(&sx->sx_lock, tid, SX_LOCK_UNLOCKED))
return;
 
-   MPASS(x & (SX_LOCK_SHARED_WAITERS | SX_LOCK_EXCLUSIVE_WAITERS));
if (LOCK_LOG_TEST(&sx->lock_object, 0))
CTR2(KTR_LOCK, "%s: %p contested", __func__, sx);
 
sleepq_lock(&sx->lock_object);
x = SX_READ_VALUE(sx);
+   MPASS(x & (SX_LOCK_SHARED_WAITERS | SX_LOCK_EXCLUSIVE_WAITERS));
 
/*
 * The wake up algorithm here is quite simple and probably not
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326111 - head/sys/kern

2017-11-22 Thread Mateusz Guzik
Author: mjg
Date: Thu Nov 23 03:20:12 2017
New Revision: 326111
URL: https://svnweb.freebsd.org/changeset/base/326111

Log:
  rwlock: unbreak WITNESS builds after r326110
  
  Reported by:  Shawn Webb

Modified:
  head/sys/kern/kern_rwlock.c

Modified: head/sys/kern/kern_rwlock.c
==
--- head/sys/kern/kern_rwlock.c Wed Nov 22 23:52:05 2017(r326110)
+++ head/sys/kern/kern_rwlock.c Thu Nov 23 03:20:12 2017(r326111)
@@ -551,7 +551,7 @@ __rw_rlock_hard(struct rwlock *rw, struct thread *td, 
/*
 * The lock is held in write mode or it already has waiters.
 */
-   MPASS(!RW_CAN_READ(td, v));
+   MPASS(!__rw_can_read(td, v, false));
 
/*
 * If the RW_LOCK_READ_WAITERS flag is already set, then
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r326107 - in head/sys: kern sys

2017-11-22 Thread Shawn Webb
On Wed, Nov 22, 2017 at 10:04:04PM +, Mateusz Guzik wrote:
> Author: mjg
> Date: Wed Nov 22 22:04:04 2017
> New Revision: 326107
> URL: https://svnweb.freebsd.org/changeset/base/326107
> 
> Log:
>   locks: pass the found lock value to unlock slow path
>   
>   This avoids an explicit read later.
>   
>   While here whack the cheaply obtainable 'tid' argument.
> 
> Modified:
>   head/sys/kern/kern_mutex.c
>   head/sys/kern/kern_rwlock.c
>   head/sys/kern/kern_sx.c
>   head/sys/sys/mutex.h
>   head/sys/sys/rwlock.h
>   head/sys/sys/sx.h

This breaks ZFS:
https://gist.github.com/lattera/93faa9c47ccc985ebda039ab31641c2c

Thanks,

-- 
Shawn Webb
Cofounder and Security Engineer
HardenedBSD

GPG Key ID:  0x6A84658F52456EEE
GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89  3D9E 6A84 658F 5245 6EEE


signature.asc
Description: PGP signature


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

2017-11-22 Thread Shawn Webb
On Wed, Nov 22, 2017 at 11:52:05PM +, Mateusz Guzik wrote:
> Author: mjg
> Date: Wed Nov 22 23:52:05 2017
> New Revision: 326110
> URL: https://svnweb.freebsd.org/changeset/base/326110
> 
> Log:
>   rwlock: don't check for curthread's read lock count in the fast path
> 
> Modified:
>   head/sys/kern/kern_rwlock.c
> 
> Modified: head/sys/kern/kern_rwlock.c
> ==
> --- head/sys/kern/kern_rwlock.c   Wed Nov 22 23:10:20 2017
> (r326109)
> +++ head/sys/kern/kern_rwlock.c   Wed Nov 22 23:52:05 2017
> (r326110)
> @@ -364,12 +364,20 @@ _rw_wunlock_cookie(volatile uintptr_t *c, const char *
>   * is unlocked and has no writer waiters or spinners.  Failing otherwise
>   * prioritizes writers before readers.
>   */
> -#define  RW_CAN_READ(td, _rw)
> \
> -(((_rw) & (RW_LOCK_READ | RW_LOCK_WRITE_WAITERS | 
> RW_LOCK_WRITE_SPINNER)) ==\
> -RW_LOCK_READ || ((td)->td_rw_rlocks && (_rw) & RW_LOCK_READ))
> +static bool __always_inline
> +__rw_can_read(struct thread *td, uintptr_t v, bool fp)
> +{
>  
> + if ((v & (RW_LOCK_READ | RW_LOCK_WRITE_WAITERS | RW_LOCK_WRITE_SPINNER))
> + == RW_LOCK_READ)
> + return (true);
> + if (!fp && td->td_rw_rlocks && (v & RW_LOCK_READ))
> + return (true);
> + return (false);
> +}

This bit of the patch breaks buildkernel. You left a consumer of
RW_CAN_READ on line 554: MPASS(!RW_CAN_READ(td, v));

Thanks,

-- 
Shawn Webb
Cofounder and Security Engineer
HardenedBSD

GPG Key ID:  0x6A84658F52456EEE
GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89  3D9E 6A84 658F 5245 6EEE


signature.asc
Description: PGP signature


svn commit: r326110 - head/sys/kern

2017-11-22 Thread Mateusz Guzik
Author: mjg
Date: Wed Nov 22 23:52:05 2017
New Revision: 326110
URL: https://svnweb.freebsd.org/changeset/base/326110

Log:
  rwlock: don't check for curthread's read lock count in the fast path

Modified:
  head/sys/kern/kern_rwlock.c

Modified: head/sys/kern/kern_rwlock.c
==
--- head/sys/kern/kern_rwlock.c Wed Nov 22 23:10:20 2017(r326109)
+++ head/sys/kern/kern_rwlock.c Wed Nov 22 23:52:05 2017(r326110)
@@ -364,12 +364,20 @@ _rw_wunlock_cookie(volatile uintptr_t *c, const char *
  * is unlocked and has no writer waiters or spinners.  Failing otherwise
  * prioritizes writers before readers.
  */
-#defineRW_CAN_READ(td, _rw)
\
-(((_rw) & (RW_LOCK_READ | RW_LOCK_WRITE_WAITERS | RW_LOCK_WRITE_SPINNER)) 
==\
-RW_LOCK_READ || ((td)->td_rw_rlocks && (_rw) & RW_LOCK_READ))
+static bool __always_inline
+__rw_can_read(struct thread *td, uintptr_t v, bool fp)
+{
 
+   if ((v & (RW_LOCK_READ | RW_LOCK_WRITE_WAITERS | RW_LOCK_WRITE_SPINNER))
+   == RW_LOCK_READ)
+   return (true);
+   if (!fp && td->td_rw_rlocks && (v & RW_LOCK_READ))
+   return (true);
+   return (false);
+}
+
 static bool __always_inline
-__rw_rlock_try(struct rwlock *rw, struct thread *td, uintptr_t *vp
+__rw_rlock_try(struct rwlock *rw, struct thread *td, uintptr_t *vp, bool fp
 LOCK_FILE_LINE_ARG_DEF)
 {
 
@@ -383,7 +391,7 @@ __rw_rlock_try(struct rwlock *rw, struct thread *td, u
 * completely unlocked rwlock since such a lock is encoded
 * as a read lock with no waiters.
 */
-   while (RW_CAN_READ(td, *vp)) {
+   while (__rw_can_read(td, *vp, fp)) {
if (atomic_fcmpset_acq_ptr(&rw->rw_lock, vp,
*vp + RW_ONE_READER)) {
if (LOCK_LOG_TEST(&rw->lock_object, 0))
@@ -452,7 +460,7 @@ __rw_rlock_hard(struct rwlock *rw, struct thread *td, 
 #endif
 
for (;;) {
-   if (__rw_rlock_try(rw, td, &v LOCK_FILE_LINE_ARG))
+   if (__rw_rlock_try(rw, td, &v, false LOCK_FILE_LINE_ARG))
break;
 #ifdef KDTRACE_HOOKS
lda.spin_cnt++;
@@ -492,7 +500,7 @@ __rw_rlock_hard(struct rwlock *rw, struct thread *td, 
n = RW_READERS(v);
lock_delay_spin(n);
v = RW_READ_VALUE(rw);
-   if ((v & RW_LOCK_READ) == 0 || RW_CAN_READ(td, 
v))
+   if ((v & RW_LOCK_READ) == 0 || 
__rw_can_read(td, v, false))
break;
}
 #ifdef KDTRACE_HOOKS
@@ -518,7 +526,7 @@ __rw_rlock_hard(struct rwlock *rw, struct thread *td, 
 * recheck its state and restart the loop if needed.
 */
v = RW_READ_VALUE(rw);
-   if (RW_CAN_READ(td, v)) {
+   if (__rw_can_read(td, v, false)) {
turnstile_cancel(ts);
continue;
}
@@ -630,7 +638,7 @@ __rw_rlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DE
 
v = RW_READ_VALUE(rw);
if (__predict_false(LOCKSTAT_OOL_PROFILE_ENABLED(rw__acquire) ||
-   !__rw_rlock_try(rw, td, &v LOCK_FILE_LINE_ARG)))
+   !__rw_rlock_try(rw, td, &v, true LOCK_FILE_LINE_ARG)))
__rw_rlock_hard(rw, td, v LOCK_FILE_LINE_ARG);
 
LOCK_LOG_LOCK("RLOCK", &rw->lock_object, 0, 0, file, line);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326109 - in head/sys: conf dev/bhnd dev/bhnd/cores/chipc mips/conf modules/bhnd

2017-11-22 Thread Landon J. Fuller
Author: landonf
Date: Wed Nov 22 23:10:20 2017
New Revision: 326109
URL: https://svnweb.freebsd.org/changeset/base/326109

Log:
  bhnd(4): Add a basic ChipCommon GPIO driver sufficient to support bwn(4)
  
  The driver is functional on both BHND Wi-Fi adapters and MIPS SoCs, but
  does not currently include support for features not required by bwn(4),
  including GPIO interrupt handling.
  
  Approved by:  adrian (mentor, implicit)
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D12708

Added:
  head/sys/dev/bhnd/cores/chipc/chipc_gpio.c   (contents, props changed)
  head/sys/dev/bhnd/cores/chipc/chipc_gpiovar.h   (contents, props changed)
Modified:
  head/sys/conf/files
  head/sys/dev/bhnd/bhnd_types.h
  head/sys/dev/bhnd/cores/chipc/chipc.c
  head/sys/dev/bhnd/cores/chipc/chipc_subr.c
  head/sys/dev/bhnd/cores/chipc/chipcreg.h
  head/sys/mips/conf/BCM
  head/sys/mips/conf/SENTRY5
  head/sys/modules/bhnd/Makefile

Modified: head/sys/conf/files
==
--- head/sys/conf/files Wed Nov 22 22:04:27 2017(r326108)
+++ head/sys/conf/files Wed Nov 22 23:10:20 2017(r326109)
@@ -1246,6 +1246,7 @@ dev/bhnd/cores/chipc/bhnd_sprom_chipc.c   optional bhnd
 dev/bhnd/cores/chipc/bhnd_pmu_chipc.c  optional bhnd
 dev/bhnd/cores/chipc/chipc.c   optional bhnd
 dev/bhnd/cores/chipc/chipc_cfi.c   optional bhnd cfi 
+dev/bhnd/cores/chipc/chipc_gpio.c  optional bhnd gpio
 dev/bhnd/cores/chipc/chipc_slicer.coptional bhnd cfi | bhnd spibus
 dev/bhnd/cores/chipc/chipc_spi.c   optional bhnd spibus
 dev/bhnd/cores/chipc/chipc_subr.c  optional bhnd

Modified: head/sys/dev/bhnd/bhnd_types.h
==
--- head/sys/dev/bhnd/bhnd_types.h  Wed Nov 22 22:04:27 2017
(r326108)
+++ head/sys/dev/bhnd/bhnd_types.h  Wed Nov 22 23:10:20 2017
(r326109)
@@ -75,6 +75,7 @@ typedef enum {
BHND_SERVICE_PWRCTL,/**< legacy pwrctl service; implements 
the bhnd_pwrctl interface */
BHND_SERVICE_PMU,   /**< pmu service; implements the 
bhnd_pmu interface */
BHND_SERVICE_NVRAM, /**< nvram service; implements the 
bhnd_nvram interface */
+   BHND_SERVICE_GPIO,  /**< gpio service; implements the 
standard gpio interface */
 
BHND_SERVICE_ANY = 1000,/**< match on any service type */
 } bhnd_service_t;

Modified: head/sys/dev/bhnd/cores/chipc/chipc.c
==
--- head/sys/dev/bhnd/cores/chipc/chipc.c   Wed Nov 22 22:04:27 2017
(r326108)
+++ head/sys/dev/bhnd/cores/chipc/chipc.c   Wed Nov 22 23:10:20 2017
(r326109)
@@ -306,6 +306,20 @@ chipc_add_children(struct chipc_softc *sc)
}
}
 
+   /* GPIO */
+   child = BUS_ADD_CHILD(sc->dev, 0, "gpio", 0);
+   if (child == NULL) {
+   device_printf(sc->dev, "failed to add gpio\n");
+   return (ENXIO);
+   }
+
+   error = chipc_set_mem_resource(sc, child, 0, 0, RM_MAX_END, 0, 0);
+   if (error) {
+   device_printf(sc->dev, "failed to set gpio memory resource: "
+   "%d\n", error);
+   return (error);
+   }
+
/* All remaining devices are SoC-only */
if (bhnd_get_attach_type(sc->dev) != BHND_ATTACH_NATIVE)
return (0);
@@ -835,6 +849,25 @@ chipc_alloc_resource(device_t dev, device_t child, int
if ((cr = chipc_find_region(sc, start, end)) == NULL) {
/* Resource requests outside our shared port regions can be
 * delegated to our parent. */
+   rv = bus_generic_rl_alloc_resource(dev, child, type, rid,
+   start, end, count, flags);
+   return (rv);
+   }
+
+   /*
+* As a special case, children that map the complete ChipCommon register
+* block are delegated to our parent.
+*
+* The rman API does not support sharing resources that are not
+* identical in size; since we allocate subregions to various children,
+* any children that need to map the entire register block (e.g. because
+* they require access to discontiguous register ranges) must make the
+* allocation through our parent, where we hold a compatible
+* RF_SHAREABLE allocation.
+*/
+   if (cr == sc->core_region && cr->cr_addr == start &&
+   cr->cr_end == end && cr->cr_count == count)
+   {
rv = bus_generic_rl_alloc_resource(dev, child, type, rid,
start, end, count, flags);
return (rv);

Added: head/sys/dev/bhnd/cores/chipc/chipc_gpio.c
==
--- /dev/null   00:00:00 1970   (empty, becau

Re: svn commit: r326073 - head/usr.bin/systat

2017-11-22 Thread Konstantin Belousov
On Thu, Nov 23, 2017 at 04:24:13AM +1100, Bruce Evans wrote:
> sysctl/sysctl.c:
>sysctl(8) has bogus support for prettyprinting struct vmtotal (sysctl
>shouldn't have any prettyprinting, especially not for structs that have
>specialized programs to print them and much more).  This uses intmax_t
>for all calculations and printing except for the int16_t fields, so it
>automatically benefited from the expansion.  However since it uses a
>correct type (signed, and not restricted to 64 bits), it now has minor
>type errors -- it dowcasts the uint64_t to intmax_t wheen the latter is
>64 bits.  Its Makefile uses a fairly high WARNS, so if its type errors
>were fatal then printf format checking would have detected them (but
>not non-fatal errors involving downcasting).

Below is the cast to uintmax_t and unsigned format for sysctl(8).

diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index e1bf4e31914..92685a8171b 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -625,15 +625,15 @@ S_vmtotal(size_t l2, void *p)
"%hd Sleep: %hd)\n",
v->t_rq, v->t_dw, v->t_pw, v->t_sl);
printf(
-   "Virtual Memory:\t\t(Total: %jdK Active: %jdK)\n",
-   (intmax_t)v->t_vm * pageKilo, (intmax_t)v->t_avm * pageKilo);
-   printf("Real Memory:\t\t(Total: %jdK Active: %jdK)\n",
-   (intmax_t)v->t_rm * pageKilo, (intmax_t)v->t_arm * pageKilo);
-   printf("Shared Virtual Memory:\t(Total: %jdK Active: %jdK)\n",
-   (intmax_t)v->t_vmshr * pageKilo, (intmax_t)v->t_avmshr * pageKilo);
-   printf("Shared Real Memory:\t(Total: %jdK Active: %jdK)\n",
-   (intmax_t)v->t_rmshr * pageKilo, (intmax_t)v->t_armshr * pageKilo);
-   printf("Free Memory:\t%jdK", (intmax_t)v->t_free * pageKilo);
+   "Virtual Memory:\t\t(Total: %juK Active: %juK)\n",
+   (uintmax_t)v->t_vm * pageKilo, (uintmax_t)v->t_avm * pageKilo);
+   printf("Real Memory:\t\t(Total: %juK Active: %juK)\n",
+   (uintmax_t)v->t_rm * pageKilo, (uintmax_t)v->t_arm * pageKilo);
+   printf("Shared Virtual Memory:\t(Total: %juK Active: %juK)\n",
+   (uintmax_t)v->t_vmshr * pageKilo, (uintmax_t)v->t_avmshr * 
pageKilo);
+   printf("Shared Real Memory:\t(Total: %juK Active: %juK)\n",
+   (uintmax_t)v->t_rmshr * pageKilo, (uintmax_t)v->t_armshr * 
pageKilo);
+   printf("Free Memory:\t%juK", (uintmax_t)v->t_free * pageKilo);
 
return (0);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326108 - head/usr.bin/systat

2017-11-22 Thread Konstantin Belousov
Author: kib
Date: Wed Nov 22 22:04:27 2017
New Revision: 326108
URL: https://svnweb.freebsd.org/changeset/base/326108

Log:
  Order declarations alphabetically.
  Match signess of the format and the value.
  
  Noted by: bde
  Sponsored by: The FreeBSD Foundation

Modified:
  head/usr.bin/systat/vmstat.c

Modified: head/usr.bin/systat/vmstat.c
==
--- head/usr.bin/systat/vmstat.cWed Nov 22 22:04:04 2017
(r326107)
+++ head/usr.bin/systat/vmstat.cWed Nov 22 22:04:27 2017
(r326108)
@@ -138,10 +138,10 @@ static void allocinfo(struct Info *);
 static void copyinfo(struct Info *, struct Info *);
 static float cputime(int);
 static void dinfo(int, int, struct statinfo *, struct statinfo *);
+static void do_putuint64(uint64_t, int, int, int, int);
 static void getinfo(struct Info *);
 static void putint(int, int, int, int);
 static void putuint64(uint64_t, int, int, int);
-static void do_putuint64(uint64_t, int, int, int, int);
 static void putfloat(double, int, int, int, int, int);
 static void putlongdouble(long double, int, int, int, int, int);
 static int ucount(void);
@@ -699,7 +699,7 @@ do_putuint64(uint64_t n, int l, int lc, int w, int div
addch(' ');
return;
}
-   snr = snprintf(b, sizeof(b), "%*jd", w, (uintmax_t)n);
+   snr = snprintf(b, sizeof(b), "%*ju", w, (uintmax_t)n);
if (snr != w) {
humanize_number(buf, w, n, "", HN_AUTOSCALE,
HN_NOSPACE | HN_DECIMAL | div);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2017-11-22 Thread Mateusz Guzik
Author: mjg
Date: Wed Nov 22 22:04:04 2017
New Revision: 326107
URL: https://svnweb.freebsd.org/changeset/base/326107

Log:
  locks: pass the found lock value to unlock slow path
  
  This avoids an explicit read later.
  
  While here whack the cheaply obtainable 'tid' argument.

Modified:
  head/sys/kern/kern_mutex.c
  head/sys/kern/kern_rwlock.c
  head/sys/kern/kern_sx.c
  head/sys/sys/mutex.h
  head/sys/sys/rwlock.h
  head/sys/sys/sx.h

Modified: head/sys/kern/kern_mutex.c
==
--- head/sys/kern/kern_mutex.c  Wed Nov 22 21:51:17 2017(r326106)
+++ head/sys/kern/kern_mutex.c  Wed Nov 22 22:04:04 2017(r326107)
@@ -277,7 +277,7 @@ __mtx_unlock_flags(volatile uintptr_t *c, int opts, co
mtx_assert(m, MA_OWNED);
 
 #ifdef LOCK_PROFILING
-   __mtx_unlock_sleep(c, opts, file, line);
+   __mtx_unlock_sleep(c, (uintptr_t)curthread, opts, file, line);
 #else
__mtx_unlock(m, curthread, opts, file, line);
 #endif
@@ -1002,24 +1002,27 @@ thread_lock_set(struct thread *td, struct mtx *new)
  */
 #if LOCK_DEBUG > 0
 void
-__mtx_unlock_sleep(volatile uintptr_t *c, int opts, const char *file, int line)
+__mtx_unlock_sleep(volatile uintptr_t *c, uintptr_t v, int opts,
+const char *file, int line)
 #else
 void
-__mtx_unlock_sleep(volatile uintptr_t *c)
+__mtx_unlock_sleep(volatile uintptr_t *c, uintptr_t v)
 #endif
 {
struct mtx *m;
struct turnstile *ts;
-   uintptr_t tid, v;
+   uintptr_t tid;
 
if (SCHEDULER_STOPPED())
return;
 
tid = (uintptr_t)curthread;
m = mtxlock2mtx(c);
-   v = MTX_READ_VALUE(m);
 
-   if (v & MTX_RECURSED) {
+   if (__predict_false(v == tid))
+   v = MTX_READ_VALUE(m);
+
+   if (__predict_false(v & MTX_RECURSED)) {
if (--(m->mtx_recurse) == 0)
atomic_clear_ptr(&m->mtx_lock, MTX_RECURSED);
if (LOCK_LOG_TEST(&m->lock_object, opts))

Modified: head/sys/kern/kern_rwlock.c
==
--- head/sys/kern/kern_rwlock.c Wed Nov 22 21:51:17 2017(r326106)
+++ head/sys/kern/kern_rwlock.c Wed Nov 22 22:04:04 2017(r326107)
@@ -1078,18 +1078,21 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v LOC
  * on this lock.
  */
 void
-__rw_wunlock_hard(volatile uintptr_t *c, uintptr_t tid LOCK_FILE_LINE_ARG_DEF)
+__rw_wunlock_hard(volatile uintptr_t *c, uintptr_t v LOCK_FILE_LINE_ARG_DEF)
 {
struct rwlock *rw;
struct turnstile *ts;
-   uintptr_t v, setv;
+   uintptr_t tid, setv;
int queue;
 
+   tid = (uintptr_t)curthread;
if (SCHEDULER_STOPPED())
return;
 
rw = rwlock2rw(c);
-   v = RW_READ_VALUE(rw);
+   if (__predict_false(v == tid))
+   v = RW_READ_VALUE(rw);
+
if (v & RW_LOCK_WRITER_RECURSED) {
if (--(rw->rw_recurse) == 0)
atomic_clear_ptr(&rw->rw_lock, RW_LOCK_WRITER_RECURSED);

Modified: head/sys/kern/kern_sx.c
==
--- head/sys/kern/kern_sx.c Wed Nov 22 21:51:17 2017(r326106)
+++ head/sys/kern/kern_sx.c Wed Nov 22 22:04:04 2017(r326107)
@@ -799,18 +799,22 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, int opts LO
  * accessible from at least sx.h.
  */
 void
-_sx_xunlock_hard(struct sx *sx, uintptr_t tid LOCK_FILE_LINE_ARG_DEF)
+_sx_xunlock_hard(struct sx *sx, uintptr_t x LOCK_FILE_LINE_ARG_DEF)
 {
-   uintptr_t x, setx;
+   uintptr_t tid, setx;
int queue, wakeup_swapper;
 
if (SCHEDULER_STOPPED())
return;
 
-   MPASS(!(sx->sx_lock & SX_LOCK_SHARED));
+   tid = (uintptr_t)curthread;
 
-   x = SX_READ_VALUE(sx);
-   if (x & SX_LOCK_RECURSED) {
+   if (__predict_false(x == tid))
+   x = SX_READ_VALUE(sx);
+
+   MPASS(!(x & SX_LOCK_SHARED));
+
+   if (__predict_false(x & SX_LOCK_RECURSED)) {
/* The lock is recursed, unrecurse one level. */
if ((--sx->sx_recurse) == 0)
atomic_clear_ptr(&sx->sx_lock, SX_LOCK_RECURSED);
@@ -824,8 +828,7 @@ _sx_xunlock_hard(struct sx *sx, uintptr_t tid LOCK_FIL
atomic_cmpset_rel_ptr(&sx->sx_lock, tid, SX_LOCK_UNLOCKED))
return;
 
-   MPASS(sx->sx_lock & (SX_LOCK_SHARED_WAITERS |
-   SX_LOCK_EXCLUSIVE_WAITERS));
+   MPASS(x & (SX_LOCK_SHARED_WAITERS | SX_LOCK_EXCLUSIVE_WAITERS));
if (LOCK_LOG_TEST(&sx->lock_object, 0))
CTR2(KTR_LOCK, "%s: %p contested", __func__, sx);
 

Modified: head/sys/sys/mutex.h
==
--- head/sys/sys/mutex.hWed Nov 22 21:51:17 2017(r326106)
+++ head/sys/sys/mutex.hWed Nov 22 22:04:04 2017 

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

2017-11-22 Thread Mateusz Guzik
Author: mjg
Date: Wed Nov 22 21:51:17 2017
New Revision: 326106
URL: https://svnweb.freebsd.org/changeset/base/326106

Log:
  locks: remove the file + line argument from internal primitives when not used
  
  The pair is of use only in debug or LOCKPROF kernels, but was passed (zeroed)
  for many locks even in production kernels.
  
  While here whack the tid argument from wlock hard and xlock hard.
  
  There is no kbi change of any sort - "external" primitives still accept the
  pair.

Modified:
  head/sys/kern/kern_mutex.c
  head/sys/kern/kern_rwlock.c
  head/sys/kern/kern_sx.c
  head/sys/sys/lock.h
  head/sys/sys/mutex.h
  head/sys/sys/rwlock.h
  head/sys/sys/sx.h

Modified: head/sys/kern/kern_mutex.c
==
--- head/sys/kern/kern_mutex.c  Wed Nov 22 21:24:47 2017(r326105)
+++ head/sys/kern/kern_mutex.c  Wed Nov 22 21:51:17 2017(r326106)
@@ -380,9 +380,8 @@ __mtx_unlock_spin_flags(volatile uintptr_t *c, int opt
  * is already owned, it will recursively acquire the lock.
  */
 int
-_mtx_trylock_flags_(volatile uintptr_t *c, int opts, const char *file, int 
line)
+_mtx_trylock_flags_int(struct mtx *m, int opts LOCK_FILE_LINE_ARG_DEF)
 {
-   struct mtx *m;
struct thread *td;
uintptr_t tid, v;
 #ifdef LOCK_PROFILING
@@ -397,8 +396,6 @@ _mtx_trylock_flags_(volatile uintptr_t *c, int opts, c
if (SCHEDULER_STOPPED_TD(td))
return (1);
 
-   m = mtxlock2mtx(c);
-
KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(td),
("mtx_trylock() by idle thread %p on sleep mutex %s @ %s:%d",
curthread, m->lock_object.lo_name, file, line));
@@ -441,6 +438,15 @@ _mtx_trylock_flags_(volatile uintptr_t *c, int opts, c
}
 
return (rval);
+}
+
+int
+_mtx_trylock_flags_(volatile uintptr_t *c, int opts, const char *file, int 
line)
+{
+   struct mtx *m;
+
+   m = mtxlock2mtx(c);
+   return (_mtx_trylock_flags_int(m, opts LOCK_FILE_LINE_ARG));
 }
 
 /*

Modified: head/sys/kern/kern_rwlock.c
==
--- head/sys/kern/kern_rwlock.c Wed Nov 22 21:24:47 2017(r326105)
+++ head/sys/kern/kern_rwlock.c Wed Nov 22 21:51:17 2017(r326106)
@@ -273,7 +273,7 @@ _rw_wlock_cookie(volatile uintptr_t *c, const char *fi
tid = (uintptr_t)curthread;
v = RW_UNLOCKED;
if (!_rw_write_lock_fetch(rw, &v, tid))
-   _rw_wlock_hard(rw, v, tid, file, line);
+   _rw_wlock_hard(rw, v, file, line);
else
LOCKSTAT_PROFILE_OBTAIN_RWLOCK_SUCCESS(rw__acquire, rw,
0, 0, file, line, LOCKSTAT_WRITER);
@@ -369,8 +369,8 @@ _rw_wunlock_cookie(volatile uintptr_t *c, const char *
 RW_LOCK_READ || ((td)->td_rw_rlocks && (_rw) & RW_LOCK_READ))
 
 static bool __always_inline
-__rw_rlock_try(struct rwlock *rw, struct thread *td, uintptr_t *vp,
-const char *file, int line)
+__rw_rlock_try(struct rwlock *rw, struct thread *td, uintptr_t *vp
+LOCK_FILE_LINE_ARG_DEF)
 {
 
/*
@@ -399,10 +399,9 @@ __rw_rlock_try(struct rwlock *rw, struct thread *td, u
 }
 
 static void __noinline
-__rw_rlock_hard(volatile uintptr_t *c, struct thread *td, uintptr_t v,
-const char *file, int line)
+__rw_rlock_hard(struct rwlock *rw, struct thread *td, uintptr_t v
+LOCK_FILE_LINE_ARG_DEF)
 {
-   struct rwlock *rw;
struct turnstile *ts;
 #ifdef ADAPTIVE_RWLOCKS
volatile struct thread *owner;
@@ -434,7 +433,6 @@ __rw_rlock_hard(volatile uintptr_t *c, struct thread *
 #elif defined(KDTRACE_HOOKS)
lock_delay_arg_init(&lda, NULL);
 #endif
-   rw = rwlock2rw(c);
 
 #ifdef HWPMC_HOOKS
PMC_SOFT_CALL( , , lock, failed);
@@ -454,7 +452,7 @@ __rw_rlock_hard(volatile uintptr_t *c, struct thread *
 #endif
 
for (;;) {
-   if (__rw_rlock_try(rw, td, &v, file, line))
+   if (__rw_rlock_try(rw, td, &v LOCK_FILE_LINE_ARG))
break;
 #ifdef KDTRACE_HOOKS
lda.spin_cnt++;
@@ -612,14 +610,12 @@ __rw_rlock_hard(volatile uintptr_t *c, struct thread *
 }
 
 void
-__rw_rlock(volatile uintptr_t *c, const char *file, int line)
+__rw_rlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF)
 {
-   struct rwlock *rw;
struct thread *td;
uintptr_t v;
 
td = curthread;
-   rw = rwlock2rw(c);
 
KASSERT(kdb_active != 0 || SCHEDULER_STOPPED_TD(td) ||
!TD_IS_IDLETHREAD(td),
@@ -634,14 +630,23 @@ __rw_rlock(volatile uintptr_t *c, const char *file, in
 
v = RW_READ_VALUE(rw);
if (__predict_false(LOCKSTAT_OOL_PROFILE_ENABLED(rw__acquire) ||
-   !__rw_rlock_try(rw, td, &v, file, line)))
-   __rw_rlock_hard(c, td, v, file, line);
+   !__rw_rlock_try(rw, td, &v LOCK_FILE_LINE_ARG)))
+   __rw_rlock_hard(rw, td, v LOCK_FILE_LINE_ARG);
 
LOCK_LOG

svn commit: r326102 - in head/sys: conf dev/bhnd dev/bhnd/bcma dev/bhnd/bhndb dev/bhnd/cores/chipc dev/bhnd/cores/chipc/pwrctl dev/bhnd/cores/pmu dev/bhnd/siba mips/broadcom modules/bhnd modules/bh...

2017-11-22 Thread Landon J. Fuller
Author: landonf
Date: Wed Nov 22 20:27:46 2017
New Revision: 326102
URL: https://svnweb.freebsd.org/changeset/base/326102

Log:
  bhnd(4): extend the PMU APIs to support bwn(4)
  
  The bwn(4) driver requires a number of extensions to the bhnd(4) PMU
  interface to support external configuration of PLLs, LDOs, and other
  parameters that require chipset or PHY-specific workarounds.
  
  These changes add support for:
  
  - Writing raw voltage register values to PHY-specific LDO regulator
registers (required by LP-PHY).
  - Enabling/disabling PHY-specific LDOs (required by LP-PHY)
  - Writing to arbitrary PMU chipctrl registers (required for common PHY PLL
reset support).
  - Requesting chipset/PLL-specific spurious signal avoidance modes.
  - Querying clock frequency and latency.
  
  Additionally, rather than updating legacy PWRCTL support to conform to the
  new PMU interface:
  
  - PWRCTL API is now provided by a bhnd_pwrctl_if.m interface.
  - Since PWRCTL is only found in older SSB-based chipsets, translation from
bhnd(4) bus APIs to corresponding PWRCTL operations is now handled
entirely within the siba(4) driver.
  - The PWRCTL-specific host bridge clock gating APIs in bhnd_bus_if.m have
been lifted out into a standalone bhnd_pwrctl_hostb_if.m interface.
  
  Approved by:  adrian (mentor, implicit)
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D12664

Added:
  head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl.h   (contents, props changed)
  head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_hostb_if.m   (contents, 
props changed)
  head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_if.m   (contents, props 
changed)
  head/sys/dev/bhnd/cores/pmu/bhnd_pmu_types.h   (contents, props changed)
Modified:
  head/sys/conf/files
  head/sys/dev/bhnd/bcma/bcma.c
  head/sys/dev/bhnd/bcma/bcmavar.h
  head/sys/dev/bhnd/bhnd.c
  head/sys/dev/bhnd/bhnd.h
  head/sys/dev/bhnd/bhnd_bus_if.m
  head/sys/dev/bhnd/bhnd_private.h
  head/sys/dev/bhnd/bhnd_subr.c
  head/sys/dev/bhnd/bhnd_types.h
  head/sys/dev/bhnd/bhndb/bhnd_bhndb.c
  head/sys/dev/bhnd/bhndb/bhndb_pci.c
  head/sys/dev/bhnd/bhndreg.h
  head/sys/dev/bhnd/bhndvar.h
  head/sys/dev/bhnd/cores/chipc/chipc.c
  head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl.c
  head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_private.h
  head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_subr.c
  head/sys/dev/bhnd/cores/pmu/bhnd_pmu.c
  head/sys/dev/bhnd/cores/pmu/bhnd_pmu.h
  head/sys/dev/bhnd/cores/pmu/bhnd_pmu_core.c
  head/sys/dev/bhnd/cores/pmu/bhnd_pmu_if.m
  head/sys/dev/bhnd/cores/pmu/bhnd_pmu_private.h
  head/sys/dev/bhnd/cores/pmu/bhnd_pmu_subr.c
  head/sys/dev/bhnd/cores/pmu/bhnd_pmureg.h
  head/sys/dev/bhnd/cores/pmu/bhnd_pmuvar.h
  head/sys/dev/bhnd/siba/siba.c
  head/sys/dev/bhnd/siba/siba_bhndb.c
  head/sys/dev/bhnd/siba/siba_subr.c
  head/sys/dev/bhnd/siba/sibavar.h
  head/sys/mips/broadcom/siba_nexus.c
  head/sys/modules/bhnd/Makefile
  head/sys/modules/bhnd/bhndb/Makefile
  head/sys/modules/bhnd/bhndb_pci/Makefile
  head/sys/modules/bhnd/siba/Makefile

Modified: head/sys/conf/files
==
--- head/sys/conf/files Wed Nov 22 19:58:29 2017(r326101)
+++ head/sys/conf/files Wed Nov 22 20:27:46 2017(r326102)
@@ -1250,6 +1250,8 @@ dev/bhnd/cores/chipc/chipc_slicer.c   optional bhnd 
cfi 
 dev/bhnd/cores/chipc/chipc_spi.c   optional bhnd spibus
 dev/bhnd/cores/chipc/chipc_subr.c  optional bhnd
 dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl.c  optional bhnd
+dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_if.m   optional bhnd
+dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_hostb_if.m optional bhnd
 dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_subr.c optional bhnd
 dev/bhnd/cores/pci/bhnd_pci.c  optional bhnd pci
 dev/bhnd/cores/pci/bhnd_pci_hostb.coptional bhndb bhnd pci

Modified: head/sys/dev/bhnd/bcma/bcma.c
==
--- head/sys/dev/bhnd/bcma/bcma.c   Wed Nov 22 19:58:29 2017
(r326101)
+++ head/sys/dev/bhnd/bcma/bcma.c   Wed Nov 22 20:27:46 2017
(r326102)
@@ -193,7 +193,7 @@ bcma_write_ivar(device_t dev, device_t child, int inde
case BHND_IVAR_CORE_UNIT:
return (EINVAL);
case BHND_IVAR_PMU_INFO:
-   dinfo->pmu_info = (struct bhnd_core_pmu_info *) value;
+   dinfo->pmu_info = (void *)value;
return (0);
default:
return (ENOENT);
@@ -349,17 +349,15 @@ bcma_reset_hw(device_t dev, device_t child, uint16_t i
 static int
 bcma_suspend_hw(device_t dev, device_t child)
 {
-   struct bcma_devinfo *dinfo;
-   struct bhnd_core_pmu_info   *pm;
-   struct bhnd_resource*r;
-   uint32_t rst;
-   int  error;
+   struct bcma_devinfo 

svn commit: r326101 - head/lib/libcam/tests

2017-11-22 Thread Alan Somers
Author: asomers
Date: Wed Nov 22 19:58:29 2017
New Revision: 326101
URL: https://svnweb.freebsd.org/changeset/base/326101

Log:
  Add a test case for cam_get_device with sa(4) devices
  
  sa(4) has some unique behavior that is special-cased in cam_get_device. The
  existing tests don't provide coverage for this special case.
  
  Reviewed by:  ken
  MFC after:3 weeks
  Sponsored by: Spectra Logic Corp
  Differential Revision:https://reviews.freebsd.org/D13185

Modified:
  head/lib/libcam/tests/libcam_test.c

Modified: head/lib/libcam/tests/libcam_test.c
==
--- head/lib/libcam/tests/libcam_test.c Wed Nov 22 19:57:34 2017
(r326100)
+++ head/lib/libcam/tests/libcam_test.c Wed Nov 22 19:58:29 2017
(r326101)
@@ -129,6 +129,33 @@ ATF_TC_BODY(cam_get_device_positive_test, tc)
ATF_REQUIRE(parsed_unit == expected_unit);
 }
 
+/* 
+ * sa(4) uniquely creates nsa and esa device nodes for non-rewind operations
+ * and eject-on-close operations.  cam_get_device must special case these nodes
+ * to always return the base device.
+ */
+ATF_TC_WITHOUT_HEAD(cam_get_device_sa_test);
+ATF_TC_BODY(cam_get_device_sa_test, tc)
+{
+   char parsed_dev_name[DEV_IDLEN + 1];
+   int parsed_unit;
+
+   ATF_REQUIRE_MSG(cam_get_device("nsa99", parsed_dev_name,
+   nitems(parsed_dev_name), &parsed_unit) == 0,
+   "cam_get_device failed");
+   ATF_REQUIRE_STREQ(parsed_dev_name, "sa");
+   ATF_REQUIRE(parsed_unit == 99);
+
+   strcpy(parsed_dev_name, "");
+   parsed_unit = -1;
+
+   ATF_REQUIRE_MSG(cam_get_device("esa99", parsed_dev_name,
+   nitems(parsed_dev_name), &parsed_unit) == 0,
+   "cam_get_device failed");
+   ATF_REQUIRE_STREQ(parsed_dev_name, "sa");
+   ATF_REQUIRE(parsed_unit == 99);
+}
+
 ATF_TC(cam_open_device_negative_test_O_RDONLY);
 ATF_TC_HEAD(cam_open_device_negative_test_O_RDONLY, tc)
 {
@@ -282,6 +309,7 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, cam_get_device_negative_test_nul_path);
ATF_TP_ADD_TC(tp, cam_get_device_negative_test_root);
ATF_TP_ADD_TC(tp, cam_get_device_positive_test);
+   ATF_TP_ADD_TC(tp, cam_get_device_sa_test);
ATF_TP_ADD_TC(tp, cam_open_device_negative_test_O_RDONLY);
ATF_TP_ADD_TC(tp, cam_open_device_negative_test_nonexistent);
ATF_TP_ADD_TC(tp, cam_open_device_negative_test_unprivileged);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326100 - head/sys/cam

2017-11-22 Thread Alan Somers
Author: asomers
Date: Wed Nov 22 19:57:34 2017
New Revision: 326100
URL: https://svnweb.freebsd.org/changeset/base/326100

Log:
  Always null-terminate CAM periph_name and dev_name
  
  Reported by:  Coverity
  CID:  1010039, 1010040, 1010041, 1010043
  Reviewed by:  ken, imp
  MFC after:3 weeks
  Sponsored by: Spectra Logic Corp
  Differential Revision:https://reviews.freebsd.org/D13194

Modified:
  head/sys/cam/cam_xpt.c

Modified: head/sys/cam/cam_xpt.c
==
--- head/sys/cam/cam_xpt.c  Wed Nov 22 18:06:41 2017(r326099)
+++ head/sys/cam/cam_xpt.c  Wed Nov 22 19:57:34 2017(r326100)
@@ -686,8 +686,9 @@ xptdoioctl(struct cdev *dev, u_long cmd, caddr_t addr,
/*
 * Fill in the getdevlist fields.
 */
-   strcpy(ccb->cgdl.periph_name,
-  periph->periph_name);
+   strlcpy(ccb->cgdl.periph_name,
+  periph->periph_name,
+  sizeof(ccb->cgdl.periph_name));
ccb->cgdl.unit_number =
periph->unit_number;
if (SLIST_NEXT(periph, periph_links))
@@ -1756,8 +1757,9 @@ xptedtbusfunc(struct cam_eb *bus, void *arg)
cdm->matches[j].result.bus_result.bus_id = bus->sim->bus_id;
cdm->matches[j].result.bus_result.unit_number =
bus->sim->unit_number;
-   strncpy(cdm->matches[j].result.bus_result.dev_name,
-   bus->sim->sim_name, DEV_IDLEN);
+   strlcpy(cdm->matches[j].result.bus_result.dev_name,
+   bus->sim->sim_name,
+   sizeof(cdm->matches[j].result.bus_result.dev_name));
}
 
/*
@@ -1976,6 +1978,7 @@ xptedtperiphfunc(struct cam_periph *periph, void *arg)
 */
if (retval & DM_RET_COPY) {
int spaceleft, j;
+   size_t l;
 
spaceleft = cdm->match_buf_len - (cdm->num_matches *
sizeof(struct dev_match_result));
@@ -2019,8 +2022,9 @@ xptedtperiphfunc(struct cam_periph *periph, void *arg)
periph->path->device->lun_id;
cdm->matches[j].result.periph_result.unit_number =
periph->unit_number;
-   strncpy(cdm->matches[j].result.periph_result.periph_name,
-   periph->periph_name, DEV_IDLEN);
+   l = sizeof(cdm->matches[j].result.periph_result.periph_name);
+   strlcpy(cdm->matches[j].result.periph_result.periph_name,
+   periph->periph_name, l);
}
 
return(1);
@@ -2115,6 +2119,7 @@ xptplistperiphfunc(struct cam_periph *periph, void *ar
 */
if (retval & DM_RET_COPY) {
int spaceleft, j;
+   size_t l;
 
spaceleft = cdm->match_buf_len - (cdm->num_matches *
sizeof(struct dev_match_result));
@@ -2191,8 +2196,9 @@ xptplistperiphfunc(struct cam_periph *periph, void *ar
 
cdm->matches[j].result.periph_result.unit_number =
periph->unit_number;
-   strncpy(cdm->matches[j].result.periph_result.periph_name,
-   periph->periph_name, DEV_IDLEN);
+   l = sizeof(cdm->matches[j].result.periph_result.periph_name);
+   strlcpy(cdm->matches[j].result.periph_result.periph_name,
+   periph->periph_name, l);
}
 
return(1);
@@ -2905,9 +2911,9 @@ call_sim:
 (nperiph != NULL) && (i <= cgdl->index);
 nperiph = SLIST_NEXT(nperiph, periph_links), i++) {
if (i == cgdl->index) {
-   strncpy(cgdl->periph_name,
+   strlcpy(cgdl->periph_name,
nperiph->periph_name,
-   DEV_IDLEN);
+   sizeof(cgdl->periph_name));
cgdl->unit_number = nperiph->unit_number;
found = 1;
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r325239 - head/sys/dev/ena

2017-11-22 Thread Gleb Smirnoff
  Michał,

  thanks for explanation. Looks like in this case software counters
are indeed superior to hardware ones.

On Wed, Nov 22, 2017 at 05:19:54PM +0100, Michał Krawczyk wrote:
M> Hi Gleb,
M> We are counting the statistics in the software because of the alignment
M> with the newest ena-com API (HAL) which is delivered to us from NIC's
M> vendor.
M> 
M> Regarding fetching them periodically - there are 2 issues with that. First
M> of all, there may be problem with the counter overflow. Secondly, reading
M> statistics on demand requires sending admin message to the NIC and then the
M> cv_timedwait function is called to wait for the response. However there are
M> a lot of witness warnings when the cv_timedwait is called from the
M> if_get_counter() context, because of the non sleepable lock which is hold
M> there (I don't remember exactly which lock was causing this issue).
M> 
M> Best regards,
M> Michal
M> 
M> 2017-11-22 1:08 GMT+01:00 Gleb Smirnoff :
M> 
M> >   Hi Martin and Michal,
M> >
M> > On Tue, Oct 31, 2017 at 04:31:23PM +, Marcin Wojtas wrote:
M> > M> Author: mw
M> > M> Date: Tue Oct 31 16:31:23 2017
M> > M> New Revision: 325239
M> > M> URL: https://svnweb.freebsd.org/changeset/base/325239
M> > M>
M> > M> Log:
M> > M>   Rework counting of hardware statistics in ENA driver
M> > M>
M> > M>   Do not read all statistics from the device, instead count them in the
M> > M>   driver except from RX drops - they are received directly from the NIC
M> > M>   in the AENQ descriptor.
M> > M>
M> > M>   Submitted by: Michal Krawczyk 
M> > M>   Reviewed by: imp
M> > M>   Obtained from: Semihalf
M> > M>   Sponsored by: Amazon.com, Inc.
M> > M>   Differential Revision: https://reviews.freebsd.org/D12852
M> >
M> > Is it possible not to count them in software, as well as not fetch
M> > them from hardware periodically, but instead just fetch them on
M> > demand, when either if_get_counter() or a sysctl is called?
M> >
M> > That would be more efficient.
M> >
M> > --
M> > Gleb Smirnoff
M> >

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


svn commit: r326099 - head/usr.bin/iscsictl

2017-11-22 Thread Niclas Zeising
Author: zeising (doc,ports committer)
Date: Wed Nov 22 18:06:41 2017
New Revision: 326099
URL: https://svnweb.freebsd.org/changeset/base/326099

Log:
  Fix language in a bunch of error messages.
  
  Reviewed by:  emaste
  Approved by:  emaste
  MFC after:1 month
  Differential Revision:D13193

Modified:
  head/usr.bin/iscsictl/iscsictl.c

Modified: head/usr.bin/iscsictl/iscsictl.c
==
--- head/usr.bin/iscsictl/iscsictl.cWed Nov 22 16:45:27 2017
(r326098)
+++ head/usr.bin/iscsictl/iscsictl.cWed Nov 22 18:06:41 2017
(r326099)
@@ -813,41 +813,41 @@ main(int argc, char **argv)
if (Aflag != 0) {
if (aflag != 0) {
if (enable != ENABLE_UNSPECIFIED)
-   xo_errx(1, "-a and -e and mutually exclusive");
+   xo_errx(1, "-a and -e are mutually exclusive");
if (portal != NULL)
-   xo_errx(1, "-a and -p and mutually exclusive");
+   xo_errx(1, "-a and -p are mutually exclusive");
if (target != NULL)
-   xo_errx(1, "-a and -t and mutually exclusive");
+   xo_errx(1, "-a and -t are mutually exclusive");
if (user != NULL)
-   xo_errx(1, "-a and -u and mutually exclusive");
+   xo_errx(1, "-a and -u are mutually exclusive");
if (secret != NULL)
-   xo_errx(1, "-a and -s and mutually exclusive");
+   xo_errx(1, "-a and -s are mutually exclusive");
if (nickname != NULL)
-   xo_errx(1, "-a and -n and mutually exclusive");
+   xo_errx(1, "-a and -n are mutually exclusive");
if (discovery_host != NULL)
-   xo_errx(1, "-a and -d and mutually exclusive");
+   xo_errx(1, "-a and -d are mutually exclusive");
if (rflag != 0)
-   xo_errx(1, "-a and -r and mutually exclusive");
+   xo_errx(1, "-a and -r are mutually exclusive");
} else if (nickname != NULL) {
if (enable != ENABLE_UNSPECIFIED)
-   xo_errx(1, "-n and -e and mutually exclusive");
+   xo_errx(1, "-n and -e are mutually exclusive");
if (portal != NULL)
-   xo_errx(1, "-n and -p and mutually exclusive");
+   xo_errx(1, "-n and -p are mutually exclusive");
if (target != NULL)
-   xo_errx(1, "-n and -t and mutually exclusive");
+   xo_errx(1, "-n and -t are mutually exclusive");
if (user != NULL)
-   xo_errx(1, "-n and -u and mutually exclusive");
+   xo_errx(1, "-n and -u are mutually exclusive");
if (secret != NULL)
-   xo_errx(1, "-n and -s and mutually exclusive");
+   xo_errx(1, "-n and -s are mutually exclusive");
if (discovery_host != NULL)
-   xo_errx(1, "-n and -d and mutually exclusive");
+   xo_errx(1, "-n and -d are mutually exclusive");
if (rflag != 0)
-   xo_errx(1, "-n and -r and mutually exclusive");
+   xo_errx(1, "-n and -r are mutually exclusive");
} else if (discovery_host != NULL) {
if (portal != NULL)
-   xo_errx(1, "-d and -p and mutually exclusive");
+   xo_errx(1, "-d and -p are mutually exclusive");
if (target != NULL)
-   xo_errx(1, "-d and -t and mutually exclusive");
+   xo_errx(1, "-d and -t are mutually exclusive");
} else {
if (target == NULL && portal == NULL)
xo_errx(1, "must specify -a, -n or -t/-p");
@@ -874,15 +874,15 @@ main(int argc, char **argv)
 
if (nickname != NULL) {
if (enable != ENABLE_UNSPECIFIED)
-   xo_errx(1, "-n and -e and mutually exclusive");
+   xo_errx(1, "-n and -e are mutually exclusive");
if (portal != NULL)
-   xo_errx(1, "-n and -p and mutually exclusive");
+   

Re: svn commit: r326036 - head/sys/cam/scsi

2017-11-22 Thread Justin T. Gibbs
I'm sure it was to improve the performance of some SSD we were testing at 
Spectra.

--
Justin

> On Nov 22, 2017, at 9:16 AM, Alan Somers  wrote:
> 
> I believe the original motivation was to reduce FLUSH CACHE EXT
> activity with some old SSDs that handled that command very slowly.
> gibbs might know more.
> 
> On Tue, Nov 21, 2017 at 1:14 PM, Ronald Klop  wrote:
>> Out of curiosity, What is the use case which this improves? Does happen in
>> daily usage or mostly in testing?
>> 
>> Regards,
>> Ronald.
>> 
>> 
>> 
>> On Mon, 20 Nov 2017 23:27:34 +0100, Alan Somers  wrote:
>> 
>>> Author: asomers
>>> Date: Mon Nov 20 22:27:33 2017
>>> New Revision: 326036
>>> URL: https://svnweb.freebsd.org/changeset/base/326036
>>> 
>>> Log:
>>>  da(4): Short-circuit unnecessary BIO_FLUSH commands
>>> sys/cam/scsi/scsi_da.c
>>>Complete BIO_FLUSH commands immediately if the da(4) device hasn't
>>>been written to since the last flush. If we haven't written to the
>>>device, there is no reason to send a flush.
>>> Submitted by:  gibbs
>>>  Reviewed by:  imp
>>>  MFC after:3 weeks
>>>  Sponsored by: Spectra Logic Corp
>>>  Differential Revision:https://reviews.freebsd.org/D13106
>>> 
>>> Modified:
>>>  head/sys/cam/scsi/scsi_da.c
>>> 
>>> Modified: head/sys/cam/scsi/scsi_da.c
>>> 
>>> ==
>>> --- head/sys/cam/scsi/scsi_da.c Mon Nov 20 22:18:24 2017(r326035)
>>> +++ head/sys/cam/scsi/scsi_da.c Mon Nov 20 22:27:33 2017(r326036)
>>> @@ -3038,6 +3038,18 @@ more:
>>>}
>>>case BIO_FLUSH:
>>>/*
>>> +* If we don't support sync cache, or the disk
>>> +* isn't dirty, FLUSH is a no-op.  Use the
>>> +* allocated * CCB for the next bio if one is
>>> +* available.
>>> +*/
>>> +   if ((softc->quirks & DA_Q_NO_SYNC_CACHE) != 0 ||
>>> +   (softc->flags & DA_FLAG_DIRTY) == 0) {
>>> +   biodone(bp);
>>> +   goto skipstate;
>>> +   }
>>> +
>>> +   /*
>>> * BIO_FLUSH doesn't currently communicate
>>> * range data, so we synchronize the cache
>>> * over the whole disk.  We also force
>>> @@ -3052,6 +3064,15 @@ more:
>>>   /*lb_count*/0,
>>>   SSD_FULL_SIZE,
>>>   da_default_timeout*1000);
>>> +   /*
>>> +* Clear the dirty flag before sending the
>>> command.
>>> +* Either this sync cache will be successful, or
>>> it
>>> +* will fail after a retry.  If it fails, it is
>>> +* unlikely to be successful if retried later, so
>>> +* we'll save ourselves time by just marking the
>>> +* device clean.
>>> +*/
>>> +   softc->flags &= ~DA_FLAG_DIRTY;
>>>break;
>>>case BIO_ZONE: {
>>>int error, queue_ccb;
>>> ___
>>> svn-src-...@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-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r326073 - head/usr.bin/systat

2017-11-22 Thread Bruce Evans

On Wed, 22 Nov 2017, Konstantin Belousov wrote:


On Wed, Nov 22, 2017 at 08:59:21AM +1100, Bruce Evans wrote:

On Tue, 21 Nov 2017, Konstantin Belousov wrote:


Log:
 systat: use and correctly display 64bit counters.

...
Using unsigned types gives sign extension bugs as usual.  In old versions
...

@@ -491,15 +495,15 @@ showkre(void)
putfloat(100.0 * s.v_kmem_map_size / kmem_size,
   STATROW + 1, STATCOL + 22, 2, 0, 1);

-   putint(pgtokb(total.t_arm), MEMROW + 2, MEMCOL + 4, 7);
-   putint(pgtokb(total.t_armshr), MEMROW + 2, MEMCOL + 12, 7);
-   putint(pgtokb(total.t_avm), MEMROW + 2, MEMCOL + 20, 8);
-   putint(pgtokb(total.t_avmshr), MEMROW + 2, MEMCOL + 29, 8);
-   putint(pgtokb(total.t_rm), MEMROW + 3, MEMCOL + 4, 7);
-   putint(pgtokb(total.t_rmshr), MEMROW + 3, MEMCOL + 12, 7);
-   putint(pgtokb(total.t_vm), MEMROW + 3, MEMCOL + 20, 8);
-   putint(pgtokb(total.t_vmshr), MEMROW + 3, MEMCOL + 29, 8);
-   putint(pgtokb(total.t_free), MEMROW + 2, MEMCOL + 38, 7);
+   putuint64(pgtokb(total.t_arm), MEMROW + 2, MEMCOL + 4, 7);
+   putuint64(pgtokb(total.t_armshr), MEMROW + 2, MEMCOL + 12, 7);
+   putuint64(pgtokb(total.t_avm), MEMROW + 2, MEMCOL + 20, 8);
+   putuint64(pgtokb(total.t_avmshr), MEMROW + 2, MEMCOL + 29, 8);
+   putuint64(pgtokb(total.t_rm), MEMROW + 3, MEMCOL + 4, 7);
+   putuint64(pgtokb(total.t_rmshr), MEMROW + 3, MEMCOL + 12, 7);
+   putuint64(pgtokb(total.t_vm), MEMROW + 3, MEMCOL + 20, 8);
+   putuint64(pgtokb(total.t_vmshr), MEMROW + 3, MEMCOL + 29, 8);
+   putuint64(pgtokb(total.t_free), MEMROW + 2, MEMCOL + 38, 7);


I see that a very recent expansion from int32_t to uint64_t didn't work
here.

Can you explain, please ?


Just that systat -v didn't automatically benefit from the expansion (since
it is not very well written, with hard-coded types.  Hard-coded ints were
at least simple.  Now it has lots of hard-coded uint64_t's, partly to
work around dehumanize_number() being broken as designed (this function
doesn't support numbers, but only supports uint64_t.  It would be a bit
much for it to support surreal numbers, but it doesn't even support signed
integers)).

I checked all programs in /usr/src that use t_avm (t_vm is too hard to grep
for).  (There aren't many.  Statistics utilities in ports probably have more
variations and more bugs altogether.)  None automatically benefited from the
change, and all still have sign type errors:
- systat/vmstat.c as above
- vmstat/vmstat.c:
  This is much uglier, since it has flags to control the dehumanized printing
  and uses libxo so it us ugly even without all the lexical style bugs added
  with libxo.

  vmstat does most things worse:
  - with hflag (this gives the dehumanized printing), it tries to print
memory sizes in bytes.  Even humans would have problems reading the
large decimal numbers resulting from sizes in bytes, but limited field
widths usually result in dehumanization to K or M (rarely G or T).
systat -v tries to print sizes in K (without the usually-redundant K
suffix) more consistently, but this has problems when the values in K
don't fit: vmstat does one thing better:
  if the size is too large to express in K, say just 4M, then vmstat
  will print 4M starting with the size in bytes, but vmstat starts with
  the size in K (4096) and will now print this as 4K, while the old
  version printed it as 4k.  4K of a size in K is almost as confusing
  as 4k of a size in K.

This is one of the few places where the expansion worked automatically,
because prthuman() already uses uint64_t (misspelled u_int64_t).  The
casts of sum.v_page_size to u_int64_t is now redundant as well as
misspelled.  It was needed even with int32_t fields because of the
bad units -- 2G in bytes is quite small.  This casts also gave sign
extension/overflow.  Now it has no effect.  Such casts are safer, but
uint64_t hard-coded in so many places the code might as well be
simplified by hard-coding here too.

  - the !hflag case is broken by blind expansion to use more 4 more columns
than are available even when all the fields fit (large numbers
mess this up more).  Also, the headers are broken with or without
hflag (the first header line no longer lines up with the second
header line.

  - without hflag, the code is similar to systat, but much more broken.  It
has the same fairly hard to reach overflows in pgtokb().  Now it has
undefined behaviour in all cases in xo_emit(), since the arg type
changed to uint64_t but the format is still %7d.  Previously this
only had undefined behaviour in overflowing cases (t_avm was int32_t,
but v_page_size is u_int, so pgtokb() had type u_int; in overflow
cases its value exceeds INT_MAX so the behaviour is undefined even
though the overflow didn't give undefined behaviour.

xo_emit() is not declared as __printflike()

svn commit: r326098 - head/sys/vm

2017-11-22 Thread Konstantin Belousov
Author: kib
Date: Wed Nov 22 16:45:27 2017
New Revision: 326098
URL: https://svnweb.freebsd.org/changeset/base/326098

Log:
  Return different error code for the guard page layout violation.
  
  On KERN_NO_SPACE error, as it is returned now, vm_map_find() continues
  the loop searching for the suitable range for the requested mapping
  with specific alignment.  Since the vm_map_findspace() succesfully
  finds the same place, the loop never ends.
  
  The errors returned from vm_map_stack() completely repeat the behavior
  of vm_map_insert() now, as suggested by Alan.
  
  Reported by:  Arto Pekkanen 
  PR:   223732
  Reviewed by:  alc, markj
  Discussed with:   jhb
  Sponsored by: The FreeBSD Foundation
  MFC after:3 days
  Differential revision:https://reviews.freebsd.org/D13186

Modified:
  head/sys/vm/vm_map.c

Modified: head/sys/vm/vm_map.c
==
--- head/sys/vm/vm_map.cWed Nov 22 16:39:24 2017(r326097)
+++ head/sys/vm/vm_map.cWed Nov 22 16:45:27 2017(r326098)
@@ -3612,12 +3612,13 @@ vm_map_stack_locked(vm_map_t map, vm_offset_t addrbos,
KASSERT(orient != (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP),
("bi-dir stack"));
 
-   sgp = (vm_size_t)stack_guard_page * PAGE_SIZE;
if (addrbos < vm_map_min(map) ||
-   addrbos > vm_map_max(map) ||
-   addrbos + max_ssize < addrbos ||
-   sgp >= max_ssize)
-   return (KERN_NO_SPACE);
+   addrbos + max_ssize > vm_map_max(map) ||
+   addrbos + max_ssize <= addrbos)
+   return (KERN_INVALID_ADDRESS);
+   sgp = (vm_size_t)stack_guard_page * PAGE_SIZE;
+   if (sgp >= max_ssize)
+   return (KERN_INVALID_ARGUMENT);
 
init_ssize = growsize;
if (max_ssize < init_ssize + sgp)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326097 - head/sys/vm

2017-11-22 Thread Alan Cox
Author: alc
Date: Wed Nov 22 16:39:24 2017
New Revision: 326097
URL: https://svnweb.freebsd.org/changeset/base/326097

Log:
  When vm_map_find(find_space = VMFS_OPTIMAL_SPACE) fails to find space, a
  second scan of the address space with find_space = VMFS_ANY_SPACE is
  performed.  Previously, vm_map_find() released and reacquired the map lock
  between the first and second scans.  However, there is no compelling
  reason to do so.  This revision modifies vm_map_find() to retain the map
  lock.
  
  Reviewed by:  jhb, kib, markj
  MFC after:1 week
  X-Differential Revision:  https://reviews.freebsd.org/D13155

Modified:
  head/sys/vm/vm_map.c

Modified: head/sys/vm/vm_map.c
==
--- head/sys/vm/vm_map.cWed Nov 22 15:54:52 2017(r326096)
+++ head/sys/vm/vm_map.cWed Nov 22 16:39:24 2017(r326097)
@@ -1513,18 +1513,18 @@ vm_map_find(vm_map_t map, vm_object_t object, vm_ooffs
} else
alignment = 0;
initial_addr = *addr;
+   vm_map_lock(map);
 again:
start = initial_addr;
-   vm_map_lock(map);
do {
if (find_space != VMFS_NO_SPACE) {
if (vm_map_findspace(map, start, length, addr) ||
(max_addr != 0 && *addr + length > max_addr)) {
-   vm_map_unlock(map);
if (find_space == VMFS_OPTIMAL_SPACE) {
find_space = VMFS_ANY_SPACE;
goto again;
}
+   vm_map_unlock(map);
return (KERN_NO_SPACE);
}
switch (find_space) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r326095 - head/usr.sbin/bsdinstall/scripts

2017-11-22 Thread Ian Lepore
On Wed, 2017-11-22 at 15:27 +, Emmanuel Vadot wrote:
> Author: manu
> Date: Wed Nov 22 15:27:47 2017
> New Revision: 326095
> URL: https://svnweb.freebsd.org/changeset/base/326095
> 
> Log:
>   bsdinstall: Add ntpdate option
>   
>   When you install a computer for the first time, the date in the CMOS 
> sometimes
>   not accurate and you need to ntpdate as ntpd will fail a the time difference
>   is too big.
>   Add an option in bsdinstall to enable ntpdate that will do that for us.
>   
>   Reviewed by:allanjude
>   Differential Revision:  https://reviews.freebsd.org/D13149
> 
> Modified:
>   head/usr.sbin/bsdinstall/scripts/services
> 
> Modified: head/usr.sbin/bsdinstall/scripts/services
> ==
> --- head/usr.sbin/bsdinstall/scripts/services Wed Nov 22 15:18:11 2017
> (r326094)
> +++ head/usr.sbin/bsdinstall/scripts/services Wed Nov 22 15:27:47 2017
> (r326095)
> @@ -46,6 +46,8 @@ DAEMONS=$( dialog --backtitle "FreeBSD Installer" \
>   local_unbound "Local caching validating resolver" ${local_unbound:-off} 
> \
>   sshd"Secure shell daemon" ${sshd_enable:-off} \
>   moused  "PS/2 mouse pointer on console" ${moused_enable:-off} \
> + ntpdate "Synchronize system and network time at bootime" \
> + ${ntpdate_enable:-off} \
>   ntpd"Synchronize system and network time" ${ntpd_enable:-off} \
>   powerd  "Adjust CPU frequency dynamically if supported" \
>   ${powerd_enable:-off} \
> 

The right way to enable a time-step at boot is to set the rc conf
variable ntpd_sync_on_start to YES.  ntpdate has been deprecated for
*years*.

-- Ian

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


Re: svn commit: r325239 - head/sys/dev/ena

2017-11-22 Thread Michał Krawczyk
Hi Gleb,
We are counting the statistics in the software because of the alignment
with the newest ena-com API (HAL) which is delivered to us from NIC's
vendor.

Regarding fetching them periodically - there are 2 issues with that. First
of all, there may be problem with the counter overflow. Secondly, reading
statistics on demand requires sending admin message to the NIC and then the
cv_timedwait function is called to wait for the response. However there are
a lot of witness warnings when the cv_timedwait is called from the
if_get_counter() context, because of the non sleepable lock which is hold
there (I don't remember exactly which lock was causing this issue).

Best regards,
Michal

2017-11-22 1:08 GMT+01:00 Gleb Smirnoff :

>   Hi Martin and Michal,
>
> On Tue, Oct 31, 2017 at 04:31:23PM +, Marcin Wojtas wrote:
> M> Author: mw
> M> Date: Tue Oct 31 16:31:23 2017
> M> New Revision: 325239
> M> URL: https://svnweb.freebsd.org/changeset/base/325239
> M>
> M> Log:
> M>   Rework counting of hardware statistics in ENA driver
> M>
> M>   Do not read all statistics from the device, instead count them in the
> M>   driver except from RX drops - they are received directly from the NIC
> M>   in the AENQ descriptor.
> M>
> M>   Submitted by: Michal Krawczyk 
> M>   Reviewed by: imp
> M>   Obtained from: Semihalf
> M>   Sponsored by: Amazon.com, Inc.
> M>   Differential Revision: https://reviews.freebsd.org/D12852
>
> Is it possible not to count them in software, as well as not fetch
> them from hardware periodically, but instead just fetch them on
> demand, when either if_get_counter() or a sysctl is called?
>
> That would be more efficient.
>
> --
> Gleb Smirnoff
>
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r326036 - head/sys/cam/scsi

2017-11-22 Thread Alan Somers
I believe the original motivation was to reduce FLUSH CACHE EXT
activity with some old SSDs that handled that command very slowly.
gibbs might know more.

On Tue, Nov 21, 2017 at 1:14 PM, Ronald Klop  wrote:
> Out of curiosity, What is the use case which this improves? Does happen in
> daily usage or mostly in testing?
>
> Regards,
> Ronald.
>
>
>
> On Mon, 20 Nov 2017 23:27:34 +0100, Alan Somers  wrote:
>
>> Author: asomers
>> Date: Mon Nov 20 22:27:33 2017
>> New Revision: 326036
>> URL: https://svnweb.freebsd.org/changeset/base/326036
>>
>> Log:
>>   da(4): Short-circuit unnecessary BIO_FLUSH commands
>>  sys/cam/scsi/scsi_da.c
>> Complete BIO_FLUSH commands immediately if the da(4) device hasn't
>> been written to since the last flush. If we haven't written to the
>> device, there is no reason to send a flush.
>>  Submitted by:  gibbs
>>   Reviewed by:  imp
>>   MFC after:3 weeks
>>   Sponsored by: Spectra Logic Corp
>>   Differential Revision:https://reviews.freebsd.org/D13106
>>
>> Modified:
>>   head/sys/cam/scsi/scsi_da.c
>>
>> Modified: head/sys/cam/scsi/scsi_da.c
>>
>> ==
>> --- head/sys/cam/scsi/scsi_da.c Mon Nov 20 22:18:24 2017(r326035)
>> +++ head/sys/cam/scsi/scsi_da.c Mon Nov 20 22:27:33 2017(r326036)
>> @@ -3038,6 +3038,18 @@ more:
>> }
>> case BIO_FLUSH:
>> /*
>> +* If we don't support sync cache, or the disk
>> +* isn't dirty, FLUSH is a no-op.  Use the
>> +* allocated * CCB for the next bio if one is
>> +* available.
>> +*/
>> +   if ((softc->quirks & DA_Q_NO_SYNC_CACHE) != 0 ||
>> +   (softc->flags & DA_FLAG_DIRTY) == 0) {
>> +   biodone(bp);
>> +   goto skipstate;
>> +   }
>> +
>> +   /*
>>  * BIO_FLUSH doesn't currently communicate
>>  * range data, so we synchronize the cache
>>  * over the whole disk.  We also force
>> @@ -3052,6 +3064,15 @@ more:
>>/*lb_count*/0,
>>SSD_FULL_SIZE,
>>da_default_timeout*1000);
>> +   /*
>> +* Clear the dirty flag before sending the
>> command.
>> +* Either this sync cache will be successful, or
>> it
>> +* will fail after a retry.  If it fails, it is
>> +* unlikely to be successful if retried later, so
>> +* we'll save ourselves time by just marking the
>> +* device clean.
>> +*/
>> +   softc->flags &= ~DA_FLAG_DIRTY;
>> break;
>> case BIO_ZONE: {
>> int error, queue_ccb;
>> ___
>> svn-src-...@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-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326096 - head/cddl/usr.sbin/dtrace/tests/tools

2017-11-22 Thread Mark Johnston
Author: markj
Date: Wed Nov 22 15:54:52 2017
New Revision: 326096
URL: https://svnweb.freebsd.org/changeset/base/326096

Log:
  Annotate pragma/err.invalidlibdep.ksh as EXFAIL.
  
  The test creates a D library with a "depends_on library" pragma
  referencing a non-existent library, and expects compilation to fail.
  However, as far as I can tell, libdtrace is supposed simply abort
  compilation of the library in this case, and continue. This behaviour
  is desirable when adding libraries which depend on optional KLDs, for
  example.
  
  MFC after:1 week

Modified:
  head/cddl/usr.sbin/dtrace/tests/tools/exclude.sh

Modified: head/cddl/usr.sbin/dtrace/tests/tools/exclude.sh
==
--- head/cddl/usr.sbin/dtrace/tests/tools/exclude.shWed Nov 22 15:27:47 
2017(r326095)
+++ head/cddl/usr.sbin/dtrace/tests/tools/exclude.shWed Nov 22 15:54:52 
2017(r326096)
@@ -139,6 +139,11 @@ exclude EXFAIL common/pid/tst.newprobes.ksh
 exclude EXFAIL common/pid/tst.provregex2.ksh
 exclude EXFAIL common/pid/tst.provregex4.ksh
 
+# This test appears to be invalid. dtrace is supposed to press on if a
+# depends_on pragma cannot be satisfied, per the comment above
+# dt_load_libs_dir() in libdtrace.
+exclude EXFAIL common/pragma/err.invalidlibdep.ksh
+
 # This test checks for a leading tab on a line before #define. That is illegal
 # on Solaris, but the clang pre-processor on FreeBSD is happy with code like
 # that.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2017-11-22 Thread Emmanuel Vadot
Author: manu
Date: Wed Nov 22 15:27:47 2017
New Revision: 326095
URL: https://svnweb.freebsd.org/changeset/base/326095

Log:
  bsdinstall: Add ntpdate option
  
  When you install a computer for the first time, the date in the CMOS sometimes
  not accurate and you need to ntpdate as ntpd will fail a the time difference
  is too big.
  Add an option in bsdinstall to enable ntpdate that will do that for us.
  
  Reviewed by:  allanjude
  Differential Revision:https://reviews.freebsd.org/D13149

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

Modified: head/usr.sbin/bsdinstall/scripts/services
==
--- head/usr.sbin/bsdinstall/scripts/services   Wed Nov 22 15:18:11 2017
(r326094)
+++ head/usr.sbin/bsdinstall/scripts/services   Wed Nov 22 15:27:47 2017
(r326095)
@@ -46,6 +46,8 @@ DAEMONS=$( dialog --backtitle "FreeBSD Installer" \
local_unbound "Local caching validating resolver" ${local_unbound:-off} 
\
sshd"Secure shell daemon" ${sshd_enable:-off} \
moused  "PS/2 mouse pointer on console" ${moused_enable:-off} \
+   ntpdate "Synchronize system and network time at bootime" \
+   ${ntpdate_enable:-off} \
ntpd"Synchronize system and network time" ${ntpd_enable:-off} \
powerd  "Adjust CPU frequency dynamically if supported" \
${powerd_enable:-off} \
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2017-11-22 Thread Ed Maste
Author: emaste
Date: Wed Nov 22 15:18:11 2017
New Revision: 326094
URL: https://svnweb.freebsd.org/changeset/base/326094

Log:
  Fix indentation in bsdinstall-created wpa_supplicant.conf
  
  r309934 cleaned up some cases in bsdinstall to use heredocs but broke
  the indentation of the generated output, because <<- heredocs strip
  leading tabs.
  
  PR:   221982
  Reviewed by:  allanjude, dteske
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D13190

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

Modified: head/usr.sbin/bsdinstall/scripts/wlanconfig
==
--- head/usr.sbin/bsdinstall/scripts/wlanconfig Wed Nov 22 14:13:40 2017
(r326093)
+++ head/usr.sbin/bsdinstall/scripts/wlanconfig Wed Nov 22 15:18:11 2017
(r326094)
@@ -280,14 +280,14 @@ if echo "$ENCRYPTION" | grep -q PSK; then
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
) || exec "$0" "$@"
awk 'sub(/^\t/,"")||1' \
-   >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF
-   network={
-   ssid="$NETWORK"
-   scan_ssid=$SCANSSID
-   psk="$PASS"
-   priority=5
-   }
-   EOF
+   >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
) || exec "$0" "$@"
awk 'sub(/^\t/,"")||1' \
-   >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF
-   network={
-   ssid="$NETWORK"
-   scan_ssid=$SCANSSID
-   key_mgmt=WPA-EAP$(
-   echo "$USERPASS" | awk '
-   NR == 1 { printf "\n\t\tidentity=\"%s\"", $1 }
-   NR == 2 { printf "\n\t\tpassword=\"%s\"", $1 }
-   ' )
-   priority=5
-   }
-   EOF
+   >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
) || exec "$0" "$@"
awk 'sub(/^\t/,"")||1' \
-   >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF
-   network={
-   ssid="$NETWORK"
-   scan_ssid=$SCANSSID
-   key_mgmt=NONE
-   wep_key0="$WEPKEY"
-   wep_tx_keyidx=0
-   priority=5
-   }
-   EOF
+   >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF
-   network={
-   ssid="$NETWORK"
-   scan_ssid=$SCANSSID
-   key_mgmt=NONE
-   priority=5
-   }
-   EOF
+   >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" 

svn commit: r326093 - head/sys/netinet

2017-11-22 Thread Mark Johnston
Author: markj
Date: Wed Nov 22 14:13:40 2017
New Revision: 326093
URL: https://svnweb.freebsd.org/changeset/base/326093

Log:
  Use the right variable for the IP header parameter to tcp:::send.
  
  This addresses a regression from r311225.
  
  MFC after:1 week

Modified:
  head/sys/netinet/tcp_subr.c

Modified: head/sys/netinet/tcp_subr.c
==
--- head/sys/netinet/tcp_subr.c Wed Nov 22 14:10:58 2017(r326092)
+++ head/sys/netinet/tcp_subr.c Wed Nov 22 14:13:40 2017(r326093)
@@ -1238,16 +1238,20 @@ tcp_respond(struct tcpcb *tp, void *ipgen, struct tcph
if (flags & TH_RST)
TCP_PROBE5(accept__refused, NULL, NULL, m, tp, nth);
 
-   TCP_PROBE5(send, NULL, tp, m, tp, nth);
 #ifdef INET6
-   if (isipv6)
-   (void) ip6_output(m, NULL, NULL, 0, NULL, NULL, inp);
+   if (isipv6) {
+   TCP_PROBE5(send, NULL, tp, ip6, tp, nth);
+   (void)ip6_output(m, NULL, NULL, 0, NULL, NULL, inp);
+   }
 #endif /* INET6 */
 #if defined(INET) && defined(INET6)
else
 #endif
 #ifdef INET
-   (void) ip_output(m, NULL, NULL, 0, NULL, inp);
+   {
+   TCP_PROBE5(send, NULL, tp, ip, tp, nth);
+   (void)ip_output(m, NULL, NULL, 0, NULL, inp);
+   }
 #endif
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2017-11-22 Thread Ruslan Bukin
Author: br
Date: Wed Nov 22 14:10:58 2017
New Revision: 326092
URL: https://svnweb.freebsd.org/changeset/base/326092

Log:
  o Invalidate the correct page in pmap_protect().
With this bug fix we don't need to invalidate all the entries.
  o Remove a call to pmap_invalidate_all(). This was never called
as the anyvalid variable is never set.
  
  Obtained from:arm64/pmap.c (r322797, r322800)
  Sponsored by: DARPA, AFRL

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

Modified: head/sys/riscv/riscv/pmap.c
==
--- head/sys/riscv/riscv/pmap.c Wed Nov 22 14:06:40 2017(r326091)
+++ head/sys/riscv/riscv/pmap.c Wed Nov 22 14:10:58 2017(r326092)
@@ -1804,7 +1804,6 @@ pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t 
pd_entry_t *l1, *l2;
pt_entry_t l3_pte, *l3;
struct spglist free;
-   int anyvalid;
 
/*
 * Perform an unsynchronized read.  This is, however, safe.
@@ -1812,7 +1811,6 @@ pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t 
if (pmap->pm_stats.resident_count == 0)
return;
 
-   anyvalid = 0;
SLIST_INIT(&free);
 
rw_rlock(&pvh_global_lock);
@@ -1885,8 +1883,6 @@ pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t 
}
if (lock != NULL)
rw_wunlock(lock);
-   if (anyvalid)
-   pmap_invalidate_all(pmap);
rw_runlock(&pvh_global_lock);   
PMAP_UNLOCK(pmap);
pmap_free_zero_pages(&free);
@@ -2014,14 +2010,11 @@ pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t
pmap_load_store(l3p, entry);
PTE_SYNC(l3p);
/* XXX: Use pmap_invalidate_range */
-   pmap_invalidate_page(pmap, va);
+   pmap_invalidate_page(pmap, sva);
}
}
}
PMAP_UNLOCK(pmap);
-
-   /* TODO: Only invalidate entries we are touching */
-   pmap_invalidate_all(pmap);
 }
 
 /*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r326073 - head/usr.bin/systat

2017-11-22 Thread Konstantin Belousov
On Wed, Nov 22, 2017 at 08:59:21AM +1100, Bruce Evans wrote:
> On Tue, 21 Nov 2017, Konstantin Belousov wrote:
> 
> > Log:
> >  systat: use and correctly display 64bit counters.
> >
> >  Following struct vmtotal changes, make systat use and correctly
> >  display 64-bit counters.  Switch to humanize_number(3) to overcome
> >  homegrown arithmetics limits in pretty printing large numbers.  Use
> >  1024 as a divisor for memory fields to make it consistent with other
> >  tools and users expectations.
> 
> I don't like dehumanize_number(), and it can't handle most cases in
> systat -v since most cases use floating point.
> 
> Using unsigned types gives sign extension bugs as usual.  In old versions
> version, large unsigned numbers (only their lower 32 bits) were not
> unintentionally printed in signed format to get an early warning about
> overflow when they reach half-way to 32-bit overflow.  This is no longer
> useful, but signed format is still used.  There are related sign extension
> bugs for non-64-bit fields that allow the early warning to still work.
> 
> > Modified: head/usr.bin/systat/vmstat.c
> > ==
> > --- head/usr.bin/systat/vmstat.cTue Nov 21 19:23:20 2017
> > (r326072)
> > +++ head/usr.bin/systat/vmstat.cTue Nov 21 19:55:32 2017
> > (r326073)
> > @@ -138,6 +140,8 @@ static float cputime(int);
> > static void dinfo(int, int, struct statinfo *, struct statinfo *);
> > static void getinfo(struct Info *);
> > static void putint(int, int, int, int);
> > +static void putuint64(uint64_t, int, int, int);
> > +static void do_putuint64(uint64_t, int, int, int, int);
> 
> Style bug (unsorting).
> 
> > static void putfloat(double, int, int, int, int, int);
> > static void putlongdouble(long double, int, int, int, int, int);
> > static int ucount(void);
> > @@ -491,15 +495,15 @@ showkre(void)
> > putfloat(100.0 * s.v_kmem_map_size / kmem_size,
> >STATROW + 1, STATCOL + 22, 2, 0, 1);
> >
> > -   putint(pgtokb(total.t_arm), MEMROW + 2, MEMCOL + 4, 7);
> > -   putint(pgtokb(total.t_armshr), MEMROW + 2, MEMCOL + 12, 7);
> > -   putint(pgtokb(total.t_avm), MEMROW + 2, MEMCOL + 20, 8);
> > -   putint(pgtokb(total.t_avmshr), MEMROW + 2, MEMCOL + 29, 8);
> > -   putint(pgtokb(total.t_rm), MEMROW + 3, MEMCOL + 4, 7);
> > -   putint(pgtokb(total.t_rmshr), MEMROW + 3, MEMCOL + 12, 7);
> > -   putint(pgtokb(total.t_vm), MEMROW + 3, MEMCOL + 20, 8);
> > -   putint(pgtokb(total.t_vmshr), MEMROW + 3, MEMCOL + 29, 8);
> > -   putint(pgtokb(total.t_free), MEMROW + 2, MEMCOL + 38, 7);
> > +   putuint64(pgtokb(total.t_arm), MEMROW + 2, MEMCOL + 4, 7);
> > +   putuint64(pgtokb(total.t_armshr), MEMROW + 2, MEMCOL + 12, 7);
> > +   putuint64(pgtokb(total.t_avm), MEMROW + 2, MEMCOL + 20, 8);
> > +   putuint64(pgtokb(total.t_avmshr), MEMROW + 2, MEMCOL + 29, 8);
> > +   putuint64(pgtokb(total.t_rm), MEMROW + 3, MEMCOL + 4, 7);
> > +   putuint64(pgtokb(total.t_rmshr), MEMROW + 3, MEMCOL + 12, 7);
> > +   putuint64(pgtokb(total.t_vm), MEMROW + 3, MEMCOL + 20, 8);
> > +   putuint64(pgtokb(total.t_vmshr), MEMROW + 3, MEMCOL + 29, 8);
> > +   putuint64(pgtokb(total.t_free), MEMROW + 2, MEMCOL + 38, 7);
> 
> I see that a very recent expansion from int32_t to uint64_t didn't work
> here.
Can you explain, please ?

> 
> > putint(total.t_rq - 1, PROCSROW + 2, PROCSCOL, 3);
> > putint(total.t_pw, PROCSROW + 2, PROCSCOL + 4, 3);
> > putint(total.t_dw, PROCSROW + 2, PROCSCOL + 8, 3);
> 
> This has larger sign extension bugs than before.  All the fields here are
> still int16_t.  putint() still takes int args, and so the int16_t's int
> converted to int.  The used to be printed as int, but now they are converted
> to uint64_t.  They shouldn't be negative, but if they are then the were 
> printed
> as negative.  Now the conversion to uint64_t has sign-extension bugs/overflows
> for negative values.  Negative values still be printed as negative via further
> overflows, but if the values are passed to dehumanize_number(), they are
> printed as enormous unsigned values.
I do not see a point in expanding the process counters to uint16_t. I
might do it if somebody has a realistic load with 30K processes in a
system.

Having 100K threads created simultaneously is quite affordable, so the
change could be useful one day.

> 
> Printing everything as 64 bits is a pessimization.  It would probably work
> to convert everything to float and use only putfloat().  This gives about
> 8 digits of accuracy and even that is often too many.  This was not done
> mainly because floating point was slower than integers.  Now it might
> be faster than uint64_t.
> 
> Flots could also be converted to integers except for printing the percentage
> and not much more.  A special case for the percentage would be easy to write
> and is already partly there to avoid printing 100.0 which is too wide.  This
> was not done mainly because 32-bit ints were t

svn commit: r326090 - head/stand/common

2017-11-22 Thread Toomas Soome
Author: tsoome
Date: Wed Nov 22 10:04:09 2017
New Revision: 326090
URL: https://svnweb.freebsd.org/changeset/base/326090

Log:
  net_parse_rootpath() has no parameters
  
  Add void for parameter list.

Modified:
  head/stand/common/dev_net.c

Modified: head/stand/common/dev_net.c
==
--- head/stand/common/dev_net.c Wed Nov 22 08:48:00 2017(r326089)
+++ head/stand/common/dev_net.c Wed Nov 22 10:04:09 2017(r326090)
@@ -382,7 +382,7 @@ net_print(int verbose)
  * It leaves just the pathname in the global rootpath.
  */
 uint32_t
-net_parse_rootpath()
+net_parse_rootpath(void)
 {
n_long addr = htonl(INADDR_NONE);
size_t i;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326089 - head/stand/efi/libefi

2017-11-22 Thread Toomas Soome
Author: tsoome
Date: Wed Nov 22 08:48:00 2017
New Revision: 326089
URL: https://svnweb.freebsd.org/changeset/base/326089

Log:
  loader.efi: efipart does not recognize partitionless disks
  
  Rework the block device handle check to allow more robust device
  classification. This is mostly usability issue - it can be quite confusing
  for user when no disks are listed with lsdev.
  
  Add more comments about what and why is done.
  
  Reviewed by:  imp
  Differential Revision:https://reviews.freebsd.org/D13026

Modified:
  head/stand/efi/libefi/efipart.c

Modified: head/stand/efi/libefi/efipart.c
==
--- head/stand/efi/libefi/efipart.c Wed Nov 22 06:36:55 2017
(r326088)
+++ head/stand/efi/libefi/efipart.c Wed Nov 22 08:48:00 2017
(r326089)
@@ -196,6 +196,72 @@ efipart_floppy(EFI_DEVICE_PATH *node)
 }
 
 /*
+ * Determine if the provided device path is hdd.
+ *
+ * There really is no simple fool proof way to classify the devices.
+ * Since we do build three lists of devices - floppy, cd and hdd, we
+ * will try to see  if the device is floppy or cd, and list anything else
+ * as hdd.
+ */
+static bool
+efipart_hdd(EFI_DEVICE_PATH *dp)
+{
+   unsigned i, nin;
+   EFI_DEVICE_PATH *devpath, *node;
+   EFI_BLOCK_IO *blkio;
+   EFI_STATUS status;
+
+   if (dp == NULL)
+   return (false);
+
+   if ((node = efi_devpath_last_node(dp)) == NULL)
+   return (false);
+
+   if (efipart_floppy(node) != NULL)
+   return (false);
+
+   /*
+* Test every EFI BLOCK IO handle to make sure dp is not device path
+* for CD/DVD.
+*/
+   nin = efipart_nhandles / sizeof (*efipart_handles);
+   for (i = 0; i < nin; i++) {
+   devpath = efi_lookup_devpath(efipart_handles[i]);
+   if (devpath == NULL)
+   return (false);
+
+   /* Only continue testing when dp is prefix in devpath. */
+   if (!efi_devpath_is_prefix(dp, devpath))
+   continue;
+
+   /*
+* The device path has to have last node describing the
+*  device, or we can not test the type.
+*/
+   if ((node = efi_devpath_last_node(devpath)) == NULL)
+   return (false);
+
+   if (DevicePathType(node) == MEDIA_DEVICE_PATH &&
+   DevicePathSubType(node) == MEDIA_CDROM_DP) {
+   return (false);
+   }
+
+   /* Make sure we do have the media. */
+   status = BS->HandleProtocol(efipart_handles[i],
+   &blkio_guid, (void **)&blkio);
+   if (EFI_ERROR(status))
+   return (false);
+
+   /* USB or SATA cd without the media. */
+   if (blkio->Media->RemovableMedia &&
+   !blkio->Media->MediaPresent) {
+   return (false);
+   }
+   }
+   return (true);
+}
+
+/*
  * Add or update entries with new handle data.
  */
 static int
@@ -308,9 +374,13 @@ efipart_updatecd(void)
 
if ((node = efi_devpath_last_node(devpath)) == NULL)
continue;
+
if (efipart_floppy(node) != NULL)
continue;
 
+   if (efipart_hdd(devpath))
+   continue;
+
status = BS->HandleProtocol(efipart_handles[i],
&blkio_guid, (void **)&blkio);
if (EFI_ERROR(status))
@@ -380,13 +450,21 @@ efipart_hdinfo_add(EFI_HANDLE disk_handle, EFI_HANDLE 
pdinfo_t *hd, *pd, *last;
 
disk_devpath = efi_lookup_devpath(disk_handle);
-   part_devpath = efi_lookup_devpath(part_handle);
-   if (disk_devpath == NULL || part_devpath == NULL) {
+   if (disk_devpath == NULL)
return (ENOENT);
+
+   if (part_handle != NULL) {
+   part_devpath = efi_lookup_devpath(part_handle);
+   if (part_devpath == NULL)
+   return (ENOENT);
+   node = (HARDDRIVE_DEVICE_PATH *)
+   efi_devpath_last_node(part_devpath);
+   if (node == NULL)
+   return (ENOENT);/* This should not happen. */
+   } else {
+   part_devpath = NULL;
+   node = NULL;
}
-   node = (HARDDRIVE_DEVICE_PATH *)efi_devpath_last_node(part_devpath);
-   if (node == NULL)
-   return (ENOENT);/* This should not happen. */
 
pd = calloc(1, sizeof(pdinfo_t));
if (pd == NULL) {
@@ -397,6 +475,9 @@ efipart_hdinfo_add(EFI_HANDLE disk_handle, EFI_HANDLE 
 
STAILQ_FOREACH(hd, &hdinfo, pd_link) {
if (efi_devpath_match(hd->pd_devpath, disk_devpath) == true) {
+   if (part_devpath == NULL)
+