Re: svn commit: r360233 - in head: contrib/jemalloc . . . : This partially breaks a 2-socket 32-bit powerpc (old PowerMac G4) based on head -r360311

2020-05-06 Thread Mark Millard via svn-src-head
[This explores process crashes that happen during system
shutdown, in a context not having MALLOC_PRODUCTION= .
So assert failures are reported as the stopping points.]

It looks like shutdown -p now, shutdown -r now, and the
like can lead some processes to assert during their exit
attempt, including a sshd failure (that I've not seen
before), rpcbind, and nfsd. I show information about the
observed asserts for those below.


sshd hit an assert, failing slab == extent_slab_get(extent) :

(gdb) bt 
#0  thr_kill () at thr_kill.S:4
#1  0x50927170 in __raise (s=6) at /usr/src/lib/libc/gen/raise.c:52
#2  0x50886cc0 in abort () at /usr/src/lib/libc/stdlib/abort.c:67
#3  0x508834b0 in arena_dalloc (tsdn=, ptr=, 
tcache=, alloc_ctx=, slow_path=)
at /usr/src/contrib/jemalloc/include/jemalloc/internal/arena_inlines_b.h:315
#4  idalloctm (tsdn=0x500dd040, ptr=0x5008a180, tcache=0x500dd160, 
alloc_ctx=, is_internal=, slow_path=)
at 
/usr/src/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal_inlines_c.h:118
#5  0x5087b0a4 in ifree (tsd=0x500dd040, ptr=0x5008a180, tcache=0x500dd160, 
slow_path=) at jemalloc_jemalloc.c:2590
#6  0x5087acac in __je_free_default (ptr=0x5008a180) at jemalloc_jemalloc.c:2784
#7  0x5087b294 in __free (ptr=0x5008a180) at jemalloc_jemalloc.c:2852
#8  0x10029464 in server_accept_loop (config_s=, 
sock_in=, sock_out=, newsock=) at 
/usr/src/crypto/openssh/sshd.c:1185
#9  main (ac=, av=0xde3c) at 
/usr/src/crypto/openssh/sshd.c:2009

. . .
(gdb) up
#2  0x50886cc0 in abort () at /usr/src/lib/libc/stdlib/abort.c:67
67  (void)raise(SIGABRT);
(gdb) up
#3  0x508834b0 in arena_dalloc (tsdn=, ptr=, 
tcache=, alloc_ctx=, slow_path=)
at /usr/src/contrib/jemalloc/include/jemalloc/internal/arena_inlines_b.h:315
315 assert(slab == extent_slab_get(extent));

(gdb) list
310 rtree_ctx = tsd_rtree_ctx(tsdn_tsd(tsdn));
311 extent_t *extent = rtree_extent_read(tsdn, 
_rtree,
312 rtree_ctx, (uintptr_t)ptr, true);
313 assert(szind == extent_szind_get(extent));
314 assert(szind < SC_NSIZES);
315 assert(slab == extent_slab_get(extent));
316 }
317 
318 if (likely(slab)) {
319 /* Small allocation. */

More fully:

285 JEMALLOC_ALWAYS_INLINE void
286 arena_dalloc(tsdn_t *tsdn, void *ptr, tcache_t *tcache,
287 alloc_ctx_t *alloc_ctx, bool slow_path) {
288 assert(!tsdn_null(tsdn) || tcache == NULL);
289 assert(ptr != NULL);
290 
291 if (unlikely(tcache == NULL)) {
292 arena_dalloc_no_tcache(tsdn, ptr);
293 return;
294 }
295 
296 szind_t szind;
297 bool slab;
298 rtree_ctx_t *rtree_ctx;
299 if (alloc_ctx != NULL) {
300 szind = alloc_ctx->szind;
301 slab = alloc_ctx->slab;
302 assert(szind != SC_NSIZES);
303 } else {
304 rtree_ctx = tsd_rtree_ctx(tsdn_tsd(tsdn));
305 rtree_szind_slab_read(tsdn, _rtree, rtree_ctx,
306 (uintptr_t)ptr, true, , );
307 }
308 
309 if (config_debug) {
310 rtree_ctx = tsd_rtree_ctx(tsdn_tsd(tsdn));
311 extent_t *extent = rtree_extent_read(tsdn, 
_rtree,
312 rtree_ctx, (uintptr_t)ptr, true);
313 assert(szind == extent_szind_get(extent));
314 assert(szind < SC_NSIZES);
315 assert(slab == extent_slab_get(extent));
316 }
317 
318 if (likely(slab)) {
319 /* Small allocation. */
320 tcache_dalloc_small(tsdn_tsd(tsdn), tcache, ptr, szind,
321 slow_path);
322 } else {
323 arena_dalloc_large(tsdn, ptr, tcache, szind, slow_path);
324 }
325 }


rpcbind hit an assert, failing ret == sz_size2index_compute(size) :

(gdb) bt
#0  thr_kill () at thr_kill.S:4
#1  0x502f2170 in __raise (s=6) at /usr/src/lib/libc/gen/raise.c:52
#2  0x50251d04 in abort () at /usr/src/lib/libc/stdlib/abort.c:79
#3  0x5024f260 in sz_size2index_lookup (size=) at 
/usr/src/contrib/jemalloc/include/jemalloc/internal/sz.h:159
#4  sz_size2index (size=) at 
/usr/src/contrib/jemalloc/include/jemalloc/internal/sz.h:166
#5  imalloc_body (sopts=0xb360, dopts=0xb340, tsd=0x5009a018) at 
jemalloc_jemalloc.c:2066
#6  0x50244874 in imalloc (sopts=0xb360, dopts=0xb340) at 
/usr/src/contrib/jemalloc/include/jemalloc/internal/tsd.h:331
#7  0x50244fe8 in __calloc (num=1, size=96) at jemalloc_jemalloc.c:2498
#8  0x50265690 in svc_xprt_alloc () at /usr/src/lib/libc/rpc/svc.c:541
#9  0x502635f4 in makefd_xprt (fd=14, sendsize=9000, 

svn commit: r360723 - in head/sys/dev/virtio: balloon console random scsi

2020-05-06 Thread Jessica Clarke
Author: jrtc27
Date: Wed May  6 23:31:30 2020
New Revision: 360723
URL: https://svnweb.freebsd.org/changeset/base/360723

Log:
  virtio: Support MMIO bus for all devices
  
  The bus is independent of the device, so all devices can be attached to
  either a PCI bus or an MMIO bus. For example, QEMU's virtio-rng-device
  gives the MMIO variant of virtio-rng-pci, and is now detected.
  
  Reviewed by:  andrew, br, brooks (mentor)
  Approved by:  andrew, br, brooks (mentor)
  Differential Revision:https://reviews.freebsd.org/D24730

Modified:
  head/sys/dev/virtio/balloon/virtio_balloon.c
  head/sys/dev/virtio/console/virtio_console.c
  head/sys/dev/virtio/random/virtio_random.c
  head/sys/dev/virtio/scsi/virtio_scsi.c

Modified: head/sys/dev/virtio/balloon/virtio_balloon.c
==
--- head/sys/dev/virtio/balloon/virtio_balloon.cWed May  6 23:28:51 
2020(r360722)
+++ head/sys/dev/virtio/balloon/virtio_balloon.cWed May  6 23:31:30 
2020(r360723)
@@ -153,6 +153,8 @@ static driver_t vtballoon_driver = {
 };
 static devclass_t vtballoon_devclass;
 
+DRIVER_MODULE(virtio_balloon, virtio_mmio, vtballoon_driver,
+vtballoon_devclass, 0, 0);
 DRIVER_MODULE(virtio_balloon, virtio_pci, vtballoon_driver,
 vtballoon_devclass, 0, 0);
 MODULE_VERSION(virtio_balloon, 1);
@@ -160,6 +162,7 @@ MODULE_DEPEND(virtio_balloon, virtio, 1, 1, 1);
 
 VIRTIO_SIMPLE_PNPTABLE(virtio_balloon, VIRTIO_ID_BALLOON,
 "VirtIO Balloon Adapter");
+VIRTIO_SIMPLE_PNPINFO(virtio_mmio, virtio_balloon);
 VIRTIO_SIMPLE_PNPINFO(virtio_pci, virtio_balloon);
 
 static int

Modified: head/sys/dev/virtio/console/virtio_console.c
==
--- head/sys/dev/virtio/console/virtio_console.cWed May  6 23:28:51 
2020(r360722)
+++ head/sys/dev/virtio/console/virtio_console.cWed May  6 23:31:30 
2020(r360723)
@@ -256,6 +256,8 @@ static driver_t vtcon_driver = {
 };
 static devclass_t vtcon_devclass;
 
+DRIVER_MODULE(virtio_console, virtio_mmio, vtcon_driver, vtcon_devclass,
+vtcon_modevent, 0);
 DRIVER_MODULE(virtio_console, virtio_pci, vtcon_driver, vtcon_devclass,
 vtcon_modevent, 0);
 MODULE_VERSION(virtio_console, 1);
@@ -263,6 +265,7 @@ MODULE_DEPEND(virtio_console, virtio, 1, 1, 1);
 
 VIRTIO_SIMPLE_PNPTABLE(virtio_console, VIRTIO_ID_CONSOLE,
 "VirtIO Console Adapter");
+VIRTIO_SIMPLE_PNPINFO(virtio_mmio, virtio_console);
 VIRTIO_SIMPLE_PNPINFO(virtio_pci, virtio_console);
 
 static int

Modified: head/sys/dev/virtio/random/virtio_random.c
==
--- head/sys/dev/virtio/random/virtio_random.c  Wed May  6 23:28:51 2020
(r360722)
+++ head/sys/dev/virtio/random/virtio_random.c  Wed May  6 23:31:30 2020
(r360723)
@@ -96,6 +96,8 @@ static driver_t vtrnd_driver = {
 };
 static devclass_t vtrnd_devclass;
 
+DRIVER_MODULE(virtio_random, virtio_mmio, vtrnd_driver, vtrnd_devclass,
+vtrnd_modevent, 0);
 DRIVER_MODULE(virtio_random, virtio_pci, vtrnd_driver, vtrnd_devclass,
 vtrnd_modevent, 0);
 MODULE_VERSION(virtio_random, 1);
@@ -104,6 +106,7 @@ MODULE_DEPEND(virtio_random, random_device, 1, 1, 1);
 
 VIRTIO_SIMPLE_PNPTABLE(virtio_random, VIRTIO_ID_ENTROPY,
 "VirtIO Entropy Adapter");
+VIRTIO_SIMPLE_PNPINFO(virtio_mmio, virtio_random);
 VIRTIO_SIMPLE_PNPINFO(virtio_pci, virtio_random);
 
 static int

Modified: head/sys/dev/virtio/scsi/virtio_scsi.c
==
--- head/sys/dev/virtio/scsi/virtio_scsi.c  Wed May  6 23:28:51 2020
(r360722)
+++ head/sys/dev/virtio/scsi/virtio_scsi.c  Wed May  6 23:31:30 2020
(r360723)
@@ -228,6 +228,8 @@ static driver_t vtscsi_driver = {
 };
 static devclass_t vtscsi_devclass;
 
+DRIVER_MODULE(virtio_scsi, virtio_mmio, vtscsi_driver, vtscsi_devclass,
+vtscsi_modevent, 0);
 DRIVER_MODULE(virtio_scsi, virtio_pci, vtscsi_driver, vtscsi_devclass,
 vtscsi_modevent, 0);
 MODULE_VERSION(virtio_scsi, 1);
@@ -235,6 +237,7 @@ MODULE_DEPEND(virtio_scsi, virtio, 1, 1, 1);
 MODULE_DEPEND(virtio_scsi, cam, 1, 1, 1);
 
 VIRTIO_SIMPLE_PNPTABLE(virtio_scsi, VIRTIO_ID_SCSI, "VirtIO SCSI Adapter");
+VIRTIO_SIMPLE_PNPINFO(virtio_mmio, virtio_scsi);
 VIRTIO_SIMPLE_PNPINFO(virtio_pci, virtio_scsi);
 
 static int
___
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: r360722 - head/sys/dev/virtio/mmio

2020-05-06 Thread Jessica Clarke
Author: jrtc27
Date: Wed May  6 23:28:51 2020
New Revision: 360722
URL: https://svnweb.freebsd.org/changeset/base/360722

Log:
  virtio_mmio: Support non-transitional version 2 devices
  
  The non-legacy virtio MMIO specification drops the use of PFNs and
  replaces them with physical addresses. Whilst many implementations are
  so-called transitional devices, also implementing the legacy
  specification, TinyEMU[1] does not. Device-specific configuration
  registers have also changed to being little-endian, and must be accessed
  using a single aligned access for registers up to 32 bits, and two
  32-bit aligned accesses for 64-bit registers.
  
  [1] https://bellard.org/tinyemu/
  
  Reviewed by:  br, brooks (mentor)
  Approved by:  br, brooks (mentor)
  Differential Revision:https://reviews.freebsd.org/D24681

Modified:
  head/sys/dev/virtio/mmio/virtio_mmio.c
  head/sys/dev/virtio/mmio/virtio_mmio.h

Modified: head/sys/dev/virtio/mmio/virtio_mmio.c
==
--- head/sys/dev/virtio/mmio/virtio_mmio.c  Wed May  6 23:23:22 2020
(r360721)
+++ head/sys/dev/virtio/mmio/virtio_mmio.c  Wed May  6 23:28:51 2020
(r360722)
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -76,6 +77,8 @@ static intvtmmio_read_ivar(device_t, device_t, int, u
 static int vtmmio_write_ivar(device_t, device_t, int, uintptr_t);
 static uint64_tvtmmio_negotiate_features(device_t, uint64_t);
 static int vtmmio_with_feature(device_t, uint64_t);
+static voidvtmmio_set_virtqueue(struct vtmmio_softc *sc,
+   struct virtqueue *vq, uint32_t size);
 static int vtmmio_alloc_virtqueues(device_t, int, int,
struct vq_alloc_info *);
 static int vtmmio_setup_intr(device_t, enum intr_type);
@@ -223,6 +226,16 @@ vtmmio_attach(device_t dev)
return (ENXIO);
}
 
+   sc->vtmmio_version = vtmmio_read_config_4(sc, VIRTIO_MMIO_VERSION);
+   if (sc->vtmmio_version < 1 || sc->vtmmio_version > 2) {
+   device_printf(dev, "Unsupported version: %x\n",
+   sc->vtmmio_version);
+   bus_release_resource(dev, SYS_RES_MEMORY, 0,
+   sc->res[0]);
+   sc->res[0] = NULL;
+   return (ENXIO);
+   }
+
vtmmio_reset(sc);
 
/* Tell the host we've noticed this device. */
@@ -404,6 +417,46 @@ vtmmio_with_feature(device_t dev, uint64_t feature)
return ((sc->vtmmio_features & feature) != 0);
 }
 
+static void
+vtmmio_set_virtqueue(struct vtmmio_softc *sc, struct virtqueue *vq,
+uint32_t size)
+{
+   vm_paddr_t paddr;
+
+   vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_NUM, size);
+#if 0
+   device_printf(dev, "virtqueue paddr 0x%08lx\n",
+   (uint64_t)paddr);
+#endif
+   if (sc->vtmmio_version == 1) {
+   vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_ALIGN,
+   VIRTIO_MMIO_VRING_ALIGN);
+   paddr = virtqueue_paddr(vq);
+   vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_PFN,
+   paddr >> PAGE_SHIFT);
+   } else {
+   paddr = virtqueue_desc_paddr(vq);
+   vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_DESC_LOW,
+   paddr);
+   vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_DESC_HIGH,
+   paddr >> 32);
+
+   paddr = virtqueue_avail_paddr(vq);
+   vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_AVAIL_LOW,
+   paddr);
+   vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_AVAIL_HIGH,
+   paddr >> 32);
+
+   paddr = virtqueue_used_paddr(vq);
+   vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_USED_LOW,
+   paddr);
+   vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_USED_HIGH,
+   paddr >> 32);
+
+   vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_READY, 1);
+   }
+}
+
 static int
 vtmmio_alloc_virtqueues(device_t dev, int flags, int nvqs,
 struct vq_alloc_info *vq_info)
@@ -448,15 +501,7 @@ vtmmio_alloc_virtqueues(device_t dev, int flags, int n
break;
}
 
-   vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_NUM, size);
-   vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_ALIGN,
-   VIRTIO_MMIO_VRING_ALIGN);
-#if 0
-   device_printf(dev, "virtqueue paddr 0x%08lx\n",
-   (uint64_t)virtqueue_paddr(vq));
-#endif
-   vtmmio_write_config_4(sc, VIRTIO_MMIO_QUEUE_PFN,
-   virtqueue_paddr(vq) >> PAGE_SHIFT);
+   vtmmio_set_virtqueue(sc, vq, size);
 
vqx->vtv_vq = *info->vqai_vq = vq;
vqx->vtv_no_intr = info->vqai_intr == NULL;
@@ -568,10 +613,54 @@ vtmmio_read_dev_config(device_t 

svn commit: r360710 - in head: share/man/man4 sys/dev/ubsec

2020-05-06 Thread John Baldwin
Author: jhb
Date: Wed May  6 22:15:09 2020
New Revision: 360710
URL: https://svnweb.freebsd.org/changeset/base/360710

Log:
  Deprecate ubsec(4) for FreeBSD 13.0.
  
  With the removal of in-tree consumers of DES, Triple DES, and
  MD5-HMAC, the only algorithm this driver still supports is SHA1-HMAC.
  This is not very useful as a standalone algorithm (IPsec AH-only with
  SHA1 would be the only user).
  
  This driver has also not been kept up to date with the original driver
  in OpenBSD which supports a few more cards and AES-CBC on newer cards.
  The newest card currently supported by this driver was released in
  2005.
  
  Reviewed by:  cem
  MFC after:1 week
  Relnotes: yes
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D24691

Modified:
  head/share/man/man4/ubsec.4
  head/sys/dev/ubsec/ubsec.c

Modified: head/share/man/man4/ubsec.4
==
--- head/share/man/man4/ubsec.4 Wed May  6 22:13:08 2020(r360709)
+++ head/share/man/man4/ubsec.4 Wed May  6 22:15:09 2020(r360710)
@@ -48,6 +48,15 @@ module at boot time, place the following line in
 .Bd -literal -offset indent
 ubsec_load="YES"
 .Ed
+.Sh DEPRECATION NOTICE
+The
+.Nm
+driver is not present in
+.Fx 13.0
+and later.
+The majority of crypto algorithms supported by this driver are no longer
+used by the kernel in
+.Fx 13.0 .
 .Sh DESCRIPTION
 The
 .Nm

Modified: head/sys/dev/ubsec/ubsec.c
==
--- head/sys/dev/ubsec/ubsec.c  Wed May  6 22:13:08 2020(r360709)
+++ head/sys/dev/ubsec/ubsec.c  Wed May  6 22:15:09 2020(r360710)
@@ -472,6 +472,7 @@ skip_rng:
crypto_kregister(sc->sc_cid, CRK_MOD_EXP_CRT, 0);
 #endif
}
+   gone_in_dev(dev, 13, "Does not support modern crypto algorithms");
return (0);
 bad4:
while (!SIMPLEQ_EMPTY(>sc_freequeue)) {
___
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: r360702 - in head/contrib/llvm-project/clang: include/clang/Driver lib/CodeGen lib/Driver/ToolChains lib/Frontend

2020-05-06 Thread Dimitry Andric
Author: dim
Date: Wed May  6 19:10:39 2020
New Revision: 360702
URL: https://svnweb.freebsd.org/changeset/base/360702

Log:
  Merge commit 4ca2cad94 from llvm git (by Justin Hibbits):
  
[PowerPC] Add clang -msvr4-struct-return for 32-bit ELF
  
Summary:
  
Change the default ABI to be compatible with GCC. For 32-bit ELF
targets other than Linux, Clang now returns small structs in
registers r3/r4. This affects FreeBSD, NetBSD, OpenBSD. There is no
change for 32-bit Linux, where Clang continues to return all structs
in memory.
  
Add clang options -maix-struct-return (to return structs in memory)
and -msvr4-struct-return (to return structs in registers) to be
compatible with gcc. These options are only for PPC32; reject them on
PPC64 and other targets. The options are like -fpcc-struct-return and
-freg-struct-return for X86_32, and use similar code.
  
To actually return a struct in registers, coerce it to an integer of
the same size. LLVM may optimize the code to remove unnecessary
accesses to memory, and will return i32 in r3 or i64 in r3:r4.
  
Fixes PR#40736
  
Patch by George Koehler!
  
Reviewed By: jhibbits, nemanjai
Differential Revision: https://reviews.llvm.org/D73290
  
  Requested by: jhibbits
  MFC after:3 days

Modified:
  head/contrib/llvm-project/clang/include/clang/Driver/Options.td
  head/contrib/llvm-project/clang/lib/CodeGen/TargetInfo.cpp
  head/contrib/llvm-project/clang/lib/Driver/ToolChains/Clang.cpp
  head/contrib/llvm-project/clang/lib/Frontend/CompilerInvocation.cpp

Modified: head/contrib/llvm-project/clang/include/clang/Driver/Options.td
==
--- head/contrib/llvm-project/clang/include/clang/Driver/Options.td Wed May 
 6 18:43:27 2020(r360701)
+++ head/contrib/llvm-project/clang/include/clang/Driver/Options.td Wed May 
 6 19:10:39 2020(r360702)
@@ -2439,6 +2439,12 @@ def mlongcall: Flag<["-"], "mlongcall">,
 Group;
 def mno_longcall : Flag<["-"], "mno-longcall">,
 Group;
+def maix_struct_return : Flag<["-"], "maix-struct-return">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Return all structs in memory (PPC32 only)">;
+def msvr4_struct_return : Flag<["-"], "msvr4-struct-return">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Return small structs in registers (PPC32 only)">;
 
 def mvx : Flag<["-"], "mvx">, Group;
 def mno_vx : Flag<["-"], "mno-vx">, Group;

Modified: head/contrib/llvm-project/clang/lib/CodeGen/TargetInfo.cpp
==
--- head/contrib/llvm-project/clang/lib/CodeGen/TargetInfo.cpp  Wed May  6 
18:43:27 2020(r360701)
+++ head/contrib/llvm-project/clang/lib/CodeGen/TargetInfo.cpp  Wed May  6 
19:10:39 2020(r360702)
@@ -4123,22 +4123,39 @@ namespace {
 /// PPC32_SVR4_ABIInfo - The 32-bit PowerPC ELF (SVR4) ABI information.
 class PPC32_SVR4_ABIInfo : public DefaultABIInfo {
   bool IsSoftFloatABI;
+  bool IsRetSmallStructInRegABI;
 
   CharUnits getParamTypeAlignment(QualType Ty) const;
 
 public:
-  PPC32_SVR4_ABIInfo(CodeGen::CodeGenTypes , bool SoftFloatABI)
-  : DefaultABIInfo(CGT), IsSoftFloatABI(SoftFloatABI) {}
+  PPC32_SVR4_ABIInfo(CodeGen::CodeGenTypes , bool SoftFloatABI,
+ bool RetSmallStructInRegABI)
+  : DefaultABIInfo(CGT), IsSoftFloatABI(SoftFloatABI),
+IsRetSmallStructInRegABI(RetSmallStructInRegABI) {}
 
+  ABIArgInfo classifyReturnType(QualType RetTy) const;
+
+  void computeInfo(CGFunctionInfo ) const override {
+if (!getCXXABI().classifyReturnType(FI))
+  FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
+for (auto  : FI.arguments())
+  I.info = classifyArgumentType(I.type);
+  }
+
   Address EmitVAArg(CodeGenFunction , Address VAListAddr,
 QualType Ty) const override;
 };
 
 class PPC32TargetCodeGenInfo : public TargetCodeGenInfo {
 public:
-  PPC32TargetCodeGenInfo(CodeGenTypes , bool SoftFloatABI)
-  : TargetCodeGenInfo(new PPC32_SVR4_ABIInfo(CGT, SoftFloatABI)) {}
+  PPC32TargetCodeGenInfo(CodeGenTypes , bool SoftFloatABI,
+ bool RetSmallStructInRegABI)
+  : TargetCodeGenInfo(new PPC32_SVR4_ABIInfo(CGT, SoftFloatABI,
+ RetSmallStructInRegABI)) {}
 
+  static bool isStructReturnInRegABI(const llvm::Triple ,
+ const CodeGenOptions );
+
   int getDwarfEHStackPointer(CodeGen::CodeGenModule ) const override {
 // This is recovered from gcc output.
 return 1; // r1 is the dedicated stack pointer
@@ -4173,6 +4190,34 @@ CharUnits PPC32_SVR4_ABIInfo::getParamTypeAlignment(Qu
   return CharUnits::fromQuantity(4);
 }
 
+ABIArgInfo PPC32_SVR4_ABIInfo::classifyReturnType(QualType RetTy) const {
+  uint64_t Size;
+
+  // -msvr4-struct-return puts small aggregates in GPR3 and GPR4.
+  if 

svn commit: r360701 - head/share/man/man5

2020-05-06 Thread Ed Maste
Author: emaste
Date: Wed May  6 18:43:27 2020
New Revision: 360701
URL: https://svnweb.freebsd.org/changeset/base/360701

Log:
  src.conf.5: regen after objdump removal

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

Modified: head/share/man/man5/src.conf.5
==
--- head/share/man/man5/src.conf.5  Wed May  6 18:40:52 2020
(r360700)
+++ head/share/man/man5/src.conf.5  Wed May  6 18:43:27 2020
(r360701)
@@ -1,6 +1,6 @@
 .\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman.
 .\" $FreeBSD$
-.Dd May 4, 2020
+.Dd May 6, 2020
 .Dt SRC.CONF 5
 .Os
 .Sh NAME
@@ -184,23 +184,19 @@ flag set to indicate that the run-time loader should p
 processing at process startup rather than on demand.
 .It Va WITHOUT_BINUTILS
 Do not build or install GNU
-.Xr as 1 and
-.Xr objdump 1
+.Xr as 1
 as part
 of the normal system build.
 .Pp
 This is a default setting on
-arm64/aarch64, riscv/riscv64 and riscv/riscv64sf.
+arm/armv6, arm/armv7, arm64/aarch64, mips/mips, mips/mips64, powerpc/powerpc, 
powerpc/powerpc64, riscv/riscv64 and riscv/riscv64sf.
 .It Va WITH_BINUTILS
 Build and install GNU
 .Xr as 1
-on i386 and amd64,
-and
-.Xr objdump 1
 as part of the normal system build.
 .Pp
 This is a default setting on
-amd64/amd64, arm/armv6, arm/armv7, i386/i386, mips/mips, mips/mips64, 
powerpc/powerpc and powerpc/powerpc64.
+amd64/amd64 and i386/i386.
 .It Va WITHOUT_BINUTILS_BOOTSTRAP
 Do not build GNU binutils
 as part of the bootstrap process.
___
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: r360700 - head/share/mk

2020-05-06 Thread Ed Maste
Author: emaste
Date: Wed May  6 18:40:52 2020
New Revision: 360700
URL: https://svnweb.freebsd.org/changeset/base/360700

Log:
  src.opts.mk: with BINUTILS limited to as it is used on i386 and amd64 only

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

Modified: head/share/mk/src.opts.mk
==
--- head/share/mk/src.opts.mk   Wed May  6 18:39:55 2020(r360699)
+++ head/share/mk/src.opts.mk   Wed May  6 18:40:52 2020(r360700)
@@ -62,7 +62,6 @@ __DEFAULT_YES_OPTIONS = \
 AUTHPF \
 AUTOFS \
 BHYVE \
-BINUTILS \
 BLACKLIST \
 BLUETOOTH \
 BOOT \
@@ -292,9 +291,9 @@ __DEFAULT_NO_OPTIONS+=LLVM_TARGET_BPF
 BROKEN_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP GDB
 .endif
 .if ${__T} == "amd64" || ${__T} == "i386"
-__DEFAULT_YES_OPTIONS+=BINUTILS_BOOTSTRAP
+__DEFAULT_YES_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP
 .else
-__DEFAULT_NO_OPTIONS+=BINUTILS_BOOTSTRAP
+__DEFAULT_NO_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP
 .endif
 .if ${__T:Mriscv*} != ""
 BROKEN_OPTIONS+=OFED
___
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: r360699 - head/tools/build/options

2020-05-06 Thread Ed Maste
Author: emaste
Date: Wed May  6 18:39:55 2020
New Revision: 360699
URL: https://svnweb.freebsd.org/changeset/base/360699

Log:
  update WITH_/WITHOUT_BINUTILS descriptions for objdump removal

Modified:
  head/tools/build/options/WITHOUT_BINUTILS
  head/tools/build/options/WITH_BINUTILS

Modified: head/tools/build/options/WITHOUT_BINUTILS
==
--- head/tools/build/options/WITHOUT_BINUTILS   Wed May  6 18:38:40 2020
(r360698)
+++ head/tools/build/options/WITHOUT_BINUTILS   Wed May  6 18:39:55 2020
(r360699)
@@ -1,6 +1,5 @@
 .\" $FreeBSD$
 Do not build or install GNU
-.Xr as 1 and
-.Xr objdump 1
+.Xr as 1
 as part
 of the normal system build.

Modified: head/tools/build/options/WITH_BINUTILS
==
--- head/tools/build/options/WITH_BINUTILS  Wed May  6 18:38:40 2020
(r360698)
+++ head/tools/build/options/WITH_BINUTILS  Wed May  6 18:39:55 2020
(r360699)
@@ -1,7 +1,4 @@
 .\" $FreeBSD$
 Build and install GNU
 .Xr as 1
-on i386 and amd64,
-and
-.Xr objdump 1
 as part of the normal system build.
___
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: r360698 - in head: . gnu/usr.bin/binutils

2020-05-06 Thread Ed Maste
Author: emaste
Date: Wed May  6 18:38:40 2020
New Revision: 360698
URL: https://svnweb.freebsd.org/changeset/base/360698

Log:
  binutils: disconnect objdump from the build
  
  The in-tree binutils is old and will not be updated.  It does not support
  all archs supported by FreeBSD, and for the archs it does support not all
  CPU features are supported.
  
  Other tools have migrated to copyfree alternatives.  Although llvm-objdump
  is nearly a drop-in replacement for GNU objdump it is missing a few options
  and has some differences in output format.  For now just remove GNU objdump;
  ports and developers can use a contemporary, maintained version from ports
  or packages.  We can revisit installing llvm-objdump as objdump in the
  future.
  
  PR:   212319 [exp-run]
  Relnotes: Yes
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D7338

Modified:
  head/ObsoleteFiles.inc
  head/gnu/usr.bin/binutils/Makefile

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Wed May  6 18:13:00 2020(r360697)
+++ head/ObsoleteFiles.inc  Wed May  6 18:38:40 2020(r360698)
@@ -36,6 +36,10 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20200506: GNU objdump 2.17.50 retired
+OLD_FILES+=usr/bin/objdump
+OLD_FILES+=usr/share/man/man1/objdump.1.gz
+
 # 20200418: Make libauditd private
 OLD_FILES+=usr/lib/libauditd.a
 OLD_FILES+=usr/lib/libauditd.so

Modified: head/gnu/usr.bin/binutils/Makefile
==
--- head/gnu/usr.bin/binutils/Makefile  Wed May  6 18:13:00 2020
(r360697)
+++ head/gnu/usr.bin/binutils/Makefile  Wed May  6 18:38:40 2020
(r360698)
@@ -7,8 +7,6 @@ SUBDIR= libiberty \
libopcodes
 
 SUBDIR.${MK_BINUTILS}+=doc
-SUBDIR.${MK_BINUTILS}+=libbinutils
-SUBDIR.${MK_BINUTILS}+=objdump
 
 # GNU as is used on x86 only, for a few files that cannot be assembled by
 # Clang IAS. Other archs either use Clang IAS for every assembly file, or
@@ -17,9 +15,7 @@ SUBDIR.${MK_BINUTILS}+=   objdump
 SUBDIR.${MK_BINUTILS}+=as
 .endif
 
-SUBDIR_DEPEND_libbinutils=libbfd   # for bfdver.h
 SUBDIR_DEPEND_as=libbfd libiberty libopcodes
-SUBDIR_DEPEND_objdump=libbfd libiberty libbinutils libopcodes
 
 .if !make(install)
 SUBDIR_PARALLEL=
___
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: r360697 - head/contrib/llvm-project/llvm/lib/Target/ARM/MCTargetDesc

2020-05-06 Thread Dimitry Andric
Author: dim
Date: Wed May  6 18:13:00 2020
New Revision: 360697
URL: https://svnweb.freebsd.org/changeset/base/360697

Log:
  In r358396 I merged llvm upstream commit 2e24219d3, which fixed "error:
  unsupported relocation on symbol" when assembling arm 'adr' pseudo
  instructions. However, the upstream commit did not take big-endian arm
  into account.
  
  Applying the same changes to the big-endian handling is straightforward,
  thanks to Andrew Turner and Peter Smith for the hint. This will also be
  submitted upstream.
  
  MFC after:immediately, since this fix is meant for stable/11

Modified:
  head/contrib/llvm-project/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp

Modified: 
head/contrib/llvm-project/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
==
--- 
head/contrib/llvm-project/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
Wed May  6 17:44:17 2020(r360696)
+++ 
head/contrib/llvm-project/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
Wed May  6 18:13:00 2020(r360697)
@@ -116,26 +116,22 @@ const MCFixupKindInfo ::getFixupKindInfo
   // ARMFixupKinds.h.
   //
   // Name  Offset (bits) Size (bits) Flags
-  {"fixup_arm_ldst_pcrel_12", 0, 32, MCFixupKindInfo::FKF_IsPCRel},
+  {"fixup_arm_ldst_pcrel_12", 0, 32, IsPCRelConstant},
   {"fixup_t2_ldst_pcrel_12", 0, 32,
-   MCFixupKindInfo::FKF_IsPCRel |
-   MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
-  {"fixup_arm_pcrel_10_unscaled", 0, 32, MCFixupKindInfo::FKF_IsPCRel},
-  {"fixup_arm_pcrel_10", 0, 32, MCFixupKindInfo::FKF_IsPCRel},
+   IsPCRelConstant | MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
+  {"fixup_arm_pcrel_10_unscaled", 0, 32, IsPCRelConstant},
+  {"fixup_arm_pcrel_10", 0, 32, IsPCRelConstant},
   {"fixup_t2_pcrel_10", 0, 32,
MCFixupKindInfo::FKF_IsPCRel |
MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
   {"fixup_arm_pcrel_9", 0, 32, MCFixupKindInfo::FKF_IsPCRel},
   {"fixup_t2_pcrel_9", 0, 32,
-   MCFixupKindInfo::FKF_IsPCRel |
-   MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
+   IsPCRelConstant | MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
   {"fixup_thumb_adr_pcrel_10", 8, 8,
-   MCFixupKindInfo::FKF_IsPCRel |
-   MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
-  {"fixup_arm_adr_pcrel_12", 0, 32, MCFixupKindInfo::FKF_IsPCRel},
+   IsPCRelConstant | MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
+  {"fixup_arm_adr_pcrel_12", 0, 32, IsPCRelConstant},
   {"fixup_t2_adr_pcrel_12", 0, 32,
-   MCFixupKindInfo::FKF_IsPCRel |
-   MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
+   IsPCRelConstant | MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
   {"fixup_arm_condbranch", 8, 24, MCFixupKindInfo::FKF_IsPCRel},
   {"fixup_arm_uncondbranch", 8, 24, MCFixupKindInfo::FKF_IsPCRel},
   {"fixup_t2_condbranch", 0, 32, MCFixupKindInfo::FKF_IsPCRel},
___
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: r360692 - head/sys/dev/usb

2020-05-06 Thread Andriy Gapon
Author: avg
Date: Wed May  6 15:24:31 2020
New Revision: 360692
URL: https://svnweb.freebsd.org/changeset/base/360692

Log:
  usbhid: add several missing usages from Digitizer page
  
  This is applicable to HID in general, not just USB HID.
  
  Inspired by:  wulf
  MFC after:1 week

Modified:
  head/sys/dev/usb/usbhid.h

Modified: head/sys/dev/usb/usbhid.h
==
--- head/sys/dev/usb/usbhid.h   Wed May  6 15:10:05 2020(r360691)
+++ head/sys/dev/usb/usbhid.h   Wed May  6 15:24:31 2020(r360692)
@@ -174,7 +174,10 @@ struct usb_hid_descriptor {
 #defineHUD_CONTACTCOUNT0x0054
 #defineHUD_CONTACT_MAX 0x0055
 #defineHUD_SCAN_TIME   0x0056
+#defineHUD_SURFACE_SWITCH  0x0057
+#defineHUD_BUTTONS_SWITCH  0x0058
 #defineHUD_BUTTON_TYPE 0x0059
+#defineHUD_LATENCY_MODE0x0060
 
 /* Usages, Consumer */
 #defineHUC_AC_PAN  0x0238
___
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: r360691 - head/sys/arm/arm

2020-05-06 Thread Mark Johnston
Author: markj
Date: Wed May  6 15:10:05 2020
New Revision: 360691
URL: https://svnweb.freebsd.org/changeset/base/360691

Log:
  arm: Don't enable interrupts in init_secondary().
  
  This has the same reasoning as described in r357048.
  
  Remove a stray declaration while here.
  
  Reported and tested by:   trasz
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm/arm/mp_machdep.c

Modified: head/sys/arm/arm/mp_machdep.c
==
--- head/sys/arm/arm/mp_machdep.c   Wed May  6 15:01:06 2020
(r360690)
+++ head/sys/arm/arm/mp_machdep.c   Wed May  6 15:10:05 2020
(r360691)
@@ -138,7 +138,6 @@ cpu_mp_announce(void)
 
 }
 
-extern vm_paddr_t pmap_pa;
 void
 init_secondary(int cpu)
 {
@@ -202,8 +201,6 @@ init_secondary(int cpu)
}
 
mtx_unlock_spin(_boot_mtx);
-
-   enable_interrupts(PSR_I);
 
loop_counter = 0;
while (smp_started == 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: r360690 - head/sys/arm64/arm64

2020-05-06 Thread Mark Johnston
Author: markj
Date: Wed May  6 15:01:06 2020
New Revision: 360690
URL: https://svnweb.freebsd.org/changeset/base/360690

Log:
  Simplify arm64's pmap_bootstrap() a bit.
  
  locore constructs an L2 page mapping the kernel and preloaded data
  starting a KERNBASE (the same as VM_MIN_KERNEL_ADDRESS on arm64).
  initarm() and pmap_bootstrap() use the preloaded metadata to
  tell it where it can start allocating from.
  
  pmap_bootstrap() currently iterates over the L2 page to find the last
  valid entry, but doesn't do anything with the result.  Remove the loop
  and zap some now-unused local variables.
  
  MFC after:2 weeks
  Sponsored by: Juniper Networks, Klara Inc.
  Differential Revision:https://reviews.freebsd.org/D24559

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

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Wed May  6 11:40:32 2020(r360689)
+++ head/sys/arm64/arm64/pmap.c Wed May  6 15:01:06 2020(r360690)
@@ -831,9 +831,7 @@ void
 pmap_bootstrap(vm_offset_t l0pt, vm_offset_t l1pt, vm_paddr_t kernstart,
 vm_size_t kernlen)
 {
-   u_int l1_slot, l2_slot;
-   pt_entry_t *l2;
-   vm_offset_t va, freemempos;
+   vm_offset_t freemempos;
vm_offset_t dpcpu, msgbufpv;
vm_paddr_t start_pa, pa, min_pa;
uint64_t kern_delta;
@@ -867,7 +865,7 @@ pmap_bootstrap(vm_offset_t l0pt, vm_offset_t l1pt, vm_
 * Find the minimum physical address. physmap is sorted,
 * but may contain empty ranges.
 */
-   for (i = 0; i < (physmap_idx * 2); i += 2) {
+   for (i = 0; i < physmap_idx * 2; i += 2) {
if (physmap[i] == physmap[i + 1])
continue;
if (physmap[i] <= min_pa)
@@ -880,38 +878,14 @@ pmap_bootstrap(vm_offset_t l0pt, vm_offset_t l1pt, vm_
/* Create a direct map region early so we can use it for pa -> va */
freemempos = pmap_bootstrap_dmap(l1pt, min_pa, freemempos);
 
-   va = KERNBASE;
start_pa = pa = KERNBASE - kern_delta;
 
/*
-* Read the page table to find out what is already mapped.
-* This assumes we have mapped a block of memory from KERNBASE
-* using a single L1 entry.
+* Create the l2 tables up to VM_MAX_KERNEL_ADDRESS.  We assume that the
+* loader allocated the first and only l2 page table page used to map
+* the kernel, preloaded files and module metadata.
 */
-   l2 = pmap_early_page_idx(l1pt, KERNBASE, _slot, _slot);
-
-   /* Sanity check the index, KERNBASE should be the first VA */
-   KASSERT(l2_slot == 0, ("The L2 index is non-zero"));
-
-   /* Find how many pages we have mapped */
-   for (; l2_slot < Ln_ENTRIES; l2_slot++) {
-   if ((l2[l2_slot] & ATTR_DESCR_MASK) == 0)
-   break;
-
-   /* Check locore used L2 blocks */
-   KASSERT((l2[l2_slot] & ATTR_DESCR_MASK) == L2_BLOCK,
-   ("Invalid bootstrap L2 table"));
-   KASSERT((l2[l2_slot] & ~ATTR_MASK) == pa,
-   ("Incorrect PA in L2 table"));
-
-   va += L2_SIZE;
-   pa += L2_SIZE;
-   }
-
-   va = roundup2(va, L1_SIZE);
-
-   /* Create the l2 tables up to VM_MAX_KERNEL_ADDRESS */
-   freemempos = pmap_bootstrap_l2(l1pt, va, freemempos);
+   freemempos = pmap_bootstrap_l2(l1pt, KERNBASE + L1_SIZE, freemempos);
/* And the l3 tables for the early devmap */
freemempos = pmap_bootstrap_l3(l1pt,
VM_MAX_KERNEL_ADDRESS - (PMAP_MAPDEV_EARLY_SIZE), freemempos);
___
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: r360648 - in head: lib/libvmmapi share/man/man5 share/mk sys/amd64/include sys/amd64/vmm sys/amd64/vmm/amd sys/amd64/vmm/intel sys/amd64/vmm/io sys/conf sys/modules/vmm tools/build/opt

2020-05-06 Thread John Baldwin
On 5/5/20 7:20 PM, Li-Wen Hsu wrote:
> On Tue, May 5, 2020 at 8:02 AM John Baldwin  wrote:
>>
>> Author: jhb
>> Date: Tue May  5 00:02:04 2020
>> New Revision: 360648
>> URL: https://svnweb.freebsd.org/changeset/base/360648
> ...
>> Added:
>>   head/sys/amd64/include/vmm_snapshot.h   (contents, props changed)
>>   head/sys/amd64/vmm/vmm_snapshot.c   (contents, props changed)
>>   head/tools/build/options/WITH_BHYVE_SNAPSHOT   (contents, props changed)
>>   head/usr.sbin/bhyve/snapshot.c   (contents, props changed)
>>   head/usr.sbin/bhyve/snapshot.h   (contents, props changed)
> 
> These added files all have "THIS SOFTWARE IS PROVIDED BY NETAPP, INC"
> in copyright header, but non of the authors look like from NetApp.  Is
> it intended or it's better to have "THIS SOFTWARE IS PROVIDED BY THE
> AUTHOR AND CONTRIBUTORS"?

They probably should have the latter, I will check this with the authors.

-- 
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: r360685 - in head/tests/sys: netinet netinet6

2020-05-06 Thread Alexander V. Chernikov
Author: melifaro
Date: Wed May  6 07:48:37 2020
New Revision: 360685
URL: https://svnweb.freebsd.org/changeset/base/360685

Log:
  Add basic routing LPM tests.
  
  Differential Revision:https://reviews.freebsd.org/D24684

Added:
  head/tests/sys/netinet/lpm.sh   (contents, props changed)
  head/tests/sys/netinet6/lpm6.sh   (contents, props changed)
Modified:
  head/tests/sys/netinet/Makefile
  head/tests/sys/netinet6/Makefile

Modified: head/tests/sys/netinet/Makefile
==
--- head/tests/sys/netinet/Makefile Wed May  6 05:41:02 2020
(r360684)
+++ head/tests/sys/netinet/Makefile Wed May  6 07:48:37 2020
(r360685)
@@ -9,7 +9,7 @@ ATF_TESTS_C=ip_reass_test \
so_reuseport_lb_test \
socket_afinet
 
-ATF_TESTS_SH=  carp fibs_test redirect divert forward output
+ATF_TESTS_SH=  carp fibs_test redirect divert forward output lpm
 
 PROGS= udp_dontroute tcp_user_cookie
 

Added: head/tests/sys/netinet/lpm.sh
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tests/sys/netinet/lpm.sh   Wed May  6 07:48:37 2020
(r360685)
@@ -0,0 +1,179 @@
+#!/usr/bin/env atf-sh
+#-
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (c) 2020 Alexander V. Chernikov
+#
+# 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$
+#
+
+. $(atf_get_srcdir)/../common/vnet.subr
+
+setup_networking()
+{
+   jname="$1"
+   lo_dst="$2"
+   epair0="$3"
+   epair1="$4"
+
+   vnet_mkjail ${jname}a ${epair0}a ${epair1}a
+   # Setup transit IPv4 networks
+   jexec ${jname}a ifconfig ${epair0}a up
+   jexec ${jname}a ifconfig ${epair0}a inet 203.0.113.1/30
+   jexec ${jname}a ifconfig ${epair1}a up
+   jexec ${jname}a ifconfig ${epair1}a inet 203.0.113.5/30
+
+   vnet_mkjail ${jname}b ${epair0}b ${epair1}b ${lo_dst}
+   jexec ${jname}b ifconfig ${epair0}b up
+   jexec ${jname}b ifconfig ${epair0}b inet 203.0.113.2/30
+   jexec ${jname}b ifconfig ${epair1}b up
+   jexec ${jname}b ifconfig ${epair1}b inet 203.0.113.6/30
+   jexec ${jname}b ifconfig ${lo_dst} up
+
+}
+
+atf_test_case "lpm_test1_success" "cleanup"
+lpm_test1_success_head()
+{
+
+   atf_set descr 'Test IPv4 LPM for /30 and /31'
+   atf_set require.user root
+}
+
+lpm_test1_success_body()
+{
+
+   vnet_init
+
+   jname="v4t-lpm_test1_success"
+
+   lo_dst=$(vnet_mkloopback)
+   epair0=$(vnet_mkepair)
+   epair1=$(vnet_mkepair)
+
+   setup_networking ${jname} ${lo_dst} ${epair0} ${epair1}
+
+   jexec ${jname}b ifconfig ${lo_dst} inet 198.51.100.0/32
+   jexec ${jname}b ifconfig ${lo_dst} alias 198.51.100.2/32
+
+   # Add routes
+   # A -> towards B via epair0a 
+   jexec ${jname}a route add -4 -net 198.51.100.0/30 203.0.113.2
+   # A -> towards B via epair1a
+   jexec ${jname}a route add -4 -net 198.51.100.0/31 203.0.113.6
+
+   count=20
+   valid_message="${count} packets transmitted, ${count} packets received"
+   
+   # Check that 198.51.100.0 goes via epair1
+   atf_check -o match:"${valid_message}" jexec ${jname}a ping -f 
-nc${count} 198.51.100.0
+   pkt_0=`jexec ${jname}a netstat -Wf link -I ${epair0}a | head | awk 
'$1!~/^Name/{print$8}'`
+   pkt_1=`jexec ${jname}a netstat -Wf link -I ${epair1}a | head | awk 
'$1!~/^Name/{print$8}'`
+   if [ ${pkt_1} -le ${count} ]; then
+   echo "LPM failure: 1: ${pkt_0} 2: ${pkt_1} (should be ${count})"
+   exit 1
+   fi
+
+   # Check that 198.51.100.2 goes via epair0
+   atf_check