svn commit: r356068 - stable/12/sys/modules/uart

2019-12-24 Thread Mark Johnston
Author: markj
Date: Wed Dec 25 05:51:47 2019
New Revision: 356068
URL: https://svnweb.freebsd.org/changeset/base/356068

Log:
  MFC r356030:
  Compile uart_cpu_acpi.c, added in r348195, into uart.ko.
  
  PR:   242771

Modified:
  stable/12/sys/modules/uart/Makefile
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/modules/uart/Makefile
==
--- stable/12/sys/modules/uart/Makefile Wed Dec 25 05:00:50 2019
(r356067)
+++ stable/12/sys/modules/uart/Makefile Wed Dec 25 05:51:47 2019
(r356068)
@@ -5,6 +5,7 @@
 .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \
 ${MACHINE_CPUARCH} == "i386"
 uart_bus_acpi=uart_bus_acpi.c
+uart_cpu_acpi=uart_cpu_acpi.c
 .endif
 
 .if ${MACHINE_CPUARCH} == "sparc64"
@@ -34,7 +35,7 @@ uart_dev_mu=uart_dev_mu.c
 KMOD=  uart
 SRCS=  ${uart_bus_acpi} ${uart_bus_ebus} uart_bus_isa.c uart_bus_pccard.c \
uart_bus_pci.c uart_bus_puc.c uart_bus_scc.c \
-   uart_core.c ${uart_cpu_machine} uart_dbg.c \
+   uart_core.c ${uart_cpu_acpi} ${uart_cpu_machine} uart_dbg.c \
${uart_dev_mvebu} uart_dev_ns8250.c ${uart_dev_mu} \
uart_dev_quicc.c uart_dev_sab82532.c uart_dev_z8530.c \
uart_if.c uart_if.h uart_subr.c uart_tty.c
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356067 - stable/12/sbin/hastd

2019-12-24 Thread Kirk McKusick
Author: mckusick
Date: Wed Dec 25 05:00:50 2019
New Revision: 356067
URL: https://svnweb.freebsd.org/changeset/base/356067

Log:
  MFC of 355995
  
  Fix manual page typo.

Modified:
  stable/12/sbin/hastd/hastd.8
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/hastd/hastd.8
==
--- stable/12/sbin/hastd/hastd.8Wed Dec 25 01:15:38 2019
(r356066)
+++ stable/12/sbin/hastd/hastd.8Wed Dec 25 05:00:50 2019
(r356067)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 8, 2016
+.Dd December 21, 2019
 .Dt HASTD 8
 .Os
 .Sh NAME
@@ -44,7 +44,7 @@ The
 daemon is responsible for managing highly available GEOM providers.
 .Pp
 .Nm
-allows the transpaent storage of data on two physically separated machines
+allows the transparent storage of data on two physically separated machines
 connected over a TCP/IP network.
 Only one machine (cluster node) can actively use storage provided by
 .Nm .
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356066 - head/sys/fs/nfsclient

2019-12-24 Thread Rick Macklem
Author: rmacklem
Date: Wed Dec 25 01:15:38 2019
New Revision: 356066
URL: https://svnweb.freebsd.org/changeset/base/356066

Log:
  Fix nfsmount() so that it will return NFSERR_MINORVERMISMATCH.
  
  If nfsrpc_getdirpath() returns NFSERR_MINORVERMISMATCH, it would erroneously
  get mapped to EIO. This was not particularily harmful, but would make it
  hard for sysadmins to diagnose why an NFSv4 mount is failing.
  
  mount_nfs.c still needs to be fixed so that it does not report
  NFSERR_MINORVERMISMATCH as an unknown error 10021.
  
  MFC after:1 week

Modified:
  head/sys/fs/nfsclient/nfs_clvfsops.c

Modified: head/sys/fs/nfsclient/nfs_clvfsops.c
==
--- head/sys/fs/nfsclient/nfs_clvfsops.cTue Dec 24 23:43:29 2019
(r356065)
+++ head/sys/fs/nfsclient/nfs_clvfsops.cWed Dec 25 01:15:38 2019
(r356066)
@@ -1544,10 +1544,8 @@ mountnfs(struct nfs_args *argp, struct mount *mp, stru
if (error)
(void) nfs_catnap(PZERO, error, "nfsgetdirp");
} while (error && --trycnt > 0);
-   if (error) {
-   error = nfscl_maperr(td, error, (uid_t)0, (gid_t)0);
+   if (error)
goto bad;
-   }
}
 
/*
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356065 - head/sys/arm/arm

2019-12-24 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Dec 24 23:43:29 2019
New Revision: 356065
URL: https://svnweb.freebsd.org/changeset/base/356065

Log:
  Initialize the bounce pages list in armv[4|6] DMA maps.
  
  Fixes the crash on the first use of STAILQ_INSERT_TAIL() in
  add_bounce_page().
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/arm/busdma_machdep-v4.c
  head/sys/arm/arm/busdma_machdep-v6.c

Modified: head/sys/arm/arm/busdma_machdep-v4.c
==
--- head/sys/arm/arm/busdma_machdep-v4.cTue Dec 24 23:20:18 2019
(r356064)
+++ head/sys/arm/arm/busdma_machdep-v4.cTue Dec 24 23:43:29 2019
(r356065)
@@ -669,6 +669,7 @@ allocate_map(bus_dma_tag_t dmat, int mflags)
return (NULL);
}
map->segments = (bus_dma_segment_t *)((uintptr_t)map + mapsize);
+   STAILQ_INIT(>bpages);
return (map);
 }
 

Modified: head/sys/arm/arm/busdma_machdep-v6.c
==
--- head/sys/arm/arm/busdma_machdep-v6.cTue Dec 24 23:20:18 2019
(r356064)
+++ head/sys/arm/arm/busdma_machdep-v6.cTue Dec 24 23:43:29 2019
(r356065)
@@ -735,6 +735,7 @@ allocate_map(bus_dma_tag_t dmat, int mflags)
return (NULL);
}
map->segments = (bus_dma_segment_t *)((uintptr_t)map + mapsize);
+   STAILQ_INIT(>bpages);
return (map);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356064 - stable/11/sys/arm/arm

2019-12-24 Thread Luiz Otavio O Souza
Author: loos
Date: Tue Dec 24 23:20:18 2019
New Revision: 356064
URL: https://svnweb.freebsd.org/changeset/base/356064

Log:
  MFC r320001 by zbb:
  
  Fix typo in "Marvell" string
  
  Change Marwell to Marvell
  
  Pointed out by:   Ravi Pokala 
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  stable/11/sys/arm/arm/identcpu-v6.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/arm/arm/identcpu-v6.c
==
--- stable/11/sys/arm/arm/identcpu-v6.c Tue Dec 24 23:03:12 2019
(r356063)
+++ stable/11/sys/arm/arm/identcpu-v6.c Tue Dec 24 23:20:18 2019
(r356064)
@@ -83,8 +83,8 @@ static struct {
{CPU_IMPLEMENTER_ARM, CPU_ARCH_CORTEX_A72, "ARM", "Cortex-A72"},
{CPU_IMPLEMENTER_ARM, CPU_ARCH_CORTEX_A73, "ARM", "Cortex-A73"},
 
-   {CPU_IMPLEMENTER_MRVL, CPU_ARCH_SHEEVA_581, "Marwell", "PJ4 v7"},
-   {CPU_IMPLEMENTER_MRVL, CPU_ARCH_SHEEVA_584, "Marwell", "PJ4MP v7"},
+   {CPU_IMPLEMENTER_MRVL, CPU_ARCH_SHEEVA_581, "Marvell", "PJ4 v7"},
+   {CPU_IMPLEMENTER_MRVL, CPU_ARCH_SHEEVA_584, "Marvell", "PJ4MP v7"},
 
{CPU_IMPLEMENTER_QCOM, CPU_ARCH_KRAIT_300, "Qualcomm", "Krait 300"},
 };
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356063 - head/sbin/fsck_ffs

2019-12-24 Thread Kirk McKusick
Author: mckusick
Date: Tue Dec 24 23:03:12 2019
New Revision: 356063
URL: https://svnweb.freebsd.org/changeset/base/356063

Log:
  When running fsck_ffs manually, do not ask:
  
USE JOURNAL? [yn]
  
  when the journal timestamp does not match the filesystem mount time
  as we are just going to print an error and fall through to a full fsck.
  Instead, just run a full fsck.
  
  Requested by: Bjoern A. Zeeb (bz)
  MFC after:7 days

Modified:
  head/sbin/fsck_ffs/main.c
  head/sbin/fsck_ffs/suj.c

Modified: head/sbin/fsck_ffs/main.c
==
--- head/sbin/fsck_ffs/main.c   Tue Dec 24 22:27:06 2019(r356062)
+++ head/sbin/fsck_ffs/main.c   Tue Dec 24 23:03:12 2019(r356063)
@@ -423,13 +423,11 @@ checkfilesys(char *filesys)
 */
if ((sblock.fs_flags & FS_SUJ) == FS_SUJ) {
if ((sblock.fs_flags & FS_NEEDSFSCK) != FS_NEEDSFSCK && 
skipclean) {
-   if (preen || reply("USE JOURNAL")) {
-   if (suj_check(filesys) == 0) {
-   printf("\n* FILE SYSTEM MARKED 
CLEAN *\n");
-   if (chkdoreload(mntp) == 0)
-   exit(0);
-   exit(4);
-   }
+   if (suj_check(filesys) == 0) {
+   printf("\n* FILE SYSTEM MARKED CLEAN 
*\n");
+   if (chkdoreload(mntp) == 0)
+   exit(0);
+   exit(4);
}
printf("** Skipping journal, falling through to full 
fsck\n\n");
}

Modified: head/sbin/fsck_ffs/suj.c
==
--- head/sbin/fsck_ffs/suj.cTue Dec 24 22:27:06 2019(r356062)
+++ head/sbin/fsck_ffs/suj.cTue Dec 24 23:03:12 2019(r356063)
@@ -2720,6 +2720,8 @@ suj_check(const char *filesys)
printf("** SU+J Recovering %s\n", filesys);
if (suj_verifyino(jip) != 0)
return (-1);
+   if (!preen && !reply("USE JOURNAL"))
+   return (-1);
/*
 * Build a list of journal blocks in jblocks before parsing the
 * available journal blocks in with suj_read().
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356062 - head/sys/dev/aic7xxx

2019-12-24 Thread Brandon Bergren
Author: bdragon
Date: Tue Dec 24 22:27:06 2019
New Revision: 356062
URL: https://svnweb.freebsd.org/changeset/base/356062

Log:
  Fix trivial whitespace issue that is tripping -Wmisleading-indentation
  in clang HEAD.
  
  There was an invisible space in the middle of the tabs, and that apprently
  was enough to throw off clang's column counting.
  
  Even if clang is "incorrect" here, it's still a style(9) violation.

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

Modified: head/sys/dev/aic7xxx/aic7xxx.c
==
--- head/sys/dev/aic7xxx/aic7xxx.c  Tue Dec 24 20:13:29 2019
(r356061)
+++ head/sys/dev/aic7xxx/aic7xxx.c  Tue Dec 24 22:27:06 2019
(r356062)
@@ -1749,7 +1749,7 @@ ahc_find_syncrate(struct ahc_softc *ahc, u_int *period
 * At some speeds, we only support
 * ST transfers.
 */
-   if ((syncrate->sxfr_u2 & ST_SXFR) != 0)
+   if ((syncrate->sxfr_u2 & ST_SXFR) != 0)
*ppr_options &= ~MSG_EXT_PPR_DT_REQ;
break;
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2019-12-24 Thread Brandon Bergren
Author: bdragon
Date: Tue Dec 24 20:13:29 2019
New Revision: 356061
URL: https://svnweb.freebsd.org/changeset/base/356061

Log:
  [PowerPC] Define powerpc IFUNC kernel/userspace ABI.
  
  This is a prerequisite for anything IFUNC in the ELFv2 / clang switch.
  
  Since probing cpu info on powerpc is a privileged operation, define that we
  pass AT_HWCAP / AT_HWCAP2 through as cpu_features and cpu_features2 to ifunc
  resolvers.
  
  This is particularly important when dealing with non-PLT GNU IFUNC, which is
  not allowed to PLT call from resolvers and therefore can't access global
  variables.
  
  The naming convention "cpu_features"/"cpu_features2" is an existing FreeBSD
  PowerPC convention and matches the way we treat these variables in
  machine/cpu.h.
  
  The underlying variables are u_long, however, as per the commit message for
  r332868, only the low 32 bits are ever used, so the underlying flags are
  compatible across all of PowerPC.
  
  The resolver prototype is defined to reserve the maximum number of
  register-passed parameters the various PowerPC ABIs allow. This leaves
  plenty of room for growth without needing to resort to passing via the
  stack in the future.
  
  Reviewed by:  jhibbits
  Differential Revision:https://reviews.freebsd.org/D22787

Added:
  head/sys/powerpc/include/ifunc.h   (contents, props changed)

Added: head/sys/powerpc/include/ifunc.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/powerpc/include/ifunc.hTue Dec 24 20:13:29 2019
(r356061)
@@ -0,0 +1,60 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2019 Brandon Bergren 
+ * Copyright (c) 2015-2018 The FreeBSD Foundation. All rights reserved.
+ *
+ * Part of this software was developed by
+ * Konstantin Belousov 
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef __POWERPC_IFUNC_H
+#define__POWERPC_IFUNC_H
+
+#include 
+
+#defineDEFINE_IFUNC(qual, ret_type, name, args)
\
+static ret_type (*name##_resolver(void))args __used;   \
+qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
+static ret_type (*name##_resolver(void))args
+
+#defineDEFINE_UIFUNC(qual, ret_type, name, args)   
\
+static ret_type (*name##_resolver(register_t, register_t,  \
+   register_t, register_t, register_t, register_t, register_t, \
+   register_t))args __used;\
+qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
+static ret_type (*name##_resolver( \
+   register_t cpu_features,\
+   register_t cpu_features2,   \
+   register_t arg3 __unused,   \
+   register_t arg4 __unused,   \
+   register_t arg5 __unused,   \
+   register_t arg6 __unused,   \
+   register_t arg7 __unused,   \
+   register_t arg8 __unused))args
+
+#endif
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356060 - head/usr.sbin/fstyp

2019-12-24 Thread Pedro F. Giffuni
Author: pfg
Date: Tue Dec 24 19:00:20 2019
New Revision: 356060
URL: https://svnweb.freebsd.org/changeset/base/356060

Log:
  sbin/fstyp: recgonize Dragonfly's hammer and hammer2.
  
  This is based on DragonFly's implementation from about 2019-09-13. It
  only contains the basic code and header information to identify the
  disks.
  
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D13369

Added:
  head/usr.sbin/fstyp/hammer.c   (contents, props changed)
  head/usr.sbin/fstyp/hammer2.c   (contents, props changed)
  head/usr.sbin/fstyp/hammer2_disk.h   (contents, props changed)
  head/usr.sbin/fstyp/hammer_disk.h   (contents, props changed)
Modified:
  head/usr.sbin/fstyp/Makefile
  head/usr.sbin/fstyp/fstyp.8
  head/usr.sbin/fstyp/fstyp.c
  head/usr.sbin/fstyp/fstyp.h

Modified: head/usr.sbin/fstyp/Makefile
==
--- head/usr.sbin/fstyp/MakefileTue Dec 24 18:38:06 2019
(r356059)
+++ head/usr.sbin/fstyp/MakefileTue Dec 24 19:00:20 2019
(r356060)
@@ -3,7 +3,8 @@
 .include 
 
 PROG=  fstyp
-SRCS=  apfs.c cd9660.c exfat.c ext2fs.c fstyp.c geli.c hfsplus.c msdosfs.c 
ntfs.c ufs.c
+SRCS=  apfs.c cd9660.c exfat.c ext2fs.c fstyp.c geli.c hammer.c\
+   hammer2.c hfsplus.c msdosfs.c ntfs.c ufs.c
 
 .if ${MK_ZFS} != "no"
 SRCS +=zfs.c

Modified: head/usr.sbin/fstyp/fstyp.8
==
--- head/usr.sbin/fstyp/fstyp.8 Tue Dec 24 18:38:06 2019(r356059)
+++ head/usr.sbin/fstyp/fstyp.8 Tue Dec 24 19:00:20 2019(r356060)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 26, 2017
+.Dd December 24, 2019
 .Dt FSTYP 8
 .Os
 .Sh NAME
@@ -67,6 +67,10 @@ exfat
 ext2fs
 .It
 geli
+.It
+hammer
+.It
+hammer2
 .It
 msdosfs
 .It

Modified: head/usr.sbin/fstyp/fstyp.c
==
--- head/usr.sbin/fstyp/fstyp.c Tue Dec 24 18:38:06 2019(r356059)
+++ head/usr.sbin/fstyp/fstyp.c Tue Dec 24 19:00:20 2019(r356060)
@@ -69,6 +69,8 @@ static struct {
{ "exfat", _exfat, false, EXFAT_ENC },
{ "ext2fs", _ext2fs, false, NULL },
{ "geli", _geli, true, NULL },
+   { "hammer", _hammer, true, NULL },
+   { "hammer2", _hammer2, true, NULL },
{ "hfs+", _hfsp, false, NULL },
{ "msdosfs", _msdosfs, false, NULL },
{ "ntfs", _ntfs, false, NTFS_ENC },

Modified: head/usr.sbin/fstyp/fstyp.h
==
--- head/usr.sbin/fstyp/fstyp.h Tue Dec 24 18:38:06 2019(r356059)
+++ head/usr.sbin/fstyp/fstyp.h Tue Dec 24 19:00:20 2019(r356060)
@@ -55,6 +55,8 @@ int   fstyp_cd9660(FILE *fp, char *label, size_t size);
 intfstyp_exfat(FILE *fp, char *label, size_t size);
 intfstyp_ext2fs(FILE *fp, char *label, size_t size);
 intfstyp_geli(FILE *fp, char *label, size_t size);
+intfstyp_hammer(FILE *fp, char *label, size_t size);
+intfstyp_hammer2(FILE *fp, char *label, size_t size);
 intfstyp_hfsp(FILE *fp, char *label, size_t size);
 intfstyp_msdosfs(FILE *fp, char *label, size_t size);
 intfstyp_ntfs(FILE *fp, char *label, size_t size);

Added: head/usr.sbin/fstyp/hammer.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/fstyp/hammer.cTue Dec 24 19:00:20 2019
(r356060)
@@ -0,0 +1,198 @@
+/*-
+ * Copyright (c) 2016 The DragonFly Project
+ * All rights reserved.
+ *
+ * This software was developed by Edward Tomasz Napierala under sponsorship
+ * from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 

svn commit: r356059 - head/sys/vm

2019-12-24 Thread Jeff Roberson
Author: jeff
Date: Tue Dec 24 18:38:06 2019
New Revision: 356059
URL: https://svnweb.freebsd.org/changeset/base/356059

Log:
  Don't unnecessarily relock the vm object after sleeps.  This results in a
  surprising amount of object contention on loop restarts in fault.
  
  Reviewed by:  kib, markj
  Differential Revision:https://reviews.freebsd.org/D22821

Modified:
  head/sys/vm/vm_fault.c
  head/sys/vm/vm_page.c

Modified: head/sys/vm/vm_fault.c
==
--- head/sys/vm/vm_fault.c  Tue Dec 24 16:52:10 2019(r356058)
+++ head/sys/vm/vm_fault.c  Tue Dec 24 18:38:06 2019(r356059)
@@ -713,8 +713,9 @@ vm_fault_busy_sleep(struct faultstate *fs)
vm_object_pip_wakeup(fs->object);
unlock_map(fs);
if (fs->m == vm_page_lookup(fs->object, fs->pindex))
-   vm_page_sleep_if_busy(fs->m, "vmpfw");
-   VM_OBJECT_WUNLOCK(fs->object);
+   vm_page_busy_sleep(fs->m, "vmpfw", false);
+   else
+   VM_OBJECT_WUNLOCK(fs->object);
VM_CNT_INC(v_intrans);
vm_object_deallocate(fs->first_object);
 }

Modified: head/sys/vm/vm_page.c
==
--- head/sys/vm/vm_page.c   Tue Dec 24 16:52:10 2019(r356058)
+++ head/sys/vm/vm_page.c   Tue Dec 24 18:38:06 2019(r356059)
@@ -176,7 +176,7 @@ SYSCTL_PROC(_vm, OID_AUTO, page_blacklist, CTLTYPE_STR
 static uma_zone_t fakepg_zone;
 
 static void vm_page_alloc_check(vm_page_t m);
-static void _vm_page_busy_sleep(vm_object_t obj, vm_page_t m,
+static bool _vm_page_busy_sleep(vm_object_t obj, vm_page_t m,
 const char *wmesg, bool nonshared, bool locked);
 static void vm_page_clear_dirty_mask(vm_page_t m, vm_page_bits_t pagebits);
 static void vm_page_dequeue_complete(vm_page_t m);
@@ -878,8 +878,13 @@ vm_page_acquire_flags(vm_page_t m, int allocflags)
return (locked);
 }
 
+/*
+ * vm_page_busy_sleep_flags
+ *
+ * Sleep for busy according to VM_ALLOC_ parameters.
+ */
 static bool
-vm_page_busy_sleep_flags(vm_object_t object, vm_page_t m, const char *wchan,
+vm_page_busy_sleep_flags(vm_object_t object, vm_page_t m, const char *wmesg,
 int allocflags)
 {
 
@@ -892,9 +897,9 @@ vm_page_busy_sleep_flags(vm_object_t object, vm_page_t
 */
if ((allocflags & VM_ALLOC_NOCREAT) == 0)
vm_page_aflag_set(m, PGA_REFERENCED);
-   vm_page_busy_sleep(m, wchan, (allocflags &
-   VM_ALLOC_IGN_SBUSY) != 0);
-   VM_OBJECT_WLOCK(object);
+   if (_vm_page_busy_sleep(object, m, wmesg, (allocflags &
+   VM_ALLOC_IGN_SBUSY) != 0, true))
+   VM_OBJECT_WLOCK(object);
if ((allocflags & VM_ALLOC_WAITFAIL) != 0)
return (false);
return (true);
@@ -930,9 +935,8 @@ vm_page_busy_acquire(vm_page_t m, int allocflags)
else
locked = false;
MPASS(locked || vm_page_wired(m));
-   _vm_page_busy_sleep(obj, m, "vmpba",
-   (allocflags & VM_ALLOC_SBUSY) != 0, locked);
-   if (locked)
+   if (_vm_page_busy_sleep(obj, m, "vmpba",
+   (allocflags & VM_ALLOC_SBUSY) != 0, locked))
VM_OBJECT_WLOCK(obj);
if ((allocflags & VM_ALLOC_WAITFAIL) != 0)
return (false);
@@ -1055,10 +1059,16 @@ vm_page_busy_sleep(vm_page_t m, const char *wmesg, boo
VM_OBJECT_ASSERT_LOCKED(obj);
vm_page_lock_assert(m, MA_NOTOWNED);
 
-   _vm_page_busy_sleep(obj, m, wmesg, nonshared, true);
+   if (!_vm_page_busy_sleep(obj, m, wmesg, nonshared, true))
+   VM_OBJECT_DROP(obj);
 }
 
-static void
+/*
+ * _vm_page_busy_sleep:
+ *
+ * Internal busy sleep function.
+ */
+static bool
 _vm_page_busy_sleep(vm_object_t obj, vm_page_t m, const char *wmesg,
 bool nonshared, bool locked)
 {
@@ -1072,17 +1082,15 @@ _vm_page_busy_sleep(vm_object_t obj, vm_page_t m, cons
if (locked)
VM_OBJECT_DROP(obj);
vm_object_busy_wait(obj, wmesg);
-   return;
+   return (locked);
}
sleepq_lock(m);
x = m->busy_lock;
if (x == VPB_UNBUSIED || (nonshared && (x & VPB_BIT_SHARED) != 0) ||
((x & VPB_BIT_WAITERS) == 0 &&
!atomic_cmpset_int(>busy_lock, x, x | VPB_BIT_WAITERS))) {
-   if (locked)
-   VM_OBJECT_DROP(obj);
sleepq_release(m);
-   return;
+   return (false);
}
if (locked)
VM_OBJECT_DROP(obj);
@@ -1090,6 +1098,7 @@ _vm_page_busy_sleep(vm_object_t obj, vm_page_t m, cons
sleepq_add(m, NULL, wmesg, 0, 0);
sleepq_wait(m, PVM);
PICKUP_GIANT();
+   return (locked);
 }
 
 /*

svn commit: r356058 - in head/sys: amd64/amd64 mips/mips sys

2019-12-24 Thread Brandon Bergren
Author: bdragon
Date: Tue Dec 24 16:52:10 2019
New Revision: 356058
URL: https://svnweb.freebsd.org/changeset/base/356058

Log:
  Unbreak build. It seems that mips and amd64 still pull in link_elf.c, so
  we need to have elf_cpu_parse_dynamic() everywhere after all to avoid
  an undefined symbol.

Modified:
  head/sys/amd64/amd64/elf_machdep.c
  head/sys/mips/mips/elf_machdep.c
  head/sys/sys/linker.h

Modified: head/sys/amd64/amd64/elf_machdep.c
==
--- head/sys/amd64/amd64/elf_machdep.c  Tue Dec 24 16:19:33 2019
(r356057)
+++ head/sys/amd64/amd64/elf_machdep.c  Tue Dec 24 16:52:10 2019
(r356058)
@@ -329,3 +329,10 @@ elf_cpu_unload_file(linker_file_t lf __unused)
 
return (0);
 }
+
+int
+elf_cpu_parse_dynamic(linker_file_t lf __unused, Elf_Dyn *dynamic __unused)
+{
+
+   return (0);
+}

Modified: head/sys/mips/mips/elf_machdep.c
==
--- head/sys/mips/mips/elf_machdep.cTue Dec 24 16:19:33 2019
(r356057)
+++ head/sys/mips/mips/elf_machdep.cTue Dec 24 16:52:10 2019
(r356058)
@@ -501,3 +501,10 @@ elf_cpu_unload_file(linker_file_t lf __unused)
 
return (0);
 }
+
+int
+elf_cpu_parse_dynamic(linker_file_t lf __unused, Elf_Dyn *dynamic __unused)
+{
+
+   return (0);
+}

Modified: head/sys/sys/linker.h
==
--- head/sys/sys/linker.h   Tue Dec 24 16:19:33 2019(r356057)
+++ head/sys/sys/linker.h   Tue Dec 24 16:52:10 2019(r356058)
@@ -305,10 +305,7 @@ intlinker_ctf_get(linker_file_t, linker_ctf_t *);
 
 int elf_cpu_load_file(linker_file_t);
 int elf_cpu_unload_file(linker_file_t);
-/* amd64 and mips use objects instead of shared libraries */
-#if !defined(__amd64__) && !defined(__mips__)
 int elf_cpu_parse_dynamic(linker_file_t, Elf_Dyn *);
-#endif
 
 /* values for type */
 #define ELF_RELOC_REL  1
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356057 - in head: share/man/man9 sys/ddb sys/kern sys/sys

2019-12-24 Thread Conrad Meyer
Author: cem
Date: Tue Dec 24 16:19:33 2019
New Revision: 356057
URL: https://svnweb.freebsd.org/changeset/base/356057

Log:
  sleep(9), sleepqueue(9): const'ify wchan pointers
  
  _sleep(9), wakeup(9), sleepqueue(9), et al do not dereference or modify the
  channel pointers provided in any way; they are merely used as intptrs into a
  dictionary structure to match waiters with wakers.  Correctly annotate this
  such that _sleep() and wakeup() may be used on const pointers without
  invoking ugly patterns like __DECONST().  Plumb const through all of the
  underlying sleepqueue bits.
  
  No functional change.
  
  Reviewed by:  rlibby
  Discussed with:   kib, markj
  Differential Revision:https://reviews.freebsd.org/D22914

Modified:
  head/share/man/man9/sleep.9
  head/share/man/man9/sleepqueue.9
  head/sys/ddb/db_ps.c
  head/sys/kern/kern_clock.c
  head/sys/kern/kern_lock.c
  head/sys/kern/kern_proc.c
  head/sys/kern/kern_sx.c
  head/sys/kern/kern_synch.c
  head/sys/kern/subr_sleepqueue.c
  head/sys/sys/proc.h
  head/sys/sys/sleepqueue.h
  head/sys/sys/systm.h
  head/sys/sys/user.h

Modified: head/share/man/man9/sleep.9
==
--- head/share/man/man9/sleep.9 Tue Dec 24 16:13:15 2019(r356056)
+++ head/share/man/man9/sleep.9 Tue Dec 24 16:19:33 2019(r356057)
@@ -47,14 +47,14 @@
 .In sys/systm.h
 .In sys/proc.h
 .Ft int
-.Fn msleep "void *chan" "struct mtx *mtx" "int priority" "const char *wmesg" 
"int timo"
+.Fn msleep "const void *chan" "struct mtx *mtx" "int priority" "const char 
*wmesg" "int timo"
 .Ft int
-.Fn msleep_sbt "void *chan" "struct mtx *mtx" "int priority" \
+.Fn msleep_sbt "const void *chan" "struct mtx *mtx" "int priority" \
 "const char *wmesg" "sbintime_t sbt" "sbintime_t pr" "int flags"
 .Ft int
-.Fn msleep_spin "void *chan" "struct mtx *mtx" "const char *wmesg" "int timo"
+.Fn msleep_spin "const void *chan" "struct mtx *mtx" "const char *wmesg" "int 
timo"
 .Ft int
-.Fn msleep_spin_sbt "void *chan" "struct mtx *mtx" "const char *wmesg" \
+.Fn msleep_spin_sbt "const void *chan" "struct mtx *mtx" "const char *wmesg" \
 "sbintime_t sbt" "sbintime_t pr" "int flags"
 .Ft int
 .Fn pause "const char *wmesg" "int timo"
@@ -64,16 +64,16 @@
 .Fn pause_sbt "const char *wmesg" "sbintime_t sbt" "sbintime_t pr" \
  "int flags"
 .Ft int
-.Fn tsleep "void *chan" "int priority" "const char *wmesg" "int timo"
+.Fn tsleep "const void *chan" "int priority" "const char *wmesg" "int timo"
 .Ft int
-.Fn tsleep_sbt "void *chan" "int priority" "const char *wmesg" \
+.Fn tsleep_sbt "const void *chan" "int priority" "const char *wmesg" \
 "sbintime_t sbt" "sbintime_t pr" "int flags"
 .Ft void
-.Fn wakeup "void *chan"
+.Fn wakeup "const void *chan"
 .Ft void
-.Fn wakeup_one "void *chan"
+.Fn wakeup_one "const void *chan"
 .Ft void
-.Fn wakeup_any "void *chan"
+.Fn wakeup_any "const void *chan"
 .Sh DESCRIPTION
 The functions
 .Fn tsleep ,

Modified: head/share/man/man9/sleepqueue.9
==
--- head/share/man/man9/sleepqueue.9Tue Dec 24 16:13:15 2019
(r356056)
+++ head/share/man/man9/sleepqueue.9Tue Dec 24 16:19:33 2019
(r356057)
@@ -54,40 +54,40 @@
 .Ft int
 .Fn sleepq_abort "struct thread *td"
 .Ft void
-.Fn sleepq_add "void *wchan" "struct lock_object *lock" "const char *wmesg" 
"int flags" "int queue"
+.Fn sleepq_add "const void *wchan" "struct lock_object *lock" "const char 
*wmesg" "int flags" "int queue"
 .Ft struct sleepqueue *
 .Fn sleepq_alloc "void"
 .Ft int
-.Fn sleepq_broadcast "void *wchan" "int flags" "int pri" "int queue"
+.Fn sleepq_broadcast "const void *wchan" "int flags" "int pri" "int queue"
 .Ft void
 .Fn sleepq_free "struct sleepqueue *sq"
 .Ft struct sleepqueue *
-.Fn sleepq_lookup "void *wchan"
+.Fn sleepq_lookup "const void *wchan"
 .Ft void
-.Fn sleepq_lock "void *wchan"
+.Fn sleepq_lock "const void *wchan"
 .Ft void
-.Fn sleepq_release "void *wchan"
+.Fn sleepq_release "const void *wchan"
 .Ft void
-.Fn sleepq_remove "struct thread *td" "void *wchan"
+.Fn sleepq_remove "struct thread *td" "const void *wchan"
 .Ft int
-.Fn sleepq_signal "void *wchan" "int flags" "int pri" "int queue"
+.Fn sleepq_signal "const void *wchan" "int flags" "int pri" "int queue"
 .Ft void
-.Fn sleepq_set_timeout "void *wchan" "int timo"
+.Fn sleepq_set_timeout "const void *wchan" "int timo"
 .Ft void
-.Fn sleepq_set_timeout_sbt "void *wchan" "sbintime_t sbt" \
+.Fn sleepq_set_timeout_sbt "const void *wchan" "sbintime_t sbt" \
 "sbintime_t pr" "int flags"
 .Ft u_int
-.Fn sleepq_sleepcnt "void *wchan" "int queue"
+.Fn sleepq_sleepcnt "const void *wchan" "int queue"
 .Ft int
-.Fn sleepq_timedwait "void *wchan" "int pri"
+.Fn sleepq_timedwait "const void *wchan" "int pri"
 .Ft int
-.Fn sleepq_timedwait_sig "void *wchan" "int pri"
+.Fn sleepq_timedwait_sig "const void *wchan" "int pri"
 .Ft int
-.Fn sleepq_type "void 

svn commit: r356056 - head/libexec/rtld-elf/powerpc

2019-12-24 Thread Brandon Bergren
Author: bdragon
Date: Tue Dec 24 16:13:15 2019
New Revision: 356056
URL: https://svnweb.freebsd.org/changeset/base/356056

Log:
  [PowerPC] powerpc32 rtld IFUNC handling code
  
  As PowerPC is moving to clang, we can finally start taking advantage of
  IFUNC.
  
  Implement the MD parts of IFUNC handling for rtld.
  
  Currently, it is necessary to look for R_PPC_IRELATIVE in the PLT in
  addition to RELA. This is an ABI violation, but LLD9 has some .iplt bugs
  that require this as a workaround.
  
  Reviewed by:  jhibbits
  Differential Revision:https://reviews.freebsd.org/D22855

Modified:
  head/libexec/rtld-elf/powerpc/reloc.c
  head/libexec/rtld-elf/powerpc/rtld_machdep.h

Modified: head/libexec/rtld-elf/powerpc/reloc.c
==
--- head/libexec/rtld-elf/powerpc/reloc.c   Tue Dec 24 16:07:35 2019
(r356055)
+++ head/libexec/rtld-elf/powerpc/reloc.c   Tue Dec 24 16:13:15 2019
(r356056)
@@ -166,82 +166,84 @@ static int
 reloc_nonplt_object(Obj_Entry *obj_rtld __unused, Obj_Entry *obj,
 const Elf_Rela *rela, SymCache *cache, int flags, RtldLockState *lockstate)
 {
-   Elf_Addr*where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
-   const Elf_Sym   *def;
-   const Obj_Entry *defobj;
-   Elf_Addr tmp;
+   const Elf_Sym   *def = NULL;
+   const Obj_Entry *defobj;
+   Elf_Addr*where, symval = 0;
 
+   /*
+* First, resolve symbol for relocations which
+* reference symbols.
+*/
switch (ELF_R_TYPE(rela->r_info)) {
 
-   case R_PPC_NONE:
-   break;
-
-case R_PPC_ADDR32:/* word32 S + A */
-case R_PPC_GLOB_DAT:  /* word32 S + A */
+   case R_PPC_UADDR32:/* word32 S + A */
+   case R_PPC_ADDR32:
+   case R_PPC_GLOB_DAT:  /* word32 S + A */
+   case R_PPC_DTPMOD32:
+   case R_PPC_TPREL32:
+   case R_PPC_DTPREL32:
def = find_symdef(ELF_R_SYM(rela->r_info), obj, ,
flags, cache, lockstate);
if (def == NULL) {
return (-1);
}
 
-tmp = (Elf_Addr)(defobj->relocbase + def->st_value +
-rela->r_addend);
-
-   /* Don't issue write if unnecessary; avoid COW page fault */
-if (*where != tmp) {
-*where = tmp;
-   }
-break;
-
-case R_PPC_RELATIVE:  /* word32 B + A */
-   tmp = (Elf_Addr)(obj->relocbase + rela->r_addend);
-
-   /* As above, don't issue write unnecessarily */
-   if (*where != tmp) {
-   *where = tmp;
-   }
-   break;
-
-   case R_PPC_COPY:
/*
-* These are deferred until all other relocations
-* have been done.  All we do here is make sure
-* that the COPY relocation is not in a shared
-* library.  They are allowed only in executable
-* files.
+* If symbol is IFUNC, only perform relocation
+* when caller allowed it by passing
+* SYMLOOK_IFUNC flag.  Skip the relocations
+* otherwise.
+*
+* Also error out in case IFUNC relocations
+* are specified for TLS, which cannot be
+* usefully interpreted.
 */
-   if (!obj->mainprog) {
-   _rtld_error("%s: Unexpected R_COPY "
-   " relocation in shared library",
-   obj->path);
-   return (-1);
+   if (ELF_ST_TYPE(def->st_info) == STT_GNU_IFUNC) {
+   switch (ELF_R_TYPE(rela->r_info)) {
+   case R_PPC_UADDR32:
+   case R_PPC_ADDR32:
+   case R_PPC_GLOB_DAT:
+   if ((flags & SYMLOOK_IFUNC) == 0) {
+   dbg("Non-PLT reference to IFUNC 
found!");
+   obj->non_plt_gnu_ifunc = true;
+   return (0);
+   }
+   symval = (Elf_Addr)rtld_resolve_ifunc(
+   defobj, def);
+   break;
+   default:
+   _rtld_error("%s: IFUNC for TLS reloc",
+   obj->path);
+   return (-1);
+   }
+   } else {
+   if ((flags & SYMLOOK_IFUNC) != 0)
+   return (0);
+   symval = (Elf_Addr)defobj->relocbase +
+   def->st_value;
   

svn commit: r356055 - head/libexec/rtld-elf/powerpc64

2019-12-24 Thread Brandon Bergren
Author: bdragon
Date: Tue Dec 24 16:07:35 2019
New Revision: 356055
URL: https://svnweb.freebsd.org/changeset/base/356055

Log:
  [PowerPC] powerpc64 rtld IFUNC handling code
  
  As PowerPC is moving to clang, we can finally start taking advantage of
  IFUNC.
  
  Implement the MD parts of IFUNC handling for rtld.
  
  Currently, it is necessary to look for R_PPC_IRELATIVE in the PLT in
  addition to RELA. This is an ABI violation, but LLD9 has some .iplt bugs
  that require this as a workaround.
  
  Reviewed by:  kib
  Differential Revision:https://reviews.freebsd.org/D22789

Modified:
  head/libexec/rtld-elf/powerpc64/reloc.c
  head/libexec/rtld-elf/powerpc64/rtld_machdep.h

Modified: head/libexec/rtld-elf/powerpc64/reloc.c
==
--- head/libexec/rtld-elf/powerpc64/reloc.c Tue Dec 24 16:03:33 2019
(r356054)
+++ head/libexec/rtld-elf/powerpc64/reloc.c Tue Dec 24 16:07:35 2019
(r356055)
@@ -33,6 +33,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -160,83 +161,84 @@ static int
 reloc_nonplt_object(Obj_Entry *obj_rtld __unused, Obj_Entry *obj,
 const Elf_Rela *rela, SymCache *cache, int flags, RtldLockState *lockstate)
 {
-   Elf_Addr*where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
-   const Elf_Sym   *def;
-   const Obj_Entry *defobj;
-   Elf_Addr tmp;
+   const Elf_Sym   *def = NULL;
+   const Obj_Entry *defobj;
+   Elf_Addr*where, symval = 0;
 
+   /*
+* First, resolve symbol for relocations which
+* reference symbols.
+*/
switch (ELF_R_TYPE(rela->r_info)) {
 
-   case R_PPC_NONE:
-   break;
-
-case R_PPC64_UADDR64:/* doubleword64 S + A */
-case R_PPC64_ADDR64:
-case R_PPC_GLOB_DAT:
+   case R_PPC64_UADDR64:/* doubleword64 S + A */
+   case R_PPC64_ADDR64:
+   case R_PPC_GLOB_DAT:
+   case R_PPC64_DTPMOD64:
+   case R_PPC64_TPREL64:
+   case R_PPC64_DTPREL64:
def = find_symdef(ELF_R_SYM(rela->r_info), obj, ,
flags, cache, lockstate);
if (def == NULL) {
return (-1);
}
-
-tmp = (Elf_Addr)(defobj->relocbase + def->st_value +
-rela->r_addend);
-
-   /* Don't issue write if unnecessary; avoid COW page fault */
-if (*where != tmp) {
-*where = tmp;
-   }
-break;
-
-case R_PPC_RELATIVE:  /* doubleword64 B + A */
-   tmp = (Elf_Addr)(obj->relocbase + rela->r_addend);
-
-   /* As above, don't issue write unnecessarily */
-   if (*where != tmp) {
-   *where = tmp;
-   }
-   break;
-
-   case R_PPC_COPY:
/*
-* These are deferred until all other relocations
-* have been done.  All we do here is make sure
-* that the COPY relocation is not in a shared
-* library.  They are allowed only in executable
-* files.
+* If symbol is IFUNC, only perform relocation
+* when caller allowed it by passing
+* SYMLOOK_IFUNC flag.  Skip the relocations
+* otherwise.
+*
+* Also error out in case IFUNC relocations
+* are specified for TLS, which cannot be
+* usefully interpreted.
 */
-   if (!obj->mainprog) {
-   _rtld_error("%s: Unexpected R_COPY "
-   " relocation in shared library",
-   obj->path);
-   return (-1);
+   if (ELF_ST_TYPE(def->st_info) == STT_GNU_IFUNC) {
+   switch (ELF_R_TYPE(rela->r_info)) {
+   case R_PPC64_UADDR64:
+   case R_PPC64_ADDR64:
+   case R_PPC_GLOB_DAT:
+   if ((flags & SYMLOOK_IFUNC) == 0) {
+   dbg("Non-PLT reference to IFUNC 
found!");
+   obj->non_plt_gnu_ifunc = true;
+   return (0);
+   }
+   symval = (Elf_Addr)rtld_resolve_ifunc(
+   defobj, def);
+   break;
+   default:
+   _rtld_error("%s: IFUNC for TLS reloc",
+obj->path);
+   return (-1);
+   }
+   } else {
+   if ((flags & SYMLOOK_IFUNC) != 0)
+   return (0);
+

svn commit: r356054 - in head: share/mk stand

2019-12-24 Thread Justin Hibbits
Author: jhibbits
Date: Tue Dec 24 16:03:33 2019
New Revision: 356054
URL: https://svnweb.freebsd.org/changeset/base/356054

Log:
  [PowerPC64]  Use ld.bfd to build LIB32 and STAND - when using llvm
  
  Summary:
  This patch is to support ongoing work for replacing "GCC/BFD" by "CLANG/LLD" 
on
  target PowerPC64 [1], by proposing a way to specify and/or locate a secondary
  ld.bfd linker.
  This is necessary as LLD currently doesn't support PowerPC 32 bits, so we keep
  using BFD for the 32 bit stuff on PowePC64(LIB32 compatibility and
  STAND/slof/loader.)
  
  - creates LD_BFD variable pointing to ld.bfd
  - use LD_BFD as linker for LIB32/compat
  - Default behavior for other platforms aren't changed.
  
  [1] https://wiki.freebsd.org/powerpc/llvm-elfv2
  
  Submitted by: alfredo.junior_eldorado.org.br
  Reviewed by:  imp
  Differential Revision: https://reviews.freebsd.org/D20261

Modified:
  head/share/mk/bsd.compat.mk
  head/share/mk/bsd.cpu.mk
  head/stand/defs.mk

Modified: head/share/mk/bsd.compat.mk
==
--- head/share/mk/bsd.compat.mk Tue Dec 24 15:56:24 2019(r356053)
+++ head/share/mk/bsd.compat.mk Tue Dec 24 16:03:33 2019(r356054)
@@ -47,11 +47,20 @@ LIB32CPUFLAGS=  -mcpu=powerpc
 .else
 LIB32CPUFLAGS= -mcpu=${COMPAT_CPUTYPE}
 .endif
+
+.if ${COMPAT_COMPILER_TYPE} == "gcc"
 LIB32CPUFLAGS+=-m32
+.else
+LIB32CPUFLAGS+=-target powerpc-unknown-freebsd13.0
+
+# Use BFD to workaround ld.lld issues on PowerPC 32 bit 
+LIB32CPUFLAGS+= -fuse-ld=${LD_BFD}
+.endif
+
 LIB32_MACHINE= powerpc
 LIB32_MACHINE_ARCH=powerpc
 LIB32WMAKEFLAGS=   \
-   LD="${XLD} -m elf32ppc_fbsd"
+   LD="${LD_BFD} -m elf32ppc_fbsd"
 
 .elif ${COMPAT_ARCH:Mmips64*} != ""
 HAS_COMPAT=32

Modified: head/share/mk/bsd.cpu.mk
==
--- head/share/mk/bsd.cpu.mkTue Dec 24 15:56:24 2019(r356053)
+++ head/share/mk/bsd.cpu.mkTue Dec 24 16:03:33 2019(r356054)
@@ -412,3 +412,17 @@ CFLAGS_NO_SIMD += ${CFLAGS_NO_SIMD.${COMPILER_TYPE}}
 # These come from make.conf or the command line or the environment.
 CFLAGS += ${CFLAGS.${MACHINE_ARCH}}
 CXXFLAGS += ${CXXFLAGS.${MACHINE_ARCH}}
+
+
+# Defines a variable for Binutils linker, to be used to workaround some
+# issue with LLVM LLD (i.e. support for PowerPC32 bit on PowerPC64)
+#
+# This is an unavoidable cross coupling with Makefile.inc1 and
+# normal builds works when CROSS_BINUTILS_PREFIX and could be removed
+# when LLD PowerPC 32 bit support is completed
+.if defined(CROSS_BINUTILS_PREFIX)
+LD_BFD=${LOCALBASE}/bin/${CROSS_BINUTILS_PREFIX}-ld.bfd
+.else
+LD_BFD=${OBJTOP}/tmp/usr/bin/ld.bfd
+.endif
+

Modified: head/stand/defs.mk
==
--- head/stand/defs.mk  Tue Dec 24 15:56:24 2019(r356053)
+++ head/stand/defs.mk  Tue Dec 24 16:03:33 2019(r356054)
@@ -99,6 +99,10 @@ CFLAGS+= -DLOADER_DISK_SUPPORT
 # or powerpc64.
 .if ${MACHINE_ARCH} == "powerpc64"
 CFLAGS+=   -m32 -mcpu=powerpc
+# Use ld.bfd to workaround ld.lld issues on PowerPC 32 bit
+.if "${COMPILER_TYPE}" == "clang" && "${LINKER_TYPE}" == "lld"
+CFLAGS+=   -fuse-ld=${LD_BFD}
+.endif
 .endif
 
 # For amd64, there's a bit of mixed bag. Some of the tree (i386, lib*32) is
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356053 - in head/sys: arm/arm arm64/arm64 i386/i386 kern powerpc/powerpc riscv/riscv sparc64/sparc64 sys

2019-12-24 Thread Brandon Bergren
Author: bdragon
Date: Tue Dec 24 15:56:24 2019
New Revision: 356053
URL: https://svnweb.freebsd.org/changeset/base/356053

Log:
  [PowerPC] Implement Secure-PLT jump table processing for ppc32.
  
  Due to clang and LLD's tendency to use a PLT for builtins, and as they
  don't have full support for EABI, we sometimes have to deal with a PLT in
  .ko files in a clang-built kernel.
  
  As such, augment the in-kernel linker to support jump table processing.
  
  As there is no particular reason to support lazy binding in kernel modules,
  only implement Secure-PLT immediate binding.
  
  As part of these changes, add elf_cpu_parse_dynamic() to the MD API of the
  in-kernel linker (except on platforms that use raw object files.)
  
  The new function will allow MD code to act on MD tags in _DYNAMIC.
  
  Use this new function in the PowerPC MD code to ensure BSS-PLT modules using
  PLT will be rejected during insertion, and to poison the runtime resolver to
  ensure we get a clear panic reason if a call is made to the resolver.
  
  Reviewed by:  jhibbits
  Differential Revision:https://reviews.freebsd.org/D22608

Modified:
  head/sys/arm/arm/elf_machdep.c
  head/sys/arm64/arm64/elf_machdep.c
  head/sys/i386/i386/elf_machdep.c
  head/sys/kern/link_elf.c
  head/sys/powerpc/powerpc/elf32_machdep.c
  head/sys/powerpc/powerpc/elf64_machdep.c
  head/sys/riscv/riscv/elf_machdep.c
  head/sys/sparc64/sparc64/elf_machdep.c
  head/sys/sys/linker.h

Modified: head/sys/arm/arm/elf_machdep.c
==
--- head/sys/arm/arm/elf_machdep.c  Tue Dec 24 14:50:17 2019
(r356052)
+++ head/sys/arm/arm/elf_machdep.c  Tue Dec 24 15:56:24 2019
(r356053)
@@ -321,6 +321,13 @@ elf_cpu_load_file(linker_file_t lf)
 }
 
 int
+elf_cpu_parse_dynamic(linker_file_t lf __unused, Elf_Dyn *dynamic __unused)
+{
+
+   return (0);
+}
+
+int
 elf_cpu_unload_file(linker_file_t lf)
 {
 

Modified: head/sys/arm64/arm64/elf_machdep.c
==
--- head/sys/arm64/arm64/elf_machdep.c  Tue Dec 24 14:50:17 2019
(r356052)
+++ head/sys/arm64/arm64/elf_machdep.c  Tue Dec 24 15:56:24 2019
(r356053)
@@ -216,3 +216,10 @@ elf_cpu_unload_file(linker_file_t lf __unused)
 
return (0);
 }
+
+int
+elf_cpu_parse_dynamic(linker_file_t lf __unused, Elf_Dyn *dynamic __unused)
+{
+
+   return (0);
+}

Modified: head/sys/i386/i386/elf_machdep.c
==
--- head/sys/i386/i386/elf_machdep.cTue Dec 24 14:50:17 2019
(r356052)
+++ head/sys/i386/i386/elf_machdep.cTue Dec 24 15:56:24 2019
(r356053)
@@ -295,3 +295,10 @@ elf_cpu_unload_file(linker_file_t lf __unused)
 
return (0);
 }
+
+int
+elf_cpu_parse_dynamic(linker_file_t lf __unused, Elf_Dyn *dynamic __unused)
+{
+
+   return (0);
+}

Modified: head/sys/kern/link_elf.c
==
--- head/sys/kern/link_elf.cTue Dec 24 14:50:17 2019(r356052)
+++ head/sys/kern/link_elf.cTue Dec 24 15:56:24 2019(r356053)
@@ -611,7 +611,7 @@ parse_dynamic(elf_file_t ef)
ef->ddbstrtab = ef->strtab;
ef->ddbstrcnt = ef->strsz;
 
-   return (0);
+   return elf_cpu_parse_dynamic(>lf, ef->dynamic);
 }
 
 #defineLS_PADDING  0x90909090

Modified: head/sys/powerpc/powerpc/elf32_machdep.c
==
--- head/sys/powerpc/powerpc/elf32_machdep.cTue Dec 24 14:50:17 2019
(r356052)
+++ head/sys/powerpc/powerpc/elf32_machdep.cTue Dec 24 15:56:24 2019
(r356053)
@@ -63,6 +63,7 @@
 
 extern const char *freebsd32_syscallnames[];
 static void ppc32_fixlimit(struct rlimit *rl, int which);
+static void ppc32_runtime_resolve(void);
 
 static SYSCTL_NODE(_compat, OID_AUTO, ppc32, CTLFLAG_RW, 0, "32-bit mode");
 
@@ -296,6 +297,20 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas
*where = elf_relocaddr(lf, relocbase + addend);
break;
 
+   case R_PPC_JMP_SLOT: /* PLT jump slot entry */
+   /*
+* We currently only support Secure-PLT jump slots.
+* Given that we reject BSS-PLT modules during load, we
+* don't need to check again.
+* The method we are using here is equivilent to
+* LD_BIND_NOW.
+*/
+   error = lookup(lf, symidx, 1, );
+   if (error != 0)
+   return -1;
+   *where = elf_relocaddr(lf, addr + addend);
+   break;
+
default:
printf("kldload: unexpected relocation type %d\n",
(int) rtype);
@@ -356,6 +371,7 @@ elf_reloc_local(linker_file_t lf, Elf_Addr relocbase, 
 int
 

svn commit: r356052 - head/sys/dev/mpr

2019-12-24 Thread Scott Long
Author: scottl
Date: Tue Dec 24 14:50:17 2019
New Revision: 356052
URL: https://svnweb.freebsd.org/changeset/base/356052

Log:
  Convert the mpr driver to use busdma templates.

Modified:
  head/sys/dev/mpr/mpr.c
  head/sys/dev/mpr/mpr_pci.c
  head/sys/dev/mpr/mpr_user.c

Modified: head/sys/dev/mpr/mpr.c
==
--- head/sys/dev/mpr/mpr.c  Tue Dec 24 14:49:37 2019(r356051)
+++ head/sys/dev/mpr/mpr.c  Tue Dec 24 14:50:17 2019(r356052)
@@ -1311,6 +1311,7 @@ mpr_alloc_queues(struct mpr_softc *sc)
 static int
 mpr_alloc_hw_queues(struct mpr_softc *sc)
 {
+   bus_dma_tag_template_t t;
bus_addr_t queues_busaddr;
uint8_t *queues;
int qsize, fqsize, pqsize;
@@ -1332,17 +1333,12 @@ mpr_alloc_hw_queues(struct mpr_softc *sc)
pqsize = sc->pqdepth * 8;
qsize = fqsize + pqsize;
 
-if (bus_dma_tag_create( sc->mpr_parent_dmat,/* parent */
-   16, 0,  /* algnmnt, boundary */
-   BUS_SPACE_MAXADDR_32BIT,/* lowaddr */
-   BUS_SPACE_MAXADDR,  /* highaddr */
-   NULL, NULL, /* filter, filterarg */
-qsize, /* maxsize */
-1, /* nsegments */
-qsize, /* maxsegsize */
-0, /* flags */
-NULL, NULL,/* lockfunc, lockarg */
->queues_dmat)) {
+   bus_dma_template_init(, sc->mpr_parent_dmat);
+   t.alignment = 16;
+   t.lowaddr = BUS_SPACE_MAXADDR_32BIT;
+   t.maxsize = t.maxsegsize = qsize;
+   t.nsegments = 1;
+   if (bus_dma_template_tag(, >queues_dmat)) {
mpr_dprint(sc, MPR_ERROR, "Cannot allocate queues DMA tag\n");
return (ENOMEM);
 }
@@ -1370,6 +1366,7 @@ mpr_alloc_hw_queues(struct mpr_softc *sc)
 static int
 mpr_alloc_replies(struct mpr_softc *sc)
 {
+   bus_dma_tag_template_t t;
int rsize, num_replies;
 
/* Store the reply frame size in bytes rather than as 32bit words */
@@ -1383,17 +1380,12 @@ mpr_alloc_replies(struct mpr_softc *sc)
num_replies = max(sc->fqdepth, sc->num_replies);
 
rsize = sc->replyframesz * num_replies; 
-if (bus_dma_tag_create( sc->mpr_parent_dmat,/* parent */
-   4, 0,   /* algnmnt, boundary */
-   BUS_SPACE_MAXADDR_32BIT,/* lowaddr */
-   BUS_SPACE_MAXADDR,  /* highaddr */
-   NULL, NULL, /* filter, filterarg */
-rsize, /* maxsize */
-1, /* nsegments */
-rsize, /* maxsegsize */
-0, /* flags */
-NULL, NULL,/* lockfunc, lockarg */
->reply_dmat)) {
+   bus_dma_template_init(, sc->mpr_parent_dmat);
+   t.alignment = 4;
+   t.lowaddr = BUS_SPACE_MAXADDR_32BIT;
+   t.maxsize = t.maxsegsize = rsize;
+   t.nsegments = 1;
+   if (bus_dma_template_tag(, >reply_dmat)) {
mpr_dprint(sc, MPR_ERROR, "Cannot allocate replies DMA tag\n");
return (ENOMEM);
 }
@@ -1440,21 +1432,17 @@ mpr_load_chains_cb(void *arg, bus_dma_segment_t *segs,
 static int
 mpr_alloc_requests(struct mpr_softc *sc)
 {
+   bus_dma_tag_template_t t;
struct mpr_command *cm;
int i, rsize, nsegs;
 
rsize = sc->reqframesz * sc->num_reqs;
-if (bus_dma_tag_create( sc->mpr_parent_dmat,/* parent */
-   16, 0,  /* algnmnt, boundary */
-   BUS_SPACE_MAXADDR_32BIT,/* lowaddr */
-   BUS_SPACE_MAXADDR,  /* highaddr */
-   NULL, NULL, /* filter, filterarg */
-rsize, /* maxsize */
-1, /* nsegments */
-rsize, /* maxsegsize */
-0, /* flags */
-NULL, NULL,/* lockfunc, lockarg */
->req_dmat)) {
+   bus_dma_template_init(, sc->mpr_parent_dmat);
+   t.alignment = 16;
+   t.lowaddr = BUS_SPACE_MAXADDR_32BIT;
+   t.maxsize = t.maxsegsize = rsize;
+   t.nsegments = 1;
+   if (bus_dma_template_tag(, >req_dmat)) {
mpr_dprint(sc, MPR_ERROR, 

svn commit: r356051 - head/sys/sys

2019-12-24 Thread Scott Long
Author: scottl
Date: Tue Dec 24 14:49:37 2019
New Revision: 356051
URL: https://svnweb.freebsd.org/changeset/base/356051

Log:
  Bump __FreeBSD_version for the addition of busdma templates.

Modified:
  head/sys/sys/param.h

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hTue Dec 24 14:48:46 2019(r356050)
+++ head/sys/sys/param.hTue Dec 24 14:49:37 2019(r356051)
@@ -60,7 +60,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1300068  /* Master, propagated to newvers */
+#define __FreeBSD_version 1300069  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356050 - in head: share/man/man9 sys/arm/arm sys/arm64/arm64 sys/mips/mips sys/powerpc/powerpc sys/riscv/riscv sys/sparc64/sparc64 sys/sys sys/x86/x86

2019-12-24 Thread Scott Long
Author: scottl
Date: Tue Dec 24 14:48:46 2019
New Revision: 356050
URL: https://svnweb.freebsd.org/changeset/base/356050

Log:
  Introduce the concept of busdma tag templates. A template can be allocated
  off the stack, initialized to default values, and then filled in with
  driver-specific values, all without having to worry about the numerous
  other fields in the tag. The resulting template is then passed into
  busdma and the normal opaque tag object created.  See the man page for
  details on how to initialize a template.
  
  Templates do not support tag filters.  Filters have been broken for many
  years, and only existed for an ancient make/model of hardware that had a
  quirky DMA engine.  Instead of breaking the ABI/API and changing the
  arugment signature of bus_dma_tag_create() to remove the filter arguments,
  templates allow us to ignore them, and also significantly reduce the
  complexity of creating and managing tags.
  
  Reviewed by:  imp, kib
  Differential Revision:https://reviews.freebsd.org/D22906

Modified:
  head/share/man/man9/bus_dma.9
  head/sys/arm/arm/busdma_machdep-v4.c
  head/sys/arm/arm/busdma_machdep-v6.c
  head/sys/arm64/arm64/busdma_machdep.c
  head/sys/mips/mips/busdma_machdep.c
  head/sys/powerpc/powerpc/busdma_machdep.c
  head/sys/riscv/riscv/busdma_machdep.c
  head/sys/sparc64/sparc64/bus_machdep.c
  head/sys/sys/bus_dma.h
  head/sys/x86/x86/busdma_machdep.c

Modified: head/share/man/man9/bus_dma.9
==
--- head/share/man/man9/bus_dma.9   Tue Dec 24 06:08:29 2019
(r356049)
+++ head/share/man/man9/bus_dma.9   Tue Dec 24 14:48:46 2019
(r356050)
@@ -60,6 +60,9 @@
 .Nm bus_dma ,
 .Nm bus_dma_tag_create ,
 .Nm bus_dma_tag_destroy ,
+.Nm bus_dma_template_init ,
+.Nm bus_dma_template_tag ,
+.Nm bus_dma_template_clone ,
 .Nm bus_dmamap_create ,
 .Nm bus_dmamap_destroy ,
 .Nm bus_dmamap_load ,
@@ -83,7 +86,22 @@
 "void *lockfuncarg" "bus_dma_tag_t *dmat"
 .Ft int
 .Fn bus_dma_tag_destroy "bus_dma_tag_t dmat"
+.Ft void
+.Fo bus_dma_template_init
+.Fa "bus_dma_template_t template"
+.Fa "bus_dma_tag_t parent"
+.Fc
 .Ft int
+.Fo bus_dma_template_tag
+.Fa "bus_dma_template_t template"
+.Fa "bus_dma_tag_t *dmat"
+.Fc
+.Ft void
+.Fo bus_dma_template_clone
+.Fa "bus_dma_template_t template"
+.Fa "bus_dma_tag_t dmat"
+.Fc
+.Ft int
 .Fn bus_dmamap_create "bus_dma_tag_t dmat" "int flags" "bus_dmamap_t *mapp"
 .Ft int
 .Fn bus_dmamap_destroy "bus_dma_tag_t dmat" "bus_dmamap_t map"
@@ -282,6 +300,34 @@ DMA tags are organized into a hierarchy, with each chi
 tag inheriting the restrictions of its parent.
 This allows all devices along the path of DMA transactions
 to contribute to the constraints of those transactions.
+.It Vt bus_dma_template_t
+A template structure for creating a
+.Fa bus_dma_tag_t
+from a set of defaults.
+Once initialized with
+.Fn bus_dma_template_init ,
+a driver can over-ride individual fields to suit its needs.
+The following fields have the indicated values:
+.Bd -literal
+   alignment   1
+   boundary0
+   lowaddr BUS_SPACE_MAXADDR
+   highaddrBUS_SPACE_MAXADDR
+   maxsize BUS_SPACE_MAXSIZE
+   nsegments   BUS_SPACE_UNRESTRICTED
+   maxsegsize  BUS_SPACE_MAXSIZE
+   flags   0
+   lockfuncNULL
+   lockfuncarg NULL
+.Ed
+.Pp
+Descriptions of each field are documented with
+.Fn bus_dma_tag_create .
+Note that the
+.Fa filtfunc
+and
+.Fa filtfuncarg
+attributes of the DMA tag are not supported with templates.
 .It Vt bus_dma_filter_t
 Client specified address filter having the format:
 .Bl -tag -width indent
@@ -633,6 +679,25 @@ if any DMA maps remain associated with
 or
 .Ql 0
 on success.
+.It Fn bus_dma_template_init "*template" "parent"
+Initializes a
+.Fa bus_dma_template_t
+structure and associates it with an optional 
+.Fa parent .
+The
+.Fa parent
+argument may be NULL.
+.It Fn bus_dma_template_tag "*template" "*dmat"
+Unpacks a template into a tag, and returns the tag via the
+.Fa dmat .
+All return values are identical to
+.Fn bus_dma_tag_create .
+.It Fn bus_dma_template_clone "*template" "dmat"
+Clones the fields from a tag to a template.
+This is useful for cloning tags when paired with
+.Fn bus_dma_template_tag .
+A template that is filled in as a clone does not need to be initialized
+first.
 .It Fn bus_dmamap_create "dmat" "flags" "*mapp"
 Allocates and initializes a DMA map.
 Arguments are as follows:

Modified: head/sys/arm/arm/busdma_machdep-v4.c
==
--- head/sys/arm/arm/busdma_machdep-v4.cTue Dec 24 06:08:29 2019
(r356049)
+++ head/sys/arm/arm/busdma_machdep-v4.cTue Dec 24 14:48:46 2019
(r356050)
@@ -501,6 +501,57 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t al
return (error);
 }
 
+void