Page MenuHomeFreeBSD

powerpc/powerpc64: Enforce natural alignment in memcpy
ClosedPublic

Authored by jhibbits on Mar 5 2020, 2:59 PM.
Tags
None
Referenced Files
F154000091: D23969.id69219.diff
Sat, Apr 25, 8:54 AM
F153993758: D23969.id.diff
Sat, Apr 25, 7:50 AM
Unknown Object (File)
Thu, Apr 23, 5:36 AM
Unknown Object (File)
Mon, Apr 20, 10:04 PM
Unknown Object (File)
Mon, Apr 20, 1:38 PM
Unknown Object (File)
Thu, Apr 16, 2:40 PM
Unknown Object (File)
Tue, Apr 14, 11:35 AM
Unknown Object (File)
Fri, Apr 10, 3:00 AM
Subscribers

Details

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.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

lib/libc/powerpc64/string/memcpy.S
61 ↗(On Diff #69219)

You also need to check if len (r5) is 0 and exit, because .Lcopy_remaining_fix_index_byte doesn't handle this case.

lib/libc/powerpc64/string/memcpy.S
61 ↗(On Diff #69219)

Sorry, I missed the cmpdi %r5, 0 above, so forget my previous comment.

I tested this patch with D23958/r358672 reverted. This solution makes optimized memcpy/bcopy code viable again on POWER7. It slows down some cases but it's a gain in overal, I think.

This revision is now accepted and ready to land.Mar 5 2020, 8:09 PM