svn commit: r356827 - head/share/mk

2020-01-17 Thread Bryan Drewery
Author: bdrewery
Date: Fri Jan 17 14:29:27 2020
New Revision: 356827
URL: https://svnweb.freebsd.org/changeset/base/356827

Log:
  META_MODE: Allow 'make all install' to work with filemon.
  
  Filemon will add the ability to ignore the cookie if the installed file is
  missing. Without filemon that's not possible though so if the cookie is 
present
  an the command unchanged then the install wouldn't run.
  
  Sponsored by: DellEMC
  MFC after:2 weeks

Modified:
  head/share/mk/src.sys.env.mk

Modified: head/share/mk/src.sys.env.mk
==
--- head/share/mk/src.sys.env.mkFri Jan 17 06:10:24 2020
(r356826)
+++ head/share/mk/src.sys.env.mkFri Jan 17 14:29:27 2020
(r356827)
@@ -61,8 +61,9 @@ MAKEOBJDIRPREFIX:=${_saveMAKEOBJDIRPREFIX}
 .include 
 
 # Top-level installs should not use meta mode as it may prevent installing
-# based on cookies.
-.if make(*install*) && ${.MAKE.LEVEL} == 0
+# based on cookies. It's fine with filemon though.
+.if !empty(META_MODE:Mnofilemon) && \
+  make(*install*) && ${.MAKE.LEVEL} == 0
 META_MODE= normal
 MK_META_MODE=  no
 .export MK_META_MODE
___
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: r356828 - head/sys/kern

2020-01-17 Thread Mateusz Guzik
Author: mjg
Date: Fri Jan 17 14:39:00 2020
New Revision: 356828
URL: https://svnweb.freebsd.org/changeset/base/356828

Log:
  vfs: shorten lock hold time in vdbatch_process

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cFri Jan 17 14:29:27 2020(r356827)
+++ head/sys/kern/vfs_subr.cFri Jan 17 14:39:00 2020(r356828)
@@ -3243,9 +3243,9 @@ vdbatch_process(struct vdbatch *vd)
MPASS(vp->v_dbatchcpu != NOCPU);
vp->v_dbatchcpu = NOCPU;
}
+   mtx_unlock(&vnode_list_mtx);
bzero(vd->tab, sizeof(vd->tab));
vd->index = 0;
-   mtx_unlock(&vnode_list_mtx);
 }
 
 static 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: r356829 - head/lib/libc/gen

2020-01-17 Thread Mateusz Guzik
Author: mjg
Date: Fri Jan 17 14:40:09 2020
New Revision: 356829
URL: https://svnweb.freebsd.org/changeset/base/356829

Log:
  libc: assume no union stack if fstatfs fails in readdir
  
  The failure is not really expected, but should it happen it's better to
  get some data.
  
  Suggested by: kib

Modified:
  head/lib/libc/gen/opendir.c

Modified: head/lib/libc/gen/opendir.c
==
--- head/lib/libc/gen/opendir.c Fri Jan 17 14:39:00 2020(r356828)
+++ head/lib/libc/gen/opendir.c Fri Jan 17 14:40:09 2020(r356829)
@@ -283,7 +283,7 @@ __opendir_common(int fd, int flags, bool use_current_p
DIR *dirp;
int incr;
int saved_errno;
-   int unionstack;
+   bool unionstack;
 
if ((dirp = malloc(sizeof(DIR) + sizeof(struct _telldir))) == NULL)
return (NULL);
@@ -310,15 +310,14 @@ __opendir_common(int fd, int flags, bool use_current_p
/*
 * Determine whether this directory is the top of a union stack.
 */
+   unionstack = false;
if (flags & DTF_NODUP) {
struct statfs sfb;
 
-   if (_fstatfs(fd, &sfb) < 0)
-   goto fail;
-   unionstack = !strcmp(sfb.f_fstypename, "unionfs")
-   || (sfb.f_flags & MNT_UNION);
-   } else {
-   unionstack = 0;
+   if (_fstatfs(fd, &sfb) == 0) {
+   unionstack = strcmp(sfb.f_fstypename, "unionfs") == 0 ||
+   (sfb.f_flags & MNT_UNION);
+   }
}
 
if (unionstack) {
___
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: r356830 - in head: lib/libc/gen lib/libc/sys sys/fs/unionfs sys/kern sys/sys

2020-01-17 Thread Mateusz Guzik
Author: mjg
Date: Fri Jan 17 14:42:25 2020
New Revision: 356830
URL: https://svnweb.freebsd.org/changeset/base/356830

Log:
  vfs: provide F_ISUNIONSTACK as a kludge for libc
  
  Prior to introduction of this op libc's readdir would call fstatfs(2), in
  effect unnecessarily copying kilobytes of data just to check fs name and a
  mount flag.
  
  Reviewed by:  kib (previous version)
  Differential Revision:https://reviews.freebsd.org/D23162

Modified:
  head/lib/libc/gen/opendir.c
  head/lib/libc/sys/fcntl.2
  head/sys/fs/unionfs/union_vfsops.c
  head/sys/kern/kern_descrip.c
  head/sys/sys/fcntl.h
  head/sys/sys/mount.h

Modified: head/lib/libc/gen/opendir.c
==
--- head/lib/libc/gen/opendir.c Fri Jan 17 14:40:09 2020(r356829)
+++ head/lib/libc/gen/opendir.c Fri Jan 17 14:42:25 2020(r356830)
@@ -273,7 +273,25 @@ _filldir(DIR *dirp, bool use_current_pos)
return (true);
 }
 
+static bool
+is_unionstack(int fd)
+{
+   struct statfs sfb;
+   int unionstack;
 
+   unionstack = _fcntl(fd, F_ISUNIONSTACK);
+   if (unionstack != -1)
+   return (unionstack);
+
+   /*
+* Temporary compat for kernels which don't provide F_ISUNIONSTACK.
+*/
+   if (_fstatfs(fd, &sfb) < 0)
+   return (true);
+   return (strcmp(sfb.f_fstypename, "unionfs") == 0 ||
+   (sfb.f_flags & MNT_UNION));
+}
+
 /*
  * Common routine for opendir(3), __opendir2(3) and fdopendir(3).
  */
@@ -312,12 +330,7 @@ __opendir_common(int fd, int flags, bool use_current_p
 */
unionstack = false;
if (flags & DTF_NODUP) {
-   struct statfs sfb;
-
-   if (_fstatfs(fd, &sfb) == 0) {
-   unionstack = strcmp(sfb.f_fstypename, "unionfs") == 0 ||
-   (sfb.f_flags & MNT_UNION);
-   }
+   unionstack = is_unionstack(fd);
}
 
if (unionstack) {

Modified: head/lib/libc/sys/fcntl.2
==
--- head/lib/libc/sys/fcntl.2   Fri Jan 17 14:40:09 2020(r356829)
+++ head/lib/libc/sys/fcntl.2   Fri Jan 17 14:42:25 2020(r356830)
@@ -28,7 +28,7 @@
 .\" @(#)fcntl.28.2 (Berkeley) 1/12/94
 .\" $FreeBSD$
 .\"
-.Dd September 4, 2019
+.Dd January 17, 2020
 .Dt FCNTL 2
 .Os
 .Sh NAME
@@ -185,6 +185,11 @@ Add seals to the file as described below, if the under
 seals.
 .It Dv F_GET_SEALS
 Get seals associated with the file, if the underlying filesystem supports 
seals.
+.It Dv F_ISUNIONSTACK
+Check if the vnode is part of a union stack (either the "union" flag from
+.Xr mount 2
+or unionfs).
+This is a hack not intended to be used outside of libc.
 .El
 .Pp
 The flags for the

Modified: head/sys/fs/unionfs/union_vfsops.c
==
--- head/sys/fs/unionfs/union_vfsops.c  Fri Jan 17 14:40:09 2020
(r356829)
+++ head/sys/fs/unionfs/union_vfsops.c  Fri Jan 17 14:42:25 2020
(r356830)
@@ -296,7 +296,7 @@ unionfs_domount(struct mount *mp)
if ((ump->um_lowervp->v_mount->mnt_flag & MNT_LOCAL) &&
(ump->um_uppervp->v_mount->mnt_flag & MNT_LOCAL))
mp->mnt_flag |= MNT_LOCAL;
-   mp->mnt_kern_flag |= MNTK_NOMSYNC;
+   mp->mnt_kern_flag |= MNTK_NOMSYNC | MNTK_UNIONFS;
MNT_IUNLOCK(mp);
 
/*

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cFri Jan 17 14:40:09 2020
(r356829)
+++ head/sys/kern/kern_descrip.cFri Jan 17 14:42:25 2020
(r356830)
@@ -489,6 +489,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_
struct filedescent *fde;
struct proc *p;
struct vnode *vp;
+   struct mount *mp;
int error, flg, seals, tmp;
uint64_t bsize;
off_t foffset;
@@ -813,6 +814,49 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_
atomic_clear_int(&fp->f_flag, FRDAHEAD);
}
VOP_UNLOCK(vp);
+   fdrop(fp, td);
+   break;
+
+   case F_ISUNIONSTACK:
+   /*
+* Check if the vnode is part of a union stack (either the
+* "union" flag from mount(2) or unionfs).
+*
+* Prior to introduction of this op libc's readdir would call
+* fstatfs(2), in effect unnecessarily copying kilobytes of
+* data just to check fs name and a mount flag.
+*
+* Fixing the code to handle everything in the kernel instead
+* is a non-trivial endeavor and has low priority, thus this
+* horrible kludge facilitates the current behavior in a much
+* cheaper manne

svn commit: r356831 - head/sys/powerpc/include

2020-01-17 Thread Leandro Lupori
Author: luporl
Date: Fri Jan 17 14:43:58 2020
New Revision: 356831
URL: https://svnweb.freebsd.org/changeset/base/356831

Log:
  [PPC] Fix wrong comment
  
  pcb_context[20] holds r12-r31 and not r14-r31, as the comment said.

Modified:
  head/sys/powerpc/include/pcb.h

Modified: head/sys/powerpc/include/pcb.h
==
--- head/sys/powerpc/include/pcb.h  Fri Jan 17 14:42:25 2020
(r356830)
+++ head/sys/powerpc/include/pcb.h  Fri Jan 17 14:43:58 2020
(r356831)
@@ -41,7 +41,7 @@
 
 #ifndef _STANDALONE
 struct pcb {
-   register_t  pcb_context[20];/* non-volatile r14-r31 */
+   register_t  pcb_context[20];/* non-volatile r12-r31 */
register_t  pcb_cr; /* Condition register */
register_t  pcb_sp; /* stack pointer */
register_t  pcb_toc;/* toc pointer */
___
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: r356832 - head/lib/libc/gen

2020-01-17 Thread Mateusz Guzik
Author: mjg
Date: Fri Jan 17 15:45:39 2020
New Revision: 356832
URL: https://svnweb.freebsd.org/changeset/base/356832

Log:
  libc: fix build after r356830
  
  Apparently building with 'cd lib/libc; make all install' is not the same
  as buildworld.
  
  Reported by:  Michael Butler

Modified:
  head/lib/libc/gen/opendir.c

Modified: head/lib/libc/gen/opendir.c
==
--- head/lib/libc/gen/opendir.c Fri Jan 17 14:43:58 2020(r356831)
+++ head/lib/libc/gen/opendir.c Fri Jan 17 15:45:39 2020(r356832)
@@ -279,7 +279,7 @@ is_unionstack(int fd)
struct statfs sfb;
int unionstack;
 
-   unionstack = _fcntl(fd, F_ISUNIONSTACK);
+   unionstack = _fcntl(fd, F_ISUNIONSTACK, 0);
if (unionstack != -1)
return (unionstack);
 
___
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: r356834 - head/sys/riscv/riscv

2020-01-17 Thread Ruslan Bukin
Author: br
Date: Fri Jan 17 16:48:20 2020
New Revision: 356834
URL: https://svnweb.freebsd.org/changeset/base/356834

Log:
  Use unsigned loads in fubyte, fuword16, generic_bs_r_1, generic_bs_r_2
  as these functions should do zero-extend.
  
  Discovered by running pci_read_cap(), and by hint from James Clarke.
  
  Reviewed by:  James Clarke 
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D23236

Modified:
  head/sys/riscv/riscv/bus_space_asm.S
  head/sys/riscv/riscv/support.S

Modified: head/sys/riscv/riscv/bus_space_asm.S
==
--- head/sys/riscv/riscv/bus_space_asm.SFri Jan 17 15:55:14 2020
(r356833)
+++ head/sys/riscv/riscv/bus_space_asm.SFri Jan 17 16:48:20 2020
(r356834)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2016 Ruslan Bukin 
+ * Copyright (c) 2016-2020 Ruslan Bukin 
  * All rights reserved.
  *
  * Portions of this software were developed by SRI International and the
@@ -38,13 +38,13 @@ __FBSDID("$FreeBSD$");
 
 ENTRY(generic_bs_r_1)
add a3, a1, a2
-   lb  a0, 0(a3)
+   lbu a0, 0(a3)
ret
 END(generic_bs_r_1)
 
 ENTRY(generic_bs_r_2)
add a3, a1, a2
-   lh  a0, 0(a3)
+   lhu a0, 0(a3)
ret
 END(generic_bs_r_2)
 

Modified: head/sys/riscv/riscv/support.S
==
--- head/sys/riscv/riscv/support.S  Fri Jan 17 15:55:14 2020
(r356833)
+++ head/sys/riscv/riscv/support.S  Fri Jan 17 16:48:20 2020
(r356834)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2015-2018 Ruslan Bukin 
+ * Copyright (c) 2015-2020 Ruslan Bukin 
  * All rights reserved.
  *
  * Portions of this software were developed by SRI International and the
@@ -102,7 +102,7 @@ ENTRY(fubyte)
la  a6, fsu_fault   /* Load the fault handler */
SET_FAULT_HANDLER(a6, a1)   /* And set it */
ENTER_USER_ACCESS(a1)
-   lb  a0, 0(a0)   /* Try loading the data */
+   lbu a0, 0(a0)   /* Try loading the data */
EXIT_USER_ACCESS(a1)
SET_FAULT_HANDLER(x0, a1)   /* Reset the fault handler */
ret /* Return */
@@ -117,7 +117,7 @@ ENTRY(fuword16)
la  a6, fsu_fault   /* Load the fault handler */
SET_FAULT_HANDLER(a6, a1)   /* And set it */
ENTER_USER_ACCESS(a1)
-   lh  a0, 0(a0)   /* Try loading the data */
+   lhu a0, 0(a0)   /* Try loading the data */
EXIT_USER_ACCESS(a1)
SET_FAULT_HANDLER(x0, a1)   /* Reset the fault handler */
ret /* Return */
___
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: r356835 - head/sys/riscv/riscv

2020-01-17 Thread Mitchell Horne
Author: mhorne
Date: Fri Jan 17 17:03:25 2020
New Revision: 356835
URL: https://svnweb.freebsd.org/changeset/base/356835

Log:
  RISC-V: fix global pointer assignment at boot
  
  As part of the RISC-V ABI, the gp register is expected to initialized
  with the address of __global_pointer$ as early as possible. This allows
  loads and stores from .sdata to be relaxed based on the value of gp. In
  locore.S we do this initialization twice, once each for va and mpva.
  However, in both cases the initialization is preceded by an la
  instruction, which in theory could be relaxed by the linker.
  
  Move the initialization of gp to be slightly earlier (before la
  cpu_exception_handler), and add an additional gp initialization at the
  very beginning of _start, before virtual memory is set up.
  
  Reported by:  jrtc27
  Reviewed by:  jrtc27
  Differential Revision:https://reviews.freebsd.org/D23139

Modified:
  head/sys/riscv/riscv/locore.S

Modified: head/sys/riscv/riscv/locore.S
==
--- head/sys/riscv/riscv/locore.S   Fri Jan 17 16:48:20 2020
(r356834)
+++ head/sys/riscv/riscv/locore.S   Fri Jan 17 17:03:25 2020
(r356835)
@@ -53,6 +53,12 @@
.text
.globl _start
 _start:
+   /* Set the global pointer */
+.option push
+.option norelax
+   lla gp, __global_pointer$
+.option pop
+
/* Get the physical address kernel loaded to */
lla t0, virt_map
ld  t1, 0(t0)
@@ -168,6 +174,11 @@ _start:
 
.align 2
 va:
+   /* Set the global pointer again, this time with the virtual address. */
+.option push
+.option norelax
+   lla gp, __global_pointer$
+.option pop
 
/* Setup supervisor trap vector */
la  t0, cpu_exception_handler
@@ -177,12 +188,6 @@ va:
li  t0, 0
csrwsscratch, t0
 
-   /* Set the global pointer */
-.option push
-.option norelax
-   la  gp, __global_pointer$
-.option pop
-
/* Initialize stack pointer */
la  s3, initstack_end
mv  sp, s3
@@ -322,6 +327,12 @@ ENTRY(mpentry)
 
.align 2
 mpva:
+   /* Set the global pointer again, this time with the virtual address. */
+.option push
+.option norelax
+   lla gp, __global_pointer$
+.option pop
+
/* Setup supervisor trap vector */
la  t0, cpu_exception_handler
csrwstvec, t0
@@ -329,12 +340,6 @@ mpva:
/* Ensure sscratch is zero */
li  t0, 0
csrwsscratch, t0
-
-   /* Set the global pointer */
-.option push
-.option norelax
-   la  gp, __global_pointer$
-.option pop
 
callinit_secondary
 END(mpentry)
___
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: r356831 - head/sys/powerpc/include

2020-01-17 Thread John Baldwin
On 1/17/20 6:43 AM, Leandro Lupori wrote:
> Author: luporl
> Date: Fri Jan 17 14:43:58 2020
> New Revision: 356831
> URL: https://svnweb.freebsd.org/changeset/base/356831
> 
> Log:
>   [PPC] Fix wrong comment
>   
>   pcb_context[20] holds r12-r31 and not r14-r31, as the comment said.

Thanks, this was the source of the kgdb bug I think. :)

-- 
John Baldwin
___
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: r356836 - head/share/mk

2020-01-17 Thread Ed Maste
Author: emaste
Date: Fri Jan 17 17:53:13 2020
New Revision: 356836
URL: https://svnweb.freebsd.org/changeset/base/356836

Log:
  src.opts.mk: force DMAGENT off under WITHOUT_OPENSSL
  
  dma(8) depends on OpenSSL unconditionally.
  
  Reported by:  Michael Dexter's Build Options Survey run
  MFC after:1 weeks
  Sponsored by: The FreeBSD Foundation

Modified:
  head/share/mk/src.opts.mk

Modified: head/share/mk/src.opts.mk
==
--- head/share/mk/src.opts.mk   Fri Jan 17 17:03:25 2020(r356835)
+++ head/share/mk/src.opts.mk   Fri Jan 17 17:53:13 2020(r356836)
@@ -497,6 +497,7 @@ MK_NLS_CATALOGS:= no
 .endif
 
 .if ${MK_OPENSSL} == "no"
+MK_DMAGENT:=   no
 MK_OPENSSH:=   no
 MK_KERBEROS:=  no
 MK_KERBEROS_SUPPORT:=  no
___
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: r356837 - head/share/man/man5

2020-01-17 Thread Ed Maste
Author: emaste
Date: Fri Jan 17 17:56:31 2020
New Revision: 356837
URL: https://svnweb.freebsd.org/changeset/base/356837

Log:
  src.conf.5: regen after r356836, DMAGENT dependency on OPENSSL

Modified:
  head/share/man/man5/src.conf.5

Modified: head/share/man/man5/src.conf.5
==
--- head/share/man/man5/src.conf.5  Fri Jan 17 17:53:13 2020
(r356836)
+++ head/share/man/man5/src.conf.5  Fri Jan 17 17:56:31 2020
(r356837)
@@ -1,6 +1,6 @@
 .\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman.
 .\" $FreeBSD$
-.Dd January 14, 2020
+.Dd January 17, 2020
 .Dt SRC.CONF 5
 .Os
 .Sh NAME
@@ -179,11 +179,10 @@ Build all binaries with the
 flag set to indicate that the run-time loader should perform all relocation
 processing at process startup rather than on demand.
 .It Va WITHOUT_BINUTILS
-Set to not build or install GNU
+Do not build or install GNU
 .Xr as 1 ,
-.Xr objdump 1 ,
-and, on powerpc,
-.Xr ld.bfd 1
+.Xr ld.bfd 1 , and
+.Xr objdump 1
 as part
 of the normal system build.
 The resulting system cannot build programs from source.
@@ -202,7 +201,7 @@ of the normal system build.
 This is a default setting on
 amd64/amd64, arm/armv6, arm/armv7, i386/i386, mips/mipsel, mips/mips, 
mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, 
mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpc64 and 
sparc64/sparc64.
 .It Va WITHOUT_BINUTILS_BOOTSTRAP
-Set to not build binutils (as, objdump, and on powerpc ld)
+Do not build binutils (as, ld.bfd, and objdump)
 as part of the bootstrap process.
 .Bf -symbolic
 The option does not work for build targets unless some alternative
@@ -469,6 +468,8 @@ When set, it enforces these options:
 .Pp
 .Bl -item -compact
 .It
+.Va WITHOUT_DMAGENT
+.It
 .Va WITHOUT_KERBEROS
 .It
 .Va WITHOUT_KERBEROS_SUPPORT
@@ -1453,6 +1454,8 @@ Set to not build OpenSSL.
 When set, it enforces these options:
 .Pp
 .Bl -item -compact
+.It
+.Va WITHOUT_DMAGENT
 .It
 .Va WITHOUT_KERBEROS
 .It
___
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: r356832 - head/lib/libc/gen

2020-01-17 Thread Dimitry Andric
On 17 Jan 2020, at 16:45, Mateusz Guzik  wrote:
> 
> Author: mjg
> Date: Fri Jan 17 15:45:39 2020
> New Revision: 356832
> URL: https://svnweb.freebsd.org/changeset/base/356832
> 
> Log:
>  libc: fix build after r356830
> 
>  Apparently building with 'cd lib/libc; make all install' is not the same
>  as buildworld.

Definitely not, indeed.  Such a plain make will use your system's
headers for inclusion, not those in /usr/src.  Only use this when you
are certain those headers are up-to-date (or up-to-date enough ;).

-Dimitry



signature.asc
Description: Message signed with OpenPGP


svn commit: r356839 - in head/sys: arm64/arm64 riscv/riscv

2020-01-17 Thread John Baldwin
Author: jhb
Date: Fri Jan 17 19:01:59 2020
New Revision: 356839
URL: https://svnweb.freebsd.org/changeset/base/356839

Log:
  Save and restore floating point registers in get/set_mcontext().
  
  arm64 and riscv were only saving and restoring floating point
  registers for sendsig() and sys_sigreturn(), but not for getcontext(),
  setcontext(), and swapcontext().
  
  While here, remove an always-false check for uap being NULL from
  sys_sigreturn().
  
  Reviewed by:  br, mhorne
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D23218

Modified:
  head/sys/arm64/arm64/machdep.c
  head/sys/riscv/riscv/machdep.c

Modified: head/sys/arm64/arm64/machdep.c
==
--- head/sys/arm64/arm64/machdep.c  Fri Jan 17 17:57:34 2020
(r356838)
+++ head/sys/arm64/arm64/machdep.c  Fri Jan 17 19:01:59 2020
(r356839)
@@ -98,6 +98,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #endif
 
+static void get_fpcontext(struct thread *td, mcontext_t *mcp);
+static void set_fpcontext(struct thread *td, mcontext_t *mcp);
 
 enum arm64_bus arm64_bus_method = ARM64_BUS_NONE;
 
@@ -473,6 +475,7 @@ get_mcontext(struct thread *td, mcontext_t *mcp, int c
mcp->mc_gpregs.gp_sp = tf->tf_sp;
mcp->mc_gpregs.gp_lr = tf->tf_lr;
mcp->mc_gpregs.gp_elr = tf->tf_elr;
+   get_fpcontext(td, mcp);
 
return (0);
 }
@@ -495,6 +498,7 @@ set_mcontext(struct thread *td, mcontext_t *mcp)
tf->tf_lr = mcp->mc_gpregs.gp_lr;
tf->tf_elr = mcp->mc_gpregs.gp_elr;
tf->tf_spsr = mcp->mc_gpregs.gp_spsr;
+   set_fpcontext(td, mcp);
 
return (0);
 }
@@ -667,15 +671,12 @@ sys_sigreturn(struct thread *td, struct sigreturn_args
ucontext_t uc;
int error;
 
-   if (uap == NULL)
-   return (EFAULT);
if (copyin(uap->sigcntxp, &uc, sizeof(uc)))
return (EFAULT);
 
error = set_mcontext(td, &uc.uc_mcontext);
if (error != 0)
return (error);
-   set_fpcontext(td, &uc.uc_mcontext);
 
/* Restore signal mask. */
kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0);
@@ -747,7 +748,6 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask
/* Fill in the frame to copy out */
bzero(&frame, sizeof(frame));
get_mcontext(td, &frame.sf_uc.uc_mcontext, 0);
-   get_fpcontext(td, &frame.sf_uc.uc_mcontext);
frame.sf_si = ksi->ksi_info;
frame.sf_uc.uc_sigmask = *mask;
frame.sf_uc.uc_stack = td->td_sigstk;

Modified: head/sys/riscv/riscv/machdep.c
==
--- head/sys/riscv/riscv/machdep.c  Fri Jan 17 17:57:34 2020
(r356838)
+++ head/sys/riscv/riscv/machdep.c  Fri Jan 17 19:01:59 2020
(r356839)
@@ -99,6 +99,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #endif
 
+static void get_fpcontext(struct thread *td, mcontext_t *mcp);
+static void set_fpcontext(struct thread *td, mcontext_t *mcp);
+
 struct pcpu __pcpu[MAXCPU];
 
 static struct trapframe proc0_tf;
@@ -352,6 +355,7 @@ get_mcontext(struct thread *td, mcontext_t *mcp, int c
mcp->mc_gpregs.gp_tp = tf->tf_tp;
mcp->mc_gpregs.gp_sepc = tf->tf_sepc;
mcp->mc_gpregs.gp_sstatus = tf->tf_sstatus;
+   get_fpcontext(td, mcp);
 
return (0);
 }
@@ -372,6 +376,7 @@ set_mcontext(struct thread *td, mcontext_t *mcp)
tf->tf_gp = mcp->mc_gpregs.gp_gp;
tf->tf_sepc = mcp->mc_gpregs.gp_sepc;
tf->tf_sstatus = mcp->mc_gpregs.gp_sstatus;
+   set_fpcontext(td, mcp);
 
return (0);
 }
@@ -522,8 +527,6 @@ sys_sigreturn(struct thread *td, struct sigreturn_args
ucontext_t uc;
int error;
 
-   if (uap == NULL)
-   return (EFAULT);
if (copyin(uap->sigcntxp, &uc, sizeof(uc)))
return (EFAULT);
 
@@ -540,8 +543,6 @@ sys_sigreturn(struct thread *td, struct sigreturn_args
if (error != 0)
return (error);
 
-   set_fpcontext(td, &uc.uc_mcontext);
-
/* Restore signal mask. */
kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0);
 
@@ -612,7 +613,6 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask
/* Fill in the frame to copy out */
bzero(&frame, sizeof(frame));
get_mcontext(td, &frame.sf_uc.uc_mcontext, 0);
-   get_fpcontext(td, &frame.sf_uc.uc_mcontext);
frame.sf_si = ksi->ksi_info;
frame.sf_uc.uc_sigmask = *mask;
frame.sf_uc.uc_stack = td->td_sigstk;
___
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: r356840 - head/sys/riscv/riscv

2020-01-17 Thread John Baldwin
Author: jhb
Date: Fri Jan 17 19:13:49 2020
New Revision: 356840
URL: https://svnweb.freebsd.org/changeset/base/356840

Log:
  Check for invalid sstatus values in set_mcontext().
  
  Previously, this check was only in sys_sigreturn() which meant that
  user applications could write invalid values to the register via
  setcontext() or swapcontext().
  
  Reviewed by:  mhorne
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D23219

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

Modified: head/sys/riscv/riscv/machdep.c
==
--- head/sys/riscv/riscv/machdep.c  Fri Jan 17 19:01:59 2020
(r356839)
+++ head/sys/riscv/riscv/machdep.c  Fri Jan 17 19:13:49 2020
(r356840)
@@ -367,6 +367,14 @@ set_mcontext(struct thread *td, mcontext_t *mcp)
 
tf = td->td_frame;
 
+   /*
+* Make sure the processor mode has not been tampered with and
+* interrupts have not been disabled.
+* Supervisor interrupts in user mode are always enabled.
+*/
+   if ((mcp->mc_gpregs.gp_sstatus & SSTATUS_SPP) != 0)
+   return (EINVAL);
+
memcpy(tf->tf_t, mcp->mc_gpregs.gp_t, sizeof(tf->tf_t));
memcpy(tf->tf_s, mcp->mc_gpregs.gp_s, sizeof(tf->tf_s));
memcpy(tf->tf_a, mcp->mc_gpregs.gp_a, sizeof(tf->tf_a));
@@ -523,21 +531,11 @@ struct sigreturn_args {
 int
 sys_sigreturn(struct thread *td, struct sigreturn_args *uap)
 {
-   uint64_t sstatus;
ucontext_t uc;
int error;
 
if (copyin(uap->sigcntxp, &uc, sizeof(uc)))
return (EFAULT);
-
-   /*
-* Make sure the processor mode has not been tampered with and
-* interrupts have not been disabled.
-* Supervisor interrupts in user mode are always enabled.
-*/
-   sstatus = uc.uc_mcontext.mc_gpregs.gp_sstatus;
-   if ((sstatus & SSTATUS_SPP) != 0)
-   return (EINVAL);
 
error = set_mcontext(td, &uc.uc_mcontext);
if (error != 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"


Re: svn commit: r356832 - head/lib/libc/gen

2020-01-17 Thread Mateusz Guzik
On 1/17/20, Dimitry Andric  wrote:
> On 17 Jan 2020, at 16:45, Mateusz Guzik  wrote:
>>
>> Author: mjg
>> Date: Fri Jan 17 15:45:39 2020
>> New Revision: 356832
>> URL: https://svnweb.freebsd.org/changeset/base/356832
>>
>> Log:
>>  libc: fix build after r356830
>>
>>  Apparently building with 'cd lib/libc; make all install' is not the same
>>  as buildworld.
>
> Definitely not, indeed.  Such a plain make will use your system's
> headers for inclusion, not those in /usr/src.  Only use this when you
> are certain those headers are up-to-date (or up-to-date enough ;).
>

That's not the difference I meant.

Building like above works fine with:

unionstack = _fcntl(fd, F_ISUNIONSTACK);

It's only buildworld during which this fails with:
/usr/src/lib/libc/gen/opendir.c:282:40: error: too few arguments
provided to function-like macro invocation
unionstack = _fcntl(fd, F_ISUNIONSTACK);

hence the patch.

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


Re: svn commit: r356832 - head/lib/libc/gen

2020-01-17 Thread Warner Losh
On Fri, Jan 17, 2020 at 11:55 AM Dimitry Andric  wrote:

> On 17 Jan 2020, at 16:45, Mateusz Guzik  wrote:
> >
> > Author: mjg
> > Date: Fri Jan 17 15:45:39 2020
> > New Revision: 356832
> > URL: https://svnweb.freebsd.org/changeset/base/356832
> >
> > Log:
> >  libc: fix build after r356830
> >
> >  Apparently building with 'cd lib/libc; make all install' is not the same
> >  as buildworld.
>
> Definitely not, indeed.  Such a plain make will use your system's
> headers for inclusion, not those in /usr/src.  Only use this when you
> are certain those headers are up-to-date (or up-to-date enough ;).
>

Generally, one can do

% cd lib/libc; make buildenv
$ make all install
to get this functionality.

Warner
___
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: r356849 - head/sys/arm/broadcom/bcm2835

2020-01-17 Thread Kyle Evans
Author: kevans
Date: Fri Jan 17 21:39:28 2020
New Revision: 356849
URL: https://svnweb.freebsd.org/changeset/base/356849

Log:
  bcm2835_vcbus: unifdef all platform definitions
  
  Raspberry Pi are all over the board, and the reality is that there's no harm
  in including all of the definitions by default but plenty of harm in the
  current situation. This change is safe because we match a definition by root
  /compatible in the FDT, so there will be no false-positives because of it.
  
  The main array of definitions grows, but it's only walked exactly once to
  determine which we need to use.

Modified:
  head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.c

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.c   Fri Jan 17 21:29:20 
2020(r356848)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.c   Fri Jan 17 21:39:28 
2020(r356849)
@@ -35,9 +35,6 @@ __FBSDID("$FreeBSD$");
  * mappings for use in DMA/mailbox interactions.  This is only used for the
  * arm64 SoC because the 32-bit SoC used the same mappings.
  */
-#if defined (__aarch64__)
-#include "opt_soc.h"
-#endif
 
 #include 
 #include 
@@ -67,7 +64,6 @@ struct bcm283x_memory_mapping {
vm_paddr_t  vcbus_start;
 };
 
-#ifdef SOC_BCM2835
 static struct bcm283x_memory_mapping bcm2835_memmap[] = {
{
/* SDRAM */
@@ -83,9 +79,7 @@ static struct bcm283x_memory_mapping bcm2835_memmap[] 
},
{ 0, 0, 0 },
 };
-#endif
 
-#ifdef SOC_BCM2836
 static struct bcm283x_memory_mapping bcm2836_memmap[] = {
{
/* SDRAM */
@@ -101,9 +95,7 @@ static struct bcm283x_memory_mapping bcm2836_memmap[] 
},
{ 0, 0, 0 },
 };
-#endif
 
-#ifdef SOC_BRCM_BCM2837
 static struct bcm283x_memory_mapping bcm2837_memmap[] = {
{
/* SDRAM */
@@ -119,10 +111,7 @@ static struct bcm283x_memory_mapping bcm2837_memmap[] 
},
{ 0, 0, 0 },
 };
-#endif
 
-#ifdef SOC_BRCM_BCM2838
-
 /*
  * The BCM2838 supports up to 4GB of SDRAM, but unfortunately we can still only
  * map the first 1GB into the "legacy master view" (vcbus) address space.  
Thus,
@@ -144,14 +133,12 @@ static struct bcm283x_memory_mapping bcm2838_memmap[] 
},
{ 0, 0, 0 },
 };
-#endif
 
 static struct bcm283x_memory_soc_cfg {
struct bcm283x_memory_mapping   *memmap;
const char  *soc_compat;
bus_addr_t   busdma_lowaddr;
 } bcm283x_memory_configs[] = {
-#ifdef SOC_BCM2835
/* Legacy */
{
.memmap = bcm2835_memmap,
@@ -164,8 +151,6 @@ static struct bcm283x_memory_soc_cfg {
.soc_compat = "brcm,bcm2835",
.busdma_lowaddr = BUS_SPACE_MAXADDR_32BIT,
},
-#endif
-#ifdef SOC_BCM2836
/* Legacy */
{
.memmap = bcm2836_memmap,
@@ -178,16 +163,11 @@ static struct bcm283x_memory_soc_cfg {
.soc_compat = "brcm,bcm2836",
.busdma_lowaddr = BUS_SPACE_MAXADDR_32BIT,
},
-
-#endif
-#ifdef SOC_BRCM_BCM2837
{
.memmap = bcm2837_memmap,
.soc_compat = "brcm,bcm2837",
.busdma_lowaddr = BUS_SPACE_MAXADDR_32BIT,
},
-#endif
-#ifdef SOC_BRCM_BCM2838
{
.memmap = bcm2838_memmap,
.soc_compat = "brcm,bcm2711",
@@ -198,7 +178,6 @@ static struct bcm283x_memory_soc_cfg {
.soc_compat = "brcm,bcm2838",
.busdma_lowaddr = BCM2838_PERIPH_MAXADDR,
},
-#endif
 };
 
 static struct bcm283x_memory_soc_cfg *booted_soc_memcfg;
___
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: r356852 - head/sys/net80211

2020-01-17 Thread Conrad Meyer
Author: cem
Date: Fri Jan 17 22:04:11 2020
New Revision: 356852
URL: https://svnweb.freebsd.org/changeset/base/356852

Log:
  net80211: Move rate printing in amrr_node_stats() to a separate method
  
  This makes amrr_node_stats() cleaner and allows the rate printing to be
  reusable.
  
  Submitted by: Neel Chauhan 
  Reviewed by:  adrian
  Differential Revision:https://reviews.freebsd.org/D22318

Modified:
  head/sys/net80211/ieee80211_amrr.c

Modified: head/sys/net80211/ieee80211_amrr.c
==
--- head/sys/net80211/ieee80211_amrr.c  Fri Jan 17 22:02:35 2020
(r356851)
+++ head/sys/net80211/ieee80211_amrr.c  Fri Jan 17 22:04:11 2020
(r356852)
@@ -477,18 +477,12 @@ amrr_sysctlattach(struct ieee80211vap *vap,
 }
 
 static void
-amrr_node_stats(struct ieee80211_node *ni, struct sbuf *s)
+amrr_print_node_rate(struct ieee80211_amrr_node *amn,
+struct ieee80211_node *ni, struct sbuf *s)
 {
int rate;
-   struct ieee80211_amrr_node *amn = ni->ni_rctls;
struct ieee80211_rateset *rs;
 
-   /* XXX TODO: check locking? */
-
-   if (!amn)
-   return;
-
-   /* XXX TODO: this should be a method */
if (amrr_node_is_11n(ni)) {
rs = (struct ieee80211_rateset *) &ni->ni_htrates;
rate = rs->rs_rates[amn->amn_rix] & IEEE80211_RATE_VAL;
@@ -498,7 +492,19 @@ amrr_node_stats(struct ieee80211_node *ni, struct sbuf
rate = rs->rs_rates[amn->amn_rix] & IEEE80211_RATE_VAL;
sbuf_printf(s, "rate: %d Mbit\n", rate / 2);
}
+}
 
+static void
+amrr_node_stats(struct ieee80211_node *ni, struct sbuf *s)
+{
+   struct ieee80211_amrr_node *amn = ni->ni_rctls;
+
+   /* XXX TODO: check locking? */
+
+   if (!amn)
+   return;
+
+   amrr_print_node_rate(amn, ni, s);
sbuf_printf(s, "ticks: %d\n", amn->amn_ticks);
sbuf_printf(s, "txcnt: %u\n", amn->amn_txcnt);
sbuf_printf(s, "success: %u\n", amn->amn_success);
___
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: r356855 - head/usr.sbin/bsdinstall/partedit

2020-01-17 Thread Ben Woods
Author: woodsb02 (ports committer)
Date: Fri Jan 17 22:26:41 2020
New Revision: 356855
URL: https://svnweb.freebsd.org/changeset/base/356855

Log:
  Fix regression in bsdinstall post r356740 - partedit errno(2) 21 EISDIR
  
  This resulted in the partitioning step failing if either of the
  "Auto (UFS)" or "Manual" options were selected.
  
  Reason: partedit was attempting to open a directory (TMPDIR) read/write,
  which resulted in errno(2) 21 - EISDIR - Is a directory.
  
  Reported by:  Clay Daniels 
  Reviewed by:  Ryan Moeller 
  Approved by:  emaste, bcran
  Differential Revision:https://reviews.freebsd.org/D23232

Modified:
  head/usr.sbin/bsdinstall/partedit/partedit.c

Modified: head/usr.sbin/bsdinstall/partedit/partedit.c
==
--- head/usr.sbin/bsdinstall/partedit/partedit.cFri Jan 17 22:24:56 
2020(r356854)
+++ head/usr.sbin/bsdinstall/partedit/partedit.cFri Jan 17 22:26:41 
2020(r356855)
@@ -93,7 +93,7 @@ main(int argc, const char **argv)
tmpdir = getenv("TMPDIR");
if (tmpdir == NULL)
tmpdir = "/tmp";
-   tmpdfd = open(tmpdir, O_RDWR | O_DIRECTORY);
+   tmpdfd = open(tmpdir, O_DIRECTORY);
if (tmpdfd < 0)
err(EX_OSERR, "%s", tmpdir);
unlinkat(tmpdfd, "bsdinstall-esps", 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: r356856 - head/sys/powerpc/powerpc

2020-01-17 Thread Brandon Bergren
Author: bdragon
Date: Fri Jan 17 23:41:35 2020
New Revision: 356856
URL: https://svnweb.freebsd.org/changeset/base/356856

Log:
  [PowerPC] Save a dword in the powerpc64 signal trampoline
  
  In r291668, an instruction was added to sigcode64.S without the nop pad at
  the end being taken out.
  
  Due to alignment, this means that a dword is being wasted on the shared
  page for no reason.
  
  Take out this nop, and add some comments while I'm here.
  
  Reviewed by:  jhibbits
  Sponsored by: Tag1 Consulting, Inc.
  Differential Revision:https://reviews.freebsd.org/D23055

Modified:
  head/sys/powerpc/powerpc/sigcode64.S

Modified: head/sys/powerpc/powerpc/sigcode64.S
==
--- head/sys/powerpc/powerpc/sigcode64.SFri Jan 17 22:26:41 2020
(r356855)
+++ head/sys/powerpc/powerpc/sigcode64.SFri Jan 17 23:41:35 2020
(r356856)
@@ -63,9 +63,13 @@ CNAME(sigcode64_elfv2):
addi3,1,112+SF_UC   /* restore sp, and get &frame->sf_uc */
li  0,SYS_sigreturn
sc  /* sigreturn(scp) */
+   /*
+* If we get back to here, it means sigreturn failed.
+* As such, we are now stuck in the wrong context.
+* Exit immediately without touching the stack.
+*/
li  0,SYS_exit
sc  /* exit(errno) */
-   nop /* align to doubleword */
 endsigcode64:

.data
___
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: r356857 - head/sys/powerpc/booke

2020-01-17 Thread Brandon Bergren
Author: bdragon
Date: Sat Jan 18 01:22:54 2020
New Revision: 356857
URL: https://svnweb.freebsd.org/changeset/base/356857

Log:
  [PowerPC] Fix Book-E direct map for >=16G ram on e5500
  
  It turns out the maximum TLB1 page size on e5500 is 4G, despite the format
  being defined for up to 1TB.
  
  So, we need to clamp the DMAP TLB1 entries to not attempt to create 16G or
  larger entries.
  
  Fixes boot on my X5000 in which I just installed 16G of RAM.
  
  Reviewed by:  jhibbits
  Sponsored by: Tag1 Consulting, Inc.
  Differential Revision:https://reviews.freebsd.org/D23244

Modified:
  head/sys/powerpc/booke/pmap.c

Modified: head/sys/powerpc/booke/pmap.c
==
--- head/sys/powerpc/booke/pmap.c   Fri Jan 17 23:41:35 2020
(r356856)
+++ head/sys/powerpc/booke/pmap.c   Sat Jan 18 01:22:54 2020
(r356857)
@@ -4028,7 +4028,22 @@ tlb1_mapin_region(vm_offset_t va, vm_paddr_t pa, vm_si
sz >>= 2;
} while (va % sz != 0);
}
-   /* Now align from there to VA */
+#ifdef __powerpc64__
+   /*
+* Clamp TLB1 entries to 4G.
+*
+* While the e6500 supports up to 1TB mappings, the e5500
+* only supports up to 4G mappings. (0b1011)
+*
+* If any e6500 machines capable of supporting a very
+* large amount of memory appear in the future, we can
+* revisit this.
+*
+* For now, though, since we have plenty of space in TLB1,
+* always avoid creating entries larger than 4GB.
+*/
+   sz = MIN(sz, 1UL << 32);
+#endif
if (bootverbose)
printf("Wiring VA=%p to PA=%jx (size=%lx)\n",
(void *)va, (uintmax_t)pa, (long)sz);
___
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: r356858 - in head/sys/powerpc: include ofw powernv powerpc

2020-01-17 Thread Justin Hibbits
Author: jhibbits
Date: Sat Jan 18 01:26:54 2020
New Revision: 356858
URL: https://svnweb.freebsd.org/changeset/base/356858

Log:
  powerpc: Fix the NUMA domain list on powernv
  
  Summary:
  Consolidate the NUMA associativity handling into a platform function.
  Non-NUMA platforms will just fall back to the default (0).  Currently
  only implemented for powernv, which uses a lookup table to map the
  device tree associativity into a system NUMA domain.
  
  Fixes hangs on powernv after r356534, and corrects a fairly longstanding
  bug in powernv's NUMA handling, which ended up using domains 1 and 2 for
  devices and memory on power9, while CPUs were bound to domains 0 and 1.
  
  Reviewed by:  bdragon, luporl
  Differential Revision:https://reviews.freebsd.org/D23220

Modified:
  head/sys/powerpc/include/ofw_machdep.h
  head/sys/powerpc/include/platform.h
  head/sys/powerpc/ofw/ofw_machdep.c
  head/sys/powerpc/ofw/ofw_pcibus.c
  head/sys/powerpc/powernv/platform_powernv.c
  head/sys/powerpc/powerpc/platform.c
  head/sys/powerpc/powerpc/platform_if.m

Modified: head/sys/powerpc/include/ofw_machdep.h
==
--- head/sys/powerpc/include/ofw_machdep.h  Sat Jan 18 01:22:54 2020
(r356857)
+++ head/sys/powerpc/include/ofw_machdep.h  Sat Jan 18 01:26:54 2020
(r356858)
@@ -37,6 +37,9 @@
 #include 
 #include 
 
+struct mem_region;
+struct numa_mem_region;
+
 typedefuint32_tcell_t;
 
 void OF_getetheraddr(device_t dev, u_char *addr);

Modified: head/sys/powerpc/include/platform.h
==
--- head/sys/powerpc/include/platform.h Sat Jan 18 01:22:54 2020
(r356857)
+++ head/sys/powerpc/include/platform.h Sat Jan 18 01:26:54 2020
(r356858)
@@ -37,6 +37,7 @@
 #ifndef_MACHINE_PLATFORM_H_
 #define_MACHINE_PLATFORM_H_
   
+#include 
 #include 
 #include 
 
@@ -66,6 +67,7 @@ int   platform_smp_start_cpu(struct pcpu *);
 void   platform_smp_timebase_sync(u_long tb, int ap);
 void   platform_smp_ap_init(void);
 void   platform_smp_probe_threads(void);
+intplatform_node_numa_domain(phandle_t);
   
 const char *installed_platform(void);
 void platform_probe_and_attach(void);

Modified: head/sys/powerpc/ofw/ofw_machdep.c
==
--- head/sys/powerpc/ofw/ofw_machdep.c  Sat Jan 18 01:22:54 2020
(r356857)
+++ head/sys/powerpc/ofw/ofw_machdep.c  Sat Jan 18 01:26:54 2020
(r356858)
@@ -466,9 +466,8 @@ void
 ofw_numa_mem_regions(struct numa_mem_region *memp, int *memsz)
 {
phandle_t phandle;
-   int res, count, msz;
+   int count, msz;
char name[31];
-   cell_t associativity[5];
struct numa_mem_region *curmemp;
 
msz = 0;
@@ -486,13 +485,8 @@ ofw_numa_mem_regions(struct numa_mem_region *memp, int
if (count == 0)
continue;
curmemp = &memp[msz];
-   res = OF_getproplen(phandle, "ibm,associativity");
-   if (res <= 0)
-   continue;
MPASS(count == 1);
-   OF_getencprop(phandle, "ibm,associativity",
-   associativity, res);
-   curmemp->mr_domain = associativity[3];
+   curmemp->mr_domain = platform_node_numa_domain(phandle);
if (bootverbose)
printf("%s %#jx-%#jx domain(%ju)\n",
name, (uintmax_t)curmemp->mr_start,

Modified: head/sys/powerpc/ofw/ofw_pcibus.c
==
--- head/sys/powerpc/ofw/ofw_pcibus.c   Sat Jan 18 01:22:54 2020
(r356857)
+++ head/sys/powerpc/ofw/ofw_pcibus.c   Sat Jan 18 01:26:54 2020
(r356858)
@@ -385,39 +385,13 @@ ofw_pcibus_get_devinfo(device_t bus, device_t dev)
return (&dinfo->opd_obdinfo);
 }
 
-static int
-ofw_pcibus_parse_associativity(device_t dev, int *domain)
-{
-   phandle_t node;
-   cell_t associativity[5];
-   int res;
-
-   if ((node = ofw_bus_get_node(dev)) == -1) {
-   if (bootverbose)
-   device_printf(dev, "no ofw node found\n");
-   return (ENXIO);
-   }
-   res = OF_getproplen(node, "ibm,associativity");
-   if (res <= 0)
-   return (ENXIO);
-   OF_getencprop(node, "ibm,associativity",
-   associativity, res);
-
-   *domain = associativity[3];
-   if (bootverbose)
-   device_printf(dev, "domain(%d)\n", *domain);
-   return (0);
-}
-
 int
 ofw_pcibus_get_cpus(device_t dev, device_t child, enum cpu_sets op, size_t 
setsize,
 cpuset_t *cpuset)
 {
int d, error;
 
-   error = ofw_pcibus_parse_associativity(child, &d);
-   if (error)
-   return (bus_generic_get_cpus(dev, chil

svn commit: r356859 - head/sys/kern

2020-01-17 Thread Mateusz Guzik
Author: mjg
Date: Sat Jan 18 01:29:02 2020
New Revision: 356859
URL: https://svnweb.freebsd.org/changeset/base/356859

Log:
  vfs: distribute freevnodes counter per-cpu
  
  It gets rolled up to the global when deferred requeueing is performed.
  A dedicated read routine makes sure to return a value only off by a certain
  amount.
  
  This soothes a global serialisation point for all 0<->1 hold count 
transitions.
  
  Reviewed by:  jeff
  Differential Revision:https://reviews.freebsd.org/D23235

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cSat Jan 18 01:26:54 2020(r356858)
+++ head/sys/kern/vfs_subr.cSat Jan 18 01:29:02 2020(r356859)
@@ -191,10 +191,11 @@ static struct vnode *vnode_list_reclaim_marker;
  * E.g., 9% of 75% of MAXVNODES is more than 566000 vnodes to reclaim
  * whenever vnlru_proc() becomes active.
  */
-static u_long wantfreevnodes;
-static u_long __exclusive_cache_line freevnodes;
+static long wantfreevnodes;
+static long __exclusive_cache_line freevnodes;
 SYSCTL_ULONG(_vfs, OID_AUTO, freevnodes, CTLFLAG_RD,
 &freevnodes, 0, "Number of \"free\" vnodes");
+static long freevnodes_old;
 
 static counter_u64_t recycles_count;
 SYSCTL_COUNTER_U64(_vfs, OID_AUTO, recycles, CTLFLAG_RD, &recycles_count,
@@ -299,6 +300,7 @@ SYSCTL_INT(_debug, OID_AUTO, rush_requests, CTLFLAG_RW
 #defineVDBATCH_SIZE 8
 struct vdbatch {
u_int index;
+   long freevnodes;
struct mtx lock;
struct vnode *tab[VDBATCH_SIZE];
 };
@@ -323,6 +325,8 @@ static u_long vlowat;   /* minimal extras 
before expans
 static u_long vstir;   /* nonzero to stir non-free vnodes */
 static volatile int vsmalltrigger = 8; /* pref to keep if > this many pages */
 
+static u_long vnlru_read_freevnodes(void);
+
 /*
  * Note that no attempt is made to sanitize these parameters.
  */
@@ -1205,15 +1209,17 @@ SYSCTL_INT(_debug, OID_AUTO, max_vnlru_free, CTLFLAG_R
 /*
  * Attempt to reduce the free list by the requested amount.
  */
-static void
+static int
 vnlru_free_locked(int count, struct vfsops *mnt_op)
 {
struct vnode *vp, *mvp;
struct mount *mp;
+   int ocount;
 
mtx_assert(&vnode_list_mtx, MA_OWNED);
if (count > max_vnlru_free)
count = max_vnlru_free;
+   ocount = count;
mvp = vnode_list_free_marker;
 restart:
vp = mvp;
@@ -1254,6 +1260,7 @@ restart:
mtx_lock(&vnode_list_mtx);
goto restart;
}
+   return (ocount - count);
 }
 
 void
@@ -1283,6 +1290,38 @@ vnlru_recalc(void)
 static struct proc *vnlruproc;
 static int vnlruproc_sig;
 
+/*
+ * The main freevnodes counter is only updated when threads requeue their vnode
+ * batches. CPUs are conditionally walked to compute a more accurate total.
+ *
+ * Limit how much of a slop are we willing to tolerate. Note: the actual value
+ * at any given moment can still exceed slop, but it should not be by 
significant
+ * margin in practice.
+ */
+#define VNLRU_FREEVNODES_SLOP 128
+
+static u_long
+vnlru_read_freevnodes(void)
+{
+   struct vdbatch *vd;
+   long slop;
+   int cpu;
+
+   mtx_assert(&vnode_list_mtx, MA_OWNED);
+   if (freevnodes > freevnodes_old)
+   slop = freevnodes - freevnodes_old;
+   else
+   slop = freevnodes_old - freevnodes;
+   if (slop < VNLRU_FREEVNODES_SLOP)
+   return (freevnodes >= 0 ? freevnodes : 0);
+   freevnodes_old = freevnodes;
+   CPU_FOREACH(cpu) {
+   vd = DPCPU_ID_PTR((cpu), vd);
+   freevnodes_old += vd->freevnodes;
+   }
+   return (freevnodes_old >= 0 ? freevnodes_old : 0);
+}
+
 static bool
 vnlru_under(u_long rnumvnodes, u_long limit)
 {
@@ -1293,6 +1332,23 @@ vnlru_under(u_long rnumvnodes, u_long limit)
 
space = desiredvnodes - rnumvnodes;
if (space < limit) {
+   rfreevnodes = vnlru_read_freevnodes();
+   if (rfreevnodes > wantfreevnodes)
+   space += rfreevnodes - wantfreevnodes;
+   }
+   return (space < limit);
+}
+
+static bool
+vnlru_under_unlocked(u_long rnumvnodes, u_long limit)
+{
+   long rfreevnodes, space;
+
+   if (__predict_false(rnumvnodes > desiredvnodes))
+   return (true);
+
+   space = desiredvnodes - rnumvnodes;
+   if (space < limit) {
rfreevnodes = atomic_load_long(&freevnodes);
if (rfreevnodes > wantfreevnodes)
space += rfreevnodes - wantfreevnodes;
@@ -1317,16 +1373,23 @@ vnlru_proc(void)
u_long rnumvnodes, rfreevnodes, target;
unsigned long onumvnodes;
int done, force, trigger, usevnodes;
-   bool reclaim_nc_src;
+   bool reclaim_nc_src, want_reread;
 
EVENTHANDLER_REGISTER(shutdown_pre_sync, kproc_sh

svn commit: r356860 - in head/sys: powerpc/aim powerpc/powerpc tools

2020-01-17 Thread Justin Hibbits
Author: jhibbits
Date: Sat Jan 18 02:39:38 2020
New Revision: 356860
URL: https://svnweb.freebsd.org/changeset/base/356860

Log:
  Add a 'SINGLETON' directive to kobj interface definition
  
  Summary:
  This makes the interface described in the definition file act like a
  pseudo-IFUNC service, by caching the found method locally.
  
  Applying this to the PowerPC MMU definitions, it yields a significant
  (15-20%) performance improvement, seen in both a 'make buildworld' and a
  parallel build of LLVM, on a POWER9 system.
  
  Reviewed By:  imp
  Differential Revision:https://reviews.freebsd.org/D23245

Modified:
  head/sys/powerpc/aim/moea64_if.m
  head/sys/powerpc/powerpc/mmu_if.m
  head/sys/tools/makeobjops.awk

Modified: head/sys/powerpc/aim/moea64_if.m
==
--- head/sys/powerpc/aim/moea64_if.mSat Jan 18 01:29:02 2020
(r356859)
+++ head/sys/powerpc/aim/moea64_if.mSat Jan 18 02:39:38 2020
(r356860)
@@ -43,6 +43,7 @@
  */
 
 INTERFACE moea64;
+SINGLETON;
 
 CODE {
static moea64_pte_replace_t moea64_pte_replace_default;

Modified: head/sys/powerpc/powerpc/mmu_if.m
==
--- head/sys/powerpc/powerpc/mmu_if.m   Sat Jan 18 01:29:02 2020
(r356859)
+++ head/sys/powerpc/powerpc/mmu_if.m   Sat Jan 18 02:39:38 2020
(r356860)
@@ -46,6 +46,7 @@
  */
 
 INTERFACE mmu;
+SINGLETON;
 
 #
 # Default implementations of some methods

Modified: head/sys/tools/makeobjops.awk
==
--- head/sys/tools/makeobjops.awk   Sat Jan 18 01:29:02 2020
(r356859)
+++ head/sys/tools/makeobjops.awk   Sat Jan 18 02:39:38 2020
(r356860)
@@ -325,13 +325,18 @@ function handle_method (static, doc)
line_width, length(prototype)));
}
printh("{");
-   printh("\tkobjop_t _m;");
+   if (singleton)
+   printh("\tstatic kobjop_t _m;");
+   else
+   printh("\tkobjop_t _m;");
if (ret != "void")
printh("\t" ret " rc;");
if (!static)
firstvar = "((kobj_t)" firstvar ")";
if (prolog != "")
printh(prolog);
+   if (singleton)
+   printh("\tif (_m == NULL)");
printh("\tKOBJOPLOOKUP(" firstvar "->ops," mname ");");
rceq = (ret != "void") ? "rc = " : "";
printh("\t" rceq "((" mname "_t *) _m)(" varname_list ");");
@@ -453,6 +458,7 @@ for (file_i = 0; file_i < num_files; file_i++) {
lastdoc = "";
prolog = "";
epilog = "";
+   singleton = 0;
 
while (!error && (getline < src) > 0) {
lineno++;
@@ -497,6 +503,8 @@ for (file_i = 0; file_i < num_files; file_i++) {
prolog = handle_code();
else if (/^EPILOG[  ]*{$/)
epilog = handle_code();
+   else if (/^SINGLETON/)
+   singleton = 1;
else {
debug($0);
warnsrc("Invalid line encountered");
___
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: r356861 - head/sys/geom/label

2020-01-17 Thread Conrad Meyer
Author: cem
Date: Sat Jan 18 03:33:44 2020
New Revision: 356861
URL: https://svnweb.freebsd.org/changeset/base/356861

Log:
  GEOM label: strip leading/trailing space synthesizing devfs names
  
  %20%20%20 is ugly and doesn't really help make human-readable devfs names.
  
  PR:   243318
  Reported by:  Peter Eriksson 
  Relnotes: yes

Modified:
  head/sys/geom/label/g_label.c

Modified: head/sys/geom/label/g_label.c
==
--- head/sys/geom/label/g_label.c   Sat Jan 18 02:39:38 2020
(r356860)
+++ head/sys/geom/label/g_label.c   Sat Jan 18 03:33:44 2020
(r356861)
@@ -179,9 +179,25 @@ g_label_mangle_name(char *label, size_t size)
 {
struct sbuf *sb;
const u_char *c;
+   size_t len, i;
 
+   /* Trim trailing whitespace. */
+   len = strlen(label);
+   for (i = len; i > 0; i--) {
+   if (isspace(label[i - 1]))
+   label[i - 1] = '\0';
+   else
+   break;
+   }
+   if (*label == '\0')
+   return;
+
+
sb = sbuf_new(NULL, NULL, size, SBUF_FIXEDLEN);
for (c = label; *c != '\0'; c++) {
+   /* Trim leading whitespace. */
+   if (isspace(*c) && sbuf_len(sb) == 0)
+   continue;
if (!isprint(*c) || isspace(*c) || *c =='"' || *c == '%')
sbuf_printf(sb, "%%%02X", *c);
else
___
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: r356862 - in head/sys/powerpc: aim include

2020-01-17 Thread Brandon Bergren
Author: bdragon
Date: Sat Jan 18 04:12:41 2020
New Revision: 356862
URL: https://svnweb.freebsd.org/changeset/base/356862

Log:
  D23057: [PowerPC] Fix offset calculations in bridge mode
  
  In rS354701, I replaced text relocations with offsets from &generictrap.
  
  Unfortunately, the magic variable I was using doesn't actually mean the
  address of &generictrap, in bridge mode it actually means &generictrap64.
  
  So, for bridge mode to work, it is necessary to differentiate between
  "where do we need to branch to to handle a trap" and "where is &generictrap
  for purposes of doing relative math".
  
  Introduce a new TRAP_ENTRY and use it instead of TRAP_GENTRAP for doing
  actual calls to the generic trap handler.
  
  Reported by:  Mark Millard 
  Reviewed by:  jhibbits
  Sponsored by: Tag1 Consulting, Inc.
  Differential Revision:https://reviews.freebsd.org/D23057
  > Description of fields to fill in above: 76 columns --|
  > PR:   If and which Problem Report is related.
  > Submitted by: If someone else sent in the change.
  > Reported by:  If someone else reported the issue.
  > Reviewed by:  If someone else reviewed your modification.
  > Approved by:  If you needed approval for this commit.
  > Obtained from:If the change is from a third party.
  > MFC after:N [day[s]|week[s]|month[s]].  Request a reminder 
email.
  > MFH:  Ports tree branch name.  Request approval for 
merge.
  > Relnotes: Set to 'yes' for mention in release notes.
  > Security: Vulnerability reference (one per line) or 
description.
  > Sponsored by: If the change was sponsored by an organization 
(each collaborator).
  > Differential Revision:https://reviews.freebsd.org/D### (*full* phabric 
URL needed).
  > Empty fields above will be automatically removed.
  
  Msys/powerpc/aim/aim_machdep.c
  Msys/powerpc/aim/trap_subr32.S
  Msys/powerpc/aim/trap_subr64.S
  Msys/powerpc/include/trap.h

Modified:
  head/sys/powerpc/aim/aim_machdep.c
  head/sys/powerpc/aim/trap_subr32.S
  head/sys/powerpc/aim/trap_subr64.S
  head/sys/powerpc/include/trap.h

Modified: head/sys/powerpc/aim/aim_machdep.c
==
--- head/sys/powerpc/aim/aim_machdep.c  Sat Jan 18 03:33:44 2020
(r356861)
+++ head/sys/powerpc/aim/aim_machdep.c  Sat Jan 18 04:12:41 2020
(r356862)
@@ -388,16 +388,18 @@ aim_cpu_init(vm_offset_t toc)
bcopy(&dsitrap,  (void *)(EXC_DSI + trap_offset),  (size_t)&dsiend -
(size_t)&dsitrap);
 
+   /* Set address of generictrap for self-reloc calculations */
+   *((void **)TRAP_GENTRAP) = &generictrap;
#ifdef __powerpc64__
/* Set TOC base so that the interrupt code can get at it */
-   *((void **)TRAP_GENTRAP) = &generictrap;
+   *((void **)TRAP_ENTRY) = &generictrap;
*((register_t *)TRAP_TOCBASE) = toc;
#else
/* Set branch address for trap code */
if (cpu_features & PPC_FEATURE_64)
-   *((void **)TRAP_GENTRAP) = &generictrap64;
+   *((void **)TRAP_ENTRY) = &generictrap64;
else
-   *((void **)TRAP_GENTRAP) = &generictrap;
+   *((void **)TRAP_ENTRY) = &generictrap;
*((void **)TRAP_TOCBASE) = _GLOBAL_OFFSET_TABLE_;
 
/* G2-specific TLB miss helper handlers */

Modified: head/sys/powerpc/aim/trap_subr32.S
==
--- head/sys/powerpc/aim/trap_subr32.S  Sat Jan 18 03:33:44 2020
(r356861)
+++ head/sys/powerpc/aim/trap_subr32.S  Sat Jan 18 04:12:41 2020
(r356862)
@@ -348,7 +348,7 @@ CNAME(trapcode):
mtsprg1 %r1 /* save SP */
mflr%r1 /* Save the old LR in r1 */
mtsprg2 %r1 /* And then in SPRG2 */
-   lwz %r1, TRAP_GENTRAP(0)/* Get branch address */
+   lwz %r1, TRAP_ENTRY(0)  /* Get branch address */
mtlr%r1
li  %r1, 0xe0   /* How to get the vector from LR */
blrl/* LR & (0xff00 | r1) is exception # */
@@ -908,7 +908,7 @@ CNAME(dblow):
 mflr   %r1 /* save LR */
mtsprg2 %r1 /* And then in SPRG2 */
 
-   lwz %r1, TRAP_GENTRAP(0)/* Get branch address */
+   lwz %r1, TRAP_ENTRY(0)  /* Get branch address */
mtlr%r1
li  %r1, 0  /* How to get the vector from LR */
blrl/* LR & (0xff00 | r1) is exception # */

Modified: head/sys/powerpc/aim/trap_subr64.S
==
--- head/sys/powerpc/aim/trap_subr64.S  Sat Jan 18 03:33:44 20

svn commit: r356863 - head/sys/net

2020-01-17 Thread Eugene Grosbein
Author: eugen
Date: Sat Jan 18 04:48:05 2020
New Revision: 356863
URL: https://svnweb.freebsd.org/changeset/base/356863

Log:
  ifa_maintain_loopback_route: adjust debugging output
  
  Correction after r333476:
  
  - write this as LOG_DEBUG again instead of LOG_INFO;
  - get back function name into the message;
  - error may be ESRCH if an address is removed in process (by carp f.e.),
  not only ENOENT;
  - expression complexity grows, so try making it more readable.
  
  MFC after:1 week

Modified:
  head/sys/net/if.c

Modified: head/sys/net/if.c
==
--- head/sys/net/if.c   Sat Jan 18 04:12:41 2020(r356862)
+++ head/sys/net/if.c   Sat Jan 18 04:48:05 2020(r356863)
@@ -1867,10 +1867,13 @@ ifa_maintain_loopback_route(int cmd, const char *otype
if (rti_ifa != NULL)
ifa_free(rti_ifa);
 
-   if (error != 0 &&
-   !(cmd == RTM_ADD && error == EEXIST) &&
-   !(cmd == RTM_DELETE && error == ENOENT))
-   if_printf(ifp, "%s failed: %d\n", otype, error);
+   if (error == 0 ||
+   (cmd == RTM_ADD && error == EEXIST) ||
+   (cmd == RTM_DELETE && (error == ENOENT || error == ESRCH)))
+   return (error);
+
+   log(LOG_DEBUG, "%s: %s failed for interface %s: %u\n",
+   __func__, otype, if_name(ifp), error);
 
return (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"