From owner-svn-src-head@freebsd.org Fri Mar 6 01:45:04 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9C568252A7D; Fri, 6 Mar 2020 01:45:04 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48YVmc2wLKz3CLr; Fri, 6 Mar 2020 01:45:04 +0000 (UTC) (envelope-from jhibbits@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 3067B18B26; Fri, 6 Mar 2020 01:45:04 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0261j3wE053285; Fri, 6 Mar 2020 01:45:03 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0261j3vl053282; Fri, 6 Mar 2020 01:45:03 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <202003060145.0261j3vl053282@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Fri, 6 Mar 2020 01:45:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r358688 - head/lib/libc/powerpc64/string X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/lib/libc/powerpc64/string X-SVN-Commit-Revision: 358688 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Mar 2020 01:45:04 -0000 Author: jhibbits Date: Fri Mar 6 01:45:03 2020 New Revision: 358688 URL: https://svnweb.freebsd.org/changeset/base/358688 Log: powerpc/powerpc64: Enforce natural alignment in memcpy Summary: POWER architecture CPUs (Book-S) require natural alignment for cache-inhibited storage accesses. Since we can't know the caching model for a page ahead of time, always enforce natural alignment in memcpy. This fixes a SIGBUS in X with acceleration enabled on POWER9. As part of this, revert r358672, it's no longer necessary with this fix. Regression tested by alfredo. Reviewed by: alfredo Differential Revision: https://reviews.freebsd.org/D23969 Modified: head/lib/libc/powerpc64/string/bcopy_resolver.c head/lib/libc/powerpc64/string/memcpy.S head/lib/libc/powerpc64/string/memcpy_vsx.S Modified: head/lib/libc/powerpc64/string/bcopy_resolver.c ============================================================================== --- head/lib/libc/powerpc64/string/bcopy_resolver.c Thu Mar 5 22:45:16 2020 (r358687) +++ head/lib/libc/powerpc64/string/bcopy_resolver.c Fri Mar 6 01:45:03 2020 (r358688) @@ -66,7 +66,7 @@ DEFINE_UIFUNC(, FN_RET, FN_NAME, FN_PARAMS) * Since POWER ISA 2.07B this is solved transparently * by the hardware */ - if (cpu_features2 & PPC_FEATURE2_ARCH_2_07) + if (cpu_features2 & PPC_FEATURE_HAS_VSX) return (FN_NAME_VSX); else return (FN_NAME_NOVSX); Modified: head/lib/libc/powerpc64/string/memcpy.S ============================================================================== --- head/lib/libc/powerpc64/string/memcpy.S Thu Mar 5 22:45:16 2020 (r358687) +++ head/lib/libc/powerpc64/string/memcpy.S Fri Mar 6 01:45:03 2020 (r358688) @@ -39,6 +39,11 @@ WEAK_REFERENCE(__memcpy, memcpy); #define BLOCK_BYTES (1 << BLOCK_BITS) #define BLOCK_MASK (BLOCK_BYTES - 1) +/* Minimum 8 byte alignment, to avoid cache-inhibited alignment faults. */ +#ifndef ALIGN_MASK +#define ALIGN_MASK 0x7 +#endif + /* * r3: dst * r4: src @@ -48,6 +53,12 @@ ENTRY(FN_NAME) cmpdi %r5, 0 /* len == 0? nothing to do */ beqlr- + /* If src and dst are relatively misaligned, do byte copies. */ + andi. %r8, %r3, ALIGN_MASK + andi. %r7, %r4, ALIGN_MASK + cmpd %r8, %r7 + mr %r7, %r5 + bne+ .Lcopy_remaining_fix_index_byte mr %r8, %r3 /* save dst */ /* align src */ Modified: head/lib/libc/powerpc64/string/memcpy_vsx.S ============================================================================== --- head/lib/libc/powerpc64/string/memcpy_vsx.S Thu Mar 5 22:45:16 2020 (r358687) +++ head/lib/libc/powerpc64/string/memcpy_vsx.S Fri Mar 6 01:45:03 2020 (r358688) @@ -30,6 +30,7 @@ #define FN_NAME __memcpy_vsx #define BLOCK_BITS 6 +#define ALIGN_MASK 0xf /* * r5: bytes to copy (multiple of BLOCK_BYTES)