Re: svn commit: r327890 - head/usr.sbin/bsdinstall/partedit

2018-01-12 Thread Alexey Dokuchaev
On Fri, Jan 12, 2018 at 08:25:57PM +, Ed Maste wrote:
> New Revision: 327890
> URL: https://svnweb.freebsd.org/changeset/base/327890
> 
> Log:
>   bsdinstall: disable SUJ by default
>   
>   SUJ + cg checksums produce spurious warnings after an unclean shutdown
>   (e.g. a crash).  For now disable SUJ for UFS installs so installing from
>   a FreeBSD 12 snapshot results in a usable filesystem, until this can be
>   fixed.

Thanks; I keep seeing it quite often.  Is it safe to disable SUJ on already
populated filesystem?  Can (should) it better be done on live, mounted one,
of better off the other booted instance of FreeBSD (from another media)?

./danfe
___
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: r327911 - head/lib/libpmc

2018-01-12 Thread Justin Hibbits
Author: jhibbits
Date: Sat Jan 13 04:53:04 2018
New Revision: 327911
URL: https://svnweb.freebsd.org/changeset/base/327911

Log:
  Replace the PMC class struct copy with an explicit memcpy()
  
  This should be effectively a nop for all archs, but for some reason the 
codegen
  difference on the PowerPC 970 is such that the struct assignment doesn't work
  (unless a printf() using one of the elements in the copied struct follows it),
  while the memcpy() succeeds.  On all archs the memcpy() should be expanded to 
an
  inline copy, since the copy is bounded to ~16 bytes.
  
  MFC after:3 weeks

Modified:
  head/lib/libpmc/libpmc.c

Modified: head/lib/libpmc/libpmc.c
==
--- head/lib/libpmc/libpmc.cSat Jan 13 04:00:55 2018(r327910)
+++ head/lib/libpmc/libpmc.cSat Jan 13 04:53:04 2018(r327911)
@@ -3270,7 +3270,8 @@ pmc_init(void)
cpu_info.pm_npmc= op_cpu_info.pm_npmc;
cpu_info.pm_nclass  = op_cpu_info.pm_nclass;
for (n = 0; n < cpu_info.pm_nclass; n++)
-   cpu_info.pm_classes[n] = op_cpu_info.pm_classes[n];
+   memcpy(_info.pm_classes[n], _cpu_info.pm_classes[n],
+   sizeof(cpu_info.pm_classes[n]));
 
pmc_class_table = malloc(PMC_CLASS_TABLE_SIZE *
sizeof(struct pmc_class_descr *));
___
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: r327823 - head/share/mk

2018-01-12 Thread Ed Maste
On 12 January 2018 at 17:49, Antoine Brodin  wrote:
> On Thu, Jan 11, 2018 at 3:03 PM, Ed Maste  wrote:
>> Author: emaste
>> Date: Thu Jan 11 14:03:05 2018
>> New Revision: 327823
>> URL: https://svnweb.freebsd.org/changeset/base/327823
>>
>> Log:
>>   Enable ld.lld as bootstrap linker by default on i386
>>
> Hi,
>
> There are some regressions in ports after this change,  could you
> revert it and request a proper exp-run?

Reverted in r327910, exp-run request (for LLD_BOOTSTRAP without
LLD_IS_LD) in PR 225128.

Do you have a few examples of regressions?
___
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: r327910 - in head/share: man/man5 mk

2018-01-12 Thread Ed Maste
Author: emaste
Date: Sat Jan 13 04:00:55 2018
New Revision: 327910
URL: https://svnweb.freebsd.org/changeset/base/327910

Log:
  Revert r327823, Enable ld.lld as bootstrap linker by default on i386
  
  There's a report of some regression in ports.  Revert for now for an
  exp run for this change in isolation (previous lld exp run also included
  switching the linker used for ports to lld).
  
  Also revert the src.conf.5 regeneration in r327824.
  
  Reported by:  antoine
  Sponsored by: The FreeBSD Foundation

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

Modified: head/share/man/man5/src.conf.5
==
--- head/share/man/man5/src.conf.5  Sat Jan 13 03:12:21 2018
(r327909)
+++ head/share/man/man5/src.conf.5  Sat Jan 13 04:00:55 2018
(r327910)
@@ -1,6 +1,6 @@
 .\" DO NOT EDIT-- this file is generated by tools/build/options/makeman.
 .\" $FreeBSD$
-.Dd January 11, 2018
+.Dd January 12, 2018
 .Dt SRC.CONF 5
 .Os
 .Sh NAME
@@ -970,12 +970,12 @@ To be able to build the system, either Binutils or LLD
 enabled unless an alternate linker is provided via XLD.
 .Pp
 This is a default setting on
-arm/arm, arm/armeb, arm/armv6, arm/armv7, mips/mipsel, mips/mips, 
mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, 
mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpc64, 
powerpc/powerpcspe, riscv/riscv64, riscv/riscv64sf and sparc64/sparc64.
+arm/arm, arm/armeb, 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, 
powerpc/powerpcspe, riscv/riscv64, riscv/riscv64sf and sparc64/sparc64.
 .It Va WITH_LLD_BOOTSTRAP
 Set to build the LLD linker during the bootstrap phase of the build.
 .Pp
 This is a default setting on
-amd64/amd64, arm64/aarch64 and i386/i386.
+amd64/amd64 and arm64/aarch64.
 .It Va WITHOUT_LLD_IS_LD
 Set to use GNU binutils ld as the system linker, instead of LLVM's LLD.
 .Pp

Modified: head/share/mk/src.opts.mk
==
--- head/share/mk/src.opts.mk   Sat Jan 13 03:12:21 2018(r327909)
+++ head/share/mk/src.opts.mk   Sat Jan 13 04:00:55 2018(r327910)
@@ -253,7 +253,7 @@ __DEFAULT_NO_OPTIONS+=LLVM_LIBUNWIND
 .endif
 .if ${__T} == "aarch64"
 __DEFAULT_YES_OPTIONS+=LLD_BOOTSTRAP LLD_IS_LD
-.elif ${__T} == "amd64" || ${__T} == "i386"
+.elif ${__T} == "amd64"
 __DEFAULT_YES_OPTIONS+=LLD_BOOTSTRAP
 __DEFAULT_NO_OPTIONS+=LLD_IS_LD
 .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"


Re: svn commit: r327783 - head/share/mk

2018-01-12 Thread Adrian Chadd
hi,

can we just flip the switch back for now until it's figured out?

Some of us have to like, do development on -HEAD for fun. :)



-a


On 12 January 2018 at 17:46, John Baldwin  wrote:
> On Wednesday, January 10, 2018 08:28:01 PM Ed Maste wrote:
>> Author: emaste
>> Date: Wed Jan 10 20:28:01 2018
>> New Revision: 327783
>> URL: https://svnweb.freebsd.org/changeset/base/327783
>>
>> Log:
>>   Enable ld.lld as bootstrap linker by default on amd64
>>
>>   For some time we have been planning to migrate to LLVM's lld linker.
>>   Having a man page was the last blocking issue for using ld.lld to link
>>   the base system kernel + userland, now addressed by r327770.  Link the
>>   kernel and userland libraries and binaries with ld.lld by default, for
>>   additional test coverage.
>>
>>   This has been a long time in the making.  On 2013-04-13 I submitted an
>>   upstream tracking issue in LLVM PR 23214: [META] Using LLD as FreeBSD's
>>   system linker.  Since then 85 individual issues were identified, and
>>   submitted as dependencies.  These have been addressed along with two
>>   and a half years of other lld development and improvement.
>>
>>   I'd like to express deep gratitude to upstream lld developers Rui
>>   Ueyama, Rafael Espindola, George Rimar and Davide Italiano.  They put in
>>   substantial effort in addressing the issues we found affecting
>>   FreeBSD/amd64.
>>
>>   To revert to using ld.bfd as the bootstrap linker, in /etc/src.conf set
>>
>>   WITHOUT_LLD_BOOTSTRAP=yes
>>
>>   If you need to set this, please follow up with a PR or post to the
>>   freebsd-toolchain mailing list explaining how default WITH_LLD_BOOTSTRAP
>>   failed for your use case.
>>
>>   Note that GNU ld.bfd is still installed as /usr/bin/ld, and will still
>>   be used for linking ports.  ld.lld can be installed as /usr/bin/ld by
>>   setting in /etc/src.conf
>>
>>   WITH_LLD_IS_LLD=yes
>>
>>   A followup commit will set WITH_LLD_IS_LD by default, possibly after
>>   Clang/LLVM/lld 6.0 is merged to FreeBSD.
>>
>>   Release notes:  Yes
>>   Sponsored by:   The FreeBSD Foundation
>
> FYI, due to a quirk of how we load kernel modules on amd64 in such a way that
> doesn't really honor the ELF spec (but is self-consistent in the kernel and
> loader) and the fact that LLD doesn't sort sections the way BFD does, this
> change has confused kgdb such that it can compute different address for
> symbols.  I dont think i386 is affected, only amd64.  I've started on a fix,
> but my first attempt to boot it resulted in no modules loading anymore and
> it's time to go home for the day. :-P  I'll try to resolve this early next
> week.  If you need to use kgdb on amd64 with kernel modules, you will have
> to build with an external toolchain (the old ld.bfd can't cope with the
> kernel ifunc stuff).
>
> --
> 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"


Re: svn commit: r327907 - in head/sys: conf dev/fdt dev/ofw

2018-01-12 Thread Nathan Whitehorn
Thanks, Justin! Since the fixup stuff is now only defined for 
FDT_MARVELL, it would be great if it could move to sys/arm/mv now 
instead of being in MI code.

-Nathan

On 01/12/18 18:56, Justin Hibbits wrote:

Author: jhibbits
Date: Sat Jan 13 02:56:09 2018
New Revision: 327907
URL: https://svnweb.freebsd.org/changeset/base/327907

Log:
   Remove fdt fixups for powerpc, they are no longer needed.
   
   If a fixup really is needed, it should be fixed in u-boot, not in FreeBSD.
   
   Suggested by:	nwhitehorn


Deleted:
   head/sys/dev/fdt/fdt_powerpc.c
Modified:
   head/sys/conf/files.powerpc
   head/sys/dev/ofw/ofw_fdt.c

Modified: head/sys/conf/files.powerpc
==
--- head/sys/conf/files.powerpc Sat Jan 13 01:36:37 2018(r327906)
+++ head/sys/conf/files.powerpc Sat Jan 13 02:56:09 2018(r327907)
@@ -31,7 +31,6 @@ dev/adb/adb_if.m  optionaladb
  dev/adb/adb_buttons.c optionaladb
  dev/agp/agp_apple.c   optionalagp powermac
  dev/fb/fb.c   optionalsc
-dev/fdt/fdt_powerpc.c  optionalfdt
  # ofwbus depends on simplebus.
  dev/fdt/simplebus.c   optionalaim | fdt
  dev/hwpmc/hwpmc_e500.coptionalhwpmc

Modified: head/sys/dev/ofw/ofw_fdt.c
==
--- head/sys/dev/ofw/ofw_fdt.c  Sat Jan 13 01:36:37 2018(r327906)
+++ head/sys/dev/ofw/ofw_fdt.c  Sat Jan 13 02:56:09 2018(r327907)
@@ -430,7 +430,7 @@ ofw_fdt_package_to_path(ofw_t ofw, phandle_t package,
return (-1);
  }
  
-#if defined(FDT_MARVELL) || defined(__powerpc__)

+#if defined(FDT_MARVELL)
  static int
  ofw_fdt_fixup(ofw_t ofw)
  {
@@ -477,7 +477,7 @@ ofw_fdt_fixup(ofw_t ofw)
  static int
  ofw_fdt_interpret(ofw_t ofw, const char *cmd, int nret, cell_t *retvals)
  {
-#if defined(FDT_MARVELL) || defined(__powerpc__)
+#if defined(FDT_MARVELL)
int rv;
  
  	/*




___
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: r327908 - head/sys/powerpc/ofw

2018-01-12 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Jan 13 03:09:05 2018
New Revision: 327908
URL: https://svnweb.freebsd.org/changeset/base/327908

Log:
  Chase removal of FDT fixup code on PowerPC in r327907.

Modified:
  head/sys/powerpc/ofw/ofw_machdep.c

Modified: head/sys/powerpc/ofw/ofw_machdep.c
==
--- head/sys/powerpc/ofw/ofw_machdep.c  Sat Jan 13 02:56:09 2018
(r327907)
+++ head/sys/powerpc/ofw/ofw_machdep.c  Sat Jan 13 03:09:05 2018
(r327908)
@@ -420,8 +420,6 @@ OF_bootstrap()
return status;
 
err = OF_init(fdt);
-   if (err == 0)
-   OF_interpret("perform-fixup", 0);
} 
 
if (err != 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: r327907 - in head/sys: conf dev/fdt dev/ofw

2018-01-12 Thread Justin Hibbits
Author: jhibbits
Date: Sat Jan 13 02:56:09 2018
New Revision: 327907
URL: https://svnweb.freebsd.org/changeset/base/327907

Log:
  Remove fdt fixups for powerpc, they are no longer needed.
  
  If a fixup really is needed, it should be fixed in u-boot, not in FreeBSD.
  
  Suggested by: nwhitehorn

Deleted:
  head/sys/dev/fdt/fdt_powerpc.c
Modified:
  head/sys/conf/files.powerpc
  head/sys/dev/ofw/ofw_fdt.c

Modified: head/sys/conf/files.powerpc
==
--- head/sys/conf/files.powerpc Sat Jan 13 01:36:37 2018(r327906)
+++ head/sys/conf/files.powerpc Sat Jan 13 02:56:09 2018(r327907)
@@ -31,7 +31,6 @@ dev/adb/adb_if.m  optionaladb
 dev/adb/adb_buttons.c  optionaladb
 dev/agp/agp_apple.coptionalagp powermac
 dev/fb/fb.coptionalsc
-dev/fdt/fdt_powerpc.c  optionalfdt
 # ofwbus depends on simplebus.
 dev/fdt/simplebus.coptionalaim | fdt
 dev/hwpmc/hwpmc_e500.c optionalhwpmc

Modified: head/sys/dev/ofw/ofw_fdt.c
==
--- head/sys/dev/ofw/ofw_fdt.c  Sat Jan 13 01:36:37 2018(r327906)
+++ head/sys/dev/ofw/ofw_fdt.c  Sat Jan 13 02:56:09 2018(r327907)
@@ -430,7 +430,7 @@ ofw_fdt_package_to_path(ofw_t ofw, phandle_t package, 
return (-1);
 }
 
-#if defined(FDT_MARVELL) || defined(__powerpc__)
+#if defined(FDT_MARVELL)
 static int
 ofw_fdt_fixup(ofw_t ofw)
 {
@@ -477,7 +477,7 @@ ofw_fdt_fixup(ofw_t ofw)
 static int
 ofw_fdt_interpret(ofw_t ofw, const char *cmd, int nret, cell_t *retvals)
 {
-#if defined(FDT_MARVELL) || defined(__powerpc__)
+#if defined(FDT_MARVELL)
int rv;
 
/*
___
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: r327783 - head/share/mk

2018-01-12 Thread John Baldwin
On Wednesday, January 10, 2018 08:28:01 PM Ed Maste wrote:
> Author: emaste
> Date: Wed Jan 10 20:28:01 2018
> New Revision: 327783
> URL: https://svnweb.freebsd.org/changeset/base/327783
> 
> Log:
>   Enable ld.lld as bootstrap linker by default on amd64
>   
>   For some time we have been planning to migrate to LLVM's lld linker.
>   Having a man page was the last blocking issue for using ld.lld to link
>   the base system kernel + userland, now addressed by r327770.  Link the
>   kernel and userland libraries and binaries with ld.lld by default, for
>   additional test coverage.
>   
>   This has been a long time in the making.  On 2013-04-13 I submitted an
>   upstream tracking issue in LLVM PR 23214: [META] Using LLD as FreeBSD's
>   system linker.  Since then 85 individual issues were identified, and
>   submitted as dependencies.  These have been addressed along with two
>   and a half years of other lld development and improvement.
>   
>   I'd like to express deep gratitude to upstream lld developers Rui
>   Ueyama, Rafael Espindola, George Rimar and Davide Italiano.  They put in
>   substantial effort in addressing the issues we found affecting
>   FreeBSD/amd64.
>   
>   To revert to using ld.bfd as the bootstrap linker, in /etc/src.conf set
>   
>   WITHOUT_LLD_BOOTSTRAP=yes
>   
>   If you need to set this, please follow up with a PR or post to the
>   freebsd-toolchain mailing list explaining how default WITH_LLD_BOOTSTRAP
>   failed for your use case.
>   
>   Note that GNU ld.bfd is still installed as /usr/bin/ld, and will still
>   be used for linking ports.  ld.lld can be installed as /usr/bin/ld by
>   setting in /etc/src.conf
>   
>   WITH_LLD_IS_LLD=yes
>   
>   A followup commit will set WITH_LLD_IS_LD by default, possibly after
>   Clang/LLVM/lld 6.0 is merged to FreeBSD.
>   
>   Release notes:  Yes
>   Sponsored by:   The FreeBSD Foundation

FYI, due to a quirk of how we load kernel modules on amd64 in such a way that
doesn't really honor the ELF spec (but is self-consistent in the kernel and
loader) and the fact that LLD doesn't sort sections the way BFD does, this
change has confused kgdb such that it can compute different address for
symbols.  I dont think i386 is affected, only amd64.  I've started on a fix,
but my first attempt to boot it resulted in no modules loading anymore and
it's time to go home for the day. :-P  I'll try to resolve this early next
week.  If you need to use kgdb on amd64 with kernel modules, you will have
to build with an external toolchain (the old ld.bfd can't cope with the
kernel ifunc stuff).

-- 
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: r327906 - in head/sys: conf powerpc/mpc85xx

2018-01-12 Thread Justin Hibbits
Author: jhibbits
Date: Sat Jan 13 01:36:37 2018
New Revision: 327906
URL: https://svnweb.freebsd.org/changeset/base/327906

Log:
  Enable L2 cache on supported PowerQUICC and QorIQ platforms
  
  Some PowerQUICC and QorIQ platforms have a L2 cache managed via the
  memory-mapped configuration registers, and appear as a node in the device
  tree.  This adds basic support to enable the cache.

Added:
  head/sys/powerpc/mpc85xx/mpc85xx_cache.c   (contents, props changed)
Modified:
  head/sys/conf/files.powerpc

Modified: head/sys/conf/files.powerpc
==
--- head/sys/conf/files.powerpc Sat Jan 13 00:05:31 2018(r327905)
+++ head/sys/conf/files.powerpc Sat Jan 13 01:36:37 2018(r327906)
@@ -146,6 +146,7 @@ powerpc/mpc85xx/i2c.c   optionaliicbus 
fdt
 powerpc/mpc85xx/isa.c  optionalmpc85xx isa
 powerpc/mpc85xx/lbc.c  optionalmpc85xx
 powerpc/mpc85xx/mpc85xx.c  optionalmpc85xx
+powerpc/mpc85xx/mpc85xx_cache.coptionalmpc85xx
 powerpc/mpc85xx/mpc85xx_gpio.c optionalmpc85xx gpio
 powerpc/mpc85xx/platform_mpc85xx.c optionalmpc85xx
 powerpc/mpc85xx/pci_mpc85xx.c  optionalpci mpc85xx

Added: head/sys/powerpc/mpc85xx/mpc85xx_cache.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/powerpc/mpc85xx/mpc85xx_cache.cSat Jan 13 01:36:37 2018
(r327906)
@@ -0,0 +1,129 @@
+/*-
+ * Copyright (c) 2018 Justin Hibbits
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+/*
+ * From the P1022 manual, sequence for writing to L2CTL is:
+ * - mbar
+ * - isync
+ * - write
+ * - read
+ * - mbar
+ */
+#defineL2_CTL  0x0
+#define  L2CTL_L2E   0x8000
+#define  L2CTL_L2I   0x4000
+struct mpc85xx_cache_softc {
+   struct resource *sc_mem;
+};
+
+static int
+mpc85xx_cache_probe(device_t dev)
+{
+
+   if (!ofw_bus_is_compatible(dev, "cache"))
+   return (ENXIO);
+
+   device_set_desc(dev, "MPC85xx L2 cache");
+   return (0);
+}
+
+static int
+mpc85xx_cache_attach(device_t dev)
+{
+   struct mpc85xx_cache_softc *sc = device_get_softc(dev);
+   int rid;
+   int cache_line_size, cache_size;
+
+   /* Map registers. */
+   rid = 0;
+   sc->sc_mem = bus_alloc_resource_any(dev,
+SYS_RES_MEMORY, , RF_ACTIVE);
+   if (sc->sc_mem == NULL)
+   return (ENOMEM);
+
+   /* Enable cache and flash invalidate. */
+   __asm __volatile ("mbar; isync" ::: "memory");
+   bus_write_4(sc->sc_mem, L2_CTL, L2CTL_L2E | L2CTL_L2I);
+   bus_read_4(sc->sc_mem, L2_CTL);
+   __asm __volatile ("mbar" ::: "memory");
+
+   cache_line_size = 0;
+   cache_size = 0;
+   OF_getencprop(ofw_bus_get_node(dev), "cache-size", _size,
+   sizeof(cache_size));
+   OF_getencprop(ofw_bus_get_node(dev), "cache-line-size",
+   _line_size, sizeof(cache_line_size));
+
+   if (cache_line_size != 0 && cache_size != 0)
+   device_printf(dev,
+   "L2 cache size: %dKB, cache line size: %d bytes\n",
+   cache_size / 1024, cache_line_size);
+
+   return (0);
+}
+
+static device_method_t mpc85xx_cache_methods[] = {
+   /* device methods */
+   

svn commit: r327905 - head/sys/kern

2018-01-12 Thread Mateusz Guzik
Author: mjg
Date: Sat Jan 13 00:05:31 2018
New Revision: 327905
URL: https://svnweb.freebsd.org/changeset/base/327905

Log:
  rwlock: try regular read unlock even in the hard path
  
  Saves on turnstile trips if the lock got more readers.

Modified:
  head/sys/kern/kern_rwlock.c

Modified: head/sys/kern/kern_rwlock.c
==
--- head/sys/kern/kern_rwlock.c Sat Jan 13 00:04:11 2018(r327904)
+++ head/sys/kern/kern_rwlock.c Sat Jan 13 00:05:31 2018(r327905)
@@ -771,9 +771,9 @@ __rw_runlock_hard(struct rwlock *rw, struct thread *td
turnstile_chain_lock(>lock_object);
v = RW_READ_VALUE(rw);
 retry_ts:
-   if (__predict_false(RW_READERS(v) > 1)) {
+   if (__rw_runlock_try(rw, td, )) {
turnstile_chain_unlock(>lock_object);
-   continue;
+   break;
}
 
v &= (RW_LOCK_WAITERS | RW_LOCK_WRITE_SPINNER);
___
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: r327904 - head/sys/dev/cxgbe/iw_cxgbe

2018-01-12 Thread Navdeep Parhar
Author: np
Date: Sat Jan 13 00:04:11 2018
New Revision: 327904
URL: https://svnweb.freebsd.org/changeset/base/327904

Log:
  cxgbe/iw_cxgbe: Remove duplicates to fix compilation with recent gcc.

Modified:
  head/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h

Modified: head/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
==
--- head/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h  Fri Jan 12 23:41:12 2018
(r327903)
+++ head/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h  Sat Jan 13 00:04:11 2018
(r327904)
@@ -899,8 +899,6 @@ typedef int (*c4iw_handler_func)(struct c4iw_dev *dev,
 
 int c4iw_ep_redirect(void *ctx, struct dst_entry *old, struct dst_entry *new,
 struct l2t_entry *l2t);
-void c4iw_put_qpid(struct c4iw_rdev *rdev, u32 qpid,
-  struct c4iw_dev_ucontext *uctx);
 u32 c4iw_get_resource(struct c4iw_id_table *id_table);
 void c4iw_put_resource(struct c4iw_id_table *id_table, u32 entry);
 int c4iw_init_resource(struct c4iw_rdev *rdev, u32 nr_tpt, u32 nr_pdid);
@@ -986,7 +984,6 @@ void __iomem *c4iw_bar2_addrs(struct c4iw_rdev *rdev, 
unsigned int *pbar2_qid, u64 *pbar2_pa);
 extern struct cxgb4_client t4c_client;
 extern c4iw_handler_func c4iw_handlers[NUM_CPL_CMDS];
-extern int c4iw_max_read_depth;
 
 #if defined(__i386__) || defined(__amd64__)
 #define L1_CACHE_BYTES 128
___
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: r327903 - head/sys/sys

2018-01-12 Thread Jeff Roberson
Author: jeff
Date: Fri Jan 12 23:41:12 2018
New Revision: 327903
URL: https://svnweb.freebsd.org/changeset/base/327903

Log:
  Fix compile error from r327900

Modified:
  head/sys/sys/busdma_bufalloc.h

Modified: head/sys/sys/busdma_bufalloc.h
==
--- head/sys/sys/busdma_bufalloc.h  Fri Jan 12 23:38:15 2018
(r327902)
+++ head/sys/sys/busdma_bufalloc.h  Fri Jan 12 23:41:12 2018
(r327903)
@@ -113,7 +113,7 @@ struct busdma_bufzone * busdma_bufalloc_findzone(busdm
  * you can probably use these when you need uncacheable buffers.
  */
 void * busdma_bufalloc_alloc_uncacheable(uma_zone_t zone, vm_size_t size,
-uint8_t *pflag, int wait);
+int domain, uint8_t *pflag, int wait);
 void  busdma_bufalloc_free_uncacheable(void *item, vm_size_t size,
 uint8_t pflag);
 
___
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: r327901 - in head/sys: arm/arm arm64/arm64 dev/acpica mips/mips powerpc/powerpc sys vm x86/include x86/iommu x86/x86

2018-01-12 Thread Jeff Roberson
Author: jeff
Date: Fri Jan 12 23:34:16 2018
New Revision: 327901
URL: https://svnweb.freebsd.org/changeset/base/327901

Log:
  Add support for NUMA domains to bus dma tags.  This causes all memory
  allocated with a tag to come from the specified domain if it meets the
  other constraints provided by the tag.  Automatically create a tag at
  the root of each bus specifying the domain local to that bus if
  available.
  
  Reviewed by:  jhb, kib
  Tested by:pho
  Sponsored by: Netflix, Dell/EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D13545

Modified:
  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/dev/acpica/acpi_pcib_acpi.c
  head/sys/mips/mips/busdma_machdep.c
  head/sys/powerpc/powerpc/busdma_machdep.c
  head/sys/sys/bus_dma.h
  head/sys/vm/vm_phys.c
  head/sys/vm/vm_phys.h
  head/sys/x86/include/busdma_impl.h
  head/sys/x86/iommu/busdma_dmar.c
  head/sys/x86/x86/busdma_bounce.c
  head/sys/x86/x86/busdma_machdep.c

Modified: head/sys/arm/arm/busdma_machdep-v4.c
==
--- head/sys/arm/arm/busdma_machdep-v4.cFri Jan 12 23:25:05 2018
(r327900)
+++ head/sys/arm/arm/busdma_machdep-v4.cFri Jan 12 23:34:16 2018
(r327901)
@@ -500,6 +500,13 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t al
 }
 
 int
+bus_dma_tag_set_domain(bus_dma_tag_t dmat, int domain)
+{
+
+   return (0);
+}
+
+int
 bus_dma_tag_destroy(bus_dma_tag_t dmat)
 {
bus_dma_tag_t dmat_copy;

Modified: head/sys/arm/arm/busdma_machdep-v6.c
==
--- head/sys/arm/arm/busdma_machdep-v6.cFri Jan 12 23:25:05 2018
(r327900)
+++ head/sys/arm/arm/busdma_machdep-v6.cFri Jan 12 23:34:16 2018
(r327901)
@@ -563,6 +563,13 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t al
 }
 
 int
+bus_dma_tag_set_domain(bus_dma_tag_t dmat, int domain)
+{
+
+   return (0);
+}
+
+int
 bus_dma_tag_destroy(bus_dma_tag_t dmat)
 {
bus_dma_tag_t dmat_copy;

Modified: head/sys/arm64/arm64/busdma_machdep.c
==
--- head/sys/arm64/arm64/busdma_machdep.c   Fri Jan 12 23:25:05 2018
(r327900)
+++ head/sys/arm64/arm64/busdma_machdep.c   Fri Jan 12 23:34:16 2018
(r327901)
@@ -223,3 +223,9 @@ bus_dma_tag_destroy(bus_dma_tag_t dmat)
return (tc->impl->tag_destroy(dmat));
 }
 
+int
+bus_dma_tag_set_domain(bus_dma_tag_t dmat, int domain)
+{
+
+   return (0);
+}

Modified: head/sys/dev/acpica/acpi_pcib_acpi.c
==
--- head/sys/dev/acpica/acpi_pcib_acpi.cFri Jan 12 23:25:05 2018
(r327900)
+++ head/sys/dev/acpica/acpi_pcib_acpi.cFri Jan 12 23:34:16 2018
(r327901)
@@ -60,6 +60,7 @@ ACPI_MODULE_NAME("PCI_ACPI")
 struct acpi_hpcib_softc {
 device_t   ap_dev;
 ACPI_HANDLEap_handle;
+bus_dma_tag_t  ap_dma_tag;
 intap_flags;
 uint32_t   ap_osc_ctl;
 
@@ -108,6 +109,7 @@ static int  
acpi_pcib_acpi_release_resource(device_t d
 #endif
 static int acpi_pcib_request_feature(device_t pcib, device_t dev,
enum pci_feature feature);
+static bus_dma_tag_t   acpi_pcib_get_dma_tag(device_t bus, device_t child);
 
 static device_method_t acpi_pcib_acpi_methods[] = {
 /* Device interface */
@@ -136,6 +138,7 @@ static device_method_t acpi_pcib_acpi_methods[] = {
 DEVMETHOD(bus_setup_intr,  bus_generic_setup_intr),
 DEVMETHOD(bus_teardown_intr,   bus_generic_teardown_intr),
 DEVMETHOD(bus_get_cpus,acpi_pcib_get_cpus),
+DEVMETHOD(bus_get_dma_tag, acpi_pcib_get_dma_tag),
 
 /* pcib interface */
 DEVMETHOD(pcib_maxslots,   pcib_maxslots),
@@ -366,6 +369,7 @@ acpi_pcib_acpi_attach(device_t dev)
 rman_res_t start;
 int rid;
 #endif
+int error, domain;
 uint8_t busno;
 
 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
@@ -537,15 +541,33 @@ acpi_pcib_acpi_attach(device_t dev)
 
 acpi_pcib_fetch_prt(dev, >ap_prt);
 
+error = bus_dma_tag_create(bus_get_dma_tag(dev), 1,
+   0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
+   NULL, NULL, BUS_SPACE_MAXSIZE, BUS_SPACE_UNRESTRICTED,
+   BUS_SPACE_MAXSIZE, 0, NULL, NULL, >ap_dma_tag);
+if (error != 0)
+   goto errout;
+error = bus_get_domain(dev, );
+if (error == 0)
+   error = bus_dma_tag_set_domain(sc->ap_dma_tag, domain);
+/* Don't fail to attach if the domain can't be queried or set. */
+error = 0;
+
 bus_generic_probe(dev);
 if (device_add_child(dev, "pci", -1) == NULL) {
-   device_printf(device_get_parent(dev), "couldn't attach pci bus\n");
-#if 

svn commit: r327900 - in head: lib/libmemstat sys/amd64/amd64 sys/arm64/arm64 sys/i386/i386 sys/kern sys/mips/mips sys/powerpc/aim sys/powerpc/powerpc sys/riscv/riscv sys/sparc64/sparc64 sys/sys sy...

2018-01-12 Thread Jeff Roberson
Author: jeff
Date: Fri Jan 12 23:25:05 2018
New Revision: 327900
URL: https://svnweb.freebsd.org/changeset/base/327900

Log:
  Implement NUMA support in uma(9) and malloc(9).  Allocations from specific
  domains can be done by the _domain() API variants.  UMA also supports a
  first-touch policy via the NUMA zone flag.
  
  The slab layer is now segregated by VM domains and is precise.  It handles
  iteration for round-robin directly.  The per-cpu cache layer remains
  a mix of domains according to where memory is allocated and freed.  Well
  behaved clients can achieve perfect locality with no performance penalty.
  
  The direct domain allocation functions have to visit the slab layer and
  so require per-zone locks which come at some expense.
  
  Reviewed by:  Attilio (a slightly older version)
  Tested by:pho
  Sponsored by: Netflix, Dell/EMC Isilon

Modified:
  head/lib/libmemstat/memstat_uma.c
  head/sys/amd64/amd64/uma_machdep.c
  head/sys/arm64/arm64/uma_machdep.c
  head/sys/i386/i386/pmap.c
  head/sys/kern/kern_malloc.c
  head/sys/kern/kern_mbuf.c
  head/sys/kern/subr_busdma_bufalloc.c
  head/sys/kern/subr_vmem.c
  head/sys/kern/vfs_bio.c
  head/sys/mips/mips/uma_machdep.c
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/aim/slb.c
  head/sys/powerpc/powerpc/uma_machdep.c
  head/sys/riscv/riscv/uma_machdep.c
  head/sys/sparc64/sparc64/vm_machdep.c
  head/sys/sys/malloc.h
  head/sys/vm/uma.h
  head/sys/vm/uma_core.c
  head/sys/vm/uma_int.h

Modified: head/lib/libmemstat/memstat_uma.c
==
--- head/lib/libmemstat/memstat_uma.c   Fri Jan 12 23:13:55 2018
(r327899)
+++ head/lib/libmemstat/memstat_uma.c   Fri Jan 12 23:25:05 2018
(r327900)
@@ -55,6 +55,8 @@ static struct nlist namelist[] = {
{ .n_name = "_mp_maxid" },
 #defineX_ALL_CPUS  2
{ .n_name = "_all_cpus" },
+#defineX_VM_NDOMAINS   3
+   { .n_name = "_vm_ndomains" },
{ .n_name = "" },
 };
 
@@ -297,11 +299,12 @@ memstat_kvm_uma(struct memory_type_list *list, void *k
 {
LIST_HEAD(, uma_keg) uma_kegs;
struct memory_type *mtp;
+   struct uma_zone_domain uzd;
struct uma_bucket *ubp, ub;
struct uma_cache *ucp, *ucp_array;
struct uma_zone *uzp, uz;
struct uma_keg *kzp, kz;
-   int hint_dontsearch, i, mp_maxid, ret;
+   int hint_dontsearch, i, mp_maxid, ndomains, ret;
char name[MEMTYPE_MAXNAME];
cpuset_t all_cpus;
long cpusetsize;
@@ -323,6 +326,12 @@ memstat_kvm_uma(struct memory_type_list *list, void *k
list->mtl_error = ret;
return (-1);
}
+   ret = kread_symbol(kvm, X_VM_NDOMAINS, ,
+   sizeof(ndomains), 0);
+   if (ret != 0) {
+   list->mtl_error = ret;
+   return (-1);
+   }
ret = kread_symbol(kvm, X_UMA_KEGS, _kegs, sizeof(uma_kegs), 0);
if (ret != 0) {
list->mtl_error = ret;
@@ -447,10 +456,17 @@ skip_percpu:
kz.uk_ipers;
mtp->mt_byteslimit = mtp->mt_countlimit * mtp->mt_size;
mtp->mt_count = mtp->mt_numallocs - mtp->mt_numfrees;
-   for (ubp = LIST_FIRST(_buckets); ubp !=
-   NULL; ubp = LIST_NEXT(, ub_link)) {
-   ret = kread(kvm, ubp, , sizeof(ub), 0);
-   mtp->mt_zonefree += ub.ub_cnt;
+   for (i = 0; i < ndomains; i++) {
+   ret = kread(kvm, _domain[i], ,
+  sizeof(uzd), 0);
+   for (ubp =
+   LIST_FIRST(_buckets);
+   ubp != NULL;
+   ubp = LIST_NEXT(, ub_link)) {
+   ret = kread(kvm, ubp, ,
+  sizeof(ub), 0);
+   mtp->mt_zonefree += ub.ub_cnt;
+   }
}
if (!((kz.uk_flags & UMA_ZONE_SECONDARY) &&
LIST_FIRST(_zones) != uzp)) {

Modified: head/sys/amd64/amd64/uma_machdep.c
==
--- head/sys/amd64/amd64/uma_machdep.c  Fri Jan 12 23:13:55 2018
(r327899)
+++ head/sys/amd64/amd64/uma_machdep.c  Fri Jan 12 23:25:05 2018
(r327900)
@@ -44,14 +44,15 @@ __FBSDID("$FreeBSD$");
 #include 
 
 void *
-uma_small_alloc(uma_zone_t zone, vm_size_t bytes, u_int8_t *flags, int wait)
+uma_small_alloc(uma_zone_t zone, vm_size_t bytes, int domain, u_int8_t *flags,
+int wait)
 {
vm_page_t m;
vm_paddr_t pa;
void *va;
 
*flags = UMA_SLAB_PRIV;
-   m = vm_page_alloc(NULL, 0,
+   m = 

svn commit: r327899 - in head/sys: kern vm

2018-01-12 Thread Jeff Roberson
Author: jeff
Date: Fri Jan 12 23:13:55 2018
New Revision: 327899
URL: https://svnweb.freebsd.org/changeset/base/327899

Log:
  Implement NUMA policy for kmem_*(9).  This maintains compatibility with
  reservations by giving each memory domain its own KVA space in vmem that
  is naturally aligned on superpage boundaries.
  
  Reviewed by:  alc, markj, kib  (some objections)
  Sponsored by: Netflix, Dell/EMC Isilon
  Tested by;pho
  Differential Revision:https://reviews.freebsd.org/D13289

Modified:
  head/sys/kern/subr_vmem.c
  head/sys/vm/vm_extern.h
  head/sys/vm/vm_init.c
  head/sys/vm/vm_kern.c
  head/sys/vm/vm_phys.h
  head/sys/vm/vm_reserv.c

Modified: head/sys/kern/subr_vmem.c
==
--- head/sys/kern/subr_vmem.c   Fri Jan 12 23:12:30 2018(r327898)
+++ head/sys/kern/subr_vmem.c   Fri Jan 12 23:13:55 2018(r327899)
@@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #defineVMEM_OPTORDER   5
@@ -186,6 +187,7 @@ static struct task  vmem_periodic_wk;
 
 static struct mtx_padalign __exclusive_cache_line vmem_list_lock;
 static LIST_HEAD(, vmem) vmem_list = LIST_HEAD_INITIALIZER(vmem_list);
+static uma_zone_t vmem_zone;
 
 /*  misc */
 #defineVMEM_CONDVAR_INIT(vm, wchan)cv_init(>vm_cv, wchan)
@@ -255,11 +257,11 @@ bt_fill(vmem_t *vm, int flags)
VMEM_ASSERT_LOCKED(vm);
 
/*
-* Only allow the kernel arena to dip into reserve tags.  It is the
-* vmem where new tags come from.
+* Only allow the kernel arena and arenas derived from kernel arena to
+* dip into reserve tags.  They are where new tags come from.
 */
flags &= BT_FLAGS;
-   if (vm != kernel_arena)
+   if (vm != kernel_arena && vm->vm_arg != kernel_arena)
flags &= ~M_USE_RESERVE;
 
/*
@@ -615,23 +617,25 @@ static void *
 vmem_bt_alloc(uma_zone_t zone, vm_size_t bytes, uint8_t *pflag, int wait)
 {
vmem_addr_t addr;
+   int domain;
 
*pflag = UMA_SLAB_KERNEL;
+   domain = 0; /* XXX Temporary. */
 
/*
 * Single thread boundary tag allocation so that the address space
 * and memory are added in one atomic operation.
 */
mtx_lock(_bt_lock);
-   if (vmem_xalloc(kernel_arena, bytes, 0, 0, 0, VMEM_ADDR_MIN,
-   VMEM_ADDR_MAX, M_NOWAIT | M_NOVM | M_USE_RESERVE | M_BESTFIT,
-   ) == 0) {
-   if (kmem_back(kernel_object, addr, bytes,
+   if (vmem_xalloc(vm_dom[domain].vmd_kernel_arena, bytes, 0, 0, 0,
+   VMEM_ADDR_MIN, VMEM_ADDR_MAX,
+   M_NOWAIT | M_NOVM | M_USE_RESERVE | M_BESTFIT, ) == 0) {
+   if (kmem_back_domain(domain, kernel_object, addr, bytes,
M_NOWAIT | M_USE_RESERVE) == 0) {
mtx_unlock(_bt_lock);
return ((void *)addr);
}
-   vmem_xfree(kernel_arena, addr, bytes);
+   vmem_xfree(vm_dom[domain].vmd_kernel_arena, addr, bytes);
mtx_unlock(_bt_lock);
/*
 * Out of memory, not address space.  This may not even be
@@ -657,9 +661,12 @@ vmem_startup(void)
 {
 
mtx_init(_list_lock, "vmem list lock", NULL, MTX_DEF);
+   vmem_zone = uma_zcreate("vmem",
+   sizeof(struct vmem), NULL, NULL, NULL, NULL,
+   UMA_ALIGN_PTR, UMA_ZONE_VM);
vmem_bt_zone = uma_zcreate("vmem btag",
sizeof(struct vmem_btag), NULL, NULL, NULL, NULL,
-   UMA_ALIGN_PTR, UMA_ZONE_VM);
+   UMA_ALIGN_PTR, UMA_ZONE_VM | UMA_ZONE_NOFREE);
 #ifndef UMA_MD_SMALL_ALLOC
mtx_init(_bt_lock, "btag lock", NULL, MTX_DEF);
uma_prealloc(vmem_bt_zone, BT_MAXALLOC);
@@ -826,7 +833,7 @@ vmem_destroy1(vmem_t *vm)
 
VMEM_CONDVAR_DESTROY(vm);
VMEM_LOCK_DESTROY(vm);
-   free(vm, M_VMEM);
+   uma_zfree(vmem_zone, vm);
 }
 
 static int
@@ -1058,7 +1065,7 @@ vmem_create(const char *name, vmem_addr_t base, vmem_s
 
vmem_t *vm;
 
-   vm = malloc(sizeof(*vm), M_VMEM, flags & (M_WAITOK|M_NOWAIT));
+   vm = uma_zalloc(vmem_zone, flags & (M_WAITOK|M_NOWAIT));
if (vm == NULL)
return (NULL);
if (vmem_init(vm, name, base, size, quantum, qcache_max,

Modified: head/sys/vm/vm_extern.h
==
--- head/sys/vm/vm_extern.h Fri Jan 12 23:12:30 2018(r327898)
+++ head/sys/vm/vm_extern.h Fri Jan 12 23:13:55 2018(r327899)
@@ -56,14 +56,21 @@ void kmap_free_wakeup(vm_map_t, vm_offset_t, vm_size_t
 /* These operate on virtual addresses backed by memory. */
 vm_offset_t kmem_alloc_attr(struct vmem *, vm_size_t size, int flags,
 vm_paddr_t low, vm_paddr_t high, vm_memattr_t memattr);
+vm_offset_t kmem_alloc_attr_domain(int domain, vm_size_t size, 

svn commit: r327898 - head/sys/netinet/libalias

2018-01-12 Thread Pedro F. Giffuni
Author: pfg
Date: Fri Jan 12 23:12:30 2018
New Revision: 327898
URL: https://svnweb.freebsd.org/changeset/base/327898

Log:
  libalias: small memory allocation cleanups.
  
  Make the calloc wrappers behave as expected by using mallocarray.
  It is rather weird that the malloc wrappers also zeroes the memory: update
  a comment to reflect at least two cases where it is expected.
  
  Reviewed by:  tuexen

Modified:
  head/sys/netinet/libalias/alias_mod.h
  head/sys/netinet/libalias/alias_sctp.c

Modified: head/sys/netinet/libalias/alias_mod.h
==
--- head/sys/netinet/libalias/alias_mod.h   Fri Jan 12 23:06:35 2018
(r327897)
+++ head/sys/netinet/libalias/alias_mod.h   Fri Jan 12 23:12:30 2018
(r327898)
@@ -42,7 +42,7 @@ MALLOC_DECLARE(M_ALIAS);
 /* Use kernel allocator. */
 #if defined(_SYS_MALLOC_H_)
 #definemalloc(x)   malloc(x, M_ALIAS, M_NOWAIT|M_ZERO)
-#definecalloc(x, n)malloc(x*n)
+#definecalloc(n, x)mallocarray((n), (x), M_ALIAS, M_NOWAIT|M_ZERO)
 #definefree(x) free(x, M_ALIAS)
 #endif
 #endif

Modified: head/sys/netinet/libalias/alias_sctp.c
==
--- head/sys/netinet/libalias/alias_sctp.c  Fri Jan 12 23:06:35 2018
(r327897)
+++ head/sys/netinet/libalias/alias_sctp.c  Fri Jan 12 23:12:30 2018
(r327898)
@@ -187,7 +187,7 @@ static MALLOC_DEFINE(M_SCTPNAT, "sctpnat", "sctp nat d
 /* Use kernel allocator. */
 #ifdef _SYS_MALLOC_H_
 #definesn_malloc(x)malloc(x, M_SCTPNAT, M_NOWAIT|M_ZERO)
-#definesn_calloc(n,x)  sn_malloc((x) * (n))
+#definesn_calloc(n,x)  mallocarray((n), (x), M_SCTPNAT, 
M_NOWAIT|M_ZERO)
 #definesn_free(x)  free(x, M_SCTPNAT)
 #endif// #ifdef _SYS_MALLOC_H_
 
@@ -1104,7 +1104,7 @@ sctp_PktParser(struct libalias *la, int direction, str
if (*passoc == NULL) {/* out of 
resources */
return 
(SN_PARSE_ERROR_AS_MALLOC);
}
-   /* Initialise association - malloc 
initialises memory to zeros */
+   /* Initialize association - sn_malloc 
initializes memory to zeros */
(*passoc)->state = SN_ID;
LIST_INIT(&((*passoc)->Gaddr)); /* 
always initialise to avoid memory problems */
(*passoc)->TableRegister = SN_NULL_TBL;
@@ -1168,7 +1168,7 @@ sctp_PktParser(struct libalias *la, int direction, str
if (*passoc == NULL) {/* out of 
resources */
return 
(SN_PARSE_ERROR_AS_MALLOC);
}
-   /* Initialise association  - malloc 
initialises memory to zeros */
+   /* Initialize association  - sn_malloc 
initializes memory to zeros */
(*passoc)->state = SN_ID;
LIST_INIT(&((*passoc)->Gaddr)); /* 
always initialise to avoid memory problems */
(*passoc)->TableRegister = SN_NULL_TBL;
___
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: r327897 - in head/sys: compat/freebsd32 kern sys

2018-01-12 Thread Jeff Roberson
Author: jeff
Date: Fri Jan 12 23:06:35 2018
New Revision: 327897
URL: https://svnweb.freebsd.org/changeset/base/327897

Log:
  Regenerate auto-generated files

Modified:
  head/sys/compat/freebsd32/freebsd32_proto.h
  head/sys/compat/freebsd32/freebsd32_syscall.h
  head/sys/compat/freebsd32/freebsd32_syscalls.c
  head/sys/compat/freebsd32/freebsd32_sysent.c
  head/sys/compat/freebsd32/freebsd32_systrace_args.c
  head/sys/kern/syscalls.c
  head/sys/kern/systrace_args.c
  head/sys/sys/syscall.h
  head/sys/sys/syscall.mk
  head/sys/sys/sysproto.h

Modified: head/sys/compat/freebsd32/freebsd32_proto.h
==
--- head/sys/compat/freebsd32/freebsd32_proto.h Fri Jan 12 22:57:57 2018
(r327896)
+++ head/sys/compat/freebsd32/freebsd32_proto.h Fri Jan 12 23:06:35 2018
(r327897)
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -693,6 +694,24 @@ struct freebsd32_kevent_args {
char nevents_l_[PADL_(int)]; int nevents; char nevents_r_[PADR_(int)];
char timeout_l_[PADL_(const struct timespec32 *)]; const struct 
timespec32 * timeout; char timeout_r_[PADR_(const struct timespec32 *)];
 };
+struct freebsd32_cpuset_getdomain_args {
+   char level_l_[PADL_(cpulevel_t)]; cpulevel_t level; char 
level_r_[PADR_(cpulevel_t)];
+   char which_l_[PADL_(cpuwhich_t)]; cpuwhich_t which; char 
which_r_[PADR_(cpuwhich_t)];
+   char id1_l_[PADL_(uint32_t)]; uint32_t id1; char 
id1_r_[PADR_(uint32_t)];
+   char id2_l_[PADL_(uint32_t)]; uint32_t id2; char 
id2_r_[PADR_(uint32_t)];
+   char domainsetsize_l_[PADL_(size_t)]; size_t domainsetsize; char 
domainsetsize_r_[PADR_(size_t)];
+   char mask_l_[PADL_(domainset_t *)]; domainset_t * mask; char 
mask_r_[PADR_(domainset_t *)];
+   char policy_l_[PADL_(int *)]; int * policy; char policy_r_[PADR_(int 
*)];
+};
+struct freebsd32_cpuset_setdomain_args {
+   char level_l_[PADL_(cpulevel_t)]; cpulevel_t level; char 
level_r_[PADR_(cpulevel_t)];
+   char which_l_[PADL_(cpuwhich_t)]; cpuwhich_t which; char 
which_r_[PADR_(cpuwhich_t)];
+   char id1_l_[PADL_(uint32_t)]; uint32_t id1; char 
id1_r_[PADR_(uint32_t)];
+   char id2_l_[PADL_(uint32_t)]; uint32_t id2; char 
id2_r_[PADR_(uint32_t)];
+   char domainsetsize_l_[PADL_(size_t)]; size_t domainsetsize; char 
domainsetsize_r_[PADR_(size_t)];
+   char mask_l_[PADL_(domainset_t *)]; domainset_t * mask; char 
mask_r_[PADR_(domainset_t *)];
+   char policy_l_[PADL_(int)]; int policy; char policy_r_[PADR_(int)];
+};
 #if !defined(PAD64_REQUIRED) && (defined(__powerpc__) || defined(__mips__))
 #define PAD64_REQUIRED
 #endif
@@ -823,6 +842,8 @@ int freebsd32_fstatat(struct thread *, struct freebsd3
 intfreebsd32_fhstat(struct thread *, struct freebsd32_fhstat_args *);
 intfreebsd32_getdirentries(struct thread *, struct 
freebsd32_getdirentries_args *);
 intfreebsd32_kevent(struct thread *, struct freebsd32_kevent_args *);
+intfreebsd32_cpuset_getdomain(struct thread *, struct 
freebsd32_cpuset_getdomain_args *);
+intfreebsd32_cpuset_setdomain(struct thread *, struct 
freebsd32_cpuset_setdomain_args *);
 
 #ifdef COMPAT_43
 
@@ -1370,6 +1391,8 @@ int   freebsd11_freebsd32_mknodat(struct thread *, 
struc
 #defineFREEBSD32_SYS_AUE_freebsd32_fhstat  AUE_FHSTAT
 #defineFREEBSD32_SYS_AUE_freebsd32_getdirentries   
AUE_GETDIRENTRIES
 #defineFREEBSD32_SYS_AUE_freebsd32_kevent  AUE_KEVENT
+#defineFREEBSD32_SYS_AUE_freebsd32_cpuset_getdomainAUE_NULL
+#defineFREEBSD32_SYS_AUE_freebsd32_cpuset_setdomainAUE_NULL
 
 #undef PAD_
 #undef PADL_

Modified: head/sys/compat/freebsd32/freebsd32_syscall.h
==
--- head/sys/compat/freebsd32/freebsd32_syscall.h   Fri Jan 12 22:57:57 
2018(r327896)
+++ head/sys/compat/freebsd32/freebsd32_syscall.h   Fri Jan 12 23:06:35 
2018(r327897)
@@ -455,8 +455,6 @@
 #defineFREEBSD32_SYS_freebsd32_ppoll   545
 #defineFREEBSD32_SYS_freebsd32_futimens546
 #defineFREEBSD32_SYS_freebsd32_utimensat   547
-#defineFREEBSD32_SYS_numa_getaffinity  548
-#defineFREEBSD32_SYS_numa_setaffinity  549
 #defineFREEBSD32_SYS_fdatasync 550
 #defineFREEBSD32_SYS_freebsd32_fstat   551
 #defineFREEBSD32_SYS_freebsd32_fstatat 552
@@ -468,4 +466,6 @@
 #defineFREEBSD32_SYS_fhstatfs  558
 #defineFREEBSD32_SYS_mknodat   559
 #defineFREEBSD32_SYS_freebsd32_kevent  560
-#defineFREEBSD32_SYS_MAXSYSCALL561
+#defineFREEBSD32_SYS_freebsd32_cpuset_getdomain561
+#defineFREEBSD32_SYS_freebsd32_cpuset_setdomain562
+#defineFREEBSD32_SYS_MAXSYSCALL563

Modified: head/sys/compat/freebsd32/freebsd32_syscalls.c

svn commit: r327896 - in head/sys: sys vm

2018-01-12 Thread Jeff Roberson
Author: jeff
Date: Fri Jan 12 22:57:57 2018
New Revision: 327896
URL: https://svnweb.freebsd.org/changeset/base/327896

Log:
  Add files for r327895
  
  Implement 'domainset', a cpuset based NUMA policy mechanism.  This allows
  userspace to control NUMA policy administratively and programmatically.
  
  Implement domainset based iterators in the page layer.
  
  Remove the now legacy numa_* syscalls.
  
  Cleanup some header polution created by having seq.h in proc.h.
  
  Reviewed by:  markj, kib
  Discussed with:   alc
  Tested by:pho
  Sponsored by: Netflix, Dell/EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D13403

Added:
  head/sys/sys/_domainset.h   (contents, props changed)
  head/sys/sys/domainset.h   (contents, props changed)
  head/sys/vm/vm_domainset.c   (contents, props changed)
  head/sys/vm/vm_domainset.h   (contents, props changed)

Added: head/sys/sys/_domainset.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/sys/_domainset.h   Fri Jan 12 22:57:57 2018(r327896)
@@ -0,0 +1,60 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2017, Jeffrey Roberson 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice unmodified, 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 ``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 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 _SYS__DOMAINSET_H_
+#define_SYS__DOMAINSET_H_
+
+#include 
+
+#ifdef _KERNEL
+#defineDOMAINSET_SETSIZE   MAXMEMDOM
+#endif
+
+#defineDOMAINSET_MAXSIZE   256
+
+#ifndefDOMAINSET_SETSIZE
+#defineDOMAINSET_SETSIZE   DOMAINSET_MAXSIZE
+#endif
+
+BITSET_DEFINE(_domainset, DOMAINSET_SETSIZE);
+typedef struct _domainset domainset_t;
+
+/*
+ * This structure is intended to be embedded in objects which have policy
+ * attributes.  Each object keeps its own iterator so round-robin is
+ * synchronized and accurate.
+ */
+struct domainset;
+struct domainset_ref {
+   struct domainset * volatile dr_policy;
+   int dr_iterator;
+};
+
+#endif /* !_SYS__DOMAINSET_H_ */

Added: head/sys/sys/domainset.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/sys/domainset.hFri Jan 12 22:57:57 2018(r327896)
@@ -0,0 +1,102 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2017, Jeffrey Roberson 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice unmodified, 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 ``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 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 

Re: svn commit: r327823 - head/share/mk

2018-01-12 Thread Antoine Brodin
On Thu, Jan 11, 2018 at 3:03 PM, Ed Maste  wrote:
> Author: emaste
> Date: Thu Jan 11 14:03:05 2018
> New Revision: 327823
> URL: https://svnweb.freebsd.org/changeset/base/327823
>
> Log:
>   Enable ld.lld as bootstrap linker by default on i386
>
>   Akin to r327783 for amd64.  lld has been usable for amd64 for quite some
>   time, but a couple of issues remained that affected i386.  These were
>   recently addressed upstream in lld and merged into FreeBSD (r326831,
>   r326879, r326897, r326957), so we can now use ld.lld on i386 as well.
>
>   Similarly to amd64 this change enables lld only as the bootstrap linker
>   (used to link the kernel and userland libraries and executables), while
>   GNU ld.bfd is still installed as /usr/bin/ld and used for ports builds.
>
>   The ports collection is essentially ready to use lld as the system
>   linker for amd64, but many ports still have trouble with lld on i386,
>   because lld defaults to -ztext, disallowing relocations against readonly
>   segments.  Thus switching the system linker (WITH_LLD_IS_LD) will happen
>   later on a per-arch basis.
>
>   Relnotes: Yes
>   Sponsored by: The FreeBSD Foundation

Hi,

There are some regressions in ports after this change,  could you
revert it and request a proper exp-run?

Thanks.

Antoine
___
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: r327895 - in head: lib/libc/sys sys/arm/arm sys/compat/freebsd32 sys/conf sys/ddb sys/kern sys/netpfil/ipfw sys/sys sys/vm sys/x86/acpica usr.bin/cpuset usr.bin/numactl

2018-01-12 Thread Jeff Roberson
Author: jeff
Date: Fri Jan 12 22:48:23 2018
New Revision: 327895
URL: https://svnweb.freebsd.org/changeset/base/327895

Log:
  Implement 'domainset', a cpuset based NUMA policy mechanism.  This allows
  userspace to control NUMA policy administratively and programmatically.
  
  Implement domainset based iterators in the page layer.
  
  Remove the now legacy numa_* syscalls.
  
  Cleanup some header polution created by having seq.h in proc.h.
  
  Reviewed by:  markj, kib
  Discussed with:   alc
  Tested by:pho
  Sponsored by: Netflix, Dell/EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D13403

Deleted:
  head/sys/kern/kern_numa.c
  head/sys/sys/_vm_domain.h
  head/sys/vm/vm_domain.c
  head/sys/vm/vm_domain.h
Modified:
  head/lib/libc/sys/Symbol.map
  head/sys/arm/arm/machdep_ptrace.c
  head/sys/compat/freebsd32/freebsd32_misc.c
  head/sys/compat/freebsd32/syscalls.master
  head/sys/conf/files
  head/sys/ddb/db_run.c
  head/sys/kern/init_main.c
  head/sys/kern/init_sysent.c
  head/sys/kern/kern_cpuset.c
  head/sys/kern/kern_exit.c
  head/sys/kern/kern_fork.c
  head/sys/kern/kern_thr.c
  head/sys/kern/kern_thread.c
  head/sys/kern/makesyscalls.sh
  head/sys/kern/sched_4bsd.c
  head/sys/kern/sched_ule.c
  head/sys/kern/subr_kdb.c
  head/sys/kern/syscalls.master
  head/sys/netpfil/ipfw/dn_sched_fq_codel.c
  head/sys/sys/cpuset.h
  head/sys/sys/proc.h
  head/sys/sys/syscallsubr.h
  head/sys/vm/vm_fault.c
  head/sys/vm/vm_object.c
  head/sys/vm/vm_object.h
  head/sys/vm/vm_page.c
  head/sys/vm/vm_page.h
  head/sys/vm/vm_phys.c
  head/sys/vm/vm_phys.h
  head/sys/x86/acpica/srat.c
  head/usr.bin/cpuset/cpuset.c
  head/usr.bin/numactl/numactl.c

Modified: head/lib/libc/sys/Symbol.map
==
--- head/lib/libc/sys/Symbol.mapFri Jan 12 21:50:18 2018
(r327894)
+++ head/lib/libc/sys/Symbol.mapFri Jan 12 22:48:23 2018
(r327895)
@@ -398,6 +398,8 @@ FBSD_1.5 {
mknodat;
stat;
statfs;
+   cpuset_getdomain;
+   cpuset_setdomain;
 };
 
 FBSDprivate_1.0 {
@@ -1022,4 +1024,8 @@ FBSDprivate_1.0 {
gssd_syscall;
__libc_interposing_slot;
__libc_sigwait;
+   _cpuset_getdomain;
+   __sys_cpuset_getdomain;
+   _cpuset_setdomain;
+   __sys_cpuset_setdomain;
 };

Modified: head/sys/arm/arm/machdep_ptrace.c
==
--- head/sys/arm/arm/machdep_ptrace.c   Fri Jan 12 21:50:18 2018
(r327894)
+++ head/sys/arm/arm/machdep_ptrace.c   Fri Jan 12 22:48:23 2018
(r327895)
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 

Modified: head/sys/compat/freebsd32/freebsd32_misc.c
==
--- head/sys/compat/freebsd32/freebsd32_misc.c  Fri Jan 12 21:50:18 2018
(r327894)
+++ head/sys/compat/freebsd32/freebsd32_misc.c  Fri Jan 12 22:48:23 2018
(r327895)
@@ -3017,6 +3017,24 @@ freebsd32_cpuset_setaffinity(struct thread *td,
 }
 
 int
+freebsd32_cpuset_getdomain(struct thread *td,
+struct freebsd32_cpuset_getdomain_args *uap)
+{
+
+   return (kern_cpuset_getdomain(td, uap->level, uap->which,
+   PAIR32TO64(id_t,uap->id), uap->domainsetsize, uap->mask, 
uap->policy));
+}
+
+int
+freebsd32_cpuset_setdomain(struct thread *td,
+struct freebsd32_cpuset_setdomain_args *uap)
+{
+
+   return (kern_cpuset_setdomain(td, uap->level, uap->which,
+   PAIR32TO64(id_t,uap->id), uap->domainsetsize, uap->mask, 
uap->policy));
+}
+
+int
 freebsd32_nmount(struct thread *td,
 struct freebsd32_nmount_args /* {
struct iovec *iovp;

Modified: head/sys/compat/freebsd32/syscalls.master
==
--- head/sys/compat/freebsd32/syscalls.master   Fri Jan 12 21:50:18 2018
(r327894)
+++ head/sys/compat/freebsd32/syscalls.master   Fri Jan 12 22:48:23 2018
(r327895)
@@ -1086,12 +1086,8 @@
 547AUE_FUTIMESAT   STD { int freebsd32_utimensat(int fd, \
char *path, \
struct timespec *times, int flag); }
-548AUE_NULLNOPROTO { int numa_getaffinity(cpuwhich_t which, \
-   id_t id, \
-   struct vm_domain_policy *policy); }
-549AUE_NULLNOPROTO { int numa_setaffinity(cpuwhich_t which, \
-   id_t id, \
-   const struct vm_domain_policy *policy); }
+548AUE_NULLUNIMPL  numa_getaffinity
+549AUE_NULLUNIMPL  numa_setaffinity
 550AUE_FSYNC   NOPROTO { int fdatasync(int fd); }
 551AUE_FSTAT   STD { int freebsd32_fstat(int fd, \
struct stat32 

Re: svn commit: r327888 - in head: cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/safety cddl/contrib/opensolaris/lib/libdtrace/common cddl/usr.sbin/dtrace/tests/common/safety sys/cddl/contrib/op

2018-01-12 Thread Mateusz Guzik
On Fri, Jan 12, 2018 at 8:59 PM, Mark Johnston  wrote:

> Modified: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
> 
> ==
> --- head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
> Fri Jan 12 18:44:28 2018(r327887)
> +++ head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
> Fri Jan 12 19:59:46 2018(r327888)
> @@ -3654,6 +3654,24 @@ dtrace_dif_variable(dtrace_mstate_t *mstate,
> dtrace_st
> return (dtrace_dif_varstr(
> (uintptr_t)curthread->t_procp->p_zone->zone_name,
> state, mstate));
> +#elif defined(__FreeBSD__)
> +   /*
> +* On FreeBSD, we introduce compatibility to zonename by falling
> through
> +* into jailname.
> +*/
> +   case DIF_VAR_JAILNAME:
> +   if (!dtrace_priv_kernel(state))
> +   return (0);
> +
> +   return (dtrace_dif_varstr(
> +   (uintptr_t)curthread->t_procp-
> >p_ucred->cr_prison->pr_name,
> +   state, mstate));
> +
>

Why t_procp? curthread->td_proc creds are what is used for permission
checking and it
rarely temporarily goes out of sync with proc's creds. However, if someone
changes creds
while this tracing is enabled this extra dereference risks accessing a
freed object. On the
other hand curthread creads are always safe to read.


> +   case DIF_VAR_JID:
> +   if (!dtrace_priv_kernel(state))
> +   return (0);
> +
> +   return ((uint64_t)curthread->t_procp-
> >p_ucred->cr_prison->pr_id);
>  #else
> return (0);
>  #endif
>
___
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: r327892 - head

2018-01-12 Thread Bryan Drewery
Author: bdrewery
Date: Fri Jan 12 20:40:27 2018
New Revision: 327892
URL: https://svnweb.freebsd.org/changeset/base/327892

Log:
  Ensure MK_LDD for bootstrap-tools matches MK_LLD_BOOTSTRAP.
  
  This fixes building libllvmminimal with MK_LLD support when WITHOUT_LLD
  or WITHOUT_TOOLCHAIN are set, which are install flags not build tools
  flags.
  
  Reported by:  sbruno
  Tested by:sbruno
  Sponsored by: Dell EMC

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Fri Jan 12 20:35:27 2018(r327891)
+++ head/Makefile.inc1  Fri Jan 12 20:40:27 2018(r327892)
@@ -537,6 +537,7 @@ BSARGS= DESTDIR= \
-DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
MK_LLDB=no MK_TESTS=no \
+   MK_LLD=${MK_LLD_BOOTSTRAP} \
MK_INCLUDES=yes
 
 BMAKE= \
___
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: r327891 - head/sys/arm/allwinner/a83t

2018-01-12 Thread Kyle Evans
Author: kevans
Date: Fri Jan 12 20:35:27 2018
New Revision: 327891
URL: https://svnweb.freebsd.org/changeset/base/327891

Log:
  allwinner/a83t_padconf: Rename "emac" function to "gmac" as per upstream DTS
  
  Although these should have been 'emac', upstream DTS is going with using
  'gmac' as the function name for the emac RGMII pins. Rename here to
  accommodate.
  
  emac support for the a83t should come in with the 4.16 DTS update, in
  another couple of months.

Modified:
  head/sys/arm/allwinner/a83t/a83t_padconf.c

Modified: head/sys/arm/allwinner/a83t/a83t_padconf.c
==
--- head/sys/arm/allwinner/a83t/a83t_padconf.c  Fri Jan 12 20:25:57 2018
(r327890)
+++ head/sys/arm/allwinner/a83t/a83t_padconf.c  Fri Jan 12 20:35:27 2018
(r327891)
@@ -71,24 +71,24 @@ static const struct allwinner_pins a83t_pins[] = {
{ "PC17", 2, 17,  { "gpio_in", "gpio_out", "nand" } },
{ "PC18", 2, 18,  { "gpio_in", "gpio_out", "nand" } },
 
-   { "PD2",  3, 2,   { "gpio_in", "gpio_out", "lcd", NULL, "emac" } },
-   { "PD3",  3, 3,   { "gpio_in", "gpio_out", "lcd", NULL, "emac" } },
-   { "PD4",  3, 4,   { "gpio_in", "gpio_out", "lcd", NULL, "emac" } },
-   { "PD5",  3, 5,   { "gpio_in", "gpio_out", "lcd", NULL, "emac" } },
-   { "PD6",  3, 6,   { "gpio_in", "gpio_out", "lcd", NULL, "emac" } },
-   { "PD7",  3, 7,   { "gpio_in", "gpio_out", "lcd", NULL, "emac" } },
-   { "PD10", 3, 10,  { "gpio_in", "gpio_out", "lcd", NULL, "emac" } },
-   { "PD11", 3, 11,  { "gpio_in", "gpio_out", "lcd", NULL, "emac" } },
-   { "PD12", 3, 12,  { "gpio_in", "gpio_out", "lcd", NULL, "emac" } },
-   { "PD13", 3, 13,  { "gpio_in", "gpio_out", "lcd", NULL, "emac" } },
-   { "PD14", 3, 14,  { "gpio_in", "gpio_out", "lcd", NULL, "emac" } },
-   { "PD15", 3, 15,  { "gpio_in", "gpio_out", "lcd", NULL, "emac" } },
-   { "PD18", 3, 18,  { "gpio_in", "gpio_out", "lcd", "lvds", "emac" } },
-   { "PD19", 3, 19,  { "gpio_in", "gpio_out", "lcd", "lvds", "emac" } },
-   { "PD20", 3, 20,  { "gpio_in", "gpio_out", "lcd", "lvds", "emac" } },
-   { "PD21", 3, 21,  { "gpio_in", "gpio_out", "lcd", "lvds", "emac" } },
-   { "PD22", 3, 22,  { "gpio_in", "gpio_out", "lcd", "lvds", "emac" } },
-   { "PD23", 3, 23,  { "gpio_in", "gpio_out", "lcd", "lvds", "emac" } },
+   { "PD2",  3, 2,   { "gpio_in", "gpio_out", "lcd", NULL, "gmac" } },
+   { "PD3",  3, 3,   { "gpio_in", "gpio_out", "lcd", NULL, "gmac" } },
+   { "PD4",  3, 4,   { "gpio_in", "gpio_out", "lcd", NULL, "gmac" } },
+   { "PD5",  3, 5,   { "gpio_in", "gpio_out", "lcd", NULL, "gmac" } },
+   { "PD6",  3, 6,   { "gpio_in", "gpio_out", "lcd", NULL, "gmac" } },
+   { "PD7",  3, 7,   { "gpio_in", "gpio_out", "lcd", NULL, "gmac" } },
+   { "PD10", 3, 10,  { "gpio_in", "gpio_out", "lcd", NULL, "gmac" } },
+   { "PD11", 3, 11,  { "gpio_in", "gpio_out", "lcd", NULL, "gmac" } },
+   { "PD12", 3, 12,  { "gpio_in", "gpio_out", "lcd", NULL, "gmac" } },
+   { "PD13", 3, 13,  { "gpio_in", "gpio_out", "lcd", NULL, "gmac" } },
+   { "PD14", 3, 14,  { "gpio_in", "gpio_out", "lcd", NULL, "gmac" } },
+   { "PD15", 3, 15,  { "gpio_in", "gpio_out", "lcd", NULL, "gmac" } },
+   { "PD18", 3, 18,  { "gpio_in", "gpio_out", "lcd", "lvds", "gmac" } },
+   { "PD19", 3, 19,  { "gpio_in", "gpio_out", "lcd", "lvds", "gmac" } },
+   { "PD20", 3, 20,  { "gpio_in", "gpio_out", "lcd", "lvds", "gmac" } },
+   { "PD21", 3, 21,  { "gpio_in", "gpio_out", "lcd", "lvds", "gmac" } },
+   { "PD22", 3, 22,  { "gpio_in", "gpio_out", "lcd", "lvds", "gmac" } },
+   { "PD23", 3, 23,  { "gpio_in", "gpio_out", "lcd", "lvds", "gmac" } },
{ "PD24", 3, 24,  { "gpio_in", "gpio_out", "lcd", "lvds" } },
{ "PD25", 3, 25,  { "gpio_in", "gpio_out", "lcd", "lvds" } },
{ "PD26", 3, 26,  { "gpio_in", "gpio_out", "lcd", "lvds" } },
___
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: r327890 - head/usr.sbin/bsdinstall/partedit

2018-01-12 Thread Ed Maste
Author: emaste
Date: Fri Jan 12 20:25:57 2018
New Revision: 327890
URL: https://svnweb.freebsd.org/changeset/base/327890

Log:
  bsdinstall: disable SUJ by default
  
  SUJ + cg checksums produce spurious warnings after an unclean shutdown
  (e.g. a crash).  For now disable SUJ for UFS installs so installing from
  a FreeBSD 12 snapshot results in a usable filesystem, until this can be
  fixed.
  
  PR:   225110
  Submitted by: Arshan Khanifar 
  Sponsored by: The FreeBSD Foundation
  Differential Revision: https://reviews.freebsd.org/D13890

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

Modified: head/usr.sbin/bsdinstall/partedit/gpart_ops.c
==
--- head/usr.sbin/bsdinstall/partedit/gpart_ops.c   Fri Jan 12 20:03:24 
2018(r327889)
+++ head/usr.sbin/bsdinstall/partedit/gpart_ops.c   Fri Jan 12 20:25:57 
2018(r327890)
@@ -91,8 +91,7 @@ newfs_command(const char *fstype, char *command, int u
{"SU", "Softupdates",
"Enable softupdates (default)", 1 },
{"SUJ", "Softupdates journaling",
-   "Enable file system journaling (default - "
-   "turn off for SSDs)", 1 },
+   "Enable file system journaling", 0 },
{"TRIM", "Enable SSD TRIM support",
"Enable TRIM support, useful on solid-state drives",
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: r327889 - head/contrib/gcc

2018-01-12 Thread Ed Maste
Author: emaste
Date: Fri Jan 12 20:03:24 2018
New Revision: 327889
URL: https://svnweb.freebsd.org/changeset/base/327889

Log:
  Revert r280909 "unwind-d2 build workaround for arm64"
  
  We no longer try to build unwind-dw2.c on arm64 so no need for this
  workaround.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/contrib/gcc/unwind-dw2.c

Modified: head/contrib/gcc/unwind-dw2.c
==
--- head/contrib/gcc/unwind-dw2.c   Fri Jan 12 19:59:46 2018
(r327888)
+++ head/contrib/gcc/unwind-dw2.c   Fri Jan 12 20:03:24 2018
(r327889)
@@ -1393,16 +1393,7 @@ uw_advance_context (struct _Unwind_Context *context, _
 static inline void
 init_dwarf_reg_size_table (void)
 {
-/*
- * ARM64TODO: http://llvm.org/pr22997
- * llvm 3.6 doesn't support __builtin_init_dwarf_reg_size_table on AArch64.
- */
-#ifdef __aarch64__
-  printf("Unimplemented: init_dwarf_reg_size_table\n");
-  abort();
-#else
   __builtin_init_dwarf_reg_size_table (dwarf_reg_size_table);
-#endif
 }
 
 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: r327888 - in head: cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/safety cddl/contrib/opensolaris/lib/libdtrace/common cddl/usr.sbin/dtrace/tests/common/safety sys/cddl/contrib/ope...

2018-01-12 Thread Mark Johnston
Author: markj
Date: Fri Jan 12 19:59:46 2018
New Revision: 327888
URL: https://svnweb.freebsd.org/changeset/base/327888

Log:
  Add "jid" and "jailname" variables to DTrace.
  
  These return the jail ID and jail name for the traced process,
  respectively, and are analogous to "zonename" on Solaris/illumos.
  "zonename" is now aliased to "jailname".
  
  Also add some stress tests for the new variables.
  
  Submitted by: Domagoj Stolfa 
  Reviewed by:  dteske (previous version)
  MFC after:2 weeks
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D13877

Added:
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/safety/tst.jailname.d
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/safety/tst.jid.d
Modified:
  head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
  head/cddl/usr.sbin/dtrace/tests/common/safety/Makefile
  head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
  head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h

Added: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/safety/tst.jailname.d
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/safety/tst.jailname.d  
Fri Jan 12 19:59:46 2018(r327888)
@@ -0,0 +1,44 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2018 Domagoj Stolfa .
+ *
+ * This software was developed by BAE Systems, the University of Cambridge
+ * Computer Laboratory, and Memorial University under DARPA/AFRL contract
+ * FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent Computing
+ * (TC) research program.
+ *
+ */
+
+#pragma ident  "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * collect jailname at every fbt probe and at every firing of a
+ * high-frequency profile probe
+ */
+
+fbt:::
+{
+   @a[jailname] = count();
+}
+
+profile-4999hz
+{
+   @a[jailname] = count();
+}
+
+tick-1sec
+/n++ == 10/
+{
+   exit(0);
+}

Added: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/safety/tst.jid.d
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/safety/tst.jid.d   
Fri Jan 12 19:59:46 2018(r327888)
@@ -0,0 +1,44 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2018 Domagoj Stolfa .
+ *
+ * This software was developed by BAE Systems, the University of Cambridge
+ * Computer Laboratory, and Memorial University under DARPA/AFRL contract
+ * FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent Computing
+ * (TC) research program.
+ *
+ */
+
+#pragma ident  "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION:
+ * collect jid at every fbt probe and at every firing of a
+ * high-frequency profile probe
+ */
+
+fbt:::
+{
+   @a[jid] = count();
+}
+
+profile-4999hz
+{
+   @a[jid] = count();
+}
+
+tick-1sec
+/n++ == 10/
+{
+   exit(0);
+}

Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
==
--- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.cFri Jan 
12 18:44:28 2018(r327887)
+++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.cFri Jan 
12 19:59:46 2018(r327888)
@@ -313,6 +313,12 @@ static const dt_ident_t _dtrace_globals[] = {
DT_VERS_1_5, _idops_func, "string(int, void *)" },
 { "ipl", DT_IDENT_SCALAR, 0, DIF_VAR_IPL, DT_ATTR_STABCMN, DT_VERS_1_0,
_idops_type, "uint_t" },
+#ifdef __FreeBSD__
+{ "jailname", DT_IDENT_SCALAR, 0, DIF_VAR_JAILNAME,
+   DT_ATTR_STABCMN, DT_VERS_1_13, _idops_type, "string" },
+{ "jid", DT_IDENT_SCALAR, 0, DIF_VAR_JID, DT_ATTR_STABCMN, DT_VERS_1_13,
+   _idops_type, "int" },
+#endif
 { "json", DT_IDENT_FUNC, 0, DIF_SUBR_JSON, DT_ATTR_STABCMN, DT_VERS_1_11,
_idops_func, "string(const char *, const char *)" },
 { "jstack", DT_IDENT_ACTFUNC, 0, 

svn commit: r327882 - head

2018-01-12 Thread Jens Schweikhardt
Author: schweikh
Date: Fri Jan 12 17:33:20 2018
New Revision: 327882
URL: https://svnweb.freebsd.org/changeset/base/327882

Log:
  Correct a couple of typos.

Modified:
  head/UPDATING

Modified: head/UPDATING
==
--- head/UPDATING   Fri Jan 12 17:21:48 2018(r327881)
+++ head/UPDATING   Fri Jan 12 17:33:20 2018(r327882)
@@ -60,8 +60,8 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW:
 WITHOUT_LLD_BOOTSTRAP=yes
 
 20180110:
-   On i386, pmtimer has been removed. It's functionality has been folded
-   into apm. It was a nop on ACPI in current for a while now (but was still
+   On i386, pmtimer has been removed. Its functionality has been folded
+   into apm. It was a no-op on ACPI in current for a while now (but was 
still
needed on i386 in FreeBSD 11 and earlier). Users may need to remove it
from kernel config files.
 
@@ -209,7 +209,7 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW:
will create the recovery information. If you have a filesystem
created prior to this change and wish to have a recovery block
created for your filesystem, you can do so by running fsck in
-   forground mode (i.e., do not use the -p or -y options). As it
+   foreground mode (i.e., do not use the -p or -y options). As it
starts, fsck will ask ``SAVE DATA TO FIND ALTERNATE SUPERBLOCKS''
to which you should answer yes.
 
@@ -1869,7 +1869,7 @@ COMMON ITEMS:
do an upgrade to the new branch. This is the best-tested upgrade path,
and has the highest probability of being successful.  Please try this
approach if you encounter problems with a major version upgrade.  Since
-   the stable 4.x branch point, one has generally been able to upgade from
+   the stable 4.x branch point, one has generally been able to upgrade from
anywhere in the most recent stable branch to head / current (or even the
last couple of stable branches). See the top of this file when there's
an exception.
@@ -2007,7 +2007,7 @@ COMMON ITEMS:
for potential gotchas.  The -U option is also useful to consider.
See mergemaster(8) for more information.
 
-   [5] Usually this step is a noop.  However, from time to time
+   [5] Usually this step is a no-op.  However, from time to time
you may need to do this if you get unknown user in the following
step.  It never hurts to do it all the time.  You may need to
install a new mergemaster (cd src/usr.sbin/mergemaster && make
___
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: r327881 - head/stand/efi/boot1

2018-01-12 Thread Warner Losh
Author: imp
Date: Fri Jan 12 17:21:48 2018
New Revision: 327881
URL: https://svnweb.freebsd.org/changeset/base/327881

Log:
  Allow this file to be included
  
  Use simple "foo" rather than "${.CURDIR}/foo" to include Makefile.fat
  since the former works when including this Makefile from else
  where. Also, use full path from ${BOOTSRC} to the FAT templates for
  similar reasons. It doesn't change anything in base FreeBSD, but
  allows us to have a custom boot1.efi more easily (though that will be
  short-lived for us, it may also be helpful for others).
  
  Sponsored by: Netflix

Modified:
  head/stand/efi/boot1/Makefile

Modified: head/stand/efi/boot1/Makefile
==
--- head/stand/efi/boot1/Makefile   Fri Jan 12 16:28:51 2018
(r327880)
+++ head/stand/efi/boot1/Makefile   Fri Jan 12 17:21:48 2018
(r327881)
@@ -110,7 +110,7 @@ boot1.efi: ${PROG}
 # The following inserts our objects into a template FAT file system
 # created by generate-fat.sh
 
-.include "${.CURDIR}/Makefile.fat"
+.include "Makefile.fat"
 
 boot1.efifat: boot1.efi
@set -- `ls -l ${.ALLSRC}`; \
@@ -120,7 +120,7 @@ boot1.efifat: boot1.efi
exit 1; \
fi
echo ${.OBJDIR}
-   xz -d -c ${.CURDIR}/fat-${MACHINE}.tmpl.xz > ${.TARGET}
+   xz -d -c ${BOOTSRC}/efi/boot1/fat-${MACHINE}.tmpl.xz > ${.TARGET}
${DD} if=${.ALLSRC} of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc
 
 CLEANFILES+= boot1.efi boot1.efifat
___
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: r327876 - in head/sys/arm64: arm64 include

2018-01-12 Thread Michal Meloun



On 12.01.2018 15:54, Warner Losh wrote:



On Fri, Jan 12, 2018 at 7:52 AM, Andrew Turner > wrote:





On 12 Jan 2018, at 14:37, Warner Losh > wrote:



On Fri, Jan 12, 2018 at 7:15 AM, Andrew Turner > wrote:




On 12 Jan 2018, at 14:10, Marcin Wojtas > wrote:

Hi Andrew,



2018-01-12 15:01 GMT+01:00 Andrew Turner >:

Author: andrew
Date: Fri Jan 12 14:01:38 2018
New Revision: 327876
URL: https://svnweb.freebsd.org/changeset/base/327876


Log:
 Workaround Spectre Variant 2 on arm64.

 We need to handle two cases:

 1. One process attacking another process.
 2. A process attacking the kernel.

 For the first case we clear the branch predictor state on
context switch
 between different processes. For the second we do this when
taking an
 instruction abort on a non-userspace address.

 To clear the branch predictor state a per-CPU function
pointer has been
 added. This is set by the new cpu errata code based on if
the CPU is
 known to be affected.

 On Cortex-A57, A72, A73, and A75 we call into the PSCI
firmware as newer
 versions of this will clear the branch predictor state for us.

 It has been reported the ThunderX is unaffected, however
the ThunderX2 is
 vulnerable. The Qualcomm Falkor core is also affected. As
FreeBSD doesn't
 yet run on the ThunderX2 or Falkor no workaround is
included for these CPUs.


Regardless ThunderX2 / Falkor work-arounds, do I understand
correctly
that pure CA72 machines, such as Marvell Armada 7k/8k are
immune to
Variant 2 now?


It is my understanding that the A72 will be immune with this
patch and an updated Arm Trusted Firmware as documented in [1].

Andrew

[1]

https://github.com/ARM-software/arm-trusted-firmware/wiki/ARM-Trusted-Firmware-Security-Advisory-TFV-6




Are you also working on aarch32 mitigation?


No. I think a similar technique could be used, however as aarch32
has instructions to invalidate the branch predictor these can be
used directly.


That's my reading as well. It looks fairly easy to do it always, but 
I've not researched it sufficiently.




I work on patches for armv6/7. But for aarch32, there is, unfortunately, 
much less information available about affective mitigation of variant 2.

BPIALL while switching pmap is clear and we have it in code for years
(well, BPIALL is effectively NOP for A15/A17, it must be explicitly 
enabled).

But is not clear for me for which trap is branch predictor flush necessary.

Michal
___
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: r327880 - head/stand/libsa

2018-01-12 Thread Warner Losh
Author: imp
Date: Fri Jan 12 16:28:51 2018
New Revision: 327880
URL: https://svnweb.freebsd.org/changeset/base/327880

Log:
  Move getsecs() prototype to stand.h from net.h so it can be used
  everywhere.
  
  Sponsored by: Netflix

Modified:
  head/stand/libsa/net.h
  head/stand/libsa/stand.h

Modified: head/stand/libsa/net.h
==
--- head/stand/libsa/net.h  Fri Jan 12 15:30:56 2018(r327879)
+++ head/stand/libsa/net.h  Fri Jan 12 16:28:51 2018(r327880)
@@ -128,6 +128,4 @@ char*inet_ntoa(struct in_addr);
 char   *intoa(n_long); /* similar to inet_ntoa */
 n_long inet_addr(char *);
 
-/* Machine-dependent functions: */
-time_t getsecs(void);
 #endif /* ! _STAND_NET_H */

Modified: head/stand/libsa/stand.h
==
--- head/stand/libsa/stand.hFri Jan 12 15:30:56 2018(r327879)
+++ head/stand/libsa/stand.hFri Jan 12 16:28:51 2018(r327880)
@@ -394,6 +394,7 @@ extern void putchar(int);
 extern int devopen(struct open_file *, const char *, const char 
**);
 extern int devclose(struct open_file *f);
 extern voidpanic(const char *, ...) __dead2 __printflike(1, 2);
+extern time_t  getsecs(void);
 extern struct fs_ops   *file_system[];
 extern struct fs_ops   *exclusive_file_system;
 extern struct devsw*devsw[];
___
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: r327879 - head/stand/efi/boot1

2018-01-12 Thread Warner Losh
Author: imp
Date: Fri Jan 12 15:30:56 2018
New Revision: 327879
URL: https://svnweb.freebsd.org/changeset/base/327879

Log:
  Report the boot order and where we are in that boot order.  Add
  ability to create a boot1.efi that always fails for testing purposes
  and failover scenarios.
  
  Sponsored by: Netflix

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

Modified: head/stand/efi/boot1/boot1.c
==
--- head/stand/efi/boot1/boot1.cFri Jan 12 15:30:52 2018
(r327878)
+++ head/stand/efi/boot1/boot1.cFri Jan 12 15:30:56 2018
(r327879)
@@ -55,6 +55,7 @@ static EFI_GUID DevicePathGUID = DEVICE_PATH_PROTOCOL;
 static EFI_GUID LoadedImageGUID = LOADED_IMAGE_PROTOCOL;
 static EFI_GUID ConsoleControlGUID = EFI_CONSOLE_CONTROL_PROTOCOL_GUID;
 static EFI_GUID FreeBSDBootVarGUID = FREEBSD_BOOT_VAR_GUID;
+static EFI_GUID GlobalBootVarGUID = UEFI_BOOT_VAR_GUID;
 
 /*
  * Provide Malloc / Free backed by EFIs AllocatePool / FreePool which ensures
@@ -80,6 +81,25 @@ Free(void *buf, const char *file __unused, int line __
 }
 
 static EFI_STATUS
+efi_getenv(EFI_GUID *g, const char *v, void *data, size_t *len)
+{
+   size_t ul;
+   CHAR16 *uv;
+   UINT32 attr;
+   UINTN dl;
+   EFI_STATUS rv;
+
+   utf8_to_ucs2(v, , );
+   if (uv == NULL)
+   return (EFI_OUT_OF_RESOURCES);
+   dl = *len;
+   rv = RS->GetVariable(uv, g, , , data);
+   if (rv == EFI_SUCCESS)
+   *len = dl;
+   return (rv);
+}
+
+static EFI_STATUS
 efi_setenv_freebsd_wcs(const char *varname, CHAR16 *valstr)
 {
CHAR16 *var = NULL;
@@ -411,6 +431,9 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab)
SIMPLE_TEXT_OUTPUT_INTERFACE *conout = NULL;
UINTN i, max_dim, best_mode, cols, rows, hsize, nhandles;
CHAR16 *text;
+   UINT16 boot_current;
+   size_t sz;
+   UINT16 boot_order[100];
 
/* Basic initialization*/
ST = Xsystab;
@@ -480,12 +503,32 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab)
}
}
 
+   boot_current = 0;
+   sz = sizeof(boot_current);
+   efi_getenv(, "BootCurrent", _current, );
+   printf("   BootCurrent: %04x\n", boot_current);
+
+   sz = sizeof(boot_order);
+   efi_getenv(, "BootOrder", _order, );
+   printf("   BootOrder:");
+   for (i = 0; i < sz / sizeof(boot_order[0]); i++)
+   printf(" %04x", boot_order[i]);
+   printf("\n");
+
+#ifdef TEST_FAILURE
+   /*
+* For testing failover scenarios, it's nice to be able to fail fast.
+* Define TEST_FAILURE to create a boot1.efi that always fails after
+* reporting the boot manager protocol details.
+*/
+   BS->Exit(IH, EFI_OUT_OF_RESOURCES, 0, NULL);
+#endif
+
/* Get all the device handles */
hsize = (UINTN)NUM_HANDLES_INIT * sizeof(EFI_HANDLE);
handles = malloc(hsize);
-   if (handles == NULL) {
+   if (handles == NULL)
printf("Failed to allocate %d handles\n", NUM_HANDLES_INIT);
-   }
 
status = BS->LocateHandle(ByProtocol, , NULL,
, handles);
___
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: r327878 - head/stand/efi/include

2018-01-12 Thread Warner Losh
Author: imp
Date: Fri Jan 12 15:30:52 2018
New Revision: 327878
URL: https://svnweb.freebsd.org/changeset/base/327878

Log:
  Add GUID for UEFI boot manager variables.
  
  Sponsoered by: Netflix

Modified:
  head/stand/efi/include/efi.h

Modified: head/stand/efi/include/efi.h
==
--- head/stand/efi/include/efi.hFri Jan 12 15:30:48 2018
(r327877)
+++ head/stand/efi/include/efi.hFri Jan 12 15:30:52 2018
(r327878)
@@ -59,5 +59,7 @@ Revision History
  */
 #define FREEBSD_BOOT_VAR_GUID \
{ 0xCFEE69AD, 0xA0DE, 0x47A9, {0x93, 0xA8, 0xF6, 0x31, 0x06, 0xF8, 
0xAE, 0x99} }
+#define UEFI_BOOT_VAR_GUID \
+   { 0x8be4df61, 0x93ca, 0x11d2, {0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 
0x2b, 0x8c} }
 
 #endif
___
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: r327876 - in head/sys/arm64: arm64 include

2018-01-12 Thread Warner Losh
On Fri, Jan 12, 2018 at 7:52 AM, Andrew Turner  wrote:

>
>
> On 12 Jan 2018, at 14:37, Warner Losh  wrote:
>
>
>
> On Fri, Jan 12, 2018 at 7:15 AM, Andrew Turner  wrote:
>
>>
>>
>> On 12 Jan 2018, at 14:10, Marcin Wojtas  wrote:
>>
>> Hi Andrew,
>>
>>
>>
>> 2018-01-12 15:01 GMT+01:00 Andrew Turner :
>>
>> Author: andrew
>> Date: Fri Jan 12 14:01:38 2018
>> New Revision: 327876
>> URL: https://svnweb.freebsd.org/changeset/base/327876
>>
>> Log:
>>  Workaround Spectre Variant 2 on arm64.
>>
>>  We need to handle two cases:
>>
>>  1. One process attacking another process.
>>  2. A process attacking the kernel.
>>
>>  For the first case we clear the branch predictor state on context switch
>>  between different processes. For the second we do this when taking an
>>  instruction abort on a non-userspace address.
>>
>>  To clear the branch predictor state a per-CPU function pointer has been
>>  added. This is set by the new cpu errata code based on if the CPU is
>>  known to be affected.
>>
>>  On Cortex-A57, A72, A73, and A75 we call into the PSCI firmware as newer
>>  versions of this will clear the branch predictor state for us.
>>
>>  It has been reported the ThunderX is unaffected, however the ThunderX2 is
>>  vulnerable. The Qualcomm Falkor core is also affected. As FreeBSD doesn't
>>  yet run on the ThunderX2 or Falkor no workaround is included for these
>> CPUs.
>>
>>
>> Regardless ThunderX2 / Falkor work-arounds, do I understand correctly
>> that pure CA72 machines, such as Marvell Armada 7k/8k are immune to
>> Variant 2 now?
>>
>>
>> It is my understanding that the A72 will be immune with this patch and an
>> updated Arm Trusted Firmware as documented in [1].
>>
>> Andrew
>>
>> [1] https://github.com/ARM-software/arm-trusted-firmware/wik
>> i/ARM-Trusted-Firmware-Security-Advisory-TFV-6
>>
>
> Are you also working on aarch32 mitigation?
>
>
> No. I think a similar technique could be used, however as aarch32 has
> instructions to invalidate the branch predictor these can be used directly.
>

That's my reading as well. It looks fairly easy to do it always, but I've
not researched it sufficiently.

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"


Re: svn commit: r327876 - in head/sys/arm64: arm64 include

2018-01-12 Thread Andrew Turner


> On 12 Jan 2018, at 14:37, Warner Losh  wrote:
> 
> 
> 
> On Fri, Jan 12, 2018 at 7:15 AM, Andrew Turner  > wrote:
> 
> 
>> On 12 Jan 2018, at 14:10, Marcin Wojtas > > wrote:
>> 
>> Hi Andrew,
>> 
>> 
>> 
>> 2018-01-12 15:01 GMT+01:00 Andrew Turner > >:
>>> Author: andrew
>>> Date: Fri Jan 12 14:01:38 2018
>>> New Revision: 327876
>>> URL: https://svnweb.freebsd.org/changeset/base/327876 
>>> 
>>> 
>>> Log:
>>>  Workaround Spectre Variant 2 on arm64.
>>> 
>>>  We need to handle two cases:
>>> 
>>>  1. One process attacking another process.
>>>  2. A process attacking the kernel.
>>> 
>>>  For the first case we clear the branch predictor state on context switch
>>>  between different processes. For the second we do this when taking an
>>>  instruction abort on a non-userspace address.
>>> 
>>>  To clear the branch predictor state a per-CPU function pointer has been
>>>  added. This is set by the new cpu errata code based on if the CPU is
>>>  known to be affected.
>>> 
>>>  On Cortex-A57, A72, A73, and A75 we call into the PSCI firmware as newer
>>>  versions of this will clear the branch predictor state for us.
>>> 
>>>  It has been reported the ThunderX is unaffected, however the ThunderX2 is
>>>  vulnerable. The Qualcomm Falkor core is also affected. As FreeBSD doesn't
>>>  yet run on the ThunderX2 or Falkor no workaround is included for these 
>>> CPUs.
>> 
>> Regardless ThunderX2 / Falkor work-arounds, do I understand correctly
>> that pure CA72 machines, such as Marvell Armada 7k/8k are immune to
>> Variant 2 now?
> 
> It is my understanding that the A72 will be immune with this patch and an 
> updated Arm Trusted Firmware as documented in [1].
> 
> Andrew
> 
> [1] 
> https://github.com/ARM-software/arm-trusted-firmware/wiki/ARM-Trusted-Firmware-Security-Advisory-TFV-6
>  
> 
> 
> Are you also working on aarch32 mitigation?

No. I think a similar technique could be used, however as aarch32 has 
instructions to invalidate the branch predictor these can be used directly.

Andrew
___
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: r327876 - in head/sys/arm64: arm64 include

2018-01-12 Thread Warner Losh
On Fri, Jan 12, 2018 at 7:15 AM, Andrew Turner  wrote:

>
>
> On 12 Jan 2018, at 14:10, Marcin Wojtas  wrote:
>
> Hi Andrew,
>
>
>
> 2018-01-12 15:01 GMT+01:00 Andrew Turner :
>
> Author: andrew
> Date: Fri Jan 12 14:01:38 2018
> New Revision: 327876
> URL: https://svnweb.freebsd.org/changeset/base/327876
>
> Log:
>  Workaround Spectre Variant 2 on arm64.
>
>  We need to handle two cases:
>
>  1. One process attacking another process.
>  2. A process attacking the kernel.
>
>  For the first case we clear the branch predictor state on context switch
>  between different processes. For the second we do this when taking an
>  instruction abort on a non-userspace address.
>
>  To clear the branch predictor state a per-CPU function pointer has been
>  added. This is set by the new cpu errata code based on if the CPU is
>  known to be affected.
>
>  On Cortex-A57, A72, A73, and A75 we call into the PSCI firmware as newer
>  versions of this will clear the branch predictor state for us.
>
>  It has been reported the ThunderX is unaffected, however the ThunderX2 is
>  vulnerable. The Qualcomm Falkor core is also affected. As FreeBSD doesn't
>  yet run on the ThunderX2 or Falkor no workaround is included for these
> CPUs.
>
>
> Regardless ThunderX2 / Falkor work-arounds, do I understand correctly
> that pure CA72 machines, such as Marvell Armada 7k/8k are immune to
> Variant 2 now?
>
>
> It is my understanding that the A72 will be immune with this patch and an
> updated Arm Trusted Firmware as documented in [1].
>
> Andrew
>
> [1] https://github.com/ARM-software/arm-trusted-firmware/
> wiki/ARM-Trusted-Firmware-Security-Advisory-TFV-6
>

Are you also working on aarch32 mitigation?

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"


Re: svn commit: r327876 - in head/sys/arm64: arm64 include

2018-01-12 Thread Andrew Turner


> On 12 Jan 2018, at 14:10, Marcin Wojtas  wrote:
> 
> Hi Andrew,
> 
> 
> 
> 2018-01-12 15:01 GMT+01:00 Andrew Turner  >:
>> Author: andrew
>> Date: Fri Jan 12 14:01:38 2018
>> New Revision: 327876
>> URL: https://svnweb.freebsd.org/changeset/base/327876
>> 
>> Log:
>>  Workaround Spectre Variant 2 on arm64.
>> 
>>  We need to handle two cases:
>> 
>>  1. One process attacking another process.
>>  2. A process attacking the kernel.
>> 
>>  For the first case we clear the branch predictor state on context switch
>>  between different processes. For the second we do this when taking an
>>  instruction abort on a non-userspace address.
>> 
>>  To clear the branch predictor state a per-CPU function pointer has been
>>  added. This is set by the new cpu errata code based on if the CPU is
>>  known to be affected.
>> 
>>  On Cortex-A57, A72, A73, and A75 we call into the PSCI firmware as newer
>>  versions of this will clear the branch predictor state for us.
>> 
>>  It has been reported the ThunderX is unaffected, however the ThunderX2 is
>>  vulnerable. The Qualcomm Falkor core is also affected. As FreeBSD doesn't
>>  yet run on the ThunderX2 or Falkor no workaround is included for these CPUs.
> 
> Regardless ThunderX2 / Falkor work-arounds, do I understand correctly
> that pure CA72 machines, such as Marvell Armada 7k/8k are immune to
> Variant 2 now?

It is my understanding that the A72 will be immune with this patch and an 
updated Arm Trusted Firmware as documented in [1].

Andrew

[1] 
https://github.com/ARM-software/arm-trusted-firmware/wiki/ARM-Trusted-Firmware-Security-Advisory-TFV-6
 


___
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: r327876 - in head/sys/arm64: arm64 include

2018-01-12 Thread Marcin Wojtas
Hi Andrew,



2018-01-12 15:01 GMT+01:00 Andrew Turner :
> Author: andrew
> Date: Fri Jan 12 14:01:38 2018
> New Revision: 327876
> URL: https://svnweb.freebsd.org/changeset/base/327876
>
> Log:
>   Workaround Spectre Variant 2 on arm64.
>
>   We need to handle two cases:
>
>   1. One process attacking another process.
>   2. A process attacking the kernel.
>
>   For the first case we clear the branch predictor state on context switch
>   between different processes. For the second we do this when taking an
>   instruction abort on a non-userspace address.
>
>   To clear the branch predictor state a per-CPU function pointer has been
>   added. This is set by the new cpu errata code based on if the CPU is
>   known to be affected.
>
>   On Cortex-A57, A72, A73, and A75 we call into the PSCI firmware as newer
>   versions of this will clear the branch predictor state for us.
>
>   It has been reported the ThunderX is unaffected, however the ThunderX2 is
>   vulnerable. The Qualcomm Falkor core is also affected. As FreeBSD doesn't
>   yet run on the ThunderX2 or Falkor no workaround is included for these CPUs.

Regardless ThunderX2 / Falkor work-arounds, do I understand correctly
that pure CA72 machines, such as Marvell Armada 7k/8k are immune to
Variant 2 now?

Thanks,
Marcin

>
>   MFC after:3 days
>   Sponsored by: DARPA, AFRL
>   Differential Revision:https://reviews.freebsd.org/D13812
>
> Modified:
>   head/sys/arm64/arm64/cpu_errata.c
>   head/sys/arm64/arm64/pmap.c
>   head/sys/arm64/arm64/trap.c
>   head/sys/arm64/include/pcpu.h
>
> Modified: head/sys/arm64/arm64/cpu_errata.c
> ==
> --- head/sys/arm64/arm64/cpu_errata.c   Fri Jan 12 13:40:50 2018
> (r327875)
> +++ head/sys/arm64/arm64/cpu_errata.c   Fri Jan 12 14:01:38 2018
> (r327876)
> @@ -30,6 +30,8 @@
>   * SUCH DAMAGE.
>   */
>
> +#include "opt_platform.h"
> +
>  #include 
>  __FBSDID("$FreeBSD$");
>
> @@ -39,6 +41,10 @@ __FBSDID("$FreeBSD$");
>
>  #include 
>
> +#ifdef DEV_PSCI
> +#include 
> +#endif
> +
>  typedef void (cpu_quirk_install)(void);
>  struct cpu_quirks {
> cpu_quirk_install *quirk_install;
> @@ -49,7 +55,36 @@ struct cpu_quirks {
>  static cpu_quirk_install install_psci_bp_hardening;
>
>  static struct cpu_quirks cpu_quirks[] = {
> +   {
> +   .midr_mask = CPU_IMPL_MASK | CPU_PART_MASK,
> +   .midr_value = CPU_ID_RAW(CPU_IMPL_ARM, 
> CPU_PART_CORTEX_A57,0,0),
> +   .quirk_install = install_psci_bp_hardening,
> +   },
> +   {
> +   .midr_mask = CPU_IMPL_MASK | CPU_PART_MASK,
> +   .midr_value = CPU_ID_RAW(CPU_IMPL_ARM, 
> CPU_PART_CORTEX_A72,0,0),
> +   .quirk_install = install_psci_bp_hardening,
> +   },
> +   {
> +   .midr_mask = CPU_IMPL_MASK | CPU_PART_MASK,
> +   .midr_value = CPU_ID_RAW(CPU_IMPL_ARM, 
> CPU_PART_CORTEX_A73,0,0),
> +   .quirk_install = install_psci_bp_hardening,
> +   },
> +   {
> +   .midr_mask = CPU_IMPL_MASK | CPU_PART_MASK,
> +   .midr_value = CPU_ID_RAW(CPU_IMPL_ARM, 
> CPU_PART_CORTEX_A75,0,0),
> +   .quirk_install = install_psci_bp_hardening,
> +   },
>  };
> +
> +static void
> +install_psci_bp_hardening(void)
> +{
> +
> +#ifdef DEV_PSCI
> +   PCPU_SET(bp_harden, psci_get_version);
> +#endif
> +}
>
>  void
>  install_cpu_errata(void)
>
> Modified: head/sys/arm64/arm64/pmap.c
> ==
> --- head/sys/arm64/arm64/pmap.c Fri Jan 12 13:40:50 2018(r327875)
> +++ head/sys/arm64/arm64/pmap.c Fri Jan 12 14:01:38 2018(r327876)
> @@ -4663,6 +4663,7 @@ pmap_activate(struct thread *td)
>  struct pcb *
>  pmap_switch(struct thread *old, struct thread *new)
>  {
> +   pcpu_bp_harden bp_harden;
> struct pcb *pcb;
>
> /* Store the new curthread */
> @@ -4690,6 +4691,15 @@ pmap_switch(struct thread *old, struct thread *new)
> "dsbish \n"
> "isb\n"
> : : "r"(new->td_proc->p_md.md_l0addr));
> +
> +   /*
> +* Stop userspace from training the branch predictor against
> +* other processes. This will call into a CPU specific
> +* function that clears the branch predictor state.
> +*/
> +   bp_harden = PCPU_GET(bp_harden);
> +   if (bp_harden != NULL)
> +   bp_harden();
> }
>
> return (pcb);
>
> Modified: head/sys/arm64/arm64/trap.c
> ==
> --- head/sys/arm64/arm64/trap.c Fri Jan 12 13:40:50 2018(r327875)
> +++ head/sys/arm64/arm64/trap.c Fri Jan 12 14:01:38 2018(r327876)
> @@ -352,6 +352,7 

svn commit: r327876 - in head/sys/arm64: arm64 include

2018-01-12 Thread Andrew Turner
Author: andrew
Date: Fri Jan 12 14:01:38 2018
New Revision: 327876
URL: https://svnweb.freebsd.org/changeset/base/327876

Log:
  Workaround Spectre Variant 2 on arm64.
  
  We need to handle two cases:
  
  1. One process attacking another process.
  2. A process attacking the kernel.
  
  For the first case we clear the branch predictor state on context switch
  between different processes. For the second we do this when taking an
  instruction abort on a non-userspace address.
  
  To clear the branch predictor state a per-CPU function pointer has been
  added. This is set by the new cpu errata code based on if the CPU is
  known to be affected.
  
  On Cortex-A57, A72, A73, and A75 we call into the PSCI firmware as newer
  versions of this will clear the branch predictor state for us.
  
  It has been reported the ThunderX is unaffected, however the ThunderX2 is
  vulnerable. The Qualcomm Falkor core is also affected. As FreeBSD doesn't
  yet run on the ThunderX2 or Falkor no workaround is included for these CPUs.
  
  MFC after:3 days
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D13812

Modified:
  head/sys/arm64/arm64/cpu_errata.c
  head/sys/arm64/arm64/pmap.c
  head/sys/arm64/arm64/trap.c
  head/sys/arm64/include/pcpu.h

Modified: head/sys/arm64/arm64/cpu_errata.c
==
--- head/sys/arm64/arm64/cpu_errata.c   Fri Jan 12 13:40:50 2018
(r327875)
+++ head/sys/arm64/arm64/cpu_errata.c   Fri Jan 12 14:01:38 2018
(r327876)
@@ -30,6 +30,8 @@
  * SUCH DAMAGE.
  */
 
+#include "opt_platform.h"
+
 #include 
 __FBSDID("$FreeBSD$");
 
@@ -39,6 +41,10 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+#ifdef DEV_PSCI
+#include 
+#endif
+
 typedef void (cpu_quirk_install)(void);
 struct cpu_quirks {
cpu_quirk_install *quirk_install;
@@ -49,7 +55,36 @@ struct cpu_quirks {
 static cpu_quirk_install install_psci_bp_hardening;
 
 static struct cpu_quirks cpu_quirks[] = {
+   {
+   .midr_mask = CPU_IMPL_MASK | CPU_PART_MASK,
+   .midr_value = CPU_ID_RAW(CPU_IMPL_ARM, CPU_PART_CORTEX_A57,0,0),
+   .quirk_install = install_psci_bp_hardening,
+   },
+   {
+   .midr_mask = CPU_IMPL_MASK | CPU_PART_MASK,
+   .midr_value = CPU_ID_RAW(CPU_IMPL_ARM, CPU_PART_CORTEX_A72,0,0),
+   .quirk_install = install_psci_bp_hardening,
+   },
+   {
+   .midr_mask = CPU_IMPL_MASK | CPU_PART_MASK,
+   .midr_value = CPU_ID_RAW(CPU_IMPL_ARM, CPU_PART_CORTEX_A73,0,0),
+   .quirk_install = install_psci_bp_hardening,
+   },
+   {
+   .midr_mask = CPU_IMPL_MASK | CPU_PART_MASK,
+   .midr_value = CPU_ID_RAW(CPU_IMPL_ARM, CPU_PART_CORTEX_A75,0,0),
+   .quirk_install = install_psci_bp_hardening,
+   },
 };
+
+static void
+install_psci_bp_hardening(void)
+{
+
+#ifdef DEV_PSCI
+   PCPU_SET(bp_harden, psci_get_version);
+#endif
+}
 
 void
 install_cpu_errata(void)

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Fri Jan 12 13:40:50 2018(r327875)
+++ head/sys/arm64/arm64/pmap.c Fri Jan 12 14:01:38 2018(r327876)
@@ -4663,6 +4663,7 @@ pmap_activate(struct thread *td)
 struct pcb *
 pmap_switch(struct thread *old, struct thread *new)
 {
+   pcpu_bp_harden bp_harden;
struct pcb *pcb;
 
/* Store the new curthread */
@@ -4690,6 +4691,15 @@ pmap_switch(struct thread *old, struct thread *new)
"dsbish \n"
"isb\n"
: : "r"(new->td_proc->p_md.md_l0addr));
+
+   /*
+* Stop userspace from training the branch predictor against
+* other processes. This will call into a CPU specific
+* function that clears the branch predictor state.
+*/
+   bp_harden = PCPU_GET(bp_harden);
+   if (bp_harden != NULL)
+   bp_harden();
}
 
return (pcb);

Modified: head/sys/arm64/arm64/trap.c
==
--- head/sys/arm64/arm64/trap.c Fri Jan 12 13:40:50 2018(r327875)
+++ head/sys/arm64/arm64/trap.c Fri Jan 12 14:01:38 2018(r327876)
@@ -352,6 +352,7 @@ do_el1h_sync(struct thread *td, struct trapframe *fram
 void
 do_el0_sync(struct thread *td, struct trapframe *frame)
 {
+   pcpu_bp_harden bp_harden;
uint32_t exception;
uint64_t esr, far;
 
@@ -363,11 +364,25 @@ do_el0_sync(struct thread *td, struct trapframe *frame
esr = frame->tf_esr;
exception = ESR_ELx_EXCEPTION(esr);
switch (exception) {
-   case EXCP_UNKNOWN:
case EXCP_INSN_ABORT_L:
+   far = 

svn commit: r327875 - head/sys/kern

2018-01-12 Thread Mateusz Guzik
Author: mjg
Date: Fri Jan 12 13:40:50 2018
New Revision: 327875
URL: https://svnweb.freebsd.org/changeset/base/327875

Log:
  mtx: use fcmpset to cover setting MTX_CONTESTED

Modified:
  head/sys/kern/kern_mutex.c

Modified: head/sys/kern/kern_mutex.c
==
--- head/sys/kern/kern_mutex.c  Fri Jan 12 13:39:02 2018(r327874)
+++ head/sys/kern/kern_mutex.c  Fri Jan 12 13:40:50 2018(r327875)
@@ -578,6 +578,7 @@ __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v)
 
ts = turnstile_trywait(>lock_object);
v = MTX_READ_VALUE(m);
+retry_turnstile:
 
/*
 * Check if the lock has been released while spinning for
@@ -609,10 +610,8 @@ __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v)
 * or the state of the MTX_RECURSED bit changed.
 */
if ((v & MTX_CONTESTED) == 0 &&
-   !atomic_cmpset_ptr(>mtx_lock, v, v | MTX_CONTESTED)) {
-   turnstile_cancel(ts);
-   v = MTX_READ_VALUE(m);
-   continue;
+   !atomic_fcmpset_ptr(>mtx_lock, , v | MTX_CONTESTED)) {
+   goto retry_turnstile;
}
 
/*
___
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: r327874 - head/sys/kern

2018-01-12 Thread Mateusz Guzik
Author: mjg
Date: Fri Jan 12 13:39:02 2018
New Revision: 327874
URL: https://svnweb.freebsd.org/changeset/base/327874

Log:
  vfs: tidy up vdrop
  
  Skip vfs_refcount_release_if_not_last if the interlock is held and just
  go straight to refcount_release.
  
  While here do cosmetic rearrangement of _vhold to better show it contains
  equivalent behaviour.

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cFri Jan 12 12:14:52 2018(r327873)
+++ head/sys/kern/vfs_subr.cFri Jan 12 13:39:02 2018(r327874)
@@ -2840,14 +2840,14 @@ _vhold(struct vnode *vp, bool locked)
else
ASSERT_VI_UNLOCKED(vp, __func__);
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
-   if (!locked && vfs_refcount_acquire_if_not_zero(>v_holdcnt)) {
-   VNASSERT((vp->v_iflag & VI_FREE) == 0, vp,
-   ("_vhold: vnode with holdcnt is free"));
-   return;
-   }
-
-   if (!locked)
+   if (!locked) {
+   if (vfs_refcount_acquire_if_not_zero(>v_holdcnt)) {
+   VNASSERT((vp->v_iflag & VI_FREE) == 0, vp,
+   ("_vhold: vnode with holdcnt is free"));
+   return;
+   }
VI_LOCK(vp);
+   }
if ((vp->v_iflag & VI_FREE) == 0) {
refcount_acquire(>v_holdcnt);
if (!locked)
@@ -2911,14 +2911,11 @@ _vdrop(struct vnode *vp, bool locked)
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
if ((int)vp->v_holdcnt <= 0)
panic("vdrop: holdcnt %d", vp->v_holdcnt);
-   if (vfs_refcount_release_if_not_last(>v_holdcnt)) {
-   if (locked)
-   VI_UNLOCK(vp);
-   return;
-   }
-
-   if (!locked)
+   if (!locked) {
+   if (vfs_refcount_release_if_not_last(>v_holdcnt))
+   return;
VI_LOCK(vp);
+   }
if (refcount_release(>v_holdcnt) == 0) {
VI_UNLOCK(vp);
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: r327873 - head/sys/powerpc/powernv

2018-01-12 Thread Wojciech Macek
Author: wma
Date: Fri Jan 12 12:14:52 2018
New Revision: 327873
URL: https://svnweb.freebsd.org/changeset/base/327873

Log:
  PowerNV: update OPAL driver
  
  Update OPAL driver with:
  - better console support
  - proper AP configuration
  - enhanced IRQ/OFW mapping
  - RTC support
  
  Created by:Nathan Whitehorn 
  Submitted by:  Wojciech Macek 
  Sponsored by:  FreeBSD Foundation

Modified:
  head/sys/powerpc/powernv/opal.h
  head/sys/powerpc/powernv/opal_console.c
  head/sys/powerpc/powernv/opal_dev.c
  head/sys/powerpc/powernv/platform_powernv.c

Modified: head/sys/powerpc/powernv/opal.h
==
--- head/sys/powerpc/powernv/opal.h Fri Jan 12 12:14:14 2018
(r327872)
+++ head/sys/powerpc/powernv/opal.h Fri Jan 12 12:14:52 2018
(r327873)
@@ -40,9 +40,12 @@ int opal_call(uint64_t token, ...);
 
 #define OPAL_CONSOLE_WRITE 1
 #define OPAL_CONSOLE_READ  2
+#define OPAL_RTC_READ  3
+#define OPAL_RTC_WRITE 4
 #defineOPAL_CEC_POWER_DOWN 5
 #defineOPAL_CEC_REBOOT 6
 #defineOPAL_HANDLE_INTERRUPT   9
+#defineOPAL_POLL_EVENTS10
 #defineOPAL_PCI_CONFIG_READ_BYTE   13
 #defineOPAL_PCI_CONFIG_READ_HALF_WORD  14
 #defineOPAL_PCI_CONFIG_READ_WORD   15
@@ -57,10 +60,10 @@ int opal_call(uint64_t token, ...);
 #defineOPAL_PCI_RESET  49
 #defineOPAL_PCI_POLL   62
 #defineOPAL_PCI_SET_PE 31
-#define OPAL_START_CPU 41
 #defineOPAL_GET_MSI_32 39
 #defineOPAL_GET_MSI_64 40
 #defineOPAL_PCI_MSI_EOI63
+#defineOPAL_START_CPU  41
 #defineOPAL_PCI_MAP_PE_DMA_WINDOW_REAL 45
 #defineOPAL_RETURN_CPU 69
 #defineOPAL_REINIT_CPUS70

Modified: head/sys/powerpc/powernv/opal_console.c
==
--- head/sys/powerpc/powernv/opal_console.c Fri Jan 12 12:14:14 2018
(r327872)
+++ head/sys/powerpc/powernv/opal_console.c Fri Jan 12 12:14:52 2018
(r327873)
@@ -133,42 +133,39 @@ static struct {
char tmpbuf[16];
uint64_t size;
struct mtx mtx;
-} escapehatch;
+} opalcons_buffer;
 
 static void
 uart_opal_real_map_outbuffer(uint64_t *bufferp, uint64_t *lenp)
 {
 
-   if (!mtx_initialized())
-   mtx_init(, "uart_opal", NULL, MTX_SPIN | 
MTX_QUIET |
-   MTX_NOWITNESS);
+   if (!mtx_initialized(_buffer.mtx))
+   mtx_init(_buffer.mtx, "uart_opal", NULL,
+   MTX_SPIN | MTX_QUIET | MTX_NOWITNESS);
 
if (!pmap_bootstrapped)
return;
 
-   if (TD_IS_IDLETHREAD(curthread)) {
-   escapehatch.size = *(uint64_t *)(*lenp) =
-   min(sizeof(escapehatch.tmpbuf), *(uint64_t *)(*lenp));
-   mtx_lock_spin();
-   memcpy(escapehatch.tmpbuf, (void *)(*bufferp), *(uint64_t 
*)(*lenp));
-   *bufferp = (uint64_t)escapehatch.tmpbuf;
-   *lenp = (uint64_t)
-   }
+   mtx_lock_spin(_buffer.mtx);
 
-   *bufferp = vtophys(*bufferp);
-   *lenp = vtophys(*lenp);
+   opalcons_buffer.size = *(uint64_t *)(*lenp) =
+   min(sizeof(opalcons_buffer.tmpbuf), *(uint64_t *)(*lenp));
+   memcpy(opalcons_buffer.tmpbuf, (void *)(*bufferp),
+   *(uint64_t *)(*lenp));
+   *bufferp = (uint64_t)opalcons_buffer.tmpbuf;
+   *lenp = (uint64_t)_buffer.size;
 }

 static void
-uart_opal_real_unmap_outbuffer(uint64_t lenp, uint64_t *origlen)
+uart_opal_real_unmap_outbuffer(uint64_t *len)
 {
 
-   if (!pmap_bootstrapped || !TD_IS_IDLETHREAD(curthread))
+   if (!pmap_bootstrapped)
return;
 
-   mtx_assert(, MA_OWNED);
-   *origlen = escapehatch.size;
-   mtx_unlock_spin();
+   mtx_assert(_buffer.mtx, MA_OWNED);
+   *len = opalcons_buffer.size;
+   mtx_unlock_spin(_buffer.mtx);
 }
 
 static int
@@ -187,7 +184,7 @@ uart_opal_probe_node(struct uart_opal_softc *sc)
return (ENXIO);
 
reg = -1;
-   OF_getprop(node, "reg", , sizeof(reg));
+   OF_getencprop(node, "reg", , sizeof(reg));
if (reg == -1)
return (ENXIO);
sc->vtermid = reg;
@@ -389,7 +386,7 @@ uart_opal_put(struct uart_opal_softc *sc, void *buffer
 
uart_opal_real_map_outbuffer(, );
err = opal_call(OPAL_CONSOLE_WRITE, sc->vtermid, olen, obuf);
-   uart_opal_real_unmap_outbuffer(olen, );
+   uart_opal_real_unmap_outbuffer();
} else {
uart_lock(>sc_mtx);
  

svn commit: r327872 - in head/sys/modules: bhnd sdhci_acpi sdhci_pci sgx

2018-01-12 Thread Li-Wen Hsu
Author: lwhsu (ports committer)
Date: Fri Jan 12 12:14:14 2018
New Revision: 327872
URL: https://svnweb.freebsd.org/changeset/base/327872

Log:
  - Fix `make` in sys/modules
  
  Reviewed by:  gonzo, landonf, br
  Differential Revision:https://reviews.freebsd.org/D13856

Modified:
  head/sys/modules/bhnd/Makefile
  head/sys/modules/sdhci_acpi/Makefile
  head/sys/modules/sdhci_pci/Makefile
  head/sys/modules/sgx/Makefile

Modified: head/sys/modules/bhnd/Makefile
==
--- head/sys/modules/bhnd/Makefile  Fri Jan 12 10:54:00 2018
(r327871)
+++ head/sys/modules/bhnd/Makefile  Fri Jan 12 12:14:14 2018
(r327872)
@@ -18,6 +18,7 @@ SRCS+=chipc.c chipc_subr.c
 
 SRCS+= chipc_gpio.c
 SRCS+= gpio_if.h ofw_bus_if.h
+SRCS+= opt_platform.h
 
 SRCS+= bhnd_sprom_chipc.c \
bhnd_pmu_chipc.c

Modified: head/sys/modules/sdhci_acpi/Makefile
==
--- head/sys/modules/sdhci_acpi/MakefileFri Jan 12 10:54:00 2018
(r327871)
+++ head/sys/modules/sdhci_acpi/MakefileFri Jan 12 12:14:14 2018
(r327872)
@@ -4,6 +4,7 @@
 
 KMOD=  sdhci_acpi
 SRCS=  sdhci_acpi.c sdhci.h sdhci_if.h
-SRCS+= acpi_if.h device_if.h bus_if.h opt_acpi.h pci_if.h mmcbr_if.h
+SRCS+= acpi_if.h device_if.h bus_if.h pci_if.h mmcbr_if.h
+SRCS+= opt_acpi.h opt_mmccam.h
 
 .include 

Modified: head/sys/modules/sdhci_pci/Makefile
==
--- head/sys/modules/sdhci_pci/Makefile Fri Jan 12 10:54:00 2018
(r327871)
+++ head/sys/modules/sdhci_pci/Makefile Fri Jan 12 12:14:14 2018
(r327872)
@@ -4,5 +4,6 @@
 
 KMOD=  sdhci_pci
 SRCS=  sdhci_pci.c sdhci.h sdhci_if.h device_if.h bus_if.h pci_if.h mmcbr_if.h
+SRCS+= opt_mmccam.h
 
 .include 

Modified: head/sys/modules/sgx/Makefile
==
--- head/sys/modules/sgx/Makefile   Fri Jan 12 10:54:00 2018
(r327871)
+++ head/sys/modules/sgx/Makefile   Fri Jan 12 12:14:14 2018
(r327872)
@@ -4,6 +4,7 @@
 
 KMOD=  sgx
 SRCS=  sgx.c sgxvar.h assym.s sgx_support.S
+SRCS+= opt_compat.h opt_hwpmc_hooks.h opt_kstack_pages.h
 
 sgx_support.o:  assym.s
${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \
___
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"