Re: svn commit: r366697 - head/usr.bin/xinstall

2020-10-14 Thread Enji Cooper


> On Oct 14, 2020, at 5:28 AM, Alex Richardson  wrote:
> 
> Author: arichardson
> Date: Wed Oct 14 12:28:41 2020
> New Revision: 366697
> URL: https://svnweb.freebsd.org/changeset/base/366697
> 
> Log:
>  install(1): Avoid unncessary fstatfs() calls and use mmap() based on size
> 
>  According to git blame the trymmap() function was added in 1996 to skip
>  mmap() calls for NFS file systems. However, nowadays mmap() should be
>  perfectly safe even on NFS. Importantly, onl ufs and cd9660 file systems
>  were whitelisted so we don't use mmap() on ZFS. It also prevents the use
>  of mmap() when bootstrapping from macOS/Linux since on those systems the
>  trymmap() function was always returning zero due to the missing MFSNAMELEN
>  define.
> 
>  This change keeps the trymmap() function but changes it to check whether
>  using mmap() can reduce the number of system calls that are required.
>  Using mmap() only reduces the number of system calls if we need multiple 
> read()
>  syscalls, i.e. if the file size is > MAXBSIZE. However, mmap() is more 
> expensive
>  than read() so this sets the threshold at 4 fewer syscalls. Additionally, for
>  larger file size mmap() can significantly increase the number of page faults,
>  so avoid it in that case.
> 
>  It's unclear whether using mmap() is ever faster than a read with an 
> appropriate
>  buffer size, but this change at least removes two unnecessary system calls
>  for every file that is installed.
> 
>  Reviewed By: markj
>  Differential Revision: https://reviews.freebsd.org/D26041

* Has this change been tested out with source filesystems other than 
UFS/ZFS? Not all filesystems support mmap(2).
* trymmap(..) seems to be less about computing whether or not the 
filesystem should use mmap(2) after this change, but how it should use mmap(2). 
Seems like a misnamed function call now.
Cheers,
-Enji
___
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: r366720 - head/sys/dev/hyperv/pcib

2020-10-14 Thread Wei Hu
Author: whu
Date: Thu Oct 15 05:57:20 2020
New Revision: 366720
URL: https://svnweb.freebsd.org/changeset/base/366720

Log:
  Hyper-V: pcib: Check revoke status during device attach
  
  It is possible that the vmbus pcib channel is revoked during attach path.
  The attach path could be waiting for response from host and this response 
will never
  arrive since the channel has already been revoked from host point of view. 
Check
  this situation during wait complete and return failed if this happens.
  
  Reported by:  Netapp
  MFC after:2 weeks
  Sponsored by: Microsoft
  Differential Revision:https://reviews.freebsd.org/D26486

Modified:
  head/sys/dev/hyperv/pcib/vmbus_pcib.c

Modified: head/sys/dev/hyperv/pcib/vmbus_pcib.c
==
--- head/sys/dev/hyperv/pcib/vmbus_pcib.c   Thu Oct 15 05:11:16 2020
(r366719)
+++ head/sys/dev/hyperv/pcib/vmbus_pcib.c   Thu Oct 15 05:57:20 2020
(r366720)
@@ -117,6 +117,31 @@ wait_for_completion(struct completion *c)
mtx_unlock(>lock);
 }
 
+/*
+ * Return: 0 if completed, a non-zero value if timed out.
+ */
+static int
+wait_for_completion_timeout(struct completion *c, int timeout)
+{
+   int ret;
+
+   mtx_lock(>lock);
+
+   if (c->done == 0)
+   mtx_sleep(c, >lock, 0, "hvwfc", timeout);
+
+   if (c->done > 0) {
+   c->done--;
+   ret = 0;
+   } else {
+   ret = 1;
+   }
+
+   mtx_unlock(>lock);
+
+   return (ret);
+}
+
 #define PCI_MAKE_VERSION(major, minor) ((uint32_t)(((major) << 16) | (major)))
 
 enum {
@@ -438,6 +463,25 @@ struct compose_comp_ctxt {
struct tran_int_desc int_desc;
 };
 
+/*
+ * It is possible the device is revoked during initialization.
+ * Check if this happens during wait.
+ * Return: 0 if response arrived, ENODEV if device revoked.
+ */
+static int
+wait_for_response(struct hv_pcibus *hbus, struct completion *c)
+{
+   do {
+   if (vmbus_chan_is_revoked(hbus->sc->chan)) {
+   device_printf(hbus->pcib,
+   "The device is revoked.\n");
+   return (ENODEV);
+   }
+   } while (wait_for_completion_timeout(c, hz /10) != 0);
+
+   return 0;
+}
+
 static void
 hv_pci_generic_compl(void *context, struct pci_response *resp,
 int resp_packet_size)
@@ -568,7 +612,9 @@ new_pcichild_device(struct hv_pcibus *hbus, struct pci
if (ret)
goto err;
 
-   wait_for_completion(_pkt.host_event);
+   if (wait_for_response(hbus, _pkt.host_event))
+   goto err;
+
free_completion(_pkt.host_event);
 
hpdev->desc = *desc;
@@ -1011,11 +1057,16 @@ hv_pci_protocol_negotiation(struct hv_pcibus *hbus)
ret = vmbus_chan_send(hbus->sc->chan, VMBUS_CHANPKT_TYPE_INBAND,
VMBUS_CHANPKT_FLAG_RC, version_req, sizeof(*version_req),
(uint64_t)(uintptr_t));
-   if (ret)
+   if (!ret)
+   ret = wait_for_response(hbus, _pkt.host_event);
+
+   if (ret) {
+   device_printf(hbus->pcib,
+   "vmbus_pcib failed to request version: %d\n",
+   ret);
goto out;
+   }
 
-   wait_for_completion(_pkt.host_event);
-
if (comp_pkt.completion_status < 0) {
device_printf(hbus->pcib,
"vmbus_pcib version negotiation failed: %x\n",
@@ -1072,11 +1123,12 @@ hv_pci_enter_d0(struct hv_pcibus *hbus)
ret = vmbus_chan_send(hbus->sc->chan, VMBUS_CHANPKT_TYPE_INBAND,
VMBUS_CHANPKT_FLAG_RC, d0_entry, sizeof(*d0_entry),
(uint64_t)(uintptr_t));
+   if (!ret)
+   ret = wait_for_response(hbus, _pkt.host_event);
+
if (ret)
goto out;
 
-   wait_for_completion(_pkt.host_event);
-
if (comp_pkt.completion_status < 0) {
device_printf(hbus->pcib, "vmbus_pcib failed to enable D0\n");
ret = EPROTO;
@@ -1125,14 +1177,14 @@ hv_send_resources_allocated(struct hv_pcibus *hbus)
VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC,
>message, sizeof(*res_assigned),
(uint64_t)(uintptr_t)pkt);
-   if (ret) {
-   free_completion(_pkt.host_event);
-   break;
-   }
+   if (!ret)
+   ret = wait_for_response(hbus, _pkt.host_event);
 
-   wait_for_completion(_pkt.host_event);
free_completion(_pkt.host_event);
 
+   if (ret)
+   break;
+
if (comp_pkt.completion_status < 0) {
ret = EPROTO;
device_printf(hbus->pcib,
@@ -1413,9 +1465,11 @@ vmbus_pcib_attach(device_t dev)
goto vmbus_close;
 
ret = 

svn commit: r366719 - head/sys/sys

2020-10-14 Thread Mateusz Guzik
Author: mjg
Date: Thu Oct 15 05:11:16 2020
New Revision: 366719
URL: https://svnweb.freebsd.org/changeset/base/366719

Log:
  Bump __FreeBSD_version after addition of VOP_EAGAIN

Modified:
  head/sys/sys/param.h

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hThu Oct 15 05:04:57 2020(r366718)
+++ head/sys/sys/param.hThu Oct 15 05:11:16 2020(r366719)
@@ -60,7 +60,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1300120  /* Master, propagated to newvers */
+#define __FreeBSD_version 1300121  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
___
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: r366718 - head/sys/contrib/openzfs/module/os/freebsd/zfs

2020-10-14 Thread Mateusz Guzik
Author: mjg
Date: Thu Oct 15 05:04:57 2020
New Revision: 366718
URL: https://svnweb.freebsd.org/changeset/base/366718

Log:
  zfs: g/c unused vop_vector zfsctl_ops_shares_dir

Modified:
  head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c

Modified: head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c
==
--- head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c Thu Oct 15 
04:49:34 2020(r366717)
+++ head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c Thu Oct 15 
05:04:57 2020(r366718)
@@ -314,7 +314,6 @@ sfs_readdir_common(uint64_t parent_id, uint64_t id, st
 static struct vop_vector zfsctl_ops_root;
 static struct vop_vector zfsctl_ops_snapdir;
 static struct vop_vector zfsctl_ops_snapshot;
-static struct vop_vector zfsctl_ops_shares_dir;
 
 void
 zfsctl_init(void)
@@ -331,8 +330,7 @@ zfsctl_is_node(vnode_t *vp)
 {
return (vn_matchops(vp, zfsctl_ops_root) ||
vn_matchops(vp, zfsctl_ops_snapdir) ||
-   vn_matchops(vp, zfsctl_ops_snapshot) ||
-   vn_matchops(vp, zfsctl_ops_shares_dir));
+   vn_matchops(vp, zfsctl_ops_snapshot));
 
 }
 
___
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: r366717 - head/sys/contrib/openzfs/module/os/freebsd/zfs

2020-10-14 Thread Mateusz Guzik
Author: mjg
Date: Thu Oct 15 04:49:34 2020
New Revision: 366717
URL: https://svnweb.freebsd.org/changeset/base/366717

Log:
  zfs: add missing fplookup vops
  
  Some vnodes come with a hack which inherits the fplookup flag despite having 
vops
  which don't provide the routine.
  
  Reported by:  YAMAMOTO Shigeru 

Modified:
  head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c
  head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops.c

Modified: head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c
==
--- head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c Thu Oct 15 
04:48:14 2020(r366716)
+++ head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c Thu Oct 15 
04:49:34 2020(r366717)
@@ -798,6 +798,7 @@ zfsctl_common_getacl(struct vop_getacl_args *ap)
 
 static struct vop_vector zfsctl_ops_root = {
.vop_default =  _vnodeops,
+   .vop_fplookup_vexec = VOP_EAGAIN,
.vop_open = zfsctl_common_open,
.vop_close =zfsctl_common_close,
.vop_ioctl =VOP_EINVAL,
@@ -1115,6 +1116,7 @@ zfsctl_snapdir_getattr(struct vop_getattr_args *ap)
 
 static struct vop_vector zfsctl_ops_snapdir = {
.vop_default =  _vnodeops,
+   .vop_fplookup_vexec = VOP_EAGAIN,
.vop_open = zfsctl_common_open,
.vop_close =zfsctl_common_close,
.vop_getattr =  zfsctl_snapdir_getattr,
@@ -1216,6 +1218,7 @@ zfsctl_snapshot_vptocnp(struct vop_vptocnp_args *ap)
  */
 static struct vop_vector zfsctl_ops_snapshot = {
.vop_default =  NULL, /* ensure very restricted access */
+   .vop_fplookup_vexec =   VOP_EAGAIN,
.vop_inactive = zfsctl_snapshot_inactive,
 #if __FreeBSD_version >= 1300045
.vop_need_inactive = vop_stdneed_inactive,

Modified: head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops.c
==
--- head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops.c  Thu Oct 15 
04:48:14 2020(r366716)
+++ head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops.c  Thu Oct 15 
04:49:34 2020(r366717)
@@ -6619,6 +6619,7 @@ VFS_VOP_VECTOR_REGISTER(zfs_fifoops);
  */
 struct vop_vector zfs_shareops = {
.vop_default =  _vnodeops,
+   .vop_fplookup_vexec =   VOP_EAGAIN,
.vop_access =   zfs_freebsd_access,
.vop_inactive = zfs_freebsd_inactive,
.vop_reclaim =  zfs_freebsd_reclaim,
___
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: r366716 - in head/sys: kern sys

2020-10-14 Thread Mateusz Guzik
Author: mjg
Date: Thu Oct 15 04:48:14 2020
New Revision: 366716
URL: https://svnweb.freebsd.org/changeset/base/366716

Log:
  vfs: add VOP_EAGAIN
  
  Can be used to stub fplookup for example.

Modified:
  head/sys/kern/vfs_default.c
  head/sys/sys/vnode.h

Modified: head/sys/kern/vfs_default.c
==
--- head/sys/kern/vfs_default.c Thu Oct 15 03:12:00 2020(r366715)
+++ head/sys/kern/vfs_default.c Thu Oct 15 04:48:14 2020(r366716)
@@ -198,6 +198,13 @@ vop_enoent(struct vop_generic_args *ap)
 }
 
 int
+vop_eagain(struct vop_generic_args *ap)
+{
+
+   return (EAGAIN);
+}
+
+int
 vop_null(struct vop_generic_args *ap)
 {
 

Modified: head/sys/sys/vnode.h
==
--- head/sys/sys/vnode.hThu Oct 15 03:12:00 2020(r366715)
+++ head/sys/sys/vnode.hThu Oct 15 04:48:14 2020(r366716)
@@ -828,6 +828,7 @@ int vop_ebadf(struct vop_generic_args *ap);
 intvop_einval(struct vop_generic_args *ap);
 intvop_enoent(struct vop_generic_args *ap);
 intvop_enotty(struct vop_generic_args *ap);
+intvop_eagain(struct vop_generic_args *ap);
 intvop_null(struct vop_generic_args *ap);
 intvop_panic(struct vop_generic_args *ap);
 intdead_poll(struct vop_poll_args *ap);
@@ -1001,6 +1002,7 @@ extern struct vop_vector default_vnodeops;
 #define VOP_EINVAL ((void*)(uintptr_t)vop_einval)
 #define VOP_ENOENT ((void*)(uintptr_t)vop_enoent)
 #define VOP_EOPNOTSUPP ((void*)(uintptr_t)vop_eopnotsupp)
+#define VOP_EAGAIN ((void*)(uintptr_t)vop_eagain)
 
 /* fifo_vnops.c */
 intfifo_printinfo(struct vnode *);
___
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: r366715 - head/sys/arm64/include

2020-10-14 Thread D Scott Phillips
Author: scottph
Date: Thu Oct 15 03:12:00 2020
New Revision: 366715
URL: https://svnweb.freebsd.org/changeset/base/366715

Log:
  arm64: Increase NIRQ to 16k
  
  Ampere Altra in a dual socket configuration has 12 ITSes for the
  12 PCIe root complexes. The NIRQ interrupts are statically split
  between each child of the gic bus, so here we increase that
  value. 16k is enough for
  
(#cpus * #its * max_pcie_bifurcation) LPIs + (#SPIs and #PPIs)
  
  Reviewed by:  jhb
  Approved by:  scottl (implicit)
  MFC after:1 week
  Sponsored by: Ampere Computing
  Differential Revision:https://reviews.freebsd.org/D26766

Modified:
  head/sys/arm64/include/intr.h

Modified: head/sys/arm64/include/intr.h
==
--- head/sys/arm64/include/intr.h   Thu Oct 15 00:50:26 2020
(r366714)
+++ head/sys/arm64/include/intr.h   Thu Oct 15 03:12:00 2020
(r366715)
@@ -36,7 +36,7 @@
 #include 
 
 #ifndef NIRQ
-#defineNIRQ2048/* XXX - It should be an option. */
+#defineNIRQ16384   /* XXX - It should be an option. */
 #endif
 
 static inline 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: r366713 - in head/sys: amd64/amd64 amd64/include i386/i386 i386/include

2020-10-14 Thread Konstantin Belousov
Author: kib
Date: Wed Oct 14 23:01:41 2020
New Revision: 366713
URL: https://svnweb.freebsd.org/changeset/base/366713

Log:
  Fix for mis-interpretation of PCB_KERNFPU.
  
  RIght now PCB_KERNFPU is used both as indication that kernel prepared
  hardware FPU context to use and that the thread is fpu-kern
  thread.  This also breaks fpu_kern_enter(FPU_KERN_NOCTX), since
  fpu_kern_leave() then clears PCB_KERNFPU.
  
  Introduce new flag PCB_KERNFPU_THR which indicates that the thread is
  fpu-kern.  Do not clear PCB_KERNFPU if fpu-kern thread leaves noctx
  fpu region.
  
  Reported and tested by:   jhb (amd64)
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D25511

Modified:
  head/sys/amd64/amd64/fpu.c
  head/sys/amd64/include/pcb.h
  head/sys/i386/i386/npx.c
  head/sys/i386/include/pcb.h

Modified: head/sys/amd64/amd64/fpu.c
==
--- head/sys/amd64/amd64/fpu.c  Wed Oct 14 22:57:50 2020(r366712)
+++ head/sys/amd64/amd64/fpu.c  Wed Oct 14 23:01:41 2020(r366713)
@@ -1230,8 +1230,9 @@ fpu_kern_leave(struct thread *td, struct fpu_kern_ctx 
if (pcb->pcb_save == get_pcb_user_save_pcb(pcb)) {
if ((pcb->pcb_flags & PCB_USERFPUINITDONE) != 0) {
set_pcb_flags(pcb, PCB_FPUINITDONE);
-   clear_pcb_flags(pcb, PCB_KERNFPU);
-   } else
+   if ((pcb->pcb_flags & PCB_KERNFPU_THR) == 0)
+   clear_pcb_flags(pcb, PCB_KERNFPU);
+   } else if ((pcb->pcb_flags & PCB_KERNFPU_THR) == 0)
clear_pcb_flags(pcb, PCB_FPUINITDONE | PCB_KERNFPU);
} else {
if ((ctx->flags & FPU_KERN_CTX_FPUINITDONE) != 0)
@@ -1254,7 +1255,7 @@ fpu_kern_thread(u_int flags)
("mangled pcb_save"));
KASSERT(PCB_USER_FPU(curpcb), ("recursive call"));
 
-   set_pcb_flags(curpcb, PCB_KERNFPU);
+   set_pcb_flags(curpcb, PCB_KERNFPU | PCB_KERNFPU_THR);
return (0);
 }
 
@@ -1264,7 +1265,7 @@ is_fpu_kern_thread(u_int flags)
 
if ((curthread->td_pflags & TDP_KTHREAD) == 0)
return (0);
-   return ((curpcb->pcb_flags & PCB_KERNFPU) != 0);
+   return ((curpcb->pcb_flags & PCB_KERNFPU_THR) != 0);
 }
 
 /*

Modified: head/sys/amd64/include/pcb.h
==
--- head/sys/amd64/include/pcb.hWed Oct 14 22:57:50 2020
(r366712)
+++ head/sys/amd64/include/pcb.hWed Oct 14 23:01:41 2020
(r366713)
@@ -84,6 +84,7 @@ struct pcb {
 #definePCB_KERNFPU 0x04/* kernel uses fpu */
 #definePCB_FPUINITDONE 0x08/* fpu state is initialized */
 #definePCB_USERFPUINITDONE 0x10 /* fpu user state is initialized */
+#definePCB_KERNFPU_THR 0x20/* fpu_kern_thread() */
 #definePCB_32BIT   0x40/* process has 32 bit context (segs 
etc) */
 #definePCB_FPUNOSAVE   0x80/* no save area for current FPU ctx */
 

Modified: head/sys/i386/i386/npx.c
==
--- head/sys/i386/i386/npx.cWed Oct 14 22:57:50 2020(r366712)
+++ head/sys/i386/i386/npx.cWed Oct 14 23:01:41 2020(r366713)
@@ -1472,11 +1472,12 @@ fpu_kern_leave(struct thread *td, struct fpu_kern_ctx 
}
 
if (pcb->pcb_save == get_pcb_user_save_pcb(pcb)) {
-   if ((pcb->pcb_flags & PCB_NPXUSERINITDONE) != 0)
+   if ((pcb->pcb_flags & PCB_NPXUSERINITDONE) != 0) {
pcb->pcb_flags |= PCB_NPXINITDONE;
-   else
-   pcb->pcb_flags &= ~PCB_NPXINITDONE;
-   pcb->pcb_flags &= ~PCB_KERNNPX;
+   if ((pcb->pcb_flags & PCB_KERNNPX_THR) == 0)
+   pcb->pcb_flags |= ~PCB_KERNNPX;
+   } else if ((pcb->pcb_flags & PCB_KERNNPX_THR) == 0)
+   pcb->pcb_flags &= ~(PCB_NPXINITDONE | PCB_KERNNPX);
} else {
if ((ctx->flags & FPU_KERN_CTX_NPXINITDONE) != 0)
pcb->pcb_flags |= PCB_NPXINITDONE;
@@ -1498,7 +1499,7 @@ fpu_kern_thread(u_int flags)
("mangled pcb_save"));
KASSERT(PCB_USER_FPU(curpcb), ("recursive call"));
 
-   curpcb->pcb_flags |= PCB_KERNNPX;
+   curpcb->pcb_flags |= PCB_KERNNPX | PCB_KERNNPX_THR;
return (0);
 }
 
@@ -1508,7 +1509,7 @@ is_fpu_kern_thread(u_int flags)
 
if ((curthread->td_pflags & TDP_KTHREAD) == 0)
return (0);
-   return ((curpcb->pcb_flags & PCB_KERNNPX) != 0);
+   return ((curpcb->pcb_flags & PCB_KERNNPX_THR) != 0);
 }
 
 /*

Modified: head/sys/i386/include/pcb.h
==
--- head/sys/i386/include/pcb.h 

svn commit: r366712 - in head/sys: amd64/amd64 i386/i386 x86/include x86/x86

2020-10-14 Thread Konstantin Belousov
Author: kib
Date: Wed Oct 14 22:57:50 2020
New Revision: 366712
URL: https://svnweb.freebsd.org/changeset/base/366712

Log:
  Limit workaround for errata E400 to appropriate AMD cpus.
  
  From Linux sources and several datasheets I looked at, it seems that
  the workaround is only needed on families 0xf and 0x10.  For instance,
  Ryzens do not implement the accessed MSR at all, it is documented as
  reserved.  Also, hypervisors should not allow guest to put CPU into
  idle state, so activate workaround only when on bare hardware.
  
  While there, style the code:
  move MSR defines to specialreg.h
  move identification to initcpu.c
  
  Reported by:  whu
  Reviewed by:  avg
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D26470

Modified:
  head/sys/amd64/amd64/initcpu.c
  head/sys/amd64/amd64/machdep.c
  head/sys/i386/i386/initcpu.c
  head/sys/i386/i386/machdep.c
  head/sys/x86/include/specialreg.h
  head/sys/x86/include/x86_var.h
  head/sys/x86/x86/cpu_machdep.c

Modified: head/sys/amd64/amd64/initcpu.c
==
--- head/sys/amd64/amd64/initcpu.c  Wed Oct 14 22:51:40 2020
(r366711)
+++ head/sys/amd64/amd64/initcpu.c  Wed Oct 14 22:57:50 2020
(r366712)
@@ -69,6 +69,23 @@ init_amd(void)
uint64_t msr;
 
/*
+* C1E renders the local APIC timer dead, so we disable it by
+* reading the Interrupt Pending Message register and clearing
+* both C1eOnCmpHalt (bit 28) and SmiOnCmpHalt (bit 27).
+*
+* Reference:
+*   "BIOS and Kernel Developer's Guide for AMD NPT Family 0Fh 
Processors"
+*   #32559 revision 3.00+
+*
+* Detect the presence of C1E capability mostly on latest
+* dual-cores (or future) k8 family.  Affected models range is
+* taken from Linux sources.
+*/
+   if ((CPUID_TO_FAMILY(cpu_id) == 0xf ||
+   CPUID_TO_FAMILY(cpu_id) == 0x10) && (cpu_feature2 & CPUID2_HV) == 0)
+   cpu_amdc1e_bug = 1;
+
+   /*
 * Work around Erratum 721 for Family 10h and 12h processors.
 * These processors may incorrectly update the stack pointer
 * after a long series of push and/or near-call instructions,

Modified: head/sys/amd64/amd64/machdep.c
==
--- head/sys/amd64/amd64/machdep.c  Wed Oct 14 22:51:40 2020
(r366711)
+++ head/sys/amd64/amd64/machdep.c  Wed Oct 14 22:57:50 2020
(r366712)
@@ -1928,8 +1928,6 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
if (env != NULL)
strlcpy(kernelname, env, sizeof(kernelname));
 
-   cpu_probe_amdc1e();
-
kcsan_cpu_init(0);
 
 #ifdef FDT

Modified: head/sys/i386/i386/initcpu.c
==
--- head/sys/i386/i386/initcpu.cWed Oct 14 22:51:40 2020
(r366711)
+++ head/sys/i386/i386/initcpu.cWed Oct 14 22:57:50 2020
(r366712)
@@ -720,8 +720,8 @@ initializecpu(void)
break;
}
break;
-#ifdef CPU_ATHLON_SSE_HACK
case CPU_VENDOR_AMD:
+#ifdef CPU_ATHLON_SSE_HACK
/*
 * Sometimes the BIOS doesn't enable SSE instructions.
 * According to AMD document 20734, the mobile
@@ -738,8 +738,16 @@ initializecpu(void)
do_cpuid(1, regs);
cpu_feature = regs[3];
}
-   break;
 #endif
+   /*
+* Detect C1E that breaks APIC.  See comment in
+* amd64/initcpu.c.
+*/
+   if ((CPUID_TO_FAMILY(cpu_id) == 0xf ||
+   CPUID_TO_FAMILY(cpu_id) == 0x10) &&
+   (cpu_feature2 & CPUID2_HV) == 0)
+   cpu_amdc1e_bug = 1;
+   break;
case CPU_VENDOR_CENTAUR:
init_via();
break;

Modified: head/sys/i386/i386/machdep.c
==
--- head/sys/i386/i386/machdep.cWed Oct 14 22:51:40 2020
(r366711)
+++ head/sys/i386/i386/machdep.cWed Oct 14 22:57:50 2020
(r366712)
@@ -2505,8 +2505,6 @@ init386(int first)
thread0.td_pcb->pcb_ext = 0;
thread0.td_frame = _tf;
 
-   cpu_probe_amdc1e();
-
 #ifdef FDT
x86_init_fdt();
 #endif

Modified: head/sys/x86/include/specialreg.h
==
--- head/sys/x86/include/specialreg.h   Wed Oct 14 22:51:40 2020

svn commit: r366711 - in head/sys: amd64/amd64 arm/arm arm64/arm64 i386/i386 kern mips/atheros mips/atheros/ar531x mips/beri mips/broadcom mips/cavium mips/ingenic mips/malta mips/mediatek mips/mip...

2020-10-14 Thread Konstantin Belousov
Author: kib
Date: Wed Oct 14 22:51:40 2020
New Revision: 366711
URL: https://svnweb.freebsd.org/changeset/base/366711

Log:
  Avoid dump_avail[] redefinition.
  
  Move dump_avail[] extern declaration and inlines into a new header
  vm/vm_dumpset.h.  This fixes default gcc build for mips.
  
  Reviewed by:  alc, scottph
  Tested by:kevans (previous version)
  Sponsored by: The FreeBSD Foundation
  Differential revision:https://reviews.freebsd.org/D26741

Added:
  head/sys/vm/vm_dumpset.h   (contents, props changed)
Modified:
  head/sys/amd64/amd64/machdep.c
  head/sys/amd64/amd64/minidump_machdep.c
  head/sys/amd64/amd64/pmap.c
  head/sys/amd64/amd64/uma_machdep.c
  head/sys/arm/arm/mem.c
  head/sys/arm/arm/minidump_machdep.c
  head/sys/arm64/arm64/minidump_machdep.c
  head/sys/arm64/arm64/pmap.c
  head/sys/arm64/arm64/uma_machdep.c
  head/sys/i386/i386/machdep.c
  head/sys/i386/i386/minidump_machdep_base.c
  head/sys/kern/kern_dump.c
  head/sys/kern/subr_physmem.c
  head/sys/mips/atheros/ar531x/ar5315_machdep.c
  head/sys/mips/atheros/ar71xx_machdep.c
  head/sys/mips/beri/beri_machdep.c
  head/sys/mips/broadcom/bcm_machdep.c
  head/sys/mips/cavium/octeon_machdep.c
  head/sys/mips/ingenic/jz4780_machdep.c
  head/sys/mips/malta/malta_machdep.c
  head/sys/mips/mediatek/mtk_machdep.c
  head/sys/mips/mips/minidump_machdep.c
  head/sys/mips/mips/pmap.c
  head/sys/mips/mips/uma_machdep.c
  head/sys/mips/nlm/xlp_machdep.c
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/aim/mmu_radix.c
  head/sys/powerpc/booke/pmap.c
  head/sys/powerpc/powerpc/minidump_machdep.c
  head/sys/powerpc/powerpc/uma_machdep.c
  head/sys/riscv/riscv/minidump_machdep.c
  head/sys/riscv/riscv/pmap.c
  head/sys/riscv/riscv/uma_machdep.c
  head/sys/vm/uma_core.c
  head/sys/vm/vm_page.c
  head/sys/vm/vm_page.h
  head/sys/vm/vm_phys.h
  head/sys/x86/x86/nexus.c

Modified: head/sys/amd64/amd64/machdep.c
==
--- head/sys/amd64/amd64/machdep.c  Wed Oct 14 21:22:23 2020
(r366710)
+++ head/sys/amd64/amd64/machdep.c  Wed Oct 14 22:51:40 2020
(r366711)
@@ -95,14 +95,15 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
+#include 
 
 #ifdef DDB
 #ifndef KDB

Modified: head/sys/amd64/amd64/minidump_machdep.c
==
--- head/sys/amd64/amd64/minidump_machdep.c Wed Oct 14 21:22:23 2020
(r366710)
+++ head/sys/amd64/amd64/minidump_machdep.c Wed Oct 14 22:51:40 2020
(r366711)
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Wed Oct 14 21:22:23 2020(r366710)
+++ head/sys/amd64/amd64/pmap.c Wed Oct 14 22:51:40 2020(r366711)
@@ -149,6 +149,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 

Modified: head/sys/amd64/amd64/uma_machdep.c
==
--- head/sys/amd64/amd64/uma_machdep.c  Wed Oct 14 21:22:23 2020
(r366710)
+++ head/sys/amd64/amd64/uma_machdep.c  Wed Oct 14 22:51:40 2020
(r366711)
@@ -36,12 +36,13 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-#include 
 
 void *
 uma_small_alloc(uma_zone_t zone, vm_size_t bytes, int domain, u_int8_t *flags,

Modified: head/sys/arm/arm/mem.c
==
--- head/sys/arm/arm/mem.c  Wed Oct 14 21:22:23 2020(r366710)
+++ head/sys/arm/arm/mem.c  Wed Oct 14 22:51:40 2020(r366711)
@@ -65,11 +65,11 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
 #include 
-#include 
 
 /*
  * Used in /dev/mem drivers and elsewhere

Modified: head/sys/arm/arm/minidump_machdep.c
==
--- head/sys/arm/arm/minidump_machdep.c Wed Oct 14 21:22:23 2020
(r366710)
+++ head/sys/arm/arm/minidump_machdep.c Wed Oct 14 22:51:40 2020
(r366711)
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/sys/arm64/arm64/minidump_machdep.c
==
--- head/sys/arm64/arm64/minidump_machdep.c Wed Oct 14 21:22:23 2020
(r366710)
+++ head/sys/arm64/arm64/minidump_machdep.c Wed Oct 14 22:51:40 2020
(r366711)
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 


svn commit: r366710 - head/sys/dev/iommu

2020-10-14 Thread Ruslan Bukin
Author: br
Date: Wed Oct 14 21:22:23 2020
New Revision: 366710
URL: https://svnweb.freebsd.org/changeset/base/366710

Log:
  Split-out iommu type definitions to a separate header.
  
  Reviewed by:  kib
  Sponsored by: Innovate DSbD
  Differential Revision:https://reviews.freebsd.org/D26780

Added:
  head/sys/dev/iommu/iommu_types.h   (contents, props changed)
Modified:
  head/sys/dev/iommu/iommu.h

Modified: head/sys/dev/iommu/iommu.h
==
--- head/sys/dev/iommu/iommu.h  Wed Oct 14 20:55:31 2020(r366709)
+++ head/sys/dev/iommu/iommu.h  Wed Oct 14 21:22:23 2020(r366710)
@@ -34,10 +34,7 @@
 #ifndef _DEV_IOMMU_IOMMU_H_
 #define _DEV_IOMMU_IOMMU_H_
 
-/* Host or physical memory address, after translation. */
-typedef uint64_t iommu_haddr_t;
-/* Guest or bus address, before translation. */
-typedef uint64_t iommu_gaddr_t;
+#include 
 
 struct bus_dma_tag_common;
 struct iommu_map_entry;

Added: head/sys/dev/iommu/iommu_types.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/iommu/iommu_types.hWed Oct 14 21:22:23 2020
(r366710)
@@ -0,0 +1,42 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Konstantin Belousov 
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _DEV_IOMMU_IOMMU_TYPES_H_
+#define _DEV_IOMMU_IOMMU_TYPES_H_
+
+/* Host or physical memory address, after translation. */
+typedef uint64_t iommu_haddr_t;
+/* Guest or bus address, before translation. */
+typedef uint64_t iommu_gaddr_t;
+
+#endif /* !_DEV_IOMMU_IOMMU_TYPES_H_ */
___
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: r366709 - head/sys/crypto/skein/amd64

2020-10-14 Thread Adrian Chadd
Author: adrian
Date: Wed Oct 14 20:55:31 2020
New Revision: 366709
URL: https://svnweb.freebsd.org/changeset/base/366709

Log:
  [skein] Fix compile issue with unknown symbol SKEIN_ASM_UNROLL1024
  
  Weirdly, I needed to sprinkle more parens here to get gcc-as in 6.4
  to correctly generate things.
  
  Without them, I'd get an unknown variable reference to SKEIN_ASM_UNROLL1024.
  
  This at least links now, but I haven't run any test cases against it.
  It may be worthwhile doing it in case gcc-as demands we liberally sprinkle
  more brackets around variables in .if statements.
  
  Thanks to ed for the suggestion of just sprinkling more brackets to
  see if that helped.
  
  Reviewed by:  emaste

Modified:
  head/sys/crypto/skein/amd64/skein_block_asm.S

Modified: head/sys/crypto/skein/amd64/skein_block_asm.S
==
--- head/sys/crypto/skein/amd64/skein_block_asm.S   Wed Oct 14 17:39:50 
2020(r366708)
+++ head/sys/crypto/skein/amd64/skein_block_asm.S   Wed Oct 14 20:55:31 
2020(r366709)
@@ -41,7 +41,7 @@ SKEIN_UNROLL_1024 = (_SKEIN_LOOP  ) % 10
 SKEIN_ASM_UNROLL  = 0
   .irp _NN_,256,512,1024
 .if (SKEIN_UNROLL_\_NN_) == 0
-SKEIN_ASM_UNROLL  = SKEIN_ASM_UNROLL + \_NN_
+SKEIN_ASM_UNROLL  = (SKEIN_ASM_UNROLL) + \_NN_
 .endif
   .endr
 #
@@ -397,7 +397,7 @@ _NN_ = _NN_ - 1
 .macro Skein_Debug_Round BLK_BITS,R,RDI_OFFS,afterOp
 # call the appropriate (local) debug "function"
 pushq   %rdx#save rdx, so we can use it for round 
"number"
-  .if (SKEIN_ASM_UNROLL & \BLK_BITS) || (\R >= SKEIN_RND_SPECIAL)
+  .if ((SKEIN_ASM_UNROLL) & \BLK_BITS) || (\R >= SKEIN_RND_SPECIAL)
 movq$\R,%rdx
   .else #compute round number using edi
 _rOffs_ = \RDI_OFFS + 0
@@ -533,7 +533,7 @@ Skein_256_block_loop:
 Skein_Debug_Round 256,SKEIN_RND_KEY_INITIAL
 .endif
 #
-.if ((SKEIN_ASM_UNROLL & 256) == 0)
+.if (((SKEIN_ASM_UNROLL) & 256) == 0)
 movq%r8 ,ksKey+40+F_O(%rbp)  #save key schedule on stack for looping 
code
 movq%r9 ,ksKey+ 8+F_O(%rbp)
 movq%r10,ksKey+16+F_O(%rbp)
@@ -549,7 +549,7 @@ Skein_256_block_loop:
 #
 # now the key schedule is computed. Start the rounds
 #
-.if SKEIN_ASM_UNROLL & 256
+.if (SKEIN_ASM_UNROLL) & 256
 _UNROLL_CNT =   ROUNDS_256/8
 .else
 _UNROLL_CNT =   SKEIN_UNROLL_256
@@ -566,20 +566,20 @@ _Rbase_ = 0
 addReg  rax, rbx
 RotL64  rbx, 256,%((4*_Rbase_+0) % 8),0
 addReg  rcx, rdx
-.if (SKEIN_ASM_UNROLL & 256) == 0
+.if ((SKEIN_ASM_UNROLL) & 256) == 0
 movq ksKey+8*1+F_O(%rbp,%rdi,8),%r8
 .endif
 xorReg  rbx, rax
 RotL64  rdx, 256,%((4*_Rbase_+0) % 8),1
 xorReg  rdx, rcx
-  .if SKEIN_ASM_UNROLL & 256
+  .if (SKEIN_ASM_UNROLL) & 256
 .irp _r0_,%( 8+(_Rbase_+3) % 5)
 .irp _r1_,%(13+(_Rbase_+2) % 3)
   leaq   (%r\_r0_,%r\_r1_),%rdi#precompute key injection value for %rcx
 .endr
 .endr
   .endif
-.if (SKEIN_ASM_UNROLL & 256) == 0
+.if ((SKEIN_ASM_UNROLL) & 256) == 0
 movq ksTwk+8*1+F_O(%rbp,%rdi,8),%r13
 .endif
 Skein_Debug_Round 256,%(4*_Rbase_+1)
@@ -588,17 +588,17 @@ _Rbase_ = 0
 addReg  rax, rdx
 RotL64  rdx, 256,%((4*_Rbase_+1) % 8),0
 xorReg  rdx, rax
-.if (SKEIN_ASM_UNROLL & 256) == 0
+.if ((SKEIN_ASM_UNROLL) & 256) == 0
 movq ksKey+8*2+F_O(%rbp,%rdi,8),%r9
 .endif
 addReg  rcx, rbx
 RotL64  rbx, 256,%((4*_Rbase_+1) % 8),1
 xorReg  rbx, rcx
-.if (SKEIN_ASM_UNROLL & 256) == 0
+.if ((SKEIN_ASM_UNROLL) & 256) == 0
 movq ksKey+8*4+F_O(%rbp,%rdi,8),%r11
 .endif
 Skein_Debug_Round 256,%(4*_Rbase_+2)
- .if SKEIN_ASM_UNROLL & 256
+ .if (SKEIN_ASM_UNROLL) & 256
 .irp _r0_,%( 8+(_Rbase_+2) % 5)
 .irp _r1_,%(13+(_Rbase_+1) % 3)
   leaq   (%r\_r0_,%r\_r1_),%rsi #precompute key injection value for 
%rbx
@@ -609,13 +609,13 @@ _Rbase_ = 0
 addReg  rax, rbx
 RotL64  rbx, 256,%((4*_Rbase_+2) % 8),0
 addReg  rcx, rdx
-.if (SKEIN_ASM_UNROLL & 256) == 0
+.if ((SKEIN_ASM_UNROLL) & 256) == 0
 movq ksKey+8*3+F_O(%rbp,%rdi,8),%r10
 .endif
 xorReg  rbx, rax
 RotL64  rdx, 256,%((4*_Rbase_+2) % 8),1
 xorReg  rdx, rcx
-.if (SKEIN_ASM_UNROLL & 256) == 0
+.if ((SKEIN_ASM_UNROLL) & 256) == 0
 movq %r8,ksKey+8*6+F_O(%rbp,%rdi,8)  #"rotate" the key
 leaq 1(%r11,%rdi),%r11   #precompute key + 
tweak
 .endif
@@ -624,7 +624,7 @@ _Rbase_ = 0
 addReg  rax, rdx
 RotL64  rdx, 256,%((4*_Rbase_+3) % 8),0
 addReg  rcx, rbx
-.if 

Re: svn commit: r366697 - head/usr.bin/xinstall

2020-10-14 Thread Brooks Davis
On Wed, Oct 14, 2020 at 02:40:42PM +0100, Jessica Clarke wrote:
> On 14 Oct 2020, at 14:28, Mateusz Guzik  wrote:
> > 
> > This should use copy_file_range (also available on Linux).
> 
> I assume this is a bootstrap tool and hence the system OS and version
> is relevant. macOS does not have copy_file_range, and FreeBSD only has
> it in -CURRENT so that would break building on 11.x and 12.x. So any
> use would need to be guarded by preprocessor checks (and there are
> still actively-supported Linux distributions out there that are based
> on too-old versions of the kernel and/or glibc to include it).
> 
> (FYI macOS's equivalent is copyfile(3)... maybe one day it will adopt
> the copy_file_range(2) interface too)

copyfile has different semantics, not the least of which is supporting
file clones.  Once ZFS grows file clone support it would be nice if install
supported them as well.  I'd love to only pay the inode cost for
installed files when I'm just building a disk image.

-- Brooks


signature.asc
Description: PGP signature


svn commit: r366708 - in head/sbin/pfctl/tests: . files

2020-10-14 Thread Alex Richardson
Author: arichardson
Date: Wed Oct 14 17:39:50 2020
New Revision: 366708
URL: https://svnweb.freebsd.org/changeset/base/366708

Log:
  Rewrite pfctl_test in C to reduce testsuite run time
  
  The new C test takes 25 seconds on QEMU-RISC-V, wheras the shell version
  takes 332 seconds.
  
  Even with the latest optimizations to atf-sh this test still takes a few
  seconds to startup in QEMU. Re-writing it in C reduces the runtime for a
  single test from about 2-3 seconds to less than .5 seconds. Since there
  are ~80 tests, this adds up to about 3-4 minutes.
  This may not seem like a big speedup, but before the recent optimizations
  to avoid atf_get_srcdir, each test took almost 100 seconds on QEMU RISC-V
  instead of 3. This also significantly reduces the time it takes to list
  the available test cases, which speeds up running the tests via kyua:
  
  ```
  root@qemu-riscv64-alex:~ # /usr/bin/time kyua test -k 
/usr/tests/sbin/pfctl/Kyuafile pfctl_test_old
  ...
  158/158 passed (0 failed)
332.08 real42.58 user   286.17 sys
  root@qemu-riscv64-alex:~ # /usr/bin/time kyua test -k 
/usr/tests/sbin/pfctl/Kyuafile pfctl_test
  158/158 passed (0 failed)
 24.96 real 9.75 user14.26 sys
  
  root@qemu-riscv64-alex:/usr/tests/sbin/pfctl # /usr/bin/time ./pfctl_test 
pf1001
  pfctl_test: WARNING: Running test cases outside of kyua(1) is unsupported
  pfctl_test: WARNING: No isolation nor timeout control is being applied; you 
may get unexpected failures; see atf-test-case(4)
  Running pfctl -o none -nvf /usr/tests/sbin/pfctl/./files/pf1001.in
  ---
  binat on em0 inet6 from fc00::/64 to any -> fc00:0:0:1::/64
  binat on em0 inet6 from any to fc00:0:0:1::/64 -> fc00::/64
  ---
  passed
  0.17 real 0.06 user 0.08 sys
  root@qemu-riscv64-alex:/usr/tests/sbin/pfctl # /usr/bin/time ./pfctl_test_old 
pf1001
  pfctl_test_old: WARNING: Running test cases outside of kyua(1) is unsupported
  pfctl_test_old: WARNING: No isolation nor timeout control is being applied; 
you may get unexpected failures; see atf-test-case(4)
  Id  Refs Name
  1411 pf
  Executing command [ pfctl -o none -nvf - ]
  passed
  1.73 real 0.25 user 1.41 sys
  root@qemu-riscv64-alex:/usr/tests/sbin/pfctl # /usr/bin/time ./pfctl_test_old 
-l > /dev/null
 24.36 real 2.26 user21.86 sys
  root@qemu-riscv64-alex:/usr/tests/sbin/pfctl # /usr/bin/time ./pfctl_test -l 
> /dev/null
  0.04 real 0.02 user 0.01 sys
  ```
  
  The speedups are even more noticeable on CHERI-RISC-V (since QEMU runs
  slower when emulating CHERI instructions):
  ```
  root@qemu-cheri-alex:/usr/tests/sbin/pfctl # /usr/bin/time ./pfctl_test_new 
-l > /dev/null
  0.51 real 0.49 user 0.00 sys
  root@qemu-cheri-alex:/usr/tests/sbin/pfctl # /usr/bin/time ./pfctl_test -l > 
/dev/null
 34.20 real32.69 user 0.16 sys
  root@qemu-cheri-alex:/usr/tests/sbin/pfctl # /usr/bin/time ./pfctl_test pf1001
  pfctl_test: WARNING: Running test cases outside of kyua(1) is unsupported
  pfctl_test: WARNING: No isolation nor timeout control is being applied; you 
may get unexpected failures; see atf-test-case(4)
  Id  Refs Name
  1471 pf
  Executing command [ pfctl -o none -nvf - ]
  passed
  5.74 real 5.41 user 0.03 sys
  root@qemu-cheri-alex:/usr/tests/sbin/pfctl # /usr/bin/time ./pfctl_test_new 
pf1001
  pfctl_test_new: WARNING: Running test cases outside of kyua(1) is unsupported
  pfctl_test_new: WARNING: No isolation nor timeout control is being applied; 
you may get unexpected failures; see atf-test-case(4)
  Running pfctl -o none -nvf /usr/tests/sbin/pfctl/./files/pf1001.in
  ---
  binat on em0 inet6 from fc00::/64 to any -> fc00:0:0:1::/64
  binat on em0 inet6 from any to fc00:0:0:1::/64 -> fc00::/64
  ---
  passed
  0.68 real 0.66 user 0.00 sys
  root@qemu-cheri-alex:/usr/tests/sbin/pfctl #
  ```
  
  Reviewed By:  kp
  Differential Revision: https://reviews.freebsd.org/D26779

Added:
  head/sbin/pfctl/tests/pfctl_test.c   (contents, props changed)
  head/sbin/pfctl/tests/pfctl_test_list.inc   (contents, props changed)
Deleted:
  head/sbin/pfctl/tests/files/pfctl_test_descr.sh
  head/sbin/pfctl/tests/pfctl_test.sh
Modified:
  head/sbin/pfctl/tests/Makefile
  head/sbin/pfctl/tests/files/Makefile

Modified: head/sbin/pfctl/tests/Makefile
==
--- head/sbin/pfctl/tests/Makefile  Wed Oct 14 15:50:28 2020
(r366707)
+++ head/sbin/pfctl/tests/Makefile  Wed Oct 14 17:39:50 2020
(r366708)
@@ -2,9 +2,11 @@
 
 PACKAGE=   tests
 
-ATF_TESTS_SH=  pfctl_test \
-   macro
+ATF_TESTS_C=   pfctl_test
+ATF_TESTS_SH=  macro
 
+LIBADD+=   sbuf
 SUBDIR+=   files
+WARNS=6
 
 .include 

Modified: head/sbin/pfctl/tests/files/Makefile

svn commit: r366707 - head/sys/dev/nvme

2020-10-14 Thread Alexander Motin
Author: mav
Date: Wed Oct 14 15:50:28 2020
New Revision: 366707
URL: https://svnweb.freebsd.org/changeset/base/366707

Log:
  Use RTD3 Entry Latency value as shutdown timeout.
  
  This field was not in specs when the driver was written, but now there
  are SSDs with the reported latency of 10s, where hardcoded value of 5s
  seems to be not enough sometimes, causing shutdown timeout messages.
  
  MFC after:1 week
  Sponsored by: iXsystems, Inc.

Modified:
  head/sys/dev/nvme/nvme_ctrlr.c

Modified: head/sys/dev/nvme/nvme_ctrlr.c
==
--- head/sys/dev/nvme/nvme_ctrlr.c  Wed Oct 14 15:31:42 2020
(r366706)
+++ head/sys/dev/nvme/nvme_ctrlr.c  Wed Oct 14 15:50:28 2020
(r366707)
@@ -1510,22 +1510,24 @@ nvme_ctrlr_shutdown(struct nvme_controller *ctrlr)
 {
uint32_tcc;
uint32_tcsts;
-   int ticks = 0;
+   int ticks = 0, timeout;
 
cc = nvme_mmio_read_4(ctrlr, cc);
cc &= ~(NVME_CC_REG_SHN_MASK << NVME_CC_REG_SHN_SHIFT);
cc |= NVME_SHN_NORMAL << NVME_CC_REG_SHN_SHIFT;
nvme_mmio_write_4(ctrlr, cc, cc);
 
+   timeout = ctrlr->cdata.rtd3e == 0 ? 5 * hz :
+   ((uint64_t)ctrlr->cdata.rtd3e * hz + 99) / 100;
while (1) {
csts = nvme_mmio_read_4(ctrlr, csts);
if (csts == 0x) /* Hot unplug. */
break;
if (NVME_CSTS_GET_SHST(csts) == NVME_SHST_COMPLETE)
break;
-   if (ticks++ > 5*hz) {
+   if (ticks++ > timeout) {
nvme_printf(ctrlr, "did not complete shutdown within"
-   " 5 seconds of notification\n");
+   " %d ticks of notification\n", timeout);
break;
}
pause("nvme shn", 1);
___
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: r366706 - head/sys/arm64/arm64

2020-10-14 Thread Andrew Turner
Author: andrew
Date: Wed Oct 14 15:31:42 2020
New Revision: 366706
URL: https://svnweb.freebsd.org/changeset/base/366706

Log:
  Remove direct user access from the arm64 copyinstr
  
  These already use the load variant that simulates userspace access.
  Remove the macros that enable normal loads and stores from userspace
  as they are unneeded.
  
  Sponsored by: Innovate UK

Modified:
  head/sys/arm64/arm64/copyinout.S

Modified: head/sys/arm64/arm64/copyinout.S
==
--- head/sys/arm64/arm64/copyinout.SWed Oct 14 15:26:19 2020
(r366705)
+++ head/sys/arm64/arm64/copyinout.SWed Oct 14 15:31:42 2020
(r366706)
@@ -100,7 +100,6 @@ ENTRY(copyinstr)
 
adr x6, copyio_fault /* Get the handler address */
SET_FAULT_HANDLER(x6, x7) /* Set the handler */
-   ENTER_USER_ACCESS(w6, x7)
 
ldr x7, =VM_MAXUSER_ADDRESS
 1: cmp x0, x7
@@ -113,8 +112,7 @@ ENTRY(copyinstr)
sub x2, x2, #1  /* len-- */
cbnzx2, 1b
 
-2: EXIT_USER_ACCESS(w6)
-   SET_FAULT_HANDLER(xzr, x7) /* Clear the handler */
+2: SET_FAULT_HANDLER(xzr, x7) /* Clear the handler */
 
 
 3: cbz x3, 4f  /* Check if done != NULL */
___
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: r366704 - in head/sys: dev/iommu i386/include

2020-10-14 Thread Ruslan Bukin
Author: br
Date: Wed Oct 14 14:51:11 2020
New Revision: 366704
URL: https://svnweb.freebsd.org/changeset/base/366704

Log:
  Add a per-each macro IOMMU_DOMAIN_UNLOAD_SLEEP which allows to sleep
  during iommu guest address space entries unload.
  
  Suggested by: kib
  Sponsored by: Innovate DSbD
  Differential Revision:https://reviews.freebsd.org/D26722

Modified:
  head/sys/dev/iommu/busdma_iommu.c
  head/sys/i386/include/iommu.h

Modified: head/sys/dev/iommu/busdma_iommu.c
==
--- head/sys/dev/iommu/busdma_iommu.c   Wed Oct 14 14:29:56 2020
(r366703)
+++ head/sys/dev/iommu/busdma_iommu.c   Wed Oct 14 14:51:11 2020
(r366704)
@@ -888,7 +888,7 @@ iommu_bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap
struct bus_dmamap_iommu *map;
struct iommu_ctx *ctx;
struct iommu_domain *domain;
-#if defined(__amd64__)
+#ifndef IOMMU_DOMAIN_UNLOAD_SLEEP
struct iommu_map_entries_tailq entries;
 #endif
 
@@ -898,13 +898,13 @@ iommu_bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap
domain = ctx->domain;
atomic_add_long(>unloads, 1);
 
-#if defined(__i386__)
+#if defined(IOMMU_DOMAIN_UNLOAD_SLEEP)
IOMMU_DOMAIN_LOCK(domain);
TAILQ_CONCAT(>unload_entries, >map_entries, dmamap_link);
IOMMU_DOMAIN_UNLOCK(domain);
taskqueue_enqueue(domain->iommu->delayed_taskqueue,
>unload_task);
-#else /* defined(__amd64__) */
+#else
TAILQ_INIT();
IOMMU_DOMAIN_LOCK(domain);
TAILQ_CONCAT(, >map_entries, dmamap_link);

Modified: head/sys/i386/include/iommu.h
==
--- head/sys/i386/include/iommu.h   Wed Oct 14 14:29:56 2020
(r366703)
+++ head/sys/i386/include/iommu.h   Wed Oct 14 14:51:11 2020
(r366704)
@@ -4,3 +4,5 @@
 /* $FreeBSD$ */
 
 #include 
+
+#defineIOMMU_DOMAIN_UNLOAD_SLEEP
___
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: r366703 - head/sys/crypto/skein/amd64

2020-10-14 Thread Adrian Chadd
Author: adrian
Date: Wed Oct 14 14:29:56 2020
New Revision: 366703
URL: https://svnweb.freebsd.org/changeset/base/366703

Log:
  [skein] Fix compilation on gnu assembler with gcc-6 and gcc-9
  
  For some reason I don't want to really understand, the following
  happens with gnu as.
  
  /home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S: 
Assembler messages:
  /home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:466: 
Error: found '(', expected: ')'
  /home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:466: 
Error: junk at end of line, first unrecognized character is `('
  /home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:795: 
Error: found '(', expected: ')'
  /home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:795: 
Error: junk at end of line, first unrecognized character is `('
  /home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:885: 
Error: non-constant expression in ".if" statement
  /home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:885: 
Error: non-constant expression in ".if" statement
  /home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:885: 
Error: non-constant expression in ".if" statement
  /home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:885: 
Error: non-constant expression in ".if" statement
  /home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:885: 
Error: non-constant expression in ".if" statement
  /home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:885: 
Error: non-constant expression in ".if" statement
  
  After an exhaustive search and experimentation at 11pm, I discovered that
  putting them in parentheses fixes the compilation.
  
  Ed pointed out that I could likely fix this in a bunch of other
  locations but I'd rather leave these alone until other options
  are enabled.
  
  Tested:
  
  * gcc-6, amd64
  
  Reviewed by:  emaste

Modified:
  head/sys/crypto/skein/amd64/skein_block_asm.S

Modified: head/sys/crypto/skein/amd64/skein_block_asm.S
==
--- head/sys/crypto/skein/amd64/skein_block_asm.S   Wed Oct 14 14:12:15 
2020(r366702)
+++ head/sys/crypto/skein/amd64/skein_block_asm.S   Wed Oct 14 14:29:56 
2020(r366703)
@@ -277,7 +277,7 @@ _STK_OFFS_  =   0   #starting offset f
 StackVarX_stk  ,8*(WCNT)#local context vars
 StackVarksTwk  ,8*3 #key schedule: tweak words
 StackVarksKey  ,8*(WCNT)+8  #key schedule: key   words
-  .if (SKEIN_ASM_UNROLL & (\BLK_BITS)) == 0
+  .if ((SKEIN_ASM_UNROLL) & (\BLK_BITS)) == 0
 StackVarksRot ,16*(\KS_CNT) #leave space for "rotation" to happen
   .endif
 StackVarWcopy  ,8*(WCNT)#copy of input block
@@ -749,7 +749,7 @@ C_label Skein_256_Unroll_Cnt
 # MACRO: eight rounds for 512-bit blocks
 #
 .macro R_512_FourRounds _RR_#RR = base round number (0 % 8)
-  .if (SKEIN_ASM_UNROLL & 512)
+  .if ((SKEIN_ASM_UNROLL) & 512)
 # here for fully unrolled case.
 _II_ = ((\_RR_)/4) + 1   #key injection counter
 R_512_OneRound  8, 9,10,11,12,13,14,15,%((\_RR_)+0),,,
@@ -978,7 +978,7 @@ rIdx_offs = tmpStk_1024
 movq   %\reg1 , xDebug_1024+8*\w1(%rsp)# (before inline key 
injection)
  .endif
 _II_ = ((\_RN0_)/4)+1   #injection count
- .if SKEIN_ASM_UNROLL & 1024   #here to do fully unrolled key injection
+ .if (SKEIN_ASM_UNROLL) & 1024   #here to do fully unrolled key injection
 addqksKey+ 8*((_II_+\w0) % 17)(%rsp),%\reg0
 addqksKey+ 8*((_II_+\w1) % 17)(%rsp),%\reg1
   .if \w1 == 13#tweak injection
___
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: r366702 - head/sys/dev/iommu

2020-10-14 Thread Ruslan Bukin
Author: br
Date: Wed Oct 14 14:12:15 2020
New Revision: 366702
URL: https://svnweb.freebsd.org/changeset/base/366702

Log:
  Add iommu_get_ctx_domain() that allows to get iommu domain for a given
  iommu context.
  
  Submitted by: andrew
  Sponsored by: Innovate DSbD

Modified:
  head/sys/dev/iommu/iommu.h
  head/sys/dev/iommu/iommu_gas.c

Modified: head/sys/dev/iommu/iommu.h
==
--- head/sys/dev/iommu/iommu.h  Wed Oct 14 13:39:50 2020(r366701)
+++ head/sys/dev/iommu/iommu.h  Wed Oct 14 14:12:15 2020(r366702)
@@ -234,6 +234,7 @@ int bus_dma_iommu_load_ident(bus_dma_tag_t dmat, bus_d
 
 bus_dma_tag_t iommu_get_dma_tag(device_t dev, device_t child);
 struct iommu_ctx *iommu_get_dev_ctx(device_t dev);
+struct iommu_domain *iommu_get_ctx_domain(struct iommu_ctx *ctx);
 
 SYSCTL_DECL(_hw_iommu);
 

Modified: head/sys/dev/iommu/iommu_gas.c
==
--- head/sys/dev/iommu/iommu_gas.c  Wed Oct 14 13:39:50 2020
(r366701)
+++ head/sys/dev/iommu/iommu_gas.c  Wed Oct 14 14:12:15 2020
(r366702)
@@ -208,6 +208,13 @@ iommu_gas_rb_remove(struct iommu_domain *domain, struc
RB_REMOVE(iommu_gas_entries_tree, >rb_root, entry);
 }
 
+struct iommu_domain *
+iommu_get_ctx_domain(struct iommu_ctx *ctx)
+{
+
+   return (ctx->domain);
+}
+
 void
 iommu_gas_init_domain(struct iommu_domain *domain)
 {
___
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: r366697 - head/usr.bin/xinstall

2020-10-14 Thread Mateusz Guzik
On 10/14/20, Alexander Richardson  wrote:
> On Wed, 14 Oct 2020 at 14:29, Mateusz Guzik  wrote:
>>
>> This should use copy_file_range (also available on Linux).
>>
>
> I agree. I even mentioned this in
> https://reviews.freebsd.org/D26041#589287.
> This change avoids the two unnecessary syscalls, but I agree that
> longer-term install should share the copy_file_range code with cp.
> The only thing that copy_file_range won't speed up is the check
> whether source and target are already identical.
>

So did a quick check with make install in bin/cp:

install  -s -o root -g wheel -m 555   cp /zoo/lynx4/bin/cp
install  -o root -g wheel -m 444  cp.debug /zoo/lynx4/usr/lib/debug/bin/cp.debug
install  -o root -g wheel -m 444 cp.1.gz  /zoo/lynx4/usr/share/man/man1/

None of these result in calling the compare routine.

Looking at truss output it seems the biggest win for these files would
be to avoid root:wheel translation.

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


Re: svn commit: r366697 - head/usr.bin/xinstall

2020-10-14 Thread Jessica Clarke
On 14 Oct 2020, at 14:28, Mateusz Guzik  wrote:
> 
> This should use copy_file_range (also available on Linux).

I assume this is a bootstrap tool and hence the system OS and version
is relevant. macOS does not have copy_file_range, and FreeBSD only has
it in -CURRENT so that would break building on 11.x and 12.x. So any
use would need to be guarded by preprocessor checks (and there are
still actively-supported Linux distributions out there that are based
on too-old versions of the kernel and/or glibc to include it).

(FYI macOS's equivalent is copyfile(3)... maybe one day it will adopt
the copy_file_range(2) interface too)

Jess

> On 10/14/20, Alex Richardson  wrote:
>> Author: arichardson
>> Date: Wed Oct 14 12:28:41 2020
>> New Revision: 366697
>> URL: https://svnweb.freebsd.org/changeset/base/366697
>> 
>> Log:
>>  install(1): Avoid unncessary fstatfs() calls and use mmap() based on size
>> 
>>  According to git blame the trymmap() function was added in 1996 to skip
>>  mmap() calls for NFS file systems. However, nowadays mmap() should be
>>  perfectly safe even on NFS. Importantly, onl ufs and cd9660 file systems
>>  were whitelisted so we don't use mmap() on ZFS. It also prevents the use
>>  of mmap() when bootstrapping from macOS/Linux since on those systems the
>>  trymmap() function was always returning zero due to the missing
>> MFSNAMELEN
>>  define.
>> 
>>  This change keeps the trymmap() function but changes it to check whether
>>  using mmap() can reduce the number of system calls that are required.
>>  Using mmap() only reduces the number of system calls if we need multiple
>> read()
>>  syscalls, i.e. if the file size is > MAXBSIZE. However, mmap() is more
>> expensive
>>  than read() so this sets the threshold at 4 fewer syscalls. Additionally,
>> for
>>  larger file size mmap() can significantly increase the number of page
>> faults,
>>  so avoid it in that case.
>> 
>>  It's unclear whether using mmap() is ever faster than a read with an
>> appropriate
>>  buffer size, but this change at least removes two unnecessary system
>> calls
>>  for every file that is installed.
>> 
>>  Reviewed By:markj
>>  Differential Revision: https://reviews.freebsd.org/D26041
>> 
>> Modified:
>>  head/usr.bin/xinstall/xinstall.c
>> 
>> Modified: head/usr.bin/xinstall/xinstall.c
>> ==
>> --- head/usr.bin/xinstall/xinstall.c Wed Oct 14 10:12:39 2020
>> (r366696)
>> +++ head/usr.bin/xinstall/xinstall.c Wed Oct 14 12:28:41 2020
>> (r366697)
>> @@ -148,7 +148,7 @@ static void  metadata_log(const char *, const char 
>> *, s
>>  const char *, const char *, off_t);
>> static int   parseid(const char *, id_t *);
>> static int   strip(const char *, int, const char *, char **);
>> -static int  trymmap(int);
>> +static int  trymmap(size_t);
>> static void  usage(void);
>> 
>> int
>> @@ -1087,7 +1087,7 @@ compare(int from_fd, const char *from_name __unused,
>> s
>>  if (do_digest)
>>  digest_init();
>>  done_compare = 0;
>> -if (trymmap(from_fd) && trymmap(to_fd)) {
>> +if (trymmap(from_len) && trymmap(to_len)) {
>>  p = mmap(NULL, from_len, PROT_READ, MAP_SHARED,
>>  from_fd, (off_t)0);
>>  if (p == MAP_FAILED)
>> @@ -1248,13 +1248,8 @@ copy(int from_fd, const char *from_name, int to_fd,
>> co
>> 
>>  digest_init();
>> 
>> -/*
>> - * Mmap and write if less than 8M (the limit is so we don't totally
>> - * trash memory on big files.  This is really a minor hack, but it
>> - * wins some CPU back.
>> - */
>>  done_copy = 0;
>> -if (size <= 8 * 1048576 && trymmap(from_fd) &&
>> +if (trymmap((size_t)size) &&
>>  (p = mmap(NULL, (size_t)size, PROT_READ, MAP_SHARED,
>>  from_fd, (off_t)0)) != MAP_FAILED) {
>>  nw = write(to_fd, p, size);
>> @@ -1523,20 +1518,23 @@ usage(void)
>>  *   return true (1) if mmap should be tried, false (0) if not.
>>  */
>> static int
>> -trymmap(int fd)
>> +trymmap(size_t filesize)
>> {
>> -/*
>> - * The ifdef is for bootstrapping - f_fstypename doesn't exist in
>> - * pre-Lite2-merge systems.
>> - */
>> -#ifdef MFSNAMELEN
>> -struct statfs stfs;
>> -
>> -if (fstatfs(fd, ) != 0)
>> -return (0);
>> -if (strcmp(stfs.f_fstypename, "ufs") == 0 ||
>> -strcmp(stfs.f_fstypename, "cd9660") == 0)
>> -return (1);
>> -#endif
>> -return (0);
>> +/*
>> + * This function existed to skip mmap() for NFS file systems whereas
>> + * nowadays mmap() should be perfectly safe. Nevertheless, using mmap()
>> + * only reduces the number of system calls if we need multiple read()
>> + * syscalls, i.e. if the file size is > MAXBSIZE. However, mmap() is
>> + * more expensive than read() so set the threshold at 4 fewer syscalls.
>> +   

svn commit: r366701 - head/sys/dev/iommu

2020-10-14 Thread Ruslan Bukin
Author: br
Date: Wed Oct 14 13:39:50 2020
New Revision: 366701
URL: https://svnweb.freebsd.org/changeset/base/366701

Log:
  Rename a header protection macro.
  
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/dev/iommu/iommu.h

Modified: head/sys/dev/iommu/iommu.h
==
--- head/sys/dev/iommu/iommu.h  Wed Oct 14 13:13:14 2020(r366700)
+++ head/sys/dev/iommu/iommu.h  Wed Oct 14 13:39:50 2020(r366701)
@@ -31,8 +31,8 @@
  * $FreeBSD$
  */
 
-#ifndef _SYS_IOMMU_H_
-#define _SYS_IOMMU_H_
+#ifndef _DEV_IOMMU_IOMMU_H_
+#define _DEV_IOMMU_IOMMU_H_
 
 /* Host or physical memory address, after translation. */
 typedef uint64_t iommu_haddr_t;
@@ -237,4 +237,4 @@ struct iommu_ctx *iommu_get_dev_ctx(device_t dev);
 
 SYSCTL_DECL(_hw_iommu);
 
-#endif /* !_SYS_IOMMU_H_ */
+#endif /* !_DEV_IOMMU_IOMMU_H_ */
___
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: r366697 - head/usr.bin/xinstall

2020-10-14 Thread Alexander Richardson
On Wed, 14 Oct 2020 at 14:29, Mateusz Guzik  wrote:
>
> This should use copy_file_range (also available on Linux).
>

I agree. I even mentioned this in https://reviews.freebsd.org/D26041#589287.
This change avoids the two unnecessary syscalls, but I agree that
longer-term install should share the copy_file_range code with cp.
The only thing that copy_file_range won't speed up is the check
whether source and target are already identical.

Alex

> On 10/14/20, Alex Richardson  wrote:
> > Author: arichardson
> > Date: Wed Oct 14 12:28:41 2020
> > New Revision: 366697
> > URL: https://svnweb.freebsd.org/changeset/base/366697
> >
> > Log:
> >   install(1): Avoid unncessary fstatfs() calls and use mmap() based on size
> >
> >   According to git blame the trymmap() function was added in 1996 to skip
> >   mmap() calls for NFS file systems. However, nowadays mmap() should be
> >   perfectly safe even on NFS. Importantly, onl ufs and cd9660 file systems
> >   were whitelisted so we don't use mmap() on ZFS. It also prevents the use
> >   of mmap() when bootstrapping from macOS/Linux since on those systems the
> >   trymmap() function was always returning zero due to the missing
> > MFSNAMELEN
> >   define.
> >
> >   This change keeps the trymmap() function but changes it to check whether
> >   using mmap() can reduce the number of system calls that are required.
> >   Using mmap() only reduces the number of system calls if we need multiple
> > read()
> >   syscalls, i.e. if the file size is > MAXBSIZE. However, mmap() is more
> > expensive
> >   than read() so this sets the threshold at 4 fewer syscalls. Additionally,
> > for
> >   larger file size mmap() can significantly increase the number of page
> > faults,
> >   so avoid it in that case.
> >
> >   It's unclear whether using mmap() is ever faster than a read with an
> > appropriate
> >   buffer size, but this change at least removes two unnecessary system
> > calls
> >   for every file that is installed.
> >
> >   Reviewed By:markj
> >   Differential Revision: https://reviews.freebsd.org/D26041
> >
> > Modified:
> >   head/usr.bin/xinstall/xinstall.c
> >
> > Modified: head/usr.bin/xinstall/xinstall.c
> > ==
> > --- head/usr.bin/xinstall/xinstall.c  Wed Oct 14 10:12:39 2020
> > (r366696)
> > +++ head/usr.bin/xinstall/xinstall.c  Wed Oct 14 12:28:41 2020
> > (r366697)
> > @@ -148,7 +148,7 @@ static void   metadata_log(const char *, const char 
> > *, s
> >   const char *, const char *, off_t);
> >  static int   parseid(const char *, id_t *);
> >  static int   strip(const char *, int, const char *, char **);
> > -static int   trymmap(int);
> > +static int   trymmap(size_t);
> >  static void  usage(void);
> >
> >  int
> > @@ -1087,7 +1087,7 @@ compare(int from_fd, const char *from_name __unused,
> > s
> >   if (do_digest)
> >   digest_init();
> >   done_compare = 0;
> > - if (trymmap(from_fd) && trymmap(to_fd)) {
> > + if (trymmap(from_len) && trymmap(to_len)) {
> >   p = mmap(NULL, from_len, PROT_READ, MAP_SHARED,
> >   from_fd, (off_t)0);
> >   if (p == MAP_FAILED)
> > @@ -1248,13 +1248,8 @@ copy(int from_fd, const char *from_name, int to_fd,
> > co
> >
> >   digest_init();
> >
> > - /*
> > -  * Mmap and write if less than 8M (the limit is so we don't totally
> > -  * trash memory on big files.  This is really a minor hack, but it
> > -  * wins some CPU back.
> > -  */
> >   done_copy = 0;
> > - if (size <= 8 * 1048576 && trymmap(from_fd) &&
> > + if (trymmap((size_t)size) &&
> >   (p = mmap(NULL, (size_t)size, PROT_READ, MAP_SHARED,
> >   from_fd, (off_t)0)) != MAP_FAILED) {
> >   nw = write(to_fd, p, size);
> > @@ -1523,20 +1518,23 @@ usage(void)
> >   *   return true (1) if mmap should be tried, false (0) if not.
> >   */
> >  static int
> > -trymmap(int fd)
> > +trymmap(size_t filesize)
> >  {
> > -/*
> > - * The ifdef is for bootstrapping - f_fstypename doesn't exist in
> > - * pre-Lite2-merge systems.
> > - */
> > -#ifdef MFSNAMELEN
> > - struct statfs stfs;
> > -
> > - if (fstatfs(fd, ) != 0)
> > - return (0);
> > - if (strcmp(stfs.f_fstypename, "ufs") == 0 ||
> > - strcmp(stfs.f_fstypename, "cd9660") == 0)
> > - return (1);
> > -#endif
> > - return (0);
> > + /*
> > +  * This function existed to skip mmap() for NFS file systems whereas
> > +  * nowadays mmap() should be perfectly safe. Nevertheless, using 
> > mmap()
> > +  * only reduces the number of system calls if we need multiple read()
> > +  * syscalls, i.e. if the file size is > MAXBSIZE. However, mmap() is
> > +  * more expensive than read() so set the threshold at 4 fewer 
> > syscalls.
> > +  * 

Re: svn commit: r366697 - head/usr.bin/xinstall

2020-10-14 Thread Mateusz Guzik
This should use copy_file_range (also available on Linux).

On 10/14/20, Alex Richardson  wrote:
> Author: arichardson
> Date: Wed Oct 14 12:28:41 2020
> New Revision: 366697
> URL: https://svnweb.freebsd.org/changeset/base/366697
>
> Log:
>   install(1): Avoid unncessary fstatfs() calls and use mmap() based on size
>
>   According to git blame the trymmap() function was added in 1996 to skip
>   mmap() calls for NFS file systems. However, nowadays mmap() should be
>   perfectly safe even on NFS. Importantly, onl ufs and cd9660 file systems
>   were whitelisted so we don't use mmap() on ZFS. It also prevents the use
>   of mmap() when bootstrapping from macOS/Linux since on those systems the
>   trymmap() function was always returning zero due to the missing
> MFSNAMELEN
>   define.
>
>   This change keeps the trymmap() function but changes it to check whether
>   using mmap() can reduce the number of system calls that are required.
>   Using mmap() only reduces the number of system calls if we need multiple
> read()
>   syscalls, i.e. if the file size is > MAXBSIZE. However, mmap() is more
> expensive
>   than read() so this sets the threshold at 4 fewer syscalls. Additionally,
> for
>   larger file size mmap() can significantly increase the number of page
> faults,
>   so avoid it in that case.
>
>   It's unclear whether using mmap() is ever faster than a read with an
> appropriate
>   buffer size, but this change at least removes two unnecessary system
> calls
>   for every file that is installed.
>
>   Reviewed By:markj
>   Differential Revision: https://reviews.freebsd.org/D26041
>
> Modified:
>   head/usr.bin/xinstall/xinstall.c
>
> Modified: head/usr.bin/xinstall/xinstall.c
> ==
> --- head/usr.bin/xinstall/xinstall.c  Wed Oct 14 10:12:39 2020
> (r366696)
> +++ head/usr.bin/xinstall/xinstall.c  Wed Oct 14 12:28:41 2020
> (r366697)
> @@ -148,7 +148,7 @@ static void   metadata_log(const char *, const char 
> *, s
>   const char *, const char *, off_t);
>  static int   parseid(const char *, id_t *);
>  static int   strip(const char *, int, const char *, char **);
> -static int   trymmap(int);
> +static int   trymmap(size_t);
>  static void  usage(void);
>
>  int
> @@ -1087,7 +1087,7 @@ compare(int from_fd, const char *from_name __unused,
> s
>   if (do_digest)
>   digest_init();
>   done_compare = 0;
> - if (trymmap(from_fd) && trymmap(to_fd)) {
> + if (trymmap(from_len) && trymmap(to_len)) {
>   p = mmap(NULL, from_len, PROT_READ, MAP_SHARED,
>   from_fd, (off_t)0);
>   if (p == MAP_FAILED)
> @@ -1248,13 +1248,8 @@ copy(int from_fd, const char *from_name, int to_fd,
> co
>
>   digest_init();
>
> - /*
> -  * Mmap and write if less than 8M (the limit is so we don't totally
> -  * trash memory on big files.  This is really a minor hack, but it
> -  * wins some CPU back.
> -  */
>   done_copy = 0;
> - if (size <= 8 * 1048576 && trymmap(from_fd) &&
> + if (trymmap((size_t)size) &&
>   (p = mmap(NULL, (size_t)size, PROT_READ, MAP_SHARED,
>   from_fd, (off_t)0)) != MAP_FAILED) {
>   nw = write(to_fd, p, size);
> @@ -1523,20 +1518,23 @@ usage(void)
>   *   return true (1) if mmap should be tried, false (0) if not.
>   */
>  static int
> -trymmap(int fd)
> +trymmap(size_t filesize)
>  {
> -/*
> - * The ifdef is for bootstrapping - f_fstypename doesn't exist in
> - * pre-Lite2-merge systems.
> - */
> -#ifdef MFSNAMELEN
> - struct statfs stfs;
> -
> - if (fstatfs(fd, ) != 0)
> - return (0);
> - if (strcmp(stfs.f_fstypename, "ufs") == 0 ||
> - strcmp(stfs.f_fstypename, "cd9660") == 0)
> - return (1);
> -#endif
> - return (0);
> + /*
> +  * This function existed to skip mmap() for NFS file systems whereas
> +  * nowadays mmap() should be perfectly safe. Nevertheless, using mmap()
> +  * only reduces the number of system calls if we need multiple read()
> +  * syscalls, i.e. if the file size is > MAXBSIZE. However, mmap() is
> +  * more expensive than read() so set the threshold at 4 fewer syscalls.
> +  * Additionally, for larger file size mmap() can significantly increase
> +  * the number of page faults, so avoid it in that case.
> +  *
> +  * Note: the 8MB limit is not based on any meaningful benchmarking
> +  * results, it is simply reusing the same value that was used before
> +  * and also matches bin/cp.
> +  *
> +  * XXX: Maybe we shouldn't bother with mmap() at all, since we use
> +  * MAXBSIZE the syscall overhead of read() shouldn't be too high?
> +  */
> + return (filesize > 4 * MAXBSIZE && filesize < 8 * 1024 * 1024);
>  }
> 

svn commit: r366700 - head/stand/efi/loader

2020-10-14 Thread Michal Meloun
Author: mmel
Date: Wed Oct 14 13:13:14 2020
New Revision: 366700
URL: https://svnweb.freebsd.org/changeset/base/366700

Log:
  Add 'netserver' command to EFI loader.
  
  In some environments is difficult to access bootp/dhcp
  configuration as "standard user". Add a command that allows to set
  or display the URI of the network server used as "net:" device.
  Currently only tftp and nfs protocols are supported.
  
  Typical usage pattern is:
  netserver tftp://192.168.168.1/path_to_obj_dir/arm.armv7/sys/GENERIC/
  boot net:kernel
  
  Reviewed by:  imp, kevans
  MFC after:4 weeks
  Differential Revision: https://reviews.freebsd.org/D26736

Modified:
  head/stand/efi/loader/main.c

Modified: head/stand/efi/loader/main.c
==
--- head/stand/efi/loader/main.cWed Oct 14 12:28:54 2020
(r366699)
+++ head/stand/efi/loader/main.cWed Oct 14 13:13:14 2020
(r366700)
@@ -40,10 +40,14 @@ __FBSDID("$FreeBSD$");
 #include 
 #endif
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -1594,3 +1598,34 @@ command_chain(int argc, char *argv[])
 }
 
 COMMAND_SET(chain, "chain", "chain load file", command_chain);
+
+extern struct in_addr servip;
+static int
+command_netserver(int argc, char *argv[])
+{
+   char *proto;
+   n_long rootaddr;
+
+   if (argc > 2) {
+   command_errmsg = "wrong number of arguments";
+   return (CMD_ERROR);
+   }
+   if (argc < 2) {
+   proto = netproto == NET_TFTP ? "tftp://; : "nfs://";
+   printf("Netserver URI: %s%s%s\n", proto, intoa(rootip.s_addr),
+   rootpath);
+   return (CMD_OK);
+   }
+   if (argc == 2) {
+   strncpy(rootpath, argv[1], sizeof(rootpath));
+   rootpath[sizeof(rootpath) -1] = '\0';
+   if ((rootaddr = net_parse_rootpath()) != INADDR_NONE)
+   servip.s_addr = rootip.s_addr = rootaddr;
+   return (CMD_OK);
+   }
+   return (CMD_ERROR); /* not reached */
+
+}
+
+COMMAND_SET(netserver, "netserver", "change or display netserver URI",
+command_netserver);
___
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: r366698 - head/sys/modules

2020-10-14 Thread Alex Richardson
Author: arichardson
Date: Wed Oct 14 12:28:48 2020
New Revision: 366698
URL: https://svnweb.freebsd.org/changeset/base/366698

Log:
  Don't build the malo module with clang 10
  
  Compiling it with LLVM 10 triggers https://bugs.llvm.org/show_bug.cgi?id=44351
  While LLVM 11 is the default compiler, I regularly build with
  CROSS_TOOLCHAIN=llvm10 or use system packages for clang on Linux/macOS and
  those have not been updated to 11 yet.

Modified:
  head/sys/modules/Makefile

Modified: head/sys/modules/Makefile
==
--- head/sys/modules/Makefile   Wed Oct 14 12:28:41 2020(r366697)
+++ head/sys/modules/Makefile   Wed Oct 14 12:28:48 2020(r366698)
@@ -224,7 +224,7 @@ SUBDIR= \
mac_seeotheruids \
mac_stub \
mac_test \
-   malo \
+   ${_malo} \
md \
mdio \
mem \
@@ -802,6 +802,12 @@ _cloudabi64=   cloudabi64
 .if ${MACHINE_ARCH:Marmv[67]*} != "" || ${MACHINE_CPUARCH} == "aarch64"
 _bcm283x_clkman=  bcm283x_clkman
 _bcm283x_pwm=  bcm283x_pwm
+.endif
+
+.if !(${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} < 11)
+# LLVM 10 crashes when building if_malo_pci.c, fixed in LLVM11:
+# https://bugs.llvm.org/show_bug.cgi?id=44351
+_malo= malo
 .endif
 
 SUBDIR+=${MODULES_EXTRA}
___
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: r366699 - in head: kerberos5/include tools/build tools/build/cross-build/include/common/sys

2020-10-14 Thread Alex Richardson
Author: arichardson
Date: Wed Oct 14 12:28:54 2020
New Revision: 366699
URL: https://svnweb.freebsd.org/changeset/base/366699

Log:
  Fix more -Wundef warnings during bootstrap

Modified:
  head/kerberos5/include/config.h
  head/tools/build/Makefile
  head/tools/build/cross-build/include/common/sys/cdefs.h

Modified: head/kerberos5/include/config.h
==
--- head/kerberos5/include/config.h Wed Oct 14 12:28:48 2020
(r366698)
+++ head/kerberos5/include/config.h Wed Oct 14 12:28:54 2020
(r366699)
@@ -975,7 +975,7 @@ static /**/const char *const rcsid[] = { (const char *
 #define HAVE_STRVISX 1
 
 /* Define to 1 if you have the `svis' function. */
-/* #undef HAVE_SVIS */
+#define HAVE_SVIS 1
 
 /* Define if you have the function `swab'. */
 #define HAVE_SWAB 1

Modified: head/tools/build/Makefile
==
--- head/tools/build/Makefile   Wed Oct 14 12:28:48 2020(r366698)
+++ head/tools/build/Makefile   Wed Oct 14 12:28:54 2020(r366699)
@@ -57,8 +57,8 @@ _WITH_STRSVIS!=   grep -c strsvis ${HOST_INCLUDE_ROOT}/v
 .PATH: ${.CURDIR}/../../contrib/libc-vis
 INCS+= vis.h
 SRCS+= vis.c unvis.c
-CFLAGS.vis.c+= -I${.CURDIR}/../../contrib/libc-vis
-CFLAGS.unvis.c+=   -I${.CURDIR}/../../contrib/libc-vis
+CFLAGS.vis.c+= -I${.CURDIR}/../../contrib/libc-vis -DHAVE_VIS=0 -DHAVE_SVIS=0
+CFLAGS.unvis.c+=   -I${.CURDIR}/../../contrib/libc-vis -DHAVE_VIS=0 
-DHAVE_SVIS=0
 .endif
 
 _WITH_REALLOCARRAY!= grep -c reallocarray ${HOST_INCLUDE_ROOT}/stdlib.h || true

Modified: head/tools/build/cross-build/include/common/sys/cdefs.h
==
--- head/tools/build/cross-build/include/common/sys/cdefs.h Wed Oct 14 
12:28:48 2020(r366698)
+++ head/tools/build/cross-build/include/common/sys/cdefs.h Wed Oct 14 
12:28:54 2020(r366699)
@@ -190,11 +190,6 @@ typedef unsigned short u_short;
 typedef unsigned int u_int;
 typedef unsigned long u_long;
 
-/* This is needed so that BSNMP doesn't redeclare an incompatible version */
-#define HAVE_STRLCPY 1
-/* The compiler supports __func__ */
-#define HAVE_DECL___FUNC__ 1
-
 /* On MacOS __CONCAT is defined as x ## y, which won't expand macros */
 #undef __CONCAT
 #define __CONCAT1(x, y) x##y
___
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: r366697 - head/usr.bin/xinstall

2020-10-14 Thread Alex Richardson
Author: arichardson
Date: Wed Oct 14 12:28:41 2020
New Revision: 366697
URL: https://svnweb.freebsd.org/changeset/base/366697

Log:
  install(1): Avoid unncessary fstatfs() calls and use mmap() based on size
  
  According to git blame the trymmap() function was added in 1996 to skip
  mmap() calls for NFS file systems. However, nowadays mmap() should be
  perfectly safe even on NFS. Importantly, onl ufs and cd9660 file systems
  were whitelisted so we don't use mmap() on ZFS. It also prevents the use
  of mmap() when bootstrapping from macOS/Linux since on those systems the
  trymmap() function was always returning zero due to the missing MFSNAMELEN
  define.
  
  This change keeps the trymmap() function but changes it to check whether
  using mmap() can reduce the number of system calls that are required.
  Using mmap() only reduces the number of system calls if we need multiple 
read()
  syscalls, i.e. if the file size is > MAXBSIZE. However, mmap() is more 
expensive
  than read() so this sets the threshold at 4 fewer syscalls. Additionally, for
  larger file size mmap() can significantly increase the number of page faults,
  so avoid it in that case.
  
  It's unclear whether using mmap() is ever faster than a read with an 
appropriate
  buffer size, but this change at least removes two unnecessary system calls
  for every file that is installed.
  
  Reviewed By:  markj
  Differential Revision: https://reviews.freebsd.org/D26041

Modified:
  head/usr.bin/xinstall/xinstall.c

Modified: head/usr.bin/xinstall/xinstall.c
==
--- head/usr.bin/xinstall/xinstall.cWed Oct 14 10:12:39 2020
(r366696)
+++ head/usr.bin/xinstall/xinstall.cWed Oct 14 12:28:41 2020
(r366697)
@@ -148,7 +148,7 @@ static void metadata_log(const char *, const char *, s
const char *, const char *, off_t);
 static int parseid(const char *, id_t *);
 static int strip(const char *, int, const char *, char **);
-static int trymmap(int);
+static int trymmap(size_t);
 static voidusage(void);
 
 int
@@ -1087,7 +1087,7 @@ compare(int from_fd, const char *from_name __unused, s
if (do_digest)
digest_init();
done_compare = 0;
-   if (trymmap(from_fd) && trymmap(to_fd)) {
+   if (trymmap(from_len) && trymmap(to_len)) {
p = mmap(NULL, from_len, PROT_READ, MAP_SHARED,
from_fd, (off_t)0);
if (p == MAP_FAILED)
@@ -1248,13 +1248,8 @@ copy(int from_fd, const char *from_name, int to_fd, co
 
digest_init();
 
-   /*
-* Mmap and write if less than 8M (the limit is so we don't totally
-* trash memory on big files.  This is really a minor hack, but it
-* wins some CPU back.
-*/
done_copy = 0;
-   if (size <= 8 * 1048576 && trymmap(from_fd) &&
+   if (trymmap((size_t)size) &&
(p = mmap(NULL, (size_t)size, PROT_READ, MAP_SHARED,
from_fd, (off_t)0)) != MAP_FAILED) {
nw = write(to_fd, p, size);
@@ -1523,20 +1518,23 @@ usage(void)
  * return true (1) if mmap should be tried, false (0) if not.
  */
 static int
-trymmap(int fd)
+trymmap(size_t filesize)
 {
-/*
- * The ifdef is for bootstrapping - f_fstypename doesn't exist in
- * pre-Lite2-merge systems.
- */
-#ifdef MFSNAMELEN
-   struct statfs stfs;
-
-   if (fstatfs(fd, ) != 0)
-   return (0);
-   if (strcmp(stfs.f_fstypename, "ufs") == 0 ||
-   strcmp(stfs.f_fstypename, "cd9660") == 0)
-   return (1);
-#endif
-   return (0);
+   /*
+* This function existed to skip mmap() for NFS file systems whereas
+* nowadays mmap() should be perfectly safe. Nevertheless, using mmap()
+* only reduces the number of system calls if we need multiple read()
+* syscalls, i.e. if the file size is > MAXBSIZE. However, mmap() is
+* more expensive than read() so set the threshold at 4 fewer syscalls.
+* Additionally, for larger file size mmap() can significantly increase
+* the number of page faults, so avoid it in that case.
+*
+* Note: the 8MB limit is not based on any meaningful benchmarking
+* results, it is simply reusing the same value that was used before
+* and also matches bin/cp.
+*
+* XXX: Maybe we shouldn't bother with mmap() at all, since we use
+* MAXBSIZE the syscall overhead of read() shouldn't be too high?
+*/
+   return (filesize > 4 * MAXBSIZE && filesize < 8 * 1024 * 1024);
 }
___
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: r366696 - head/sys/dev/cxgbe/common

2020-10-14 Thread Navdeep Parhar
Author: np
Date: Wed Oct 14 10:12:39 2020
New Revision: 366696
URL: https://svnweb.freebsd.org/changeset/base/366696

Log:
  cxgbe(4): Do not request FEC when requesting speeds that don't have FEC.
  
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/common/t4_hw.c

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==
--- head/sys/dev/cxgbe/common/t4_hw.c   Wed Oct 14 09:22:54 2020
(r366695)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Wed Oct 14 10:12:39 2020
(r366696)
@@ -3915,7 +3915,7 @@ int t4_link_l1cfg(struct adapter *adap, unsigned int m
speed = fwcap_top_speed(lc->pcaps);
 
fec = 0;
-   if (fec_supported(lc->pcaps)) {
+   if (fec_supported(speed)) {
if (lc->requested_fec == FEC_AUTO) {
if (lc->pcaps & FW_PORT_CAP32_FORCE_FEC) {
if (speed & FW_PORT_CAP32_SPEED_100G) {
___
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: r366695 - in head: share/man/man4 sys/netinet sys/sys

2020-10-14 Thread Andrey V. Elsukov
Author: ae
Date: Wed Oct 14 09:22:54 2020
New Revision: 366695
URL: https://svnweb.freebsd.org/changeset/base/366695

Log:
  Implement SIOCGIFALIAS.
  
  It is lightweight way to check if an IPv4 address exists.
  
  Submitted by: Roy Marples
  Reviewed by:  gnn, melifaro
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D26636

Modified:
  head/share/man/man4/netintro.4
  head/sys/netinet/in.c
  head/sys/sys/sockio.h

Modified: head/share/man/man4/netintro.4
==
--- head/share/man/man4/netintro.4  Wed Oct 14 08:04:39 2020
(r366694)
+++ head/share/man/man4/netintro.4  Wed Oct 14 09:22:54 2020
(r366695)
@@ -28,7 +28,7 @@
 .\" @(#)netintro.4 8.2 (Berkeley) 11/30/93
 .\" $FreeBSD$
 .\"
-.Dd January 26, 2012
+.Dd October 14, 2020
 .Dt NETINTRO 4
 .Os
 .Sh NAME
@@ -349,6 +349,13 @@ multiple masks or destination addresses, and also adop
 convention that specification of the default address means
 to delete the first address for the interface belonging to
 the address family in which the original socket was opened.
+.It Dv SIOCGIFALIAS
+This request provides means to get additional addresses
+together with netmask and broadcast/destination from an
+interface.
+It also uses the
+.Vt ifaliasreq
+structure.
 .It Dv SIOCGIFCONF
 Get interface configuration list.
 This request takes an

Modified: head/sys/netinet/in.c
==
--- head/sys/netinet/in.c   Wed Oct 14 08:04:39 2020(r366694)
+++ head/sys/netinet/in.c   Wed Oct 14 09:22:54 2020(r366695)
@@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
 
 static int in_aifaddr_ioctl(u_long, caddr_t, struct ifnet *, struct thread *);
 static int in_difaddr_ioctl(u_long, caddr_t, struct ifnet *, struct thread *);
+static int in_gifaddr_ioctl(u_long, caddr_t, struct ifnet *, struct thread *);
 
 static voidin_socktrim(struct sockaddr_in *);
 static voidin_purgemaddrs(struct ifnet *);
@@ -237,6 +238,11 @@ in_control(struct socket *so, u_long cmd, caddr_t data
case SIOCGIFDSTADDR:
case SIOCGIFNETMASK:
break;
+   case SIOCGIFALIAS:
+   sx_xlock(_control_sx);
+   error = in_gifaddr_ioctl(cmd, data, ifp, td);
+   sx_xunlock(_control_sx);
+   return (error);
case SIOCDIFADDR:
sx_xlock(_control_sx);
error = in_difaddr_ioctl(cmd, data, ifp, td);
@@ -646,6 +652,60 @@ in_difaddr_ioctl(u_long cmd, caddr_t data, struct ifne
IFADDR_EVENT_DEL);
ifa_free(>ia_ifa);  /* in_ifaddrhead */
 
+   return (0);
+}
+
+static int
+in_gifaddr_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp, struct thread 
*td)
+{
+   struct in_aliasreq *ifra = (struct in_aliasreq *)data;
+   const struct sockaddr_in *addr = >ifra_addr;
+   struct epoch_tracker et;
+   struct ifaddr *ifa;
+   struct in_ifaddr *ia;
+
+   /*
+* ifra_addr must be present and be of INET family.
+*/
+   if (addr->sin_len != sizeof(struct sockaddr_in) ||
+   addr->sin_family != AF_INET)
+   return (EINVAL);
+
+   /*
+* See whether address exist.
+*/
+   ia = NULL;
+   NET_EPOCH_ENTER(et);
+   CK_STAILQ_FOREACH(ifa, >if_addrhead, ifa_link) {
+   struct in_ifaddr *it;
+
+   if (ifa->ifa_addr->sa_family != AF_INET)
+   continue;
+
+   it = (struct in_ifaddr *)ifa;
+   if (it->ia_addr.sin_addr.s_addr == addr->sin_addr.s_addr &&
+   prison_check_ip4(td->td_ucred, >sin_addr) == 0) {
+   ia = it;
+   break;
+   }
+   }
+   if (ia == NULL) {
+   NET_EPOCH_EXIT(et);
+   return (EADDRNOTAVAIL);
+   }
+
+   ifra->ifra_mask = ia->ia_sockmask;
+   if ((ifp->if_flags & IFF_POINTOPOINT) &&
+   ia->ia_dstaddr.sin_family == AF_INET)
+   ifra->ifra_dstaddr = ia->ia_dstaddr;
+   else if ((ifp->if_flags & IFF_BROADCAST) &&
+   ia->ia_broadaddr.sin_family == AF_INET)
+   ifra->ifra_broadaddr = ia->ia_broadaddr;
+   else
+   memset(>ifra_broadaddr, 0,
+   sizeof(ifra->ifra_broadaddr));
+
+   NET_EPOCH_EXIT(et);
return (0);
 }
 

Modified: head/sys/sys/sockio.h
==
--- head/sys/sys/sockio.h   Wed Oct 14 08:04:39 2020(r366694)
+++ head/sys/sys/sockio.h   Wed Oct 14 09:22:54 2020(r366695)
@@ -84,6 +84,7 @@
 #defineSIOCGIFDESCR_IOWR('i', 42, struct ifreq)/* get ifnet 
descr */ 
 #defineSIOCAIFADDR  _IOW('i', 43, struct ifaliasreq)/* add/chg IF 
alias */
 #defineSIOCGIFDATA  _IOW('i', 44, 

svn commit: r366694 - head/sys/dev/cxgbe/cudbg

2020-10-14 Thread Navdeep Parhar
Author: np
Date: Wed Oct 14 08:04:39 2020
New Revision: 366694
URL: https://svnweb.freebsd.org/changeset/base/366694

Log:
  cxgbe(4): unimplemented cudbg routines should return the correct
  internal error code and not an errno.
  
  Submitted by: Krishnamraju Eraparaju @ Chelsio
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/cudbg/cudbg_lib.c

Modified: head/sys/dev/cxgbe/cudbg/cudbg_lib.c
==
--- head/sys/dev/cxgbe/cudbg/cudbg_lib.cWed Oct 14 06:25:55 2020
(r366693)
+++ head/sys/dev/cxgbe/cudbg/cudbg_lib.cWed Oct 14 08:04:39 2020
(r366694)
@@ -2027,7 +2027,7 @@ err1:
 err:
return rc;
 #endif
-   return (EDOOFUS);
+   return (CUDBG_STATUS_NOT_IMPLEMENTED);
 }
 /* CIM OBQ */
 
@@ -2664,7 +2664,7 @@ err1:
 err:
return rc;
 #endif
-   return (EDOOFUS);
+   return (CUDBG_STATUS_NOT_IMPLEMENTED);
 }
 
 static void collect_mem_info(struct cudbg_init *pdbg_init,
@@ -3130,7 +3130,7 @@ err1:
 err:
return rc;
 #endif
-   return (EDOOFUS);
+   return (CUDBG_STATUS_NOT_IMPLEMENTED);
 }
 
 static int collect_pbt_tables(struct cudbg_init *pdbg_init,
@@ -4450,5 +4450,5 @@ err1:
 err:
return rc;
 #endif
-   return (EDOOFUS);
+   return (CUDBG_STATUS_NOT_IMPLEMENTED);
 }
___
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"