From 97aba5586d36f9670a77dc6e60ec1b9ef31ce9ae Mon Sep 17 00:00:00 2001 From: Lorenzo Stoakes Date: Thu, 28 Jul 2016 14:25:49 +0100 Subject: bucket: correct broken unaligned load/store in armv5 armv5 devices and older (i.e. <= arm9 generation) require addresses that are stored to and loaded from to to be 4-byte aligned. If this is not the case the lower 2 bits of the address are cleared and the load is performed in an unexpected order, including up to 3 bytes of data located prior to the address. Inlined buckets are stored after their key in a page and since there is no guarantee that the key will be of a length that is a multiple of 4, it is possible for unaligned load/stores to occur when they are cast back to bucket and page pointer types. The fix adds a new field to track whether the current architecture exhibits this issue, sets it on module load for ARM architectures, and then on bucket open, if this field is set and the address is unaligned, a byte-by-byte copy of the inlined bucket is performed. Ref: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka15414.html --- bolt_s390x.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'bolt_s390x.go') diff --git a/bolt_s390x.go b/bolt_s390x.go index f4dd26b..d7c39af 100644 --- a/bolt_s390x.go +++ b/bolt_s390x.go @@ -7,3 +7,6 @@ const maxMapSize = 0xFFFFFFFFFFFF // 256TB // maxAllocSize is the size used when creating array pointers. const maxAllocSize = 0x7FFFFFFF + +// Are unaligned load/stores broken on this arch? +var brokenUnaligned = false -- cgit v1.2.3