From owner-svn-src-projects@freebsd.org Tue Oct 16 16:36:03 2018 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BCFAF10D9E5E for ; Tue, 16 Oct 2018 16:36:03 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7193F7498D; Tue, 16 Oct 2018 16:36:03 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 688591F1C3; Tue, 16 Oct 2018 16:36:03 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w9GGa3Z4001744; Tue, 16 Oct 2018 16:36:03 GMT (envelope-from luporl@FreeBSD.org) Received: (from luporl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w9GGa3Nl001743; Tue, 16 Oct 2018 16:36:03 GMT (envelope-from luporl@FreeBSD.org) Message-Id: <201810161636.w9GGa3Nl001743@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: luporl set sender to luporl@FreeBSD.org using -f From: Leandro Lupori Date: Tue, 16 Oct 2018 16:36:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r339382 - projects/power8_bringup_hacks/sys/dev/bge X-SVN-Group: projects X-SVN-Commit-Author: luporl X-SVN-Commit-Paths: projects/power8_bringup_hacks/sys/dev/bge X-SVN-Commit-Revision: 339382 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Oct 2018 16:36:03 -0000 Author: luporl Date: Tue Oct 16 16:36:02 2018 New Revision: 339382 URL: https://svnweb.freebsd.org/changeset/base/339382 Log: bge(4): limit DMA address to 2GB This is a temporary hack, to avoid POWER8 Broadcom NICs from becoming unusable after transferring a reasonable amount of data. The issue is the same as that of AHCI, where DMA addresses above 2GB do not work and causes PCI errors. Modified: projects/power8_bringup_hacks/sys/dev/bge/if_bge.c Modified: projects/power8_bringup_hacks/sys/dev/bge/if_bge.c ============================================================================== --- projects/power8_bringup_hacks/sys/dev/bge/if_bge.c Tue Oct 16 16:03:17 2018 (r339381) +++ projects/power8_bringup_hacks/sys/dev/bge/if_bge.c Tue Oct 16 16:36:02 2018 (r339382) @@ -134,6 +134,8 @@ MODULE_DEPEND(bge, miibus, 1, 1, 1); /* "device miibus" required. See GENERIC if you get errors here. */ #include "miibus_if.h" +#define BGE_BUS_SPACE_MAXADDR_32BIT 0x7FFFFFFFU + /* * Various supported device vendors/types and their names. Note: the * spec seems to indicate that the hardware still has Alteon's vendor @@ -3050,15 +3052,16 @@ bge_dma_alloc(struct bge_softc *sc) /* Create parent tag for buffers. */ if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0) { + lowaddr = BGE_BUS_SPACE_MAXADDR_32BIT; /* * XXX * watchdog timeout issue was observed on BCM5704 which * lives behind PCI-X bridge(e.g AMD 8131 PCI-X bridge). * Both limiting DMA address space to 32bits and flushing * mailbox write seem to address the issue. - */ if (sc->bge_pcixcap != 0) lowaddr = BUS_SPACE_MAXADDR_32BIT; + */ } error = bus_dma_tag_create(bus_get_dma_tag(sc->bge_dev), 1, 0, lowaddr, BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, 0, From owner-svn-src-projects@freebsd.org Tue Oct 16 16:45:27 2018 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0368B10DA29D for ; Tue, 16 Oct 2018 16:45:27 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A955574FBC; Tue, 16 Oct 2018 16:45:26 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A3DBC1F38C; Tue, 16 Oct 2018 16:45:26 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w9GGjQZa007340; Tue, 16 Oct 2018 16:45:26 GMT (envelope-from luporl@FreeBSD.org) Received: (from luporl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w9GGjLGR007311; Tue, 16 Oct 2018 16:45:21 GMT (envelope-from luporl@FreeBSD.org) Message-Id: <201810161645.w9GGjLGR007311@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: luporl set sender to luporl@FreeBSD.org using -f From: Leandro Lupori Date: Tue, 16 Oct 2018 16:45:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r339383 - in projects/power8_bringup_hacks: . contrib/elftoolchain/elfcopy lib/csu/aarch64 lib/csu/amd64 lib/csu/arm lib/csu/common lib/csu/i386 lib/csu/mips lib/csu/powerpc lib/csu/pow... X-SVN-Group: projects X-SVN-Commit-Author: luporl X-SVN-Commit-Paths: in projects/power8_bringup_hacks: . contrib/elftoolchain/elfcopy lib/csu/aarch64 lib/csu/amd64 lib/csu/arm lib/csu/common lib/csu/i386 lib/csu/mips lib/csu/powerpc lib/csu/powerpc64 lib/csu/riscv lib/... X-SVN-Commit-Revision: 339383 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Oct 2018 16:45:27 -0000 Author: luporl Date: Tue Oct 16 16:45:21 2018 New Revision: 339383 URL: https://svnweb.freebsd.org/changeset/base/339383 Log: Merge power8_bringup_hacks with HEAD. Added: projects/power8_bringup_hacks/lib/csu/amd64/reloc.c - copied unchanged from r339382, head/lib/csu/amd64/reloc.c projects/power8_bringup_hacks/lib/csu/i386/reloc.c - copied unchanged from r339382, head/lib/csu/i386/reloc.c projects/power8_bringup_hacks/lib/libc/amd64/string/bcopy.c - copied unchanged from r339382, head/lib/libc/amd64/string/bcopy.c projects/power8_bringup_hacks/share/man/man4/iavf.4 - copied unchanged from r339382, head/share/man/man4/iavf.4 projects/power8_bringup_hacks/sys/dev/ixl/iavf.h - copied unchanged from r339382, head/sys/dev/ixl/iavf.h projects/power8_bringup_hacks/sys/dev/ixl/iavf_vc.c - copied unchanged from r339382, head/sys/dev/ixl/iavf_vc.c projects/power8_bringup_hacks/sys/dev/ixl/if_iavf.c - copied unchanged from r339382, head/sys/dev/ixl/if_iavf.c projects/power8_bringup_hacks/sys/dev/uart/uart_dev_lowrisc.c - copied unchanged from r339382, head/sys/dev/uart/uart_dev_lowrisc.c projects/power8_bringup_hacks/sys/dev/uart/uart_dev_lowrisc.h - copied unchanged from r339382, head/sys/dev/uart/uart_dev_lowrisc.h projects/power8_bringup_hacks/sys/kern/subr_early.c - copied unchanged from r339382, head/sys/kern/subr_early.c projects/power8_bringup_hacks/sys/modules/iavf/ - copied from r339382, head/sys/modules/iavf/ Deleted: projects/power8_bringup_hacks/lib/libc/amd64/string/bcopy.S projects/power8_bringup_hacks/share/man/man4/ixlv.4 projects/power8_bringup_hacks/sys/dev/ixl/README projects/power8_bringup_hacks/sys/dev/ixl/if_ixlv.c projects/power8_bringup_hacks/sys/dev/ixl/ixlv.h projects/power8_bringup_hacks/sys/dev/ixl/ixlv_vc_mgr.h projects/power8_bringup_hacks/sys/dev/ixl/ixlvc.c projects/power8_bringup_hacks/sys/modules/ixlv/ Modified: projects/power8_bringup_hacks/Makefile.inc1 projects/power8_bringup_hacks/ObsoleteFiles.inc projects/power8_bringup_hacks/contrib/elftoolchain/elfcopy/sections.c projects/power8_bringup_hacks/lib/csu/aarch64/Makefile projects/power8_bringup_hacks/lib/csu/amd64/Makefile projects/power8_bringup_hacks/lib/csu/amd64/crt1.c projects/power8_bringup_hacks/lib/csu/arm/Makefile projects/power8_bringup_hacks/lib/csu/common/ignore_init.c projects/power8_bringup_hacks/lib/csu/i386/Makefile projects/power8_bringup_hacks/lib/csu/i386/crt1_c.c projects/power8_bringup_hacks/lib/csu/mips/Makefile projects/power8_bringup_hacks/lib/csu/powerpc/Makefile projects/power8_bringup_hacks/lib/csu/powerpc64/Makefile projects/power8_bringup_hacks/lib/csu/riscv/Makefile projects/power8_bringup_hacks/lib/csu/sparc64/Makefile projects/power8_bringup_hacks/lib/libc/amd64/string/Makefile.inc projects/power8_bringup_hacks/lib/libc/amd64/string/memcpy.S projects/power8_bringup_hacks/lib/libc/amd64/string/memmove.S projects/power8_bringup_hacks/lib/libc/net/nsdispatch.3 projects/power8_bringup_hacks/lib/libc/net/nsdispatch.c projects/power8_bringup_hacks/lib/libc/net/nslexer.l projects/power8_bringup_hacks/lib/libc/stdtime/strptime.c projects/power8_bringup_hacks/lib/libc/string/memmem.c projects/power8_bringup_hacks/lib/libc/sys/pdfork.2 projects/power8_bringup_hacks/lib/libc/sys/sendfile.2 projects/power8_bringup_hacks/lib/libldns/Makefile projects/power8_bringup_hacks/lib/libmemstat/memstat_malloc.c projects/power8_bringup_hacks/share/man/man4/Makefile projects/power8_bringup_hacks/share/man/man4/dtrace_ip.4 projects/power8_bringup_hacks/share/man/man4/ixl.4 projects/power8_bringup_hacks/share/man/man4/procdesc.4 projects/power8_bringup_hacks/share/man/man9/MODULE_PNP_INFO.9 projects/power8_bringup_hacks/share/mk/src.libnames.mk projects/power8_bringup_hacks/stand/efi/loader/main.c projects/power8_bringup_hacks/sys/amd64/amd64/machdep.c projects/power8_bringup_hacks/sys/amd64/amd64/support.S projects/power8_bringup_hacks/sys/amd64/amd64/trap.c projects/power8_bringup_hacks/sys/amd64/amd64/vm_machdep.c projects/power8_bringup_hacks/sys/amd64/conf/GENERIC projects/power8_bringup_hacks/sys/amd64/conf/NOTES projects/power8_bringup_hacks/sys/amd64/include/cpu.h projects/power8_bringup_hacks/sys/amd64/include/proc.h projects/power8_bringup_hacks/sys/amd64/vmm/amd/svm.c projects/power8_bringup_hacks/sys/amd64/vmm/vmm_instruction_emul.c projects/power8_bringup_hacks/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c projects/power8_bringup_hacks/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_indirect.c projects/power8_bringup_hacks/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c projects/power8_bringup_hacks/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c projects/power8_bringup_hacks/sys/cddl/dev/fbt/riscv/fbt_isa.c projects/power8_bringup_hacks/sys/compat/freebsd32/syscalls.master projects/power8_bringup_hacks/sys/conf/files projects/power8_bringup_hacks/sys/conf/files.amd64 projects/power8_bringup_hacks/sys/conf/files.riscv projects/power8_bringup_hacks/sys/conf/newvers.sh projects/power8_bringup_hacks/sys/contrib/ck/src/ck_epoch.c projects/power8_bringup_hacks/sys/dev/bxe/bxe.c projects/power8_bringup_hacks/sys/dev/bxe/bxe.h projects/power8_bringup_hacks/sys/dev/bxe/bxe_stats.c projects/power8_bringup_hacks/sys/dev/cxgbe/t4_sge.c projects/power8_bringup_hacks/sys/dev/e1000/em_txrx.c projects/power8_bringup_hacks/sys/dev/e1000/igb_txrx.c projects/power8_bringup_hacks/sys/dev/ixgbe/if_ix.c projects/power8_bringup_hacks/sys/dev/ixgbe/if_ixv.c projects/power8_bringup_hacks/sys/dev/ixgbe/ix_txrx.c projects/power8_bringup_hacks/sys/dev/ixl/i40e_osdep.c projects/power8_bringup_hacks/sys/dev/ixl/if_ixl.c projects/power8_bringup_hacks/sys/dev/ixl/ixl.h projects/power8_bringup_hacks/sys/dev/ixl/ixl_debug.h projects/power8_bringup_hacks/sys/dev/ixl/ixl_pf.h projects/power8_bringup_hacks/sys/dev/ixl/ixl_pf_iov.c projects/power8_bringup_hacks/sys/dev/ixl/ixl_pf_iov.h projects/power8_bringup_hacks/sys/dev/ixl/ixl_pf_main.c projects/power8_bringup_hacks/sys/dev/ixl/ixl_pf_qmgr.c projects/power8_bringup_hacks/sys/dev/ixl/ixl_pf_qmgr.h projects/power8_bringup_hacks/sys/dev/ixl/ixl_txrx.c projects/power8_bringup_hacks/sys/kern/kern_descrip.c projects/power8_bringup_hacks/sys/kern/kern_sendfile.c projects/power8_bringup_hacks/sys/kern/link_elf.c projects/power8_bringup_hacks/sys/kern/sys_capability.c projects/power8_bringup_hacks/sys/kern/syscalls.master projects/power8_bringup_hacks/sys/modules/Makefile projects/power8_bringup_hacks/sys/modules/ixl/Makefile projects/power8_bringup_hacks/sys/net/if_vlan.c projects/power8_bringup_hacks/sys/net/iflib.c projects/power8_bringup_hacks/sys/net/iflib.h projects/power8_bringup_hacks/sys/net/iflib_private.h projects/power8_bringup_hacks/sys/netinet/tcp_reass.c projects/power8_bringup_hacks/sys/netinet/udp_usrreq.c projects/power8_bringup_hacks/sys/netpfil/ipfw/ip_fw2.c projects/power8_bringup_hacks/sys/riscv/conf/GENERIC projects/power8_bringup_hacks/sys/riscv/include/cpufunc.h projects/power8_bringup_hacks/sys/riscv/include/kdb.h projects/power8_bringup_hacks/sys/riscv/include/sbi.h projects/power8_bringup_hacks/sys/riscv/riscv/cpufunc_asm.S projects/power8_bringup_hacks/sys/riscv/riscv/db_interface.c projects/power8_bringup_hacks/sys/riscv/riscv/mp_machdep.c projects/power8_bringup_hacks/sys/riscv/riscv/plic.c projects/power8_bringup_hacks/sys/riscv/riscv/pmap.c projects/power8_bringup_hacks/sys/sys/capsicum.h projects/power8_bringup_hacks/sys/sys/systm.h projects/power8_bringup_hacks/sys/x86/x86/ucode.c projects/power8_bringup_hacks/sys/x86/xen/pv.c projects/power8_bringup_hacks/usr.sbin/mfiutil/mfi_cmd.c projects/power8_bringup_hacks/usr.sbin/pw/pw.c projects/power8_bringup_hacks/usr.sbin/pw/pw.h projects/power8_bringup_hacks/usr.sbin/pw/pw_conf.c projects/power8_bringup_hacks/usr.sbin/pw/pw_utils.c Directory Properties: projects/power8_bringup_hacks/ (props changed) projects/power8_bringup_hacks/contrib/elftoolchain/ (props changed) projects/power8_bringup_hacks/sys/cddl/contrib/opensolaris/ (props changed) projects/power8_bringup_hacks/sys/contrib/ck/ (props changed) Modified: projects/power8_bringup_hacks/Makefile.inc1 ============================================================================== --- projects/power8_bringup_hacks/Makefile.inc1 Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/Makefile.inc1 Tue Oct 16 16:45:21 2018 (r339383) @@ -939,6 +939,15 @@ _cleanobj_fast_depend_hack: .PHONY ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \ fi .endfor +# 20181013 r339348 bcopy reimplemented as .c +.for f in bcopy memcpy memmove + @if [ -e "${OBJTOP}/lib/libc/.depend.${f}.o" ] && \ + egrep -qw 'bcopy\.[sS]' ${OBJTOP}/lib/libc/.depend.${f}.o; then \ + echo "Removing stale dependencies for bcopy"; \ + rm -f ${OBJTOP}/lib/libc/.depend.${f}.* \ + ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \ + fi +.endfor # 20181009 track migration from ntp's embedded libevent to updated one @if [ -e "${OBJTOP}/usr.sbin/ntp/libntpevent/.depend.bufferevent_openssl.o" ] && \ egrep -q 'contrib/ntp/sntp/libevent/bufferevent_openssl.c' \ @@ -2534,8 +2543,8 @@ _prebuild_libs= ${_kerberos5_lib_libasn1} \ ${_cddl_lib_libctf} \ lib/libufs \ lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \ - ${_secure_lib_libcrypto} ${_lib_libldns} \ - ${_secure_lib_libssh} ${_secure_lib_libssl} + ${_secure_lib_libcrypto} ${_secure_lib_libssl} \ + ${_lib_libldns} ${_secure_lib_libssh} .if ${MK_GNUCXX} != "no" _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++ @@ -2631,9 +2640,10 @@ lib/librtld_db__L: lib/libprocstat__L _secure_lib_libcrypto= secure/lib/libcrypto _secure_lib_libssl= secure/lib/libssl lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L +secure/lib/libcrypto__L: lib/libthr__L .if ${MK_LDNS} != "no" _lib_libldns= lib/libldns -lib/libldns__L: secure/lib/libcrypto__L +lib/libldns__L: secure/lib/libssl__L .endif .if ${MK_OPENSSH} != "no" _secure_lib_libssh= secure/lib/libssh Modified: projects/power8_bringup_hacks/ObsoleteFiles.inc ============================================================================== --- projects/power8_bringup_hacks/ObsoleteFiles.inc Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/ObsoleteFiles.inc Tue Oct 16 16:45:21 2018 (r339383) @@ -38,6 +38,19 @@ # xargs -n1 | sort | uniq -d; # done +# 20181015: Stale libcasper(3) files following 20181009: OpenSSL 1.1.1 +OLD_LIBS+=lib/casper/libcap_sysctl.so.0 +OLD_LIBS+=lib/casper/libcap_grp.so.0 +OLD_LIBS+=lib/casper/libcap_pwd.so.0 +OLD_LIBS+=lib/casper/libcap_random.so.0 +OLD_LIBS+=lib/casper/libcap_dns.so.0 +OLD_LIBS+=lib/casper/libcap_syslog.so.0 +OLD_LIBS+=usr/lib32/libcap_sysctl.so.0 +OLD_LIBS+=usr/lib32/libcap_grp.so.0 +OLD_LIBS+=usr/lib32/libcap_pwd.so.0 +OLD_LIBS+=usr/lib32/libcap_random.so.0 +OLD_LIBS+=usr/lib32/libcap_dns.so.0 +OLD_LIBS+=usr/lib32/libcap_syslog.so.0 # 20181009: OpenSSL 1.1.1 OLD_FILES+=usr/include/openssl/des_old.h OLD_FILES+=usr/include/openssl/dso.h Modified: projects/power8_bringup_hacks/contrib/elftoolchain/elfcopy/sections.c ============================================================================== --- projects/power8_bringup_hacks/contrib/elftoolchain/elfcopy/sections.c Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/contrib/elftoolchain/elfcopy/sections.c Tue Oct 16 16:45:21 2018 (r339383) @@ -39,7 +39,6 @@ ELFTC_VCSID("$Id: sections.c 3443 2016-04-15 18:57:54Z static void add_gnu_debuglink(struct elfcopy *ecp); static uint32_t calc_crc32(const char *p, size_t len, uint32_t crc); static void check_section_rename(struct elfcopy *ecp, struct section *s); -static void filter_reloc(struct elfcopy *ecp, struct section *s); static int get_section_flags(struct elfcopy *ecp, const char *name); static void insert_sections(struct elfcopy *ecp); static void insert_to_strtab(struct section *t, const char *s); @@ -574,14 +573,6 @@ copy_content(struct elfcopy *ecp) continue; /* - * If strip action is STRIP_ALL, relocation info need - * to be stripped. Skip filtering otherwisw. - */ - if (ecp->strip == STRIP_ALL && - (s->type == SHT_REL || s->type == SHT_RELA)) - filter_reloc(ecp, s); - - /* * The section indices in the SHT_GROUP section needs * to be updated since we might have stripped some * sections and changed section numbering. @@ -670,125 +661,6 @@ update_section_group(struct elfcopy *ecp, struct secti s->sz -= 4; } - s->nocopy = 1; -} - -/* - * Filter relocation entries, only keep those entries whose - * symbol is in the keep list. - */ -static void -filter_reloc(struct elfcopy *ecp, struct section *s) -{ - const char *name; - GElf_Shdr ish; - GElf_Rel rel; - GElf_Rela rela; - Elf32_Rel *rel32; - Elf64_Rel *rel64; - Elf32_Rela *rela32; - Elf64_Rela *rela64; - Elf_Data *id; - uint64_t cap, n, nrels; - int elferr, i; - - if (gelf_getshdr(s->is, &ish) == NULL) - errx(EXIT_FAILURE, "gelf_getehdr() failed: %s", - elf_errmsg(-1)); - - /* We don't want to touch relocation info for dynamic symbols. */ - if ((ecp->flags & SYMTAB_EXIST) == 0) { - if (ish.sh_link == 0 || ecp->secndx[ish.sh_link] == 0) { - /* - * This reloc section applies to the symbol table - * that was stripped, so discard whole section. - */ - s->nocopy = 1; - s->sz = 0; - } - return; - } else { - /* Symbol table exist, check if index equals. */ - if (ish.sh_link != elf_ndxscn(ecp->symtab->is)) - return; - } - -#define COPYREL(REL, SZ) do { \ - if (nrels == 0) { \ - if ((REL##SZ = malloc(cap * \ - sizeof(*REL##SZ))) == NULL) \ - err(EXIT_FAILURE, "malloc failed"); \ - } \ - if (nrels >= cap) { \ - cap *= 2; \ - if ((REL##SZ = realloc(REL##SZ, cap * \ - sizeof(*REL##SZ))) == NULL) \ - err(EXIT_FAILURE, "realloc failed"); \ - } \ - REL##SZ[nrels].r_offset = REL.r_offset; \ - REL##SZ[nrels].r_info = REL.r_info; \ - if (s->type == SHT_RELA) \ - rela##SZ[nrels].r_addend = rela.r_addend; \ - nrels++; \ -} while (0) - - nrels = 0; - cap = 4; /* keep list is usually small. */ - rel32 = NULL; - rel64 = NULL; - rela32 = NULL; - rela64 = NULL; - if ((id = elf_getdata(s->is, NULL)) == NULL) - errx(EXIT_FAILURE, "elf_getdata() failed: %s", - elf_errmsg(-1)); - n = ish.sh_size / ish.sh_entsize; - for(i = 0; (uint64_t)i < n; i++) { - if (s->type == SHT_REL) { - if (gelf_getrel(id, i, &rel) != &rel) - errx(EXIT_FAILURE, "gelf_getrel failed: %s", - elf_errmsg(-1)); - } else { - if (gelf_getrela(id, i, &rela) != &rela) - errx(EXIT_FAILURE, "gelf_getrel failed: %s", - elf_errmsg(-1)); - } - name = elf_strptr(ecp->ein, elf_ndxscn(ecp->strtab->is), - GELF_R_SYM(rel.r_info)); - if (name == NULL) - errx(EXIT_FAILURE, "elf_strptr failed: %s", - elf_errmsg(-1)); - if (lookup_symop_list(ecp, name, SYMOP_KEEP) != NULL) { - if (ecp->oec == ELFCLASS32) { - if (s->type == SHT_REL) - COPYREL(rel, 32); - else - COPYREL(rela, 32); - } else { - if (s->type == SHT_REL) - COPYREL(rel, 64); - else - COPYREL(rela, 64); - } - } - } - elferr = elf_errno(); - if (elferr != 0) - errx(EXIT_FAILURE, "elf_getdata() failed: %s", - elf_errmsg(elferr)); - - if (ecp->oec == ELFCLASS32) { - if (s->type == SHT_REL) - s->buf = rel32; - else - s->buf = rela32; - } else { - if (s->type == SHT_REL) - s->buf = rel64; - else - s->buf = rela64; - } - s->sz = gelf_fsize(ecp->eout, (s->type == SHT_REL ? ELF_T_REL : - ELF_T_RELA), nrels, EV_CURRENT); s->nocopy = 1; } Modified: projects/power8_bringup_hacks/lib/csu/aarch64/Makefile ============================================================================== --- projects/power8_bringup_hacks/lib/csu/aarch64/Makefile Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/csu/aarch64/Makefile Tue Oct 16 16:45:21 2018 (r339383) @@ -7,6 +7,7 @@ OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= Scrt1.o gcrt1.o CFLAGS+= -I${.CURDIR:H}/common \ -I${SRCTOP}/lib/libc/include +CFLAGS+= -DCRT_IRELOC_SUPPRESS FILES= ${OBJS} FILESMODE= ${LIBMODE} Modified: projects/power8_bringup_hacks/lib/csu/amd64/Makefile ============================================================================== --- projects/power8_bringup_hacks/lib/csu/amd64/Makefile Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/csu/amd64/Makefile Tue Oct 16 16:45:21 2018 (r339383) @@ -5,9 +5,9 @@ SRCS= crt1.c crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= Scrt1.o gcrt1.o -CFLAGS+= -I${.CURDIR:H}/common \ +CFLAGS+= -I${.CURDIR} -I${.CURDIR:H}/common \ -I${SRCTOP}/lib/libc/include -CFLAGS+= -fno-omit-frame-pointer +CFLAGS+= -fno-omit-frame-pointer -DCRT_IRELOC_RELA FILES= ${OBJS} FILESMODE= ${LIBMODE} Modified: projects/power8_bringup_hacks/lib/csu/amd64/crt1.c ============================================================================== --- projects/power8_bringup_hacks/lib/csu/amd64/crt1.c Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/csu/amd64/crt1.c Tue Oct 16 16:45:21 2018 (r339383) @@ -59,10 +59,12 @@ _start(char **ap, void (*cleanup)(void)) env = ap + 2 + argc; handle_argv(argc, argv, env); - if (&_DYNAMIC != NULL) + if (&_DYNAMIC != NULL) { atexit(cleanup); - else + } else { + process_irelocs(); _init_tls(); + } #ifdef GCRT atexit(_mcleanup); Copied: projects/power8_bringup_hacks/lib/csu/amd64/reloc.c (from r339382, head/lib/csu/amd64/reloc.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/power8_bringup_hacks/lib/csu/amd64/reloc.c Tue Oct 16 16:45:21 2018 (r339383, copy of r339382, head/lib/csu/amd64/reloc.c) @@ -0,0 +1,66 @@ +/*- + * Copyright (c) 2018 The FreeBSD Foundation + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +static void +crt1_handle_rela(const Elf_Rela *r) +{ + Elf_Addr *ptr, *where, target; + u_int p[4]; + uint32_t cpu_feature, cpu_feature2; + uint32_t cpu_stdext_feature, cpu_stdext_feature2; + + do_cpuid(1, p); + cpu_feature = p[3]; + cpu_feature2 = p[2]; + do_cpuid(0, p); + if (p[0] >= 7) { + cpuid_count(7, 0, p); + cpu_stdext_feature = p[1]; + cpu_stdext_feature2 = p[2]; + } else { + cpu_stdext_feature = 0; + cpu_stdext_feature2 = 0; + } + + switch (ELF_R_TYPE(r->r_info)) { + case R_X86_64_IRELATIVE: + ptr = (Elf_Addr *)r->r_addend; + where = (Elf_Addr *)r->r_offset; + target = ((Elf_Addr (*)(uint32_t, uint32_t, uint32_t, + uint32_t))ptr)(cpu_feature, cpu_feature2, + cpu_stdext_feature, cpu_stdext_feature2); + *where = target; + break; + } +} Modified: projects/power8_bringup_hacks/lib/csu/arm/Makefile ============================================================================== --- projects/power8_bringup_hacks/lib/csu/arm/Makefile Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/csu/arm/Makefile Tue Oct 16 16:45:21 2018 (r339383) @@ -7,6 +7,7 @@ OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= Scrt1.o gcrt1.o CFLAGS+= -I${.CURDIR:H}/common \ -I${SRCTOP}/lib/libc/include +CFLAGS+= -DCRT_IRELOC_SUPPRESS STATIC_CFLAGS+= -mlong-calls FILES= ${OBJS} Modified: projects/power8_bringup_hacks/lib/csu/common/ignore_init.c ============================================================================== --- projects/power8_bringup_hacks/lib/csu/common/ignore_init.c Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/csu/common/ignore_init.c Tue Oct 16 16:45:21 2018 (r339383) @@ -2,8 +2,11 @@ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright 2012 Konstantin Belousov - * All rights reserved. + * Copyright (c) 2018 The FreeBSD Foundation * + * Parts of this software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -29,7 +32,9 @@ __FBSDID("$FreeBSD$"); #include +#include #include + #include "notes.h" extern int main(int, char **, char **); @@ -45,6 +50,39 @@ extern void _init(void) __hidden; extern int _DYNAMIC; #pragma weak _DYNAMIC + +#if defined(CRT_IRELOC_RELA) +extern const Elf_Rela __rela_iplt_start[] __weak_symbol __hidden; +extern const Elf_Rela __rela_iplt_end[] __weak_symbol __hidden; + +#include "reloc.c" + +static void +process_irelocs(void) +{ + const Elf_Rela *r; + + for (r = &__rela_iplt_start[0]; r < &__rela_iplt_end[0]; r++) + crt1_handle_rela(r); +} +#elif defined(CRT_IRELOC_REL) +extern const Elf_Rel __rel_iplt_start[] __weak_symbol __hidden; +extern const Elf_Rel __rel_iplt_end[] __weak_symbol __hidden; + +#include "reloc.c" + +static void +process_irelocs(void) +{ + const Elf_Rel *r; + + for (r = &__rel_iplt_start[0]; r < &__rel_iplt_end[0]; r++) + crt1_handle_rel(r); +} +#elif defined(CRT_IRELOC_SUPPRESS) +#else +#error "Define platform reloc type" +#endif char **environ; const char *__progname = ""; Modified: projects/power8_bringup_hacks/lib/csu/i386/Makefile ============================================================================== --- projects/power8_bringup_hacks/lib/csu/i386/Makefile Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/csu/i386/Makefile Tue Oct 16 16:45:21 2018 (r339383) @@ -5,8 +5,9 @@ SRCS= crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= gcrt1.o crt1.o Scrt1.o -CFLAGS+= -I${.CURDIR:H}/common \ +CFLAGS+= -I${.CURDIR} -I${.CURDIR:H}/common \ -I${SRCTOP}/lib/libc/include +CFLAGS+= -DCRT_IRELOC_REL FILES= ${OBJS} FILESMODE= ${LIBMODE} Modified: projects/power8_bringup_hacks/lib/csu/i386/crt1_c.c ============================================================================== --- projects/power8_bringup_hacks/lib/csu/i386/crt1_c.c Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/csu/i386/crt1_c.c Tue Oct 16 16:45:21 2018 (r339383) @@ -56,10 +56,12 @@ _start1(fptr cleanup, int argc, char *argv[]) env = argv + argc + 1; handle_argv(argc, argv, env); - if (&_DYNAMIC != NULL) + if (&_DYNAMIC != NULL) { atexit(cleanup); - else + } else { + process_irelocs(); _init_tls(); + } #ifdef GCRT atexit(_mcleanup); Copied: projects/power8_bringup_hacks/lib/csu/i386/reloc.c (from r339382, head/lib/csu/i386/reloc.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/power8_bringup_hacks/lib/csu/i386/reloc.c Tue Oct 16 16:45:21 2018 (r339383, copy of r339382, head/lib/csu/i386/reloc.c) @@ -0,0 +1,88 @@ +/*- + * Copyright (c) 2018 The FreeBSD Foundation + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +static void +crt1_handle_rel(const Elf_Rel *r) +{ + Elf_Addr *where, target; + u_int cpuid_supported, p[4]; + uint32_t cpu_feature, cpu_feature2; + uint32_t cpu_stdext_feature, cpu_stdext_feature2; + + __asm __volatile( + " pushfl\n" + " popl %%eax\n" + " movl %%eax,%%ecx\n" + " xorl $0x200000,%%eax\n" + " pushl %%eax\n" + " popfl\n" + " pushfl\n" + " popl %%eax\n" + " xorl %%eax,%%ecx\n" + " je 1f\n" + " movl $1,%0\n" + " jmp 2f\n" + "1: movl $0,%0\n" + "2:\n" + : "=r" (cpuid_supported) : : "eax", "ecx", "cc"); + if (cpuid_supported) { + do_cpuid(1, p); + cpu_feature = p[3]; + cpu_feature2 = p[2]; + do_cpuid(0, p); + if (p[0] >= 7) { + cpuid_count(7, 0, p); + cpu_stdext_feature = p[1]; + cpu_stdext_feature2 = p[2]; + } else { + cpu_stdext_feature = 0; + cpu_stdext_feature2 = 0; + } + } else { + cpu_feature = 0; + cpu_feature2 = 0; + cpu_stdext_feature = 0; + cpu_stdext_feature2 = 0; + } + + switch (ELF_R_TYPE(r->r_info)) { + case R_386_IRELATIVE: + where = (Elf_Addr *)r->r_offset; + target = ((Elf_Addr (*)(uint32_t, uint32_t, uint32_t, + uint32_t))*where)(cpu_feature, cpu_feature2, + cpu_stdext_feature, cpu_stdext_feature2); + *where = target; + break; + } +} Modified: projects/power8_bringup_hacks/lib/csu/mips/Makefile ============================================================================== --- projects/power8_bringup_hacks/lib/csu/mips/Makefile Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/csu/mips/Makefile Tue Oct 16 16:45:21 2018 (r339383) @@ -7,6 +7,7 @@ OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= Scrt1.o gcrt1.o CFLAGS+= -I${.CURDIR:H}/common \ -I${SRCTOP}/lib/libc/include +CFLAGS+= -DCRT_IRELOC_SUPPRESS FILES= ${OBJS} FILESMODE= ${LIBMODE} Modified: projects/power8_bringup_hacks/lib/csu/powerpc/Makefile ============================================================================== --- projects/power8_bringup_hacks/lib/csu/powerpc/Makefile Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/csu/powerpc/Makefile Tue Oct 16 16:45:21 2018 (r339383) @@ -7,6 +7,7 @@ OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= Scrt1.o gcrt1.o CFLAGS+= -I${.CURDIR:H}/common \ -I${SRCTOP}/lib/libc/include +CFLAGS+= -DCRT_IRELOC_SUPPRESS FILES= ${OBJS} FILESMODE= ${LIBMODE} Modified: projects/power8_bringup_hacks/lib/csu/powerpc64/Makefile ============================================================================== --- projects/power8_bringup_hacks/lib/csu/powerpc64/Makefile Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/csu/powerpc64/Makefile Tue Oct 16 16:45:21 2018 (r339383) @@ -7,7 +7,7 @@ OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= Scrt1.o gcrt1.o CFLAGS+= -I${.CURDIR:H}/common \ -I${SRCTOP}/lib/libc/include \ - -mlongcall + -mlongcall -DCRT_IRELOC_SUPPRESS FILES= ${OBJS} FILESMODE= ${LIBMODE} Modified: projects/power8_bringup_hacks/lib/csu/riscv/Makefile ============================================================================== --- projects/power8_bringup_hacks/lib/csu/riscv/Makefile Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/csu/riscv/Makefile Tue Oct 16 16:45:21 2018 (r339383) @@ -7,6 +7,7 @@ OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= Scrt1.o gcrt1.o CFLAGS+= -I${.CURDIR:H}/common \ -I${SRCTOP}/lib/libc/include +CFLAGS+= -DCRT_IRELOC_SUPPRESS FILES= ${OBJS} FILESMODE= ${LIBMODE} Modified: projects/power8_bringup_hacks/lib/csu/sparc64/Makefile ============================================================================== --- projects/power8_bringup_hacks/lib/csu/sparc64/Makefile Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/csu/sparc64/Makefile Tue Oct 16 16:45:21 2018 (r339383) @@ -7,6 +7,7 @@ OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= Scrt1.o gcrt1.o CFLAGS+= -I${.CURDIR:H}/common \ -I${SRCTOP}/lib/libc/include +CFLAGS+= -DCRT_IRELOC_SUPPRESS FILES= ${OBJS} FILESMODE= ${LIBMODE} Modified: projects/power8_bringup_hacks/lib/libc/amd64/string/Makefile.inc ============================================================================== --- projects/power8_bringup_hacks/lib/libc/amd64/string/Makefile.inc Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/libc/amd64/string/Makefile.inc Tue Oct 16 16:45:21 2018 (r339383) @@ -2,7 +2,6 @@ MDSRCS+= \ bcmp.S \ - bcopy.S \ bzero.S \ memcmp.S \ memcpy.S \ Copied: projects/power8_bringup_hacks/lib/libc/amd64/string/bcopy.c (from r339382, head/lib/libc/amd64/string/bcopy.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/power8_bringup_hacks/lib/libc/amd64/string/bcopy.c Tue Oct 16 16:45:21 2018 (r339383, copy of r339382, head/lib/libc/amd64/string/bcopy.c) @@ -0,0 +1,15 @@ +/*- + * Public domain. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +void +bcopy(const void *src, void *dst, size_t len) +{ + + memmove(dst, src, len); +} Modified: projects/power8_bringup_hacks/lib/libc/amd64/string/memcpy.S ============================================================================== --- projects/power8_bringup_hacks/lib/libc/amd64/string/memcpy.S Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/libc/amd64/string/memcpy.S Tue Oct 16 16:45:21 2018 (r339383) @@ -1,5 +1,5 @@ /* $NetBSD: memcpy.S,v 1.1 2001/06/19 00:25:05 fvdl Exp $ */ /* $FreeBSD$ */ -#define MEMCOPY -#include "bcopy.S" +#define MEMCPY +#include "memmove.S" Modified: projects/power8_bringup_hacks/lib/libc/amd64/string/memmove.S ============================================================================== --- projects/power8_bringup_hacks/lib/libc/amd64/string/memmove.S Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/libc/amd64/string/memmove.S Tue Oct 16 16:45:21 2018 (r339383) @@ -1,5 +1,270 @@ -/* $NetBSD: memmove.S,v 1.1 2001/06/19 00:25:05 fvdl Exp $ */ -/* $FreeBSD$ */ +/*- + * Copyright (c) 2018 The FreeBSD Foundation + * + * This software was developed by Mateusz Guzik + * 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. + */ -#define MEMMOVE -#include "bcopy.S" +#include +__FBSDID("$FreeBSD$"); + +#define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */ + +/* + * memmove(dst, src, cnt) + * rdi, rsi, rdx + * Contains parts of bcopy written by: + * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 + */ + +/* + * Register state at entry is supposed to be as follows: + * rdi - destination + * rsi - source + * rdx - count + * + * The macro possibly clobbers the above and: rcx, r8. + * It does not clobber rax, r10 nor r11. + */ +.macro MEMMOVE erms overlap begin end + \begin +.if \overlap == 1 + movq %rdi,%r8 + subq %rsi,%r8 + cmpq %rcx,%r8 /* overlapping && src < dst? */ + jb 2f +.endif + + cmpq $32,%rcx + jb 1016f + + cmpq $256,%rcx + ja 1256f + +1032: + movq (%rsi),%rdx + movq %rdx,(%rdi) + movq 8(%rsi),%rdx + movq %rdx,8(%rdi) + movq 16(%rsi),%rdx + movq %rdx,16(%rdi) + movq 24(%rsi),%rdx + movq %rdx,24(%rdi) + leaq 32(%rsi),%rsi + leaq 32(%rdi),%rdi + subq $32,%rcx + cmpq $32,%rcx + jae 1032b + cmpb $0,%cl + jne 1016f + \end + ret + ALIGN_TEXT +1016: + cmpb $16,%cl + jl 1008f + movq (%rsi),%rdx + movq %rdx,(%rdi) + movq 8(%rsi),%rdx + movq %rdx,8(%rdi) + subb $16,%cl + jz 1000f + leaq 16(%rsi),%rsi + leaq 16(%rdi),%rdi +1008: + cmpb $8,%cl + jl 1004f + movq (%rsi),%rdx + movq %rdx,(%rdi) + subb $8,%cl + jz 1000f + leaq 8(%rsi),%rsi + leaq 8(%rdi),%rdi +1004: + cmpb $4,%cl + jl 1002f + movl (%rsi),%edx + movl %edx,(%rdi) + subb $4,%cl + jz 1000f + leaq 4(%rsi),%rsi + leaq 4(%rdi),%rdi +1002: + cmpb $2,%cl + jl 1001f + movw (%rsi),%dx + movw %dx,(%rdi) + subb $2,%cl + jz 1000f + leaq 2(%rsi),%rsi + leaq 2(%rdi),%rdi +1001: + cmpb $1,%cl + jl 1000f + movb (%rsi),%dl + movb %dl,(%rdi) +1000: + \end + ret + + ALIGN_TEXT +1256: +.if \erms == 1 + rep + movsb +.else + shrq $3,%rcx /* copy by 64-bit words */ + rep + movsq + movq %rdx,%rcx + andb $7,%cl /* any bytes left? */ + jne 1004b +.endif + \end + ret + +.if \overlap == 1 + /* + * Copy backwards. + */ + ALIGN_TEXT +2: + addq %rcx,%rdi + addq %rcx,%rsi + + cmpq $32,%rcx + jb 2016f + + cmpq $256,%rcx + ja 2256f + +2032: + movq -8(%rsi),%rdx + movq %rdx,-8(%rdi) + movq -16(%rsi),%rdx + movq %rdx,-16(%rdi) + movq -24(%rsi),%rdx + movq %rdx,-24(%rdi) + movq -32(%rsi),%rdx + movq %rdx,-32(%rdi) + leaq -32(%rsi),%rsi + leaq -32(%rdi),%rdi + subq $32,%rcx + cmpq $32,%rcx + jae 2032b + cmpb $0,%cl + jne 2016f + \end + ret + ALIGN_TEXT +2016: + cmpb $16,%cl + jl 2008f + movq -8(%rsi),%rdx + movq %rdx,-8(%rdi) + movq -16(%rsi),%rdx + movq %rdx,-16(%rdi) + subb $16,%cl + jz 2000f + leaq -16(%rsi),%rsi + leaq -16(%rdi),%rdi +2008: + cmpb $8,%cl + jl 2004f + movq -8(%rsi),%rdx + movq %rdx,-8(%rdi) + subb $8,%cl + jz 2000f + leaq -8(%rsi),%rsi + leaq -8(%rdi),%rdi +2004: + cmpb $4,%cl + jl 2002f + movl -4(%rsi),%edx + movl %edx,-4(%rdi) + subb $4,%cl + jz 2000f + leaq -4(%rsi),%rsi + leaq -4(%rdi),%rdi +2002: + cmpb $2,%cl + jl 2001f + movw -2(%rsi),%dx + movw %dx,-2(%rdi) + subb $2,%cl + jz 2000f + leaq -2(%rsi),%rsi + leaq -2(%rdi),%rdi +2001: + cmpb $1,%cl + jl 2000f + movb -1(%rsi),%dl + movb %dl,-1(%rdi) +2000: + \end + ret + ALIGN_TEXT +2256: + decq %rdi + decq %rsi + std +.if \erms == 1 + rep + movsb +.else + andq $7,%rcx /* any fractional bytes? */ + je 3f + rep + movsb +3: + movq %rdx,%rcx /* copy remainder by 32-bit words */ + shrq $3,%rcx + subq $7,%rsi + subq $7,%rdi + rep + movsq +.endif + cld + \end + ret +.endif +.endm + +.macro MEMMOVE_BEGIN + movq %rdi,%rax + movq %rdx,%rcx +.endm + +.macro MEMMOVE_END +.endm + +#ifndef MEMCPY +ENTRY(memmove) + MEMMOVE erms=0 overlap=1 begin=MEMMOVE_BEGIN end=MEMMOVE_END +END(memmove) +#else +ENTRY(memcpy) + MEMMOVE erms=0 overlap=1 begin=MEMMOVE_BEGIN end=MEMMOVE_END +END(memcpy) +#endif Modified: projects/power8_bringup_hacks/lib/libc/net/nsdispatch.3 ============================================================================== --- projects/power8_bringup_hacks/lib/libc/net/nsdispatch.3 Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/libc/net/nsdispatch.3 Tue Oct 16 16:45:21 2018 (r339383) @@ -32,7 +32,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 4, 2010 +.Dd October 15, 2018 .Dt NSDISPATCH 3 .Os .Sh NAME @@ -112,10 +112,7 @@ which case they are selected using the and .Fa method_name arguments along with the configured source. -(The methods supplied via -.Fa dtab -take priority over those implemented in NSS modules in the event -of a conflict.) +Modules must use source names different from the built-in ones. .Pp .Va defaults contains a list of default sources to try if Modified: projects/power8_bringup_hacks/lib/libc/net/nsdispatch.c ============================================================================== --- projects/power8_bringup_hacks/lib/libc/net/nsdispatch.c Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/libc/net/nsdispatch.c Tue Oct 16 16:45:21 2018 (r339383) @@ -486,9 +486,19 @@ nss_load_module(const char *source, nss_module_registe */ mod.handle = nss_builtin_handle; fn = reg_fn; - } else if (!is_dynamic()) + } else if (!is_dynamic()) { goto fin; - else { + } else if (strcmp(source, NSSRC_CACHE) == 0 || + strcmp(source, NSSRC_COMPAT) == 0 || + strcmp(source, NSSRC_DB) == 0 || + strcmp(source, NSSRC_DNS) == 0 || + strcmp(source, NSSRC_FILES) == 0 || + strcmp(source, NSSRC_NIS) == 0) { + /* + * Avoid calling dlopen(3) for built-in modules. + */ + goto fin; + } else { if (snprintf(buf, sizeof(buf), "nss_%s.so.%d", mod.name, NSS_MODULE_INTERFACE_VERSION) >= (int)sizeof(buf)) goto fin; Modified: projects/power8_bringup_hacks/lib/libc/net/nslexer.l ============================================================================== --- projects/power8_bringup_hacks/lib/libc/net/nslexer.l Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/libc/net/nslexer.l Tue Oct 16 16:45:21 2018 (r339383) @@ -50,6 +50,7 @@ static char *rcsid = %} +%option never-interactive %option noinput %option nounput %option yylineno Modified: projects/power8_bringup_hacks/lib/libc/stdtime/strptime.c ============================================================================== --- projects/power8_bringup_hacks/lib/libc/stdtime/strptime.c Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/libc/stdtime/strptime.c Tue Oct 16 16:45:21 2018 (r339383) @@ -291,7 +291,7 @@ label: if (c == 'H' || c == 'k') { if (i > 23) return (NULL); - } else if (i > 12) + } else if (i == 0 || i > 12) return (NULL); tm->tm_hour = i; Modified: projects/power8_bringup_hacks/lib/libc/string/memmem.c ============================================================================== --- projects/power8_bringup_hacks/lib/libc/string/memmem.c Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/libc/string/memmem.c Tue Oct 16 16:45:21 2018 (r339383) @@ -31,27 +31,27 @@ __FBSDID("$FreeBSD$"); static char *twobyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) { uint16_t nw = n[0]<<8 | n[1], hw = h[0]<<8 | h[1]; - for (h++, k--; k; k--, hw = hw<<8 | *++h) - if (hw == nw) return (char *)h-1; - return 0; + for (h+=2, k-=2; k; k--, hw = hw<<8 | *h++) + if (hw == nw) return (char *)h-2; + return hw == nw ? (char *)h-2 : 0; } static char *threebyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) { uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8; uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8; - for (h+=2, k-=2; k; k--, hw = (hw|*++h)<<8) - if (hw == nw) return (char *)h-2; - return 0; + for (h+=3, k-=3; k; k--, hw = (hw|*h++)<<8) + if (hw == nw) return (char *)h-3; + return hw == nw ? (char *)h-3 : 0; } static char *fourbyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) { uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3]; uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3]; - for (h+=3, k-=3; k; k--, hw = hw<<8 | *++h) - if (hw == nw) return (char *)h-3; - return 0; + for (h+=4, k-=4; k; k--, hw = hw<<8 | *h++) + if (hw == nw) return (char *)h-4; + return hw == nw ? (char *)h-4 : 0; } #define MAX(a,b) ((a)>(b)?(a):(b)) Modified: projects/power8_bringup_hacks/lib/libc/sys/pdfork.2 ============================================================================== --- projects/power8_bringup_hacks/lib/libc/sys/pdfork.2 Tue Oct 16 16:36:02 2018 (r339382) +++ projects/power8_bringup_hacks/lib/libc/sys/pdfork.2 Tue Oct 16 16:45:21 2018 (r339383) @@ -32,7 +32,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 17, 2017 *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-projects@freebsd.org Tue Oct 16 16:55:19 2018 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5F38310DA73F for ; Tue, 16 Oct 2018 16:55:19 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 14B7C75622; Tue, 16 Oct 2018 16:55:18 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro-2.local (ralph.baldwin.cx [66.234.199.215]) by mail.baldwin.cx (Postfix) with ESMTPSA id D1C5810AFD2; Tue, 16 Oct 2018 12:55:16 -0400 (EDT) Subject: Re: svn commit: r339382 - projects/power8_bringup_hacks/sys/dev/bge To: Leandro Lupori , src-committers@freebsd.org, svn-src-projects@freebsd.org References: <201810161636.w9GGa3Nl001743@repo.freebsd.org> From: John Baldwin Message-ID: <8a90e167-a4ac-c32f-ae9c-d71f0fcb5471@FreeBSD.org> Date: Tue, 16 Oct 2018 09:55:13 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <201810161636.w9GGa3Nl001743@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Tue, 16 Oct 2018 12:55:18 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Oct 2018 16:55:19 -0000 On 10/16/18 9:36 AM, Leandro Lupori wrote: > Author: luporl > Date: Tue Oct 16 16:36:02 2018 > New Revision: 339382 > URL: https://svnweb.freebsd.org/changeset/base/339382 > > Log: > bge(4): limit DMA address to 2GB > > This is a temporary hack, to avoid POWER8 Broadcom NICs from becoming > unusable after transferring a reasonable amount of data. > The issue is the same as that of AHCI, where DMA addresses above 2GB > do not work and causes PCI errors. Is the issue bge specific or specific to the PCI chipset in these boxes? If the latter, the better approach would be to set the limit in a tag the chipset provides that all child devices would then inherit. -- John Baldwin                                                                              From owner-svn-src-projects@freebsd.org Tue Oct 16 17:07:03 2018 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E6AE710DADFF for ; Tue, 16 Oct 2018 17:07:02 +0000 (UTC) (envelope-from leandro.lupori@gmail.com) Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 782BE75FC1; Tue, 16 Oct 2018 17:07:02 +0000 (UTC) (envelope-from leandro.lupori@gmail.com) Received: by mail-yb1-xb35.google.com with SMTP id o63-v6so9202967yba.2; Tue, 16 Oct 2018 10:07:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=h2KQrxGLhJkppGut9QjcAs8FB1grLsEYnNPDUBcjEd4=; b=DbYgxuWUWliBrfuTzj5DOh3EqEVplRRHCvr7vg+nFmm7DHea70DmhkUpaRzsnOWeY5 e6n5/OzOU0pAUMd10h2Ly17QeS0OolfIv6HkyayJ35oXwVeDiGsER3cMPO5Efk9jTIY1 nBul0fI3iGix9pbvzX2ig8VD5YgEygy/xOu+oVf7PdQRw4L/4yqZTO7DNR5sAYqaF1Nt rlmh1j8sxyzp3e9AM2eaCSHToBLTz5z0GKo+7EbXU79RPg/wzyRhKjYYOrkiwjz6HWmX C+C1z3fb4itMv00bgEN6J7uMMRz2lxl6/XtXT9CiD5iUI8gPK1bLQkc1fDR4FrDMKB63 0SuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=h2KQrxGLhJkppGut9QjcAs8FB1grLsEYnNPDUBcjEd4=; b=RLYTrHsFqXhEc7hOPe4KVB5aG8Ipz/z7o3+F95NtBYchN0FoTDKks2uxAI8f5ryA4E 0VFzeYKtGJBU48PNPlToOZJ9OrMk+MOSS4mQJvx5fpo9a67DwFY+Om+SbXSBl7++ZiN3 URcazw4mZqXFxcoqf6EUj8rj5Zj9j1y1igexCLxm0YiM7s91j2bsrkjJScyGx5ytXPLi 4L2Y/S48hL5TvfI90qBKBu2B/fUl9XBG6Qg0yvYLR3bEtPCpLpTlM1MYhy2HIPuGZqKp TqpugBHJedAH/7LvEaXMHxbPytHIYic1Y85amfUj5SHh05GKEe/hvAXfAFPrktKNHAyv TWuA== X-Gm-Message-State: ABuFfojvqsIeK97GQKS/GSYB1Ny8/iwTY/t1DiCYQKBmw2viZFSp+Y3F cI3K31acoQsOxQGvDZEqF8WhAu4phNbVDA2qD+UwCP7O X-Google-Smtp-Source: ACcGV606ERknphWQRO8TCPxa95ar6pOb7R3fcT+lmAa4pmeMkl/6dTN94ANOgll58YY/y912+a2SiWDjI9pnjWgngZU= X-Received: by 2002:a25:3748:: with SMTP id e69-v6mr5915389yba.245.1539709621329; Tue, 16 Oct 2018 10:07:01 -0700 (PDT) MIME-Version: 1.0 References: <201810161636.w9GGa3Nl001743@repo.freebsd.org> <8a90e167-a4ac-c32f-ae9c-d71f0fcb5471@FreeBSD.org> In-Reply-To: <8a90e167-a4ac-c32f-ae9c-d71f0fcb5471@FreeBSD.org> From: Leandro Date: Tue, 16 Oct 2018 14:06:49 -0300 Message-ID: Subject: Re: svn commit: r339382 - projects/power8_bringup_hacks/sys/dev/bge To: jhb@freebsd.org Cc: luporl@freebsd.org, src-committers@freebsd.org, svn-src-projects@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Oct 2018 17:07:03 -0000 The issue seems to be related to wrong configuration of DMA regions in opal_pci.c, which affects all PowerNV platforms. This is where I'm going to look next, that, if solved, we should be able to remove this hack. This is just to make the network interface stable, until the real issue is resolved. On Tue, Oct 16, 2018 at 1:55 PM John Baldwin wrote: > > On 10/16/18 9:36 AM, Leandro Lupori wrote: > > Author: luporl > > Date: Tue Oct 16 16:36:02 2018 > > New Revision: 339382 > > URL: https://svnweb.freebsd.org/changeset/base/339382 > > > > Log: > > bge(4): limit DMA address to 2GB > > > > This is a temporary hack, to avoid POWER8 Broadcom NICs from becoming > > unusable after transferring a reasonable amount of data. > > The issue is the same as that of AHCI, where DMA addresses above 2GB > > do not work and causes PCI errors. > > Is the issue bge specific or specific to the PCI chipset in these boxes? > If the latter, the better approach would be to set the limit in a tag the > chipset provides that all child devices would then inherit. > > -- > John Baldwin > > From owner-svn-src-projects@freebsd.org Wed Oct 17 19:30:00 2018 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D228210DD408 for ; Wed, 17 Oct 2018 19:29:59 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 743ED8EC32; Wed, 17 Oct 2018 19:29:59 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 48C3615228; Wed, 17 Oct 2018 19:29:59 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w9HJTxWp028752; Wed, 17 Oct 2018 19:29:59 GMT (envelope-from luporl@FreeBSD.org) Received: (from luporl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w9HJTwZC028748; Wed, 17 Oct 2018 19:29:58 GMT (envelope-from luporl@FreeBSD.org) Message-Id: <201810171929.w9HJTwZC028748@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: luporl set sender to luporl@FreeBSD.org using -f From: Leandro Lupori Date: Wed, 17 Oct 2018 19:29:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r339415 - in projects/power8_bringup_hacks/sys: dev/ahci dev/bge powerpc/powernv X-SVN-Group: projects X-SVN-Commit-Author: luporl X-SVN-Commit-Paths: in projects/power8_bringup_hacks/sys: dev/ahci dev/bge powerpc/powernv X-SVN-Commit-Revision: 339415 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Oct 2018 19:30:00 -0000 Author: luporl Date: Wed Oct 17 19:29:57 2018 New Revision: 339415 URL: https://svnweb.freebsd.org/changeset/base/339415 Log: ppc64: limited 32-bit DMA address range Further investigation of issues with 32-bit DMA on PowerNV revealed that its window is hardcoded by OPAL (at least in skiboot version 5.4.9) and cannot be changed by the OS. Thus, now jhb suggestion of limiting the range in PCI DMA tag seems the best way to deal with it. This was done in opal_pci.c. This commit also reverts 2 previous hacks, in AHCI and bge(4). Modified: projects/power8_bringup_hacks/sys/dev/ahci/ahci.c projects/power8_bringup_hacks/sys/dev/ahci/ahci.h projects/power8_bringup_hacks/sys/dev/ahci/ahci_pci.c projects/power8_bringup_hacks/sys/dev/bge/if_bge.c projects/power8_bringup_hacks/sys/powerpc/powernv/opal_pci.c Modified: projects/power8_bringup_hacks/sys/dev/ahci/ahci.c ============================================================================== --- projects/power8_bringup_hacks/sys/dev/ahci/ahci.c Wed Oct 17 16:54:13 2018 (r339414) +++ projects/power8_bringup_hacks/sys/dev/ahci/ahci.c Wed Oct 17 19:29:57 2018 (r339415) @@ -100,21 +100,6 @@ static MALLOC_DEFINE(M_AHCI, "AHCI driver", "AHCI driv #define RECOVERY_REQUEST_SENSE 2 #define recovery_slot spriv_field1 -#ifdef __powerpc64__ -#define AHCI_BUS_SPACE_MAXADDR_31BIT 0x7FFFFFFFU - -#define AHCI_BUS_SPACE_MAXADDR(quirks) \ - (quirks & AHCI_Q_DMA31 ? AHCI_BUS_SPACE_MAXADDR_31BIT : \ - BUS_SPACE_MAXADDR) - -#define AHCI_BUS_SPACE_MAXADDR_32BIT(quirks) \ - (quirks & AHCI_Q_DMA31 ? AHCI_BUS_SPACE_MAXADDR_31BIT : \ - BUS_SPACE_MAXADDR_32BIT) -#else -#define AHCI_BUS_SPACE_MAXADDR(quirks) BUS_SPACE_MAXADDR -#define AHCI_BUS_SPACE_MAXADDR_32BIT(quirks) BUS_SPACE_MAXADDR_32BIT -#endif - int ahci_ctlr_setup(device_t dev) { @@ -263,10 +248,8 @@ ahci_attach(device_t dev) /* Create controller-wide DMA tag. */ if (bus_dma_tag_create(bus_get_dma_tag(dev), 1, 0, - (ctlr->caps & AHCI_CAP_64BIT) ? - AHCI_BUS_SPACE_MAXADDR(ctlr->quirks) : - AHCI_BUS_SPACE_MAXADDR_32BIT(ctlr->quirks), - AHCI_BUS_SPACE_MAXADDR(ctlr->quirks), NULL, NULL, + (ctlr->caps & AHCI_CAP_64BIT) ? BUS_SPACE_MAXADDR : + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE, BUS_SPACE_UNRESTRICTED, BUS_SPACE_MAXSIZE, ctlr->dma_coherent ? BUS_DMA_COHERENT : 0, NULL, NULL, &ctlr->dma_tag)) { @@ -960,8 +943,7 @@ ahci_dmainit(device_t dev) /* Command area. */ if (bus_dma_tag_create(bus_get_dma_tag(dev), 1024, 0, - AHCI_BUS_SPACE_MAXADDR(ch->quirks), - AHCI_BUS_SPACE_MAXADDR(ch->quirks), + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, AHCI_WORK_SIZE, 1, AHCI_WORK_SIZE, 0, NULL, NULL, &ch->dma.work_tag)) goto error; @@ -980,8 +962,7 @@ ahci_dmainit(device_t dev) else rfsize = 256; if (bus_dma_tag_create(bus_get_dma_tag(dev), rfsize, 0, - AHCI_BUS_SPACE_MAXADDR(ch->quirks), - AHCI_BUS_SPACE_MAXADDR(ch->quirks), + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, rfsize, 1, rfsize, 0, NULL, NULL, &ch->dma.rfis_tag)) goto error; @@ -996,8 +977,7 @@ ahci_dmainit(device_t dev) ch->dma.rfis_bus = dcba.maddr; /* Data area. */ if (bus_dma_tag_create(bus_get_dma_tag(dev), 2, 0, - AHCI_BUS_SPACE_MAXADDR(ch->quirks), - AHCI_BUS_SPACE_MAXADDR(ch->quirks), + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, AHCI_SG_ENTRIES * PAGE_SIZE * ch->numslots, AHCI_SG_ENTRIES, AHCI_PRD_MAX, Modified: projects/power8_bringup_hacks/sys/dev/ahci/ahci.h ============================================================================== --- projects/power8_bringup_hacks/sys/dev/ahci/ahci.h Wed Oct 17 16:54:13 2018 (r339414) +++ projects/power8_bringup_hacks/sys/dev/ahci/ahci.h Wed Oct 17 19:29:57 2018 (r339415) @@ -604,7 +604,6 @@ enum ahci_err_type { #define AHCI_Q_MRVL_SR_DEL 0x00200000 #define AHCI_Q_NOCCS 0x00400000 #define AHCI_Q_NOAUX 0x00800000 -#define AHCI_Q_DMA31 0x01000000 #define AHCI_Q_BIT_STRING \ "\020" \ @@ -631,8 +630,7 @@ enum ahci_err_type { "\025NOMSIX" \ "\026MRVL_SR_DEL" \ "\027NOCCS" \ - "\030NOAUX" \ - "\031DMA31" + "\030NOAUX" int ahci_attach(device_t dev); int ahci_detach(device_t dev); Modified: projects/power8_bringup_hacks/sys/dev/ahci/ahci_pci.c ============================================================================== --- projects/power8_bringup_hacks/sys/dev/ahci/ahci_pci.c Wed Oct 17 16:54:13 2018 (r339414) +++ projects/power8_bringup_hacks/sys/dev/ahci/ahci_pci.c Wed Oct 17 19:29:57 2018 (r339415) @@ -261,7 +261,7 @@ static const struct { {0x92151b4b, 0x00, "Marvell 88SE9215", 0}, {0x92201b4b, 0x00, "Marvell 88SE9220", AHCI_Q_ALTSIG}, {0x92301b4b, 0x00, "Marvell 88SE9230", AHCI_Q_ALTSIG}, - {0x92351b4b, 0x00, "Marvell 88SE9235", AHCI_Q_DMA31}, + {0x92351b4b, 0x00, "Marvell 88SE9235", 0}, {0x06201103, 0x00, "HighPoint RocketRAID 620", 0}, {0x06201b4b, 0x00, "HighPoint RocketRAID 620", 0}, {0x06221103, 0x00, "HighPoint RocketRAID 622", 0}, Modified: projects/power8_bringup_hacks/sys/dev/bge/if_bge.c ============================================================================== --- projects/power8_bringup_hacks/sys/dev/bge/if_bge.c Wed Oct 17 16:54:13 2018 (r339414) +++ projects/power8_bringup_hacks/sys/dev/bge/if_bge.c Wed Oct 17 19:29:57 2018 (r339415) @@ -134,8 +134,6 @@ MODULE_DEPEND(bge, miibus, 1, 1, 1); /* "device miibus" required. See GENERIC if you get errors here. */ #include "miibus_if.h" -#define BGE_BUS_SPACE_MAXADDR_32BIT 0x7FFFFFFFU - /* * Various supported device vendors/types and their names. Note: the * spec seems to indicate that the hardware still has Alteon's vendor @@ -3052,16 +3050,15 @@ bge_dma_alloc(struct bge_softc *sc) /* Create parent tag for buffers. */ if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0) { - lowaddr = BGE_BUS_SPACE_MAXADDR_32BIT; /* * XXX * watchdog timeout issue was observed on BCM5704 which * lives behind PCI-X bridge(e.g AMD 8131 PCI-X bridge). * Both limiting DMA address space to 32bits and flushing * mailbox write seem to address the issue. + */ if (sc->bge_pcixcap != 0) lowaddr = BUS_SPACE_MAXADDR_32BIT; - */ } error = bus_dma_tag_create(bus_get_dma_tag(sc->bge_dev), 1, 0, lowaddr, BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, 0, Modified: projects/power8_bringup_hacks/sys/powerpc/powernv/opal_pci.c ============================================================================== --- projects/power8_bringup_hacks/sys/powerpc/powernv/opal_pci.c Wed Oct 17 16:54:13 2018 (r339414) +++ projects/power8_bringup_hacks/sys/powerpc/powernv/opal_pci.c Wed Oct 17 19:29:57 2018 (r339415) @@ -96,6 +96,9 @@ static int opalpci_route_interrupt(device_t bus, devic static void opalpic_pic_enable(device_t dev, u_int irq, u_int vector); static void opalpic_pic_eoi(device_t dev, u_int irq); +/* Bus interface */ +static bus_dma_tag_t opalpci_get_dma_tag(device_t dev, device_t child); + /* * Commands */ @@ -119,6 +122,8 @@ static void opalpic_pic_eoi(device_t dev, u_int irq); */ #define OPAL_PCI_DEFAULT_PE 1 +#define OPAL_PCI_BUS_SPACE_LOWADDR_32BIT 0x7FFFFFFFUL + /* * Driver methods. */ @@ -142,6 +147,9 @@ static device_method_t opalpci_methods[] = { DEVMETHOD(pic_enable, opalpic_pic_enable), DEVMETHOD(pic_eoi, opalpic_pic_eoi), + /* Bus interface */ + DEVMETHOD(bus_get_dma_tag, opalpci_get_dma_tag), + DEVMETHOD_END }; @@ -424,6 +432,23 @@ opalpci_attach(device_t dev) msi_ranges[1], msi_ranges[0]); } + /* Create the parent DMA tag */ + err = bus_dma_tag_create(bus_get_dma_tag(dev), /* parent */ + 1, 0, /* alignment, bounds */ + OPAL_PCI_BUS_SPACE_LOWADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR_32BIT, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + BUS_SPACE_MAXSIZE, /* maxsize */ + BUS_SPACE_UNRESTRICTED, /* nsegments */ + BUS_SPACE_MAXSIZE, /* maxsegsize */ + 0, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ + &sc->ofw_sc.sc_dmat); + if (err != 0) { + device_printf(dev, "Failed to create DMA tag\n"); + return (err); + } + /* * General OFW PCI attach */ @@ -660,4 +685,13 @@ static void opalpic_pic_eoi(device_t dev, u_int irq) opal_call(OPAL_PCI_MSI_EOI, sc->phb_id, irq); PIC_EOI(root_pic, irq); +} + +static bus_dma_tag_t +opalpci_get_dma_tag(device_t dev, device_t child) +{ + struct opalpci_softc *sc; + + sc = device_get_softc(dev); + return (sc->ofw_sc.sc_dmat); }