Re: svn commit: r347890 - in head/sys/dev: aac bge

2019-05-16 Thread Peter Jeremy
On 2019-May-16 20:41:29 +, Tycho Nightingale  wrote:
>Author: tychon
>Date: Thu May 16 20:41:28 2019
>New Revision: 347890
>URL: https://svnweb.freebsd.org/changeset/base/347890
>
>Log:
>  reinstate 4GB DMA boundary workarounds for bge and aac
>  
>  Reviewed by: kib
>  Sponsored by:Dell EMC Isilon
>  Differential Revision:   https://reviews.freebsd.org/D20277

My main concern with this commit is that there is nothing in the commit
message explaining why this has been done.  D20277 implies that this is
effectively reverting a couple of other commits because these devices
have 64-bit issues - the commit log should document this.

-- 
Peter Jeremy


signature.asc
Description: PGP signature


Re: svn commit: r347890 - in head/sys/dev: aac bge

2019-05-16 Thread Tycho Nightingale


> On May 16, 2019, at 5:23 PM, Hans Petter Selasky  wrote:
> 
> On 2019-05-16 22:41, Tycho Nightingale wrote:
>> Author: tychon
>> Date: Thu May 16 20:41:28 2019
>> New Revision: 347890
>> URL: https://svnweb.freebsd.org/changeset/base/347890
>> Log:
>>   reinstate 4GB DMA boundary workarounds for bge and aac
>>  Reviewed by:kib
>>   Sponsored by:  Dell EMC Isilon
>>   Differential Revision: https://reviews.freebsd.org/D20277
>> Modified:
>>   head/sys/dev/aac/aac_pci.c
>>   head/sys/dev/bge/if_bge.c
>>   head/sys/dev/bge/if_bgereg.h
>> Modified: head/sys/dev/aac/aac_pci.c
>> ==
>> --- head/sys/dev/aac/aac_pci.c   Thu May 16 19:32:11 2019
>> (r347889)
>> +++ head/sys/dev/aac/aac_pci.c   Thu May 16 20:41:28 2019
>> (r347890)
>> @@ -443,7 +443,8 @@ aac_pci_attach(device_t dev)
>>   * Note that some of these controllers are 64-bit capable.
>>   */
>>  if (bus_dma_tag_create(bus_get_dma_tag(dev),/* parent */
>> -   PAGE_SIZE, 0,/* algnmnt, boundary */
>> +   PAGE_SIZE,   /* algnmnt */
>> +   ((bus_size_t)((uint64_t)1 << 32)), /* boundary*/
>> BUS_SPACE_MAXADDR,   /* lowaddr */
>> BUS_SPACE_MAXADDR,   /* highaddr */
>> NULL, NULL,  /* filter, filterarg */
>> Modified: head/sys/dev/bge/if_bge.c
>> ==
>> --- head/sys/dev/bge/if_bge.cThu May 16 19:32:11 2019
>> (r347889)
>> +++ head/sys/dev/bge/if_bge.cThu May 16 20:41:28 2019
>> (r347890)
>> @@ -2927,10 +2927,14 @@ bge_dma_ring_alloc(struct bge_softc *sc, bus_size_t 
>> al
>>  bus_addr_t *paddr, const char *msg)
>>  {
>>  struct bge_dmamap_arg ctx;
>> +bus_addr_t lowaddr;
>> +bus_size_t ring_end;
>>  int error;
>>  +   lowaddr = BUS_SPACE_MAXADDR;
>> +again:
>>  error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag,
>> -alignment, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL,
>> +alignment, 0, lowaddr, BUS_SPACE_MAXADDR, NULL,
>>  NULL, maxsize, 1, maxsize, 0, NULL, NULL, tag);
>>  if (error != 0) {
>>  device_printf(sc->bge_dev,
>> @@ -2955,6 +2959,25 @@ bge_dma_ring_alloc(struct bge_softc *sc, bus_size_t al
>>  return (ENOMEM);
>>  }
>>  *paddr = ctx.bge_busaddr;
>> +ring_end = *paddr + maxsize;
>> +if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0 &&
>> +BGE_ADDR_HI(*paddr) != BGE_ADDR_HI(ring_end)) {
>> +/*
>> + * 4GB boundary crossed.  Limit maximum allowable DMA
>> + * address space to 32bit and try again.
>> + */
>> +bus_dmamap_unload(*tag, *map);
>> +bus_dmamem_free(*tag, *ring, *map);
>> +bus_dma_tag_destroy(*tag);
>> +if (bootverbose)
>> +device_printf(sc->bge_dev, "4GB boundary crossed, "
>> +"limit DMA address space to 32bit for %s\n", msg);
>> +*ring = NULL;
>> +*tag = NULL;
>> +*map = NULL;
>> +lowaddr = BUS_SPACE_MAXADDR_32BIT;
>> +goto again;
>> +}
>>  return (0);
>>  }
>>  @@ -2962,7 +2985,7 @@ static int
>>  bge_dma_alloc(struct bge_softc *sc)
>>  {
>>  bus_addr_t lowaddr;
>> -bus_size_t rxmaxsegsz, sbsz, txsegsz, txmaxsegsz;
>> +bus_size_t boundary, sbsz, rxmaxsegsz, txsegsz, txmaxsegsz;
>>  int i, error;
>>  lowaddr = BUS_SPACE_MAXADDR;
>> @@ -3049,7 +3072,9 @@ bge_dma_alloc(struct bge_softc *sc)
>>  }
>>  /* Create parent tag for buffers. */
>> +boundary = 0;
>>  if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0) {
>> +boundary = BGE_DMA_BNDRY;
>>  /*
>>   * XXX
>>   * watchdog timeout issue was observed on BCM5704 which
>> @@ -3060,10 +3085,10 @@ bge_dma_alloc(struct bge_softc *sc)
>>  if (sc->bge_pcixcap != 0)
>>  lowaddr = BUS_SPACE_MAXADDR_32BIT;
>>  }
>> -error = bus_dma_tag_create(bus_get_dma_tag(sc->bge_dev), 1, 0, lowaddr,
>> -BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, 0,
>> -BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL,
>> ->bge_cdata.bge_buffer_tag);
>> +error = bus_dma_tag_create(bus_get_dma_tag(sc->bge_dev),
>> +1, boundary, lowaddr, BUS_SPACE_MAXADDR, NULL,
>> +NULL, BUS_SPACE_MAXSIZE_32BIT, 0, BUS_SPACE_MAXSIZE_32BIT,
>> +0, NULL, NULL, >bge_cdata.bge_buffer_tag);
>>  if (error != 0) {
>>  device_printf(sc->bge_dev,
>>  "could not allocate buffer dma tag\n");
>> Modified: head/sys/dev/bge/if_bgereg.h
>> ==

svn commit: r347896 - head/sys/dev/bge

2019-05-16 Thread Tycho Nightingale
Author: tychon
Date: Thu May 16 22:27:38 2019
New Revision: 347896
URL: https://svnweb.freebsd.org/changeset/base/347896

Log:
  Fix integer overflow in r346386.
  
  Sponsored by: Dell EMC Isilon

Modified:
  head/sys/dev/bge/if_bgereg.h

Modified: head/sys/dev/bge/if_bgereg.h
==
--- head/sys/dev/bge/if_bgereg.hThu May 16 22:20:54 2019
(r347895)
+++ head/sys/dev/bge/if_bgereg.hThu May 16 22:27:38 2019
(r347896)
@@ -2866,7 +2866,7 @@ struct bge_gib {
 #defineBGE_DMA_MAXADDR 0xFF
 #endif
 
-#if (BUS_SPACE_MAXADDR > 0x)
+#if (BUS_SPACE_MAXSIZE > 0x)
 #defineBGE_DMA_BNDRY   0x1
 #else
 #defineBGE_DMA_BNDRY   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: r347895 - in head: lib/libc/amd64/sys lib/libc/x86/gen lib/libc/x86/sys sys/amd64/amd64 sys/amd64/linux sys/amd64/linux32 sys/arm64/include sys/cddl/dev/dtrace/amd64 sys/dev/random sys/...

2019-05-16 Thread Konstantin Belousov
Author: kib
Date: Thu May 16 22:20:54 2019
New Revision: 347895
URL: https://svnweb.freebsd.org/changeset/base/347895

Log:
  Remove resolver_qual from DEFINE_IFUNC/DEFINE_UIFUNC macros.
  
  In all practical situations, the resolver visibility is static.
  
  Requested by: markj
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Approved by:  so (emaste)
  Differential revision:https://reviews.freebsd.org/D20281

Modified:
  head/lib/libc/amd64/sys/amd64_get_fsbase.c
  head/lib/libc/amd64/sys/amd64_get_gsbase.c
  head/lib/libc/amd64/sys/amd64_set_fsbase.c
  head/lib/libc/amd64/sys/amd64_set_gsbase.c
  head/lib/libc/x86/gen/getcontextx.c
  head/lib/libc/x86/sys/__vdso_gettc.c
  head/lib/libc/x86/sys/pkru.c
  head/sys/amd64/amd64/copyout.c
  head/sys/amd64/amd64/fpu.c
  head/sys/amd64/amd64/machdep.c
  head/sys/amd64/amd64/pmap.c
  head/sys/amd64/linux/linux_machdep.c
  head/sys/amd64/linux32/linux32_machdep.c
  head/sys/arm64/include/ifunc.h
  head/sys/cddl/dev/dtrace/amd64/dtrace_isa.c
  head/sys/dev/random/ivy.c
  head/sys/i386/i386/npx.c
  head/sys/i386/i386/pmap_base.c
  head/sys/x86/include/ifunc.h

Modified: head/lib/libc/amd64/sys/amd64_get_fsbase.c
==
--- head/lib/libc/amd64/sys/amd64_get_fsbase.c  Thu May 16 22:03:25 2019
(r347894)
+++ head/lib/libc/amd64/sys/amd64_get_fsbase.c  Thu May 16 22:20:54 2019
(r347895)
@@ -57,7 +57,7 @@ amd64_get_fsbase_syscall(void **addr)
return (sysarch(AMD64_GET_FSBASE, addr));
 }
 
-DEFINE_UIFUNC(, int, amd64_get_fsbase, (void **), static)
+DEFINE_UIFUNC(, int, amd64_get_fsbase, (void **))
 {
 
if (__getosreldate() >= P_OSREL_WRFSBASE &&

Modified: head/lib/libc/amd64/sys/amd64_get_gsbase.c
==
--- head/lib/libc/amd64/sys/amd64_get_gsbase.c  Thu May 16 22:03:25 2019
(r347894)
+++ head/lib/libc/amd64/sys/amd64_get_gsbase.c  Thu May 16 22:20:54 2019
(r347895)
@@ -57,7 +57,7 @@ amd64_get_gsbase_syscall(void **addr)
return (sysarch(AMD64_GET_GSBASE, addr));
 }
 
-DEFINE_UIFUNC(, int, amd64_get_gsbase, (void **), static)
+DEFINE_UIFUNC(, int, amd64_get_gsbase, (void **))
 {
 
if (__getosreldate() >= P_OSREL_WRFSBASE &&

Modified: head/lib/libc/amd64/sys/amd64_set_fsbase.c
==
--- head/lib/libc/amd64/sys/amd64_set_fsbase.c  Thu May 16 22:03:25 2019
(r347894)
+++ head/lib/libc/amd64/sys/amd64_set_fsbase.c  Thu May 16 22:20:54 2019
(r347895)
@@ -57,7 +57,7 @@ amd64_set_fsbase_syscall(void *addr)
return (sysarch(AMD64_SET_FSBASE, ));
 }
 
-DEFINE_UIFUNC(, int, amd64_set_fsbase, (void *), static)
+DEFINE_UIFUNC(, int, amd64_set_fsbase, (void *))
 {
 
if (__getosreldate() >= P_OSREL_WRFSBASE &&

Modified: head/lib/libc/amd64/sys/amd64_set_gsbase.c
==
--- head/lib/libc/amd64/sys/amd64_set_gsbase.c  Thu May 16 22:03:25 2019
(r347894)
+++ head/lib/libc/amd64/sys/amd64_set_gsbase.c  Thu May 16 22:20:54 2019
(r347895)
@@ -57,7 +57,7 @@ amd64_set_gsbase_syscall(void *addr)
return (sysarch(AMD64_SET_GSBASE, ));
 }
 
-DEFINE_UIFUNC(, int, amd64_set_gsbase, (void *), static)
+DEFINE_UIFUNC(, int, amd64_set_gsbase, (void *))
 {
 
if (__getosreldate() >= P_OSREL_WRFSBASE &&

Modified: head/lib/libc/x86/gen/getcontextx.c
==
--- head/lib/libc/x86/gen/getcontextx.c Thu May 16 22:03:25 2019
(r347894)
+++ head/lib/libc/x86/gen/getcontextx.c Thu May 16 22:20:54 2019
(r347895)
@@ -61,7 +61,7 @@ __getcontextx_size_xfpu(void)
return (sizeof(ucontext_t) + xstate_sz);
 }
 
-DEFINE_UIFUNC(, int, __getcontextx_size, (void), static)
+DEFINE_UIFUNC(, int, __getcontextx_size, (void))
 {
u_int p[4];
 
@@ -100,7 +100,7 @@ __fillcontextx2_noxfpu(char *ctx)
return (0);
 }
 
-DEFINE_UIFUNC(, int, __fillcontextx2, (char *), static)
+DEFINE_UIFUNC(, int, __fillcontextx2, (char *))
 {
 
return ((cpu_feature2 & CPUID2_OSXSAVE) != 0 ? __fillcontextx2_xfpu : 

Modified: head/lib/libc/x86/sys/__vdso_gettc.c
==
--- head/lib/libc/x86/sys/__vdso_gettc.cThu May 16 22:03:25 2019
(r347894)
+++ head/lib/libc/x86/sys/__vdso_gettc.cThu May 16 22:20:54 2019
(r347895)
@@ -72,7 +72,7 @@ rdtsc_mb_none(void)
 {
 }
 
-DEFINE_UIFUNC(static, void, rdtsc_mb, (void), static)
+DEFINE_UIFUNC(static, void, rdtsc_mb, (void))
 {
u_int p[4];
/* Not a typo, string matches our do_cpuid() registers use. */

Modified: head/lib/libc/x86/sys/pkru.c
==
--- head/lib/libc/x86/sys/pkru.c 

svn commit: r347893 - in head/usr.sbin: etcupdate mergemaster

2019-05-16 Thread Brad Davis
Author: brd
Date: Thu May 16 21:50:12 2019
New Revision: 347893
URL: https://svnweb.freebsd.org/changeset/base/347893

Log:
  Fix mergemaster after r347638 and the master.passwd / group move.
  
  Check the legacy directory and use it instead if present.
  
  Install these first if using beinstall.
  
  UPDATING entry to follow.
  
  Approved by:  allanjude (mentor, in person)
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D20279

Modified:
  head/usr.sbin/etcupdate/etcupdate.sh
  head/usr.sbin/mergemaster/mergemaster.sh

Modified: head/usr.sbin/etcupdate/etcupdate.sh
==
--- head/usr.sbin/etcupdate/etcupdate.shThu May 16 21:17:18 2019
(r347892)
+++ head/usr.sbin/etcupdate/etcupdate.shThu May 16 21:50:12 2019
(r347893)
@@ -1737,7 +1737,9 @@ WARNINGS=$WORKDIR/warnings
 EDITOR=${EDITOR:-/usr/bin/vi}
 
 # Files that need to be updated before installworld.
-PREWORLD_FILES="etc/master.passwd etc/group"
+PREWORLD_FILES="lib/libc/gen/master.passwd lib/libc/gen/group"
+# If on an older tree, use it instead.  Delete after 13.0.
+[ -f ${SRCDIR}/etc/master.passwd ] && PREWORLD_FILES="etc/master.passwd 
etc/group"
 
 # Handle command-specific argument processing such as complaining
 # about unsupported options.  Since the configuration file is always

Modified: head/usr.sbin/mergemaster/mergemaster.sh
==
--- head/usr.sbin/mergemaster/mergemaster.shThu May 16 21:17:18 2019
(r347892)
+++ head/usr.sbin/mergemaster/mergemaster.shThu May 16 21:50:12 2019
(r347893)
@@ -669,9 +669,12 @@ case "${RERUN}" in
 ;;
   *)
 # Only set up files that are crucial to {build|install}world
-{ mkdir -p ${TEMPROOT}/etc &&
-  cp -p ${SOURCEDIR}/etc/master.passwd ${TEMPROOT}/etc &&
-  install -p -o root -g wheel -m 0644 ${SOURCEDIR}/etc/group 
${TEMPROOT}/etc;} ||
+{ MM_PASSDIR="${SOURCEDIR}/lib/libc/gen"
+  # If on an older tree, use it instead.  Delete after 13.0.
+  [ -f ${SOURCEDIR}/etc/master.passwd ] && MM_PASSDIR="${SOURCEDIR}/etc"
+  mkdir -p ${TEMPROOT}/etc &&
+  cp -p ${MM_PASSDIR}/master.passwd ${TEMPROOT}/etc &&
+  install -p -o root -g wheel -m 0644 ${MM_PASSDIR}/group 
${TEMPROOT}/etc;} ||
 { echo '';
   echo '  *** FATAL ERROR: Cannot copy files to the temproot environment';
   echo '';
___
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: r347890 - in head/sys/dev: aac bge

2019-05-16 Thread Hans Petter Selasky

On 2019-05-16 22:41, Tycho Nightingale wrote:

Author: tychon
Date: Thu May 16 20:41:28 2019
New Revision: 347890
URL: https://svnweb.freebsd.org/changeset/base/347890

Log:
   reinstate 4GB DMA boundary workarounds for bge and aac
   
   Reviewed by:	kib

   Sponsored by:Dell EMC Isilon
   Differential Revision:   https://reviews.freebsd.org/D20277

Modified:
   head/sys/dev/aac/aac_pci.c
   head/sys/dev/bge/if_bge.c
   head/sys/dev/bge/if_bgereg.h

Modified: head/sys/dev/aac/aac_pci.c
==
--- head/sys/dev/aac/aac_pci.c  Thu May 16 19:32:11 2019(r347889)
+++ head/sys/dev/aac/aac_pci.c  Thu May 16 20:41:28 2019(r347890)
@@ -443,7 +443,8 @@ aac_pci_attach(device_t dev)
 * Note that some of these controllers are 64-bit capable.
 */
if (bus_dma_tag_create(bus_get_dma_tag(dev),/* parent */
-  PAGE_SIZE, 0,/* algnmnt, boundary */
+  PAGE_SIZE,   /* algnmnt */
+  ((bus_size_t)((uint64_t)1 << 32)), /* boundary*/
   BUS_SPACE_MAXADDR,   /* lowaddr */
   BUS_SPACE_MAXADDR,   /* highaddr */
   NULL, NULL,  /* filter, filterarg */

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Thu May 16 19:32:11 2019(r347889)
+++ head/sys/dev/bge/if_bge.c   Thu May 16 20:41:28 2019(r347890)
@@ -2927,10 +2927,14 @@ bge_dma_ring_alloc(struct bge_softc *sc, bus_size_t al
  bus_addr_t *paddr, const char *msg)
  {
struct bge_dmamap_arg ctx;
+   bus_addr_t lowaddr;
+   bus_size_t ring_end;
int error;
  
+	lowaddr = BUS_SPACE_MAXADDR;

+again:
error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag,
-   alignment, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL,
+   alignment, 0, lowaddr, BUS_SPACE_MAXADDR, NULL,
NULL, maxsize, 1, maxsize, 0, NULL, NULL, tag);
if (error != 0) {
device_printf(sc->bge_dev,
@@ -2955,6 +2959,25 @@ bge_dma_ring_alloc(struct bge_softc *sc, bus_size_t al
return (ENOMEM);
}
*paddr = ctx.bge_busaddr;
+   ring_end = *paddr + maxsize;
+   if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0 &&
+   BGE_ADDR_HI(*paddr) != BGE_ADDR_HI(ring_end)) {
+   /*
+* 4GB boundary crossed.  Limit maximum allowable DMA
+* address space to 32bit and try again.
+*/
+   bus_dmamap_unload(*tag, *map);
+   bus_dmamem_free(*tag, *ring, *map);
+   bus_dma_tag_destroy(*tag);
+   if (bootverbose)
+   device_printf(sc->bge_dev, "4GB boundary crossed, "
+   "limit DMA address space to 32bit for %s\n", msg);
+   *ring = NULL;
+   *tag = NULL;
+   *map = NULL;
+   lowaddr = BUS_SPACE_MAXADDR_32BIT;
+   goto again;
+   }
return (0);
  }
  
@@ -2962,7 +2985,7 @@ static int

  bge_dma_alloc(struct bge_softc *sc)
  {
bus_addr_t lowaddr;
-   bus_size_t rxmaxsegsz, sbsz, txsegsz, txmaxsegsz;
+   bus_size_t boundary, sbsz, rxmaxsegsz, txsegsz, txmaxsegsz;
int i, error;
  
  	lowaddr = BUS_SPACE_MAXADDR;

@@ -3049,7 +3072,9 @@ bge_dma_alloc(struct bge_softc *sc)
}
  
  	/* Create parent tag for buffers. */

+   boundary = 0;
if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0) {
+   boundary = BGE_DMA_BNDRY;
/*
 * XXX
 * watchdog timeout issue was observed on BCM5704 which
@@ -3060,10 +3085,10 @@ bge_dma_alloc(struct bge_softc *sc)
if (sc->bge_pcixcap != 0)
lowaddr = BUS_SPACE_MAXADDR_32BIT;
}
-   error = bus_dma_tag_create(bus_get_dma_tag(sc->bge_dev), 1, 0, lowaddr,
-   BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, 0,
-   BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL,
-   >bge_cdata.bge_buffer_tag);
+   error = bus_dma_tag_create(bus_get_dma_tag(sc->bge_dev),
+   1, boundary, lowaddr, BUS_SPACE_MAXADDR, NULL,
+   NULL, BUS_SPACE_MAXSIZE_32BIT, 0, BUS_SPACE_MAXSIZE_32BIT,
+   0, NULL, NULL, >bge_cdata.bge_buffer_tag);
if (error != 0) {
device_printf(sc->bge_dev,
"could not allocate buffer dma tag\n");

Modified: head/sys/dev/bge/if_bgereg.h
==
--- head/sys/dev/bge/if_bgereg.hThu May 16 19:32:11 2019
(r347889)
+++ head/sys/dev/bge/if_bgereg.hThu May 16 20:41:28 2019
(r347890)
@@ -2866,6 +2866,12 @@ 

svn commit: r347892 - in head/sys: compat/linuxkpi/common/include/linux modules/linuxkpi

2019-05-16 Thread Johannes Lundberg
Author: johalun
Date: Thu May 16 21:17:18 2019
New Revision: 347892
URL: https://svnweb.freebsd.org/changeset/base/347892

Log:
  LinuxKPI: Finalize import of seq_file.
  
  seq_file.h and linux_seq_file.c was imported form ports earlier but
  linux_seq_file.c was never compiled in with the module. With this
  commit base seq_file will replace ports seq_file and it required a
  few modifications to not break functionality and build.
  
  Reviewed by:  hps
  Approved by:  imp (mentor), hps
  MFC after:1 week

Modified:
  head/sys/compat/linuxkpi/common/include/linux/seq_file.h
  head/sys/modules/linuxkpi/Makefile

Modified: head/sys/compat/linuxkpi/common/include/linux/seq_file.h
==
--- head/sys/compat/linuxkpi/common/include/linux/seq_file.hThu May 16 
21:07:37 2019(r347891)
+++ head/sys/compat/linuxkpi/common/include/linux/seq_file.hThu May 16 
21:17:18 2019(r347892)
@@ -30,13 +30,29 @@
 #ifndef _LINUX_SEQ_FILE_H_
 #define _LINUX_SEQ_FILE_H_
 
+#include 
+#include 
 #include 
 
-struct seq_operations;
-struct linux_file;
-
+#undef file
 #define inode vnode
 
+#defineDEFINE_SHOW_ATTRIBUTE(__name)   
\
+static int __name ## _open(struct inode *inode, struct linux_file *file)   
\
+{  \
+   return single_open(file, __name ## _show, inode->i_private);\
+}  \
+   \
+static const struct file_operations __name ## _fops = {
\
+   .owner  = THIS_MODULE,  \
+   .open   = __name ## _open,  \
+   .read   = seq_read, \
+   .llseek = seq_lseek,\
+   .release= single_release,   \
+}
+
+struct seq_operations;
+
 struct seq_file {
struct sbuf *buf;
 
@@ -67,5 +83,6 @@ int single_release(struct inode *, struct linux_file *
 #define seq_puts(m, str)   sbuf_printf((m)->buf, str)
 #define seq_putc(m, str)   sbuf_putc((m)->buf, str)
 
+#definefilelinux_file
 
 #endif /* _LINUX_SEQ_FILE_H_ */

Modified: head/sys/modules/linuxkpi/Makefile
==
--- head/sys/modules/linuxkpi/Makefile  Thu May 16 21:07:37 2019
(r347891)
+++ head/sys/modules/linuxkpi/Makefile  Thu May 16 21:17:18 2019
(r347892)
@@ -13,6 +13,7 @@ SRCS= linux_compat.c \
linux_pci.c \
linux_radix.c \
linux_rcu.c \
+   linux_seq_file.c \
linux_schedule.c \
linux_slab.c \
linux_tasklet.c \
___
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: r347891 - head/sys/compat/linuxkpi/common/include/linux

2019-05-16 Thread Johannes Lundberg
Author: johalun
Date: Thu May 16 21:07:37 2019
New Revision: 347891
URL: https://svnweb.freebsd.org/changeset/base/347891

Log:
  LinuxKPI: Add in_task macro.
  
  This patch is part of D19565
  
  Reviewed by:  hps, bwidawsk
  Approved by:  imp (mentor), hps
  Obtained from:bwidawsk
  MFC after:1 week

Modified:
  head/sys/compat/linuxkpi/common/include/linux/preempt.h

Modified: head/sys/compat/linuxkpi/common/include/linux/preempt.h
==
--- head/sys/compat/linuxkpi/common/include/linux/preempt.h Thu May 16 
20:41:28 2019(r347890)
+++ head/sys/compat/linuxkpi/common/include/linux/preempt.h Thu May 16 
21:07:37 2019(r347891)
@@ -34,6 +34,8 @@
 #definein_interrupt() \
(curthread->td_intr_nesting_level || curthread->td_critnest)
 
+#definein_task() (curthread->td_priority >= PI_SOFT)
+
 #definepreempt_disable()   critical_enter()
 #definepreempt_enable()critical_exit()
 
___
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: r347890 - in head/sys/dev: aac bge

2019-05-16 Thread Tycho Nightingale
Author: tychon
Date: Thu May 16 20:41:28 2019
New Revision: 347890
URL: https://svnweb.freebsd.org/changeset/base/347890

Log:
  reinstate 4GB DMA boundary workarounds for bge and aac
  
  Reviewed by:  kib
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D20277

Modified:
  head/sys/dev/aac/aac_pci.c
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bge/if_bgereg.h

Modified: head/sys/dev/aac/aac_pci.c
==
--- head/sys/dev/aac/aac_pci.c  Thu May 16 19:32:11 2019(r347889)
+++ head/sys/dev/aac/aac_pci.c  Thu May 16 20:41:28 2019(r347890)
@@ -443,7 +443,8 @@ aac_pci_attach(device_t dev)
 * Note that some of these controllers are 64-bit capable.
 */
if (bus_dma_tag_create(bus_get_dma_tag(dev),/* parent */
-  PAGE_SIZE, 0,/* algnmnt, boundary */
+  PAGE_SIZE,   /* algnmnt */
+  ((bus_size_t)((uint64_t)1 << 32)), /* boundary*/
   BUS_SPACE_MAXADDR,   /* lowaddr */
   BUS_SPACE_MAXADDR,   /* highaddr */
   NULL, NULL,  /* filter, filterarg */

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Thu May 16 19:32:11 2019(r347889)
+++ head/sys/dev/bge/if_bge.c   Thu May 16 20:41:28 2019(r347890)
@@ -2927,10 +2927,14 @@ bge_dma_ring_alloc(struct bge_softc *sc, bus_size_t al
 bus_addr_t *paddr, const char *msg)
 {
struct bge_dmamap_arg ctx;
+   bus_addr_t lowaddr;
+   bus_size_t ring_end;
int error;
 
+   lowaddr = BUS_SPACE_MAXADDR;
+again:
error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag,
-   alignment, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL,
+   alignment, 0, lowaddr, BUS_SPACE_MAXADDR, NULL,
NULL, maxsize, 1, maxsize, 0, NULL, NULL, tag);
if (error != 0) {
device_printf(sc->bge_dev,
@@ -2955,6 +2959,25 @@ bge_dma_ring_alloc(struct bge_softc *sc, bus_size_t al
return (ENOMEM);
}
*paddr = ctx.bge_busaddr;
+   ring_end = *paddr + maxsize;
+   if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0 &&
+   BGE_ADDR_HI(*paddr) != BGE_ADDR_HI(ring_end)) {
+   /*
+* 4GB boundary crossed.  Limit maximum allowable DMA
+* address space to 32bit and try again.
+*/
+   bus_dmamap_unload(*tag, *map);
+   bus_dmamem_free(*tag, *ring, *map);
+   bus_dma_tag_destroy(*tag);
+   if (bootverbose)
+   device_printf(sc->bge_dev, "4GB boundary crossed, "
+   "limit DMA address space to 32bit for %s\n", msg);
+   *ring = NULL;
+   *tag = NULL;
+   *map = NULL;
+   lowaddr = BUS_SPACE_MAXADDR_32BIT;
+   goto again;
+   }
return (0);
 }
 
@@ -2962,7 +2985,7 @@ static int
 bge_dma_alloc(struct bge_softc *sc)
 {
bus_addr_t lowaddr;
-   bus_size_t rxmaxsegsz, sbsz, txsegsz, txmaxsegsz;
+   bus_size_t boundary, sbsz, rxmaxsegsz, txsegsz, txmaxsegsz;
int i, error;
 
lowaddr = BUS_SPACE_MAXADDR;
@@ -3049,7 +3072,9 @@ bge_dma_alloc(struct bge_softc *sc)
}
 
/* Create parent tag for buffers. */
+   boundary = 0;
if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0) {
+   boundary = BGE_DMA_BNDRY;
/*
 * XXX
 * watchdog timeout issue was observed on BCM5704 which
@@ -3060,10 +3085,10 @@ bge_dma_alloc(struct bge_softc *sc)
if (sc->bge_pcixcap != 0)
lowaddr = BUS_SPACE_MAXADDR_32BIT;
}
-   error = bus_dma_tag_create(bus_get_dma_tag(sc->bge_dev), 1, 0, lowaddr,
-   BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, 0,
-   BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL,
-   >bge_cdata.bge_buffer_tag);
+   error = bus_dma_tag_create(bus_get_dma_tag(sc->bge_dev),
+   1, boundary, lowaddr, BUS_SPACE_MAXADDR, NULL,
+   NULL, BUS_SPACE_MAXSIZE_32BIT, 0, BUS_SPACE_MAXSIZE_32BIT,
+   0, NULL, NULL, >bge_cdata.bge_buffer_tag);
if (error != 0) {
device_printf(sc->bge_dev,
"could not allocate buffer dma tag\n");

Modified: head/sys/dev/bge/if_bgereg.h
==
--- head/sys/dev/bge/if_bgereg.hThu May 16 19:32:11 2019
(r347889)
+++ head/sys/dev/bge/if_bgereg.hThu May 16 20:41:28 2019
(r347890)
@@ -2866,6 +2866,12 @@ struct bge_gib {
 #defineBGE_DMA_MAXADDR 

svn commit: r347889 - head/sys/compat/linuxkpi/common/src

2019-05-16 Thread Johannes Lundberg
Author: johalun
Date: Thu May 16 19:32:11 2019
New Revision: 347889
URL: https://svnweb.freebsd.org/changeset/base/347889

Log:
  LinuxKPI: Fix build on powerpc/sparc.
  
  Use cmpset instead of testandset in tasklet lock code.
  
  Reviewed by:  hps
  Approved by:  imp (mentor), hps
  Obtained from:hps
  MFC after:1 week

Modified:
  head/sys/compat/linuxkpi/common/src/linux_tasklet.c

Modified: head/sys/compat/linuxkpi/common/src/linux_tasklet.c
==
--- head/sys/compat/linuxkpi/common/src/linux_tasklet.c Thu May 16 19:10:48 
2019(r347888)
+++ head/sys/compat/linuxkpi/common/src/linux_tasklet.c Thu May 16 19:32:11 
2019(r347889)
@@ -51,9 +51,6 @@ __FBSDID("$FreeBSD$");
 #defineTASKLET_ST_GET(ts) \
READ_ONCE(*(volatile u_int *)&(ts)->tasklet_state)
 
-#defineTASKLET_ST_TESTANDSET(ts, new) \
-   atomic_testandset_int((volatile u_int *)&(ts)->tasklet_state, new)
-
 struct tasklet_worker {
struct mtx mtx;
TAILQ_HEAD(tasklet_list, tasklet_struct) head;
@@ -234,7 +231,7 @@ int
 tasklet_trylock(struct tasklet_struct *ts)
 {
 
-   return (!TASKLET_ST_TESTANDSET(ts, TASKLET_ST_BUSY));
+   return (TASKLET_ST_CMPSET(ts, TASKLET_ST_IDLE, TASKLET_ST_BUSY));
 }
 
 void
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347887 - head/sys/netinet6

2019-05-16 Thread Hiroki Sato
Author: hrs
Date: Thu May 16 19:09:41 2019
New Revision: 347887
URL: https://svnweb.freebsd.org/changeset/base/347887

Log:
  Fix hostname to be returned in an ICMPv6 NI Reply message defined
  in RFC 4620, ICMPv6 Node Information Queries.  A vnet jail with an
  IPv6 address sent a hostname of the host environment, not the
  jail, even if another hostname was set to the jail.
  
  This change can be tested by the following commands:
  
   # ifconfig epair0 create
   # jail -c -n j1 vnet host.hostname=vnetjail path=/ persist
   # ifconfig epair0b vnet j1
   # ifconfig epair0a inet6 -ifdisabled auto_linklocal up
   # jexec j1 ifconfig epair0b inet6 -ifdisabled auto_linklocal up
   # ping6 -w ff02::1%epair0a
  
  Differential Revision:https://reviews.freebsd.org/D20207
  MFC after:1 week

Modified:
  head/sys/netinet6/icmp6.c

Modified: head/sys/netinet6/icmp6.c
==
--- head/sys/netinet6/icmp6.c   Thu May 16 18:54:20 2019(r347886)
+++ head/sys/netinet6/icmp6.c   Thu May 16 19:09:41 2019(r347887)
@@ -140,7 +140,7 @@ static int icmp6_rip6_input(struct mbuf **, int);
 static int icmp6_ratelimit(const struct in6_addr *, const int, const int);
 static const char *icmp6_redirect_diag(struct in6_addr *,
struct in6_addr *, struct in6_addr *);
-static struct mbuf *ni6_input(struct mbuf *, int);
+static struct mbuf *ni6_input(struct mbuf *, int, struct prison *);
 static struct mbuf *ni6_nametodns(const char *, int, int);
 static int ni6_dnsmatch(const char *, int, const char *, int);
 static int ni6_addrs(struct icmp6_nodeinfo *, struct mbuf *,
@@ -627,6 +627,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
case ICMP6_WRUREQUEST:  /* ICMP6_FQDN_QUERY */
{
enum { WRU, FQDN } mode;
+   struct prison *pr;
 
if (!V_icmp6_nodeinfo)
break;
@@ -638,6 +639,14 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
else
goto badlen;
 
+   pr = NULL;
+   sx_slock(_lock);
+   TAILQ_FOREACH(pr, , pr_list)
+   if (pr->pr_vnet == ifp->if_vnet)
+   break; 
+   sx_sunlock(_lock);
+   if (pr == NULL)
+   pr = curthread->td_ucred->cr_prison;
if (mode == FQDN) {
 #ifndef PULLDOWN_TEST
IP6_EXTHDR_CHECK(m, off, sizeof(struct icmp6_nodeinfo),
@@ -645,11 +654,10 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
 #endif
n = m_copym(m, 0, M_COPYALL, M_NOWAIT);
if (n)
-   n = ni6_input(n, off);
+   n = ni6_input(n, off, pr);
/* XXX meaningless if n == NULL */
noff = sizeof(struct ip6_hdr);
} else {
-   struct prison *pr;
u_char *p;
int maxhlen, hlen;
 
@@ -683,13 +691,6 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
n = NULL;
break;
}
-   maxhlen = M_TRAILINGSPACE(n) -
-   (sizeof(*nip6) + sizeof(*nicmp6) + 4);
-   pr = curthread->td_ucred->cr_prison;
-   mtx_lock(>pr_mtx);
-   hlen = strlen(pr->pr_hostname);
-   if (maxhlen > hlen)
-   maxhlen = hlen;
/*
 * Copy IPv6 and ICMPv6 only.
 */
@@ -699,6 +700,13 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
bcopy(icmp6, nicmp6, sizeof(struct icmp6_hdr));
p = (u_char *)(nicmp6 + 1);
bzero(p, 4);
+
+   maxhlen = M_TRAILINGSPACE(n) -
+   (sizeof(*nip6) + sizeof(*nicmp6) + 4);
+   mtx_lock(>pr_mtx);
+   hlen = strlen(pr->pr_hostname);
+   if (maxhlen > hlen)
+   maxhlen = hlen;
/* meaningless TTL */
bcopy(pr->pr_hostname, p + 4, maxhlen);
mtx_unlock(>pr_mtx);
@@ -1167,11 +1175,10 @@ icmp6_mtudisc_update(struct ip6ctlparam *ip6cp, int va
  *   with hostname changes by sethostname(3)
  */
 static struct mbuf *
-ni6_input(struct mbuf *m, int off)
+ni6_input(struct mbuf *m, int off, struct prison *pr)
 {
struct icmp6_nodeinfo *ni6, *nni6;
struct mbuf *n = NULL;
-   struct prison *pr;
u_int16_t qtype;
int subjlen;
int replylen = sizeof(struct ip6_hdr) + sizeof(struct icmp6_nodeinfo);
@@ -1323,7 +1330,6 @@ ni6_input(struct mbuf 

svn commit: r347888 - in head/sys/mips: include mips

2019-05-16 Thread Conrad Meyer
Author: cem
Date: Thu May 16 19:10:48 2019
New Revision: 347888
URL: https://svnweb.freebsd.org/changeset/base/347888

Log:
  mips: Implement basic pmap_kenter_device, pmap_kremove_device
  
  Unbreak mips.BERI_DE4_SDROOT build, which uses device xdma. Device xdma
  depends on the pmap_kenter_device APIs.
  
  Reported by:  tinderbox (local)
  Sponsored by: Dell EMC Isilon

Modified:
  head/sys/mips/include/pmap.h
  head/sys/mips/mips/pmap.c

Modified: head/sys/mips/include/pmap.h
==
--- head/sys/mips/include/pmap.hThu May 16 19:09:41 2019
(r347887)
+++ head/sys/mips/include/pmap.hThu May 16 19:10:48 2019
(r347888)
@@ -177,7 +177,9 @@ void pmap_unmapdev(vm_offset_t, vm_size_t);
 vm_offset_t pmap_steal_memory(vm_size_t size);
 void pmap_kenter(vm_offset_t va, vm_paddr_t pa);
 void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, vm_memattr_t attr);
+void pmap_kenter_device(vm_offset_t, vm_size_t, vm_paddr_t);
 void pmap_kremove(vm_offset_t va);
+void pmap_kremove_device(vm_offset_t, vm_size_t);
 void *pmap_kenter_temporary(vm_paddr_t pa, int i);
 void pmap_kenter_temporary_free(vm_paddr_t pa);
 void pmap_flush_pvcache(vm_page_t m);

Modified: head/sys/mips/mips/pmap.c
==
--- head/sys/mips/mips/pmap.c   Thu May 16 19:09:41 2019(r347887)
+++ head/sys/mips/mips/pmap.c   Thu May 16 19:10:48 2019(r347888)
@@ -854,6 +854,44 @@ pmap_kenter(vm_offset_t va, vm_paddr_t pa)
pmap_kenter_attr(va, pa, VM_MEMATTR_DEFAULT);
 }
 
+void
+pmap_kenter_device(vm_offset_t va, vm_size_t size, vm_paddr_t pa)
+{
+
+   KASSERT((size & PAGE_MASK) == 0,
+   ("%s: device mapping not page-sized", __func__));
+
+   for (; size > 0; size -= PAGE_SIZE) {
+   /*
+* XXXCEM: this is somewhat inefficient on SMP systems in that
+* every single page is individually TLB-invalidated via
+* rendezvous (pmap_update_page()), instead of invalidating the
+* entire range via a single rendezvous.
+*/
+   pmap_kenter_attr(va, pa, VM_MEMATTR_UNCACHEABLE);
+   va += PAGE_SIZE;
+   pa += PAGE_SIZE;
+   }
+}
+
+void
+pmap_kremove_device(vm_offset_t va, vm_size_t size)
+{
+
+   KASSERT((size & PAGE_MASK) == 0,
+   ("%s: device mapping not page-sized", __func__));
+
+   /*
+* XXXCEM: Similar to pmap_kenter_device, this is inefficient on SMP,
+* in that pages are invalidated individually instead of a single range
+* rendezvous.
+*/
+   for (; size > 0; size -= PAGE_SIZE) {
+   pmap_kremove(va);
+   va += PAGE_SIZE;
+   }
+}
+
 /*
  * remove a page from the kernel pagetables
  */
___
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: r347886 - head/share/misc

2019-05-16 Thread Ollivier Robert
Author: roberto
Date: Thu May 16 18:54:20 2019
New Revision: 347886
URL: https://svnweb.freebsd.org/changeset/base/347886

Log:
  Announce OpenBSD 6.5.

Modified:
  head/share/misc/bsd-family-tree

Modified: head/share/misc/bsd-family-tree
==
--- head/share/misc/bsd-family-tree Thu May 16 18:50:18 2019
(r347885)
+++ head/share/misc/bsd-family-tree Thu May 16 18:54:20 2019
(r347886)
@@ -379,6 +379,7 @@ FreeBSD 5.2   |  | |  
  || |  |   |   DragonFly 5.4.0
  *--FreeBSD   | |  v   |   |
  |   12.0 | |  |   DragonFly 5.4.1
+ || | OpenBSD 6.5  |
  || |  |   |
 FreeBSD 13 -current   | NetBSD -current   OpenBSD -currentDragonFly 
-current
  || |  |   |
@@ -761,6 +762,7 @@ OpenBSD 6.4 2018-10-18 [OBD]
 DragonFly 5.4.02018-12-03 [DFB]
 FreeBSD 12.0   2018-12-11 [FBD]
 DragonFly 5.4.12018-12-24 [DFB]
+OpenBSD 6.5 2019-05-01 [OBD]
 
 Bibliography
 
___
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: r347852 - in head/sys/compat/linuxkpi/common: include/linux src

2019-05-16 Thread Johannes Lundberg
Author: johalun
Date: Thu May 16 18:03:08 2019
New Revision: 347852
URL: https://svnweb.freebsd.org/changeset/base/347852

Log:
  LinuxKPI: Updates to tasklets for Linux 5.0.
  
  DRM drivers expect tasklets to have a counter for enable/disable calls.
  Also, add a few more tasklet locking functions.
  
  This patch is part of D19565
  
  Reviewed by:  hps
  Approved by:  imp (mentor), hps
  MFC after:1 week

Modified:
  head/sys/compat/linuxkpi/common/include/linux/interrupt.h
  head/sys/compat/linuxkpi/common/src/linux_tasklet.c

Modified: head/sys/compat/linuxkpi/common/include/linux/interrupt.h
==
--- head/sys/compat/linuxkpi/common/include/linux/interrupt.h   Thu May 16 
18:02:09 2019(r347851)
+++ head/sys/compat/linuxkpi/common/include/linux/interrupt.h   Thu May 16 
18:03:08 2019(r347852)
@@ -189,11 +189,14 @@ typedef void tasklet_func_t(unsigned long);
 struct tasklet_struct {
TAILQ_ENTRY(tasklet_struct) entry;
tasklet_func_t *func;
+   /* Our "state" implementation is different. Avoid same name as Linux. */
+   volatile u_int tasklet_state;
+   atomic_t count;
unsigned long data;
 };
 
 #defineDECLARE_TASKLET(name, func, data)   \
-struct tasklet_struct name = { { NULL, NULL }, func, data }
+struct tasklet_struct name = { { NULL, NULL }, func, ATOMIC_INIT(0), data }
 
 #definetasklet_hi_schedule(t)  tasklet_schedule(t)
 
@@ -203,5 +206,8 @@ extern void tasklet_init(struct tasklet_struct *, task
 unsigned long data);
 extern void tasklet_enable(struct tasklet_struct *);
 extern void tasklet_disable(struct tasklet_struct *);
+extern int tasklet_trylock(struct tasklet_struct *);
+extern void tasklet_unlock(struct tasklet_struct *);
+extern void tasklet_unlock_wait(struct tasklet_struct *ts);
 
 #endif /* _LINUX_INTERRUPT_H_ */

Modified: head/sys/compat/linuxkpi/common/src/linux_tasklet.c
==
--- head/sys/compat/linuxkpi/common/src/linux_tasklet.c Thu May 16 18:02:09 
2019(r347851)
+++ head/sys/compat/linuxkpi/common/src/linux_tasklet.c Thu May 16 18:03:08 
2019(r347852)
@@ -41,20 +41,22 @@ __FBSDID("$FreeBSD$");
 #defineTASKLET_ST_BUSY 1
 #defineTASKLET_ST_EXEC 2
 #defineTASKLET_ST_LOOP 3
-#defineTASKLET_ST_PAUSED 4
 
 #defineTASKLET_ST_CMPSET(ts, old, new) \
-   atomic_cmpset_ptr((volatile uintptr_t *)&(ts)->entry.tqe_prev, old, new)
+   atomic_cmpset_int((volatile u_int *)&(ts)->tasklet_state, old, new)
 
 #defineTASKLET_ST_SET(ts, new) \
-   WRITE_ONCE(*(volatile uintptr_t *)&(ts)->entry.tqe_prev, new)
+   WRITE_ONCE(*(volatile u_int *)&(ts)->tasklet_state, new)
 
 #defineTASKLET_ST_GET(ts) \
-   READ_ONCE(*(volatile uintptr_t *)&(ts)->entry.tqe_prev)
+   READ_ONCE(*(volatile u_int *)&(ts)->tasklet_state)
 
+#defineTASKLET_ST_TESTANDSET(ts, new) \
+   atomic_testandset_int((volatile u_int *)&(ts)->tasklet_state, new)
+
 struct tasklet_worker {
struct mtx mtx;
-   TAILQ_HEAD(, tasklet_struct) head;
+   TAILQ_HEAD(tasklet_list, tasklet_struct) head;
struct grouptask gtask;
 } __aligned(CACHE_LINE_SIZE);
 
@@ -68,25 +70,34 @@ tasklet_handler(void *arg)
 {
struct tasklet_worker *tw = (struct tasklet_worker *)arg;
struct tasklet_struct *ts;
+   struct tasklet_struct *last;
 
linux_set_current(curthread);
 
TASKLET_WORKER_LOCK(tw);
+   last = TAILQ_LAST(>head, tasklet_list);
while (1) {
ts = TAILQ_FIRST(>head);
if (ts == NULL)
break;
TAILQ_REMOVE(>head, ts, entry);
 
-   TASKLET_WORKER_UNLOCK(tw);
-   do {
-   /* reset executing state */
-   TASKLET_ST_SET(ts, TASKLET_ST_EXEC);
+   if (!atomic_read(>count)) {
+   TASKLET_WORKER_UNLOCK(tw);
+   do {
+   /* reset executing state */
+   TASKLET_ST_SET(ts, TASKLET_ST_EXEC);
 
-   ts->func(ts->data);
+   ts->func(ts->data);
 
-   } while (TASKLET_ST_CMPSET(ts, TASKLET_ST_EXEC, 
TASKLET_ST_IDLE) == 0);
-   TASKLET_WORKER_LOCK(tw);
+   } while (TASKLET_ST_CMPSET(ts, TASKLET_ST_EXEC,
+   TASKLET_ST_IDLE) == 0);
+   TASKLET_WORKER_LOCK(tw);
+   } else {
+   TAILQ_INSERT_TAIL(>head, ts, entry);
+   }
+   if (ts == last)
+   break;
}
TASKLET_WORKER_UNLOCK(tw);
 }
@@ -140,6 +151,8 @@ tasklet_init(struct tasklet_struct *ts,
ts->entry.tqe_next = NULL;
ts->func = func;

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

2019-05-16 Thread Johannes Lundberg
Author: johalun
Date: Thu May 16 17:53:36 2019
New Revision: 347843
URL: https://svnweb.freebsd.org/changeset/base/347843

Log:
  LinuxKPI: Add group_leader member to struct task_struct.
  
  Assign self as group leader at creation to act as the only member of a
  new process group.
  This patch is part of D19565
  
  Reviewed by:  hps
  Approved by:  imp (mentor), hps
  MFC after:1 week

Modified:
  head/sys/compat/linuxkpi/common/include/linux/sched.h
  head/sys/compat/linuxkpi/common/src/linux_current.c

Modified: head/sys/compat/linuxkpi/common/include/linux/sched.h
==
--- head/sys/compat/linuxkpi/common/include/linux/sched.h   Thu May 16 
17:51:30 2019(r347842)
+++ head/sys/compat/linuxkpi/common/include/linux/sched.h   Thu May 16 
17:53:36 2019(r347843)
@@ -80,6 +80,7 @@ struct task_struct {
int rcu_recurse;
int bsd_interrupt_value;
struct work_struct *work;   /* current work struct, if set */
+   struct task_struct *group_leader;
 };
 
 #definecurrent ({ \

Modified: head/sys/compat/linuxkpi/common/src/linux_current.c
==
--- head/sys/compat/linuxkpi/common/src/linux_current.c Thu May 16 17:51:30 
2019(r347842)
+++ head/sys/compat/linuxkpi/common/src/linux_current.c Thu May 16 17:53:36 
2019(r347843)
@@ -67,6 +67,7 @@ linux_alloc_current(struct thread *td, int flags)
ts->task_thread = td;
ts->comm = td->td_name;
ts->pid = td->td_tid;
+   ts->group_leader = ts;
atomic_set(>usage, 1);
atomic_set(>state, TASK_RUNNING);
init_completion(>parked);
___
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: r347837 - in head/sys/compat/linuxkpi/common: include/linux src

2019-05-16 Thread Johannes Lundberg
Author: johalun
Date: Thu May 16 17:44:17 2019
New Revision: 347837
URL: https://svnweb.freebsd.org/changeset/base/347837

Log:
  LinuxKPI: Update access_ok macro for v5.0.
  
  Check LINUXKPI_VERSION macro for backwards compatibility.
  It's recommended to update any drivers that depend on the older KPI
  so we can deprecate < 5.0 code as we update to newer Linux version.
  This patch is part of D19565
  
  Reviewed by:  hps
  Approved by:  imp (mentor), hps
  MFC after:1 week

Modified:
  head/sys/compat/linuxkpi/common/include/linux/uaccess.h
  head/sys/compat/linuxkpi/common/src/linux_compat.c

Modified: head/sys/compat/linuxkpi/common/include/linux/uaccess.h
==
--- head/sys/compat/linuxkpi/common/include/linux/uaccess.h Thu May 16 
17:41:16 2019(r347836)
+++ head/sys/compat/linuxkpi/common/include/linux/uaccess.h Thu May 16 
17:44:17 2019(r347837)
@@ -60,12 +60,17 @@
 #defineget_user(_x, _p)linux_copyin((_p), &(_x), sizeof(*(_p)))
 #defineput_user(_x, _p)__put_user(_x, _p)
 #defineclear_user(...) linux_clear_user(__VA_ARGS__)
-#defineaccess_ok(...)  linux_access_ok(__VA_ARGS__)
 
+#if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION >= 5
+#defineaccess_ok(a,b)  linux_access_ok(a,b)
+#else
+#defineaccess_ok(a,b,c)linux_access_ok(b,c)
+#endif
+
 extern int linux_copyin(const void *uaddr, void *kaddr, size_t len);
 extern int linux_copyout(const void *kaddr, void *uaddr, size_t len);
 extern size_t linux_clear_user(void *uaddr, size_t len);
-extern int linux_access_ok(int rw, const void *uaddr, size_t len);
+extern int linux_access_ok(const void *uaddr, size_t len);
 
 /*
  * NOTE: Each pagefault_disable() call must have a corresponding

Modified: head/sys/compat/linuxkpi/common/src/linux_compat.c
==
--- head/sys/compat/linuxkpi/common/src/linux_compat.c  Thu May 16 17:41:16 
2019(r347836)
+++ head/sys/compat/linuxkpi/common/src/linux_compat.c  Thu May 16 17:44:17 
2019(r347837)
@@ -897,7 +897,7 @@ linux_clear_user(void *_uaddr, size_t _len)
 }
 
 int
-linux_access_ok(int rw, const void *uaddr, size_t len)
+linux_access_ok(const void *uaddr, size_t len)
 {
uintptr_t saddr;
uintptr_t eaddr;
___
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: r347836 - in head: sys/arm64/arm64 sys/arm64/include sys/compat/linuxkpi/common/src sys/sys sys/x86/include sys/x86/iommu sys/x86/x86 usr.sbin/camdd

2019-05-16 Thread Tycho Nightingale
Author: tychon
Date: Thu May 16 17:41:16 2019
New Revision: 347836
URL: https://svnweb.freebsd.org/changeset/base/347836

Log:
  Allow loading the same DMA address multiple times without any prior
  unload for the LinuxKPI.
  
  Reviewed by:  kib, zeising
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D20181

Modified:
  head/sys/arm64/arm64/busdma_bounce.c
  head/sys/arm64/include/bus_dma.h
  head/sys/arm64/include/bus_dma_impl.h
  head/sys/compat/linuxkpi/common/src/linux_pci.c
  head/sys/sys/bus_dma.h
  head/sys/x86/include/bus_dma.h
  head/sys/x86/include/busdma_impl.h
  head/sys/x86/iommu/busdma_dmar.c
  head/sys/x86/x86/busdma_bounce.c
  head/usr.sbin/camdd/camdd.c

Modified: head/sys/arm64/arm64/busdma_bounce.c
==
--- head/sys/arm64/arm64/busdma_bounce.cThu May 16 17:38:59 2019
(r347835)
+++ head/sys/arm64/arm64/busdma_bounce.cThu May 16 17:41:16 2019
(r347836)
@@ -152,6 +152,8 @@ static bus_addr_t add_bounce_page(bus_dma_tag_t dmat, 
 vm_offset_t vaddr, bus_addr_t addr, bus_size_t size);
 static void free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage);
 int run_filter(bus_dma_tag_t dmat, bus_addr_t paddr);
+static bool _bus_dmamap_pagesneeded(bus_dma_tag_t dmat, vm_paddr_t buf,
+bus_size_t buflen, int *pagesneeded);
 static void _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map,
 pmap_t pmap, void *buf, bus_size_t buflen, int flags);
 static void _bus_dmamap_count_phys(bus_dma_tag_t dmat, bus_dmamap_t map,
@@ -271,6 +273,15 @@ out:
return (error);
 }
 
+static bool
+bounce_bus_dma_id_mapped(bus_dma_tag_t dmat, vm_paddr_t buf, bus_size_t buflen)
+{
+
+   if ((dmat->bounce_flags & BF_COULD_BOUNCE) == 0)
+   return (true);
+   return (!_bus_dmamap_pagesneeded(dmat, buf, buflen, NULL));
+}
+
 static bus_dmamap_t
 alloc_dmamap(bus_dma_tag_t dmat, int flags)
 {
@@ -539,29 +550,45 @@ bounce_bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr
dmat->bounce_flags);
 }
 
+static bool
+_bus_dmamap_pagesneeded(bus_dma_tag_t dmat, vm_paddr_t buf, bus_size_t buflen,
+int *pagesneeded)
+{
+   bus_addr_t curaddr;
+   bus_size_t sgsize;
+   int count;
+
+   /*
+* Count the number of bounce pages needed in order to
+* complete this transfer
+*/
+   count = 0;
+   curaddr = buf;
+   while (buflen != 0) {
+   sgsize = MIN(buflen, dmat->common.maxsegsz);
+   if (bus_dma_run_filter(>common, curaddr)) {
+   sgsize = MIN(sgsize,
+   PAGE_SIZE - (curaddr & PAGE_MASK));
+   if (pagesneeded == NULL)
+   return (true);
+   count++;
+   }
+   curaddr += sgsize;
+   buflen -= sgsize;
+   }
+
+   if (pagesneeded != NULL)
+   *pagesneeded = count;
+   return (count != 0);
+}
+
 static void
 _bus_dmamap_count_phys(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf,
 bus_size_t buflen, int flags)
 {
-   bus_addr_t curaddr;
-   bus_size_t sgsize;
 
if ((map->flags & DMAMAP_COULD_BOUNCE) != 0 && map->pagesneeded == 0) {
-   /*
-* Count the number of bounce pages
-* needed in order to complete this transfer
-*/
-   curaddr = buf;
-   while (buflen != 0) {
-   sgsize = MIN(buflen, dmat->common.maxsegsz);
-   if (bus_dma_run_filter(>common, curaddr)) {
-   sgsize = MIN(sgsize,
-   PAGE_SIZE - (curaddr & PAGE_MASK));
-   map->pagesneeded++;
-   }
-   curaddr += sgsize;
-   buflen -= sgsize;
-   }
+   _bus_dmamap_pagesneeded(dmat, buf, buflen, >pagesneeded);
CTR1(KTR_BUSDMA, "pagesneeded= %d\n", map->pagesneeded);
}
 }
@@ -1316,6 +1343,7 @@ busdma_swi(void)
 struct bus_dma_impl bus_dma_bounce_impl = {
.tag_create = bounce_bus_dma_tag_create,
.tag_destroy = bounce_bus_dma_tag_destroy,
+   .id_mapped = bounce_bus_dma_id_mapped,
.map_create = bounce_bus_dmamap_create,
.map_destroy = bounce_bus_dmamap_destroy,
.mem_alloc = bounce_bus_dmamem_alloc,

Modified: head/sys/arm64/include/bus_dma.h
==
--- head/sys/arm64/include/bus_dma.hThu May 16 17:38:59 2019
(r347835)
+++ head/sys/arm64/include/bus_dma.hThu May 16 17:41:16 2019
(r347836)
@@ -9,6 +9,18 @@
 #include 
 
 /*
+ * Is DMA address 1:1 mapping of physical address
+ */
+static inline bool
+bus_dma_id_mapped(bus_dma_tag_t dmat, vm_paddr_t buf, 

svn commit: r347828 - head/sys/dev/xdma

2019-05-16 Thread Conrad Meyer
Author: cem
Date: Thu May 16 17:34:36 2019
New Revision: 347828
URL: https://svnweb.freebsd.org/changeset/base/347828

Log:
  xdma(4): Fix invalid pointer use (breaks arm.SOCFPGA build)
  
  In xdma_handle_mem_node(), vmem_size_t and vmem_addr_t pointers were passed to
  an FDT API that emits u_long values to the output parameter pointer.  This
  broke on systems with both xdma and 32-bit vmem size/addr types (SOCFPGA).
  
  Reported by:  tinderbox
  Sponsored by: Dell EMC Isilon

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

Modified: head/sys/dev/xdma/xdma.c
==
--- head/sys/dev/xdma/xdma.cThu May 16 17:34:09 2019(r347827)
+++ head/sys/dev/xdma/xdma.cThu May 16 17:34:36 2019(r347828)
@@ -312,8 +312,7 @@ xdma_handle_mem_node(vmem_t *vmem, phandle_t memory)
pcell_t *regp;
int addr_cells, size_cells;
int i, reg_len, ret, tuple_size, tuples;
-   vmem_addr_t mem_start;
-   vmem_size_t mem_size;
+   u_long mem_start, mem_size;
 
if ((ret = fdt_addrsize_cells(OF_parent(memory), _cells,
_cells)) != 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: r347795 - head/sys/arm64/arm64

2019-05-16 Thread Justin Hibbits
Author: jhibbits
Date: Thu May 16 17:04:29 2019
New Revision: 347795
URL: https://svnweb.freebsd.org/changeset/base/347795

Log:
  arm64: Add the rename interpreter path for compat32 ld-elf
  
  Let arm64 and arm32 dynamic binaries coexist.  Match all other compat32
  archs.
  
  Reviewed by:  manu
  Sponsored by: Juniper Networks, Inc

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

Modified: head/sys/arm64/arm64/elf32_machdep.c
==
--- head/sys/arm64/arm64/elf32_machdep.cThu May 16 17:04:15 2019
(r347794)
+++ head/sys/arm64/arm64/elf32_machdep.cThu May 16 17:04:29 2019
(r347795)
@@ -115,7 +115,7 @@ static Elf32_Brandinfo freebsd32_brand_info = {
.emul_path  = NULL,
.interp_path= "/libexec/ld-elf.so.1",
.sysvec = _freebsd_sysvec,
-   .interp_newpath = NULL,
+   .interp_newpath = "/libexec/ld-elf32.so.1",
.brand_note = _freebsd_brandnote,
.flags  = BI_CAN_EXEC_DYN | BI_BRAND_NOTE,
.header_supported= elf32_arm_abi_supported,
___
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: r347703 - head/sys/dev/ae

2019-05-16 Thread Brooks Davis
Author: brooks
Date: Thu May 16 15:22:17 2019
New Revision: 347703
URL: https://svnweb.freebsd.org/changeset/base/347703

Log:
  FCP-101: ae(4) is sufficently popular to be moved to the keep list.

Modified:
  head/sys/dev/ae/if_ae.c

Modified: head/sys/dev/ae/if_ae.c
==
--- head/sys/dev/ae/if_ae.c Thu May 16 14:48:08 2019(r347702)
+++ head/sys/dev/ae/if_ae.c Thu May 16 15:22:17 2019(r347703)
@@ -396,8 +396,6 @@ ae_attach(device_t dev)
goto fail;
}
 
-   gone_by_fcp101_dev(dev);
-
 fail:
if (error != 0)
ae_detach(dev);
___
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: r347638 - in head: . etc lib/libc/gen

2019-05-16 Thread Bryan Drewery
usr.sbin/etcupdate/tests/preworld_test.sh:  
$SRC/etc/master.passwd


usr.sbin/mergemaster/mergemaster.sh:  cp -p 
${SOURCEDIR}/etc/master.passwd ${TEMPROOT}/etc &&


I suspect there are more places than these 2 that need to be fixed 
still. This was a very lazy grep.
Sadly I think it should be reverted until further tool analysis is done. 
Both internal and external.


Why a subdir of libc rather than just libc/? This is very oddly placed. 
Is there a libc-gen package?


On 2019-05-16 11:05, Conrad Meyer wrote:

Hi Brad,

Can you revert this?  It seems to break every config-management tool
we have (mergemaster, etcupdate, beinstall ...).

Additionally, I don't believe this move has been justified — the cons
seem to outweigh the pros, if there are any.  I skimmed the
differential and it was not immediately obvious what the benefit was.
The commit message describes what was changed, but not *why* you
thought it was a good idea.

Thanks,
Conrad

On Wed, May 15, 2019 at 6:09 PM Brad Davis  wrote:


Author: brd
Date: Thu May 16 01:09:13 2019
New Revision: 347638
URL: https://svnweb.freebsd.org/changeset/base/347638

Log:
  Move master.passwd and group to lib/libc/gen/

  libc was picked as the destination location for these because of the 
syscalls

  that use these files as the lowest level place they are referenced.

  Approved by:  will (mentor), rgrimes, manu
  Differential Revision:https://reviews.freebsd.org/D16728

Added:
  head/lib/libc/gen/group
 - copied unchanged from r347637, head/etc/group
  head/lib/libc/gen/master.passwd
 - copied unchanged from r347637, head/etc/master.passwd
Deleted:
  head/etc/group
  head/etc/master.passwd
Modified:
  head/Makefile.inc1
  head/etc/Makefile
  head/lib/libc/gen/Makefile.inc

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Thu May 16 00:53:54 2019(r347637)
+++ head/Makefile.inc1  Thu May 16 01:09:13 2019(r347638)
@@ -871,8 +871,8 @@ DB_FROM_SRC=yes
 .endif

 .if defined(DB_FROM_SRC)
-INSTALLFLAGS+= -N ${.CURDIR}/etc
-MTREEFLAGS+=   -N ${.CURDIR}/etc
+INSTALLFLAGS+= -N ${.CURDIR}/lib/libc/gen
+MTREEFLAGS+=   -N ${.CURDIR}/lib/libc/gen
 .endif
 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
 INSTALL_DDIR=  ${_INSTALL_DDIR:S://:/:g:C:/$::}

Modified: head/etc/Makefile
==
--- head/etc/Makefile   Thu May 16 00:53:54 2019(r347637)
+++ head/etc/Makefile   Thu May 16 01:09:13 2019(r347638)
@@ -15,7 +15,6 @@ SUBDIR+=sendmail
 .endif

 BIN1=  \
-   group \
login.access \
rc.bsdextended \
rc.firewall \
@@ -65,21 +64,7 @@ distribution:
 .endif
cd ${.CURDIR}; \
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
-   ${BIN1} ${DESTDIR}/etc; \
-   ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
-   master.passwd ${DESTDIR}/etc;
-
-.if ${MK_TCSH} == "no"
-   sed -i "" -e 's;/bin/csh;/bin/sh;' 
${DESTDIR}/etc/master.passwd

-.endif
-   pwd_mkdb -i -p -d ${DESTDIR}/etc ${DESTDIR}/etc/master.passwd
-.if defined(NO_ROOT)
-   ( \
-   echo "./etc/passwd type=file mode=0644 uname=root 
gname=wheel"; \
-   echo "./etc/pwd.db type=file mode=0644 uname=root 
gname=wheel"; \
-   echo "./etc/spwd.db type=file mode=0600 uname=root 
gname=wheel"; \

-   ) | ${METALOG.add}
-.endif
+   ${BIN1} ${DESTDIR}/etc
${_+_}cd ${.CURDIR}/gss; ${MAKE} install
${_+_}cd ${.CURDIR}/mtree; ${MAKE} install
${_+_}cd ${SRCTOP}/share/termcap; ${MAKE} etc-termcap

Modified: head/lib/libc/gen/Makefile.inc
==
--- head/lib/libc/gen/Makefile.inc  Thu May 16 00:53:54 2019   
 (r347637)
+++ head/lib/libc/gen/Makefile.inc  Thu May 16 01:09:13 2019   
 (r347638)

@@ -4,7 +4,8 @@
 # machine-independent gen sources
 .PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/gen ${LIBC_SRCTOP}/gen

-CONFS= shells
+CONFS+=group master.passwd shells
+CONFSMODE_master.passwd=   600

 SRCS+= __getosreldate.c \
__pthread_mutex_init_calloc_cb_stub.c \
@@ -543,3 +544,16 @@ MLINKS+=vis.3 nvis.3 \
vis.3 svis.3

 MLINKS+=wordexp.3 wordfree.3
+
+afterinstallconfig:
+.if ${MK_TCSH} == "no"
+   sed -i "" -e 's;/bin/csh;/bin/sh;' 
${DESTDIR}/etc/master.passwd

+.endif
+   pwd_mkdb -i -p -d ${DESTDIR}/etc ${DESTDIR}/etc/master.passwd
+.if defined(NO_ROOT) && defined(METALOG)
+   ( \
+   echo "./etc/pwd.db type=file mode=0644 uname=root 
gname=wheel"; \
+   echo "./etc/spwd.db type=file mode=0600 uname=root 
gname=wheel"; \
+   echo "./etc/passwd type=file mode=0644 uname=root 
gname=wheel"; \

+   ) | cat -l >> ${METALOG}
+.endif

Copied: head/lib/libc/gen/group (from r347637, head/etc/group)

Re: svn commit: r347638 - in head: . etc lib/libc/gen

2019-05-16 Thread Conrad Meyer
Hi Brad,

Can you revert this?  It seems to break every config-management tool
we have (mergemaster, etcupdate, beinstall ...).

Additionally, I don't believe this move has been justified — the cons
seem to outweigh the pros, if there are any.  I skimmed the
differential and it was not immediately obvious what the benefit was.
The commit message describes what was changed, but not *why* you
thought it was a good idea.

Thanks,
Conrad

On Wed, May 15, 2019 at 6:09 PM Brad Davis  wrote:
>
> Author: brd
> Date: Thu May 16 01:09:13 2019
> New Revision: 347638
> URL: https://svnweb.freebsd.org/changeset/base/347638
>
> Log:
>   Move master.passwd and group to lib/libc/gen/
>
>   libc was picked as the destination location for these because of the 
> syscalls
>   that use these files as the lowest level place they are referenced.
>
>   Approved by:  will (mentor), rgrimes, manu
>   Differential Revision:https://reviews.freebsd.org/D16728
>
> Added:
>   head/lib/libc/gen/group
>  - copied unchanged from r347637, head/etc/group
>   head/lib/libc/gen/master.passwd
>  - copied unchanged from r347637, head/etc/master.passwd
> Deleted:
>   head/etc/group
>   head/etc/master.passwd
> Modified:
>   head/Makefile.inc1
>   head/etc/Makefile
>   head/lib/libc/gen/Makefile.inc
>
> Modified: head/Makefile.inc1
> ==
> --- head/Makefile.inc1  Thu May 16 00:53:54 2019(r347637)
> +++ head/Makefile.inc1  Thu May 16 01:09:13 2019(r347638)
> @@ -871,8 +871,8 @@ DB_FROM_SRC=yes
>  .endif
>
>  .if defined(DB_FROM_SRC)
> -INSTALLFLAGS+= -N ${.CURDIR}/etc
> -MTREEFLAGS+=   -N ${.CURDIR}/etc
> +INSTALLFLAGS+= -N ${.CURDIR}/lib/libc/gen
> +MTREEFLAGS+=   -N ${.CURDIR}/lib/libc/gen
>  .endif
>  _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
>  INSTALL_DDIR=  ${_INSTALL_DDIR:S://:/:g:C:/$::}
>
> Modified: head/etc/Makefile
> ==
> --- head/etc/Makefile   Thu May 16 00:53:54 2019(r347637)
> +++ head/etc/Makefile   Thu May 16 01:09:13 2019(r347638)
> @@ -15,7 +15,6 @@ SUBDIR+=sendmail
>  .endif
>
>  BIN1=  \
> -   group \
> login.access \
> rc.bsdextended \
> rc.firewall \
> @@ -65,21 +64,7 @@ distribution:
>  .endif
> cd ${.CURDIR}; \
> ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
> -   ${BIN1} ${DESTDIR}/etc; \
> -   ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
> -   master.passwd ${DESTDIR}/etc;
> -
> -.if ${MK_TCSH} == "no"
> -   sed -i "" -e 's;/bin/csh;/bin/sh;' ${DESTDIR}/etc/master.passwd
> -.endif
> -   pwd_mkdb -i -p -d ${DESTDIR}/etc ${DESTDIR}/etc/master.passwd
> -.if defined(NO_ROOT)
> -   ( \
> -   echo "./etc/passwd type=file mode=0644 uname=root 
> gname=wheel"; \
> -   echo "./etc/pwd.db type=file mode=0644 uname=root 
> gname=wheel"; \
> -   echo "./etc/spwd.db type=file mode=0600 uname=root 
> gname=wheel"; \
> -   ) | ${METALOG.add}
> -.endif
> +   ${BIN1} ${DESTDIR}/etc
> ${_+_}cd ${.CURDIR}/gss; ${MAKE} install
> ${_+_}cd ${.CURDIR}/mtree; ${MAKE} install
> ${_+_}cd ${SRCTOP}/share/termcap; ${MAKE} etc-termcap
>
> Modified: head/lib/libc/gen/Makefile.inc
> ==
> --- head/lib/libc/gen/Makefile.inc  Thu May 16 00:53:54 2019
> (r347637)
> +++ head/lib/libc/gen/Makefile.inc  Thu May 16 01:09:13 2019
> (r347638)
> @@ -4,7 +4,8 @@
>  # machine-independent gen sources
>  .PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/gen ${LIBC_SRCTOP}/gen
>
> -CONFS= shells
> +CONFS+=group master.passwd shells
> +CONFSMODE_master.passwd=   600
>
>  SRCS+= __getosreldate.c \
> __pthread_mutex_init_calloc_cb_stub.c \
> @@ -543,3 +544,16 @@ MLINKS+=vis.3 nvis.3 \
> vis.3 svis.3
>
>  MLINKS+=wordexp.3 wordfree.3
> +
> +afterinstallconfig:
> +.if ${MK_TCSH} == "no"
> +   sed -i "" -e 's;/bin/csh;/bin/sh;' ${DESTDIR}/etc/master.passwd
> +.endif
> +   pwd_mkdb -i -p -d ${DESTDIR}/etc ${DESTDIR}/etc/master.passwd
> +.if defined(NO_ROOT) && defined(METALOG)
> +   ( \
> +   echo "./etc/pwd.db type=file mode=0644 uname=root 
> gname=wheel"; \
> +   echo "./etc/spwd.db type=file mode=0600 uname=root 
> gname=wheel"; \
> +   echo "./etc/passwd type=file mode=0644 uname=root 
> gname=wheel"; \
> +   ) | cat -l >> ${METALOG}
> +.endif
>
> Copied: head/lib/libc/gen/group (from r347637, head/etc/group)
> ==
> --- /dev/null   00:00:00 1970   (empty, because file is newly added)
> +++ head/lib/libc/gen/group Thu May 16 01:09:13 2019(r347638, 
> copy of r347637, head/etc/group)
> @@ -0,0 +1,36 @@
> +# $FreeBSD$
> +#
> +wheel:*:0:root
> +daemon:*:1:
> 

svn commit: r347698 - head/sys/amd64/amd64

2019-05-16 Thread Konstantin Belousov
Author: kib
Date: Thu May 16 14:33:32 2019
New Revision: 347698
URL: https://svnweb.freebsd.org/changeset/base/347698

Log:
  amd64 pmap: sysctl vm.pmap.pcid_save_cnt should be read-only.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

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

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Thu May 16 14:29:09 2019(r347697)
+++ head/sys/amd64/amd64/pmap.c Thu May 16 14:33:32 2019(r347698)
@@ -466,7 +466,7 @@ pmap_pcid_save_cnt_proc(SYSCTL_HANDLER_ARGS)
}
return (sysctl_handle_64(oidp, , 0, req));
 }
-SYSCTL_PROC(_vm_pmap, OID_AUTO, pcid_save_cnt, CTLTYPE_U64 | CTLFLAG_RW |
+SYSCTL_PROC(_vm_pmap, OID_AUTO, pcid_save_cnt, CTLTYPE_U64 | CTLFLAG_RD |
 CTLFLAG_MPSAFE, NULL, 0, pmap_pcid_save_cnt_proc, "QU",
 "Count of saved TLB context on switch");
 
___
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: r347697 - head/sys/amd64/amd64

2019-05-16 Thread Konstantin Belousov
Author: kib
Date: Thu May 16 14:29:09 2019
New Revision: 347697
URL: https://svnweb.freebsd.org/changeset/base/347697

Log:
  amd64 pmap: Add tunable vm.pmap.di_locked to set DI mode.
  
  This is done mostly for debugging in field.  Also added the sysctl of
  the same name to report used mode.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:1 month

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

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Thu May 16 13:40:54 2019(r347696)
+++ head/sys/amd64/amd64/pmap.c Thu May 16 14:29:09 2019(r347697)
@@ -486,13 +486,36 @@ static u_long pmap_invl_gen = 1;
 #definePMAP_ASSERT_NOT_IN_DI() \
 KASSERT(pmap_not_in_di(), ("DI already started"))
 
+static bool
+pmap_di_locked(void)
+{
+   int tun;
+
+   if ((cpu_feature2 & CPUID2_CX16) == 0)
+   return (true);
+   tun = 0;
+   TUNABLE_INT_FETCH("vm.pmap.di_locked", );
+   return (tun != 0);
+}
+
+static int
+sysctl_pmap_di_locked(SYSCTL_HANDLER_ARGS)
+{
+   int locked;
+
+   locked = pmap_di_locked();
+   return (sysctl_handle_int(oidp, , 0, req));
+}
+SYSCTL_PROC(_vm_pmap, OID_AUTO, di_locked, CTLTYPE_INT | CTLFLAG_RDTUN |
+CTLFLAG_MPSAFE, 0, 0, sysctl_pmap_di_locked, "",
+"Locked delayed invalidation");
+
 static bool pmap_not_in_di_l(void);
 static bool pmap_not_in_di_u(void);
 DEFINE_IFUNC(, bool, pmap_not_in_di, (void), static)
 {
 
-   return ((cpu_feature2 & CPUID2_CX16) == 0 ? pmap_not_in_di_l :
-   pmap_not_in_di_u);
+   return (pmap_di_locked() ? pmap_not_in_di_l : pmap_not_in_di_u);
 }
 
 static bool
@@ -933,29 +956,29 @@ pmap_delayed_invl_wait_u(vm_page_t m)
 DEFINE_IFUNC(, void, pmap_thread_init_invl_gen, (struct thread *), static)
 {
 
-   return ((cpu_feature2 & CPUID2_CX16) == 0 ?
-   pmap_thread_init_invl_gen_l : pmap_thread_init_invl_gen_u);
+   return (pmap_di_locked() ? pmap_thread_init_invl_gen_l :
+   pmap_thread_init_invl_gen_u);
 }
 
 DEFINE_IFUNC(static, void, pmap_delayed_invl_start, (void), static)
 {
 
-   return ((cpu_feature2 & CPUID2_CX16) == 0 ?
-   pmap_delayed_invl_start_l : pmap_delayed_invl_start_u);
+   return (pmap_di_locked() ? pmap_delayed_invl_start_l :
+   pmap_delayed_invl_start_u);
 }
 
 DEFINE_IFUNC(static, void, pmap_delayed_invl_finish, (void), static)
 {
 
-   return ((cpu_feature2 & CPUID2_CX16) == 0 ?
-   pmap_delayed_invl_finish_l : pmap_delayed_invl_finish_u);
+   return (pmap_di_locked() ? pmap_delayed_invl_finish_l :
+   pmap_delayed_invl_finish_u);
 }
 
 DEFINE_IFUNC(static, void, pmap_delayed_invl_wait, (vm_page_t), static)
 {
 
-   return ((cpu_feature2 & CPUID2_CX16) == 0 ?
-   pmap_delayed_invl_wait_l : pmap_delayed_invl_wait_u);
+   return (pmap_di_locked() ? pmap_delayed_invl_wait_l :
+   pmap_delayed_invl_wait_u);
 }
 
 /*
___
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: r347696 - head/sys/amd64/amd64

2019-05-16 Thread Konstantin Belousov
Author: kib
Date: Thu May 16 13:40:54 2019
New Revision: 347696
URL: https://svnweb.freebsd.org/changeset/base/347696

Log:
  amd64 pmap: Rename DI functions.
  
  pmap_delayed_invl_started -> pmap_delayed_invl_start
  pmap_delayed_invl_finished -> pmap_delayed_invl_finish
  
  Requested by: markj
  Sponsored by: The FreeBSD Foundation
  MFC after:1 month

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

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Thu May 16 13:28:48 2019(r347695)
+++ head/sys/amd64/amd64/pmap.c Thu May 16 13:40:54 2019(r347696)
@@ -522,7 +522,7 @@ pmap_thread_init_invl_gen_l(struct thread *td)
  * pmap active.
  */
 static void
-pmap_delayed_invl_started_l(void)
+pmap_delayed_invl_start_l(void)
 {
struct pmap_invl_gen *invl_gen;
u_long currgen;
@@ -554,13 +554,13 @@ pmap_delayed_invl_started_l(void)
  * current thread's DI.
  */
 static void
-pmap_delayed_invl_finished_l(void)
+pmap_delayed_invl_finish_l(void)
 {
struct pmap_invl_gen *invl_gen, *next;
struct turnstile *ts;
 
invl_gen = >td_md.md_invl_gen;
-   KASSERT(invl_gen->gen != 0, ("missed invl_started"));
+   KASSERT(invl_gen->gen != 0, ("missed invl_start"));
mtx_lock(_gen_mtx);
next = LIST_NEXT(invl_gen, link);
if (next == NULL) {
@@ -662,7 +662,7 @@ static struct lock_delay_config __read_frequently di_d
 LOCK_DELAY_SYSINIT_DEFAULT(di_delay);
 
 static void
-pmap_delayed_invl_started_u(void)
+pmap_delayed_invl_start_u(void)
 {
struct pmap_invl_gen *invl_gen, *p, prev, new_prev;
struct thread *td;
@@ -752,7 +752,7 @@ again:
 }
 
 static bool
-pmap_delayed_invl_finished_u_crit(struct pmap_invl_gen *invl_gen,
+pmap_delayed_invl_finish_u_crit(struct pmap_invl_gen *invl_gen,
 struct pmap_invl_gen *p)
 {
struct pmap_invl_gen prev, new_prev;
@@ -782,7 +782,7 @@ pmap_delayed_invl_finished_u_crit(struct pmap_invl_gen
 }
 
 static void
-pmap_delayed_invl_finished_u(void)
+pmap_delayed_invl_finish_u(void)
 {
struct pmap_invl_gen *invl_gen, *p;
struct thread *td;
@@ -821,7 +821,7 @@ again:
critical_enter();
atomic_set_ptr((uintptr_t *)_gen->next,
PMAP_INVL_GEN_NEXT_INVALID);
-   if (!pmap_delayed_invl_finished_u_crit(invl_gen, p)) {
+   if (!pmap_delayed_invl_finish_u_crit(invl_gen, p)) {
atomic_clear_ptr((uintptr_t *)_gen->next,
PMAP_INVL_GEN_NEXT_INVALID);
critical_exit();
@@ -937,18 +937,18 @@ DEFINE_IFUNC(, void, pmap_thread_init_invl_gen, (struc
pmap_thread_init_invl_gen_l : pmap_thread_init_invl_gen_u);
 }
 
-DEFINE_IFUNC(static, void, pmap_delayed_invl_started, (void), static)
+DEFINE_IFUNC(static, void, pmap_delayed_invl_start, (void), static)
 {
 
return ((cpu_feature2 & CPUID2_CX16) == 0 ?
-   pmap_delayed_invl_started_l : pmap_delayed_invl_started_u);
+   pmap_delayed_invl_start_l : pmap_delayed_invl_start_u);
 }
 
-DEFINE_IFUNC(static, void, pmap_delayed_invl_finished, (void), static)
+DEFINE_IFUNC(static, void, pmap_delayed_invl_finish, (void), static)
 {
 
return ((cpu_feature2 & CPUID2_CX16) == 0 ?
-   pmap_delayed_invl_finished_l : pmap_delayed_invl_finished_u);
+   pmap_delayed_invl_finish_l : pmap_delayed_invl_finish_u);
 }
 
 DEFINE_IFUNC(static, void, pmap_delayed_invl_wait, (vm_page_t), static)
@@ -967,7 +967,7 @@ DEFINE_IFUNC(static, void, pmap_delayed_invl_wait, (vm
  * The function works by setting the DI generation number for m's PV
  * list to at least the DI generation number of the current thread.
  * This forces a caller of pmap_delayed_invl_wait() to block until
- * current thread calls pmap_delayed_invl_finished().
+ * current thread calls pmap_delayed_invl_finish().
  */
 static void
 pmap_delayed_invl_page(vm_page_t m)
@@ -3793,7 +3793,7 @@ reclaim_pv_chunk_leave_pmap(pmap_t pmap, pmap_t locked
if (pmap != locked_pmap)
PMAP_UNLOCK(pmap);
if (start_di)
-   pmap_delayed_invl_finished();
+   pmap_delayed_invl_finish();
 }
 
 /*
@@ -3876,13 +3876,13 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l
RELEASE_PV_LIST_LOCK(lockp);
PMAP_LOCK(pmap);
if (start_di)
-   pmap_delayed_invl_started();
+   pmap_delayed_invl_start();
mtx_lock(_chunks_mutex);
continue;
} else if (pmap != locked_pmap) {
if (PMAP_TRYLOCK(pmap)) {
if (start_di)
-   pmap_delayed_invl_started();
+   

svn commit: r347695 - in head/sys: amd64/amd64 amd64/include kern

2019-05-16 Thread Konstantin Belousov
Author: kib
Date: Thu May 16 13:28:48 2019
New Revision: 347695
URL: https://svnweb.freebsd.org/changeset/base/347695

Log:
  amd64 pmap: rework delayed invalidation, removing global mutex.
  
  For machines having cmpxcgh16b instruction, i.e. everything but very
  early Athlons, provide lockless implementation of delayed
  invalidation.
  
  The implementation maintains lock-less single-linked list with the
  trick from the T.L. Harris article about volatile mark of the elements
  being removed. Double-CAS is used to atomically update both link and
  generation.  New thread starting DI appends itself to the end of the
  queue, setting the generation to the generation of the last element
  +1.  On DI finish, thread donates its generation to the previous
  element.  The generation of the fake head of the list is the last
  passed DI generation.  Basically, the implementation is a queued
  spinlock but without spinlock.
  
  Many thanks both to Peter Holm and Mark Johnson for keeping with me
  while I produced intermediate versions of the patch.
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 month
  MFC note: td_md.md_invl_gen should go to the end of struct thread
  Differential revision:https://reviews.freebsd.org/D19630

Modified:
  head/sys/amd64/amd64/pmap.c
  head/sys/amd64/amd64/trap.c
  head/sys/amd64/amd64/vm_machdep.c
  head/sys/amd64/include/pmap.h
  head/sys/amd64/include/proc.h
  head/sys/kern/kern_thread.c

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Thu May 16 13:17:57 2019(r347694)
+++ head/sys/amd64/amd64/pmap.c Thu May 16 13:28:48 2019(r347695)
@@ -107,6 +107,7 @@ __FBSDID("$FreeBSD$");
  * and to when physical maps must be made correct.
  */
 
+#include "opt_ddb.h"
 #include "opt_pmap.h"
 #include "opt_vm.h"
 
@@ -130,6 +131,10 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#ifdef DDB
+#include 
+#include 
+#endif
 
 #include 
 #include 
@@ -468,22 +473,46 @@ SYSCTL_PROC(_vm_pmap, OID_AUTO, pcid_save_cnt, CTLTYPE
 static LIST_HEAD(, pmap_invl_gen) pmap_invl_gen_tracker =
 LIST_HEAD_INITIALIZER(_invl_gen_tracker);
 static struct mtx invl_gen_mtx;
-static u_long pmap_invl_gen = 0;
 /* Fake lock object to satisfy turnstiles interface. */
 static struct lock_object invl_gen_ts = {
.lo_name = "invlts",
 };
+static struct pmap_invl_gen pmap_invl_gen_head = {
+   .gen = 1,
+   .next = NULL,
+};
+static u_long pmap_invl_gen = 1;
 
+#definePMAP_ASSERT_NOT_IN_DI() \
+KASSERT(pmap_not_in_di(), ("DI already started"))
+
+static bool pmap_not_in_di_l(void);
+static bool pmap_not_in_di_u(void);
+DEFINE_IFUNC(, bool, pmap_not_in_di, (void), static)
+{
+
+   return ((cpu_feature2 & CPUID2_CX16) == 0 ? pmap_not_in_di_l :
+   pmap_not_in_di_u);
+}
+
 static bool
-pmap_not_in_di(void)
+pmap_not_in_di_l(void)
 {
+   struct pmap_invl_gen *invl_gen;
 
-   return (curthread->td_md.md_invl_gen.gen == 0);
+   invl_gen = >td_md.md_invl_gen;
+   return (invl_gen->gen == 0);
 }
 
-#definePMAP_ASSERT_NOT_IN_DI() \
-KASSERT(pmap_not_in_di(), ("DI already started"))
+static void
+pmap_thread_init_invl_gen_l(struct thread *td)
+{
+   struct pmap_invl_gen *invl_gen;
 
+   invl_gen = >td_md.md_invl_gen;
+   invl_gen->gen = 0;
+}
+
 /*
  * Start a new Delayed Invalidation (DI) block of code, executed by
  * the current thread.  Within a DI block, the current thread may
@@ -493,7 +522,7 @@ pmap_not_in_di(void)
  * pmap active.
  */
 static void
-pmap_delayed_invl_started(void)
+pmap_delayed_invl_started_l(void)
 {
struct pmap_invl_gen *invl_gen;
u_long currgen;
@@ -525,7 +554,7 @@ pmap_delayed_invl_started(void)
  * current thread's DI.
  */
 static void
-pmap_delayed_invl_finished(void)
+pmap_delayed_invl_finished_l(void)
 {
struct pmap_invl_gen *invl_gen, *next;
struct turnstile *ts;
@@ -551,7 +580,285 @@ pmap_delayed_invl_finished(void)
invl_gen->gen = 0;
 }
 
+static bool
+pmap_not_in_di_u(void)
+{
+   struct pmap_invl_gen *invl_gen;
+
+   invl_gen = >td_md.md_invl_gen;
+   return (((uintptr_t)invl_gen->next & PMAP_INVL_GEN_NEXT_INVALID) != 0);
+}
+
+static void
+pmap_thread_init_invl_gen_u(struct thread *td)
+{
+   struct pmap_invl_gen *invl_gen;
+
+   invl_gen = >td_md.md_invl_gen;
+   invl_gen->gen = 0;
+   invl_gen->next = (void *)PMAP_INVL_GEN_NEXT_INVALID;
+}
+
+static bool
+pmap_di_load_invl(struct pmap_invl_gen *ptr, struct pmap_invl_gen *out)
+{
+   uint64_t new_high, new_low, old_high, old_low;
+   char res;
+
+   old_low = new_low = 0;
+   old_high = new_high = (uintptr_t)0;
+
+   __asm volatile("lock;cmpxchg16b\t%1;sete\t%0"
+   : "=r" (res), "+m" (*ptr), "+a" (old_low), "+d" (old_high)
+   : "b"(new_low), "c" (new_high)
+  

Re: svn commit: r347691 - in head/sys: netinet netinet6

2019-05-16 Thread Hans Petter Selasky

On 2019-05-16 15:04, Mark Johnston wrote:

Author: markj
Date: Thu May 16 13:04:26 2019
New Revision: 347691
URL: https://svnweb.freebsd.org/changeset/base/347691

Log:
   Revert r347582 for now.
   
   The inp lock still needs to be dropped when calling into the driver ioctl

   handler, as some drivers expect to be able to sleep.
   
   Reported by:	kib




Hi Mark,

May I ask people to not touch *anything* in the multicast code until the 
following two differential revisions are completed:


https://reviews.freebsd.org/D20080
https://reviews.freebsd.org/D20109

--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: r347694 - head/sys/kern

2019-05-16 Thread Konstantin Belousov
Author: kib
Date: Thu May 16 13:17:57 2019
New Revision: 347694
URL: https://svnweb.freebsd.org/changeset/base/347694

Log:
  subr_turnstile: Extract some common  code to a helper.
  
  Code walks the list of contested turnstiles to calculate the priority
  to unlend.
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/kern/subr_turnstile.c

Modified: head/sys/kern/subr_turnstile.c
==
--- head/sys/kern/subr_turnstile.c  Thu May 16 13:13:33 2019
(r347693)
+++ head/sys/kern/subr_turnstile.c  Thu May 16 13:17:57 2019
(r347694)
@@ -897,6 +897,24 @@ turnstile_broadcast(struct turnstile *ts, int queue)
}
 }
 
+static u_char
+turnstile_calc_unlend_prio_locked(struct thread *td)
+{
+   struct turnstile *nts;
+   u_char cp, pri;
+
+   THREAD_LOCK_ASSERT(td, MA_OWNED);
+   mtx_assert(_contested_lock, MA_OWNED);
+
+   pri = PRI_MAX;
+   LIST_FOREACH(nts, >td_contested, ts_link) {
+   cp = turnstile_first_waiter(nts)->td_priority;
+   if (cp < pri)
+   pri = cp;
+   }
+   return (pri);
+}
+
 /*
  * Wakeup all threads on the pending list and adjust the priority of the
  * current thread appropriately.  This must be called with the turnstile
@@ -906,9 +924,8 @@ void
 turnstile_unpend(struct turnstile *ts)
 {
TAILQ_HEAD( ,thread) pending_threads;
-   struct turnstile *nts;
struct thread *td;
-   u_char cp, pri;
+   u_char pri;
 
MPASS(ts != NULL);
mtx_assert(>ts_lock, MA_OWNED);
@@ -932,7 +949,6 @@ turnstile_unpend(struct turnstile *ts)
 * priority however.
 */
td = curthread;
-   pri = PRI_MAX;
thread_lock(td);
mtx_lock_spin(_contested_lock);
/*
@@ -946,11 +962,7 @@ turnstile_unpend(struct turnstile *ts)
ts->ts_owner = NULL;
LIST_REMOVE(ts, ts_link);
}
-   LIST_FOREACH(nts, >td_contested, ts_link) {
-   cp = turnstile_first_waiter(nts)->td_priority;
-   if (cp < pri)
-   pri = cp;
-   }
+   pri = turnstile_calc_unlend_prio_locked(td);
mtx_unlock_spin(_contested_lock);
sched_unlend_prio(td, pri);
thread_unlock(td);
@@ -991,7 +1003,7 @@ void
 turnstile_disown(struct turnstile *ts)
 {
struct thread *td;
-   u_char cp, pri;
+   u_char pri;
 
MPASS(ts != NULL);
mtx_assert(>ts_lock, MA_OWNED);
@@ -1017,15 +1029,10 @@ turnstile_disown(struct turnstile *ts)
 * priority however.
 */
td = curthread;
-   pri = PRI_MAX;
thread_lock(td);
mtx_unlock_spin(>ts_lock);
mtx_lock_spin(_contested_lock);
-   LIST_FOREACH(ts, >td_contested, ts_link) {
-   cp = turnstile_first_waiter(ts)->td_priority;
-   if (cp < pri)
-   pri = cp;
-   }
+   pri = turnstile_calc_unlend_prio_locked(td);
mtx_unlock_spin(_contested_lock);
sched_unlend_prio(td, pri);
thread_unlock(td);
___
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: r347693 - head/libexec/rtld-elf

2019-05-16 Thread Konstantin Belousov
Author: kib
Date: Thu May 16 13:13:33 2019
New Revision: 347693
URL: https://svnweb.freebsd.org/changeset/base/347693

Log:
  rtld_malloc.c: cleanup morepages().
  
  Use roundup2() and rounddown2() instead of inlining them.
  Get rid of the fd local variable, use literal -1 for the mmap argument.
  Use MAP_FAILED as mmap(2) failure indicator.
  After that, apply some style.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

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

Modified: head/libexec/rtld-elf/rtld_malloc.c
==
--- head/libexec/rtld-elf/rtld_malloc.c Thu May 16 13:07:26 2019
(r347692)
+++ head/libexec/rtld-elf/rtld_malloc.c Thu May 16 13:13:33 2019
(r347693)
@@ -345,12 +345,11 @@ findbucket(union overhead *freep, int srchlen)
 static int
 morepages(int n)
 {
-   int fd = -1;
-   int offset;
+   caddr_t addr;
+   int offset;
 
if (pagepool_end - pagepool_start > pagesz) {
-   caddr_t addr = (caddr_t)
-   (((long)pagepool_start + pagesz - 1) & ~(pagesz - 1));
+   addr = (caddr_t)roundup2((long)pagepool_start, pagesz);
if (munmap(addr, pagepool_end - addr) != 0) {
 #ifdef IN_RTLD
rtld_fdprintf(STDERR_FILENO, _BASENAME_RTLD ": "
@@ -360,20 +359,21 @@ morepages(int n)
}
}
 
-   offset = (long)pagepool_start - ((long)pagepool_start & ~(pagesz - 1));
+   offset = (long)pagepool_start - rounddown2((long)pagepool_start,
+   pagesz);
 
-   if ((pagepool_start = mmap(0, n * pagesz,
-   PROT_READ|PROT_WRITE,
-   MAP_ANON|MAP_PRIVATE, fd, 0)) == (caddr_t)-1) {
+   pagepool_start = mmap(0, n * pagesz, PROT_READ | PROT_WRITE,
+   MAP_ANON | MAP_PRIVATE, -1, 0);
+   if (pagepool_start == MAP_FAILED) {
 #ifdef IN_RTLD
rtld_fdprintf(STDERR_FILENO, _BASENAME_RTLD ": morepages: "
"cannot mmap anonymous memory: %s\n",
rtld_strerror(errno));
 #endif
-   return 0;
+   return (0);
}
pagepool_end = pagepool_start + n * pagesz;
pagepool_start += offset;
 
-   return n;
+   return (n);
 }
___
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: r347692 - head/libexec/rtld-elf

2019-05-16 Thread Konstantin Belousov
Author: kib
Date: Thu May 16 13:07:26 2019
New Revision: 347692
URL: https://svnweb.freebsd.org/changeset/base/347692

Log:
  Remove more dead definitions from rtld_malloc.c after r347019.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

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

Modified: head/libexec/rtld-elf/rtld_malloc.c
==
--- head/libexec/rtld-elf/rtld_malloc.c Thu May 16 13:04:26 2019
(r347691)
+++ head/libexec/rtld-elf/rtld_malloc.c Thu May 16 13:07:26 2019
(r347692)
@@ -81,17 +81,13 @@ union   overhead {
} ovu;
 #defineov_magicovu.ovu_magic
 #defineov_indexovu.ovu_index
-#defineov_rmagic   ovu.ovu_rmagic
-#defineov_size ovu.ovu_size
 };
 
 static void morecore(int bucket);
 static int morepages(int n);
 static int findbucket(union overhead *freep, int srchlen);
 
-
 #defineMAGIC   0xef/* magic # on accounting info */
-#define RMAGIC 0x  /* magic # on range info */
 
 /*
  * nextf[i] is the pointer to the next free block of size 2^(i+3).  The
___
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: r347691 - in head/sys: netinet netinet6

2019-05-16 Thread Mark Johnston
Author: markj
Date: Thu May 16 13:04:26 2019
New Revision: 347691
URL: https://svnweb.freebsd.org/changeset/base/347691

Log:
  Revert r347582 for now.
  
  The inp lock still needs to be dropped when calling into the driver ioctl
  handler, as some drivers expect to be able to sleep.
  
  Reported by:  kib

Modified:
  head/sys/netinet/in_mcast.c
  head/sys/netinet6/in6_mcast.c

Modified: head/sys/netinet/in_mcast.c
==
--- head/sys/netinet/in_mcast.c Thu May 16 13:03:54 2019(r347690)
+++ head/sys/netinet/in_mcast.c Thu May 16 13:04:26 2019(r347691)
@@ -1534,7 +1534,6 @@ inp_block_unblock_source(struct inpcb *inp, struct soc
/*
 * Check if we are actually a member of this group.
 */
-   IN_MULTI_LOCK();
imo = inp_findmoptions(inp);
idx = imo_match_group(imo, ifp, >sa);
if (idx == -1 || imo->imo_mfilters == NULL) {
@@ -1594,13 +1593,14 @@ inp_block_unblock_source(struct inpcb *inp, struct soc
/*
 * Begin state merge transaction at IGMP layer.
 */
+   IN_MULTI_LOCK();
CTR1(KTR_IGMPV3, "%s: merge inm state", __func__);
IN_MULTI_LIST_LOCK();
error = inm_merge(inm, imf);
if (error) {
CTR1(KTR_IGMPV3, "%s: failed to merge inm state", __func__);
IN_MULTI_LIST_UNLOCK();
-   goto out_imf_rollback;
+   goto out_in_multi_locked;
}
 
CTR1(KTR_IGMPV3, "%s: doing igmp downcall", __func__);
@@ -1609,6 +1609,9 @@ inp_block_unblock_source(struct inpcb *inp, struct soc
if (error)
CTR1(KTR_IGMPV3, "%s: failed igmp downcall", __func__);
 
+out_in_multi_locked:
+
+   IN_MULTI_UNLOCK();
 out_imf_rollback:
if (error)
imf_rollback(imf);
@@ -1619,7 +1622,6 @@ out_imf_rollback:
 
 out_inp_locked:
INP_WUNLOCK(inp);
-   IN_MULTI_UNLOCK();
return (error);
 }
 
@@ -1678,10 +1680,10 @@ inp_findmoptions(struct inpcb *inp)
 static void
 inp_gcmoptions(struct ip_moptions *imo)
 {
-   struct in_mfilter *imf;
+   struct in_mfilter   *imf;
struct in_multi *inm;
struct ifnet *ifp;
-   size_t idx, nmships;
+   size_t   idx, nmships;
 
nmships = imo->imo_num_memberships;
for (idx = 0; idx < nmships; ++idx) {
@@ -2140,12 +2142,12 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt
CTR2(KTR_IGMPV3, "%s: unknown sopt_name %d",
__func__, sopt->sopt_name);
return (EOPNOTSUPP);
+   break;
}
 
if (ifp == NULL || (ifp->if_flags & IFF_MULTICAST) == 0)
return (EADDRNOTAVAIL);
 
-   IN_MULTI_LOCK();
imo = inp_findmoptions(inp);
idx = imo_match_group(imo, ifp, >sa);
if (idx == -1) {
@@ -2270,6 +2272,10 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt
/*
 * Begin state merge transaction at IGMP layer.
 */
+   in_pcbref(inp);
+   INP_WUNLOCK(inp);
+   IN_MULTI_LOCK();
+
if (is_new) {
error = in_joingroup_locked(ifp, >sin.sin_addr, imf,
);
@@ -2280,8 +2286,6 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt
goto out_imo_free;
}
inm_acquire(inm);
-   KASSERT(imo->imo_membership[idx] == NULL,
-   ("%s: imo_membership already allocated", __func__));
imo->imo_membership[idx] = inm;
} else {
CTR1(KTR_IGMPV3, "%s: merge inm state", __func__);
@@ -2291,7 +2295,7 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt
CTR1(KTR_IGMPV3, "%s: failed to merge inm state",
 __func__);
IN_MULTI_LIST_UNLOCK();
-   goto out_imf_rollback;
+   goto out_in_multi_locked;
}
CTR1(KTR_IGMPV3, "%s: doing igmp downcall", __func__);
error = igmp_change_state(inm);
@@ -2299,11 +2303,16 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt
if (error) {
CTR1(KTR_IGMPV3, "%s: failed igmp downcall",
__func__);
-   goto out_imf_rollback;
+   goto out_in_multi_locked;
}
}
 
-out_imf_rollback:
+out_in_multi_locked:
+
+   IN_MULTI_UNLOCK();
+   INP_WLOCK(inp);
+   if (in_pcbrele_wlocked(inp))
+   return (ENXIO);
if (error) {
imf_rollback(imf);
if (is_new)
@@ -2328,7 +2337,6 @@ out_imo_free:
 
 out_inp_locked:
INP_WUNLOCK(inp);
-   IN_MULTI_UNLOCK();
return (error);
 }
 
@@ -2455,7 +2463,6 @@ inp_leave_group(struct inpcb *inp, struct sockopt *sop
/*

svn commit: r347690 - head/sys/kern

2019-05-16 Thread Konstantin Belousov
Author: kib
Date: Thu May 16 13:03:54 2019
New Revision: 347690
URL: https://svnweb.freebsd.org/changeset/base/347690

Log:
  imgact_elf.c: Add comment explaining the malloc/VOP_UNLOCK() dance
  from r347148.
  
  Requested by: alc
  Sponsored by: The FreeBSD Foundation
  MFC after:3 days

Modified:
  head/sys/kern/imgact_elf.c

Modified: head/sys/kern/imgact_elf.c
==
--- head/sys/kern/imgact_elf.c  Thu May 16 13:00:35 2019(r347689)
+++ head/sys/kern/imgact_elf.c  Thu May 16 13:03:54 2019(r347690)
@@ -935,12 +935,22 @@ __elfN(get_interp)(struct image_params *imgp, const El
interp_name_len = phdr->p_filesz;
if (phdr->p_offset > PAGE_SIZE ||
interp_name_len > PAGE_SIZE - phdr->p_offset) {
+   /*
+* The vnode lock might be needed by pagedaemon to
+* clean pages owned by the vnode.  Do not allow sleep
+* waiting for memory with the vnode locked, instead
+* try non-sleepable allocation first, and if it
+* fails, go to the slow path were we drop the lock
+* and do M_WAITOK.  Text reference prevents
+* modifications of the vnode content.
+*/
interp = malloc(interp_name_len + 1, M_TEMP, M_NOWAIT);
if (interp == NULL) {
VOP_UNLOCK(imgp->vp, 0);
interp = malloc(interp_name_len + 1, M_TEMP, M_WAITOK);
vn_lock(imgp->vp, LK_SHARED | LK_RETRY);
}
+
error = vn_rdwr(UIO_READ, imgp->vp, interp,
interp_name_len, phdr->p_offset,
UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred,
___
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: r347689 - head/sys/arm64/arm64

2019-05-16 Thread Konstantin Belousov
Author: kib
Date: Thu May 16 13:00:35 2019
New Revision: 347689
URL: https://svnweb.freebsd.org/changeset/base/347689

Log:
  arm64: bzero buffer for ucontext in freebsd32_swapcontext().
  
  This change is the same as r340994 for amd64.
  
  PR:   237922
  Submitted by: Young 
  MFC after:3 days

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

Modified: head/sys/arm64/arm64/freebsd32_machdep.c
==
--- head/sys/arm64/arm64/freebsd32_machdep.cThu May 16 11:20:02 2019
(r347688)
+++ head/sys/arm64/arm64/freebsd32_machdep.cThu May 16 13:00:35 2019
(r347689)
@@ -284,6 +284,7 @@ freebsd32_swapcontext(struct thread *td, struct freebs
if (uap->oucp == NULL || uap->ucp == NULL)
ret = EINVAL;
else {
+   bzero(, sizeof(uc));
get_mcontext32(td, _mcontext, GET_MC_CLEAR_RET);
PROC_LOCK(td->td_proc);
uc.uc_sigmask = td->td_sigmask;
___
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: r347682 - head/share/man/man7

2019-05-16 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu May 16 09:49:19 2019
New Revision: 347682
URL: https://svnweb.freebsd.org/changeset/base/347682

Log:
  The "apropos ''" command no longer works; change development(7)
  to suggest "apropos ." instead.
  
  MFC after:2 weeks
  Sponsored by: DARPA, AFRL

Modified:
  head/share/man/man7/development.7

Modified: head/share/man/man7/development.7
==
--- head/share/man/man7/development.7   Thu May 16 09:33:38 2019
(r347681)
+++ head/share/man/man7/development.7   Thu May 16 09:49:19 2019
(r347682)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 6, 2018
+.Dd May 16, 2019
 .Dt DEVELOPMENT 7
 .Os
 .Sh NAME
@@ -83,7 +83,7 @@ and
 .Xr release 7 .
 Kernel programming interfaces (KPIs) are documented in section 9
 manual pages; use
-.Ql "apropos -s 9 ''"
+.Ql "apropos -s 9 ."
 for a list.
 Regression test suite is described in
 .Xr tests 7 .
___
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"