Re: svn commit: r323692 - in head/sys/compat: linsysfs linux

2017-09-18 Thread Hans Petter Selasky

On 09/18/17 01:40, Conrad Meyer wrote:

+   sprintf(chardevname, "226:%d",
+   device_get_unit(dev));


Hi,

Try to use snprintf(). Define the chardevname size as a macro, or just 
allocate it on the stack if it is < 32 bytes.


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


Re: svn commit: r323692 - in head/sys/compat: linsysfs linux

2017-09-18 Thread Hans Petter Selasky

On 09/18/17 17:09, Conrad Meyer wrote:

Seems unhelpful here, as the maximum length of "226:%d" is shorter
than the buffer.



It makes code-review easier.

--HPS

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


svn commit: r323703 - in head/sys/compat/linuxkpi/common: include/linux src

2017-09-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Sep 18 13:17:23 2017
New Revision: 323703
URL: https://svnweb.freebsd.org/changeset/base/323703

Log:
  Add support for shared memory functions to the LinuxKPI.
  
  Obtained from:kmacy @
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/fs.h
  head/sys/compat/linuxkpi/common/src/linux_page.c

Modified: head/sys/compat/linuxkpi/common/include/linux/fs.h
==
--- head/sys/compat/linuxkpi/common/include/linux/fs.h  Mon Sep 18 08:46:07 
2017(r323702)
+++ head/sys/compat/linuxkpi/common/include/linux/fs.h  Mon Sep 18 13:17:23 
2017(r323703)
@@ -2,7 +2,7 @@
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2017 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -287,5 +287,26 @@ noop_llseek(struct linux_file *file, loff_t offset, in
 
return (file->_file->f_offset);
 }
+
+/* Shared memory support */
+unsigned long linux_invalidate_mapping_pages(vm_object_t, pgoff_t, pgoff_t);
+struct page *linux_shmem_read_mapping_page_gfp(vm_object_t, int, gfp_t);
+struct linux_file *linux_shmem_file_setup(const char *, loff_t, unsigned long);
+void linux_shmem_truncate_range(vm_object_t, loff_t, loff_t);
+
+#defineinvalidate_mapping_pages(...) \
+  linux_invalidate_mapping_pages(__VA_ARGS__)
+
+#defineshmem_read_mapping_page(...) \
+  linux_shmem_read_mapping_page_gfp(__VA_ARGS__, 0)
+
+#defineshmem_read_mapping_page_gfp(...) \
+  linux_shmem_read_mapping_page_gfp(__VA_ARGS__)
+
+#defineshmem_file_setup(...) \
+  linux_shmem_file_setup(__VA_ARGS__)
+
+#defineshmem_truncate_range(...) \
+  linux_shmem_truncate_range(__VA_ARGS__)
 
 #endif /* _LINUX_FS_H_ */

Modified: head/sys/compat/linuxkpi/common/src/linux_page.c
==
--- head/sys/compat/linuxkpi/common/src/linux_page.cMon Sep 18 08:46:07 
2017(r323702)
+++ head/sys/compat/linuxkpi/common/src/linux_page.cMon Sep 18 13:17:23 
2017(r323703)
@@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #if defined(__amd64__) || defined(__aarch64__) || defined(__riscv)
 #defineLINUXKPI_HAVE_DMAP
@@ -288,4 +289,108 @@ int
 is_vmalloc_addr(const void *addr)
 {
return (vtoslab((vm_offset_t)addr & ~UMA_SLAB_MASK) != NULL);
+}
+
+struct page *
+linux_shmem_read_mapping_page_gfp(vm_object_t obj, int pindex, gfp_t gfp)
+{
+   vm_page_t page;
+   int rv;
+
+   if ((gfp & GFP_NOWAIT) != 0)
+   panic("GFP_NOWAIT is unimplemented");
+
+   VM_OBJECT_WLOCK(obj);
+   page = vm_page_grab(obj, pindex, VM_ALLOC_NORMAL | VM_ALLOC_NOBUSY |
+   VM_ALLOC_WIRED);
+   if (page->valid != VM_PAGE_BITS_ALL) {
+   vm_page_xbusy(page);
+   if (vm_pager_has_page(obj, pindex, NULL, NULL)) {
+   rv = vm_pager_get_pages(obj, , 1, NULL, NULL);
+   if (rv != VM_PAGER_OK) {
+   vm_page_lock(page);
+   vm_page_unwire(page, PQ_NONE);
+   vm_page_free(page);
+   vm_page_unlock(page);
+   VM_OBJECT_WUNLOCK(obj);
+   return (ERR_PTR(-EINVAL));
+   }
+   MPASS(page->valid == VM_PAGE_BITS_ALL);
+   } else {
+   pmap_zero_page(page);
+   page->valid = VM_PAGE_BITS_ALL;
+   page->dirty = 0;
+   }
+   vm_page_xunbusy(page);
+   }
+   vm_page_lock(page);
+   vm_page_hold(page);
+   vm_page_unlock(page);
+   VM_OBJECT_WUNLOCK(obj);
+   return (page);
+}
+
+struct linux_file *
+linux_shmem_file_setup(const char *name, loff_t size, unsigned long flags)
+{
+   struct fileobj {
+   struct linux_file file __aligned(sizeof(void *));
+   struct vnode vnode __aligned(sizeof(void *));
+   };
+   struct fileobj *fileobj;
+   struct linux_file *filp;
+   struct vnode *vp;
+   int error;
+
+   fileobj = kzalloc(sizeof(*fileobj), GFP_KERNEL);
+   if (fileobj == NULL) {
+   error = -ENOMEM;
+   goto err_0;
+   }
+   filp = >file;
+   vp = >vnode;
+
+   filp->f_count = 1;
+   filp->f_vnode = vp;
+   filp->f_shmem = vm_pager_allocate(OBJT_DEFAULT, NULL, size,
+   VM_PROT_READ | VM_PROT_WRITE, 0, curthread->td_ucred);
+   if (filp->f_shmem == NULL) {
+   error = 

Re: svn commit: r323692 - in head/sys/compat: linsysfs linux

2017-09-18 Thread Hans Petter Selasky

On 09/18/17 01:40, Conrad Meyer wrote:

device_get_children(dev, , );
for (i = 0; i < nchildren; i++) {
if (children[i])
-   linsysfs_run_bus(children[i], dir, scsi, new_path, 
prefix);
+   linsysfs_run_bus(children[i], dir, scsi, chardev, 
new_path, prefix);
}
if (new_path != path)
free(new_path, M_TEMP);
+   free(chardevname, M_TEMP);
  
  	return (1);


1) Return code from device_get_children() should be checked.

2) children pointer should be freed else there is a memory leak.

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


Re: svn commit: r323692 - in head/sys/compat: linsysfs linux

2017-09-18 Thread Conrad Meyer
Seems unhelpful here, as the maximum length of "226:%d" is shorter
than the buffer.

On Mon, Sep 18, 2017 at 3:38 AM, Hans Petter Selasky  wrote:
> On 09/18/17 01:40, Conrad Meyer wrote:
>>
>> +   sprintf(chardevname, "226:%d",
>> +   device_get_unit(dev));
>
>
> Hi,
>
> Try to use snprintf(). Define the chardevname size as a macro, or just
> allocate it on the stack if it is < 32 bytes.
>
> --HPS
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r323692 - in head/sys/compat: linsysfs linux

2017-09-18 Thread Hans Petter Selasky

On 09/18/17 01:40, Conrad Meyer wrote:

+
+   dinfo = device_get_ivars(parent);
+   if (dinfo != NULL && dinfo->cfg.baseclass == PCIC_DISPLAY) {
+   devclass = device_get_devclass(dev);
+   if (devclass != NULL)
+   name = devclass_get_name(devclass);
+   if (name != NULL && strcmp(name, DRMN_DEV) == 0 &&
+   device_get_unit(dev) >= 0) {
+   sprintf(chardevname, "226:%d",


Order of comparison should be switched.

First check devclass and name.

Then try to access ivars. Else the ivars might have an undefined type!

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


RE: svn commit: r323709 - head/usr.sbin/tcpdump/tcpdump

2017-09-18 Thread Cy Schubert
Thank you.

Sent using a tiny phone keyboard. Apologies for any typos.

Cy Schubert
 or 

-Original Message-
From: Gordon Tetlow
Sent: 18/09/2017 09:42
To: src-committ...@freebsd.org; svn-src-...@freebsd.org; 
svn-src-head@freebsd.org
Subject: svn commit: r323709 - head/usr.sbin/tcpdump/tcpdump

Author: gordon
Date: Mon Sep 18 16:42:13 2017
New Revision: 323709
URL: https://svnweb.freebsd.org/changeset/base/323709

Log:
  Revert tcpdump to using the source manpage instead of having a copy here.
  
  This helps future maintainability of tcpdump so we don't forget to update
  the manpage (like we have previously).
  
  Stolen from:  usr.bin/file/Makefile
  Reviewed by:  jilles
  Approved by:  delphij (mentor)
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D12403

Deleted:
  head/usr.sbin/tcpdump/tcpdump/tcpdump.1
Modified:
  head/usr.sbin/tcpdump/tcpdump/Makefile

Modified: head/usr.sbin/tcpdump/tcpdump/Makefile
==
--- head/usr.sbin/tcpdump/tcpdump/Makefile  Mon Sep 18 15:17:07 2017
(r323708)
+++ head/usr.sbin/tcpdump/tcpdump/Makefile  Mon Sep 18 16:42:13 2017
(r323709)
@@ -173,7 +173,7 @@ SRCS=   addrtoname.c \
tcpdump.c \
util-print.c \
version.c
-CLEANFILES+=   version.c
+CLEANFILES+=   version.c ${MAN}
 
 CFLAGS+= -I${.CURDIR} -I${TCPDUMP_DISTDIR}
 CFLAGS+= -DHAVE_CONFIG_H
@@ -210,3 +210,9 @@ version.c: ${TCPDUMP_DISTDIR}/VERSION
> version.c
 
 .include 
+
+.for mp in ${MAN}
+${mp}: ${mp}.in
+   sed -e 's/@MAN_MISC_INFO@/7/g' -e 's/@MAN_FILE_FORMATS@/5/g' \
+   ${.ALLSRC} > ${.TARGET}
+.endfor

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


Re: svn commit: r323692 - in head/sys/compat: linsysfs linux

2017-09-18 Thread Conrad Meyer
This was not introduced in this change.

On Mon, Sep 18, 2017 at 8:05 AM, Hans Petter Selasky  wrote:
> On 09/18/17 01:40, Conrad Meyer wrote:
>>
>> device_get_children(dev, , );
>> for (i = 0; i < nchildren; i++) {
>> if (children[i])
>> -   linsysfs_run_bus(children[i], dir, scsi, new_path,
>> prefix);
>> +   linsysfs_run_bus(children[i], dir, scsi, chardev,
>> new_path, prefix);
>> }
>> if (new_path != path)
>> free(new_path, M_TEMP);
>> +   free(chardevname, M_TEMP);
>> return (1);
>
>
> 1) Return code from device_get_children() should be checked.
>
> 2) children pointer should be freed else there is a memory leak.
>
> --HPS
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r323709 - head/usr.sbin/tcpdump/tcpdump

2017-09-18 Thread Gordon Tetlow
Author: gordon
Date: Mon Sep 18 16:42:13 2017
New Revision: 323709
URL: https://svnweb.freebsd.org/changeset/base/323709

Log:
  Revert tcpdump to using the source manpage instead of having a copy here.
  
  This helps future maintainability of tcpdump so we don't forget to update
  the manpage (like we have previously).
  
  Stolen from:  usr.bin/file/Makefile
  Reviewed by:  jilles
  Approved by:  delphij (mentor)
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D12403

Deleted:
  head/usr.sbin/tcpdump/tcpdump/tcpdump.1
Modified:
  head/usr.sbin/tcpdump/tcpdump/Makefile

Modified: head/usr.sbin/tcpdump/tcpdump/Makefile
==
--- head/usr.sbin/tcpdump/tcpdump/Makefile  Mon Sep 18 15:17:07 2017
(r323708)
+++ head/usr.sbin/tcpdump/tcpdump/Makefile  Mon Sep 18 16:42:13 2017
(r323709)
@@ -173,7 +173,7 @@ SRCS=   addrtoname.c \
tcpdump.c \
util-print.c \
version.c
-CLEANFILES+=   version.c
+CLEANFILES+=   version.c ${MAN}
 
 CFLAGS+= -I${.CURDIR} -I${TCPDUMP_DISTDIR}
 CFLAGS+= -DHAVE_CONFIG_H
@@ -210,3 +210,9 @@ version.c: ${TCPDUMP_DISTDIR}/VERSION
> version.c
 
 .include 
+
+.for mp in ${MAN}
+${mp}: ${mp}.in
+   sed -e 's/@MAN_MISC_INFO@/7/g' -e 's/@MAN_FILE_FORMATS@/5/g' \
+   ${.ALLSRC} > ${.TARGET}
+.endfor
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r323707 - head/sys/boot/i386/libi386

2017-09-18 Thread Toomas Soome
Author: tsoome
Date: Mon Sep 18 15:17:01 2017
New Revision: 323707
URL: https://svnweb.freebsd.org/changeset/base/323707

Log:
  loader: biosmem allocate heap just below 4GB
  
  The current biosmem code is walking bios smap entries and looking for smap
  entry just below 4GB line, if there is such entry, its base and size is set
  for heap base and size. Instead of entry base, we should use last HEAP_MIN
  (currently 64MB) bytes just below 4GB, to make maximum space for kernel and
  modules.
  
  The problem was revealed on ASUS B350M-A system board, an AMD Ryzen 3 1200 CPU
  
  memory map:
  
  SMAP type=01 base= len=0009d400 attr=01
  SMAP type=02 base=0009d400 len=2c00 attr=01
  SMAP type=02 base=000e len=0002 attr=01
  SMAP type=01 base=0010 len=09c0 attr=01
  SMAP type=02 base=09d0 len=0030 attr=01
  SMAP type=01 base=0a00 len=be69b000 attr=01
  SMAP type=03 base=c869b000 len=00016000 attr=01
  SMAP type=01 base=c86b1000 len=124e7000 attr=01
  SMAP type=02 base=dab98000 len=00138000 attr=01
  SMAP type=03 base=dacd len=8000 attr=01
  SMAP type=01 base=dacd8000 len=0010 attr=01
  SMAP type=04 base=dadd8000 len=003b3000 attr=01
  SMAP type=02 base=db18b000 len=00d42000 attr=01
  SMAP type=01 base=dbecd000 len=02133000 attr=01
  SMAP type=01 base=0001 len=00011f38 attr=01
  SMAP type=02 base=de00 len=0200 attr=01
  SMAP type=02 base=f800 len=0400 attr=01
  SMAP type=02 base=fdf0 len=0010 attr=01
  SMAP type=02 base=fea0 len=0001 attr=01
  SMAP type=02 base=feb8 len=00082000 attr=01
  SMAP type=02 base=fec1 len=1000 attr=01
  SMAP type=02 base=fec3 len=1000 attr=01
  SMAP type=02 base=fed0 len=1000 attr=01
  SMAP type=02 base=fed4 len=5000 attr=01
  SMAP type=02 base=fed8 len=0001 attr=01
  SMAP type=02 base=fedc2000 len=e000 attr=01
  SMAP type=02 base=fedd4000 len=2000 attr=01
  SMAP type=02 base=fee0 len=0010 attr=01
  SMAP type=02 base=ff00 len=0100 attr=01
  
  Reviewed by:  imp
  Differential Revision:https://reviews.freebsd.org/D12368

Modified:
  head/sys/boot/i386/libi386/biosmem.c

Modified: head/sys/boot/i386/libi386/biosmem.c
==
--- head/sys/boot/i386/libi386/biosmem.cMon Sep 18 13:39:51 2017
(r323706)
+++ head/sys/boot/i386/libi386/biosmem.cMon Sep 18 15:17:01 2017
(r323707)
@@ -125,7 +125,7 @@ bios_getmem(void)
}
 
/*
-* Look for the largest segment in 'extended' memory beyond
+* Look for the highest segment in 'extended' memory beyond
 * 1MB but below 4GB.
 */
if ((smap.type == SMAP_TYPE_MEMORY) &&
@@ -140,9 +140,13 @@ bios_getmem(void)
if (smap.base + size > 0x1ull)
size = 0x1ull - smap.base;
 
-   if (size > high_heap_size) {
-   high_heap_size = size;
-   high_heap_base = smap.base;
+   /*
+* To make maximum space for the kernel and the modules,
+* set heap to use highest HEAP_MIN bytes below 4GB.
+*/
+   if (high_heap_base < smap.base && size >= HEAP_MIN) {
+   high_heap_base = smap.base + size - HEAP_MIN;
+   high_heap_size = HEAP_MIN;
}
}
} while (v86.ebx != 0);
@@ -203,7 +207,11 @@ bios_getmem(void)
}
 
/* Set memtop to actual top of memory */
-   memtop = memtop_copyin = 0x10 + bios_extmem;
+   if (high_heap_size != 0) {
+   memtop = memtop_copyin = high_heap_base;
+   } else {
+   memtop = memtop_copyin = 0x10 + bios_extmem;
+   }
 
/*
 * If we have extended memory and did not find a suitable heap
@@ -213,6 +221,7 @@ bios_getmem(void)
if (bios_extmem >= HEAP_MIN && high_heap_size < HEAP_MIN) {
high_heap_size = HEAP_MIN;
high_heap_base = memtop - HEAP_MIN;
+   memtop = memtop_copyin = high_heap_base;
}
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To 

svn commit: r323706 - head/sys/sys

2017-09-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Sep 18 13:39:51 2017
New Revision: 323706
URL: https://svnweb.freebsd.org/changeset/base/323706

Log:
  Bump the __FreeBSD_version after recent LinuxKPI changes.
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/sys/param.h

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hMon Sep 18 13:37:14 2017(r323705)
+++ head/sys/sys/param.hMon Sep 18 13:39:51 2017(r323706)
@@ -58,7 +58,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1200044  /* Master, propagated to newvers */
+#define __FreeBSD_version 1200045  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r323705 - in head/sys/compat/linuxkpi/common: include/asm include/linux src

2017-09-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Sep 18 13:37:14 2017
New Revision: 323705
URL: https://svnweb.freebsd.org/changeset/base/323705

Log:
  The LinuxKPI atomics do not have acquire nor release semantics unless
  specified. Fix code to use READ_ONCE() and WRITE_ONCE() where appropriate.
  
  Suggested by: kib @
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/asm/atomic-long.h
  head/sys/compat/linuxkpi/common/include/asm/atomic.h
  head/sys/compat/linuxkpi/common/include/asm/atomic64.h
  head/sys/compat/linuxkpi/common/include/linux/bitops.h
  head/sys/compat/linuxkpi/common/src/linux_tasklet.c

Modified: head/sys/compat/linuxkpi/common/include/asm/atomic-long.h
==
--- head/sys/compat/linuxkpi/common/include/asm/atomic-long.h   Mon Sep 18 
13:23:59 2017(r323704)
+++ head/sys/compat/linuxkpi/common/include/asm/atomic-long.h   Mon Sep 18 
13:37:14 2017(r323705)
@@ -2,7 +2,7 @@
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2017 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,7 @@
 #ifndef_ATOMIC_LONG_H_
 #define_ATOMIC_LONG_H_
 
-#include 
+#include 
 #include 
 #include 
 
@@ -54,13 +54,13 @@ atomic_long_add_return(long i, atomic_long_t *v)
 static inline void
 atomic_long_set(atomic_long_t *v, long i)
 {
-   atomic_store_rel_long(>counter, i);
+   WRITE_ONCE(v->counter, i);
 }
 
 static inline long
 atomic_long_read(atomic_long_t *v)
 {
-   return atomic_load_acq_long(>counter);
+   return READ_ONCE(v->counter);
 }
 
 static inline long

Modified: head/sys/compat/linuxkpi/common/include/asm/atomic.h
==
--- head/sys/compat/linuxkpi/common/include/asm/atomic.hMon Sep 18 
13:23:59 2017(r323704)
+++ head/sys/compat/linuxkpi/common/include/asm/atomic.hMon Sep 18 
13:37:14 2017(r323705)
@@ -2,7 +2,7 @@
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2017 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -32,9 +32,8 @@
 #ifndef _ASM_ATOMIC_H_
 #define_ASM_ATOMIC_H_
 
-#include 
+#include 
 #include 
-
 #include 
 
 #defineATOMIC_INIT(x)  { .counter = (x) }
@@ -73,7 +72,7 @@ atomic_sub_return(int i, atomic_t *v)
 static inline void
 atomic_set(atomic_t *v, int i)
 {
-   atomic_store_rel_int(>counter, i);
+   WRITE_ONCE(v->counter, i);
 }
 
 static inline void
@@ -91,7 +90,7 @@ atomic_set_mask(unsigned int mask, atomic_t *v)
 static inline int
 atomic_read(const atomic_t *v)
 {
-   return atomic_load_acq_int(&__DECONST(atomic_t *, v)->counter);
+   return READ_ONCE(v->counter);
 }
 
 static inline int
@@ -137,7 +136,7 @@ atomic_xchg(atomic_t *v, int i)
 #else
int ret;
for (;;) {
-   ret = atomic_load_acq_int(>counter);
+   ret = READ_ONCE(v->counter);
if (atomic_cmpset_int(>counter, ret, i))
break;
}
@@ -153,7 +152,7 @@ atomic_cmpxchg(atomic_t *v, int old, int new)
for (;;) {
if (atomic_cmpset_int(>counter, old, new))
break;
-   ret = atomic_load_acq_int(>counter);
+   ret = READ_ONCE(v->counter);
if (ret != old)
break;
}

Modified: head/sys/compat/linuxkpi/common/include/asm/atomic64.h
==
--- head/sys/compat/linuxkpi/common/include/asm/atomic64.h  Mon Sep 18 
13:23:59 2017(r323704)
+++ head/sys/compat/linuxkpi/common/include/asm/atomic64.h  Mon Sep 18 
13:37:14 2017(r323705)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2016 Mellanox Technologies, Ltd.
+ * Copyright (c) 2016-2017 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,7 @@
 #ifndef_ASM_ATOMIC64_H_
 #define_ASM_ATOMIC64_H_
 
-#include 
+#include 
 #include 
 #include 
 
@@ -74,7 +74,7 @@ atomic64_set(atomic64_t *v, int64_t i)
 static inline int64_t
 atomic64_read(atomic64_t *v)
 {
-   return atomic_load_acq_64(>counter);
+   return READ_ONCE(v->counter);
 }
 
 static inline int64_t
@@ -114,7 +114,7 @@ atomic64_xchg(atomic64_t *v, int64_t i)
 #else
int64_t ret;
for (;;) {
-   ret = atomic_load_acq_64(>counter);

svn commit: r323704 - in head/sys/compat/linuxkpi/common: include/linux src

2017-09-18 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Sep 18 13:23:59 2017
New Revision: 323704
URL: https://svnweb.freebsd.org/changeset/base/323704

Log:
  Only wire pages in the LinuxKPI instead of holding and wiring them.
  This prevents the page daemon from regularly scanning the held pages.
  
  Suggested by: kib @
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/mm.h
  head/sys/compat/linuxkpi/common/src/linux_page.c

Modified: head/sys/compat/linuxkpi/common/include/linux/mm.h
==
--- head/sys/compat/linuxkpi/common/include/linux/mm.h  Mon Sep 18 13:17:23 
2017(r323703)
+++ head/sys/compat/linuxkpi/common/include/linux/mm.h  Mon Sep 18 13:23:59 
2017(r323704)
@@ -220,7 +220,6 @@ static inline void
 get_page(struct vm_page *page)
 {
vm_page_lock(page);
-   vm_page_hold(page);
vm_page_wire(page);
vm_page_unlock(page);
 }
@@ -245,7 +244,6 @@ put_page(struct vm_page *page)
 {
vm_page_lock(page);
vm_page_unwire(page, PQ_ACTIVE);
-   vm_page_unhold(page);
vm_page_unlock(page);
 }
 

Modified: head/sys/compat/linuxkpi/common/src/linux_page.c
==
--- head/sys/compat/linuxkpi/common/src/linux_page.cMon Sep 18 13:17:23 
2017(r323703)
+++ head/sys/compat/linuxkpi/common/src/linux_page.cMon Sep 18 13:23:59 
2017(r323704)
@@ -209,6 +209,7 @@ linux_get_user_pages_internal(vm_map_t map, unsigned l
 
vm_page_lock(pg);
vm_page_wire(pg);
+   vm_page_unhold(pg);
vm_page_unlock(pg);
}
return (nr_pages);
@@ -243,6 +244,7 @@ __get_user_pages_fast(unsigned long start, int nr_page
 
vm_page_lock(*mp);
vm_page_wire(*mp);
+   vm_page_unhold(*mp);
vm_page_unlock(*mp);
 
if ((prot & VM_PROT_WRITE) != 0 &&
@@ -323,9 +325,6 @@ linux_shmem_read_mapping_page_gfp(vm_object_t obj, int
}
vm_page_xunbusy(page);
}
-   vm_page_lock(page);
-   vm_page_hold(page);
-   vm_page_unlock(page);
VM_OBJECT_WUNLOCK(obj);
return (page);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r323692 - in head/sys/compat: linsysfs linux

2017-09-18 Thread Ryan Libby
On Sun, Sep 17, 2017 at 4:40 PM, Conrad Meyer  wrote:
> Author: cem
> Date: Sun Sep 17 23:40:16 2017
> New Revision: 323692
> URL: https://svnweb.freebsd.org/changeset/base/323692
>
> Log:
>   linsysfs(5): Add support for recent libdrm
>
>   Expose more information about PCI devices (and GPUs in particular) via
>   linsysfs to libdrm.
>
>   This allows unmodified modern 64-bit Linux libdrm to work, which allows
>   modern Linux Mesa to work.  The submitter reports that he tested the change
>   with an Ubuntu 16.04 chroot + amdgpu from graphics/drm-next-kmod.
>
>   PR:   222375
>   Submitted by: Greg V 
>
> Modified:
>   head/sys/compat/linsysfs/linsysfs.c
>   head/sys/compat/linux/linux_util.c
>
> Modified: head/sys/compat/linsysfs/linsysfs.c
> ==
> --- head/sys/compat/linsysfs/linsysfs.c Sun Sep 17 22:58:13 2017
> (r323691)
> +++ head/sys/compat/linsysfs/linsysfs.c Sun Sep 17 23:40:16 2017
> (r323692)
> @@ -133,20 +133,135 @@ linsysfs_link_scsi_host(PFS_FILL_ARGS)
> return (0);
>  }
>
> +static int
> +linsysfs_fill_data(PFS_FILL_ARGS)
> +{
> +   sbuf_printf(sb, "%s", pn->pn_data);
> +   return (0);
> +}

This broke the gcc build with -Wformat [1]:

/workspace/src/sys/compat/linsysfs/linsysfs.c: In function 'linsysfs_fill_data':
/workspace/src/sys/compat/linsysfs/linsysfs.c:139:20: error: format
'%s' expects argument of type 'char *', but argument 3 has type 'void
*' [-Werror=format=]
  sbuf_printf(sb, "%s", pn->pn_data);

It builds if a char * cast is added.  Is that the right fix?

[1] https://ci.freebsd.org/job/FreeBSD-head-amd64-gcc/2532/
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r323715 - head/sys/contrib/ipfilter/netinet

2017-09-18 Thread Cy Schubert
Author: cy
Date: Mon Sep 18 19:16:41 2017
New Revision: 323715
URL: https://svnweb.freebsd.org/changeset/base/323715

Log:
  Don't use an apostrophe in a possesive pronoun.
  
  MFC after:3 days

Modified:
  head/sys/contrib/ipfilter/netinet/ip_state.c

Modified: head/sys/contrib/ipfilter/netinet/ip_state.c
==
--- head/sys/contrib/ipfilter/netinet/ip_state.cMon Sep 18 19:09:40 
2017(r323714)
+++ head/sys/contrib/ipfilter/netinet/ip_state.cMon Sep 18 19:16:41 
2017(r323715)
@@ -1449,7 +1449,7 @@ ipf_state_add(softc, fin, stsave, flags)
is->is_die = 1 + softc->ipf_ticks;
/*
 * We want to check everything that is a property of this packet,
-* but we don't (automatically) care about it's fragment status as
+* but we don't (automatically) care about its fragment status as
 * this may change.
 */
is->is_pass = pass;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r323714 - head/sys/compat/linsysfs

2017-09-18 Thread Ryan Libby
Author: rlibby
Date: Mon Sep 18 19:09:40 2017
New Revision: 323714
URL: https://svnweb.freebsd.org/changeset/base/323714

Log:
  linsysfs: quiet gcc -Wformat after r323692
  
  Reviewed by:  cem
  Sponsored by: Dell EMC Isilon

Modified:
  head/sys/compat/linsysfs/linsysfs.c

Modified: head/sys/compat/linsysfs/linsysfs.c
==
--- head/sys/compat/linsysfs/linsysfs.c Mon Sep 18 18:44:45 2017
(r323713)
+++ head/sys/compat/linsysfs/linsysfs.c Mon Sep 18 19:09:40 2017
(r323714)
@@ -136,7 +136,7 @@ linsysfs_link_scsi_host(PFS_FILL_ARGS)
 static int
 linsysfs_fill_data(PFS_FILL_ARGS)
 {
-   sbuf_printf(sb, "%s", pn->pn_data);
+   sbuf_printf(sb, "%s", (char *)pn->pn_data);
return (0);
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r323710 - head/sys/compat/linsysfs

2017-09-18 Thread Conrad Meyer
Author: cem
Date: Mon Sep 18 17:14:13 2017
New Revision: 323710
URL: https://svnweb.freebsd.org/changeset/base/323710

Log:
  linsysfs(5): Fix two unrelated issues
  
  1. Swap the order of device_get_ivars with device_get_devclass and devclass
 name validation.  This bug was introduced in r323692.
  
  2. Error check device_get_children and free the returned list.  This bug was
 introduced in the original linsysfs commit.
  
  Reported by:  Oleg V. Nauman , hselasky (1); hselasky 
(2)
  Reviewed by:  hselasky
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D12407

Modified:
  head/sys/compat/linsysfs/linsysfs.c

Modified: head/sys/compat/linsysfs/linsysfs.c
==
--- head/sys/compat/linsysfs/linsysfs.c Mon Sep 18 16:42:13 2017
(r323709)
+++ head/sys/compat/linsysfs/linsysfs.c Mon Sep 18 17:14:13 2017
(r323710)
@@ -252,7 +252,7 @@ linsysfs_run_bus(device_t dev, struct pfs_node *dir, s
 {
struct scsi_host_queue *scsi_host;
struct pfs_node *sub_dir, *cur_file, *cur_chardev;
-   int i, nchildren;
+   int i, nchildren, error;
device_t *children, parent;
devclass_t devclass;
const char *name = NULL;
@@ -353,13 +353,15 @@ linsysfs_run_bus(device_t dev, struct pfs_node *dir, s
}
}
 
-   dinfo = device_get_ivars(parent);
-   if (dinfo != NULL && dinfo->cfg.baseclass == PCIC_DISPLAY) {
-   devclass = device_get_devclass(dev);
-   if (devclass != NULL)
-   name = devclass_get_name(devclass);
-   if (name != NULL && strcmp(name, DRMN_DEV) == 0 &&
-   device_get_unit(dev) >= 0) {
+   devclass = device_get_devclass(dev);
+   if (devclass != NULL)
+   name = devclass_get_name(devclass);
+   else
+   name = NULL;
+   if (name != NULL && strcmp(name, DRMN_DEV) == 0 &&
+   device_get_unit(dev) >= 0) {
+   dinfo = device_get_ivars(parent);
+   if (dinfo != NULL && dinfo->cfg.baseclass == 
PCIC_DISPLAY) {
sprintf(chardevname, "226:%d",
device_get_unit(dev));
cur_chardev = pfs_create_dir(chardev,
@@ -376,10 +378,13 @@ linsysfs_run_bus(device_t dev, struct pfs_node *dir, s
}
}
 
-   device_get_children(dev, , );
-   for (i = 0; i < nchildren; i++) {
-   if (children[i])
-   linsysfs_run_bus(children[i], dir, scsi, chardev, 
new_path, prefix);
+   error = device_get_children(dev, , );
+   if (error == 0) {
+   for (i = 0; i < nchildren; i++)
+   if (children[i])
+   linsysfs_run_bus(children[i], dir, scsi,
+   chardev, new_path, prefix);
+   free(children, M_TEMP);
}
if (new_path != path)
free(new_path, M_TEMP);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r323712 - head/sys/dev/ppc

2017-09-18 Thread Scott Long
Author: scottl
Date: Mon Sep 18 18:42:28 2017
New Revision: 323712
URL: https://svnweb.freebsd.org/changeset/base/323712

Log:
  Hide a normal probe warning message under bootverbose, similar to atkbdc
  
  Sponsored by: Netflix

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

Modified: head/sys/dev/ppc/ppc.c
==
--- head/sys/dev/ppc/ppc.c  Mon Sep 18 17:26:47 2017(r323711)
+++ head/sys/dev/ppc/ppc.c  Mon Sep 18 18:42:28 2017(r323712)
@@ -1720,7 +1720,8 @@ ppc_probe(device_t dev, int rid)
if (bootverbose)
device_printf(dev, "using normal I/O port 
range\n");
} else {
-   device_printf(dev, "cannot reserve I/O port range\n");
+   if (bootverbose)
+   device_printf(dev, "cannot reserve I/O port 
range\n");
goto error;
}
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r323721 - head/sys/cam/mmc

2017-09-18 Thread Ilya Bakulin
Author: kibab
Date: Mon Sep 18 20:17:08 2017
New Revision: 323721
URL: https://svnweb.freebsd.org/changeset/base/323721

Log:
  Add kern.features flag for MMCCAM
  
  kern.features.mmcam will be present and equal to 1 if the kernel has been
  compiled with option MMCCAM.
  This will help sdio-related userland tools to fail-fast if running on the 
kernel
  without MMCCAM enabled.
  
  Approved by:  imp (mentor)
  Differential Revision:https://reviews.freebsd.org/D12386

Modified:
  head/sys/cam/mmc/mmc_xpt.c

Modified: head/sys/cam/mmc/mmc_xpt.c
==
--- head/sys/cam/mmc/mmc_xpt.c  Mon Sep 18 20:09:17 2017(r323720)
+++ head/sys/cam/mmc/mmc_xpt.c  Mon Sep 18 20:17:08 2017(r323721)
@@ -63,6 +63,8 @@ __FBSDID("$FreeBSD$");
 #include   /* for PRIu64 */
 #include "opt_cam.h"
 
+FEATURE(mmccam, "CAM-based MMC/SD/SDIO stack");
+
 static struct cam_ed * mmc_alloc_device(struct cam_eb *bus,
 struct cam_et *target, lun_id_t lun_id);
 static void mmc_dev_async(u_int32_t async_code, struct cam_eb *bus,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r323715 - head/sys/contrib/ipfilter/netinet

2017-09-18 Thread Ian Lepore
On Mon, 2017-09-18 at 19:16 +, Cy Schubert wrote:
> Author: cy
> Date: Mon Sep 18 19:16:41 2017
> New Revision: 323715
> URL: https://svnweb.freebsd.org/changeset/base/323715
> 
> Log:
>   Don't use an apostrophe in a possesive pronoun.
>   

And that really is the way to remember it for those who struggle:
yours, theirs, his, hers, its... none of the possesive pronouns that
end in s use an apostrophe.

-- Ian (only mildly obsessed with apostrophe abuse)

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


svn commit: r323717 - head/usr.bin/sdiotool

2017-09-18 Thread Ilya Bakulin
Author: kibab
Date: Mon Sep 18 20:01:01 2017
New Revision: 323717
URL: https://svnweb.freebsd.org/changeset/base/323717

Log:
  Make basic Broadcom I/O space reading functions work
  
  It's now possible to use Broadcom functions to read the I/O registers of
  SDIO card. The functions were copied from the BSD-licensed Broadcom Linux 
driver
  as-is. To make it possible, a small Linux compatibility layer was introduced.
  
  Currently the card responds with the correct version number ("magic")
  when reading the corresponding address.
  
  Approved by:  imp (mentor)
  Differential Revision:https://reviews.freebsd.org/D12111

Added:
  head/usr.bin/sdiotool/brcmfmac_bus.h   (contents, props changed)
  head/usr.bin/sdiotool/brcmfmac_sdio.h   (contents, props changed)
  head/usr.bin/sdiotool/cam_sdio.c   (contents, props changed)
  head/usr.bin/sdiotool/cam_sdio.h   (contents, props changed)
  head/usr.bin/sdiotool/linux_compat.h   (contents, props changed)
  head/usr.bin/sdiotool/linux_sdio_compat.c   (contents, props changed)
  head/usr.bin/sdiotool/linux_sdio_compat.h   (contents, props changed)
Modified:
  head/usr.bin/sdiotool/Makefile
  head/usr.bin/sdiotool/sdiotool.c

Modified: head/usr.bin/sdiotool/Makefile
==
--- head/usr.bin/sdiotool/Makefile  Mon Sep 18 19:56:05 2017
(r323716)
+++ head/usr.bin/sdiotool/Makefile  Mon Sep 18 20:01:01 2017
(r323717)
@@ -1,7 +1,7 @@
 # $FreeBSD$
 
 PROG=  sdiotool
-SRCS=  sdiotool.c
+SRCS=  sdiotool.c cam_sdio.c linux_sdio_compat.c
 
 LIBADD= cam util
 MAN=

Added: head/usr.bin/sdiotool/brcmfmac_bus.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.bin/sdiotool/brcmfmac_bus.hMon Sep 18 20:01:01 2017
(r323717)
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2010 Broadcom Corporation
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * $FreeBSD$
+ */
+/* The level of bus communication with the dongle */
+enum brcmf_bus_state {
+   BRCMF_BUS_DOWN, /* Not ready for frame transfers */
+   BRCMF_BUS_UP/* Ready for frame transfers */
+};
+
+struct brcmf_bus {
+   enum brcmf_bus_state state;
+};

Added: head/usr.bin/sdiotool/brcmfmac_sdio.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.bin/sdiotool/brcmfmac_sdio.h   Mon Sep 18 20:01:01 2017
(r323717)
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2010 Broadcom Corporation
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * $FreeBSD$
+ */
+#define SDIO_FUNC_00
+#define SDIO_FUNC_11
+#define SDIO_FUNC_22
+
+#define SDIOD_FBR_SIZE 0x100
+
+/* io_en */
+#define SDIO_FUNC_ENABLE_1 0x02
+#define SDIO_FUNC_ENABLE_2 0x04
+
+/* io_rdys */
+#define SDIO_FUNC_READY_1  0x02
+#define SDIO_FUNC_READY_2  0x04
+
+/* intr_status */
+#define INTR_STATUS_FUNC1  0x2
+#define INTR_STATUS_FUNC2  0x4
+
+/* Maximum number of I/O funcs */
+#define SDIOD_MAX_IOFUNCS  7
+
+/* mask of register map */
+#define REG_F0_REG_MASK0x7FF
+#define REG_F1_MISC_MASK   0x1
+
+/* as of sdiod rev 0, supports 3 functions */
+#define SBSDIO_NUM_FUNCTION3
+
+/* function 0 vendor specific CCCR registers */
+#define SDIO_CCCR_BRCM_CARDCAP 0xf0
+#define SDIO_CCCR_BRCM_CARDCAP_CMD14_SUPPORT   0x02
+#define 

svn commit: r323722 - in head/sys: i386/i386 i386/include i386/isa kern

2017-09-18 Thread Konstantin Belousov
Author: kib
Date: Mon Sep 18 20:22:42 2017
New Revision: 323722
URL: https://svnweb.freebsd.org/changeset/base/323722

Log:
  Fix handling of the segment registers on i386.
  
  Suppose that userspace is executing with the non-standard segment
  descriptors.  Then, until exception or interrupt handler executed
  SET_KERNEL_SEGS, kernel is still executing with user %ds, %es and %fs.
  If an interrupt occurs in this window, the interrupt handler is
  executed unsafely, relying on usability of the usermode registers.  If
  the interrupt results in the context switch on return, the
  contamination of the kernel state spreads to the thread we switched
  to.  As result, kernel data accesses might fault or, if only the base
  is changed, completely messed up.
  
  More, if the user segment was allocated in LDT, another thread might
  mark the descriptor as invalid before doreti code tried to reload
  them.  In this case kernel panics.
  
  The issue exists for all exception entry points which use trap gate,
  and thus do not automatically disable interrupts on entry, and for
  lcall_handler.
  
  Fix is two-fold: first, we need to disable interrupts for all kernel
  entries, changing the IDT descriptor types from trap gate to interrupt
  gate.  Interrupts are re-enabled not earlier than the kernel segments
  are loaded into the segment registers.  Second, we only load the
  segment registers from the trap frame when returning to usermode.  For
  the later, all interrupt return paths must happen through the doreti
  common code.
  
  There is no way to disable interrupts on call gate, which is the
  supposed mode of servicing for lcall $7,$0 syscalls.  Change the LDT
  descriptor 0 into a code segment type and point it to the userspace
  trampoline which redirects the syscall to int $0x80.
  
  All the measures make the segment register handling similar to that of
  amd64.  We do not apply amd64 optimizations of not reloading segment
  registers on return from the syscall.
  
  Reported by:  Maxime Villard 
  Tested by:pho (the non-lcall part)
  Reviewed by:  jhb
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks
  Differential revision:https://reviews.freebsd.org/D12402

Modified:
  head/sys/i386/i386/apic_vector.s
  head/sys/i386/i386/db_trace.c
  head/sys/i386/i386/exception.s
  head/sys/i386/i386/locore.s
  head/sys/i386/i386/machdep.c
  head/sys/i386/i386/trap.c
  head/sys/i386/include/md_var.h
  head/sys/i386/isa/npx.c
  head/sys/kern/imgact_aout.c

Modified: head/sys/i386/i386/apic_vector.s
==
--- head/sys/i386/i386/apic_vector.sMon Sep 18 20:17:08 2017
(r323721)
+++ head/sys/i386/i386/apic_vector.sMon Sep 18 20:22:42 2017
(r323722)
@@ -189,8 +189,7 @@ IDTVEC(xen_intr_upcall)
SUPERALIGN_TEXT
 invltlb_ret:
callas_lapic_eoi
-   POP_FRAME
-   iret
+   jmp doreti
 
SUPERALIGN_TEXT
 IDTVEC(invltlb)
@@ -274,10 +273,8 @@ IDTVEC(cpustop)
 
callas_lapic_eoi
callcpustop_handler
+   jmp doreti
 
-   POP_FRAME
-   iret
-
 /*
  * Executed by a CPU when it receives an IPI_SUSPEND from another CPU.
  */
@@ -290,10 +287,8 @@ IDTVEC(cpususpend)
 
callas_lapic_eoi
callcpususpend_handler
+   jmp doreti
 
-   POP_FRAME
-   jmp doreti_iret
-
 /*
  * Executed by a CPU when it receives a RENDEZVOUS IPI from another CPU.
  *
@@ -314,7 +309,6 @@ IDTVEC(rendezvous)
callsmp_rendezvous_action
 
callas_lapic_eoi
-   POP_FRAME
-   iret
+   jmp doreti

 #endif /* SMP */

Modified: head/sys/i386/i386/db_trace.c
==
--- head/sys/i386/i386/db_trace.c   Mon Sep 18 20:17:08 2017
(r323721)
+++ head/sys/i386/i386/db_trace.c   Mon Sep 18 20:22:42 2017
(r323722)
@@ -326,8 +326,7 @@ db_nextframe(struct i386_frame **fp, db_addr_t *ip, st
else if (strncmp(name, "Xatpic_intr", 11) == 0 ||
strncmp(name, "Xapic_isr", 9) == 0)
frame_type = INTERRUPT;
-   else if (strcmp(name, "Xlcall_syscall") == 0 ||
-   strcmp(name, "Xint0x80_syscall") == 0)
+   else if (strcmp(name, "Xint0x80_syscall") == 0)
frame_type = SYSCALL;
else if (strcmp(name, "dblfault_handler") == 0)
frame_type = DOUBLE_FAULT;

Modified: head/sys/i386/i386/exception.s
==
--- head/sys/i386/i386/exception.s  Mon Sep 18 20:17:08 2017
(r323721)
+++ head/sys/i386/i386/exception.s  Mon Sep 18 20:22:42 2017
(r323722)
@@ -98,15 +98,16 @@ MCOUNT_LABEL(user)
 MCOUNT_LABEL(btrap)
 
 #defineTRAP(a) pushl $(a) ; jmp 

svn commit: r323723 - in head/sys/ufs: ffs ufs

2017-09-18 Thread John Baldwin
Author: jhb
Date: Mon Sep 18 23:30:39 2017
New Revision: 323723
URL: https://svnweb.freebsd.org/changeset/base/323723

Log:
  Add UFS_LINK_MAX for the UFS-specific limit on link counts.
  
  ino64 expanded nlink_t to 64 bits, but the on-disk format for UFS is still
  limited to 16 bits.  This is a nop currently but will matter if LINK_MAX is
  increased in the future.
  
  Reviewed by:  kib
  Sponsored by: Chelsio Communications

Modified:
  head/sys/ufs/ffs/ffs_softdep.c
  head/sys/ufs/ufs/dinode.h
  head/sys/ufs/ufs/ufs_vnops.c

Modified: head/sys/ufs/ffs/ffs_softdep.c
==
--- head/sys/ufs/ffs/ffs_softdep.c  Mon Sep 18 20:22:42 2017
(r323722)
+++ head/sys/ufs/ffs/ffs_softdep.c  Mon Sep 18 23:30:39 2017
(r323723)
@@ -11532,7 +11532,7 @@ handle_written_inodeblock(inodedep, bp, flags)
 */
if (inodedep->id_savedsize == -1 || inodedep->id_savedextsize == -1)
panic("handle_written_inodeblock: bad size");
-   if (inodedep->id_savednlink > LINK_MAX)
+   if (inodedep->id_savednlink > UFS_LINK_MAX)
panic("handle_written_inodeblock: Invalid link count "
"%jd for inodedep %p", (uintmax_t)inodedep->id_savednlink,
inodedep);

Modified: head/sys/ufs/ufs/dinode.h
==
--- head/sys/ufs/ufs/dinode.h   Mon Sep 18 20:22:42 2017(r323722)
+++ head/sys/ufs/ufs/dinode.h   Mon Sep 18 23:30:39 2017(r323723)
@@ -186,4 +186,6 @@ struct ufs1_dinode {
u_int64_t   di_modrev;  /* 120: i_modrev for NFSv4 */
 };
 
+#defineUFS_LINK_MAX32767
+
 #endif /* _UFS_UFS_DINODE_H_ */

Modified: head/sys/ufs/ufs/ufs_vnops.c
==
--- head/sys/ufs/ufs/ufs_vnops.cMon Sep 18 20:22:42 2017
(r323722)
+++ head/sys/ufs/ufs/ufs_vnops.cMon Sep 18 23:30:39 2017
(r323723)
@@ -981,7 +981,7 @@ ufs_link(ap)
goto out;
}
ip = VTOI(vp);
-   if ((nlink_t)ip->i_nlink >= LINK_MAX) {
+   if (ip->i_nlink >= UFS_LINK_MAX) {
error = EMLINK;
goto out;
}
@@ -1266,7 +1266,7 @@ relock:
doingdirectory = 0;
newparent = 0;
ino = fip->i_number;
-   if (fip->i_nlink >= LINK_MAX) {
+   if (fip->i_nlink >= UFS_LINK_MAX) {
error = EMLINK;
goto unlockout;
}
@@ -1369,7 +1369,7 @@ relock:
 * actual link modification is completed when
 * .. is rewritten below.
 */
-   if ((nlink_t)tdp->i_nlink >= LINK_MAX) {
+   if (tdp->i_nlink >= UFS_LINK_MAX) {
error = EMLINK;
goto bad;
}
@@ -1793,7 +1793,7 @@ ufs_mkdir(ap)
panic("ufs_mkdir: no name");
 #endif
dp = VTOI(dvp);
-   if ((nlink_t)dp->i_nlink >= LINK_MAX) {
+   if (dp->i_nlink >= UFS_LINK_MAX) {
error = EMLINK;
goto out;
}
@@ -2442,6 +2442,9 @@ ufs_pathconf(ap)
 
error = 0;
switch (ap->a_name) {
+   case _PC_LINK_MAX:
+   *ap->a_retval = UFS_LINK_MAX;
+   break;
case _PC_NAME_MAX:
*ap->a_retval = UFS_MAXNAMLEN;
break;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r323724 - in head/sys/dev/cxgbe: . firmware

2017-09-18 Thread John Baldwin
Author: jhb
Date: Mon Sep 18 23:50:34 2017
New Revision: 323724
URL: https://svnweb.freebsd.org/changeset/base/323724

Log:
  Enable support for lookaside crypto operations by default.
  
  This permits ccr(4) to be used with the default firmware configuration
  file.
  
  Discussed with:   np
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/firmware/t6fw_cfg.txt
  head/sys/dev/cxgbe/t4_main.c

Modified: head/sys/dev/cxgbe/firmware/t6fw_cfg.txt
==
--- head/sys/dev/cxgbe/firmware/t6fw_cfg.txtMon Sep 18 23:30:39 2017
(r323723)
+++ head/sys/dev/cxgbe/firmware/t6fw_cfg.txtMon Sep 18 23:50:34 2017
(r323724)
@@ -153,6 +153,7 @@
nexactf = 456
cmask = all
pmask = all
+   ncrypto_lookaside = 16
nclip = 320
 
# TCAM has 6K cells; each region must start at a multiple of 128 cell.
@@ -162,7 +163,7 @@
nserver = 512
nhpfilter = 0
nhash = 16384
-   protocol = ofld, rddp, rdmac, iscsi_initiator_pdu, iscsi_target_pdu, 
iscsi_t10dif
+   protocol = ofld, rddp, rdmac, iscsi_initiator_pdu, iscsi_target_pdu, 
iscsi_t10dif, crypto_lookaside
tp_l2t = 4096
tp_ddp = 2
tp_ddp_iscsi = 2
@@ -272,7 +273,7 @@
 
 [fini]
version = 0x1
-   checksum = 0xf438bb8f
+   checksum = 0x7191019f
 #
 # $FreeBSD$
 #

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cMon Sep 18 23:30:39 2017
(r323723)
+++ head/sys/dev/cxgbe/t4_main.cMon Sep 18 23:50:34 2017
(r323724)
@@ -452,7 +452,7 @@ TUNABLE_INT("hw.cxgbe.toecaps_allowed", _toecaps_al
 static int t4_rdmacaps_allowed = -1;
 TUNABLE_INT("hw.cxgbe.rdmacaps_allowed", _rdmacaps_allowed);
 
-static int t4_cryptocaps_allowed = 0;
+static int t4_cryptocaps_allowed = -1;
 TUNABLE_INT("hw.cxgbe.cryptocaps_allowed", _cryptocaps_allowed);
 
 static int t4_iscsicaps_allowed = -1;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"