Re: svn commit: r347984 - in head/sys: amd64/vmm/io arm/allwinner arm/allwinner/a10 arm/allwinner/clkng arm/arm arm/broadcom/bcm2835 arm/freescale/imx arm/mv arm/mv/armada arm/nvidia arm/nvidia/tegra1

2019-05-20 Thread Michael Tuexen
> On 20. May 2019, at 02:38, Conrad Meyer  wrote:
> 
> Author: cem
> Date: Mon May 20 00:38:23 2019
> New Revision: 347984
> URL: https://svnweb.freebsd.org/changeset/base/347984
> 
> Log:
>  Extract eventfilter declarations to sys/_eventfilter.h
> 
>  This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h"
>  in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces header
>  pollution substantially.
> 
>  EVENTHANDLER_DECLARE and EVENTHANDLER_LIST_DECLAREs were moved out of .c
>  files into appropriate headers (e.g., sys/proc.h, powernv/opal.h).
> 
>  As a side effect of reduced header pollution, many .c files and headers no
>  longer contain needed definitions.  The remainder of the patch addresses
>  adding appropriate includes to fix those files.
> 
>  LOCK_DEBUG and LOCK_FILE_LINE_ARG are moved to sys/_lock.h, as required by
>  sys/mutex.h since r326106 (but silently protected by header pollution prior
>  to this change).
> 
>  No functional change (intended).  Of course, any out of tree modules that
>  relied on header pollution for sys/eventhandler.h, sys/lock.h, or
>  sys/mutex.h inclusion need to be fixed.  __FreeBSD_version has been bumped.
This breaks compiling kernels having the options

options KCOV# Kernel Coverage Sanitizer
options COVERAGE

enabled.

sys/kern/kern_kcov.c also needs to include sys/eventhandler.h

Best regards
Michael
> 
> Added:
>  head/sys/sys/_eventhandler.h   (contents, props changed)
> Modified:
>  head/sys/amd64/vmm/io/iommu.c
>  head/sys/arm/allwinner/a10/a10_intc.c
>  head/sys/arm/allwinner/a10_dmac.c
>  head/sys/arm/allwinner/a31_dmac.c
>  head/sys/arm/allwinner/aw_ccu.c
>  head/sys/arm/allwinner/aw_reset.c
>  head/sys/arm/allwinner/aw_rsb.c
>  head/sys/arm/allwinner/aw_spi.c
>  head/sys/arm/allwinner/aw_thermal.c
>  head/sys/arm/allwinner/aw_wdog.c
>  head/sys/arm/allwinner/clkng/aw_ccung.c
>  head/sys/arm/arm/machdep.c
>  head/sys/arm/arm/pl190.c
>  head/sys/arm/broadcom/bcm2835/bcm2835_rng.c
>  head/sys/arm/broadcom/bcm2835/bcm2835_wdog.c
>  head/sys/arm/broadcom/bcm2835/bcm2836.c
>  head/sys/arm/freescale/imx/imx_wdog.c
>  head/sys/arm/mv/armada/thermal.c
>  head/sys/arm/mv/armada/wdt.c
>  head/sys/arm/mv/mv_spi.c
>  head/sys/arm/mv/timer.c
>  head/sys/arm/nvidia/tegra124/tegra124_machdep.c
>  head/sys/arm/nvidia/tegra124/tegra124_pmc.c
>  head/sys/arm/nvidia/tegra_xhci.c
>  head/sys/arm/ti/ti_pruss.c
>  head/sys/arm/ti/ti_wdt.c
>  head/sys/arm/versatile/versatile_pci.c
>  head/sys/arm/versatile/versatile_sic.c
>  head/sys/arm64/arm64/gicv3_its.c
>  head/sys/arm64/arm64/machdep.c
>  head/sys/arm64/coresight/coresight.c
>  head/sys/arm64/rockchip/clk/rk_cru.c
>  head/sys/cam/cam_periph.h
>  head/sys/cam/ctl/ctl_ha.c
>  head/sys/cddl/compat/opensolaris/kern/opensolaris.c
>  head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
>  head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_arm.c
>  head/sys/crypto/aesni/aesni.c
>  head/sys/crypto/armv8/armv8_crypto.c
>  head/sys/crypto/blake2/blake2_cryptodev.c
>  head/sys/crypto/ccp/ccp.c
>  head/sys/crypto/ccp/ccp_hardware.c
>  head/sys/ddb/db_command.c
>  head/sys/dev/acpi_support/acpi_panasonic.c
>  head/sys/dev/acpica/acpi.c
>  head/sys/dev/acpica/acpi_lid.c
>  head/sys/dev/acpica/acpi_thermal.c
>  head/sys/dev/acpica/acpi_video.c
>  head/sys/dev/acpica/acpivar.h
>  head/sys/dev/adb/adb_kbd.c
>  head/sys/dev/adb/adb_mouse.c
>  head/sys/dev/amdsbwd/amdsbwd.c
>  head/sys/dev/atkbdc/psm.c
>  head/sys/dev/cardbus/cardbus.c
>  head/sys/dev/cmx/cmx.c
>  head/sys/dev/coretemp/coretemp.c
>  head/sys/dev/cxgbe/cxgbei/cxgbei.c
>  head/sys/dev/cxgbe/cxgbei/icl_cxgbei.c
>  head/sys/dev/cxgbe/tom/t4_tls.c
>  head/sys/dev/dcons/dcons_crom.c
>  head/sys/dev/dcons/dcons_os.c
>  head/sys/dev/dcons/dcons_os.h
>  head/sys/dev/evdev/evdev_private.h
>  head/sys/dev/extres/syscon/syscon_generic.c
>  head/sys/dev/firewire/firewire.c
>  head/sys/dev/firewire/fwohci.c
>  head/sys/dev/ichwd/ichwd.c
>  head/sys/dev/ida/ida_disk.c
>  head/sys/dev/ida/ida_pci.c
>  head/sys/dev/iir/iir_ctrl.c
>  head/sys/dev/ioat/ioat.c
>  head/sys/dev/ipmi/ipmi.c
>  head/sys/dev/ipmi/ipmi_opal.c
>  head/sys/dev/ips/ips.c
>  head/sys/dev/iscsi/icl_soft_proxy.c
>  head/sys/dev/iscsi_initiator/iscsivar.h
>  head/sys/dev/iwm/if_iwm_notif_wait.c
>  head/sys/dev/led/led.c
>  head/sys/dev/liquidio/lio_bsd.h
>  head/sys/dev/mfi/mfi_disk.c
>  head/sys/dev/mfi/mfi_pci.c
>  head/sys/dev/mfi/mfi_syspd.c
>  head/sys/dev/mlx/mlxvar.h
>  head/sys/dev/mmc/host/dwmmc.c
>  head/sys/dev/mpr/mprvar.h
>  head/sys/dev/mps/mpsvar.h
>  head/sys/dev/mrsas/mrsas.h
>  head/sys/dev/nmdm/nmdm.c
>  head/sys/dev/ntb/if_ntb/if_ntb.c
>  head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c
>  head/sys/dev/ow/ow.c
>  head/sys/dev/pccard/pccard.c
>  head/sys/dev/pci/pci.c
>  head/sys/dev/pci/pci_iov.c
>  head/sys/dev/pci/pci_pci.c
>  head/sys/dev/pci/pcivar.h
>  head/sys/dev/scc/scc_core.c
>  head/sys/dev/scc/scc_dev_quicc.c
>  head/sys/dev/scc/scc_dev_sab8

Re: svn commit: r347533 - in head/sys: compat/linux modules/linux_common

2019-05-20 Thread Dmitry Chagin
вс, 19 мая 2019 г. в 20:05, Tijl Coosemans :

> On Mon, 13 May 2019 17:48:16 + (UTC) Dmitry Chagin
>  wrote:
> > Author: dchagin
> > Date: Mon May 13 17:48:16 2019
> > New Revision: 347533
> > URL: https://svnweb.freebsd.org/changeset/base/347533
> >
> > Log:
> >   Our bsd_to_linux_sockaddr() and linux_to_bsd_sockaddr() functions
> >   alter the userspace sockaddr to convert the format between linux and
> BSD versions.
> >   That's the minimum 3 of copyin/copyout operations for one syscall.
> >
> >   Also some syscall uses linux_sa_put() and linux_getsockaddr() when load
> >   sockaddr to userspace or from userspace accordingly.
> >
> >   To avoid this chaos, especially converting sockaddr in the userspace,
> >   rewrite these 4 functions to convert sockaddr only in kernel and leave
> >   only 2 of this functions.
> >
> >   Also in order to reduce duplication between MD parts of the
> Linuxulator put
> >   struct sockaddr conversion functions that are MI out into linux_common
> module.
> >
> >   PR: 232920
> >   MFC after:  2 weeks
> >   Differential Revision:  https://reviews.freebsd.org/D20157
> >
> > Modified:
> >   head/sys/compat/linux/linux.c
> >   head/sys/compat/linux/linux.h
> >   head/sys/compat/linux/linux_common.h
> >   head/sys/compat/linux/linux_socket.c
> >   head/sys/compat/linux/linux_socket.h
> >   head/sys/modules/linux_common/Makefile
> >
> > Modified: head/sys/compat/linux/linux_socket.c
> >
> ==
> > --- head/sys/compat/linux/linux_socket.c  Mon May 13 16:38:48 2019
>   (r347532)
> > +++ head/sys/compat/linux/linux_socket.c  Mon May 13 17:48:16 2019
>   (r347533)
> > @@ -1282,6 +1110,8 @@ linux_recvmsg_common(struct thread *td, l_int s,
> struc
> >   struct mbuf *control = NULL;
> >   struct mbuf **controlp;
> >   struct timeval *ftmvl;
> > + struct l_sockaddr *lsa;
> > + struct sockaddr *sa;
> >   l_timeval ltmvl;
> >   caddr_t outbuf;
> >   void *data;
> > @@ -1305,36 +1135,34 @@ linux_recvmsg_common(struct thread *td, l_int s,
> struc
> >   return (error);
> >
> >   if (msg->msg_name) {
> > - error = linux_to_bsd_sockaddr((struct sockaddr
> *)msg->msg_name,
> > - msg->msg_namelen);
> > - if (error != 0)
> > - goto bad;
> > + sa = malloc(msg->msg_namelen, M_SONAME, M_WAITOK);
> > + msg->msg_name = sa;
> >   }
> >
> >   uiov = msg->msg_iov;
> >   msg->msg_iov = iov;
> >   controlp = (msg->msg_control != NULL) ? &control : NULL;
> > - error = kern_recvit(td, s, msg, UIO_USERSPACE, controlp);
> > + error = kern_recvit(td, s, msg, UIO_SYSSPACE, controlp);
> >   msg->msg_iov = uiov;
> >   if (error != 0)
> >   goto bad;
> >
> > - error = bsd_to_linux_msghdr(msg, &linux_msg);
> > - if (error != 0)
> > - goto bad;
> > -
> > - if (linux_msg.msg_name) {
> > - error = bsd_to_linux_sockaddr((struct sockaddr *)
> > - PTRIN(linux_msg.msg_name));
> > + if (sa) {
>
> sa may be uninitialised here.
>

yes, I see. thank you. also sa leaks if kern_recvit() returns error. will
fix
___
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: r347980 - head/lib/libsecureboot/openpgp

2019-05-20 Thread Simon J. Gerraty via svn-src-head
Rodney W. Grimes  wrote:
> > Log:
> >   load_key_buf do not free data from dearmor
> >   
> >   The data returned by dearmor is referenced by the key
> >   leave it alone!
> >   
> >   Reviewed by:  stevek
> >   MFC after:2 days
> 
> This is an exception below the standard minimal limit during
> a code freeze, is there some reason for it?  The next build
> should not be started before 3 days.

Sorry,should I wait until after freeze?
This is all optional stuff anyway, so no great harm either way.
___
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: r347984 - in head/sys: amd64/vmm/io arm/allwinner arm/allwinner/a10 arm/allwinner/clkng arm/arm arm/broadcom/bcm2835 arm/freescale/imx arm/mv arm/mv/armada arm/nvidia arm/nvidia/tegra1

2019-05-20 Thread Bruce Evans

On Mon, 20 May 2019, Conrad Meyer wrote:


Log:
 Extract eventfilter declarations to sys/_eventfilter.h


sys/_eventhandler.h has 2 identical 72-line copies of the correct version.
The second copy of the reinclusion guard works as a guard against the
doubling too.



 This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h"
 in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces header
 pollution substantially.

 EVENTHANDLER_DECLARE and EVENTHANDLER_LIST_DECLAREs were moved out of .c
 files into appropriate headers (e.g., sys/proc.h, powernv/opal.h).


Thanks, but this gives even more pollution.  Almost everything includes
sys/proc.h, so its already large pollution affects almost everything.
The previous pollution in it didn't include sys/eventhandler.h, except
possibly via a nested include.


Modified: head/sys/amd64/vmm/io/iommu.c
==
--- head/sys/amd64/vmm/io/iommu.c   Sun May 19 23:56:04 2019
(r347983)
+++ head/sys/amd64/vmm/io/iommu.c   Mon May 20 00:38:23 2019
(r347984)
@@ -32,10 +32,10 @@
__FBSDID("$FreeBSD$");

#include 
-#include 
-#include 


Error.  sys/systm.h must be included after sys/param.h, since it contains
macros like KASSERT() which may be used in inline functions in any kernel
header except sys/param.h and possibly sys/types.h.


Modified: head/sys/arm/allwinner/a10/a10_intc.c
==
--- head/sys/arm/allwinner/a10/a10_intc.c   Sun May 19 23:56:04 2019
(r347983)
+++ head/sys/arm/allwinner/a10/a10_intc.c   Mon May 20 00:38:23 2019
(r347984)
@@ -30,11 +30,12 @@ __FBSDID("$FreeBSD$");

#include "opt_platform.h"

-#include 
+#include 


Including sys/types.h and not including sys/param.h was another error.
sys/param.h supplies lots of standard pollution that may be depended
on by any other kernel header.  It is impractical to even test if
sys/types.h works with all combinations of ifdefs.


#include 
#include 
#include 
#include 
+#include 
#include 
#include 
#include 


sys/param.h is now included twice.  It is another header that must be
included in non-alphabetical order.  The second include may have
compensated for not including it first.



Modified: head/sys/arm/allwinner/a10_dmac.c
==
--- head/sys/arm/allwinner/a10_dmac.c   Sun May 19 23:56:04 2019
(r347983)
+++ head/sys/arm/allwinner/a10_dmac.c   Mon May 20 00:38:23 2019
(r347984)
@@ -38,7 +38,9 @@ __FBSDID("$FreeBSD$");
#include 
#include 
#include 
+#include 
#include 
+#include 

#include 

Modified: head/sys/arm/allwinner/a31_dmac.c
==
--- head/sys/arm/allwinner/a31_dmac.c   Sun May 19 23:56:04 2019
(r347983)
+++ head/sys/arm/allwinner/a31_dmac.c   Mon May 20 00:38:23 2019
(r347984)
@@ -38,7 +38,9 @@ __FBSDID("$FreeBSD$");
#include 
#include 
#include 
+#include 
#include 
+#include 
#include 

#include 


I gave up trying to fix missing includes of sys/mutex.h and its
prerequisite sys/lock.h 15+ years ago before disk code added lots more
of them.  sys/buf.h was polluted by adding an include of sys/mutex.h,
and most disk drivers dependended on that.  The only other includes
of sys/mutex.h in a  header were in sys/eventhandler.h and
sys/vnode.h, and the latter was fixed in my version.  This pollution
has spread to sys/buf_ring.h, sys/fail.h, sys/jail.h, sys/mman.h,
sys/msgbuf.h, sys/rmlock.h, sys/timeet.h and sys/tty.h.

The smaller headers here are trivial to fix, and even sys/vnode.h
wasn't hard to fix 15 years ago before the pollution spread.  sys/mman.h
seems to have only 1 mutex declaration, of a struct mtx, so using the
correct header sys/_mutex.h works.  Only inlines using mutexes cause
pollution that is hard to avoid.  sys/vnode.h still has only 1 inline
function.

Bruce
___
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: r347990 - in head: contrib/libarchive contrib/libarchive/cpio/test contrib/libarchive/libarchive contrib/libarchive/libarchive/test contrib/libarchive/tar contrib/libarchive/tar/test co...

2019-05-20 Thread Martin Matuska
Author: mm
Date: Mon May 20 12:57:39 2019
New Revision: 347990
URL: https://svnweb.freebsd.org/changeset/base/347990

Log:
  MFV r347989:
  Sync libarchive with vendor.
  
  Relevant vendor changes:
Issue #795: XAR - do not try to add xattrs without an allocated name
PR #812: non-recursive option for extract and list
PR #958: support reading metadata from compressed files
PR #999: add --exclude-vcs option to bsdtar
Issue #1062: treat empty archives with a GNU volume header as valid
PR #1074: Handle ZIP files with trailing 0s in the extra fields
  (Android APK archives)
PR #1109: Ignore padding in Zip extra field data (Android APK archives)
PR #1167: fix problems related to unreadable directories
Issue #1168: fix handling of strtol() and strtoul()
PR #1172: RAR5 - fix invalid window buffer read in E8E9 filter
PR #1174: ZIP reader - fix of MSZIP signature parsing
PR #1175: gzip filter - fix reading files larger than 4GB from memory
PR #1177: gzip filter - fix memory leak with repeated header reads
PR #1180: ZIP reader - add support for Info-ZIP Unicode Path Extra Field
PR #1181: RAR5 - fix merge_block() recursion
  (OSS-Fuzz 12999, 13029, 13144, 13478, 13490)
PR #1183: fix memory leak when decompressing ZIP files with LZMA
PR #1184: fix RAR5 OSS-Fuzz issues 12466, 14490, 14491, 12817
  OSS-Fuzz 12466: RAR5 - fix buffer overflow when parsing huffman tables
  OSS-Fuzz 14490, 14491: RAR5 - fix bad shift-left operations
  OSS-Fuzz 12817: RAR5 - handle a case with truncated huffman tables
PR #1186: RAR5 - fix invalid type used for dictionary size mask
  (OSS-Fuzz 14537)
PR #1187: RAR5 - fix integer overflow (OSS-Fuzz 14555)
PR #1190: RAR5 - RAR5 don't try to unpack entries marked as directories
  (OSS-Fuzz 14574)
PR #1196: RAR5 - fix a potential SIGSEGV on 32-bit builds
OSS-Fuzz 2582: RAR - fix use after free if there is an invalid entry
OSS-Fuzz 14331: RAR5 - fix maximum owner name length
OSS-Fuzz 13965: RAR5 - use unsigned int for volume number + range check
  
Additional RAR5 reader changes:
  - support symlinks, hardlinks, file owner, file group, versioned files
  - change ARCHIVE_FORMAT_RAR_V5 to 0x10
  - set correct mode for readonly directories
  - support readonly, hidden and system Windows file attributes
  
  MFC after:2 weeks

Added:
  head/contrib/libarchive/libarchive/archive_entry_misc.3
 - copied unchanged from r347989, 
vendor/libarchive/dist/libarchive/archive_entry_misc.3
  
head/contrib/libarchive/libarchive/test/test_read_format_mtree_noprint.mtree.uu
 - copied unchanged from r347989, 
vendor/libarchive/dist/libarchive/test/test_read_format_mtree_noprint.mtree.uu
  
head/contrib/libarchive/libarchive/test/test_read_format_rar5_distance_overflow.rar.uu
 - copied unchanged from r347989, 
vendor/libarchive/dist/libarchive/test/test_read_format_rar5_distance_overflow.rar.uu
  
head/contrib/libarchive/libarchive/test/test_read_format_rar5_extra_field_version.rar.uu
 - copied unchanged from r347989, 
vendor/libarchive/dist/libarchive/test/test_read_format_rar5_extra_field_version.rar.uu
  head/contrib/libarchive/libarchive/test/test_read_format_rar5_fileattr.rar.uu
 - copied unchanged from r347989, 
vendor/libarchive/dist/libarchive/test/test_read_format_rar5_fileattr.rar.uu
  head/contrib/libarchive/libarchive/test/test_read_format_rar5_hardlink.rar.uu
 - copied unchanged from r347989, 
vendor/libarchive/dist/libarchive/test/test_read_format_rar5_hardlink.rar.uu
  
head/contrib/libarchive/libarchive/test/test_read_format_rar5_invalid_dict_reference.rar.uu
 - copied unchanged from r347989, 
vendor/libarchive/dist/libarchive/test/test_read_format_rar5_invalid_dict_reference.rar.uu
  
head/contrib/libarchive/libarchive/test/test_read_format_rar5_leftshift1.rar.uu
 - copied unchanged from r347989, 
vendor/libarchive/dist/libarchive/test/test_read_format_rar5_leftshift1.rar.uu
  
head/contrib/libarchive/libarchive/test/test_read_format_rar5_leftshift2.rar.uu
 - copied unchanged from r347989, 
vendor/libarchive/dist/libarchive/test/test_read_format_rar5_leftshift2.rar.uu
  
head/contrib/libarchive/libarchive/test/test_read_format_rar5_nonempty_dir_stream.rar.uu
 - copied unchanged from r347989, 
vendor/libarchive/dist/libarchive/test/test_read_format_rar5_nonempty_dir_stream.rar.uu
  head/contrib/libarchive/libarchive/test/test_read_format_rar5_owner.rar.uu
 - copied unchanged from r347989, 
vendor/libarchive/dist/libarchive/test/test_read_format_rar5_owner.rar.uu
  
head/contrib/libarchive/libarchive/test/test_read_format_rar5_readtables_overflow.rar.uu
 - copied unchanged from r347989, 
vendor/libarchive/dist/libarchive/test/test_read_format_rar5_readtables_overflow.rar.uu
  head/contrib/libarchive/libarchive/test/test_read_format_rar5_symlink.rar.uu
 - copied unchanged 

svn commit: r347992 - head/gnu/usr.bin/binutils

2019-05-20 Thread Leandro Lupori
Author: luporl
Date: Mon May 20 16:00:32 2019
New Revision: 347992
URL: https://svnweb.freebsd.org/changeset/base/347992

Log:
  [PPC] Enable build/install of ld.bfd on base
  
  When using LLVM+clang+lld on PowerPC64, ld.bfd is also needed,
  to link 32-bit binaries correctly, as lld support for 32-bit is
  still minimal.
  
  This change enables it to be built and installed when lld is used.
  
  Reviewed by: jhibbits
  Differential Revision: https://reviews.freebsd.org/D20259

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

Modified: head/gnu/usr.bin/binutils/Makefile
==
--- head/gnu/usr.bin/binutils/Makefile  Mon May 20 15:58:44 2019
(r347991)
+++ head/gnu/usr.bin/binutils/Makefile  Mon May 20 16:00:32 2019
(r347992)
@@ -13,7 +13,9 @@ SUBDIR.${MK_BINUTILS}+=   objdump
 
 # When we use ld.lld as /usr/bin/ld, do not install the non-ifunc-capable
 # GNU binutils 2.17.50 ld.
-.if ${MK_LLD_IS_LD} == "no"
+# Except if we are on powerpc, that needs the ld from binutils to link
+# 32-bit binaries.
+.if ${MK_LLD_IS_LD} == "no" || ${TARGET} == "powerpc"
 SUBDIR.${MK_BINUTILS}+=ld
 .endif
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347996 - head/tests/sys/opencrypto

2019-05-20 Thread Enji Cooper
Author: ngie
Date: Mon May 20 16:38:12 2019
New Revision: 347996
URL: https://svnweb.freebsd.org/changeset/base/347996

Log:
  Replace uses of `foo.(de|en)code('hex')` with `binascii.(un)?hexlify(foo)`
  
  Python 3 no longer doesn't support encoding/decoding hexadecimal numbers using
  the `str.format` method. The backwards compatible new method (using the
  binascii module/methods) is a comparable means of converting to/from
  hexadecimal format.
  
  In short, the functional change is the following:
  * `foo.decode('hex')` -> `binascii.unhexlify(foo)`
  * `foo.encode('hex')` -> `binascii.hexlify(foo)`
  
  While here, move the dpkt import in `cryptodev.py` down per PEP8, so it comes
  after the standard library provided imports.
  
  PR:   237403
  MFC after:1 week

Modified:
  head/tests/sys/opencrypto/cryptodev.py
  head/tests/sys/opencrypto/cryptotest.py

Modified: head/tests/sys/opencrypto/cryptodev.py
==
--- head/tests/sys/opencrypto/cryptodev.py  Mon May 20 16:31:45 2019
(r347995)
+++ head/tests/sys/opencrypto/cryptodev.py  Mon May 20 16:38:12 2019
(r347996)
@@ -32,7 +32,7 @@
 
 from __future__ import print_function
 import array
-import dpkt
+import binascii
 from fcntl import ioctl
 import os
 import random
@@ -40,6 +40,8 @@ import signal
 from struct import pack as _pack
 import time
 
+import dpkt
+
 from cryptodevh import *
 
 __all__ = [ 'Crypto', 'MismatchError', ]
@@ -493,7 +495,7 @@ class KATCCMParser:
 
 
 def _spdechex(s):
-return ''.join(s.split()).decode('hex')
+return binascii.hexlify(''.join(s.split()))
 
 if __name__ == '__main__':
 if True:
@@ -525,15 +527,15 @@ if __name__ == '__main__':
 c = Crypto(CRYPTO_AES_ICM, key)
 enc = c.encrypt(pt, iv)
 
-print('enc:', enc.encode('hex'))
-print(' ct:', ct.encode('hex'))
+print('enc:', binascii.hexlify(enc))
+print(' ct:', binascii.hexlify(ct))
 
 assert ct == enc
 
 dec = c.decrypt(ct, iv)
 
-print('dec:', dec.encode('hex'))
-print(' pt:', pt.encode('hex'))
+print('dec:', binascii.hexlify(dec))
+print(' pt:', binascii.hexlify(pt))
 
 assert pt == dec
 elif False:
@@ -546,15 +548,15 @@ if __name__ == '__main__':
 c = Crypto(CRYPTO_AES_ICM, key)
 enc = c.encrypt(pt, iv)
 
-print('enc:', enc.encode('hex'))
-print(' ct:', ct.encode('hex'))
+print('enc:', binascii.hexlify(enc))
+print(' ct:', binascii.hexlify(ct))
 
 assert ct == enc
 
 dec = c.decrypt(ct, iv)
 
-print('dec:', dec.encode('hex'))
-print(' pt:', pt.encode('hex'))
+print('dec:', binascii.hexlify(dec))
+print(' pt:', binascii.hexlify(pt))
 
 assert pt == dec
 elif False:
@@ -566,15 +568,15 @@ if __name__ == '__main__':
 
 enc = c.encrypt(pt, iv)
 
-print('enc:', enc.encode('hex'))
-print(' ct:', ct.encode('hex'))
+print('enc:', binascii.hexlify(enc))
+print(' ct:', binascii.hexlify(ct))
 
 assert ct == enc
 
 dec = c.decrypt(ct, iv)
 
-print('dec:', dec.encode('hex'))
-print(' pt:', pt.encode('hex'))
+print('dec:', binascii.hexlify(dec))
+print(' pt:', binascii.hexlify(pt))
 
 assert pt == dec
 elif False:
@@ -592,26 +594,26 @@ if __name__ == '__main__':
 
 enc, enctag = c.encrypt(pt, iv, aad=aad)
 
-print('enc:', enc.encode('hex'))
-print(' ct:', ct.encode('hex'))
+print('enc:', binascii.hexlify(enc))
+print(' ct:', binascii.hexlify(ct))
 
 assert enc == ct
 
-print('etg:', enctag.encode('hex'))
-print('tag:', tag.encode('hex'))
+print('etg:', binascii.hexlify(enctag))
+print('tag:', binascii.hexlify(tag))
 assert enctag == tag
 
 # Make sure we get EBADMSG
 #enctag = enctag[:-1] + 'a'
 dec, dectag = c.decrypt(ct, iv, aad=aad, tag=enctag)
 
-print('dec:', dec.encode('hex'))
-print(' pt:', pt.encode('hex'))
+print('dec:', binascii.hexlify(dec))
+print(' pt:', binascii.hexlify(pt))
 
 assert dec == pt
 
-print('dtg:', dectag.encode('hex'))
-print('tag:', tag.encode('hex'))
+print('dtg:', binascii.hexlify(dectag))
+print('tag:', binascii.hexlify(tag))
 
 assert dectag == tag
 elif False:
@@ -628,27 +630,27 @@ if __name__ == '__main__':
 
 enc, enctag = c.encrypt(pt, iv, aad=aad)
 
-print('enc:', enc.encode('hex'))
-print(' ct:', ct.encode('hex'))
+print('enc:', binascii.hexlify(enc))
+print(' ct:', binascii.hexlify(ct))
 
 assert enc == ct
 
-print('etg:', enctag.encode('hex'))
-print('tag:', tag.encode('hex'))
+print('etg:', binascii.hexlify(enctag))
+print('tag:', binascii.hexl

svn commit: r347998 - head/sys/mips/mediatek

2019-05-20 Thread Adrian Chadd
Author: adrian
Date: Mon May 20 17:43:58 2019
New Revision: 347998
URL: https://svnweb.freebsd.org/changeset/base/347998

Log:
  [mediatek] Add support for non-flash devices on the SPI bus of the Mediatek 
SoCs.
  
  The existing SPI support only worked for directly attached flash chips.
  it didn't implement clock programming or chipselect.  It also supports
  transfers with unbalanced tx/rx command sizes.
  
  Submitted by: 
  Differential Revision:https://reviews.freebsd.org/D20101

Modified:
  head/sys/mips/mediatek/mtk_spi_v1.c

Modified: head/sys/mips/mediatek/mtk_spi_v1.c
==
--- head/sys/mips/mediatek/mtk_spi_v1.c Mon May 20 16:39:31 2019
(r347997)
+++ head/sys/mips/mediatek/mtk_spi_v1.c Mon May 20 17:43:58 2019
(r347998)
@@ -43,6 +43,11 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
+#include "gpiobus_if.h"
+
+#include 
+
 #include 
 #include 
 #include "spibus_if.h"
@@ -53,6 +58,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
 #include 
 #include 
 
@@ -81,6 +87,8 @@ __FBSDID("$FreeBSD$");
 struct mtk_spi_softc {
device_tsc_dev;
struct resource *sc_mem_res;
+   struct gpiobus_pin  *gpio_cs;
+   int nonflash;
 };
 
 static int mtk_spi_probe(device_t);
@@ -127,7 +135,7 @@ mtk_spi_attach(device_t dev)
sc->sc_dev = dev;
 rid = 0;
sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
-   RF_ACTIVE);
+   RF_SHAREABLE | RF_ACTIVE);
if (!sc->sc_mem_res) {
device_printf(dev, "Could not map memory\n");
return (ENXIO);
@@ -138,14 +146,20 @@ mtk_spi_attach(device_t dev)
return (EBUSY);
}
 
-   SPI_WRITE(sc, MTK_SPICFG, MSBFIRST | SPICLKPOL | TX_ON_CLK_FALL |
-   SPI_CLK_DIV8); /* XXX: make it configurable */
-   /*
-* W25Q64CV max 104MHz, bus 120-192 MHz, so divide by 2.
-* Update: divide by 4, DEV2 to fast for flash.
-*/
+   if (ofw_bus_has_prop(dev, "non-flash"))
+   sc->nonflash = 1;
+   else
+   sc->nonflash = 0;
 
-   device_add_child(dev, "spibus", 0);
+   ofw_gpiobus_parse_gpios(dev, "cs-gpios", &sc->gpio_cs);
+
+   if (sc->gpio_cs != NULL) {
+   GPIO_PIN_SETFLAGS(sc->gpio_cs->dev, sc->gpio_cs->pin,
+   GPIO_PIN_OUTPUT);
+   GPIO_PIN_SET(sc->gpio_cs->dev, sc->gpio_cs->pin, 1);
+   }
+
+   device_add_child(dev, "spibus", -1);
return (bus_generic_attach(dev));
 }
 
@@ -169,7 +183,12 @@ mtk_spi_chip_activate(struct mtk_spi_softc *sc)
/*
 * Put all CSx to low
 */
-   SPI_CLEAR_BITS(sc, MTK_SPICTL, CS_HIGH | HIZSMOSI);
+   if (sc->gpio_cs != NULL) {
+   GPIO_PIN_SET(sc->gpio_cs->dev, sc->gpio_cs->pin, 0);
+   SPI_CLEAR_BITS(sc, MTK_SPICTL, HIZSMOSI);
+   } else {
+   SPI_CLEAR_BITS(sc, MTK_SPICTL, CS_HIGH | HIZSMOSI);
+   }
 }
 
 static void
@@ -179,7 +198,12 @@ mtk_spi_chip_deactivate(struct mtk_spi_softc *sc)
/*
 * Put all CSx to high
 */
-   SPI_SET_BITS(sc, MTK_SPICTL, CS_HIGH | HIZSMOSI);
+   if (sc->gpio_cs != NULL) {
+   GPIO_PIN_SET(sc->gpio_cs->dev, sc->gpio_cs->pin, 1);
+   SPI_SET_BITS(sc, MTK_SPICTL, HIZSMOSI);
+   } else {
+   SPI_SET_BITS(sc, MTK_SPICTL, CS_HIGH | HIZSMOSI);
+   }
 }
 
 static int
@@ -224,12 +248,15 @@ mtk_spi_transfer(device_t dev, device_t child, struct 
 {
struct mtk_spi_softc *sc;
uint8_t *buf, byte, *tx_buf;
-   uint32_t cs;
+   uint32_t cs, clock, mode;
int i, sz, error = 0, write = 0;
+   int div, clk, cfgreg;
 
sc = device_get_softc(dev);
 
spibus_get_cs(child, &cs);
+   spibus_get_clock(child, &clock);
+   spibus_get_mode(child, &mode);
 
cs &= ~SPIBUS_CS_HIGH;
 
@@ -237,44 +264,80 @@ mtk_spi_transfer(device_t dev, device_t child, struct 
/* Only 1 CS */
return (ENXIO);
 
-/* There is always a command to transfer. */
-tx_buf = (uint8_t *)(cmd->tx_cmd);
-
-/* Perform some fixup because MTK dont support duplex SPI */
-switch(tx_buf[0]) {
-case CMD_READ_IDENT:
-cmd->tx_cmd_sz = 1;
-cmd->rx_cmd_sz = 3;
+   cfgreg = MSBFIRST;
+   switch(mode) {
+   case 0: /* This is workadound because of
+  mode 0 not work this soc. */
+   case 3:
+   cfgreg |= SPICLKPOL | TX_ON_CLK_FALL;
 break;
-   case CMD_ENTER_4B_MODE:
-   case CMD_EXIT_4B_MODE:
-case CMD_WRITE_ENABLE:
-case CMD_WRITE_DISABLE:
-  

svn commit: r347999 - head/lib/libarchive/tests

2019-05-20 Thread Li-Wen Hsu
Author: lwhsu
Date: Mon May 20 18:07:45 2019
New Revision: 347999
URL: https://svnweb.freebsd.org/changeset/base/347999

Log:
  Install missing data file for
  lib.libarchive.functional_test.test_read_format_zip_utf8_paths
  
  MFC after:2 weeks (with r347989)
  Sponsored by: The FreeBSD Foundation

Modified:
  head/lib/libarchive/tests/Makefile

Modified: head/lib/libarchive/tests/Makefile
==
--- head/lib/libarchive/tests/Makefile  Mon May 20 17:43:58 2019
(r347998)
+++ head/lib/libarchive/tests/Makefile  Mon May 20 18:07:45 2019
(r347999)
@@ -557,6 +557,7 @@ ${PACKAGE}FILES+=   test_read_format_ustar_filename_eucj
 ${PACKAGE}FILES+=  test_read_format_ustar_filename_koi8r.tar.Z.uu
 ${PACKAGE}FILES+=  test_read_format_warc.warc.uu
 ${PACKAGE}FILES+=  test_read_format_zip.zip.uu
+${PACKAGE}FILES+=  test_read_format_zip_7075_utf8_paths.zip.uu
 ${PACKAGE}FILES+=  test_read_format_zip_bz2_hang.zip.uu
 ${PACKAGE}FILES+=  test_read_format_zip_bzip2.zipx.uu
 ${PACKAGE}FILES+=  test_read_format_zip_bzip2_multi.zipx.uu
___
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: r347980 - head/lib/libsecureboot/openpgp

2019-05-20 Thread Rodney W. Grimes
> Rodney W. Grimes  wrote:
> > > Log:
> > >   load_key_buf do not free data from dearmor
> > >   
> > >   The data returned by dearmor is referenced by the key
> > >   leave it alone!
> > >   
> > >   Reviewed by:stevek
> > >   MFC after:  2 days
> > 
> > This is an exception below the standard minimal limit during
> > a code freeze, is there some reason for it?  The next build
> > should not be started before 3 days.
> 
> Sorry,should I wait until after freeze?
> This is all optional stuff anyway, so no great harm either way.

No, please do merge this at 3 days, it is just that the
normal minimum bake time in ^head is 3 days, freeze or not.

-- 
Rod Grimes rgri...@freebsd.org
___
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: r348000 - head/tests/sys/sys

2019-05-20 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon May 20 18:35:23 2019
New Revision: 348000
URL: https://svnweb.freebsd.org/changeset/base/348000

Log:
  Improve tree(3) tests by using ATF_REQUIRE where applicable.
  
  MFC after:2 weeks
  Sponsored by: Klara Inc.

Modified:
  head/tests/sys/sys/rb_test.c
  head/tests/sys/sys/splay_test.c

Modified: head/tests/sys/sys/rb_test.c
==
--- head/tests/sys/sys/rb_test.cMon May 20 18:07:45 2019
(r347999)
+++ head/tests/sys/sys/rb_test.cMon May 20 18:35:23 2019
(r348000)
@@ -69,7 +69,7 @@ ATF_TC_BODY(rb_test, tc)
 
for (i = 0; i < ITER; i++) {
tmp = malloc(sizeof(struct node));
-   ATF_CHECK_MSG(tmp != NULL, "malloc failed");
+   ATF_REQUIRE_MSG(tmp != NULL, "malloc failed");
do {
tmp->key = arc4random_uniform(MAX-MIN);
tmp->key += MIN;
@@ -82,20 +82,22 @@ ATF_TC_BODY(rb_test, tc)
if (tmp->key < min)
min = tmp->key;
}
-   ATF_CHECK_EQ(NULL, RB_INSERT(tree, &root, tmp));
+   ATF_REQUIRE_EQ(NULL, RB_INSERT(tree, &root, tmp));
}
 
ins = RB_MIN(tree, &root);
+   ATF_REQUIRE_MSG(ins != NULL, "RB_MIN error");
ATF_CHECK_EQ(min, ins->key);
tmp = ins;
ins = RB_MAX(tree, &root);
+   ATF_REQUIRE_MSG(ins != NULL, "RB_MAX error");
ATF_CHECK_EQ(max, ins->key);
 
ATF_CHECK_EQ(tmp, RB_REMOVE(tree, &root, tmp));
 
for (i = 0; i < ITER - 1; i++) {
tmp = RB_ROOT(&root);
-   ATF_CHECK_MSG(tmp != NULL, "RB_ROOT error");
+   ATF_REQUIRE_MSG(tmp != NULL, "RB_ROOT error");
ATF_CHECK_EQ(tmp, RB_REMOVE(tree, &root, tmp));
free(tmp);
}

Modified: head/tests/sys/sys/splay_test.c
==
--- head/tests/sys/sys/splay_test.c Mon May 20 18:07:45 2019
(r347999)
+++ head/tests/sys/sys/splay_test.c Mon May 20 18:35:23 2019
(r348000)
@@ -69,7 +69,7 @@ ATF_TC_BODY(splay_test, tc)
 
for (i = 0; i < ITER; i++) {
tmp = malloc(sizeof(struct node));
-   ATF_CHECK_MSG(tmp != NULL, "malloc failed");
+   ATF_REQUIRE_MSG(tmp != NULL, "malloc failed");
do {
tmp->key = arc4random_uniform(MAX-MIN);
tmp->key += MIN;
@@ -82,20 +82,22 @@ ATF_TC_BODY(splay_test, tc)
if (tmp->key < min)
min = tmp->key;
}
-   ATF_CHECK_EQ(NULL, SPLAY_INSERT(tree, &root, tmp));
+   ATF_REQUIRE_EQ(NULL, SPLAY_INSERT(tree, &root, tmp));
}
 
ins = SPLAY_MIN(tree, &root);
+   ATF_REQUIRE_MSG(ins != NULL, "SPLAY_MIN error");
ATF_CHECK_EQ(min, ins->key);
tmp = ins;
ins = SPLAY_MAX(tree, &root);
+   ATF_REQUIRE_MSG(ins != NULL, "SPLAY_MAX error");
ATF_CHECK_EQ(max, ins->key);
 
ATF_CHECK_EQ(tmp, SPLAY_REMOVE(tree, &root, tmp));
 
for (i = 0; i < ITER - 1; i++) {
tmp = SPLAY_ROOT(&root);
-   ATF_CHECK_MSG(tmp != NULL, "SPLAY_ROOT error");
+   ATF_REQUIRE_MSG(tmp != NULL, "SPLAY_ROOT error");
ATF_CHECK_EQ(tmp, SPLAY_REMOVE(tree, &root, tmp));
free(tmp);
}
___
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: r348001 - head/sys/dev/usb/net

2019-05-20 Thread Ed Maste
Author: emaste
Date: Mon May 20 18:41:07 2019
New Revision: 348001
URL: https://svnweb.freebsd.org/changeset/base/348001

Log:
  muge: configure LEDs per dtb (for Raspberry Pi 3B+)
  
  Also apply some style(9) and remove the message about EEPROM configuration
  (if there's an EEPROM the hardware handles LED configuration itself).
  
  PR:   237325
  Reviewed by:  ian
  MFC after:2 weeks
  Submitted by: Ralf 

Modified:
  head/sys/dev/usb/net/if_muge.c

Modified: head/sys/dev/usb/net/if_muge.c
==
--- head/sys/dev/usb/net/if_muge.c  Mon May 20 18:35:23 2019
(r348000)
+++ head/sys/dev/usb/net/if_muge.c  Mon May 20 18:41:07 2019
(r348001)
@@ -173,6 +173,7 @@ struct muge_softc {
struct mtx  sc_mtx;
struct usb_xfer *sc_xfer[MUGE_N_TRANSFER];
int sc_phyno;
+   uint32_tsc_leds;
 
/* Settings for the mac control (MAC_CSR) register. */
uint32_tsc_rfe_ctl;
@@ -891,6 +892,7 @@ lan78xx_phy_init(struct muge_softc *sc)
muge_dbg_printf(sc, "Initializing PHY.\n");
uint16_t bmcr;
usb_ticks_t start_ticks;
+   uint32_t hw_reg;
const usb_ticks_t max_ticks = USB_MS_TO_TICKS(1000);
 
MUGE_LOCK_ASSERT(sc, MA_OWNED);
@@ -931,6 +933,15 @@ lan78xx_phy_init(struct muge_softc *sc)
bmcr |= BMCR_AUTOEN;
lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno, MII_BMCR, bmcr);
bmcr = lan78xx_miibus_readreg(sc->sc_ue.ue_dev, sc->sc_phyno, MII_BMCR);
+
+   /* Enable appropriate LEDs. */
+   if (sc->sc_leds != 0 &&
+   lan78xx_read_reg(sc, ETH_HW_CFG, &hw_reg) == 0) {
+   hw_reg &= ~(ETH_HW_CFG_LEDO_EN_ | ETH_HW_CFG_LED1_EN_ |
+   ETH_HW_CFG_LED2_EN_ | ETH_HW_CFG_LED3_EN_ );
+   hw_reg |= sc->sc_leds;
+   lan78xx_write_reg(sc, ETH_HW_CFG, hw_reg);
+   }
return (0);
 }
 
@@ -1523,6 +1534,37 @@ muge_fdt_find_mac(const char *compatible, unsigned cha
 
return (ENXIO);
 }
+
+/**
+ * muge_fdt_count_led_modes - read number of LED modes from node
+ * @compatible: compatible string for DTB node in the form
+ * "usb[N]NNN,[M]MMM"
+ * where NNN is vendor id and MMM is product id
+ * @amount: memory to store number of LED entries to
+ *
+ * Tries to find matching node in DTS and obtain number of entries from it.
+ *
+ * RETURNS:
+ * Returns 0 on success, error code otherwise
+ */
+static int
+muge_fdt_count_led_modes(struct muge_softc *sc, const char *compatible,
+uint32_t *amount)
+{
+   phandle_t node, root;
+   ssize_t proplen;
+
+   *amount = 0;
+   root = OF_finddevice("/");
+   node = muge_fdt_find_eth_node(root, compatible);
+   if (node != -1 &&
+  (proplen = OF_getproplen(node, "microchip,led-modes")) > 0) {
+   *amount = proplen / sizeof( uint32_t );
+   return (0);
+   }
+
+   return (ENXIO);
+}
 #endif
 
 /**
@@ -1591,6 +1633,41 @@ muge_set_mac_addr(struct usb_ether *ue)
 }
 
 /**
+ * muge_set_leds - Initializes NIC LEDs pattern
+ * @ue: the USB ethernet device
+ *
+ * Tries to store the LED modes.
+ * Supports only DTB blob like the Linux driver does.
+ */
+static void
+muge_set_leds(struct usb_ether *ue)
+{
+   struct muge_softc *sc = uether_getsc(ue);
+#ifdef FDT
+   char compatible[16];
+   struct usb_attach_arg *uaa = device_get_ivars(ue->ue_dev);
+   uint32_t count;
+#endif
+
+   sc->sc_leds = 0;/* no LED mode is set */
+   if (lan78xx_eeprom_present(sc))
+   return;
+#ifdef FDT
+   snprintf(compatible, sizeof(compatible), "usb%x,%x",
+   uaa->info.idVendor, uaa->info.idProduct);
+   if (muge_fdt_count_led_modes(sc, compatible, &count) == 0) {
+   sc->sc_leds = (count > 0) * ETH_HW_CFG_LEDO_EN_ |
+ (count > 1) * ETH_HW_CFG_LED1_EN_ |
+ (count > 2) * ETH_HW_CFG_LED2_EN_ |
+ (count > 3) * ETH_HW_CFG_LED3_EN_;
+   muge_dbg_printf(sc, "LED modes set from FDT blob\n");
+   return;
+   }
+#endif
+   muge_dbg_printf(sc, "LED configuration not available\n");
+}
+
+/**
  * muge_attach_post - Called after the driver attached to the USB interface
  * @ue: the USB ethernet device
  *
@@ -1610,6 +1687,7 @@ muge_attach_post(struct usb_ether *ue)
sc->sc_phyno = 1;
 
muge_set_mac_addr(ue);
+   muge_set_leds(ue);
 
/* Initialise the chip for the first time */
lan78xx_chip_init(sc);
___
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: r348002 - head/share/man/man9

2019-05-20 Thread Mark Johnston
Author: markj
Date: Mon May 20 19:08:55 2019
New Revision: 348002
URL: https://svnweb.freebsd.org/changeset/base/348002

Log:
  Typo.
  
  MFC after:3 days

Modified:
  head/share/man/man9/DRIVER_MODULE.9

Modified: head/share/man/man9/DRIVER_MODULE.9
==
--- head/share/man/man9/DRIVER_MODULE.9 Mon May 20 18:41:07 2019
(r348001)
+++ head/share/man/man9/DRIVER_MODULE.9 Mon May 20 19:08:55 2019
(r348002)
@@ -125,7 +125,7 @@ macro allows a driver to be registered for a specific 
 The boot time probe and attach process makes multiple passes over the
 device tree.
 Certain critical drivers that provide basic services needed by other
-devices are attach during earlier passes.
+devices are attached during earlier passes.
 Most drivers are attached in a final general pass.
 A driver that attaches during an early pass must register for a specific
 pass level
___
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: r348003 - head/share/man/man9

2019-05-20 Thread Mark Johnston
Author: markj
Date: Mon May 20 19:12:29 2019
New Revision: 348003
URL: https://svnweb.freebsd.org/changeset/base/348003

Log:
  Add a man page for DEFINE_IFUNC.
  
  Reviewed by:  kib
  Discussed with:   emaste
  MFC after:2 weeks
  Event:Waterloo Hackathon 2019
  Differential Revision:https://reviews.freebsd.org/D20310

Added:
  head/share/man/man9/DEFINE_IFUNC.9   (contents, props changed)

Added: head/share/man/man9/DEFINE_IFUNC.9
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/man/man9/DEFINE_IFUNC.9  Mon May 20 19:12:29 2019
(r348003)
@@ -0,0 +1,143 @@
+.\" Copyright (c) 2019 The FreeBSD Foundation
+.\"
+.\" This documentation was written by Mark Johnston 
+.\" 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$
+.\"
+.Dd May 18, 2019
+.Dt DEFINE_IFUNC 9
+.Os
+.Sh NAME
+.Nm DEFINE_IFUNC
+.Nd define a kernel function with an implementation selected at run-time
+.Sh SYNOPSIS
+.In machine/ifunc.h
+.Fn DEFINE_IFUNC qual ret_type name args
+.Sh DESCRIPTION
+ifuncs are a linker feature which allows the programmer to define functions
+whose implementation is selected at boot-time or module load-time.
+The
+.Nm
+macro can be used to define an ifunc.
+The selection is performed by a resolver function, which returns a pointer
+to the selected function.
+ifunc resolvers are invoked very early during the machine-dependent
+initialization routine, or at load time for dynamically loaded modules.
+Resolution must occur before the first call to an ifunc.
+ifunc resolution is performed after CPU features are enumerated and after the
+kernel's environment is initialized.
+The typical use-case for an ifunc is a routine whose behavior depends on
+optional CPU features.
+For example, newer generations of a given CPU architecture may provide an
+instruction to optimize a common operation.
+To avoid the overhead of testing for the CPU feature each time the operation
+is performed, an ifunc can be used to provide two implementations for the
+operation: one targeting platforms with the extra instruction, and one
+for older platforms.
+.Pp
+Because
+.Nm
+is a macro that defines a dynamically typed function, its usage looks somewhat
+unusual.
+The
+.Ar qual
+parameter is a list of zero or more C function qualifiers to be applied to the
+ifunc.
+This parameter is typically empty or the
+.Dv static
+qualifier.
+.Ar ret_type
+is the return type of the ifunc.
+.Ar name
+is the name of the ifunc.
+.Ar args
+is a parenthesized, comma-separated list of the parameter types of the 
function,
+as they would appear in a C function declaration.
+.Pp
+The
+.Nm
+usage must be followed by the resolver function body.
+The resolver must return a function with return type
+.Ar ret_type
+and parameter types
+.Ar args .
+The resolver function is defined with the
+.Ql resolver
+gcc-style function attribute, causing the corresponding
+.Xr elf 5
+function symbol to be of type
+.Dv STT_GNU_IFUNC
+instead of
+.Dv STT_FUNC .
+The kernel linker invokes the resolver to process relocations targeting ifunc
+calls and PLT entries referencing such symbols.
+.Sh EXAMPLES
+ifunc resolvers are executed early during boot, before most kernel facilities
+are available.
+They are effectively limited to checking CPU feature flags and tunables.
+.Bd -literal
+static size_t
+fast_strlen(const char *s __unused)
+{
+   size_t len;
+
+   /* Fast, but may not be correct in all cases. */
+   __asm("movq $42,%0\\n" : "=r" (len));
+   return (len);
+}
+
+static size_t
+slow_strlen(const cha

svn commit: r348004 - head/sys/kern

2019-05-20 Thread Mark Johnston
Author: markj
Date: Mon May 20 19:14:07 2019
New Revision: 348004
URL: https://svnweb.freebsd.org/changeset/base/348004

Log:
  kcov depends on eventhandler.h.
  
  MFC after:3 days

Modified:
  head/sys/kern/kern_kcov.c

Modified: head/sys/kern/kern_kcov.c
==
--- head/sys/kern/kern_kcov.c   Mon May 20 19:12:29 2019(r348003)
+++ head/sys/kern/kern_kcov.c   Mon May 20 19:14:07 2019(r348004)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
___
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: r347984 - in head/sys: amd64/vmm/io arm/allwinner arm/allwinner/a10 arm/allwinner/clkng arm/arm arm/broadcom/bcm2835 arm/freescale/imx arm/mv arm/mv/armada arm/nvidia arm/nvidia/tegra1

2019-05-20 Thread Peter Jeremy
On 2019-May-20 00:38:23 +, Conrad Meyer  wrote:
>Author: cem
>Date: Mon May 20 00:38:23 2019
>New Revision: 347984
>URL: https://svnweb.freebsd.org/changeset/base/347984
>
>Log:
>  Extract eventfilter declarations to sys/_eventfilter.h
...
>  No functional change (intended).  Of course, any out of tree modules that
>  relied on header pollution for sys/eventhandler.h, sys/lock.h, or
>  sys/mutex.h inclusion need to be fixed.  __FreeBSD_version has been bumped.

This seems to have broken at least netmap and netdump for me:
/usr/src/sys/dev/netmap/netmap_freebsd.c:191:3: error: implicit declaration of 
function 'EVENTHANDLER_REGISTER' is invalid in C99 
[-Werror,-Wimplicit-function-declaration]
EVENTHANDLER_REGISTER(ifnet_arrival_event,
^
...
/usr/src/sys/netinet/netdump/netdump_client.c:1458:22: error: implicit 
declaration of function 'EVENTHANDLER_REGISTER' is invalid in C99 
[-Werror,-Wimplicit-function-declaration]
nd_detach_cookie = EVENTHANDLER_REGISTER(ifnet_departure_event,
   ^

-- 
Peter Jeremy


signature.asc
Description: PGP signature


svn commit: r348005 - in head: cddl/contrib/opensolaris/lib/libzfs/common stand/common stand/ofw/libofw stand/powerpc/boot1.chrp stand/powerpc/kboot stand/powerpc/ofw

2019-05-20 Thread Leandro Lupori
Author: luporl
Date: Mon May 20 19:21:35 2019
New Revision: 348005
URL: https://svnweb.freebsd.org/changeset/base/348005

Log:
  [PowerPC64] stand: fix build using clang 8 as compiler
  
  This change fixes "stand" build issues when using clang 8
  as compiler.
  
  Submitted by:   alfredo.junior_eldorado.org.br
  Reviewed by:jhibbits
  Differential Revision: https://reviews.freebsd.org/D20026

Modified:
  head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c
  head/stand/common/load_elf.c
  head/stand/ofw/libofw/ofw_net.c
  head/stand/ofw/libofw/openfirm.c
  head/stand/powerpc/boot1.chrp/boot1.c
  head/stand/powerpc/kboot/Makefile
  head/stand/powerpc/kboot/main.c
  head/stand/powerpc/ofw/elf_freebsd.c
  head/stand/powerpc/ofw/ppc64_elf_freebsd.c

Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c
==
--- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c   Mon May 
20 19:14:07 2019(r348004)
+++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c   Mon May 
20 19:21:35 2019(r348005)
@@ -114,7 +114,7 @@ get_stats_for_obj(differ_info_t *di, const char *dsnam
(void) snprintf(di->errbuf, sizeof (di->errbuf),
dgettext(TEXT_DOMAIN,
"Unable to determine path or stats for "
-   "object %lld in %s"), obj, dsname);
+   "object %jd in %s"), (uintmax_t)obj, dsname);
return (-1);
}
 }
@@ -406,8 +406,8 @@ write_free_diffs(FILE *fp, differ_info_t *di, dmu_diff
} else {
(void) snprintf(di->errbuf, sizeof (di->errbuf),
dgettext(TEXT_DOMAIN,
-   "next allocated object (> %lld) find failure"),
-   zc.zc_obj);
+   "next allocated object (> %jd) find failure"),
+   (uintmax_t)zc.zc_obj);
di->zerr = errno;
break;
}

Modified: head/stand/common/load_elf.c
==
--- head/stand/common/load_elf.cMon May 20 19:14:07 2019
(r348004)
+++ head/stand/common/load_elf.cMon May 20 19:21:35 2019
(r348005)
@@ -483,7 +483,7 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_
off += 0x0100;
ehdr->e_entry += off;
 #ifdef ELF_VERBOSE
-   printf("Converted entry 0x%08x\n", ehdr->e_entry);
+   printf("Converted entry 0x%jx\n", 
(uintmax_t)ehdr->e_entry);
 #endif
} else
off = 0;
@@ -509,8 +509,8 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_
off -= ehdr->e_entry & ~PAGE_MASK;
ehdr->e_entry += off;
 #ifdef ELF_VERBOSE
-   printf("ehdr->e_entry 0x%08x, va<->pa off %llx\n",
-   ehdr->e_entry, off);
+   printf("ehdr->e_entry 0x%jx", va<->pa off %llx\n",
+   (uintmax_t)ehdr->e_entry, off);
 #endif
 #else
off = 0;/* other archs use direct mapped kernels */

Modified: head/stand/ofw/libofw/ofw_net.c
==
--- head/stand/ofw/libofw/ofw_net.c Mon May 20 19:14:07 2019
(r348004)
+++ head/stand/ofw/libofw/ofw_net.c Mon May 20 19:21:35 2019
(r348005)
@@ -225,12 +225,12 @@ ofwn_init(struct iodesc *desc, void *machdep_hint)
dmabuf = NULL;
if (OF_call_method("dma-alloc", netinstance, 1, 1, (64 * 1024), &dmabuf)
< 0) {   
-   printf("Failed to allocate DMA buffer (got %08x).\n", dmabuf);
+   printf("Failed to allocate DMA buffer (got %p).\n", dmabuf);
goto punt;
}
 
 #if defined(NETIF_DEBUG)
-   printf("ofwn_init: allocated DMA buffer: %08x\n", dmabuf);
+   printf("ofwn_init: allocated DMA buffer: %p\n", dmabuf);
 #endif
 #endif
 

Modified: head/stand/ofw/libofw/openfirm.c
==
--- head/stand/ofw/libofw/openfirm.cMon May 20 19:14:07 2019
(r348004)
+++ head/stand/ofw/libofw/openfirm.cMon May 20 19:21:35 2019
(r348005)
@@ -669,7 +669,6 @@ OF_block_size(ihandle_t instance)
 }
 
 /* 
-/*
  * Memory functions
  */
 

Modified: head/stand/powerpc/boot1.chrp/boot1.c
==
--- head/stand/powerpc/boot1.chrp/boot1.c   Mon May 20 19:14:07 2019
(r348004)
+++ head/stand/powerpc/boot1.chrp/boot1.c   Mon May 20 19:21:35 2019
(r348005)
@@ -23,6 +23,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include "paths.h"
 

Modified: head/stand/powe

svn commit: r348006 - head/sys/dev/usb/net

2019-05-20 Thread Ed Maste
Author: emaste
Date: Mon May 20 19:31:49 2019
New Revision: 348006
URL: https://svnweb.freebsd.org/changeset/base/348006

Log:
  muge: update FDT LED configuration
  
  Also use LED mode settings from the FDT to set the PHY.
  From v3 of the patch submitted in the PR.
  
  I moved the sc_led_modes and sc_led_modes_mask default setting outside
  of the #ifdef FDT case.
  
  PR:   237325
  Submitted by: Ralf 
  Reviewed by:  ian
  MFC after:2 weeks
  MFC with: r348001
  Event:Waterloo Hackathon 2019
  Differential Revision:https://reviews.freebsd.org/D20325

Modified:
  head/sys/dev/usb/net/if_muge.c
  head/sys/dev/usb/net/if_mugereg.h

Modified: head/sys/dev/usb/net/if_muge.c
==
--- head/sys/dev/usb/net/if_muge.c  Mon May 20 19:21:35 2019
(r348005)
+++ head/sys/dev/usb/net/if_muge.c  Mon May 20 19:31:49 2019
(r348006)
@@ -174,6 +174,8 @@ struct muge_softc {
struct usb_xfer *sc_xfer[MUGE_N_TRANSFER];
int sc_phyno;
uint32_tsc_leds;
+   uint16_tsc_led_modes;
+   uint16_tsc_led_modes_mask;
 
/* Settings for the mac control (MAC_CSR) register. */
uint32_tsc_rfe_ctl;
@@ -890,7 +892,7 @@ static int
 lan78xx_phy_init(struct muge_softc *sc)
 {
muge_dbg_printf(sc, "Initializing PHY.\n");
-   uint16_t bmcr;
+   uint16_t bmcr, lmsr;
usb_ticks_t start_ticks;
uint32_t hw_reg;
const usb_ticks_t max_ticks = USB_MS_TO_TICKS(1000);
@@ -934,6 +936,16 @@ lan78xx_phy_init(struct muge_softc *sc)
lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno, MII_BMCR, bmcr);
bmcr = lan78xx_miibus_readreg(sc->sc_ue.ue_dev, sc->sc_phyno, MII_BMCR);
 
+   /* Configure LED Modes. */
+   if (sc->sc_led_modes_mask != 0x) {
+   lmsr = lan78xx_miibus_readreg(sc->sc_ue.ue_dev, sc->sc_phyno,
+   MUGE_PHY_LED_MODE);
+   lmsr &= sc->sc_led_modes_mask;
+   lmsr |= sc->sc_led_modes;
+   lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno,
+   MUGE_PHY_LED_MODE, lmsr);
+   }
+
/* Enable appropriate LEDs. */
if (sc->sc_leds != 0 &&
lan78xx_read_reg(sc, ETH_HW_CFG, &hw_reg) == 0) {
@@ -1534,37 +1546,6 @@ muge_fdt_find_mac(const char *compatible, unsigned cha
 
return (ENXIO);
 }
-
-/**
- * muge_fdt_count_led_modes - read number of LED modes from node
- * @compatible: compatible string for DTB node in the form
- * "usb[N]NNN,[M]MMM"
- * where NNN is vendor id and MMM is product id
- * @amount: memory to store number of LED entries to
- *
- * Tries to find matching node in DTS and obtain number of entries from it.
- *
- * RETURNS:
- * Returns 0 on success, error code otherwise
- */
-static int
-muge_fdt_count_led_modes(struct muge_softc *sc, const char *compatible,
-uint32_t *amount)
-{
-   phandle_t node, root;
-   ssize_t proplen;
-
-   *amount = 0;
-   root = OF_finddevice("/");
-   node = muge_fdt_find_eth_node(root, compatible);
-   if (node != -1 &&
-  (proplen = OF_getproplen(node, "microchip,led-modes")) > 0) {
-   *amount = proplen / sizeof( uint32_t );
-   return (0);
-   }
-
-   return (ENXIO);
-}
 #endif
 
 /**
@@ -1646,25 +1627,37 @@ muge_set_leds(struct usb_ether *ue)
 #ifdef FDT
char compatible[16];
struct usb_attach_arg *uaa = device_get_ivars(ue->ue_dev);
+   phandle_t root, node;
+   pcell_t led_modes[4];   /* 4 LEDs are possible */
+   ssize_t proplen;
uint32_t count;
 #endif
 
sc->sc_leds = 0;/* no LED mode is set */
+   sc->sc_led_modes = 0;
+   sc->sc_led_modes_mask = 0x;
if (lan78xx_eeprom_present(sc))
return;
 #ifdef FDT
snprintf(compatible, sizeof(compatible), "usb%x,%x",
uaa->info.idVendor, uaa->info.idProduct);
-   if (muge_fdt_count_led_modes(sc, compatible, &count) == 0) {
+   root = OF_finddevice("/");
+   if ((node = muge_fdt_find_eth_node(root, compatible)) != -1 &&
+   (proplen = OF_getencprop(node, "microchip,led-modes", led_modes,
+   sizeof(led_modes))) > 0) {
+   count = proplen / sizeof( uint32_t );
sc->sc_leds = (count > 0) * ETH_HW_CFG_LEDO_EN_ |
  (count > 1) * ETH_HW_CFG_LED1_EN_ |
  (count > 2) * ETH_HW_CFG_LED2_EN_ |
  (count > 3) * ETH_HW_CFG_LED3_EN_;
+   while (count-- > 0) {
+   sc->sc_led_modes |=
+   (led_modes[count] & 0xf) << (4 * count);
+   sc->sc_led_modes_mask <<= 4;
+   }
muge_dbg_printf(sc

Re: svn commit: r347984 - in head/sys: amd64/vmm/io arm/allwinner arm/allwinner/a10 arm/allwinner/clkng arm/arm arm/broadcom/bcm2835 arm/freescale/imx arm/mv arm/mv/armada arm/nvidia arm/nvidia/tegra1

2019-05-20 Thread Conrad Meyer
Hi Peter,

Thanks for reporting this.  I ran a full tinderbox on this change
(many many tinderboxes) and am not sure how I missed this.  I have to
run to an appointment now, but will fix these in a couple hours if no
one else beats me to it.  The fix is straightforward — include
.

Best,
Conrad

On Mon, May 20, 2019 at 12:21 PM Peter Jeremy  wrote:
>
> On 2019-May-20 00:38:23 +, Conrad Meyer  wrote:
> >Author: cem
> >Date: Mon May 20 00:38:23 2019
> >New Revision: 347984
> >URL: https://svnweb.freebsd.org/changeset/base/347984
> >
> >Log:
> >  Extract eventfilter declarations to sys/_eventfilter.h
> ...
> >  No functional change (intended).  Of course, any out of tree modules that
> >  relied on header pollution for sys/eventhandler.h, sys/lock.h, or
> >  sys/mutex.h inclusion need to be fixed.  __FreeBSD_version has been bumped.
>
> This seems to have broken at least netmap and netdump for me:
> /usr/src/sys/dev/netmap/netmap_freebsd.c:191:3: error: implicit declaration 
> of function 'EVENTHANDLER_REGISTER' is invalid in C99 
> [-Werror,-Wimplicit-function-declaration]
> EVENTHANDLER_REGISTER(ifnet_arrival_event,
> ^
> ...
> /usr/src/sys/netinet/netdump/netdump_client.c:1458:22: error: implicit 
> declaration of function 'EVENTHANDLER_REGISTER' is invalid in C99 
> [-Werror,-Wimplicit-function-declaration]
> nd_detach_cookie = 
> EVENTHANDLER_REGISTER(ifnet_departure_event,
>^
>
> --
> Peter Jeremy
___
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: r348008 - head/lib/csu/mips

2019-05-20 Thread Ed Maste
Author: emaste
Date: Mon May 20 20:48:04 2019
New Revision: 348008
URL: https://svnweb.freebsd.org/changeset/base/348008

Log:
  mips: remove 16-byte alignment from .init and .fini epilogues
  
  The .init and .fini epilogues from crtn should be placed immediately
  after any instructions in .init and .fini sections from the linked
  objects.  Using 16-byte alignment for the epilogues on MIPS was a bug,
  but it did not cause any issue with GNU ld as GNU ld (2.17.50) fills the
  padding with NOPs.
  
  Current versions of LLD fill any padding between different object files
  with trap instructions.  Inserting trap padding prior to the .init/.fini
  epilogue is undesriable as the resulting binary will crash at runtime.
  
  The .init and .fini sections in object files linked between crti and
  crtn must already be a multiple of the instruction size and so no
  alignment directive is required in crtn.  Indeed, other architectures
  (except sparc64) do not specify alignment in their crtn implementations.
  
  Reported by:  arichardson
  Reviewed by:  andrew
  Event:Waterloo Hackathon 2019
  Differential Revision:https://reviews.freebsd.org/D18291

Modified:
  head/lib/csu/mips/crtn.S

Modified: head/lib/csu/mips/crtn.S
==
--- head/lib/csu/mips/crtn.SMon May 20 19:36:36 2019(r348007)
+++ head/lib/csu/mips/crtn.SMon May 20 20:48:04 2019(r348008)
@@ -5,7 +5,6 @@ __FBSDID("$FreeBSD$");
.gnu_attribute 4, 0
 #endif
.section .init,"ax",%progbits
-   .align 4
.set noreorder
 #if defined(__ABICALLS__) && (defined(__mips_n32) || defined(__mips_n64))
REG_L   gp, CALLFRAME_GP(sp)
@@ -16,7 +15,6 @@ __FBSDID("$FreeBSD$");
.set reorder
 
.section .fini,"ax",%progbits
-   .align 4
.set noreorder
 #if defined(__ABICALLS__) && (defined(__mips_n32) || defined(__mips_n64))
REG_L   gp, CALLFRAME_GP(sp)
___
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: r348011 - head/share/man/man9

2019-05-20 Thread Mark Johnston
Author: markj
Date: Mon May 20 21:23:33 2019
New Revision: 348011
URL: https://svnweb.freebsd.org/changeset/base/348011

Log:
  Hook DEFINE_IFUNC.9 up to the build.
  
  Reported by:  pluknet
  MFC with: r348003

Modified:
  head/share/man/man9/Makefile

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileMon May 20 20:55:01 2019
(r348010)
+++ head/share/man/man9/MakefileMon May 20 21:23:33 2019
(r348011)
@@ -75,6 +75,7 @@ MAN=  accept_filter.9 \
DB_COMMAND.9 \
DECLARE_GEOM_CLASS.9 \
DECLARE_MODULE.9 \
+   DEFINE_IFUNC.9 \
DELAY.9 \
devclass.9 \
devclass_find.9 \
___
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: r348013 - head/sys/dev/usb/net

2019-05-20 Thread Ian Lepore
Author: ian
Date: Mon May 20 21:45:00 2019
New Revision: 348013
URL: https://svnweb.freebsd.org/changeset/base/348013

Log:
  Use the new usb fdt support functions to locate the proper fdt node for
  the device instance, and to get the MAC address for the device instance.
  The ad-hoc code this replaces could find the wrong instance if multiple
  devices were present.

Modified:
  head/sys/dev/usb/net/if_muge.c

Modified: head/sys/dev/usb/net/if_muge.c
==
--- head/sys/dev/usb/net/if_muge.c  Mon May 20 21:33:22 2019
(r348012)
+++ head/sys/dev/usb/net/if_muge.c  Mon May 20 21:45:00 2019
(r348013)
@@ -97,6 +97,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #endif
 
 #include 
@@ -1454,101 +1455,7 @@ tr_setup:
}
 }
 
-#ifdef FDT
 /**
- * muge_fdt_find_eth_node - find descendant node with required 
compatibility
- * @start: start node
- * @compatible: compatible string used to identify the node
- *
- * Loop through all descendant nodes and return first match with required
- * compatibility.
- *
- * RETURNS:
- * Returns node's phandle on success -1 otherwise
- */
-static phandle_t
-muge_fdt_find_eth_node(phandle_t start, const char *compatible)
-{
-   phandle_t child, node;
-
-   /* Traverse through entire tree to find usb ethernet nodes. */
-   for (node = OF_child(start); node != 0; node = OF_peer(node)) {
-   if (ofw_bus_node_is_compatible(node, compatible))
-   return (node);
-   child = muge_fdt_find_eth_node(node, compatible);
-   if (child != -1)
-   return (child);
-   }
-
-   return (-1);
-}
-
-/**
- * muge_fdt_read_mac_property - read MAC address from node
- * @node: USB device node
- * @mac: memory to store MAC address to
- *
- * Check for common properties that might contain MAC address
- * passed by boot loader.
- *
- * RETURNS:
- * Returns 0 on success, error code otherwise
- */
-static int
-muge_fdt_read_mac_property(phandle_t node, unsigned char *mac)
-{
-   int len;
-
-   /* Check if there is property */
-   if ((len = OF_getproplen(node, "local-mac-address")) > 0) {
-   if (len != ETHER_ADDR_LEN)
-   return (EINVAL);
-
-   OF_getprop(node, "local-mac-address", mac,
-   ETHER_ADDR_LEN);
-   return (0);
-   }
-
-   if ((len = OF_getproplen(node, "mac-address")) > 0) {
-   if (len != ETHER_ADDR_LEN)
-   return (EINVAL);
-
-   OF_getprop(node, "mac-address", mac,
-   ETHER_ADDR_LEN);
-   return (0);
-   }
-
-   return (ENXIO);
-}
-
-/**
- * muge_fdt_find_mac - read MAC address from node
- * @compatible: compatible string for DTB node in the form 
"usb[N]NNN,[M]MMM"
- * where NNN is vendor id and MMM is product id
- * @mac: memory to store MAC address to
- *
- * Tries to find matching node in DTS and obtain MAC address info from it
- *
- * RETURNS:
- * Returns 0 on success, error code otherwise
- */
-static int
-muge_fdt_find_mac(const char *compatible, unsigned char *mac)
-{
-   phandle_t node, root;
-
-   root = OF_finddevice("/");
-   node = muge_fdt_find_eth_node(root, compatible);
-   if (node != -1) {
-   if (muge_fdt_read_mac_property(node, mac) == 0)
-   return (0);
-   }
-
-   return (ENXIO);
-}
-#endif
-
-/**
  * muge_set_mac_addr - Initiailizes NIC MAC address
  * @ue: the USB ethernet device
  *
@@ -1560,10 +1467,6 @@ muge_set_mac_addr(struct usb_ether *ue)
 {
struct muge_softc *sc = uether_getsc(ue);
uint32_t mac_h, mac_l;
-#ifdef FDT
-   char compatible[16];
-   struct usb_attach_arg *uaa = device_get_ivars(ue->ue_dev);
-#endif
 
memset(sc->sc_ue.ue_eaddr, 0xff, ETHER_ADDR_LEN);
 
@@ -1599,10 +1502,10 @@ muge_set_mac_addr(struct usb_ether *ue)
}
 
 #ifdef FDT
-   snprintf(compatible, sizeof(compatible), "usb%x,%x",
-   uaa->info.idVendor, uaa->info.idProduct);
-   if (muge_fdt_find_mac(compatible, sc->sc_ue.ue_eaddr) == 0) {
-   muge_dbg_printf(sc, "MAC assigned from FDT blob\n");
+   /* ue->ue_eaddr modified only if config exists for this dev instance. */
+   usb_fdt_get_mac_addr(ue->ue_dev, ue);
+   if (ETHER_IS_VALID(sc->sc_ue.ue_eaddr)) {
+   muge_dbg_printf(sc, "MAC read from FDT data\n");
return;
}
 #endif
@@ -1625,9 +1528,7 @@ muge_set_leds(struct usb_ether *ue)
 {
struct muge_softc *sc = uether_getsc(ue);
 #ifdef FDT
-   char compatible[16];
-   struct usb_attach_arg *uaa = device_get_ivars(ue->ue_dev);
-   phandle_t root, node;
+   phandle_t node;
pcell_t led_modes[4];   /* 4 LEDs are pos

svn commit: r348016 - head/sys/dev/usb/net

2019-05-20 Thread Ian Lepore
Author: ian
Date: Mon May 20 22:04:01 2019
New Revision: 348016
URL: https://svnweb.freebsd.org/changeset/base/348016

Log:
  Don't detour through sc->sc_ue when we have a direct pointer to ue in hand
  already.  Also, shorten a variable name for nicer line-wrapping.
  
  No functional changes.

Modified:
  head/sys/dev/usb/net/if_muge.c

Modified: head/sys/dev/usb/net/if_muge.c
==
--- head/sys/dev/usb/net/if_muge.c  Mon May 20 22:02:54 2019
(r348015)
+++ head/sys/dev/usb/net/if_muge.c  Mon May 20 22:04:01 2019
(r348016)
@@ -1468,7 +1468,7 @@ muge_set_mac_addr(struct usb_ether *ue)
struct muge_softc *sc = uether_getsc(ue);
uint32_t mac_h, mac_l;
 
-   memset(sc->sc_ue.ue_eaddr, 0xff, ETHER_ADDR_LEN);
+   memset(ue->ue_eaddr, 0xff, ETHER_ADDR_LEN);
 
uint32_t val;
lan78xx_read_reg(sc, 0, &val);
@@ -1476,26 +1476,26 @@ muge_set_mac_addr(struct usb_ether *ue)
/* Read current MAC address from RX_ADDRx registers. */
if ((lan78xx_read_reg(sc, ETH_RX_ADDRL, &mac_l) == 0) &&
(lan78xx_read_reg(sc, ETH_RX_ADDRH, &mac_h) == 0)) {
-   sc->sc_ue.ue_eaddr[5] = (uint8_t)((mac_h >> 8) & 0xff);
-   sc->sc_ue.ue_eaddr[4] = (uint8_t)((mac_h) & 0xff);
-   sc->sc_ue.ue_eaddr[3] = (uint8_t)((mac_l >> 24) & 0xff);
-   sc->sc_ue.ue_eaddr[2] = (uint8_t)((mac_l >> 16) & 0xff);
-   sc->sc_ue.ue_eaddr[1] = (uint8_t)((mac_l >> 8) & 0xff);
-   sc->sc_ue.ue_eaddr[0] = (uint8_t)((mac_l) & 0xff);
+   ue->ue_eaddr[5] = (uint8_t)((mac_h >> 8) & 0xff);
+   ue->ue_eaddr[4] = (uint8_t)((mac_h) & 0xff);
+   ue->ue_eaddr[3] = (uint8_t)((mac_l >> 24) & 0xff);
+   ue->ue_eaddr[2] = (uint8_t)((mac_l >> 16) & 0xff);
+   ue->ue_eaddr[1] = (uint8_t)((mac_l >> 8) & 0xff);
+   ue->ue_eaddr[0] = (uint8_t)((mac_l) & 0xff);
}
 
/* If RX_ADDRx did not provide a valid MAC address, try EEPROM. */
-   if (ETHER_IS_VALID(sc->sc_ue.ue_eaddr)) {
+   if (ETHER_IS_VALID(ue->ue_eaddr)) {
muge_dbg_printf(sc, "MAC assigned from registers\n");
return;
}
 
if ((lan78xx_eeprom_present(sc) &&
lan78xx_eeprom_read_raw(sc, ETH_E2P_MAC_OFFSET,
-   sc->sc_ue.ue_eaddr, ETHER_ADDR_LEN) == 0) ||
+   ue->ue_eaddr, ETHER_ADDR_LEN) == 0) ||
(lan78xx_otp_read(sc, OTP_MAC_OFFSET,
-   sc->sc_ue.ue_eaddr, ETHER_ADDR_LEN) == 0)) {
-   if (ETHER_IS_VALID(sc->sc_ue.ue_eaddr)) {
+   ue->ue_eaddr, ETHER_ADDR_LEN) == 0)) {
+   if (ETHER_IS_VALID(ue->ue_eaddr)) {
muge_dbg_printf(sc, "MAC read from EEPROM\n");
return;
}
@@ -1504,16 +1504,16 @@ muge_set_mac_addr(struct usb_ether *ue)
 #ifdef FDT
/* ue->ue_eaddr modified only if config exists for this dev instance. */
usb_fdt_get_mac_addr(ue->ue_dev, ue);
-   if (ETHER_IS_VALID(sc->sc_ue.ue_eaddr)) {
+   if (ETHER_IS_VALID(ue->ue_eaddr)) {
muge_dbg_printf(sc, "MAC read from FDT data\n");
return;
}
 #endif
 
muge_dbg_printf(sc, "MAC assigned randomly\n");
-   arc4rand(sc->sc_ue.ue_eaddr, ETHER_ADDR_LEN, 0);
-   sc->sc_ue.ue_eaddr[0] &= ~0x01; /* unicast */
-   sc->sc_ue.ue_eaddr[0] |= 0x02;  /* locally administered */
+   arc4rand(ue->ue_eaddr, ETHER_ADDR_LEN, 0);
+   ue->ue_eaddr[0] &= ~0x01;   /* unicast */
+   ue->ue_eaddr[0] |= 0x02;/* locally administered */
 }
 
 /**
@@ -1529,7 +1529,7 @@ muge_set_leds(struct usb_ether *ue)
struct muge_softc *sc = uether_getsc(ue);
 #ifdef FDT
phandle_t node;
-   pcell_t led_modes[4];   /* 4 LEDs are possible */
+   pcell_t modes[4];   /* 4 LEDs are possible */
ssize_t proplen;
uint32_t count;
 #endif
@@ -1541,16 +1541,15 @@ muge_set_leds(struct usb_ether *ue)
return;
 #ifdef FDT
if ((node = usb_fdt_get_node(ue->ue_dev, ue->ue_udev)) != -1 &&
-   (proplen = OF_getencprop(node, "microchip,led-modes", led_modes,
-   sizeof(led_modes))) > 0) {
+   (proplen = OF_getencprop(node, "microchip,led-modes", modes,
+   sizeof(modes))) > 0) {
count = proplen / sizeof( uint32_t );
sc->sc_leds = (count > 0) * ETH_HW_CFG_LEDO_EN_ |
  (count > 1) * ETH_HW_CFG_LED1_EN_ |
  (count > 2) * ETH_HW_CFG_LED2_EN_ |
  (count > 3) * ETH_HW_CFG_LED3_EN_;
while (count-- > 0) {
-   sc->sc_led_modes |=
-   (led_modes[count] & 0xf) << (4 * count);
+   sc->sc_led_modes |= (modes[count] & 0xf) << (4 * count);
 

svn commit: r348018 - head/sys/dev/usb/net

2019-05-20 Thread Ian Lepore
Author: ian
Date: Mon May 20 22:21:47 2019
New Revision: 348018
URL: https://svnweb.freebsd.org/changeset/base/348018

Log:
  A MAC adddress from FDT data should override anything stored in eeprom or
  OTP registers (because the user is in control of the fdt data).  Remove the
  early returns from the code that tries to find a good mac address, so that
  the execution always flows through the routine to get an address from FDT
  data last, when on FDT-enabled systems.

Modified:
  head/sys/dev/usb/net/if_muge.c

Modified: head/sys/dev/usb/net/if_muge.c
==
--- head/sys/dev/usb/net/if_muge.c  Mon May 20 22:21:42 2019
(r348017)
+++ head/sys/dev/usb/net/if_muge.c  Mon May 20 22:21:47 2019
(r348018)
@@ -1484,36 +1484,36 @@ muge_set_mac_addr(struct usb_ether *ue)
ue->ue_eaddr[0] = (uint8_t)((mac_l) & 0xff);
}
 
-   /* If RX_ADDRx did not provide a valid MAC address, try EEPROM. */
+   /*
+* If RX_ADDRx did not provide a valid MAC address, try EEPROM.  If that
+* doesn't work, try OTP.  Whether any of these methods work or not, try
+* FDT data, because it is allowed to override the EEPROM/OTP values.
+*/
if (ETHER_IS_VALID(ue->ue_eaddr)) {
muge_dbg_printf(sc, "MAC assigned from registers\n");
-   return;
+   } else if (lan78xx_eeprom_present(sc) && lan78xx_eeprom_read_raw(sc,
+   ETH_E2P_MAC_OFFSET, ue->ue_eaddr, ETHER_ADDR_LEN) == 0 &&
+   ETHER_IS_VALID(ue->ue_eaddr)) {
+   muge_dbg_printf(sc, "MAC assigned from EEPROM\n");
+   } else if (lan78xx_otp_read(sc, OTP_MAC_OFFSET, ue->ue_eaddr,
+   ETHER_ADDR_LEN) == 0 && ETHER_IS_VALID(ue->ue_eaddr)) {
+   muge_dbg_printf(sc, "MAC assigned from OTP\n");
}
 
-   if ((lan78xx_eeprom_present(sc) &&
-   lan78xx_eeprom_read_raw(sc, ETH_E2P_MAC_OFFSET,
-   ue->ue_eaddr, ETHER_ADDR_LEN) == 0) ||
-   (lan78xx_otp_read(sc, OTP_MAC_OFFSET,
-   ue->ue_eaddr, ETHER_ADDR_LEN) == 0)) {
-   if (ETHER_IS_VALID(ue->ue_eaddr)) {
-   muge_dbg_printf(sc, "MAC read from EEPROM\n");
-   return;
-   }
-   }
-
 #ifdef FDT
/* ue->ue_eaddr modified only if config exists for this dev instance. */
usb_fdt_get_mac_addr(ue->ue_dev, ue);
if (ETHER_IS_VALID(ue->ue_eaddr)) {
-   muge_dbg_printf(sc, "MAC read from FDT data\n");
-   return;
+   muge_dbg_printf(sc, "MAC assigned from FDT data\n");
}
 #endif
 
-   muge_dbg_printf(sc, "MAC assigned randomly\n");
-   arc4rand(ue->ue_eaddr, ETHER_ADDR_LEN, 0);
-   ue->ue_eaddr[0] &= ~0x01;   /* unicast */
-   ue->ue_eaddr[0] |= 0x02;/* locally administered */
+   if (!ETHER_IS_VALID(ue->ue_eaddr)) {
+   muge_dbg_printf(sc, "MAC assigned randomly\n");
+   arc4rand(ue->ue_eaddr, ETHER_ADDR_LEN, 0);
+   ue->ue_eaddr[0] &= ~0x01;   /* unicast */
+   ue->ue_eaddr[0] |= 0x02;/* locally administered */
+   }
 }
 
 /**
___
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: r348019 - head/tests/sys/opencrypto

2019-05-20 Thread Enji Cooper
Author: ngie
Date: Mon May 20 22:32:26 2019
New Revision: 348019
URL: https://svnweb.freebsd.org/changeset/base/348019

Log:
  Allow the end-user to pass along arguments to cryptotest.py via 
`$CRYPTOTEST_ARGS`
  
  This allows someone to use `-v` to dump out standard output.

Modified:
  head/tests/sys/opencrypto/runtests.sh

Modified: head/tests/sys/opencrypto/runtests.sh
==
--- head/tests/sys/opencrypto/runtests.sh   Mon May 20 22:21:47 2019
(r348018)
+++ head/tests/sys/opencrypto/runtests.sh   Mon May 20 22:32:26 2019
(r348019)
@@ -81,7 +81,7 @@ if ! sysctl $cdas_sysctl=1; then
 fi
 
 echo "1..1"
-if "$PYTHON" $(dirname $0)/cryptotest.py; then
+if "$PYTHON" $(dirname $0)/cryptotest.py $CRYPTOTEST_ARGS; then
echo "ok 1"
 else
echo "not ok 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: r348020 - head/sys/dev/usb/net

2019-05-20 Thread Ian Lepore
Author: ian
Date: Mon May 20 22:32:31 2019
New Revision: 348020
URL: https://svnweb.freebsd.org/changeset/base/348020

Log:
  Reverse the bit logic of sc_led_modes_mask.  Instead of initializing it to
  all-ones then carving out blocks of zeroes where specified values go, init
  it to all-zeroes, put in ones where values need to be masked, then use it
  as value &= ~sc_led_modes_mask.  In addition to being more idiomatic, this
  means everything related to FDT data is initialized to zero along with the
  rest of the softc, and that allows removing some #ifdef FDT sections and
  wrapping the whole muge_set_leds() function in a single ifdef block.
  
  This also deletes the early-out from muge_set_leds() when an eeprom exists.
  Even if there is an eeprom with led config in it, the fdt data (if present)
  should override that, because the user is in control of the fdt data.

Modified:
  head/sys/dev/usb/net/if_muge.c

Modified: head/sys/dev/usb/net/if_muge.c
==
--- head/sys/dev/usb/net/if_muge.c  Mon May 20 22:32:26 2019
(r348019)
+++ head/sys/dev/usb/net/if_muge.c  Mon May 20 22:32:31 2019
(r348020)
@@ -938,10 +938,10 @@ lan78xx_phy_init(struct muge_softc *sc)
bmcr = lan78xx_miibus_readreg(sc->sc_ue.ue_dev, sc->sc_phyno, MII_BMCR);
 
/* Configure LED Modes. */
-   if (sc->sc_led_modes_mask != 0x) {
+   if (sc->sc_led_modes_mask != 0) {
lmsr = lan78xx_miibus_readreg(sc->sc_ue.ue_dev, sc->sc_phyno,
MUGE_PHY_LED_MODE);
-   lmsr &= sc->sc_led_modes_mask;
+   lmsr &= ~sc->sc_led_modes_mask;
lmsr |= sc->sc_led_modes;
lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno,
MUGE_PHY_LED_MODE, lmsr);
@@ -1526,20 +1526,13 @@ muge_set_mac_addr(struct usb_ether *ue)
 static void
 muge_set_leds(struct usb_ether *ue)
 {
-   struct muge_softc *sc = uether_getsc(ue);
 #ifdef FDT
+   struct muge_softc *sc = uether_getsc(ue);
phandle_t node;
pcell_t modes[4];   /* 4 LEDs are possible */
ssize_t proplen;
uint32_t count;
-#endif
 
-   sc->sc_leds = 0;/* no LED mode is set */
-   sc->sc_led_modes = 0;
-   sc->sc_led_modes_mask = 0x;
-   if (lan78xx_eeprom_present(sc))
-   return;
-#ifdef FDT
if ((node = usb_fdt_get_node(ue->ue_dev, ue->ue_udev)) != -1 &&
(proplen = OF_getencprop(node, "microchip,led-modes", modes,
sizeof(modes))) > 0) {
@@ -1550,7 +1543,7 @@ muge_set_leds(struct usb_ether *ue)
  (count > 3) * ETH_HW_CFG_LED3_EN_;
while (count-- > 0) {
sc->sc_led_modes |= (modes[count] & 0xf) << (4 * count);
-   sc->sc_led_modes_mask <<= 4;
+   sc->sc_led_modes_mask |= 0xf << (4 * count);
}
muge_dbg_printf(sc, "LED modes set from FDT data\n");
}
___
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: r347982 - head/sys/net

2019-05-20 Thread Alexander V . Chernikov
20.05.2019, 07:50, "Rodney W. Grimes" :
>>  Author: melifaro
>>  Date: Sun May 19 21:49:56 2019
>>  New Revision: 347982
>>  URL: https://svnweb.freebsd.org/changeset/base/347982
>>
>>  Log:
>>    Fix rt_ifa selection during loopback route insertion process.
>>  Currently such routes are added with a link-level IFA, which is
>>  plain wrong. Only after the insertion they get fixed by the special
>>  link_rtrequest() ifa handler. This behaviour complicates routing code
>>  and makes ifa selection more complex.
>>    Streamline this process by explicitly moving link_rtrequest() logic
>>  to the pre-insertion rt_getifa_fib() ifa selector. Avoid calling all
>>  this logic in the loopback route case by explicitly specifying
>>  proper rt_ifa inside the ifa_maintain_loopback_route().?
>>
>>    MFC after: 2 weeks
>>    Differential Revision: https://reviews.freebsd.org/D20076
>
> I shall again state that from a routing protocol perspecitive
> and a POLA perspective having the kernel doing route maintanance
> of any kind is fundementally wrong.
>
> I still continue to stronly object to ifa_maintain_loopback_route
> code even being present in our kernel. Having these routes
> is a micro optimization at best, and cause issues when real
> and actual routing protocols are in use.
I agree with that. It indeed causes decent amount of complications and I (as 
another router type person) prefer to have it gone as well.
However, one has to carefully check uRPF functionality in our firewalls, 
implement fib-aware in_localip_more (and its IPv6 counterpart) to make it 
happen.
>
> Bruce Evans and myself have locally killed this code, and
> just about every router type person I show it to gets ill
> seeing it.
>
> Show many another system that does this and I might reconsider,
> but I have never ever seen one.
>
>>  Modified:
>>    head/sys/net/if.c
>>    head/sys/net/route.c
>>
>>  Modified: head/sys/net/if.c
>>  
>> ==
>>  --- head/sys/net/if.c Sun May 19 20:28:49 2019 (r347981)
>>  +++ head/sys/net/if.c Sun May 19 21:49:56 2019 (r347982)
>>  @@ -264,7 +264,6 @@ static void if_route(struct ifnet *, int flag, int fam
>>   static int if_setflag(struct ifnet *, int, int, int *, int);
>>   static int if_transmit(struct ifnet *ifp, struct mbuf *m);
>>   static void if_unroute(struct ifnet *, int flag, int fam);
>>  -static void link_rtrequest(int, struct rtentry *, struct rt_addrinfo *);
>>   static int if_delmulti_locked(struct ifnet *, struct ifmultiaddr *, int);
>>   static void do_link_state_change(void *, int);
>>   static int if_getgroup(struct ifgroupreq *, struct ifnet *);
>>  @@ -862,7 +861,6 @@ if_attach_internal(struct ifnet *ifp, int vmove, struc
>>   sdl->sdl_type = ifp->if_type;
>>   ifp->if_addr = ifa;
>>   ifa->ifa_ifp = ifp;
>>  - ifa->ifa_rtrequest = link_rtrequest;
>>   ifa->ifa_addr = (struct sockaddr *)sdl;
>>   sdl = (struct sockaddr_dl *)(socksize + (caddr_t)sdl);
>>   ifa->ifa_netmask = (struct sockaddr *)sdl;
>>  @@ -1892,6 +1890,7 @@ static int
>>   ifa_maintain_loopback_route(int cmd, const char *otype, struct ifaddr *ifa,
>>   struct sockaddr *ia)
>>   {
>>  + struct epoch_tracker et;
>>   int error;
>>   struct rt_addrinfo info;
>>   struct sockaddr_dl null_sdl;
>>  @@ -1902,6 +1901,16 @@ ifa_maintain_loopback_route(int cmd, const char 
>> *otype
>>   bzero(&info, sizeof(info));
>>   if (cmd != RTM_DELETE)
>>   info.rti_ifp = V_loif;
>>  + if (cmd == RTM_ADD) {
>>  + /* explicitly specify (loopback) ifa */
>>  + if (info.rti_ifp != NULL) {
>>  + NET_EPOCH_ENTER(et);
>>  + info.rti_ifa = ifaof_ifpforaddr(ifa->ifa_addr, info.rti_ifp);
>>  + if (info.rti_ifa != NULL)
>>  + ifa_ref(info.rti_ifa);
>>  + NET_EPOCH_EXIT(et);
>>  + }
>>  + }
>>   info.rti_flags = ifa->ifa_flags | RTF_HOST | RTF_STATIC | 
>> RTF_PINNED;
>>   info.rti_info[RTAX_DST] = ia;
>>   info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&null_sdl;
>>  @@ -2208,39 +2217,6 @@ ifa_preferred(struct ifaddr *cur, struct ifaddr 
>> *next)
>>
>>   return (cur->ifa_carp && (!next->ifa_carp ||
>>   ((*carp_master_p)(next) && !(*carp_master_p)(cur;
>>  -}
>>  -
>>  -#include 
>>  -
>>  -/*
>>  - * Default action when installing a route with a Link Level gateway.
>>  - * Lookup an appropriate real ifa to point to.
>>  - * This should be moved to /sys/net/link.c eventually.
>>  - */
>>  -static void
>>  -link_rtrequest(int cmd, struct rtentry *rt, struct rt_addrinfo *info)
>>  -{
>>  - struct epoch_tracker et;
>>  - struct ifaddr *ifa, *oifa;
>>  - struct sockaddr *dst;
>>  - struct ifnet *ifp;
>>  -
>>  - if (cmd != RTM_ADD || ((ifa = rt->rt_ifa) == NULL) ||
>>  - ((ifp = ifa->ifa_ifp) == NULL) || ((dst = rt_key(rt)) == NULL))
>>  - return;
>>  - NE

svn commit: r348022 - in head/sys: dev/netmap netinet/netdump

2019-05-20 Thread Conrad Meyer
Author: cem
Date: Tue May 21 00:04:19 2019
New Revision: 348022
URL: https://svnweb.freebsd.org/changeset/base/348022

Log:
  Add two missing eventhandler.h headers
  
  These are obviously missing from the .c files, but don't show up in any
  tinderbox configuration (due to latent header pollution of some kind).  It
  seems some configurations don't have this pollution, and the includes are
  obviously missing, so go ahead and add them.
  
  Reported by:  Peter Jeremy 
  X-MFC-With:   r347984

Modified:
  head/sys/dev/netmap/netmap_freebsd.c
  head/sys/netinet/netdump/netdump_client.c

Modified: head/sys/dev/netmap/netmap_freebsd.c
==
--- head/sys/dev/netmap/netmap_freebsd.cMon May 20 22:37:42 2019
(r348021)
+++ head/sys/dev/netmap/netmap_freebsd.cTue May 21 00:04:19 2019
(r348022)
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include   /* POLLIN, POLLOUT */
 #include  /* types used in module initialization */

Modified: head/sys/netinet/netdump/netdump_client.c
==
--- head/sys/netinet/netdump/netdump_client.c   Mon May 20 22:37:42 2019
(r348021)
+++ head/sys/netinet/netdump/netdump_client.c   Tue May 21 00:04:19 2019
(r348022)
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
___
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: r347984 - in head/sys: amd64/vmm/io arm/allwinner arm/allwinner/a10 arm/allwinner/clkng arm/arm arm/broadcom/bcm2835 arm/freescale/imx arm/mv arm/mv/armada arm/nvidia arm/nvidia/tegra1

2019-05-20 Thread Conrad Meyer
Hi Peter,

Can you share what your kernel configuration is?

I believe the error is masked in existing tinderbox kernel
configurations ( https://ci.freebsd.org/tinderbox/ ) by some remaining
header pollution that must be conditional on an option.  The files
you've pointed out are missing the eventhandler header (and fixing
that is trivial), but I'd like to better understand where the leak is
so that other misses can be located.

Thanks,
Conrad

On Mon, May 20, 2019 at 12:31 PM Conrad Meyer  wrote:
>
> Hi Peter,
>
> Thanks for reporting this.  I ran a full tinderbox on this change
> (many many tinderboxes) and am not sure how I missed this.  I have to
> run to an appointment now, but will fix these in a couple hours if no
> one else beats me to it.  The fix is straightforward — include
> .
>
> Best,
> Conrad
>
> On Mon, May 20, 2019 at 12:21 PM Peter Jeremy  wrote:
> >
> > On 2019-May-20 00:38:23 +, Conrad Meyer  wrote:
> > >Author: cem
> > >Date: Mon May 20 00:38:23 2019
> > >New Revision: 347984
> > >URL: https://svnweb.freebsd.org/changeset/base/347984
> > >
> > >Log:
> > >  Extract eventfilter declarations to sys/_eventfilter.h
> > ...
> > >  No functional change (intended).  Of course, any out of tree modules that
> > >  relied on header pollution for sys/eventhandler.h, sys/lock.h, or
> > >  sys/mutex.h inclusion need to be fixed.  __FreeBSD_version has been 
> > > bumped.
> >
> > This seems to have broken at least netmap and netdump for me:
> > /usr/src/sys/dev/netmap/netmap_freebsd.c:191:3: error: implicit declaration 
> > of function 'EVENTHANDLER_REGISTER' is invalid in C99 
> > [-Werror,-Wimplicit-function-declaration]
> > EVENTHANDLER_REGISTER(ifnet_arrival_event,
> > ^
> > ...
> > /usr/src/sys/netinet/netdump/netdump_client.c:1458:22: error: implicit 
> > declaration of function 'EVENTHANDLER_REGISTER' is invalid in C99 
> > [-Werror,-Wimplicit-function-declaration]
> > nd_detach_cookie = 
> > EVENTHANDLER_REGISTER(ifnet_departure_event,
> >^
> >
> > --
> > Peter Jeremy
___
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: r348024 - head/tests/sys/opencrypto

2019-05-20 Thread Enji Cooper
Author: ngie
Date: Tue May 21 00:30:29 2019
New Revision: 348024
URL: https://svnweb.freebsd.org/changeset/base/348024

Log:
  Followup to r347996
  
  Replace uses of `foo.encode("hex")` with `binascii.hexlify(foo)` for forwards
  compatibility between python 2.x and python 3.
  
  PR:   237403
  MFC after:1 week

Modified:
  head/tests/sys/opencrypto/cryptotest.py

Modified: head/tests/sys/opencrypto/cryptotest.py
==
--- head/tests/sys/opencrypto/cryptotest.py Tue May 21 00:07:53 2019
(r348023)
+++ head/tests/sys/opencrypto/cryptotest.py Tue May 21 00:30:29 2019
(r348024)
@@ -262,7 +262,7 @@ def GenTestCase(cname):
 out = r + tag
 self.assertEqual(out, ct,
 "Count " + data['Count'] + " Actual: " + \
-repr(out.encode("hex")) + " Expected: " + \
+repr(binascii.hexlify(out)) + " Expected: " + \
 repr(data) + " on " + cname)
 
 def runCCMDecrypt(self, fname):
@@ -313,7 +313,7 @@ def GenTestCase(cname):
 payload = payload[:plen]
 self.assertEqual(r, payload,
 "Count " + data['Count'] + \
-" Actual: " + repr(r.encode("hex")) + \
+" Actual: " + repr(binascii.hexlify(r)) + \
 " Expected: " + repr(data) + \
 " on " + cname)
 
@@ -405,7 +405,7 @@ def GenTestCase(cname):
 _, r = c.encrypt(msg, iv="")
 
 self.assertEqual(r, md, "Actual: " + \
-repr(r.encode("hex")) + " Expected: " + repr(data) + " 
on " + cname)
+repr(binascii.hexlify(r)) + " Expected: " + repr(data) 
+ " on " + cname)
 
 @unittest.skipIf(cname not in shamodules, 'skipping SHA-HMAC on %s' % 
str(cname))
 def test_sha1hmac(self):
@@ -462,7 +462,7 @@ def GenTestCase(cname):
 _, r = c.encrypt(msg, iv="")
 
 self.assertEqual(r[:tlen], mac, "Actual: " + \
-repr(r.encode("hex")) + " Expected: " + repr(data))
+repr(binascii.hexlify(r)) + " Expected: " + repr(data))
 
 return GendCryptoTestCase
 
___
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: r348025 - head/stand/common

2019-05-20 Thread Enji Cooper
Author: ngie
Date: Tue May 21 00:46:47 2019
New Revision: 348025
URL: https://svnweb.freebsd.org/changeset/base/348025

Log:
  Unbreak the build when `ELF_VERBOSE` is defined after r348005
  
  This change properly terminates the formatting string quote modification done
  in r348005, which is triggered when `ELF_VERBOSE` is defined.
  
  MFC with: r348005
  Reported by:  ci (amd64, gcc)

Modified:
  head/stand/common/load_elf.c

Modified: head/stand/common/load_elf.c
==
--- head/stand/common/load_elf.cTue May 21 00:30:29 2019
(r348024)
+++ head/stand/common/load_elf.cTue May 21 00:46:47 2019
(r348025)
@@ -509,7 +509,7 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_
off -= ehdr->e_entry & ~PAGE_MASK;
ehdr->e_entry += off;
 #ifdef ELF_VERBOSE
-   printf("ehdr->e_entry 0x%jx", va<->pa off %llx\n",
+   printf("ehdr->e_entry 0x%jx, va<->pa off %llx\n",
(uintmax_t)ehdr->e_entry, off);
 #endif
 #else
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r347982 - head/sys/net

2019-05-20 Thread Rodney W. Grimes
> 20.05.2019, 07:50, "Rodney W. Grimes" :
> >> ?Author: melifaro
> >> ?Date: Sun May 19 21:49:56 2019
> >> ?New Revision: 347982
> >> ?URL: https://svnweb.freebsd.org/changeset/base/347982
> >>
> >> ?Log:
> >> ???Fix rt_ifa selection during loopback route insertion process.
> >> ?Currently such routes are added with a link-level IFA, which is
> >> ?plain wrong. Only after the insertion they get fixed by the special
> >> ?link_rtrequest() ifa handler. This behaviour complicates routing code
> >> ?and makes ifa selection more complex.
> >> ???Streamline this process by explicitly moving link_rtrequest() logic
> >> ?to the pre-insertion rt_getifa_fib() ifa selector. Avoid calling all
> >> ?this logic in the loopback route case by explicitly specifying
> >> ?proper rt_ifa inside the ifa_maintain_loopback_route().?
> >>
> >> ???MFC after: 2 weeks
> >> ???Differential Revision: https://reviews.freebsd.org/D20076
> >
> > I shall again state that from a routing protocol perspecitive
> > and a POLA perspective having the kernel doing route maintanance
> > of any kind is fundementally wrong.
> >
> > I still continue to stronly object to ifa_maintain_loopback_route
> > code even being present in our kernel. Having these routes
> > is a micro optimization at best, and cause issues when real
> > and actual routing protocols are in use.
> I agree with that. It indeed causes decent amount of complications and I (as 
> another router type person) prefer to have it gone as well.
> However, one has to carefully check uRPF functionality in our firewalls, 
> implement fib-aware in_localip_more (and its IPv6 counterpart) to make it 
> happen.

How about we implement the simplest next step, make this
behavior either a kernel compile time option with #ifdef,
and/or a sysctl to turn it off with a bit that defaults
to current behavior while we investigate the harder solution?

> > Bruce Evans and myself have locally killed this code, and
> > just about every router type person I show it to gets ill
> > seeing it.
> >
> > Show many another system that does this and I might reconsider,
> > but I have never ever seen one.
> >
> >> ?Modified:
> >> ???head/sys/net/if.c
> >> ???head/sys/net/route.c
...
> >
> > Rod Grimes rgri...@freebsd.org
-- 
Rod Grimes rgri...@freebsd.org
___
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: r348026 - in head/sys: arm/allwinner arm/amlogic/aml8726 arm/freescale/imx arm/rockchip arm/ti/am335x compat/linuxkpi/common/src dev/drm2/ttm dev/fb dev/hdmi dev/iscsi_initiator dev/mlx...

2019-05-20 Thread Conrad Meyer
Author: cem
Date: Tue May 21 01:18:43 2019
New Revision: 348026
URL: https://svnweb.freebsd.org/changeset/base/348026

Log:
  Include eventhandler.h in more compilation units
  
  This was enumerated with exhaustive search for sys/eventhandler.h includes,
  cross-referenced against EVENTHANDLER_* usage with the comm(1) utility.  
Manual
  checking was performed to avoid redundant includes in some drivers where a
  common os_bsd.h (for example) included sys/eventhandler.h indirectly, but it 
is
  possible some of these are redundant with driver-specific headers in ways I
  didn't notice.
  
  (These CUs did not show up as missing eventhandler.h in tinderbox.)
  
  X-MFC-With:   r347984

Modified:
  head/sys/arm/allwinner/a10_fb.c
  head/sys/arm/allwinner/a10_hdmi.c
  head/sys/arm/amlogic/aml8726/aml8726_wdt.c
  head/sys/arm/freescale/imx/imx6_ipu.c
  head/sys/arm/rockchip/rk30xx_wdog.c
  head/sys/arm/ti/am335x/am335x_lcd.c
  head/sys/arm/ti/am335x/tda19988.c
  head/sys/compat/linuxkpi/common/src/linux_compat.c
  head/sys/dev/drm2/ttm/ttm_page_alloc.c
  head/sys/dev/fb/creator.c
  head/sys/dev/fb/fbd.c
  head/sys/dev/hdmi/dwc_hdmi.c
  head/sys/dev/iscsi_initiator/iscsi.c
  head/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c
  head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
  head/sys/mips/atheros/ar531x/ar5315_wdog.c
  head/sys/mips/cavium/octeon_wdog.c
  head/sys/mips/ingenic/jz4780_lcd.c
  head/sys/ofed/drivers/infiniband/core/ib_roce_gid_mgmt.c
  head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
  head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c

Modified: head/sys/arm/allwinner/a10_fb.c
==
--- head/sys/arm/allwinner/a10_fb.c Tue May 21 00:46:47 2019
(r348025)
+++ head/sys/arm/allwinner/a10_fb.c Tue May 21 01:18:43 2019
(r348026)
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/sys/arm/allwinner/a10_hdmi.c
==
--- head/sys/arm/allwinner/a10_hdmi.c   Tue May 21 00:46:47 2019
(r348025)
+++ head/sys/arm/allwinner/a10_hdmi.c   Tue May 21 01:18:43 2019
(r348026)
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 

Modified: head/sys/arm/amlogic/aml8726/aml8726_wdt.c
==
--- head/sys/arm/amlogic/aml8726/aml8726_wdt.c  Tue May 21 00:46:47 2019
(r348025)
+++ head/sys/arm/amlogic/aml8726/aml8726_wdt.c  Tue May 21 01:18:43 2019
(r348026)
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/sys/arm/freescale/imx/imx6_ipu.c
==
--- head/sys/arm/freescale/imx/imx6_ipu.c   Tue May 21 00:46:47 2019
(r348025)
+++ head/sys/arm/freescale/imx/imx6_ipu.c   Tue May 21 01:18:43 2019
(r348026)
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/sys/arm/rockchip/rk30xx_wdog.c
==
--- head/sys/arm/rockchip/rk30xx_wdog.c Tue May 21 00:46:47 2019
(r348025)
+++ head/sys/arm/rockchip/rk30xx_wdog.c Tue May 21 01:18:43 2019
(r348026)
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/sys/arm/ti/am335x/am335x_lcd.c
==
--- head/sys/arm/ti/am335x/am335x_lcd.c Tue May 21 00:46:47 2019
(r348025)
+++ head/sys/arm/ti/am335x/am335x_lcd.c Tue May 21 01:18:43 2019
(r348026)
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/sys/arm/ti/am335x/tda19988.c
==
--- head/sys/arm/ti/am335x/tda19988.c   Tue May 21 00:46:47 2019
(r348025)
+++ head/sys/arm/ti/am335x/tda19988.c   Tue May 21 01:18:43 2019
(r348026)
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/sys/compat/linuxkpi/common/src/linux_compat.c
==
--- head/sys/compat/linuxkpi/common/src/linux_compat.c  Tue May 21 00:46:47 
2019(r348025)
+++ head/sys/compat/linuxkpi/common/src/linux_compat.c  Tue May 21 01:18:43 
2019(r348026)
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/sys/dev/drm2/ttm/ttm_page_alloc.c

svn commit: r348028 - head/stand/powerpc

2019-05-20 Thread Justin Hibbits
Author: jhibbits
Date: Tue May 21 01:42:57 2019
New Revision: 348028
URL: https://svnweb.freebsd.org/changeset/base/348028

Log:
  stand/powerpc: Only build loader.kboot for powerpc64
  
  kboot is only made for powerpc64 systems, not 32-bit systems.
  
  This unbreaks the build for powerpcspe.
  
  Reported by:  ngie

Modified:
  head/stand/powerpc/Makefile

Modified: head/stand/powerpc/Makefile
==
--- head/stand/powerpc/Makefile Tue May 21 01:27:08 2019(r348027)
+++ head/stand/powerpc/Makefile Tue May 21 01:42:57 2019(r348028)
@@ -5,6 +5,9 @@ NO_OBJ=t
 .include 
 
 SUBDIR.yes=boot1.chrp ofw uboot
+
+.if "${TARGET_ARCH}" == "powerpc64"
 SUBDIR.${MK_FDT}+= kboot
+.endif
 
 .include 
___
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: r348031 - head/tests/sys/opencrypto

2019-05-20 Thread Enji Cooper
Author: ngie
Date: Tue May 21 02:13:46 2019
New Revision: 348031
URL: https://svnweb.freebsd.org/changeset/base/348031

Log:
  Squash deprecation warning related to array.array(..).tostring()
  
  In version 3.2+, `array.array(..).tostring()` was renamed to
  `array.array(..).tobytes()`. Conditionally call `array.array(..).tobytes()` if
  the python version is 3.2+.
  
  PR:   237403
  MFC after:1 week

Modified:
  head/tests/sys/opencrypto/cryptodev.py

Modified: head/tests/sys/opencrypto/cryptodev.py
==
--- head/tests/sys/opencrypto/cryptodev.py  Tue May 21 02:02:09 2019
(r348030)
+++ head/tests/sys/opencrypto/cryptodev.py  Tue May 21 02:13:46 2019
(r348031)
@@ -38,6 +38,7 @@ import os
 import random
 import signal
 from struct import pack as _pack
+import sys
 import time
 
 import dpkt
@@ -151,6 +152,11 @@ def _findop(crid, name):
 
 return fop.crid, name
 
+def array_tobytes(array_obj):
+if sys.version_info[:2] >= (3, 2):
+return array_obj.tobytes()
+return array_obj.tostring()
+
 class Crypto:
 @staticmethod
 def findcrid(name):
@@ -218,9 +224,9 @@ class Crypto:
 #print('cop:', cop)
 ioctl(_cryptodev, CIOCCRYPT, str(cop))
 
-s = s.tostring()
+s = array_tobytes(s)
 if self._maclen is not None:
-return s, m.tostring()
+return s, array_tobytes(m)
 
 return s
 
@@ -255,9 +261,9 @@ class Crypto:
 
 ioctl(_cryptodev, CIOCCRYPTAEAD, str(caead))
 
-s = s.tostring()
+s = array_tobytes(s)
 
-return s, tag.tostring()
+return s, array_tobytes(tag)
 
 def perftest(self, op, size, timeo=3):
 inp = array.array('B', (random.randint(0, 255) for x in range(size)))
___
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: r348032 - head/tests/sys/opencrypto

2019-05-20 Thread Enji Cooper
Author: ngie
Date: Tue May 21 02:30:43 2019
New Revision: 348032
URL: https://svnweb.freebsd.org/changeset/base/348032

Log:
  Fix `KAT(CCM)?Parser` file descriptor leaks
  
  Make `KAT(CCM)?Parser` into a context suite-capable object by implementing
  `__enter__` and `__exit__` methods which manage opening up the file 
descriptors
  and closing them on context exit. This implementation was decided over adding
  destructor logic to a `__del__` method, as there are a number of issues around
  object lifetimes when dealing with threading cleanup, atexit handlers, and a
  number of other less obvious edgecases. Plus, the architected solution is more
  pythonic and clean.
  
  Complete the iterator implementation by implementing a `__next__` method for
  both classes which handles iterating over the data using a generator pattern,
  and by changing `__iter__` to return the object instead of the data which it
  would iterate over. Alias the `__next__` method to `next` when working with
  python 2.x in order to maintain functional compatibility between the two major
  versions.
  
  As part of this work and to ensure readability, push the initialization of the
  parser objects up one layer and pass it down to a helper function. This could
  have been done via a decorator, but I was trying to keep it simple for other
  developers to make it easier to modify in the future.
  
  This fixes ResourceWarnings with python 3.
  
  PR:   237403
  MFC after:1 week
  Tested with:  python 2.7.16 (amd64), python 3.6.8 (amd64)

Modified:
  head/tests/sys/opencrypto/cryptodev.py
  head/tests/sys/opencrypto/cryptotest.py

Modified: head/tests/sys/opencrypto/cryptodev.py
==
--- head/tests/sys/opencrypto/cryptodev.py  Tue May 21 02:13:46 2019
(r348031)
+++ head/tests/sys/opencrypto/cryptodev.py  Tue May 21 02:30:43 2019
(r348032)
@@ -323,11 +323,23 @@ class MismatchError(Exception):
 
 class KATParser:
 def __init__(self, fname, fields):
-self.fp = open(fname)
 self.fields = set(fields)
 self._pending = None
+self.fname = fname
+self.fp = None
 
+def __enter__(self):
+self.fp = open(self.fname)
+return self
+
+def __exit__(self, exc_type, exc_value, exc_tb):
+if self.fp is not None:
+self.fp.close()
+
 def __iter__(self):
+return self
+
+def __next__(self):
 while True:
 didread = False
 if self._pending is not None:
@@ -340,13 +352,14 @@ class KATParser:
 if didread and not i:
 return
 
-if (i and i[0] == '#') or not i.strip():
-continue
-if i[0] == '[':
-yield i[1:].split(']', 1)[0], self.fielditer()
-else:
-raise ValueError('unknown line: %r' % repr(i))
+if not i.startswith('#') and i.strip():
+break
 
+if i[0] == '[':
+yield i[1:].split(']', 1)[0], self.fielditer()
+else:
+raise ValueError('unknown line: %r' % repr(i))
+
 def eatblanks(self):
 while True:
 line = self.fp.readline()
@@ -400,10 +413,19 @@ class KATParser:
 # section.
 class KATCCMParser:
 def __init__(self, fname):
-self.fp = open(fname)
 self._pending = None
+self.fname = fname
+self.fp = None
+
+def __enter__(self):
+self.fp = open(self.fname)
 self.read_globals()
+return self
 
+def __exit__(self, exc_type, exc_value, exc_tb):
+if self.fp is not None:
+self.fp.close()
+
 def read_globals(self):
 self.global_values = {}
 while True:
@@ -463,6 +485,9 @@ class KATCCMParser:
 self.section_values[f] = v
 
 def __iter__(self):
+return self
+
+def __next__(self):
 while True:
 if self._pending:
 line = self._pending
@@ -503,6 +528,10 @@ class KATCCMParser:
 def _spdechex(s):
 return binascii.hexlify(''.join(s.split()))
 
+if sys.version_info[0] < 3:
+KATCCMParser.next = KATCCMParser.__next__
+KATParser.next = KATParser.__next__
+
 if __name__ == '__main__':
 if True:
 try:
@@ -518,11 +547,13 @@ if __name__ == '__main__':
 except IOError:
 pass
 elif False:
-kp = KATParser('/usr/home/jmg/aesni.testing/format tweak value input - 
data unit seq no/XTSGenAES128.rsp', [ 'COUNT', 'DataUnitLen', 'Key', 
'DataUnitSeqNumber', 'PT', 'CT' ])
-for mode, ni in kp:
-print(i, ni)
-for j in ni:
-print(j)
+columns = [ 'COUNT', 'DataUnitLen', 'Key', 'DataUnitSeqNumber', 'PT', 
'CT' ]
+fname = '/usr/home/jmg/aesni.testing/format tweak value input - data 
unit seq no/XTSGenAES128.rsp'
+with KATParser(fname, columns) as kp:
+for

svn commit: r348039 - head/tests/sys/opencrypto

2019-05-20 Thread Enji Cooper
Author: ngie
Date: Tue May 21 02:49:15 2019
New Revision: 348039
URL: https://svnweb.freebsd.org/changeset/base/348039

Log:
  Remove spurious newline
  
  Even though some python styles suggest there should be multiple newlines 
between
  methods/classes, for consistency with the surrounding code, it's best to be
  consistent by having merely one newline between each functional block.
  
  MFC after:1 week

Modified:
  head/tests/sys/opencrypto/cryptodev.py

Modified: head/tests/sys/opencrypto/cryptodev.py
==
--- head/tests/sys/opencrypto/cryptodev.py  Tue May 21 02:46:00 2019
(r348038)
+++ head/tests/sys/opencrypto/cryptodev.py  Tue May 21 02:49:15 2019
(r348039)
@@ -524,7 +524,6 @@ class KATCCMParser:
 
 yield values
 
-
 def _spdechex(s):
 return binascii.hexlify(''.join(s.split()))
 
___
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: r348040 - head/stand/powerpc

2019-05-20 Thread Justin Hibbits
Author: jhibbits
Date: Tue May 21 03:05:24 2019
New Revision: 348040
URL: https://svnweb.freebsd.org/changeset/base/348040

Log:
  stand: TARGET_ARCH is spelled MACHINE_ARCH in Makefiles
  
  Reported by:  imp

Modified:
  head/stand/powerpc/Makefile

Modified: head/stand/powerpc/Makefile
==
--- head/stand/powerpc/Makefile Tue May 21 02:49:15 2019(r348039)
+++ head/stand/powerpc/Makefile Tue May 21 03:05:24 2019(r348040)
@@ -6,7 +6,7 @@ NO_OBJ=t
 
 SUBDIR.yes=boot1.chrp ofw uboot
 
-.if "${TARGET_ARCH}" == "powerpc64"
+.if "${MACHINE_ARCH}" == "powerpc64"
 SUBDIR.${MK_FDT}+= kboot
 .endif
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r348042 - head/tests/sys/opencrypto

2019-05-20 Thread Enji Cooper
Author: ngie
Date: Tue May 21 03:52:48 2019
New Revision: 348042
URL: https://svnweb.freebsd.org/changeset/base/348042

Log:
  Fix encoding issues with python 3
  
  In python 3, the default encoding was switched from ascii character sets to
  unicode character sets in order to support internationalization by default.
  Some interfaces, like ioctls and packets, however, specify data in terms of
  non-unicode encodings formats, either in host endian (`fcntl.ioctl`) or
  network endian (`dpkt`) byte order/format.
  
  This change alters assumptions made by previous code where it was all
  data objects were assumed to be basestrings, when they should have been
  treated as byte arrays. In order to achieve this the following are done:
  * str objects with encodings needing to be encoded as ascii byte arrays are
done so via `.encode("ascii")`. In order for this to work on python 3 in a
type agnostic way (as it anecdotally varied depending on the caller), call
`.encode("ascii")` only on str objects with python 3 to cast them to ascii
byte arrays in a helper function name `str_to_ascii(..)`.
  * `dpkt.Packet` objects needing to be passed in to `fcntl.ioctl(..)` are done
so by casting them to byte arrays via `bytes()`, which calls
`dpkt.Packet__str__` under the covers and does the necessary str to byte 
array
conversion needed for the `dpkt` APIs and `struct` module.
  
  In order to accomodate this change, apply the necessary typecasting for the
  byte array literal in order to search `fop.name` for nul bytes.
  
  This resolves all remaining python 2.x and python 3.x compatibility issues on
  amd64. More work needs to be done for the tests to function with i386, in
  general (this is a legacy issue).
  
  PR:   237403
  MFC after:1 week
  Tested with:  python 2.7.16 (amd64), python 3.6.8 (amd64)

Modified:
  head/tests/sys/opencrypto/cryptodev.py

Modified: head/tests/sys/opencrypto/cryptodev.py
==
--- head/tests/sys/opencrypto/cryptodev.py  Tue May 21 03:06:10 2019
(r348041)
+++ head/tests/sys/opencrypto/cryptodev.py  Tue May 21 03:52:48 2019
(r348042)
@@ -136,16 +136,22 @@ def _getdev():
 
 _cryptodev = _getdev()
 
+def str_to_ascii(val):
+if sys.version_info[0] >= 3:
+if isinstance(val, str):
+return val.encode("ascii")
+return val
+
 def _findop(crid, name):
 fop = FindOp()
 fop.crid = crid
-fop.name = name
+fop.name = str_to_ascii(name)
 s = array.array('B', fop.pack_hdr())
 ioctl(_cryptodev, CIOCFINDDEV, s, 1)
 fop.unpack(s)
 
 try:
-idx = fop.name.index('\x00')
+idx = fop.name.index(b'\x00')
 name = fop.name[:idx]
 except ValueError:
 name = fop.name
@@ -218,11 +224,11 @@ class Crypto:
 if self._maclen is not None:
 m = array.array('B', [0] * self._maclen)
 cop.mac = m.buffer_info()[0]
-ivbuf = array.array('B', iv)
+ivbuf = array.array('B', str_to_ascii(iv))
 cop.iv = ivbuf.buffer_info()[0]
 
 #print('cop:', cop)
-ioctl(_cryptodev, CIOCCRYPT, str(cop))
+ioctl(_cryptodev, CIOCCRYPT, bytes(cop))
 
 s = array_tobytes(s)
 if self._maclen is not None:
@@ -236,6 +242,7 @@ class Crypto:
 caead.op = op
 caead.flags = CRD_F_IV_EXPLICIT
 caead.flags = 0
+src = str_to_ascii(src)
 caead.len = len(src)
 s = array.array('B', src)
 caead.src = caead.dst = s.buffer_info()[0]
@@ -246,6 +253,7 @@ class Crypto:
 if self._maclen is None:
 raise ValueError('must have a tag length')
 
+tag = str_to_ascii(tag)
 if tag is None:
 tag = array.array('B', [0] * self._maclen)
 else:
@@ -259,7 +267,7 @@ class Crypto:
 caead.ivlen = len(iv)
 caead.iv = ivbuf.buffer_info()[0]
 
-ioctl(_cryptodev, CIOCCRYPTAEAD, str(caead))
+ioctl(_cryptodev, CIOCCRYPTAEAD, bytes(caead))
 
 s = array_tobytes(s)
 
@@ -267,6 +275,7 @@ class Crypto:
 
 def perftest(self, op, size, timeo=3):
 inp = array.array('B', (random.randint(0, 255) for x in range(size)))
+inp = str_to_ascii(inp)
 out = array.array('B', inp)
 
 # prep ioctl
@@ -293,8 +302,9 @@ class Crypto:
 
 start = time.time()
 reps = 0
+cop = bytes(cop)
 while not exit[0]:
-ioctl(_cryptodev, CIOCCRYPT, str(cop))
+ioctl(_cryptodev, CIOCCRYPT, cop)
 reps += 1
 
 end = time.time()
___
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: r348045 - head/tests/sys/opencrypto

2019-05-20 Thread Enji Cooper
Author: ngie
Date: Tue May 21 04:03:22 2019
New Revision: 348045
URL: https://svnweb.freebsd.org/changeset/base/348045

Log:
  Follow up to r348042: cast `aad` to a byte array
  
  This is not completely necessary today, but this change is being made in a
  conservative manner to avoid accidental breakage in the future, if this ever
  was a unicode string.
  
  PR:   237403
  MFC after:1 week

Modified:
  head/tests/sys/opencrypto/cryptodev.py

Modified: head/tests/sys/opencrypto/cryptodev.py
==
--- head/tests/sys/opencrypto/cryptodev.py  Tue May 21 04:01:16 2019
(r348044)
+++ head/tests/sys/opencrypto/cryptodev.py  Tue May 21 04:03:22 2019
(r348045)
@@ -246,6 +246,7 @@ class Crypto:
 caead.len = len(src)
 s = array.array('B', src)
 caead.src = caead.dst = s.buffer_info()[0]
+aad = str_to_ascii(aad)
 caead.aadlen = len(aad)
 saad = array.array('B', aad)
 caead.aad = saad.buffer_info()[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: r348047 - head/tests/sys/opencrypto

2019-05-20 Thread Enji Cooper
Author: ngie
Date: Tue May 21 04:11:16 2019
New Revision: 348047
URL: https://svnweb.freebsd.org/changeset/base/348047

Log:
  Add my name to the copyright
  
  I have contributed a number of changes to these tests over the past few
  hundred revisions, and believe I deserve credit for the changes I have
  made (plus, the copyright hadn't been updated since 2014).
  
  MFC after:1 week

Modified:
  head/tests/sys/opencrypto/cryptodev.py
  head/tests/sys/opencrypto/cryptotest.py
  head/tests/sys/opencrypto/runtests.sh

Modified: head/tests/sys/opencrypto/cryptodev.py
==
--- head/tests/sys/opencrypto/cryptodev.py  Tue May 21 04:05:03 2019
(r348046)
+++ head/tests/sys/opencrypto/cryptodev.py  Tue May 21 04:11:16 2019
(r348047)
@@ -3,6 +3,7 @@
 # Copyright (c) 2014 The FreeBSD Foundation
 # Copyright 2014 John-Mark Gurney
 # All rights reserved.
+# Copyright 2019 Enji Cooper
 #
 # This software was developed by John-Mark Gurney under
 # the sponsorship from the FreeBSD Foundation.

Modified: head/tests/sys/opencrypto/cryptotest.py
==
--- head/tests/sys/opencrypto/cryptotest.py Tue May 21 04:05:03 2019
(r348046)
+++ head/tests/sys/opencrypto/cryptotest.py Tue May 21 04:11:16 2019
(r348047)
@@ -2,6 +2,7 @@
 #
 # Copyright (c) 2014 The FreeBSD Foundation
 # All rights reserved.
+# Copyright 2019 Enji Cooper
 #
 # This software was developed by John-Mark Gurney under
 # the sponsorship from the FreeBSD Foundation.

Modified: head/tests/sys/opencrypto/runtests.sh
==
--- head/tests/sys/opencrypto/runtests.sh   Tue May 21 04:05:03 2019
(r348046)
+++ head/tests/sys/opencrypto/runtests.sh   Tue May 21 04:11:16 2019
(r348047)
@@ -2,6 +2,7 @@
 #
 # Copyright (c) 2014 The FreeBSD Foundation
 # All rights reserved.
+# Copyright 2019 Enji Cooper
 #
 # This software was developed by John-Mark Gurney under
 # the sponsorship from the FreeBSD Foundation.
___
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"