aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorMeng Zhuo <mzh@golangcn.org>2022-02-09 10:39:15 +0800
committermzh <mzh@golangcn.org>2022-02-09 06:35:15 +0000
commitbe0d049a42ee4b07bfb71acb5e8f7c3d2735049a (patch)
tree931f5365041644188b070caa9e84daba3d168d83 /src/runtime
parent255acb0c059268c99e45b693645a256719f3abb2 (diff)
downloadgo-be0d049a42ee4b07bfb71acb5e8f7c3d2735049a.tar.xz
runtime: AES maphash scramble 3 times on 386
Issue #43130 shows flaky hash not inbalanced on 386 platform, which is using AES hashing instead of wyhash. This CL increase the scramble times to 3 that amd64 using right now. Fixes #43130 Change-Id: I9d012eda99ff71c13a89448f46fcb9c5e7cec921 Reviewed-on: https://go-review.googlesource.com/c/go/+/384075 Trust: mzh <mzh@golangcn.org> Run-TryBot: mzh <mzh@golangcn.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/asm_386.s33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/runtime/asm_386.s b/src/runtime/asm_386.s
index 594cd5ed0d..e16880c950 100644
--- a/src/runtime/asm_386.s
+++ b/src/runtime/asm_386.s
@@ -937,8 +937,9 @@ aes0to15:
PAND masks<>(SB)(BX*8), X1
final1:
- AESENC X0, X1 // scramble input, xor in seed
- AESENC X1, X1 // scramble combo 2 times
+ PXOR X0, X1 // xor data with seed
+ AESENC X1, X1 // scramble combo 3 times
+ AESENC X1, X1
AESENC X1, X1
MOVL X1, (DX)
RET
@@ -971,9 +972,13 @@ aes17to32:
MOVOU (AX), X2
MOVOU -16(AX)(BX*1), X3
+ // xor with seed
+ PXOR X0, X2
+ PXOR X1, X3
+
// scramble 3 times
- AESENC X0, X2
- AESENC X1, X3
+ AESENC X2, X2
+ AESENC X3, X3
AESENC X2, X2
AESENC X3, X3
AESENC X2, X2
@@ -1000,10 +1005,15 @@ aes33to64:
MOVOU -32(AX)(BX*1), X6
MOVOU -16(AX)(BX*1), X7
- AESENC X0, X4
- AESENC X1, X5
- AESENC X2, X6
- AESENC X3, X7
+ PXOR X0, X4
+ PXOR X1, X5
+ PXOR X2, X6
+ PXOR X3, X7
+
+ AESENC X4, X4
+ AESENC X5, X5
+ AESENC X6, X6
+ AESENC X7, X7
AESENC X4, X4
AESENC X5, X5
@@ -1069,7 +1079,12 @@ aesloop:
DECL BX
JNE aesloop
- // 2 more scrambles to finish
+ // 3 more scrambles to finish
+ AESENC X4, X4
+ AESENC X5, X5
+ AESENC X6, X6
+ AESENC X7, X7
+
AESENC X4, X4
AESENC X5, X5
AESENC X6, X6