Re: svn commit: r330784 - stable/11/sys/dev/iwm

2018-03-12 Thread Pintér , Olivér
On Sun, Mar 11, 2018 at 11:49 PM, Eitan Adler  wrote:

> Author: eadler
> Date: Sun Mar 11 22:49:46 2018
> New Revision: 330784
> URL: https://svnweb.freebsd.org/changeset/base/330784
>
> Log:
>   Revert r324434
>

Wrong revision here^ based on this:
https://svnweb.freebsd.org/base?view=revision=324434


>
>   Some users are reporting that it is causing issues for their hardware.
>   In the interest of not breaking stable, revert while we investigate.
>
> Modified:
>   stable/11/sys/dev/iwm/if_iwm.c
> Directory Properties:
>   stable/11/   (props changed)
>
> Modified: stable/11/sys/dev/iwm/if_iwm.c
> 
> ==
> --- stable/11/sys/dev/iwm/if_iwm.c  Sun Mar 11 20:13:15 2018
> (r330783)
> +++ stable/11/sys/dev/iwm/if_iwm.c  Sun Mar 11 22:49:46 2018
> (r330784)
> @@ -547,14 +547,12 @@ iwm_read_firmware(struct iwm_softc *sc, enum
> iwm_ucode
>  {
> struct iwm_fw_info *fw = >sc_fw;
> const struct iwm_tlv_ucode_header *uhdr;
> -   const struct iwm_ucode_tlv *tlv;
> +   struct iwm_ucode_tlv tlv;
> struct iwm_ucode_capabilities *capa = >ucode_capa;
> enum iwm_ucode_tlv_type tlv_type;
> const struct firmware *fwp;
> const uint8_t *data;
> -   uint32_t tlv_len;
> uint32_t usniffer_img;
> -   const uint8_t *tlv_data;
> uint32_t paging_mem_size;
> int num_of_cpus;
> int error = 0;
> @@ -607,21 +605,25 @@ iwm_read_firmware(struct iwm_softc *sc, enum
> iwm_ucode
> goto out;
> }
>
> -   snprintf(sc->sc_fwver, sizeof(sc->sc_fwver), "%u.%u (API ver %u)",
> +   snprintf(sc->sc_fwver, sizeof(sc->sc_fwver), "%d.%d (API ver %d)",
> IWM_UCODE_MAJOR(le32toh(uhdr->ver)),
> IWM_UCODE_MINOR(le32toh(uhdr->ver)),
> IWM_UCODE_API(le32toh(uhdr->ver)));
> data = uhdr->data;
> len = fw->fw_fp->datasize - sizeof(*uhdr);
>
> -   while (len >= sizeof(*tlv)) {
> -   len -= sizeof(*tlv);
> -   tlv = (const void *)data;
> +   while (len >= sizeof(tlv)) {
> +   size_t tlv_len;
> +   const void *tlv_data;
>
> -   tlv_len = le32toh(tlv->length);
> -   tlv_type = le32toh(tlv->type);
> -   tlv_data = tlv->data;
> +   memcpy(, data, sizeof(tlv));
> +   tlv_len = le32toh(tlv.length);
> +   tlv_type = le32toh(tlv.type);
>
> +   len -= sizeof(tlv);
> +   data += sizeof(tlv);
> +   tlv_data = data;
> +
> if (len < tlv_len) {
> device_printf(sc->sc_dev,
> "firmware too short: %zu bytes\n",
> @@ -629,21 +631,19 @@ iwm_read_firmware(struct iwm_softc *sc, enum
> iwm_ucode
> error = EINVAL;
> goto parse_out;
> }
> -   len -= roundup2(tlv_len, 4);
> -   data += sizeof(tlv) + roundup2(tlv_len, 4);
>
> switch ((int)tlv_type) {
> case IWM_UCODE_TLV_PROBE_MAX_LEN:
> -   if (tlv_len != sizeof(uint32_t)) {
> +   if (tlv_len < sizeof(uint32_t)) {
> device_printf(sc->sc_dev,
> -   "%s: PROBE_MAX_LEN (%d) !=
> sizeof(uint32_t)\n",
> +   "%s: PROBE_MAX_LEN (%d) <
> sizeof(uint32_t)\n",
> __func__,
> (int) tlv_len);
> error = EINVAL;
> goto parse_out;
> }
> capa->max_probe_length =
> -   le32_to_cpup((const uint32_t *)tlv_data);
> +   le32toh(*(const uint32_t *)tlv_data);
> /* limit it to something sensible */
> if (capa->max_probe_length >
> IWM_SCAN_OFFLOAD_PROBE_REQ_SIZE) {
> @@ -674,14 +674,6 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode
> error = EINVAL;
> goto parse_out;
> }
> -   if (tlv_len % sizeof(uint32_t)) {
> -   device_printf(sc->sc_dev,
> -   "%s: IWM_UCODE_TLV_FLAGS: tlv_len (%d)
> %% sizeof(uint32_t)\n",
> -   __func__,
> -   (int) tlv_len);
> -   error = EINVAL;
> -   goto parse_out;
> -   }
> /*
>  * Apparently there can be many flags, but Linux
> driver
>  * parses only the first one, and so do we.
> @@ -693,7 

Re: svn commit: r330338 - head/sys/amd64/amd64

2018-03-12 Thread Andriy Gapon
On 09/03/2018 21:22, John Baldwin wrote:
> On Saturday, March 03, 2018 03:10:37 PM Andriy Gapon wrote:
>> Author: avg
>> Date: Sat Mar  3 15:10:37 2018
>> New Revision: 330338
>> URL: https://svnweb.freebsd.org/changeset/base/330338
>>
>> Log:
>>   db_nextframe/amd64: catch up with r328083 to recognize fast_syscall_common
>>   
>>   Since that change the system call stack traces look like this:
>> ...
>> sys___sysctl() at sys___sysctl+0x5f/frame 0xfe0028e13ac0
>> amd64_syscall() at amd64_syscall+0x79b/frame 0xfe0028e13bf0
>> fast_syscall_common() at fast_syscall_common+0x101/frame 
>> 0xfe0028e13bf0
>>   So, db_nextframe() stopped recognizing the system call frame.
>>   This commit should fix that.
>>   
>>   Reviewed by:   kib
>>   MFC after: 4 days
>>
>> Modified:
>>   head/sys/amd64/amd64/db_trace.c
>>
>> Modified: head/sys/amd64/amd64/db_trace.c
>> ==
>> --- head/sys/amd64/amd64/db_trace.c  Sat Mar  3 13:20:44 2018
>> (r330337)
>> +++ head/sys/amd64/amd64/db_trace.c  Sat Mar  3 15:10:37 2018
>> (r330338)
>> @@ -212,7 +212,9 @@ db_nextframe(struct amd64_frame **fp, db_addr_t *ip, s
>>  strcmp(name, "Xcpususpend") == 0 ||
>>  strcmp(name, "Xrendezvous") == 0)
>>  frame_type = INTERRUPT;
>> -else if (strcmp(name, "Xfast_syscall") == 0)
>> +else if (strcmp(name, "Xfast_syscall") == 0 ||
>> +strcmp(name, "Xfast_syscall_pti") == 0 ||
>> +strcmp(name, "fast_syscall_common") == 0)
>>  frame_type = SYSCALL;
> 
> I think you actually just want to replace Xfast_syscall with
> fast_syscall_common.  Neither Xfast_syscall nor Xfast_syscall_pti call any
> functions before jumping to the common label, so when unwinding from a system
> call you should always get the common label.  (That is, I think we should
> remove Xfast_syscall and Xfast_syscall_pti here.  Any stack trace that
> happens to find those symbols during unwinding won't have a valid SYSCALL
> frame to unwind.)
> 

I kept / added those to, sort of, decouple db_nextframe from the current
implementation details.  I hope that the extra code does not create too much
overhead.

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


svn commit: r330792 - in head: sbin/ipfw sys/netpfil/ipfw

2018-03-12 Thread Andrey V. Elsukov
Author: ae
Date: Mon Mar 12 09:40:46 2018
New Revision: 330792
URL: https://svnweb.freebsd.org/changeset/base/330792

Log:
  Do not try to reassemble IPv6 fragments in "reass" rule.
  
  ip_reass() expects IPv4 packet and will just corrupt any IPv6 packets
  that it gets. Until proper IPv6 fragments handling function will be
  implemented, pass IPv6 packets to next rule.
  
  PR:   170604
  MFC after:1 week

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

Modified: head/sbin/ipfw/ipfw.8
==
--- head/sbin/ipfw/ipfw.8   Mon Mar 12 05:41:27 2018(r330791)
+++ head/sbin/ipfw/ipfw.8   Mon Mar 12 09:40:46 2018(r330792)
@@ -1,7 +1,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 26, 2017
+.Dd March 12, 2018
 .Dt IPFW 8
 .Os
 .Sh NAME
@@ -1135,7 +1135,7 @@ Regardless of matched a packet or not by the
 .Cm tcp-setmss
 rule, the search continues with the next rule.
 .It Cm reass
-Queue and reassemble IP fragments.
+Queue and reassemble IPv4 fragments.
 If the packet is not fragmented, counters are updated and
 processing continues with the next rule.
 If the packet is the last logical fragment, the packet is reassembled and, if

Modified: head/sys/netpfil/ipfw/ip_fw2.c
==
--- head/sys/netpfil/ipfw/ip_fw2.c  Mon Mar 12 05:41:27 2018
(r330791)
+++ head/sys/netpfil/ipfw/ip_fw2.c  Mon Mar 12 09:40:46 2018
(r330792)
@@ -3018,8 +3018,10 @@ do { 
\
case O_REASS: {
int ip_off;
 
-   IPFW_INC_RULE_COUNTER(f, pktlen);
l = 0;  /* in any case exit inner loop */
+   if (is_ipv6) /* IPv6 is not supported yet */
+   break;
+   IPFW_INC_RULE_COUNTER(f, pktlen);
ip_off = ntohs(ip->ip_off);
 
/* if not fragmented, go to next rule */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2018-03-12 Thread Andriy Gapon
Author: avg
Date: Mon Mar 12 11:28:09 2018
New Revision: 330793
URL: https://svnweb.freebsd.org/changeset/base/330793

Log:
  fix r297857, do not modify CPU extension bits under virtual machines
  
  r297857 was meant for real hardware only.
  
  PR:   213155
  Submitted by: mainl...@apeiron.net
  MFC after:1 week

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

Modified: head/sys/x86/x86/identcpu.c
==
--- head/sys/x86/x86/identcpu.c Mon Mar 12 09:40:46 2018(r330792)
+++ head/sys/x86/x86/identcpu.c Mon Mar 12 11:28:09 2018(r330793)
@@ -1395,7 +1395,8 @@ fix_cpuid(void)
 * See BIOS and Kernel Developer’s Guide (BKDG) for AMD Family 15h
 * Models 60h-6Fh Processors, Publication # 50742.
 */
-   if (cpu_vendor_id == CPU_VENDOR_AMD && CPUID_TO_FAMILY(cpu_id) == 0x15) 
{
+   if (vm_guest == VM_GUEST_NO && cpu_vendor_id == CPU_VENDOR_AMD &&
+   CPUID_TO_FAMILY(cpu_id) == 0x15) {
msr = rdmsr(MSR_EXTFEATURES);
if ((msr & ((uint64_t)1 << 54)) == 0) {
msr |= (uint64_t)1 << 54;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330798 - in head/sys: compat/linux i386/linux

2018-03-12 Thread Ed Maste
Author: emaste
Date: Mon Mar 12 15:35:24 2018
New Revision: 330798
URL: https://svnweb.freebsd.org/changeset/base/330798

Log:
  Linuxulator: apply style(9) to return
  
  Sponsored by: Turing Robotic Industries Inc.

Modified:
  head/sys/compat/linux/linux_ioctl.c
  head/sys/compat/linux/linux_signal.c
  head/sys/compat/linux/linux_stats.c
  head/sys/compat/linux/linux_util.c
  head/sys/i386/linux/imgact_linux.c
  head/sys/i386/linux/linux_machdep.c

Modified: head/sys/compat/linux/linux_ioctl.c
==
--- head/sys/compat/linux/linux_ioctl.c Mon Mar 12 15:26:11 2018
(r330797)
+++ head/sys/compat/linux/linux_ioctl.c Mon Mar 12 15:35:24 2018
(r330798)
@@ -385,7 +385,7 @@ linux_to_bsd_speed(int code, struct speedtab *table)
for ( ; table->sp_code != -1; table++)
if (table->sp_code == code)
return (table->sp_speed);
-   return -1;
+   return (-1);
 }
 
 static int
@@ -394,7 +394,7 @@ bsd_to_linux_speed(int speed, struct speedtab *table)
for ( ; table->sp_speed != -1; table++)
if (table->sp_speed == speed)
return (table->sp_code);
-   return -1;
+   return (-1);
 }
 
 static void
@@ -2668,7 +2668,7 @@ static int
 linux_ioctl_drm(struct thread *td, struct linux_ioctl_args *args)
 {
args->cmd = SETDIR(args->cmd);
-   return sys_ioctl(td, (struct ioctl_args *)args);
+   return (sys_ioctl(td, (struct ioctl_args *)args));
 }
 
 #ifdef COMPAT_LINUX32
@@ -3275,9 +3275,9 @@ linux_to_bsd_v4l2_format(struct l_v4l2_format *lvf, st
 * XXX TODO - needs 32 -> 64 bit conversion:
 * (unused by webcams?)
 */
-   return EINVAL;
+   return (EINVAL);
memcpy(>fmt, >fmt, sizeof(vf->fmt));
-   return 0;
+   return (0);
 }
 
 static int
@@ -3293,9 +3293,9 @@ bsd_to_linux_v4l2_format(struct v4l2_format *vf, struc
 * XXX TODO - needs 32 -> 64 bit conversion:
 * (unused by webcams?)
 */
-   return EINVAL;
+   return (EINVAL);
memcpy(>fmt, >fmt, sizeof(vf->fmt));
-   return 0;
+   return (0);
 }
 static int
 linux_ioctl_v4l2(struct thread *td, struct linux_ioctl_args *args)
@@ -3315,7 +3315,7 @@ linux_ioctl_v4l2(struct thread *td, struct linux_ioctl
case LINUX_VIDIOC_RESERVED:
case LINUX_VIDIOC_LOG_STATUS:
if ((args->cmd & IOC_DIRMASK) != LINUX_IOC_VOID)
-   return ENOIOCTL;
+   return (ENOIOCTL);
args->cmd = (args->cmd & 0x) | IOC_VOID;
break;
 

Modified: head/sys/compat/linux/linux_signal.c
==
--- head/sys/compat/linux/linux_signal.cMon Mar 12 15:26:11 2018
(r330797)
+++ head/sys/compat/linux/linux_signal.cMon Mar 12 15:35:24 2018
(r330798)
@@ -279,7 +279,7 @@ linux_rt_sigprocmask(struct thread *td, struct linux_r
 #endif
 
if (args->sigsetsize != sizeof(l_sigset_t))
-   return EINVAL;
+   return (EINVAL);
 
if (args->mask != NULL) {
error = copyin(args->mask, , sizeof(l_sigset_t));
@@ -377,7 +377,7 @@ linux_rt_sigpending(struct thread *td, struct linux_rt
l_sigset_t lset;
 
if (args->sigsetsize > sizeof(lset))
-   return EINVAL;
+   return (EINVAL);
/* NOT REACHED */
 
 #ifdef DEBUG

Modified: head/sys/compat/linux/linux_stats.c
==
--- head/sys/compat/linux/linux_stats.c Mon Mar 12 15:26:11 2018
(r330797)
+++ head/sys/compat/linux/linux_stats.c Mon Mar 12 15:35:24 2018
(r330798)
@@ -436,7 +436,7 @@ linux_statfs64(struct thread *td, struct linux_statfs6
int error;
 
if (args->bufsize != sizeof(struct l_statfs64))
-   return EINVAL;
+   return (EINVAL);
 
LCONVPATHEXIST(td, args->path, );
 

Modified: head/sys/compat/linux/linux_util.c
==
--- head/sys/compat/linux/linux_util.c  Mon Mar 12 15:26:11 2018
(r330797)
+++ head/sys/compat/linux/linux_util.c  Mon Mar 12 15:35:24 2018
(r330798)
@@ -116,7 +116,7 @@ linux_driver_get_name_dev(device_t dev)
const char *device_name = device_get_name(dev);
 
if (device_name == NULL)
-   return NULL;
+   return (NULL);
TAILQ_FOREACH(de, , list) {
if (strcmp(device_name, de->entry.bsd_driver_name) == 0)
return (de->entry.linux_driver_name);
@@ -133,7 +133,7 @@ linux_driver_get_major_minor(const char *node, int *ma
size_t sz;
 
if (node == NULL || major == NULL || 

Re: svn commit: r330780 - in head/sys: amd64/include isa x86/isa

2018-03-12 Thread Ian Lepore
On Sun, 2018-03-11 at 23:25 +0200, Konstantin Belousov wrote:
> On Sun, Mar 11, 2018 at 02:20:39PM -0600, Ian Lepore wrote:
> > 
> > On Sun, 2018-03-11 at 21:58 +0200, Konstantin Belousov wrote:
> > > 
> > > On Sun, Mar 11, 2018 at 07:22:58PM +, Ian Lepore wrote:
> > > > 
> > > > 
> > > > [...]
> > 
> > Unfortunately, this reverts one type of wrong locking back to another.
> >  The need is to prevent access to the atrtc hardware if efi is
> > accessing it, and the locking I just reverted to that uses a sleepable
> > mutex only protects against inittodr()/resettodr() access, but not
> > against nvram(4) or if the atrtc is being used as an eventtimer (of
> > course nobody uses it for that, but the driver supports it).
> > 
> > I have some pending changes that cause the atrtc driver to just not
> > attach at all if the efirtc driver attached, but they're stacked up
> > behind some other changes in phab.  And that still doesn't fix the
> > nvram(4) part of it.
> Not attaching atrtc if efirtc is attached sounds reasonable. But then
> you should also disable efirt attach if atrtc is on. One possible issue
> is that efirt is typicall loadable, while atrtc is compiled into the
> kernel, which means that efirt would become virtually unusable.
> 

Even if efirt is loaded (in loader(8)) the efirtc driver will still
attach instead of atrtc, because it's a direct child of nexus and gets
the first opportunity to probe and attach.  But you raise a good point,
I should make it handle the case where it gets kldload'd when atrtc is
already attached.

> For nvram(4), you can take the atrtc_time_lock around accesses in addition
> to the atrtc_lock, instead of providing exclusivity on the level of drivers
> attach.

It occurs to me that an even better fix for all of this would be to
remove support for atrtc being an eventtimer.  That allows removing the
interrupt filter handler, and then there's no need for a spinlock at
all, a sleepable mutex works fine for all accesses.

Does anybody really need an eventtimer that runs only at a fixed
periodic rate of 32khz in 2018?

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


Re: svn commit: r330711 - head/sbin/sysctl

2018-03-12 Thread John Baldwin
On Saturday, March 10, 2018 10:46:53 AM Eugene Grosbein wrote:
> 10.03.2018 6:37, John Baldwin wrote:
> 
> > Author: jhb
> > Date: Fri Mar  9 23:37:19 2018
> > New Revision: 330711
> > URL: https://svnweb.freebsd.org/changeset/base/330711
> > 
> > Log:
> >   Permit sysctl(8) to set an array of numeric values for a single node.
> >   
> >   Most sysctl nodes only return a single value, but some nodes return an
> >   array of values (e.g. kern.cp_time).  sysctl(8) understand how to display
> >   the values of a node that returns multiple values (it prints out each
> >   numeric value separated by spaces).  However, until now sysctl(8) has
> >   only been able to set sysctl nodes to a single value.  This change
> >   allows sysctl to accept a new value for a numeric sysctl node that 
> > contains
> >   multiple values separated by either spaces or commas.  sysctl(8) parses
> >   this list into an array of values and passes the array as the "new" value
> >   to sysctl(2).
> 
> Note well: we already have some examples of complex sysctl comma-separated 
> "list" values such as:
> 
> security.mac.portacl.rules=uid:53:tcp:53,uid:53:udp:53

Yes, but those are stored as strings (CTLTYPE_STRING) and require string parsing
in the kernel.  This permits nodes that just need a flat array of integers to be
set without requiring string parsing in the kernel.

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


Re: svn commit: r330783 - in head/sys: amd64/include isa x86/isa

2018-03-12 Thread Hans Petter Selasky

On 03/11/18 21:13, Ian Lepore wrote:

-struct mtx atrtc_lock;
+static struct mtx atrtc_lock;
  MTX_SYSINIT(atrtc_lock_init, _lock, "atrtc", MTX_SPIN);
  
+struct mtx atrtc_time_lock;

+MTX_SYSINIT(atrtc_time_lock_init, _time_lock, "atrtc", MTX_DEF);


One of my boxes panics now because there are two locks with same name!

I have:
debug.witness.skipspin=0

In /boot/loader.conf.

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


svn commit: r330795 - head/lib/libsysdecode

2018-03-12 Thread Bjoern A. Zeeb
Author: bz
Date: Mon Mar 12 13:32:51 2018
New Revision: 330795
URL: https://svnweb.freebsd.org/changeset/base/330795

Log:
  The vmresult table was missing most of the values apart from two due to
  extra "_" in the names we grep for. Add the "_" to the pattern.
  
  Reviewed by:  jhb
  MFC after:3 days
  Sponsored by: iXsystems, Inc.

Modified:
  head/lib/libsysdecode/mktables

Modified: head/lib/libsysdecode/mktables
==
--- head/lib/libsysdecode/mktables  Mon Mar 12 12:21:19 2018
(r330794)
+++ head/lib/libsysdecode/mktables  Mon Mar 12 13:32:51 2018
(r330795)
@@ -146,7 +146,7 @@ gen_table "socktype""SOCK_[A-Z]+[[:space:]]+[1
 gen_table "thrcreateflags"  "THR_[A-Z]+[[:space:]]+0x[0-9]+"   
"sys/thr.h"
 gen_table "umtxop"  "UMTX_OP_[[:alnum:]_]+[[:space:]]+[0-9]+"  
"sys/umtx.h"
 gen_table "vmprot"  
"VM_PROT_[A-Z]+[[:space:]]+\(\(vm_prot_t\)[[:space:]]+0x[0-9]+\)"  "vm/vm.h"
-gen_table "vmresult""KERN_[A-Z]+[[:space:]]+[0-9]+"
"vm/vm_param.h"
+gen_table "vmresult""KERN_[A-Z_]+[[:space:]]+[0-9]+"   
"vm/vm_param.h"
 gen_table "wait6opt""W[A-Z]+[[:space:]]+[0-9]+"
"sys/wait.h"
 gen_table "seekwhence"  "SEEK_[A-Z]+[[:space:]]+[0-9]+"
"sys/unistd.h"
 gen_table "fcntlcmd""F_[A-Z0-9_]+[[:space:]]+[0-9]+[[:space:]]+"   
"sys/fcntl.h"   "F_CANCEL|F_..LCK"
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r330780 - in head/sys: amd64/include isa x86/isa

2018-03-12 Thread Ian Lepore
On Mon, 2018-03-12 at 17:56 +0200, Konstantin Belousov wrote:
> On Mon, Mar 12, 2018 at 09:34:51AM -0600, Ian Lepore wrote:
> > 
> > On Sun, 2018-03-11 at 23:25 +0200, Konstantin Belousov wrote:
> > > 
> > > On Sun, Mar 11, 2018 at 02:20:39PM -0600, Ian Lepore wrote:
> > > > 
> > > > 
> > > > On Sun, 2018-03-11 at 21:58 +0200, Konstantin Belousov wrote:
> > > > > 
> > > > > 
> > > > > On Sun, Mar 11, 2018 at 07:22:58PM +, Ian Lepore wrote:
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > [...]
> > > > Unfortunately, this reverts one type of wrong locking back to another.
> > > >  The need is to prevent access to the atrtc hardware if efi is
> > > > accessing it, and the locking I just reverted to that uses a sleepable
> > > > mutex only protects against inittodr()/resettodr() access, but not
> > > > against nvram(4) or if the atrtc is being used as an eventtimer (of
> > > > course nobody uses it for that, but the driver supports it).
> > > > 
> > > > I have some pending changes that cause the atrtc driver to just not
> > > > attach at all if the efirtc driver attached, but they're stacked up
> > > > behind some other changes in phab.  And that still doesn't fix the
> > > > nvram(4) part of it.
> > > Not attaching atrtc if efirtc is attached sounds reasonable. But then
> > > you should also disable efirt attach if atrtc is on. One possible issue
> > > is that efirt is typicall loadable, while atrtc is compiled into the
> > > kernel, which means that efirt would become virtually unusable.
> > > 
> > Even if efirt is loaded (in loader(8)) the efirtc driver will still
> > attach instead of atrtc, because it's a direct child of nexus and gets
> > the first opportunity to probe and attach.  But you raise a good point,
> > I should make it handle the case where it gets kldload'd when atrtc is
> > already attached.
> > 
> > > 
> > > For nvram(4), you can take the atrtc_time_lock around accesses in addition
> > > to the atrtc_lock, instead of providing exclusivity on the level of 
> > > drivers
> > > attach.
> > It occurs to me that an even better fix for all of this would be to
> > remove support for atrtc being an eventtimer.  That allows removing the
> > interrupt filter handler, and then there's no need for a spinlock at
> > all, a sleepable mutex works fine for all accesses.
> > 
> > Does anybody really need an eventtimer that runs only at a fixed
> > periodic rate of 32khz in 2018?
> Problem is that atrtc is what old machines use. If we have HPET or
> better LAPIC timers, then we do not need atrtc at all, of course.
> But e.g. 486 do not have them. I am not even sure about early amd64
> machines.

I think not unless someone has manually configured it that way.  The
i8254 timer should be used as both timecounter and eventtimer if there
is no lapic or hpet.  i8254 has an ET priority of 100 compared to
atrtc's 0.  That's by code inspection...  I might still have some
industrial SBCs around here old enough to not have hpet or lapic, I'll
see if I can get one running.

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


Re: svn commit: r330780 - in head/sys: amd64/include isa x86/isa

2018-03-12 Thread Bruce Evans

On Mon, 12 Mar 2018, Konstantin Belousov wrote:


On Mon, Mar 12, 2018 at 09:34:51AM -0600, Ian Lepore wrote:

On Sun, 2018-03-11 at 23:25 +0200, Konstantin Belousov wrote:

On Sun, Mar 11, 2018 at 02:20:39PM -0600, Ian Lepore wrote:


On Sun, 2018-03-11 at 21:58 +0200, Konstantin Belousov wrote:


On Sun, Mar 11, 2018 at 07:22:58PM +, Ian Lepore wrote:



[...]


Unfortunately, this reverts one type of wrong locking back to another.
?The need is to prevent access to the atrtc hardware if efi is
accessing it, and the locking I just reverted to that uses a sleepable
mutex only protects against inittodr()/resettodr() access, but not
against nvram(4) or if the atrtc is being used as an eventtimer (of
course nobody uses it for that, but the driver supports it).

I have some pending changes that cause the atrtc driver to just not
attach at all if the efirtc driver attached, but they're stacked up
behind some other changes in phab. ?And that still doesn't fix the
nvram(4) part of it.

Not attaching atrtc if efirtc is attached sounds reasonable. But then
you should also disable efirt attach if atrtc is on. One possible issue
is that efirt is typicall loadable, while atrtc is compiled into the
kernel, which means that efirt would become virtually unusable.


Even if efirt is loaded (in loader(8)) the efirtc driver will still
attach instead of atrtc, because it's a direct child of nexus and gets
the first opportunity to probe and attach. ?But you raise a good point,
I should make it handle the case where it gets kldload'd when atrtc is
already attached.


For nvram(4), you can take the atrtc_time_lock around accesses in addition
to the atrtc_lock, instead of providing exclusivity on the level of drivers
attach.


It occurs to me that an even better fix for all of this would be to
remove support for atrtc being an eventtimer. ?That allows removing the
interrupt filter handler, and then there's no need for a spinlock at
all, a sleepable mutex works fine for all accesses.


Sleep mutexes never work fine for real time clocks.  They give unbounded
time for clock accesses.


Does anybody really need an eventtimer that runs only at a fixed
periodic rate of 32khz in 2018?


Problem is that atrtc is what old machines use. If we have HPET or
better LAPIC timers, then we do not need atrtc at all, of course.
But e.g. 486 do not have them. I am not even sure about early amd64
machines.


The early AMD development board "Solo 2" has LAPIC.  It even has HPET
for a timecounter but not for an event timer.  My 2006 laptop doesn't
have HPET.

My version of FreeBSD-5 uses the 1 Hz RTC update interrupt for fixing
up the timecounter after stopping in ddb.  This should also be used
for fixing up the timecounter after suspension.  This doesn't need
full event timer support, but it needs full interrupt support including
spin mutexes.


Definitely any machine that needs EFIRT has both HPET and LAPIC, I like
the idea of not providing eventtimer backed by atrtc if feasible. Might
be, make this a compile or runtime option, unless this over-complicates
the code.


It's just more complicated to make it optional.  The top-level event timer
code supports using "any" timer in the system with very little driver
support, at least for drivers/hardware that only support periodic interrupts.

Everyone with a 486 needs an atrtc that runs at 128 Hz like it used to.
32 kHz wastes a lot of CPU even on newer systems.  Just reading 1 status
register in rtc_intr() takes at least 1 usec.  That is about 3% of the
CPU at 32 kHz.  rtcin() used to read 4 ISA registers (2 intentional
delays which are FUD mainly for 20-30 year old systems).  That is about
12% for the CPU at 32 kHz.  Probably more like 20%.  I optimized rtcin()
especially for this case (where the index register is almost constant).

SCHED_4BSD only needs 16 Hz, and only profiling needs more than 128 Hz.
I used hz = stathz = lapic_timer_hz = 100 (all periodic) for some time
before event timers existed.  This doesn't support fine-grained timeouts,
but I don't want them.  It gives much too synchronization between
hardclock and statclock interrupts. but not much more than with the
the old default lapic_timer_hz of 2000.

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


svn commit: r330801 - stable/10/lib/libc/sys

2018-03-12 Thread Brooks Davis
Author: brooks
Date: Mon Mar 12 16:04:10 2018
New Revision: 330801
URL: https://svnweb.freebsd.org/changeset/base/330801

Log:
  MFC r330409:
  
  Refer to SysV IPC permissions as numeric constants.
  
  POSIX defines no macros for these permissions.
  
  Also remove unneeded headers from synopsis.
  
  PR:   225905
  Reviewed by:  wblock
  Differential Revision:https://reviews.freebsd.org/D14461

Modified:
  stable/10/lib/libc/sys/msgget.2
  stable/10/lib/libc/sys/semget.2
  stable/10/lib/libc/sys/shmget.2
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/sys/msgget.2
==
--- stable/10/lib/libc/sys/msgget.2 Mon Mar 12 15:57:55 2018
(r330800)
+++ stable/10/lib/libc/sys/msgget.2 Mon Mar 12 16:04:10 2018
(r330801)
@@ -31,7 +31,7 @@
 .\" $FreeBSD$
 .\"
 .\"/
-.Dd July 9, 2009
+.Dd March 4, 2018
 .Dt MSGGET 2
 .Os
 .Sh NAME
@@ -40,8 +40,6 @@
 .Sh LIBRARY
 .Lb libc
 .Sh SYNOPSIS
-.In sys/types.h
-.In sys/ipc.h
 .In sys/msg.h
 .Ft int
 .Fn msgget "key_t key" "int msgflg"
@@ -83,7 +81,22 @@ are set to the effective gid of the calling process.
 .It
 .Va msg_perm.mode
 is set to the lower 9 bits of
-.Fa msgflg .
+.Fa msgflg
+which are set by ORing these constants:
+.Bl -tag -width 
+.It Dv 0400
+Read access for user.
+.It Dv 0200
+Write access for user.
+.It Dv 0040
+Read access for group.
+.It Dv 0020
+Write access for group.
+.It Dv 0004
+Read access for other.
+.It Dv 0002
+Write access for other.
+.El
 .It
 .Va msg_cbytes ,
 .Va msg_qnum ,

Modified: stable/10/lib/libc/sys/semget.2
==
--- stable/10/lib/libc/sys/semget.2 Mon Mar 12 15:57:55 2018
(r330800)
+++ stable/10/lib/libc/sys/semget.2 Mon Mar 12 16:04:10 2018
(r330801)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 7, 2016
+.Dd March 4, 2018
 .Dt SEMGET 2
 .Os
 .Sh NAME
@@ -34,8 +34,6 @@
 .Sh LIBRARY
 .Lb libc
 .Sh SYNOPSIS
-.In sys/types.h
-.In sys/ipc.h
 .In sys/sem.h
 .Ft int
 .Fn semget "key_t key" "int nsems" "int flag"
@@ -77,23 +75,22 @@ may be used to generate a key from a pathname.
 .\" Likewise for this section, except SHM_* becomes SEM_*.
 .\"
 .Pp
-The mode of a newly created IPC object is determined by
-.Em OR Ns 'ing
-the following constants into the
+The mode of a newly created IPC object is determined by ORing these constants
+into the
 .Fa flag
 argument:
-.Bl -tag -width XSEM_WXX6XXX
-.It Dv SEM_R
+.Bl -tag -width 
+.It Dv 0400
 Read access for user.
-.It Dv SEM_A
+.It Dv 0200
 Alter access for user.
-.It Dv ( SEM_R>>3 )
+.It Dv 0040
 Read access for group.
-.It Dv ( SEM_A>>3 )
+.It Dv 0020
 Alter access for group.
-.It Dv ( SEM_R>>6 )
+.It Dv 0004
 Read access for other.
-.It Dv ( SEM_A>>6 )
+.It Dv 0002
 Alter access for other.
 .El
 .Pp

Modified: stable/10/lib/libc/sys/shmget.2
==
--- stable/10/lib/libc/sys/shmget.2 Mon Mar 12 15:57:55 2018
(r330800)
+++ stable/10/lib/libc/sys/shmget.2 Mon Mar 12 16:04:10 2018
(r330801)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 17, 2010
+.Dd March 4, 2018
 .Dt SHMGET 2
 .Os
 .Sh NAME
@@ -34,8 +34,6 @@
 .Sh LIBRARY
 .Lb libc
 .Sh SYNOPSIS
-.In sys/types.h
-.In sys/ipc.h
 .In sys/shm.h
 .Ft int
 .Fn shmget "key_t key" "size_t size" "int flag"
@@ -74,22 +72,21 @@ may be used to generate a key from a pathname.
 .El
 .Pp
 The mode of a newly created IPC object is determined by
-.Em OR Ns 'ing
-the following constants into the
+which are set by ORing these constants into the
 .Fa flag
 argument:
-.Bl -tag -width XSHM_WXX6XXX
-.It Dv S_IRUSR
+.Bl -tag -width 
+.It Dv 0400
 Read access for owner.
-.It Dv S_IWUSR
+.It Dv 0200
 Write access for owner.
-.It Dv S_IRGRP
+.It Dv 0040
 Read access for group.
-.It Dv S_IWGRP
+.It Dv 0020
 Write access for group.
-.It Dv S_IROTH
+.It Dv 0004
 Read access for other.
-.It Dv S_IWOTH
+.It Dv 0002
 Write access for other.
 .El
 .\"
@@ -142,5 +139,4 @@ already exists.
 .Xr shmat 2 ,
 .Xr shmctl 2 ,
 .Xr shmdt 2 ,
-.Xr stat 2 ,
 .Xr ftok 3
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330800 - stable/11/lib/libc/sys

2018-03-12 Thread Brooks Davis
Author: brooks
Date: Mon Mar 12 15:57:55 2018
New Revision: 330800
URL: https://svnweb.freebsd.org/changeset/base/330800

Log:
  MFC r330409:
  
  Refer to SysV IPC permissions as numeric constants.
  
  POSIX defines no macros for these permissions.
  
  Also remove unneeded headers from synopsis.
  
  PR:   225905
  Reviewed by:  wblock
  Differential Revision:https://reviews.freebsd.org/D14461

Modified:
  stable/11/lib/libc/sys/msgget.2
  stable/11/lib/libc/sys/semget.2
  stable/11/lib/libc/sys/shmget.2
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libc/sys/msgget.2
==
--- stable/11/lib/libc/sys/msgget.2 Mon Mar 12 15:45:50 2018
(r330799)
+++ stable/11/lib/libc/sys/msgget.2 Mon Mar 12 15:57:55 2018
(r330800)
@@ -31,7 +31,7 @@
 .\" $FreeBSD$
 .\"
 .\"/
-.Dd July 9, 2009
+.Dd March 4, 2018
 .Dt MSGGET 2
 .Os
 .Sh NAME
@@ -40,8 +40,6 @@
 .Sh LIBRARY
 .Lb libc
 .Sh SYNOPSIS
-.In sys/types.h
-.In sys/ipc.h
 .In sys/msg.h
 .Ft int
 .Fn msgget "key_t key" "int msgflg"
@@ -83,7 +81,22 @@ are set to the effective gid of the calling process.
 .It
 .Va msg_perm.mode
 is set to the lower 9 bits of
-.Fa msgflg .
+.Fa msgflg
+which are set by ORing these constants:
+.Bl -tag -width 
+.It Dv 0400
+Read access for user.
+.It Dv 0200
+Write access for user.
+.It Dv 0040
+Read access for group.
+.It Dv 0020
+Write access for group.
+.It Dv 0004
+Read access for other.
+.It Dv 0002
+Write access for other.
+.El
 .It
 .Va msg_cbytes ,
 .Va msg_qnum ,

Modified: stable/11/lib/libc/sys/semget.2
==
--- stable/11/lib/libc/sys/semget.2 Mon Mar 12 15:45:50 2018
(r330799)
+++ stable/11/lib/libc/sys/semget.2 Mon Mar 12 15:57:55 2018
(r330800)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 7, 2016
+.Dd March 4, 2018
 .Dt SEMGET 2
 .Os
 .Sh NAME
@@ -34,8 +34,6 @@
 .Sh LIBRARY
 .Lb libc
 .Sh SYNOPSIS
-.In sys/types.h
-.In sys/ipc.h
 .In sys/sem.h
 .Ft int
 .Fn semget "key_t key" "int nsems" "int flag"
@@ -77,23 +75,22 @@ may be used to generate a key from a pathname.
 .\" Likewise for this section, except SHM_* becomes SEM_*.
 .\"
 .Pp
-The mode of a newly created IPC object is determined by
-.Em OR Ns 'ing
-the following constants into the
+The mode of a newly created IPC object is determined by ORing these constants
+into the
 .Fa flag
 argument:
-.Bl -tag -width XSEM_WXX6XXX
-.It Dv SEM_R
+.Bl -tag -width 
+.It Dv 0400
 Read access for user.
-.It Dv SEM_A
+.It Dv 0200
 Alter access for user.
-.It Dv ( SEM_R>>3 )
+.It Dv 0040
 Read access for group.
-.It Dv ( SEM_A>>3 )
+.It Dv 0020
 Alter access for group.
-.It Dv ( SEM_R>>6 )
+.It Dv 0004
 Read access for other.
-.It Dv ( SEM_A>>6 )
+.It Dv 0002
 Alter access for other.
 .El
 .Pp

Modified: stable/11/lib/libc/sys/shmget.2
==
--- stable/11/lib/libc/sys/shmget.2 Mon Mar 12 15:45:50 2018
(r330799)
+++ stable/11/lib/libc/sys/shmget.2 Mon Mar 12 15:57:55 2018
(r330800)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 17, 2010
+.Dd March 4, 2018
 .Dt SHMGET 2
 .Os
 .Sh NAME
@@ -34,8 +34,6 @@
 .Sh LIBRARY
 .Lb libc
 .Sh SYNOPSIS
-.In sys/types.h
-.In sys/ipc.h
 .In sys/shm.h
 .Ft int
 .Fn shmget "key_t key" "size_t size" "int flag"
@@ -74,22 +72,21 @@ may be used to generate a key from a pathname.
 .El
 .Pp
 The mode of a newly created IPC object is determined by
-.Em OR Ns 'ing
-the following constants into the
+which are set by ORing these constants into the
 .Fa flag
 argument:
-.Bl -tag -width XSHM_WXX6XXX
-.It Dv S_IRUSR
+.Bl -tag -width 
+.It Dv 0400
 Read access for owner.
-.It Dv S_IWUSR
+.It Dv 0200
 Write access for owner.
-.It Dv S_IRGRP
+.It Dv 0040
 Read access for group.
-.It Dv S_IWGRP
+.It Dv 0020
 Write access for group.
-.It Dv S_IROTH
+.It Dv 0004
 Read access for other.
-.It Dv S_IWOTH
+.It Dv 0002
 Write access for other.
 .El
 .\"
@@ -142,5 +139,4 @@ already exists.
 .Xr shmat 2 ,
 .Xr shmctl 2 ,
 .Xr shmdt 2 ,
-.Xr stat 2 ,
 .Xr ftok 3
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330796 - head/sys/cam/scsi

2018-03-12 Thread Warner Losh
Author: imp
Date: Mon Mar 12 15:17:16 2018
New Revision: 330796
URL: https://svnweb.freebsd.org/changeset/base/330796

Log:
  Tighten up periph lock to avoid some races
  
  Make sure the periph lock is held around rmw access to softc data,
  espeically flags, including work flags in iosched.
  Add asserts for the periph lock where it should be held.
  
  PR: 226510
  Sponsored by: Netflix
  Differential Review: https://reviews.freebsd.org/D14456

Modified:
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/scsi/scsi_da.c
==
--- head/sys/cam/scsi/scsi_da.c Mon Mar 12 13:32:51 2018(r330795)
+++ head/sys/cam/scsi/scsi_da.c Mon Mar 12 15:17:16 2018(r330796)
@@ -1909,6 +1909,7 @@ daoninvalidate(struct cam_periph *periph)
 {
struct da_softc *softc;
 
+   cam_periph_assert(periph, MA_OWNED);
softc = (struct da_softc *)periph->softc;
 
/*
@@ -2038,6 +2039,7 @@ daasync(void *callback_arg, u_int32_t code,
 * Handle all UNIT ATTENTIONs except our own,
 * as they will be handled by daerror().
 */
+   cam_periph_lock(periph);
if (xpt_path_periph(ccb->ccb_h.path) != periph &&
scsi_extract_sense_ccb(ccb,
 _code, _key, , )) {
@@ -2056,16 +2058,19 @@ daasync(void *callback_arg, u_int32_t code,
dareprobe(periph);
}
}
+   cam_periph_unlock(periph);
break;
}
case AC_SCSI_AEN:
softc = (struct da_softc *)periph->softc;
+   cam_periph_lock(periph);
if (!cam_iosched_has_work_flags(softc->cam_iosched, 
DA_WORK_TUR)) {
if (da_periph_acquire(periph, DA_REF_TUR) == 0) {
cam_iosched_set_work_flags(softc->cam_iosched, 
DA_WORK_TUR);
daschedule(periph);
}
}
+   cam_periph_unlock(periph);
/* FALLTHROUGH */
case AC_SENT_BDR:
case AC_BUS_RESET:
@@ -2077,15 +2082,19 @@ daasync(void *callback_arg, u_int32_t code,
 * Don't fail on the expected unit attention
 * that will occur.
 */
+   cam_periph_lock(periph);
softc->flags |= DA_FLAG_RETRY_UA;
LIST_FOREACH(ccbh, >pending_ccbs, periph_links.le)
ccbh->ccb_state |= DA_CCB_RETRY_UA;
+   cam_periph_unlock(periph);
break;
}
case AC_INQ_CHANGED:
+   cam_periph_lock(periph);
softc = (struct da_softc *)periph->softc;
softc->flags &= ~DA_FLAG_PROBED;
dareprobe(periph);
+   cam_periph_unlock(periph);
break;
default:
break;
@@ -2115,7 +2124,9 @@ dasysctlinit(void *context, int pending)
snprintf(tmpstr2, sizeof(tmpstr2), "%d", periph->unit_number);
 
sysctl_ctx_init(>sysctl_ctx);
+   cam_periph_lock(periph);
softc->flags |= DA_FLAG_SCTX_INIT;
+   cam_periph_unlock(periph);
softc->sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(>sysctl_ctx,
SYSCTL_STATIC_CHILDREN(_kern_cam_da), OID_AUTO, tmpstr2,
CTLFLAG_RD, 0, tmpstr, "device_index");
@@ -2647,7 +2658,7 @@ daregister(struct cam_periph *periph, void *arg)
callout_init_mtx(>sendordered_c, cam_periph_mtx(periph), 0);
callout_reset(>sendordered_c,
(da_default_timeout * hz) / DA_ORDEREDTAG_INTERVAL,
-   dasendorderedtag, softc);
+   dasendorderedtag, periph);
 
cam_periph_unlock(periph);
/*
@@ -3075,6 +3086,7 @@ dastart(struct cam_periph *periph, union ccb *start_cc
 {
struct da_softc *softc;
 
+   cam_periph_assert(periph, MA_OWNED);
softc = (struct da_softc *)periph->softc;
 
CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dastart\n"));
@@ -4625,7 +4637,9 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
 ((have_sense) &&
  (error_code == SSD_CURRENT_ERROR) &&
  (sense_key == SSD_KEY_ILLEGAL_REQUEST 
{
+   cam_periph_lock(periph);
softc->flags &= ~DA_FLAG_CAN_RC16;
+   cam_periph_unlock(periph);
free(rdcap, M_SCSIDA);
xpt_release_ccb(done_ccb);
softc->state = DA_STATE_PROBE_RC;
@@ -5012,6 +5026,7 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
"GEOM::rotation_rate", M_NOWAIT);
  

svn commit: r330797 - head/sys/x86/isa

2018-03-12 Thread Ian Lepore
Author: ian
Date: Mon Mar 12 15:26:11 2018
New Revision: 330797
URL: https://svnweb.freebsd.org/changeset/base/330797

Log:
  Give the atrtc_time_lock a unique name.
  
  Reported by:  hps@

Modified:
  head/sys/x86/isa/atrtc.c

Modified: head/sys/x86/isa/atrtc.c
==
--- head/sys/x86/isa/atrtc.cMon Mar 12 15:17:16 2018(r330796)
+++ head/sys/x86/isa/atrtc.cMon Mar 12 15:26:11 2018(r330797)
@@ -64,7 +64,7 @@ static struct mtx atrtc_lock;
 MTX_SYSINIT(atrtc_lock_init, _lock, "atrtc", MTX_SPIN);
 
 struct mtx atrtc_time_lock;
-MTX_SYSINIT(atrtc_time_lock_init, _time_lock, "atrtc", MTX_DEF);
+MTX_SYSINIT(atrtc_time_lock_init, _time_lock, "atrtc_time", MTX_DEF);
 
 intatrtcclock_disable = 0;
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330799 - head/sys/kern

2018-03-12 Thread Ed Maste
Author: emaste
Date: Mon Mar 12 15:45:50 2018
New Revision: 330799
URL: https://svnweb.freebsd.org/changeset/base/330799

Log:
  ANSIfy sys/kern/imgact_*

Modified:
  head/sys/kern/imgact_elf.c
  head/sys/kern/imgact_gzip.c

Modified: head/sys/kern/imgact_elf.c
==
--- head/sys/kern/imgact_elf.c  Mon Mar 12 15:35:24 2018(r330798)
+++ head/sys/kern/imgact_elf.c  Mon Mar 12 15:45:50 2018(r330799)
@@ -1467,9 +1467,7 @@ done:
  * program header entry.
  */
 static void
-cb_put_phdr(entry, closure)
-   vm_map_entry_t entry;
-   void *closure;
+cb_put_phdr(vm_map_entry_t entry, void *closure)
 {
struct phdr_closure *phc = (struct phdr_closure *)closure;
Elf_Phdr *phdr = phc->phdr;

Modified: head/sys/kern/imgact_gzip.c
==
--- head/sys/kern/imgact_gzip.c Mon Mar 12 15:35:24 2018(r330798)
+++ head/sys/kern/imgact_gzip.c Mon Mar 12 15:45:50 2018(r330799)
@@ -69,8 +69,7 @@ static int do_aout_hdr(struct imgact_gzip *);
 static int Flush(void *vp, u_char *, u_long siz);
 
 static int
-exec_gzip_imgact(imgp)
-   struct image_params *imgp;
+exec_gzip_imgact(struct image_params *imgp)
 {
int error;
const u_char   *p = (const u_char *) imgp->image_header;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r330780 - in head/sys: amd64/include isa x86/isa

2018-03-12 Thread Konstantin Belousov
On Mon, Mar 12, 2018 at 09:34:51AM -0600, Ian Lepore wrote:
> On Sun, 2018-03-11 at 23:25 +0200, Konstantin Belousov wrote:
> > On Sun, Mar 11, 2018 at 02:20:39PM -0600, Ian Lepore wrote:
> > > 
> > > On Sun, 2018-03-11 at 21:58 +0200, Konstantin Belousov wrote:
> > > > 
> > > > On Sun, Mar 11, 2018 at 07:22:58PM +, Ian Lepore wrote:
> > > > > 
> > > > > 
> > > > > [...]
> > > 
> > > Unfortunately, this reverts one type of wrong locking back to another.
> > >  The need is to prevent access to the atrtc hardware if efi is
> > > accessing it, and the locking I just reverted to that uses a sleepable
> > > mutex only protects against inittodr()/resettodr() access, but not
> > > against nvram(4) or if the atrtc is being used as an eventtimer (of
> > > course nobody uses it for that, but the driver supports it).
> > > 
> > > I have some pending changes that cause the atrtc driver to just not
> > > attach at all if the efirtc driver attached, but they're stacked up
> > > behind some other changes in phab.  And that still doesn't fix the
> > > nvram(4) part of it.
> > Not attaching atrtc if efirtc is attached sounds reasonable. But then
> > you should also disable efirt attach if atrtc is on. One possible issue
> > is that efirt is typicall loadable, while atrtc is compiled into the
> > kernel, which means that efirt would become virtually unusable.
> > 
> 
> Even if efirt is loaded (in loader(8)) the efirtc driver will still
> attach instead of atrtc, because it's a direct child of nexus and gets
> the first opportunity to probe and attach.  But you raise a good point,
> I should make it handle the case where it gets kldload'd when atrtc is
> already attached.
> 
> > For nvram(4), you can take the atrtc_time_lock around accesses in addition
> > to the atrtc_lock, instead of providing exclusivity on the level of drivers
> > attach.
> 
> It occurs to me that an even better fix for all of this would be to
> remove support for atrtc being an eventtimer.  That allows removing the
> interrupt filter handler, and then there's no need for a spinlock at
> all, a sleepable mutex works fine for all accesses.
> 
> Does anybody really need an eventtimer that runs only at a fixed
> periodic rate of 32khz in 2018?

Problem is that atrtc is what old machines use. If we have HPET or
better LAPIC timers, then we do not need atrtc at all, of course.
But e.g. 486 do not have them. I am not even sure about early amd64
machines.

Definitely any machine that needs EFIRT has both HPET and LAPIC, I like
the idea of not providing eventtimer backed by atrtc if feasible. Might
be, make this a compile or runtime option, unless this over-complicates
the code.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330804 - stable/11/usr.sbin/ppp

2018-03-12 Thread Eugene Grosbein
Author: eugen
Date: Mon Mar 12 17:36:37 2018
New Revision: 330804
URL: https://svnweb.freebsd.org/changeset/base/330804

Log:
  MFC r329105: ppp(8): fix code producing debugging logs
  
ppp(8): fix code producing debugging logs
  
Fix several cases when long buffer is copied to shorter one
using snprintf that results in contents truncation and
clobbering unsaved errno value and creation of misleading logs.
  
  PR:   218517
  Approved by:  mav (mentor)

Modified:
  stable/11/usr.sbin/ppp/defs.h
  stable/11/usr.sbin/ppp/iface.c
  stable/11/usr.sbin/ppp/ip.c
  stable/11/usr.sbin/ppp/ipv6cp.c
  stable/11/usr.sbin/ppp/ncpaddr.c
  stable/11/usr.sbin/ppp/route.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/ppp/defs.h
==
--- stable/11/usr.sbin/ppp/defs.h   Mon Mar 12 17:05:53 2018
(r330803)
+++ stable/11/usr.sbin/ppp/defs.h   Mon Mar 12 17:36:37 2018
(r330804)
@@ -119,6 +119,8 @@
 
 #define ROUNDUP(x) ((x) ? (1 + (((x) - 1) | (sizeof(long) - 1))) : 
sizeof(long))
 
+#define NCP_ASCIIBUFFERSIZE52
+
 #ifdef __NetBSD__
 extern void randinit(void);
 #else

Modified: stable/11/usr.sbin/ppp/iface.c
==
--- stable/11/usr.sbin/ppp/iface.c  Mon Mar 12 17:05:53 2018
(r330803)
+++ stable/11/usr.sbin/ppp/iface.c  Mon Mar 12 17:36:37 2018
(r330804)
@@ -208,7 +208,7 @@ iface_addr_Zap(const char *name, struct iface_addr *ad
 #endif
   struct sockaddr_in *me4, *msk4, *peer4;
   struct sockaddr_storage ssme, sspeer, ssmsk;
-  int res;
+  int res, saved_errno;
 
   ncprange_getsa(>ifa, , );
   ncpaddr_getsa(>peer, );
@@ -234,8 +234,9 @@ iface_addr_Zap(const char *name, struct iface_addr *ad
   memcpy(peer4, , sizeof *peer4);
 
 res = ID0ioctl(s, SIOCDIFADDR, );
+saved_errno = errno;
 if (log_IsKept(LogDEBUG)) {
-  char buf[100];
+  char buf[NCP_ASCIIBUFFERSIZE];
 
   snprintf(buf, sizeof buf, "%s", ncprange_ntoa(>ifa));
   log_Printf(LogWARN, "%s: DIFADDR %s -> %s returns %d\n",
@@ -259,12 +260,13 @@ iface_addr_Zap(const char *name, struct iface_addr *ad
 ifra6.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME;
 
 res = ID0ioctl(s, SIOCDIFADDR_IN6, );
+saved_errno = errno;
 break;
 #endif
   }
 
   if (res == -1) {
-char dst[40];
+char dst[NCP_ASCIIBUFFERSIZE];
 const char *end =
 #ifndef NOINET6
   ncprange_family(>ifa) == AF_INET6 ? "_IN6" :
@@ -273,11 +275,11 @@ iface_addr_Zap(const char *name, struct iface_addr *ad
 
 if (ncpaddr_family(>peer) == AF_UNSPEC)
   log_Printf(LogWARN, "iface rm: ioctl(SIOCDIFADDR%s, %s): %s\n",
- end, ncprange_ntoa(>ifa), strerror(errno));
+ end, ncprange_ntoa(>ifa), strerror(saved_errno));
 else {
   snprintf(dst, sizeof dst, "%s", ncpaddr_ntoa(>peer));
   log_Printf(LogWARN, "iface rm: ioctl(SIOCDIFADDR%s, %s -> %s): %s\n",
- end, ncprange_ntoa(>ifa), dst, strerror(errno));
+ end, ncprange_ntoa(>ifa), dst, strerror(saved_errno));
 }
   }
 
@@ -293,7 +295,7 @@ iface_addr_Add(const char *name, struct iface_addr *ad
 #endif
   struct sockaddr_in *me4, *msk4, *peer4;
   struct sockaddr_storage ssme, sspeer, ssmsk;
-  int res;
+  int res, saved_errno;
 
   ncprange_getsa(>ifa, , );
   ncpaddr_getsa(>peer, );
@@ -319,8 +321,9 @@ iface_addr_Add(const char *name, struct iface_addr *ad
   memcpy(peer4, , sizeof *peer4);
 
 res = ID0ioctl(s, SIOCAIFADDR, );
+saved_errno = errno;
 if (log_IsKept(LogDEBUG)) {
-  char buf[100];
+  char buf[NCP_ASCIIBUFFERSIZE];
 
   snprintf(buf, sizeof buf, "%s", ncprange_ntoa(>ifa));
   log_Printf(LogWARN, "%s: AIFADDR %s -> %s returns %d\n",
@@ -344,12 +347,13 @@ iface_addr_Add(const char *name, struct iface_addr *ad
 ifra6.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME;
 
 res = ID0ioctl(s, SIOCAIFADDR_IN6, );
+saved_errno = errno;
 break;
 #endif
   }
 
   if (res == -1) {
-char dst[40];
+char dst[NCP_ASCIIBUFFERSIZE];
 const char *end =
 #ifndef NOINET6
   ncprange_family(>ifa) == AF_INET6 ? "_IN6" :
@@ -358,11 +362,11 @@ iface_addr_Add(const char *name, struct iface_addr *ad
 
 if (ncpaddr_family(>peer) == AF_UNSPEC)
   log_Printf(LogWARN, "iface add: ioctl(SIOCAIFADDR%s, %s): %s\n",
- end, ncprange_ntoa(>ifa), strerror(errno));
+ end, ncprange_ntoa(>ifa), strerror(saved_errno));
 else {
   snprintf(dst, sizeof dst, "%s", ncpaddr_ntoa(>peer));
   log_Printf(LogWARN, "iface add: ioctl(SIOCAIFADDR%s, %s -> %s): %s\n",
- end, ncprange_ntoa(>ifa), dst, strerror(errno));
+ end, ncprange_ntoa(>ifa), dst, strerror(saved_errno));
 }
   }
 

Modified: stable/11/usr.sbin/ppp/ip.c

svn commit: r330805 - stable/10/usr.sbin/ppp

2018-03-12 Thread Eugene Grosbein
Author: eugen
Date: Mon Mar 12 17:37:38 2018
New Revision: 330805
URL: https://svnweb.freebsd.org/changeset/base/330805

Log:
  MFC r329105: ppp(8): fix code producing debugging logs
  
ppp(8): fix code producing debugging logs
  
Fix several cases when long buffer is copied to shorter one
using snprintf that results in contents truncation and
clobbering unsaved errno value and creation of misleading logs.
  
  PR:   218517
  Approved by:  mav (mentor)

Modified:
  stable/10/usr.sbin/ppp/defs.h
  stable/10/usr.sbin/ppp/iface.c
  stable/10/usr.sbin/ppp/ip.c
  stable/10/usr.sbin/ppp/ipv6cp.c
  stable/10/usr.sbin/ppp/ncpaddr.c
  stable/10/usr.sbin/ppp/route.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/ppp/defs.h
==
--- stable/10/usr.sbin/ppp/defs.h   Mon Mar 12 17:36:37 2018
(r330804)
+++ stable/10/usr.sbin/ppp/defs.h   Mon Mar 12 17:37:38 2018
(r330805)
@@ -117,6 +117,8 @@
 
 #define ROUNDUP(x) ((x) ? (1 + (((x) - 1) | (sizeof(long) - 1))) : 
sizeof(long))
 
+#define NCP_ASCIIBUFFERSIZE52
+
 #ifdef __NetBSD__
 extern void randinit(void);
 #else

Modified: stable/10/usr.sbin/ppp/iface.c
==
--- stable/10/usr.sbin/ppp/iface.c  Mon Mar 12 17:36:37 2018
(r330804)
+++ stable/10/usr.sbin/ppp/iface.c  Mon Mar 12 17:37:38 2018
(r330805)
@@ -209,7 +209,7 @@ iface_addr_Zap(const char *name, struct iface_addr *ad
 #endif
   struct sockaddr_in *me4, *msk4, *peer4;
   struct sockaddr_storage ssme, sspeer, ssmsk;
-  int res;
+  int res, saved_errno;
 
   ncprange_getsa(>ifa, , );
   ncpaddr_getsa(>peer, );
@@ -235,8 +235,9 @@ iface_addr_Zap(const char *name, struct iface_addr *ad
   memcpy(peer4, , sizeof *peer4);
 
 res = ID0ioctl(s, SIOCDIFADDR, );
+saved_errno = errno;
 if (log_IsKept(LogDEBUG)) {
-  char buf[100];
+  char buf[NCP_ASCIIBUFFERSIZE];
 
   snprintf(buf, sizeof buf, "%s", ncprange_ntoa(>ifa));
   log_Printf(LogWARN, "%s: DIFADDR %s -> %s returns %d\n",
@@ -260,12 +261,13 @@ iface_addr_Zap(const char *name, struct iface_addr *ad
 ifra6.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME;
 
 res = ID0ioctl(s, SIOCDIFADDR_IN6, );
+saved_errno = errno;
 break;
 #endif
   }
 
   if (res == -1) {
-char dst[40];
+char dst[NCP_ASCIIBUFFERSIZE];
 const char *end =
 #ifndef NOINET6
   ncprange_family(>ifa) == AF_INET6 ? "_IN6" :
@@ -274,11 +276,11 @@ iface_addr_Zap(const char *name, struct iface_addr *ad
 
 if (ncpaddr_family(>peer) == AF_UNSPEC)
   log_Printf(LogWARN, "iface rm: ioctl(SIOCDIFADDR%s, %s): %s\n",
- end, ncprange_ntoa(>ifa), strerror(errno));
+ end, ncprange_ntoa(>ifa), strerror(saved_errno));
 else {
   snprintf(dst, sizeof dst, "%s", ncpaddr_ntoa(>peer));
   log_Printf(LogWARN, "iface rm: ioctl(SIOCDIFADDR%s, %s -> %s): %s\n",
- end, ncprange_ntoa(>ifa), dst, strerror(errno));
+ end, ncprange_ntoa(>ifa), dst, strerror(saved_errno));
 }
   }
 
@@ -294,7 +296,7 @@ iface_addr_Add(const char *name, struct iface_addr *ad
 #endif
   struct sockaddr_in *me4, *msk4, *peer4;
   struct sockaddr_storage ssme, sspeer, ssmsk;
-  int res;
+  int res, saved_errno;
 
   ncprange_getsa(>ifa, , );
   ncpaddr_getsa(>peer, );
@@ -320,8 +322,9 @@ iface_addr_Add(const char *name, struct iface_addr *ad
   memcpy(peer4, , sizeof *peer4);
 
 res = ID0ioctl(s, SIOCAIFADDR, );
+saved_errno = errno;
 if (log_IsKept(LogDEBUG)) {
-  char buf[100];
+  char buf[NCP_ASCIIBUFFERSIZE];
 
   snprintf(buf, sizeof buf, "%s", ncprange_ntoa(>ifa));
   log_Printf(LogWARN, "%s: AIFADDR %s -> %s returns %d\n",
@@ -345,12 +348,13 @@ iface_addr_Add(const char *name, struct iface_addr *ad
 ifra6.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME;
 
 res = ID0ioctl(s, SIOCAIFADDR_IN6, );
+saved_errno = errno;
 break;
 #endif
   }
 
   if (res == -1) {
-char dst[40];
+char dst[NCP_ASCIIBUFFERSIZE];
 const char *end =
 #ifndef NOINET6
   ncprange_family(>ifa) == AF_INET6 ? "_IN6" :
@@ -359,11 +363,11 @@ iface_addr_Add(const char *name, struct iface_addr *ad
 
 if (ncpaddr_family(>peer) == AF_UNSPEC)
   log_Printf(LogWARN, "iface add: ioctl(SIOCAIFADDR%s, %s): %s\n",
- end, ncprange_ntoa(>ifa), strerror(errno));
+ end, ncprange_ntoa(>ifa), strerror(saved_errno));
 else {
   snprintf(dst, sizeof dst, "%s", ncpaddr_ntoa(>peer));
   log_Printf(LogWARN, "iface add: ioctl(SIOCAIFADDR%s, %s -> %s): %s\n",
- end, ncprange_ntoa(>ifa), dst, strerror(errno));
+ end, ncprange_ntoa(>ifa), dst, strerror(saved_errno));
 }
   }
 

Modified: stable/10/usr.sbin/ppp/ip.c

Re: svn commit: r330792 - in head: sbin/ipfw sys/netpfil/ipfw

2018-03-12 Thread Rodney W. Grimes
> Author: ae
> Date: Mon Mar 12 09:40:46 2018
> New Revision: 330792
> URL: https://svnweb.freebsd.org/changeset/base/330792
> 
> Log:
>   Do not try to reassemble IPv6 fragments in "reass" rule.
>   
>   ip_reass() expects IPv4 packet and will just corrupt any IPv6 packets
>   that it gets. Until proper IPv6 fragments handling function will be
>   implemented, pass IPv6 packets to next rule.

Thank you!  This should simplify some discussion occuring about
/etc/rc.firewall in workstation mode and the fact it does not
handly fragmentation correctly, part of fixing that invovled 
be sure to only pass ipv4 to a reass rule, with this fix that
shall no longer be necessary.  

https://reviews.freebsd.org/D9920


>   PR: 170604
>   MFC after:  1 week
> 
> Modified:
>   head/sbin/ipfw/ipfw.8
>   head/sys/netpfil/ipfw/ip_fw2.c
> 
> Modified: head/sbin/ipfw/ipfw.8
> ==
> --- head/sbin/ipfw/ipfw.8 Mon Mar 12 05:41:27 2018(r330791)
> +++ head/sbin/ipfw/ipfw.8 Mon Mar 12 09:40:46 2018(r330792)
> @@ -1,7 +1,7 @@
>  .\"
>  .\" $FreeBSD$
>  .\"
> -.Dd November 26, 2017
> +.Dd March 12, 2018
>  .Dt IPFW 8
>  .Os
>  .Sh NAME
> @@ -1135,7 +1135,7 @@ Regardless of matched a packet or not by the
>  .Cm tcp-setmss
>  rule, the search continues with the next rule.
>  .It Cm reass
> -Queue and reassemble IP fragments.
> +Queue and reassemble IPv4 fragments.
>  If the packet is not fragmented, counters are updated and
>  processing continues with the next rule.
>  If the packet is the last logical fragment, the packet is reassembled and, if
> 
> Modified: head/sys/netpfil/ipfw/ip_fw2.c
> ==
> --- head/sys/netpfil/ipfw/ip_fw2.cMon Mar 12 05:41:27 2018
> (r330791)
> +++ head/sys/netpfil/ipfw/ip_fw2.cMon Mar 12 09:40:46 2018
> (r330792)
> @@ -3018,8 +3018,10 @@ do {   
> \
>   case O_REASS: {
>   int ip_off;
>  
> - IPFW_INC_RULE_COUNTER(f, pktlen);
>   l = 0;  /* in any case exit inner loop */
> + if (is_ipv6) /* IPv6 is not supported yet */
> + break;
> + IPFW_INC_RULE_COUNTER(f, pktlen);
>   ip_off = ntohs(ip->ip_off);
>  
>   /* if not fragmented, go to next rule */
> 
> 

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


svn commit: r330802 - in head: sbin/nvmecontrol sys/dev/nvme

2018-03-12 Thread Alexander Motin
Author: mav
Date: Mon Mar 12 16:31:25 2018
New Revision: 330802
URL: https://svnweb.freebsd.org/changeset/base/330802

Log:
  Print fuses and fna fields in identify data.
  
  MFC after:2 weeks
  Sponsored by: iXsystems, Inc.

Modified:
  head/sbin/nvmecontrol/identify.c
  head/sys/dev/nvme/nvme.h

Modified: head/sbin/nvmecontrol/identify.c
==
--- head/sbin/nvmecontrol/identify.cMon Mar 12 16:04:10 2018
(r330801)
+++ head/sbin/nvmecontrol/identify.cMon Mar 12 16:31:25 2018
(r330802)
@@ -196,6 +196,17 @@ print_controller(struct nvme_controller_data *cdata)
printf("Timestamp feature:   %sSupported\n",
((oncs >> NVME_CTRLR_DATA_ONCS_TIMESTAMP_SHIFT) &
 NVME_CTRLR_DATA_ONCS_TIMESTAMP_MASK) ? "" : "Not ");
+   printf("Fused Operation Support: %s%s\n",
+   (cdata->fuses == 0) ? "Not Supported" : "",
+   ((cdata->fuses >> NVME_CTRLR_DATA_FUSES_CNW_SHIFT) &
+NVME_CTRLR_DATA_FUSES_CNW_MASK) ? "Compare and Write" : "");
+   printf("Format NVM Attributes:   %s%s Erase, %s Format\n",
+   ((cdata->fna >> NVME_CTRLR_DATA_FNA_CRYPTO_ERASE_SHIFT) &
+NVME_CTRLR_DATA_FNA_CRYPTO_ERASE_MASK) ? "Crypto Erase, " : "",
+   ((cdata->fna >> NVME_CTRLR_DATA_FNA_ERASE_ALL_SHIFT) &
+NVME_CTRLR_DATA_FNA_ERASE_ALL_MASK) ? "All-NVM" : "Per-NS",
+   ((cdata->fna >> NVME_CTRLR_DATA_FNA_FORMAT_ALL_SHIFT) &
+NVME_CTRLR_DATA_FNA_FORMAT_ALL_MASK) ? "All-NVM" : "Per-NS");
printf("Volatile Write Cache:%s\n",
vwc_present ? "Present" : "Not Present");
 

Modified: head/sys/dev/nvme/nvme.h
==
--- head/sys/dev/nvme/nvme.hMon Mar 12 16:04:10 2018(r330801)
+++ head/sys/dev/nvme/nvme.hMon Mar 12 16:31:25 2018(r330802)
@@ -244,6 +244,18 @@
 #define NVME_CTRLR_DATA_ONCS_TIMESTAMP_SHIFT   (6)
 #define NVME_CTRLR_DATA_ONCS_TIMESTAMP_MASK(0x1)
 
+/** Fused Operation Support */
+#define NVME_CTRLR_DATA_FUSES_CNW_SHIFT(0)
+#define NVME_CTRLR_DATA_FUSES_CNW_MASK (0x1)
+
+/** Format NVM Attributes */
+#define NVME_CTRLR_DATA_FNA_FORMAT_ALL_SHIFT   (0)
+#define NVME_CTRLR_DATA_FNA_FORMAT_ALL_MASK(0x1)
+#define NVME_CTRLR_DATA_FNA_ERASE_ALL_SHIFT(1)
+#define NVME_CTRLR_DATA_FNA_ERASE_ALL_MASK (0x1)
+#define NVME_CTRLR_DATA_FNA_CRYPTO_ERASE_SHIFT (2)
+#define NVME_CTRLR_DATA_FNA_CRYPTO_ERASE_MASK  (0x1)
+
 /** volatile write cache */
 #define NVME_CTRLR_DATA_VWC_PRESENT_SHIFT  (0)
 #define NVME_CTRLR_DATA_VWC_PRESENT_MASK   (0x1)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2018-03-12 Thread Warner Losh
I think this is a good idea to MFC. We've had no reports of it causing
issues.

There's more extensive locking changes / tweaks needed for da that just
went in that likely should also be MFC'd.

Warner

On Sun, Mar 11, 2018 at 9:17 PM, Dexuan-BSD Cui 
wrote:

> Hi imp and all,
> I think this patch is very important, because it can fix a panic I
> noticed recently when I try to hot-remove a SCSI disk from a VM
> running on Azure/Hyper-V.
>
> The panic is almost 100% reproducible with stable/11, but not in the
> latest CURRENT code, so finally I identified this fix in the CURRENT
> branch.
>
> Can you please MFC this patch to 11 and 10?
> It looks there is a major difference in the CAM code between 11/10
> and the CURRENT code, and we may have to MFC more related patches. If
> this is difficult, I hope at least we can provide a minimal re-written
> version of the patch to 11 and 10?
>
> Looking forward to your insight!
>
> Thanks,
> -- Dexuan
>
>
> On Mon, Jan 29, 2018 at 10:07 AM, Warner Losh  wrote:
> > Author: imp
> > Date: Mon Jan 29 18:07:14 2018
> > New Revision: 328554
> > URL: https://svnweb.freebsd.org/changeset/base/328554
> >
> > Log:
> >   Do the book-keeping on release before we release the reference. The
> >   periph was going away on final release, and then returning and we
> >   started dancing in free memory.
> >
> >   Sponsored by: Netflix
> >
> > Modified:
> >   head/sys/cam/scsi/scsi_da.c
> >
> > Modified: head/sys/cam/scsi/scsi_da.c
> > 
> ==
> > --- head/sys/cam/scsi/scsi_da.c Mon Jan 29 17:32:30 2018(r328553)
> > +++ head/sys/cam/scsi/scsi_da.c Mon Jan 29 18:07:14 2018(r328554)
> > @@ -1549,12 +1549,12 @@ da_periph_unhold(struct cam_periph *periph,
> da_ref_tok
> > struct da_softc *softc = periph->softc;
> >
> > token_sanity(token);
> > -   cam_periph_unhold(periph);
> > DA_PERIPH_PRINT(periph, "Unholding device %s (%d)\n",
> > da_ref_text[token], token);
> > cnt = atomic_fetchadd_int(>ref_flags[token], -1);
> > if (cnt != 1)
> > panic("Unholding %d with cnt = %d", token, cnt);
> > +   cam_periph_unhold(periph);
> >  }
> >
> >  static inline int
> > @@ -1583,12 +1583,12 @@ da_periph_release(struct cam_periph *periph,
> da_ref_to
> > struct da_softc *softc = periph->softc;
> >
> > token_sanity(token);
> > -   cam_periph_release(periph);
> > DA_PERIPH_PRINT(periph, "releasing device %s (%d)\n",
> > da_ref_text[token], token);
> > cnt = atomic_fetchadd_int(>ref_flags[token], -1);
> > if (cnt != 1)
> > panic("Releasing %d with cnt = %d", token, cnt);
> > +   cam_periph_release(periph);
> >  }
> >
> >  static inline void
> > @@ -1598,12 +1598,12 @@ da_periph_release_locked(struct cam_periph
> *periph, da
> > struct da_softc *softc = periph->softc;
> >
> > token_sanity(token);
> > -   cam_periph_release_locked(periph);
> > DA_PERIPH_PRINT(periph, "releasing device (locked) %s (%d)\n",
> > da_ref_text[token], token);
> > cnt = atomic_fetchadd_int(>ref_flags[token], -1);
> > if (cnt != 1)
> > panic("Unholding %d with cnt = %d", token, cnt);
> > +   cam_periph_release_locked(periph);
> >  }
> >
> >  #define cam_periph_hold POISON
> >
>
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330803 - head/sys/dev/e1000

2018-03-12 Thread Toomas Soome
Author: tsoome
Date: Mon Mar 12 17:05:53 2018
New Revision: 330803
URL: https://svnweb.freebsd.org/changeset/base/330803

Log:
  e1000g: this statement may fall through
  
  The gcc 7 does check for switch statement fall through cases, and if legit,
  such complaint can besilenced by /* FALLTHROUGH */ comment. Unfortunately
  such comment is quite limited, but will still notify the reader.
  
  This patch is backport from illumos, see
  https://www.illumos.org/rb/r/941/
  
  Reviewed by:  eadler
  Differential Revision:https://reviews.freebsd.org/D14663

Modified:
  head/sys/dev/e1000/e1000_82575.c
  head/sys/dev/e1000/e1000_mbx.c
  head/sys/dev/e1000/e1000_phy.c
  head/sys/dev/e1000/e1000_vf.c

Modified: head/sys/dev/e1000/e1000_82575.c
==
--- head/sys/dev/e1000/e1000_82575.cMon Mar 12 16:31:25 2018
(r330802)
+++ head/sys/dev/e1000/e1000_82575.cMon Mar 12 17:05:53 2018
(r330803)
@@ -1679,7 +1679,7 @@ static s32 e1000_setup_serdes_link_82575(struct e1000_
case E1000_CTRL_EXT_LINK_MODE_1000BASE_KX:
/* disable PCS autoneg and support parallel detect only */
pcs_autoneg = FALSE;
-   /* fall through to default case */
+   /* FALLTHROUGH */
default:
if (hw->mac.type == e1000_82575 ||
hw->mac.type == e1000_82576) {
@@ -1806,6 +1806,7 @@ static s32 e1000_get_media_type_82575(struct e1000_hw 
break;
}
/* fall through for I2C based SGMII */
+   /* FALLTHROUGH */
case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES:
/* read media type from SFP EEPROM */
ret_val = e1000_set_sfp_media_type_82575(hw);

Modified: head/sys/dev/e1000/e1000_mbx.c
==
--- head/sys/dev/e1000/e1000_mbx.c  Mon Mar 12 16:31:25 2018
(r330802)
+++ head/sys/dev/e1000/e1000_mbx.c  Mon Mar 12 17:05:53 2018
(r330803)
@@ -779,6 +779,7 @@ s32 e1000_init_mbx_params_pf(struct e1000_hw *hw)
mbx->stats.reqs = 0;
mbx->stats.acks = 0;
mbx->stats.rsts = 0;
+   /* FALLTHROUGH */
default:
return E1000_SUCCESS;
}

Modified: head/sys/dev/e1000/e1000_phy.c
==
--- head/sys/dev/e1000/e1000_phy.c  Mon Mar 12 16:31:25 2018
(r330802)
+++ head/sys/dev/e1000/e1000_phy.c  Mon Mar 12 17:05:53 2018
(r330803)
@@ -1298,6 +1298,7 @@ s32 e1000_copper_link_setup_m88_gen2(struct e1000_hw *
phy_data |= M88E1000_PSCR_AUTO_X_1000T;
break;
}
+   /* FALLTHROUGH */
case 0:
default:
phy_data |= M88E1000_PSCR_AUTO_X_MODE;

Modified: head/sys/dev/e1000/e1000_vf.c
==
--- head/sys/dev/e1000/e1000_vf.c   Mon Mar 12 16:31:25 2018
(r330802)
+++ head/sys/dev/e1000/e1000_vf.c   Mon Mar 12 17:05:53 2018
(r330803)
@@ -488,8 +488,10 @@ s32 e1000_promisc_set_vf(struct e1000_hw *hw, enum e10
break;
case e1000_promisc_enabled:
msgbuf |= E1000_VF_SET_PROMISC_MULTICAST;
+   /* FALLTHROUGH */
case e1000_promisc_unicast:
msgbuf |= E1000_VF_SET_PROMISC_UNICAST;
+   /* FALLTHROUGH */
case e1000_promisc_disabled:
break;
default:
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330825 - head/stand/lua

2018-03-12 Thread Kyle Evans
Author: kevans
Date: Tue Mar 13 02:59:13 2018
New Revision: 330825
URL: https://svnweb.freebsd.org/changeset/base/330825

Log:
  lualoader: Sprinkle some verbose_loading salt
  
  Our module loading messages should be hidden without verbose_loading -- go
  ahead and do that as a first step.

Modified:
  head/stand/lua/config.lua

Modified: head/stand/lua/config.lua
==
--- head/stand/lua/config.lua   Tue Mar 13 01:19:07 2018(r330824)
+++ head/stand/lua/config.lua   Tue Mar 13 02:59:13 2018(r330825)
@@ -197,6 +197,7 @@ end
 config.env_changed = {}
 -- Values to restore env to (nil to unset)
 config.env_restore = {}
+config.verbose = false
 
 -- The first item in every carousel is always the default item.
 function config.getCarouselIndex(id)
@@ -490,6 +491,11 @@ function config.load(file)
 
-- Cache the provided module_path at load time for later use
config.module_path = loader.getenv("module_path")
+   local verbose = loader.getenv("verbose_loading")
+   if verbose == nil then
+   verbose = "no"
+   end
+   config.verbose = verbose:lower() == "yes"
 end
 
 -- Reload configuration
@@ -512,7 +518,7 @@ function config.loadelf()
end
 
print(MSG_MODLOADING)
-   if not config.loadmod(modules) then
+   if not config.loadmod(modules, not config.verbose) then
print(MSG_MODLOADFAIL)
end
 end
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


RE: svn commit: r328554 - head/sys/cam/scsi

2018-03-12 Thread Dexuan Cui via svn-src-all
Hi Warner,
Sorry, I need to make a correction: acutally it looks the panic can NOT 
reproduce with stable/11 or the latest master branch. This is great! :-)

Actually I was using an old version of the master branch that doesn’t have 
r328554 yet, and I could 100% reproduce the issue. If I manually apply r328554, 
or I use the latest master branch, the panic can’t happen any more.

So, it looks here we don’t need to MFC any patch to stable/11.

Thanks,
-- Dexuan

From: wl...@bsdimp.com  On Behalf Of Warner Losh
Sent: Monday, March 12, 2018 09:45
To: Dexuan-BSD Cui 
Cc: Warner Losh ; src-committers 
; svn-src-all@freebsd.org; 
svn-src-h...@freebsd.org; Dexuan Cui 
Subject: Re: svn commit: r328554 - head/sys/cam/scsi


This sender failed our fraud detection checks and may not be who they appear to 
be. Learn about spoofing

Feedback

I think this is a good idea to MFC. We've had no reports of it causing issues.

There's more extensive locking changes / tweaks needed for da that just went in 
that likely should also be MFC'd.

Warner

On Sun, Mar 11, 2018 at 9:17 PM, Dexuan-BSD Cui 
> wrote:
Hi imp and all,
I think this patch is very important, because it can fix a panic I
noticed recently when I try to hot-remove a SCSI disk from a VM
running on Azure/Hyper-V.

The panic is almost 100% reproducible with stable/11, but not in the
latest CURRENT code, so finally I identified this fix in the CURRENT
branch.

Can you please MFC this patch to 11 and 10?
It looks there is a major difference in the CAM code between 11/10
and the CURRENT code, and we may have to MFC more related patches. If
this is difficult, I hope at least we can provide a minimal re-written
version of the patch to 11 and 10?

Looking forward to your insight!

Thanks,
-- Dexuan


On Mon, Jan 29, 2018 at 10:07 AM, Warner Losh 
> wrote:
> Author: imp
> Date: Mon Jan 29 18:07:14 2018
> New Revision: 328554
> URL: 
> https://svnweb.freebsd.org/changeset/base/328554
>
> Log:
>   Do the book-keeping on release before we release the reference. The
>   periph was going away on final release, and then returning and we
>   started dancing in free memory.
>
>   Sponsored by: Netflix
>
> Modified:
>   head/sys/cam/scsi/scsi_da.c
>
> Modified: head/sys/cam/scsi/scsi_da.c
> ==
> --- head/sys/cam/scsi/scsi_da.c Mon Jan 29 17:32:30 2018(r328553)
> +++ head/sys/cam/scsi/scsi_da.c Mon Jan 29 18:07:14 2018(r328554)
> @@ -1549,12 +1549,12 @@ da_periph_unhold(struct cam_periph *periph, da_ref_tok
> struct da_softc *softc = periph->softc;
>
> token_sanity(token);
> -   cam_periph_unhold(periph);
> DA_PERIPH_PRINT(periph, "Unholding device %s (%d)\n",
> da_ref_text[token], token);
> cnt = atomic_fetchadd_int(>ref_flags[token], -1);
> if (cnt != 1)
> panic("Unholding %d with cnt = %d", token, cnt);
> +   cam_periph_unhold(periph);
>  }
>
>  static inline int
> @@ -1583,12 +1583,12 @@ da_periph_release(struct cam_periph *periph, da_ref_to
> struct da_softc *softc = periph->softc;
>
> token_sanity(token);
> -   cam_periph_release(periph);
> DA_PERIPH_PRINT(periph, "releasing device %s (%d)\n",
> da_ref_text[token], token);
> cnt = atomic_fetchadd_int(>ref_flags[token], -1);
> if (cnt != 1)
> panic("Releasing %d with cnt = %d", token, cnt);
> +   cam_periph_release(periph);
>  }
>
>  static inline void
> @@ -1598,12 +1598,12 @@ da_periph_release_locked(struct cam_periph *periph, da
> struct da_softc *softc = periph->softc;
>
> token_sanity(token);
> -   cam_periph_release_locked(periph);
> DA_PERIPH_PRINT(periph, "releasing device (locked) %s (%d)\n",
> da_ref_text[token], token);
> cnt = atomic_fetchadd_int(>ref_flags[token], -1);
> if (cnt != 1)
> panic("Unholding %d with cnt = %d", token, cnt);
> +   cam_periph_release_locked(periph);
>  }
>
>  #define cam_periph_hold POISON
>

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


svn commit: r330826 - head/sbin/nvmecontrol

2018-03-12 Thread Alexander Motin
Author: mav
Date: Tue Mar 13 03:02:09 2018
New Revision: 330826
URL: https://svnweb.freebsd.org/changeset/base/330826

Log:
  Add `nvmecontrol format` subcommand.
  
  It allows to change namespace parameters, such as block size, metadata,
  protection information, etc. and/or erase the data.
  
  MFC after:2 weeks
  Sponsored by: iXsystems, Inc.

Added:
  head/sbin/nvmecontrol/format.c   (contents, props changed)
Modified:
  head/sbin/nvmecontrol/Makefile
  head/sbin/nvmecontrol/identify.c
  head/sbin/nvmecontrol/logpage.c
  head/sbin/nvmecontrol/nvmecontrol.8
  head/sbin/nvmecontrol/nvmecontrol.c
  head/sbin/nvmecontrol/nvmecontrol.h

Modified: head/sbin/nvmecontrol/Makefile
==
--- head/sbin/nvmecontrol/Makefile  Tue Mar 13 02:59:13 2018
(r330825)
+++ head/sbin/nvmecontrol/Makefile  Tue Mar 13 03:02:09 2018
(r330826)
@@ -2,7 +2,7 @@
 
 PACKAGE=runtime
 PROG=  nvmecontrol
-SRCS=  nvmecontrol.c devlist.c firmware.c identify.c logpage.c \
+SRCS=  nvmecontrol.c devlist.c firmware.c format.c identify.c logpage.c \
perftest.c reset.c nvme_util.c power.c util.c wdc.c
 MAN=   nvmecontrol.8
 

Added: head/sbin/nvmecontrol/format.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sbin/nvmecontrol/format.c  Tue Mar 13 03:02:09 2018
(r330826)
@@ -0,0 +1,175 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (C) 2018 Alexander Motin 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "nvmecontrol.h"
+
+static void
+format_usage(void)
+{
+   fprintf(stderr, "usage:\n");
+   fprintf(stderr, FORMAT_USAGE);
+   exit(1);
+}
+
+void
+format(int argc, char *argv[])
+{
+   struct nvme_controller_data cd;
+   struct nvme_namespace_data  nsd;
+   struct nvme_pt_command  pt;
+   charpath[64];
+   char*target;
+   uint32_tnsid;
+   int ch, fd;
+   int lbaf = -1, mset = -1, pi = -1, pil = -1, ses = 0;
+
+   if (argc < 2)
+   format_usage();
+
+   while ((ch = getopt(argc, argv, "f:m:p:l:EC")) != -1) {
+   switch ((char)ch) {
+   case 'f':
+   lbaf = strtol(optarg, NULL, 0);
+   break;
+   case 'm':
+   mset = strtol(optarg, NULL, 0);
+   break;
+   case 'p':
+   pi = strtol(optarg, NULL, 0);
+   break;
+   case 'l':
+   pil = strtol(optarg, NULL, 0);
+   break;
+   case 'E':
+   ses = 1;
+   break;
+   case 'C':
+   ses = 2;
+   break;
+   default:
+   format_usage();
+   }
+   }
+
+   /* Check that a controller or namespace was specified. */
+   if (optind >= argc)
+   format_usage();
+   target = argv[optind];
+
+   /*
+* Check if the specified device node exists before continuing.
+* This is a cleaner check for cases where the correct controller
+* is specified, but an invalid namespace on that controller.
+*/
+   

svn commit: r330813 - in head/stand/efi: boot1 include libefi

2018-03-12 Thread Warner Losh
Author: imp
Date: Mon Mar 12 21:40:14 2018
New Revision: 330813
URL: https://svnweb.freebsd.org/changeset/base/330813

Log:
  Move the env convenience routines out of boot1.c.
  
  These routines are more generally useful. Even though boot1 is on its
  way out, it's better to make these common during the transition than
  copy them.

Added:
  head/stand/efi/libefi/efienv.c   (contents, props changed)
Modified:
  head/stand/efi/boot1/boot1.c
  head/stand/efi/include/efilib.h
  head/stand/efi/libefi/Makefile

Modified: head/stand/efi/boot1/boot1.c
==
--- head/stand/efi/boot1/boot1.cMon Mar 12 21:40:09 2018
(r330812)
+++ head/stand/efi/boot1/boot1.cMon Mar 12 21:40:14 2018
(r330813)
@@ -54,8 +54,6 @@ static EFI_GUID BlockIoProtocolGUID = BLOCK_IO_PROTOCO
 static EFI_GUID DevicePathGUID = DEVICE_PATH_PROTOCOL;
 static EFI_GUID LoadedImageGUID = LOADED_IMAGE_PROTOCOL;
 static EFI_GUID ConsoleControlGUID = EFI_CONSOLE_CONTROL_PROTOCOL_GUID;
-static EFI_GUID FreeBSDBootVarGUID = FREEBSD_BOOT_VAR_GUID;
-static EFI_GUID GlobalBootVarGUID = UEFI_BOOT_VAR_GUID;
 
 /*
  * Provide Malloc / Free backed by EFIs AllocatePool / FreePool which ensures
@@ -80,42 +78,6 @@ Free(void *buf, const char *file __unused, int line __
(void)BS->FreePool(buf);
 }
 
-static EFI_STATUS
-efi_getenv(EFI_GUID *g, const char *v, void *data, size_t *len)
-{
-   size_t ul;
-   CHAR16 *uv;
-   UINT32 attr;
-   UINTN dl;
-   EFI_STATUS rv;
-
-   uv = NULL;
-   if (utf8_to_ucs2(v, , ) != 0)
-   return (EFI_OUT_OF_RESOURCES);
-   dl = *len;
-   rv = RS->GetVariable(uv, g, , , data);
-   if (rv == EFI_SUCCESS)
-   *len = dl;
-   free(uv);
-   return (rv);
-}
-
-static EFI_STATUS
-efi_setenv_freebsd_wcs(const char *varname, CHAR16 *valstr)
-{
-   CHAR16 *var = NULL;
-   size_t len;
-   EFI_STATUS rv;
-
-   if (utf8_to_ucs2(varname, , ) != 0)
-   return (EFI_OUT_OF_RESOURCES);
-   rv = RS->SetVariable(var, ,
-   EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
-   (ucs2len(valstr) + 1) * sizeof(efi_char), valstr);
-   free(var);
-   return (rv);
-}
-
 /*
  * nodes_match returns TRUE if the imgpath isn't NULL and the nodes match,
  * FALSE otherwise.
@@ -505,11 +467,11 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab)
 
boot_current = 0;
sz = sizeof(boot_current);
-   efi_getenv(, "BootCurrent", _current, );
+   efi_global_getenv("BootCurrent", _current, );
printf("   BootCurrent: %04x\n", boot_current);
 
sz = sizeof(boot_order);
-   efi_getenv(, "BootOrder", _order, );
+   efi_global_getenv("BootOrder", _order, );
printf("   BootOrder:");
for (i = 0; i < sz / sizeof(boot_order[0]); i++)
printf(" %04x", boot_order[i]);

Modified: head/stand/efi/include/efilib.h
==
--- head/stand/efi/include/efilib.h Mon Mar 12 21:40:09 2018
(r330812)
+++ head/stand/efi/include/efilib.h Mon Mar 12 21:40:14 2018
(r330813)
@@ -106,6 +106,17 @@ int wcscmp(CHAR16 *, CHAR16 *);
 void cpy8to16(const char *, CHAR16 *, size_t);
 void cpy16to8(const CHAR16 *, char *, size_t);
 
+/*
+ * Routines for interacting with EFI's env vars in a more unix-like
+ * way than the standard APIs. In addition, convenience routines for
+ * the loader setting / getting FreeBSD specific variables.
+ */
+
+EFI_STATUS efi_freebsd_getenv(const char *v, void *data, __size_t *len);
+EFI_STATUS efi_getenv(EFI_GUID *g, const char *v, void *data, __size_t *len);
+EFI_STATUS efi_global_getenv(const char *v, void *data, __size_t *len);
+EFI_STATUS efi_setenv_freebsd_wcs(const char *varname, CHAR16 *valstr);
+
 /* efipart.c */
 intefipart_inithandles(void);
 

Modified: head/stand/efi/libefi/Makefile
==
--- head/stand/efi/libefi/Makefile  Mon Mar 12 21:40:09 2018
(r330812)
+++ head/stand/efi/libefi/Makefile  Mon Mar 12 21:40:14 2018
(r330813)
@@ -11,6 +11,7 @@ SRCS= delay.c \
efi_console.c \
efi_driver_utils.c \
efichar.c \
+   efienv.c \
efinet.c \
efipart.c \
efizfs.c \

Added: head/stand/efi/libefi/efienv.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/stand/efi/libefi/efienv.c  Mon Mar 12 21:40:14 2018
(r330813)
@@ -0,0 +1,87 @@
+/*-
+ * Copyright (c) 2018 Netflix, Inc.
+ * 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 

svn commit: r330823 - in head/sys: amd64/linux amd64/linux32 i386/linux

2018-03-12 Thread Ed Maste
Author: emaste
Date: Tue Mar 13 00:40:05 2018
New Revision: 330823
URL: https://svnweb.freebsd.org/changeset/base/330823

Log:
  Apply some style(9) to Linuxulator linux_sysvec.c comments

Modified:
  head/sys/amd64/linux/linux_sysvec.c
  head/sys/amd64/linux32/linux32_sysvec.c
  head/sys/i386/linux/linux_sysvec.c

Modified: head/sys/amd64/linux/linux_sysvec.c
==
--- head/sys/amd64/linux/linux_sysvec.c Mon Mar 12 23:28:25 2018
(r330822)
+++ head/sys/amd64/linux/linux_sysvec.c Tue Mar 13 00:40:05 2018
(r330823)
@@ -101,10 +101,9 @@ SYSCTL_PROC(_compat_linux, OID_AUTO, debug,
 #endif
 
 /*
- * Allow the this functions to use the ldebug() facility
- * even though they are not syscalls themselves. Map them
- * to syscall 0. This is slightly less bogus than using
- * ldebug(sigreturn).
+ * Allow the sendsig functions to use the ldebug() facility even though they
+ * are not syscalls themselves.  Map them to syscall 0.  This is slightly less
+ * bogus than using ldebug(sigreturn).
  */
 #defineLINUX_SYS_linux_rt_sendsig  0
 
@@ -253,8 +252,7 @@ linux_set_syscall_retval(struct thread *td, int error)
 
/*
 * On Linux only %rcx and %r11 values are not preserved across
-* the syscall.
-* So, do not clobber %rdx and %r10
+* the syscall.  So, do not clobber %rdx and %r10.
 */
td->td_retval[1] = frame->tf_rdx;
frame->tf_r10 = frame->tf_rcx;
@@ -335,9 +333,7 @@ linux_copyout_strings(struct image_params *imgp)
size_t execpath_len;
struct proc *p;
 
-   /*
-* Calculate string base and vector table pointers.
-*/
+   /* Calculate string base and vector table pointers. */
if (imgp->execpath != NULL && imgp->auxargs != NULL)
execpath_len = strlen(imgp->execpath) + 1;
else
@@ -345,7 +341,7 @@ linux_copyout_strings(struct image_params *imgp)
 
p = imgp->proc;
arginfo = (struct ps_strings *)p->p_sysent->sv_psstrings;
-   destp = (caddr_t)arginfo - SPARE_USRSPACE -
+   destp = (caddr_t)arginfo - SPARE_USRSPACE -
roundup(sizeof(canary), sizeof(char *)) -
roundup(execpath_len, sizeof(char *)) -
roundup(ARG_MAX - imgp->args->stringspace, sizeof(char *));
@@ -355,19 +351,14 @@ linux_copyout_strings(struct image_params *imgp)
copyout(imgp->execpath, (void *)imgp->execpathp, execpath_len);
}
 
-   /*
-* Prepare the canary for SSP.
-*/
+   /* Prepare the canary for SSP. */
arc4rand(canary, sizeof(canary), 0);
imgp->canary = (uintptr_t)arginfo -
roundup(execpath_len, sizeof(char *)) -
roundup(sizeof(canary), sizeof(char *));
copyout(canary, (void *)imgp->canary, sizeof(canary));
 
-   /*
-* If we have a valid auxargs ptr, prepare some room
-* on the stack.
-*/
+   /* If we have a valid auxargs ptr, prepare some room on the stack. */
if (imgp->auxargs) {
/*
 * 'AT_COUNT*2' is size for the ELF Auxargs data. This is for
@@ -393,29 +384,21 @@ linux_copyout_strings(struct image_params *imgp)
imgp->args->envc + 2) * sizeof(char *));
}
 
-   /*
-* vectp also becomes our initial stack base
-*/
+   /* vectp also becomes our initial stack base. */
stack_base = (register_t *)vectp;
 
stringp = imgp->args->begin_argv;
argc = imgp->args->argc;
envc = imgp->args->envc;
 
-   /*
-* Copy out strings - arguments and environment.
-*/
+   /* Copy out strings - arguments and environment. */
copyout(stringp, destp, ARG_MAX - imgp->args->stringspace);
 
-   /*
-* Fill in "ps_strings" struct for ps, w, etc.
-*/
+   /* Fill in "ps_strings" struct for ps, w, etc. */
suword(>ps_argvstr, (long)(intptr_t)vectp);
suword(>ps_nargvstr, argc);
 
-   /*
-* Fill in argument portion of vector table.
-*/
+   /* Fill in argument portion of vector table. */
for (; argc > 0; --argc) {
suword(vectp++, (long)(intptr_t)destp);
while (*stringp++ != 0)
@@ -423,15 +406,13 @@ linux_copyout_strings(struct image_params *imgp)
destp++;
}
 
-   /* a null vector table pointer separates the argp's from the envp's */
+   /* A null vector table pointer separates the argp's from the envp's. */
suword(vectp++, 0);
 
suword(>ps_envstr, (long)(intptr_t)vectp);
suword(>ps_nenvstr, envc);
 
-   /*
-* Fill in environment portion of vector table.
-*/
+   /* Fill in environment portion of vector table. */
for (; envc > 0; --envc) {
suword(vectp++, (long)(intptr_t)destp);
while (*stringp++ != 0)
@@ -439,7 

svn commit: r330820 - head/sys/cam/scsi

2018-03-12 Thread Brooks Davis
Author: brooks
Date: Mon Mar 12 23:02:01 2018
New Revision: 330820
URL: https://svnweb.freebsd.org/changeset/base/330820

Log:
  Reject ioctls to SCSI enclosures from 32-bit compat processes.
  
  The ioctl objects contain pointers and require translation and some
  refactoring of the infrastructure to work. For now prevent opertion
  on garbage values. This is very slightly overbroad in that ENCIOC_INIT
  is safe.
  
  Reviewed by:  imp, kib
  Obtained from:CheriBSD
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D14671

Modified:
  head/sys/cam/scsi/scsi_enc.c

Modified: head/sys/cam/scsi/scsi_enc.c
==
--- head/sys/cam/scsi/scsi_enc.cMon Mar 12 22:58:07 2018
(r330819)
+++ head/sys/cam/scsi/scsi_enc.cMon Mar 12 23:02:01 2018
(r330820)
@@ -29,6 +29,8 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include "opt_compat.h"
+
 #include 
 
 #include 
@@ -39,9 +41,11 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -354,6 +358,10 @@ enc_ioctl(struct cdev *dev, u_long cmd, caddr_t arg_ad
void *addr;
int error, i;
 
+#ifdef COMPAT_FREEBSD32
+   if (SV_PROC_FLAG(td->td_proc, SV_ILP32))
+   return (ENOTTY);
+#endif
 
if (arg_addr)
addr = *((caddr_t *) arg_addr);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r330780 - in head/sys: amd64/include isa x86/isa

2018-03-12 Thread Konstantin Belousov
On Mon, Mar 12, 2018 at 03:17:13PM -0600, Ian Lepore wrote:
> So, the eventtimer code in the atrtc driver doesn't even work, and has
> been broken (and unreported) since at least Nov 2015.  That sounds to
> me like even more evidence that we should just remove eventtimer stuff
> from the atrtc driver.
Ok.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2018-03-12 Thread Warner Losh
Author: imp
Date: Mon Mar 12 21:40:09 2018
New Revision: 330812
URL: https://svnweb.freebsd.org/changeset/base/330812

Log:
  Use the one-line-per-file pattern here, and sort the file names.
  
  Sponsored by: Netflix

Modified:
  head/stand/efi/libefi/Makefile

Modified: head/stand/efi/libefi/Makefile
==
--- head/stand/efi/libefi/Makefile  Mon Mar 12 21:40:05 2018
(r330811)
+++ head/stand/efi/libefi/Makefile  Mon Mar 12 21:40:09 2018
(r330812)
@@ -5,8 +5,20 @@
 LIB=   efi
 WARNS?=2
 
-SRCS=  delay.c devpath.c efi_console.c efichar.c efinet.c efipart.c env.c 
errno.c \
-   handles.c wchar.c libefi.c efi_driver_utils.c efizfs.c devicename.c
+SRCS=  delay.c \
+   devicename.c \
+   devpath.c \
+   efi_console.c \
+   efi_driver_utils.c \
+   efichar.c \
+   efinet.c \
+   efipart.c \
+   efizfs.c \
+   env.c \
+   errno.c \
+   handles.c \
+   libefi.c \
+   wchar.c
 
 .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
 SRCS+= time.c
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2018-03-12 Thread Warner Losh
Author: imp
Date: Mon Mar 12 21:40:05 2018
New Revision: 330811
URL: https://svnweb.freebsd.org/changeset/base/330811

Log:
  GC unused routines.
  
  Sponsored by: Netflix

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

Modified: head/stand/efi/libefi/env.c
==
--- head/stand/efi/libefi/env.c Mon Mar 12 21:39:59 2018(r330810)
+++ head/stand/efi/libefi/env.c Mon Mar 12 21:40:05 2018(r330811)
@@ -35,35 +35,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include "bootstrap.h"
 
-/*
- * Simple wrappers to the underlying UEFI functions.
- * See http://wiki.phoenix.com/wiki/index.php/EFI_RUNTIME_SERVICES
- * for details.
- */
-EFI_STATUS
-efi_get_next_variable_name(UINTN *variable_name_size, CHAR16 *variable_name,
-EFI_GUID *vendor_guid)
-{
-   return (RS->GetNextVariableName(variable_name_size, variable_name,
-   vendor_guid));
-}
-
-EFI_STATUS
-efi_get_variable(CHAR16 *variable_name, EFI_GUID *vendor_guid,
-UINT32 *attributes, UINTN *data_size, void *data)
-{
-   return (RS->GetVariable(variable_name, vendor_guid, attributes,
-   data_size, data));
-}
-
-EFI_STATUS
-efi_set_variable(CHAR16 *variable_name, EFI_GUID *vendor_guid,
-UINT32 attributes, UINTN data_size, void *data)
-{
-   return (RS->SetVariable(variable_name, vendor_guid, attributes,
-   data_size, data));
-}
-
 void
 efi_init_environment(void)
 {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330814 - head/stand/efi/boot1

2018-03-12 Thread Warner Losh
Author: imp
Date: Mon Mar 12 21:40:19 2018
New Revision: 330814
URL: https://svnweb.freebsd.org/changeset/base/330814

Log:
  Star BootCurrent entry when booting.
  
  Sponsored by: Netflix

Modified:
  head/stand/efi/boot1/boot1.c

Modified: head/stand/efi/boot1/boot1.c
==
--- head/stand/efi/boot1/boot1.cMon Mar 12 21:40:14 2018
(r330813)
+++ head/stand/efi/boot1/boot1.cMon Mar 12 21:40:19 2018
(r330814)
@@ -474,7 +474,8 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab)
efi_global_getenv("BootOrder", _order, );
printf("   BootOrder:");
for (i = 0; i < sz / sizeof(boot_order[0]); i++)
-   printf(" %04x", boot_order[i]);
+   printf(" %04x%s", boot_order[i],
+   boot_order[i] == boot_current ? "[*]" : "");
printf("\n");
 
 #ifdef TEST_FAILURE
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330817 - in head/sys: kern mips/include mips/mips

2018-03-12 Thread Brooks Davis
Author: brooks
Date: Mon Mar 12 22:10:06 2018
New Revision: 330817
URL: https://svnweb.freebsd.org/changeset/base/330817

Log:
  MIPS: Implement fue*word* and casueword* in assembly.
  
  Remove NO_FUEWORD so the 'e' variants are wrapped by the non-'e'
  variants.  This is more correct and leaves sparc64 as the outlier.
  
  Reviewed by:  jmallett, kib
  Obtained from:CheriBSD
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D14603

Modified:
  head/sys/kern/subr_uio.c
  head/sys/mips/include/param.h
  head/sys/mips/mips/support.S

Modified: head/sys/kern/subr_uio.c
==
--- head/sys/kern/subr_uio.cMon Mar 12 21:49:59 2018(r330816)
+++ head/sys/kern/subr_uio.cMon Mar 12 22:10:06 2018(r330817)
@@ -505,8 +505,8 @@ copyout_unmap(struct thread *td, vm_offset_t addr, siz
 /*
  * XXXKIB The temporal implementation of fue*() functions which do not
  * handle usermode -1 properly, mixing it with the fault code.  Keep
- * this until MD code is written.  Currently sparc64 and mips do not
- * have proper implementation.
+ * this until MD code is written.  Currently sparc64 does not have a
+ * proper implementation.
  */
 
 int

Modified: head/sys/mips/include/param.h
==
--- head/sys/mips/include/param.h   Mon Mar 12 21:49:59 2018
(r330816)
+++ head/sys/mips/include/param.h   Mon Mar 12 22:10:06 2018
(r330817)
@@ -185,8 +185,4 @@
 
 #definepgtok(x)((x) * (PAGE_SIZE / 1024))
 
-#ifdef _KERNEL
-#defineNO_FUEWORD  1
-#endif
-
 #endif /* !_MIPS_INCLUDE_PARAM_H_ */

Modified: head/sys/mips/mips/support.S
==
--- head/sys/mips/mips/support.SMon Mar 12 21:49:59 2018
(r330816)
+++ head/sys/mips/mips/support.SMon Mar 12 22:10:06 2018
(r330817)
@@ -285,8 +285,8 @@ END(copyerr)
  * user-space.
  */
 #ifdef __mips_n64
-LEAF(fuword64)
-XLEAF(fuword)
+LEAF(fueword64)
+XLEAF(fueword)
PTR_LA  v0, fswberr
blt a0, zero, fswberr   # make sure address is in user space
nop
@@ -294,14 +294,16 @@ XLEAF(fuword)
PTR_L   v1, PC_CURPCB(v1)
PTR_S   v0, U_PCB_ONFAULT(v1)
ld  v0, 0(a0)   # fetch word
-   j   ra
PTR_S   zero, U_PCB_ONFAULT(v1)
-END(fuword64)
+   sd  v0, 0(a1)   # store word
+   j   ra
+   li  v0, 0
+END(fueword64)
 #endif
 
-LEAF(fuword32)
+LEAF(fueword32)
 #ifndef __mips_n64
-XLEAF(fuword)
+XLEAF(fueword)
 #endif
PTR_LA  v0, fswberr
blt a0, zero, fswberr   # make sure address is in user space
@@ -310,11 +312,13 @@ XLEAF(fuword)
PTR_L   v1, PC_CURPCB(v1)
PTR_S   v0, U_PCB_ONFAULT(v1)
lw  v0, 0(a0)   # fetch word
-   j   ra
PTR_S   zero, U_PCB_ONFAULT(v1)
-END(fuword32)
+   sw  v0, 0(a1)   # store word
+   j   ra
+   li  v0, 0
+END(fueword32)
 
-LEAF(fusword)
+LEAF(fuesword)
PTR_LA  v0, fswberr
blt a0, zero, fswberr   # make sure address is in user space
nop
@@ -322,9 +326,11 @@ LEAF(fusword)
PTR_L   v1, PC_CURPCB(v1)
PTR_S   v0, U_PCB_ONFAULT(v1)
lhu v0, 0(a0)   # fetch short
-   j   ra
PTR_S   zero, U_PCB_ONFAULT(v1)
-END(fusword)
+   sh  v0, 0(a1)   # store short
+   j   ra
+   li  v0, 0
+END(fuesword)
 
 LEAF(fubyte)
PTR_LA  v0, fswberr
@@ -371,17 +377,18 @@ END(suword64)
 #endif
 
 /*
- * casuword(9)
- * u_long casuword(u_long *p, u_long oldval, u_long newval)
+ * casueword(9)
+ * u_long casueword(u_long *p, u_long oldval, u_long *oldval_p,
+ *u_long newval)
  */
 /*
- * casuword32(9)
- * uint32_t casuword(uint32_t *p, uint32_t oldval, 
- * uint32_t newval)
+ * casueword32(9)
+ * uint32_t casueword(uint32_t *p, uint32_t oldval,
+ *  uint32_t newval)
  */
-LEAF(casuword32)
+LEAF(casueword32)
 #ifndef __mips_n64
-XLEAF(casuword)
+XLEAF(casueword)
 #endif
PTR_LA  v0, fswberr
blt a0, zero, fswberr   # make sure address is in user space
@@ -390,26 +397,26 @@ XLEAF(casuword)
PTR_L   v1, PC_CURPCB(v1)
PTR_S   v0, U_PCB_ONFAULT(v1)
 1:
-   movet0, a2
-   ll  v0, 0(a0)
-   bne a1, v0, 2f
+   movet0, a3
+   ll  t1, 0(a0)
+   bne a1, t1, 2f
nop
sc  t0, 0(a0)   # store word
beqzt0, 1b
nop
j   3f
-   nop
+   li  v0, 0
 2:
li  v0, -1
 3:
PTR_S   zero, U_PCB_ONFAULT(v1)
jr  ra
-   nop
-END(casuword32)
+   

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

2018-03-12 Thread Ed Maste
Author: emaste
Date: Mon Mar 12 23:28:25 2018
New Revision: 330822
URL: https://svnweb.freebsd.org/changeset/base/330822

Log:
  imgact_linux.c: use standard indentation
  
  Sponsored by: Turing Robotic Industries Inc.

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

Modified: head/sys/i386/linux/imgact_linux.c
==
--- head/sys/i386/linux/imgact_linux.c  Mon Mar 12 23:04:42 2018
(r330821)
+++ head/sys/i386/linux/imgact_linux.c  Mon Mar 12 23:28:25 2018
(r330822)
@@ -60,176 +60,166 @@ static intexec_linux_imgact(struct image_params 
*ipar
 static int
 exec_linux_imgact(struct image_params *imgp)
 {
-const struct exec *a_out = (const struct exec *) imgp->image_header;
-struct vmspace *vmspace;
-vm_offset_t vmaddr;
-unsigned long virtual_offset, file_offset;
-unsigned long bss_size;
-ssize_t aresid;
-int error;
+   const struct exec *a_out = (const struct exec *) imgp->image_header;
+   struct vmspace *vmspace;
+   vm_offset_t vmaddr;
+   unsigned long virtual_offset, file_offset;
+   unsigned long bss_size;
+   ssize_t aresid;
+   int error;
 
-if (((a_out->a_magic >> 16) & 0xff) != 0x64)
-   return (-1);
+   if (((a_out->a_magic >> 16) & 0xff) != 0x64)
+   return (-1);
 
-/*
- * Set file/virtual offset based on a.out variant.
- */
-switch ((int)(a_out->a_magic & 0x)) {
-case 0413:
-   virtual_offset = 0;
-   file_offset = 1024;
-   break;
-case 0314:
-   virtual_offset = 4096;
-   file_offset = 0;
-   break;
-default:
-   return (-1);
-}
-bss_size = round_page(a_out->a_bss);
+   /*
+* Set file/virtual offset based on a.out variant.
+*/
+   switch ((int)(a_out->a_magic & 0x)) {
+   case 0413:
+   virtual_offset = 0;
+   file_offset = 1024;
+   break;
+   case 0314:
+   virtual_offset = 4096;
+   file_offset = 0;
+   break;
+   default:
+   return (-1);
+   }
+   bss_size = round_page(a_out->a_bss);
 #ifdef DEBUG
-printf("imgact: text: %08lx, data: %08lx, bss: %08lx\n",
-   (u_long)a_out->a_text, (u_long)a_out->a_data, bss_size);
+   printf("imgact: text: %08lx, data: %08lx, bss: %08lx\n",
+   (u_long)a_out->a_text, (u_long)a_out->a_data, bss_size);
 #endif
 
-/*
- * Check various fields in header for validity/bounds.
- */
-if (a_out->a_entry < virtual_offset ||
-   a_out->a_entry >= virtual_offset + a_out->a_text ||
-   a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK)
-   return (-1);
+   /*
+* Check various fields in header for validity/bounds.
+*/
+   if (a_out->a_entry < virtual_offset ||
+   a_out->a_entry >= virtual_offset + a_out->a_text ||
+   a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK)
+   return (-1);
 
-/* text + data can't exceed file size */
-if (a_out->a_data + a_out->a_text > imgp->attr->va_size)
-   return (EFAULT);
-/*
- * text/data/bss must not exceed limits
- */
-PROC_LOCK(imgp->proc);
-if (a_out->a_text > maxtsiz ||
-   a_out->a_data + bss_size > lim_cur_proc(imgp->proc, RLIMIT_DATA) ||
-   racct_set(imgp->proc, RACCT_DATA, a_out->a_data + bss_size) != 0) {
+   /* text + data can't exceed file size */
+   if (a_out->a_data + a_out->a_text > imgp->attr->va_size)
+   return (EFAULT);
+   /*
+* text/data/bss must not exceed limits
+*/
+   PROC_LOCK(imgp->proc);
+   if (a_out->a_text > maxtsiz ||
+   a_out->a_data + bss_size > lim_cur_proc(imgp->proc, RLIMIT_DATA) ||
+   racct_set(imgp->proc, RACCT_DATA, a_out->a_data + bss_size) != 0) {
+   PROC_UNLOCK(imgp->proc);
+   return (ENOMEM);
+   }
PROC_UNLOCK(imgp->proc);
-   return (ENOMEM);
-}
-PROC_UNLOCK(imgp->proc);
 
-VOP_UNLOCK(imgp->vp, 0);
+   VOP_UNLOCK(imgp->vp, 0);
 
-/*
- * Destroy old process VM and create a new one (with a new stack)
- */
-error = exec_new_vmspace(imgp, _sysvec);
-if (error)
-   goto fail;
-vmspace = imgp->proc->p_vmspace;
-
-/*
- * Check if file_offset page aligned,.
- * Currently we cannot handle misaligned file offsets,
- * and so we read in the entire image (what a waste).
- */
-if (file_offset & PAGE_MASK) {
-#ifdef DEBUG
-   printf("imgact: Non page aligned binary %lu\n", file_offset);
-#endif
/*
-* Map text+data+bss read/write/execute
+* Destroy old process VM and create a new one (with a new stack)
 */
-   vmaddr = virtual_offset;
-   error = vm_map_find(>vm_map, NULL, 0, ,
-   a_out->a_text + a_out->a_data + bss_size, 0, VMFS_NO_SPACE,
-   

svn commit: r330809 - in head/stand: common efi/libefi efi/loader i386/libi386 i386/loader mips/beri/loader ofw/libofw sparc64/loader uboot/common uboot/lib userboot/userboot zfs

2018-03-12 Thread Warner Losh
Author: imp
Date: Mon Mar 12 21:39:49 2018
New Revision: 330809
URL: https://svnweb.freebsd.org/changeset/base/330809

Log:
  Use the actual struct devdesc at the start of all *_devdesc structs
  
  The current system is fragile and requires very careful layout of all
  *_devdesc structures. It also makes it hard to change the base
  devdesc. Take a page from CAM and put the 'header' in all the derived
  classes and adjust the code to match.
  
  For OFW, move the iHandle h_handle out of a slot conflicting with
  d_opendata. Due to quirks in the alignment rules, this worked.
  However changing the code to use d_opendata storage now that it's a
  pointer is hard, so just have a separate field for it.
  
  All other cleanups were to make the *_devdesc structures match where
  they'd taken some liberties that were none-the-less compatible enough
  to work.

Modified:
  head/stand/common/disk.c
  head/stand/common/disk.h
  head/stand/efi/libefi/efipart.c
  head/stand/efi/libefi/efizfs.c
  head/stand/efi/loader/main.c
  head/stand/i386/libi386/bioscd.c
  head/stand/i386/libi386/biosdisk.c
  head/stand/i386/libi386/bootinfo32.c
  head/stand/i386/libi386/devicename.c
  head/stand/i386/libi386/libi386.h
  head/stand/i386/loader/chain.c
  head/stand/i386/loader/main.c
  head/stand/mips/beri/loader/beri_disk_cfi.c
  head/stand/mips/beri/loader/beri_disk_sdcard.c
  head/stand/mips/beri/loader/devicename.c
  head/stand/ofw/libofw/devicename.c
  head/stand/ofw/libofw/libofw.h
  head/stand/sparc64/loader/main.c
  head/stand/uboot/common/main.c
  head/stand/uboot/lib/devicename.c
  head/stand/uboot/lib/disk.c
  head/stand/uboot/lib/libuboot.h
  head/stand/userboot/userboot/devicename.c
  head/stand/userboot/userboot/main.c
  head/stand/userboot/userboot/userboot_disk.c
  head/stand/zfs/libzfs.h
  head/stand/zfs/zfs.c

Modified: head/stand/common/disk.c
==
--- head/stand/common/disk.cMon Mar 12 21:39:42 2018(r330808)
+++ head/stand/common/disk.cMon Mar 12 21:39:49 2018(r330809)
@@ -86,7 +86,7 @@ ptblread(void *d, void *buf, size_t blocks, uint64_t o
struct open_disk *od;
 
dev = (struct disk_devdesc *)d;
-   od = (struct open_disk *)dev->d_opendata;
+   od = (struct open_disk *)dev->dd.d_opendata;
 
/*
 * The strategy function assumes the offset is in units of 512 byte
@@ -98,7 +98,7 @@ ptblread(void *d, void *buf, size_t blocks, uint64_t o
 * As the GPT backup partition is located at the end of the disk,
 * to avoid reading past disk end, flag bcache not to use RA.
 */
-   return (dev->d_dev->dv_strategy(dev, F_READ | F_NORA, offset,
+   return (dev->dd.d_dev->dv_strategy(dev, F_READ | F_NORA, offset,
blocks * od->sectorsize, (char *)buf, NULL));
 }
 
@@ -114,7 +114,7 @@ ptable_print(void *arg, const char *pname, const struc
int res;
 
pa = (struct print_args *)arg;
-   od = (struct open_disk *)pa->dev->d_opendata;
+   od = (struct open_disk *)pa->dev->dd.d_opendata;
sprintf(line, "  %s%s: %s", pa->prefix, pname,
parttype2str(part->type));
if (pa->verbose)
@@ -127,8 +127,8 @@ ptable_print(void *arg, const char *pname, const struc
res = 0;
if (part->type == PART_FREEBSD) {
/* Open slice with BSD label */
-   dev.d_dev = pa->dev->d_dev;
-   dev.d_unit = pa->dev->d_unit;
+   dev.dd.d_dev = pa->dev->dd.d_dev;
+   dev.dd.d_unit = pa->dev->dd.d_unit;
dev.d_slice = part->index;
dev.d_partition = -1;
if (disk_open(, part->end - part->start + 1,
@@ -158,7 +158,7 @@ disk_print(struct disk_devdesc *dev, char *prefix, int
struct print_args pa;
 
/* Disk should be opened */
-   od = (struct open_disk *)dev->d_opendata;
+   od = (struct open_disk *)dev->dd.d_opendata;
pa.dev = dev;
pa.prefix = prefix;
pa.verbose = verbose;
@@ -171,8 +171,8 @@ disk_read(struct disk_devdesc *dev, void *buf, uint64_
struct open_disk *od;
int ret;
 
-   od = (struct open_disk *)dev->d_opendata;
-   ret = dev->d_dev->dv_strategy(dev, F_READ, dev->d_offset + offset,
+   od = (struct open_disk *)dev->dd.d_opendata;
+   ret = dev->dd.d_dev->dv_strategy(dev, F_READ, dev->d_offset + offset,
blocks * od->sectorsize, buf, NULL);
 
return (ret);
@@ -184,8 +184,8 @@ disk_write(struct disk_devdesc *dev, void *buf, uint64
struct open_disk *od;
int ret;
 
-   od = (struct open_disk *)dev->d_opendata;
-   ret = dev->d_dev->dv_strategy(dev, F_WRITE, dev->d_offset + offset,
+   od = (struct open_disk *)dev->dd.d_opendata;
+   ret = dev->dd.d_dev->dv_strategy(dev, F_WRITE, dev->d_offset + offset,
blocks * od->sectorsize, buf, NULL);
 
return (ret);
@@ -194,7 +194,7 

svn commit: r330810 - in head/stand: efi/libefi efi/loader i386/libi386 i386/loader libsa mips/beri/loader ofw/libofw sparc64/loader uboot/common uboot/lib userboot/userboot zfs

2018-03-12 Thread Warner Losh
Author: imp
Date: Mon Mar 12 21:39:59 2018
New Revision: 330810
URL: https://svnweb.freebsd.org/changeset/base/330810

Log:
  Remove d_type from devdesc. It's not needed as we can fetch it from
  d_dev->dv_type when we need it.

Modified:
  head/stand/efi/libefi/devicename.c
  head/stand/efi/loader/main.c
  head/stand/i386/libi386/biosdisk.c
  head/stand/i386/libi386/bootinfo32.c
  head/stand/i386/libi386/devicename.c
  head/stand/i386/loader/main.c
  head/stand/libsa/stand.h
  head/stand/mips/beri/loader/devicename.c
  head/stand/ofw/libofw/devicename.c
  head/stand/sparc64/loader/main.c
  head/stand/uboot/common/main.c
  head/stand/uboot/lib/devicename.c
  head/stand/userboot/userboot/devicename.c
  head/stand/userboot/userboot/main.c
  head/stand/zfs/zfs.c

Modified: head/stand/efi/libefi/devicename.c
==
--- head/stand/efi/libefi/devicename.c  Mon Mar 12 21:39:49 2018
(r330809)
+++ head/stand/efi/libefi/devicename.c  Mon Mar 12 21:39:59 2018
(r330810)
@@ -161,7 +161,6 @@ efi_parsedev(struct devdesc **dev, const char *devspec
}
 
idev->d_dev = dv;
-   idev->d_type = dv->dv_type;
 
if (dev != NULL)
*dev = idev;
@@ -180,7 +179,7 @@ efi_fmtdev(void *vdev)
struct devdesc *dev = (struct devdesc *)vdev;
static char buf[SPECNAMELEN + 1];
 
-   switch(dev->d_type) {
+   switch(dev->d_dev->dv_type) {
case DEVT_NONE:
strcpy(buf, "(no device)");
break;

Modified: head/stand/efi/loader/main.c
==
--- head/stand/efi/loader/main.cMon Mar 12 21:39:49 2018
(r330809)
+++ head/stand/efi/loader/main.cMon Mar 12 21:39:59 2018
(r330810)
@@ -175,7 +175,6 @@ set_devdesc_currdev(struct devsw *dev, int unit)
char *devname;
 
currdev.d_dev = dev;
-   currdev.d_type = currdev.d_dev->dv_type;
currdev.d_unit = unit;
devname = efi_fmtdev();
 
@@ -203,7 +202,6 @@ find_currdev(EFI_LOADED_IMAGE *img)
 
currdev.dd.d_dev = _dev;
currdev.dd.d_unit = 0;
-   currdev.dd.d_type = currdev.dd.d_dev->dv_type;
currdev.pool_guid = pool_guid;
currdev.root_guid = 0;
devname = efi_fmtdev();
@@ -223,7 +221,6 @@ find_currdev(EFI_LOADED_IMAGE *img)
struct disk_devdesc currdev;
 
currdev.dd.d_dev = _hddev;
-   currdev.dd.d_type = currdev.dd.d_dev->dv_type;
currdev.dd.d_unit = dp->pd_unit;
currdev.d_slice = -1;
currdev.d_partition = -1;
@@ -845,7 +842,7 @@ command_chain(int argc, char *argv[])
struct disk_devdesc *d_dev;
pdinfo_t *hd, *pd;
 
-   switch (dev->d_type) {
+   switch (dev->d_dev->dv_type) {
 #ifdef EFI_ZFS_BOOT
case DEVT_ZFS:
z_dev = (struct zfs_devdesc *)dev;

Modified: head/stand/i386/libi386/biosdisk.c
==
--- head/stand/i386/libi386/biosdisk.c  Mon Mar 12 21:39:49 2018
(r330809)
+++ head/stand/i386/libi386/biosdisk.c  Mon Mar 12 21:39:59 2018
(r330810)
@@ -403,7 +403,6 @@ bd_open(struct open_file *f, ...)
 * would overflow so it should be safe to perform here.
 */
disk.dd.d_dev = dev->dd.d_dev;
-   disk.dd.d_type = dev->dd.d_type;
disk.dd.d_unit = dev->dd.d_unit;
disk.dd.d_opendata = NULL;
disk.d_slice = -1;
@@ -441,7 +440,7 @@ bd_open(struct open_file *f, ...)
int geli_part = 0;
 
dskp.drive = bd_unit2bios(dev->dd.d_unit);
-   dskp.type = dev->dd.d_type;
+   dskp.type = dev->dd.d_dev->dv_type;
dskp.unit = dev->dd.d_unit;
dskp.slice = dev->d_slice;
dskp.part = dev->d_partition;
@@ -872,7 +871,7 @@ bd_read(struct disk_devdesc *dev, daddr_t dblk, int bl
return (err);
 
dskp.drive = bd_unit2bios(dev->dd.d_unit);
-   dskp.type = dev->dd.d_type;
+   dskp.type = dev->dd.d_dev->dv_type;
dskp.unit = dev->dd.d_unit;
dskp.slice = dev->d_slice;
dskp.part = dev->d_partition;
@@ -997,7 +996,6 @@ bios_read(void *vdev __unused, void *xpriv, off_t off,
struct dsk *priv = xpriv;
 
dev.dd.d_dev = 
-   dev.dd.d_type = priv->type;
dev.dd.d_unit = priv->unit;
dev.d_slice = priv->slice;
dev.d_partition = priv->part;

Modified: head/stand/i386/libi386/bootinfo32.c
==
--- head/stand/i386/libi386/bootinfo32.cMon Mar 12 21:39:49 2018
(r330809)
+++ head/stand/i386/libi386/bootinfo32.cMon Mar 12 21:39:59 2018

svn commit: r330824 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2018-03-12 Thread Alexander Motin
Author: mav
Date: Tue Mar 13 01:19:07 2018
New Revision: 330824
URL: https://svnweb.freebsd.org/changeset/base/330824

Log:
  MFC r330048:  Add sysctls/tunables for dbuf cache size.

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

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Tue Mar 
13 00:40:05 2018(r330823)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Tue Mar 
13 01:19:07 2018(r330824)
@@ -133,6 +133,16 @@ int dbuf_cache_max_shift = 5;
 uint_t dbuf_cache_hiwater_pct = 10;
 uint_t dbuf_cache_lowater_pct = 10;
 
+SYSCTL_DECL(_vfs_zfs);
+SYSCTL_QUAD(_vfs_zfs, OID_AUTO, dbuf_cache_max_bytes, CTLFLAG_RWTUN,
+_cache_max_bytes, 0, "dbuf cache size in bytes");
+SYSCTL_INT(_vfs_zfs, OID_AUTO, dbuf_cache_max_shift, CTLFLAG_RDTUN,
+_cache_max_shift, 0, "dbuf size as log2 fraction of ARC");
+SYSCTL_UINT(_vfs_zfs, OID_AUTO, dbuf_cache_hiwater_pct, CTLFLAG_RWTUN,
+_cache_hiwater_pct, 0, "max percents above the dbuf cache size");
+SYSCTL_UINT(_vfs_zfs, OID_AUTO, dbuf_cache_lowater_pct, CTLFLAG_RWTUN,
+_cache_lowater_pct, 0, "max percents below the dbuf cache size");
+
 /* ARGSUSED */
 static int
 dbuf_cons(void *vdb, void *unused, int kmflag)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330815 - head/stand/efi/loader

2018-03-12 Thread Warner Losh
Author: imp
Date: Mon Mar 12 21:40:24 2018
New Revision: 330815
URL: https://svnweb.freebsd.org/changeset/base/330815

Log:
  Print the load and device path as well as BootCurrent and BootOrder
  
  Sponsored by: Netflix

Modified:
  head/stand/efi/loader/main.c

Modified: head/stand/efi/loader/main.c
==
--- head/stand/efi/loader/main.cMon Mar 12 21:40:19 2018
(r330814)
+++ head/stand/efi/loader/main.cMon Mar 12 21:40:24 2018
(r330815)
@@ -312,6 +312,12 @@ main(int argc, CHAR16 *argv[])
int i, j, vargood, howto;
UINTN k;
int has_kbd;
+   CHAR16 *text;
+   UINT16 boot_current;
+   size_t sz;
+   UINT16 boot_order[100];
+   EFI_DEVICE_PATH *imgpath;
+   EFI_STATUS status;
 #if !defined(__arm__)
char buf[40];
 #endif
@@ -472,6 +478,36 @@ main(int argc, CHAR16 *argv[])
ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0x);
 
printf("\n%s", bootprog_info);
+
+   text = efi_devpath_name(img->FilePath);
+   if (text != NULL) {
+   printf("   Load Path: %S\n", text);
+   efi_setenv_freebsd_wcs("LoaderPath", text);
+   efi_free_devpath_name(text);
+   }
+
+   status = BS->HandleProtocol(img->DeviceHandle, , (void 
**));
+   if (status == EFI_SUCCESS) {
+   text = efi_devpath_name(imgpath);
+   if (text != NULL) {
+   printf("   Load Device: %S\n", text);
+   efi_setenv_freebsd_wcs("LoaderDev", text);
+   efi_free_devpath_name(text);
+   }
+   }
+
+   boot_current = 0;
+   sz = sizeof(boot_current);
+   efi_global_getenv("BootCurrent", _current, );
+   printf("   BootCurrent: %04x\n", boot_current);
+
+   sz = sizeof(boot_order);
+   efi_global_getenv("BootOrder", _order, );
+   printf("   BootOrder:");
+   for (i = 0; i < sz / sizeof(boot_order[0]); i++)
+   printf(" %04x%s", boot_order[i],
+   boot_order[i] == boot_current ? "[*]" : "");
+   printf("\n");
 
/*
 * Disable the watchdog timer. By default the boot manager sets
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330821 - head/sys/kern

2018-03-12 Thread Brooks Davis
Author: brooks
Date: Mon Mar 12 23:04:42 2018
New Revision: 330821
URL: https://svnweb.freebsd.org/changeset/base/330821

Log:
  Use the stack for temporary storage in OTIOCCONS.
  
  The old code used the thread's pcb via the uap->data pointer.
  
  Reviewed by:  ed
  Approved by:  CheriBSD
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D14674

Modified:
  head/sys/kern/tty_compat.c

Modified: head/sys/kern/tty_compat.c
==
--- head/sys/kern/tty_compat.c  Mon Mar 12 23:02:01 2018(r330820)
+++ head/sys/kern/tty_compat.c  Mon Mar 12 23:04:42 2018(r330821)
@@ -262,9 +262,11 @@ tty_ioctl_compat(struct tty *tp, u_long com, caddr_t d
fflag, td));
}
 
-   case OTIOCCONS:
-   *(int *)data = 1;
-   return (tty_ioctl(tp, TIOCCONS, data, fflag, td));
+   case OTIOCCONS: {
+   int one = 1;
+
+   return (tty_ioctl(tp, TIOCCONS, (caddr_t), fflag, td));
+   }
 
default:
return (ENOIOCTL);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330808 - head/stand/i386/libi386

2018-03-12 Thread Warner Losh
Author: imp
Date: Mon Mar 12 21:39:42 2018
New Revision: 330808
URL: https://svnweb.freebsd.org/changeset/base/330808

Log:
  Make struct libi386_devdesc match the struct devdesc better
  
  Move data to top and call it d_opendata.

Modified:
  head/stand/i386/libi386/libi386.h

Modified: head/stand/i386/libi386/libi386.h
==
--- head/stand/i386/libi386/libi386.h   Mon Mar 12 21:39:38 2018
(r330807)
+++ head/stand/i386/libi386/libi386.h   Mon Mar 12 21:39:42 2018
(r330808)
@@ -36,22 +36,17 @@ struct i386_devdesc {
 struct devsw   *d_dev;
 intd_type;
 intd_unit;
+void   *d_opendata;
 union 
 {
struct 
{
-   void*data;
int slice;
int partition;
off_t   offset;
} biosdisk;
struct
{
-   void*data;
-   } bioscd;
-   struct
-   {
-   void*data;
uint64_tpool_guid;
uint64_troot_guid;
} zfs;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330806 - in head/stand: common i386/libi386 libsa ofw/libofw uboot/lib zfs

2018-03-12 Thread Warner Losh
Author: imp
Date: Mon Mar 12 21:39:27 2018
New Revision: 330806
URL: https://svnweb.freebsd.org/changeset/base/330806

Log:
  Minor cosmetic changes.
  
  Make sure { on the same line as struct for all struct *devdesc.  Move
  some type definitions to next to the dv_type define, since that's what
  sets the d_type.

Modified:
  head/stand/common/disk.h
  head/stand/i386/libi386/libi386.h
  head/stand/libsa/stand.h
  head/stand/ofw/libofw/libofw.h
  head/stand/uboot/lib/libuboot.h
  head/stand/zfs/libzfs.h

Modified: head/stand/common/disk.h
==
--- head/stand/common/disk.hMon Mar 12 17:37:38 2018(r330805)
+++ head/stand/common/disk.hMon Mar 12 21:39:27 2018(r330806)
@@ -81,8 +81,8 @@
 #ifndef_DISK_H
 #define_DISK_H
 
-struct disk_devdesc
-{
+/* Note: Must match the 'struct devdesc' in stand.h */
+struct disk_devdesc {
struct devsw*d_dev;
int d_type;
int d_unit;

Modified: head/stand/i386/libi386/libi386.h
==
--- head/stand/i386/libi386/libi386.h   Mon Mar 12 17:37:38 2018
(r330805)
+++ head/stand/i386/libi386/libi386.h   Mon Mar 12 21:39:27 2018
(r330806)
@@ -29,12 +29,10 @@
 
 /*
  * i386 fully-qualified device descriptor.
- * Note, this must match the 'struct devdesc' declaration
- * in bootstrap.h and also with struct zfs_devdesc for zfs
- * support.
+ * Note, this must match struct zfs_devdesc for zfs support.
  */
-struct i386_devdesc
-{
+/* Note: Must match the 'struct devdesc' in stand.h */
+struct i386_devdesc {
 struct devsw   *d_dev;
 intd_type;
 intd_unit;

Modified: head/stand/libsa/stand.h
==
--- head/stand/libsa/stand.hMon Mar 12 17:37:38 2018(r330805)
+++ head/stand/libsa/stand.hMon Mar 12 21:39:27 2018(r330806)
@@ -138,6 +138,12 @@ extern struct fs_ops pkgfs_fsops;
 struct devsw {
 const char dv_name[8];
 intdv_type;/* opaque type constant, 
arch-dependant */
+#define DEVT_NONE  0
+#define DEVT_DISK  1
+#define DEVT_NET   2
+#define DEVT_CD3
+#define DEVT_ZFS   4
+#define DEVT_FD5
 int(*dv_init)(void);   /* early probe call */
 int(*dv_strategy)(void *devdata, int rw, daddr_t blk,
size_t size, char *buf, size_t *rsize);
@@ -160,16 +166,9 @@ extern int errno;
  * versions may be larger, but should be allowed to
  * overlap.
  */
-struct devdesc
-{
+struct devdesc {
 struct devsw   *d_dev;
 intd_type;
-#define DEVT_NONE  0
-#define DEVT_DISK  1
-#define DEVT_NET   2
-#define DEVT_CD3
-#define DEVT_ZFS   4
-#define DEVT_FD5
 intd_unit;
 void   *d_opendata;
 };

Modified: head/stand/ofw/libofw/libofw.h
==
--- head/stand/ofw/libofw/libofw.h  Mon Mar 12 17:37:38 2018
(r330805)
+++ head/stand/ofw/libofw/libofw.h  Mon Mar 12 21:39:27 2018
(r330806)
@@ -27,7 +27,7 @@
 
 #include "openfirm.h"
 
-/* Note: Must match the 'struct devdesc' in bootstrap.h */
+/* Note: Must match the 'struct devdesc' in stand.h */
 struct ofw_devdesc {
struct devsw*d_dev;
int d_type;

Modified: head/stand/uboot/lib/libuboot.h
==
--- head/stand/uboot/lib/libuboot.h Mon Mar 12 17:37:38 2018
(r330805)
+++ head/stand/uboot/lib/libuboot.h Mon Mar 12 21:39:27 2018
(r330806)
@@ -27,8 +27,8 @@
  * $FreeBSD$
  */
 
-struct uboot_devdesc
-{
+/* Note: Must match the 'struct devdesc' in stand.h */
+struct uboot_devdesc {
struct devsw*d_dev;
int d_type;
int d_unit;

Modified: head/stand/zfs/libzfs.h
==
--- head/stand/zfs/libzfs.h Mon Mar 12 17:37:38 2018(r330805)
+++ head/stand/zfs/libzfs.h Mon Mar 12 21:39:27 2018(r330806)
@@ -33,12 +33,11 @@
 
 /*
  * ZFS fully-qualified device descriptor.
- * Note, this must match the 'struct devdesc' declaration in bootstrap.h.
  * Arch-specific device descriptors should be binary compatible with this
  * structure if they are to support ZFS.
  */
-struct zfs_devdesc
-{
+/* Note: Must match the 'struct devdesc' in stand.h */
+struct zfs_devdesc {
 struct devsw   *d_dev;
 intd_type;
 intd_unit;
___
svn-src-all@freebsd.org 

svn commit: r330807 - in head/stand/efi: libefi loader

2018-03-12 Thread Warner Losh
Author: imp
Date: Mon Mar 12 21:39:38 2018
New Revision: 330807
URL: https://svnweb.freebsd.org/changeset/base/330807

Log:
  We can't use d_opendata for blkio storage.
  
  open_disk uses d_opendata for it's own purpse. We can't store blkio
  there. Fortunately, blkio is stored elsewhere and we never actually
  retrieve blkio from d_opendata. Eliminate it as a source of confusion.
  Eliminate all stores of d_opendata in efi since this layer doesn't own
  that field.

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

Modified: head/stand/efi/libefi/efipart.c
==
--- head/stand/efi/libefi/efipart.c Mon Mar 12 21:39:27 2018
(r330806)
+++ head/stand/efi/libefi/efipart.c Mon Mar 12 21:39:38 2018
(r330807)
@@ -748,7 +748,6 @@ efipart_print_common(struct devsw *dev, pdinfo_list_t 
pd_dev.d_unit = pd->pd_unit;
pd_dev.d_slice = -1;
pd_dev.d_partition = -1;
-   pd_dev.d_opendata = blkio;
ret = disk_open(_dev, blkio->Media->BlockSize *
(blkio->Media->LastBlock + 1),
blkio->Media->BlockSize);

Modified: head/stand/efi/loader/main.c
==
--- head/stand/efi/loader/main.cMon Mar 12 21:39:27 2018
(r330806)
+++ head/stand/efi/loader/main.cMon Mar 12 21:39:38 2018
(r330807)
@@ -177,7 +177,6 @@ set_devdesc_currdev(struct devsw *dev, int unit)
currdev.d_dev = dev;
currdev.d_type = currdev.d_dev->dv_type;
currdev.d_unit = unit;
-   currdev.d_opendata = NULL;
devname = efi_fmtdev();
 
env_setenv("currdev", EV_VOLATILE, devname, efi_setcurrdev,
@@ -205,7 +204,6 @@ find_currdev(EFI_LOADED_IMAGE *img)
currdev.d_dev = _dev;
currdev.d_unit = 0;
currdev.d_type = currdev.d_dev->dv_type;
-   currdev.d_opendata = NULL;
currdev.pool_guid = pool_guid;
currdev.root_guid = 0;
devname = efi_fmtdev();
@@ -227,7 +225,6 @@ find_currdev(EFI_LOADED_IMAGE *img)
currdev.d_dev = _hddev;
currdev.d_type = currdev.d_dev->dv_type;
currdev.d_unit = dp->pd_unit;
-   currdev.d_opendata = NULL;
currdev.d_slice = -1;
currdev.d_partition = -1;
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r330819 - head/sys/cam/scsi

2018-03-12 Thread Brooks Davis
Author: brooks
Date: Mon Mar 12 22:58:07 2018
New Revision: 330819
URL: https://svnweb.freebsd.org/changeset/base/330819

Log:
  Reject CAMIOGET and CAMIOQUEUE ioctl's on pass(4) in 32-bit compat mode.
  
  These take a union ccb argument which is full of kernel pointers.
  Substantial translation efforts would be required to make this work.
  By rejecting the request we avoid processing or returning entierly
  wrong data.
  
  Reviewed by:  imp, ken, markj, cem
  Obtained from:CheriBSD
  MFC after:1 week
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D14654

Modified:
  head/sys/cam/scsi/scsi_pass.c

Modified: head/sys/cam/scsi/scsi_pass.c
==
--- head/sys/cam/scsi/scsi_pass.c   Mon Mar 12 22:17:14 2018
(r330818)
+++ head/sys/cam/scsi/scsi_pass.c   Mon Mar 12 22:58:07 2018
(r330819)
@@ -30,6 +30,8 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include "opt_compat.h"
+
 #include 
 #include 
 #include 
@@ -45,6 +47,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1859,6 +1862,12 @@ passdoioctl(struct cdev *dev, u_long cmd, caddr_t addr
union ccb **user_ccb, *ccb;
xpt_opcode fc;
 
+#ifdef COMPAT_FREEBSD32
+   if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) {
+   error = ENOTTY;
+   goto bailout;
+   }
+#endif
if ((softc->flags & PASS_FLAG_ZONE_VALID) == 0) {
error = passcreatezone(periph);
if (error != 0)
@@ -2033,6 +2042,12 @@ camioqueue_error:
struct pass_io_req *io_req;
int old_error;
 
+#ifdef COMPAT_FREEBSD32
+   if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) {
+   error = ENOTTY;
+   goto bailout;
+   }
+#endif
user_ccb = (union ccb **)addr;
old_error = 0;
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r330780 - in head/sys: amd64/include isa x86/isa

2018-03-12 Thread Ian Lepore
On Mon, 2018-03-12 at 13:03 -0600, Ian Lepore wrote:
> On Mon, 2018-03-12 at 17:56 +0200, Konstantin Belousov wrote:
> > 
> > On Mon, Mar 12, 2018 at 09:34:51AM -0600, Ian Lepore wrote:
> > > 
> > > [...]
> > > 
> > > Does anybody really need an eventtimer that runs only at a fixed
> > > periodic rate of 32khz in 2018?
> > Problem is that atrtc is what old machines use. If we have HPET or
> > better LAPIC timers, then we do not need atrtc at all, of course.
> > But e.g. 486 do not have them. I am not even sure about early amd64
> > machines.
> I think not unless someone has manually configured it that way.  The
> i8254 timer should be used as both timecounter and eventtimer if there
> is no lapic or hpet.  i8254 has an ET priority of 100 compared to
> atrtc's 0.  That's by code inspection...  I might still have some
> industrial SBCs around here old enough to not have hpet or lapic, I'll
> see if I can get one running.
> 

I found a nice old (2001 vintage) SBC based on a 586-class cyrix chip
that has no lapic or hpet timers.  It had a copy of freebsd 11-current
from Nov 2015 already installed and it booted right up.  It was using
the i8254 hardware as both timecounter and eventtimer.  I rebooted it
from a drive that had a copy of 12-current from yesterday and it
behaved the same.

Then I rebooted and set hint.attimer.0.clock=0 to prevent the i8254
driver from attaching an eventtimer.  That left only the atrtc
eventimer, and the result of that was that the system just becomes
comatose after saying "Timecounters tick every 0.967 msec".  So I
booted the old 11-current image with i8254 disabled, and that behaved
just the same.

So, the eventtimer code in the atrtc driver doesn't even work, and has
been broken (and unreported) since at least Nov 2015.  That sounds to
me like even more evidence that we should just remove eventtimer stuff
from the atrtc driver.

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