From 7d4cca07d2c6890fb39635aaa5b3b8d902bf2cbf Mon Sep 17 00:00:00 2001 From: Lynn Boger Date: Wed, 12 Apr 2017 14:22:16 -0400 Subject: cmd/asm: detect invalid DS form offsets for ppc64x While debugging a recent regression it was discovered that the assembler for ppc64x was not always generating the correct instruction for DS form loads and stores. When an instruction is DS form then the offset must be a multiple of 4, and if it isn't then bits outside the offset field were being incorrectly set resulting in unexpected and incorrect instructions. This change adds a check to determine when the opcode is DS form and then verifies that the offset is a multiple of 4 before generating the instruction, otherwise logs an error. This also changes a few asm files that were using unaligned offsets for DS form loads and stores. In the runtime package these were instructions intended to cause a crash so using aligned or unaligned offsets doesn't change that behavior. Change-Id: Ie3a7e1e65dcc9933b54de7a46a054da8459cb56f Reviewed-on: https://go-review.googlesource.com/40476 Reviewed-by: Michael Hudson-Doyle --- src/runtime/sys_linux_ppc64x.s | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/runtime/sys_linux_ppc64x.s') diff --git a/src/runtime/sys_linux_ppc64x.s b/src/runtime/sys_linux_ppc64x.s index b43bda1ef2..ef7dab21b7 100644 --- a/src/runtime/sys_linux_ppc64x.s +++ b/src/runtime/sys_linux_ppc64x.s @@ -189,7 +189,7 @@ TEXT runtime·rtsigprocmask(SB),NOSPLIT|NOFRAME,$0-28 MOVW size+24(FP), R6 SYSCALL $SYS_rt_sigprocmask BVC 2(PC) - MOVD R0, 0xf1(R0) // crash + MOVD R0, 0xf0(R0) // crash RET TEXT runtime·rt_sigaction(SB),NOSPLIT|NOFRAME,$0-36 @@ -273,7 +273,7 @@ TEXT runtime·munmap(SB),NOSPLIT|NOFRAME,$0 MOVD n+8(FP), R4 SYSCALL $SYS_munmap BVC 2(PC) - MOVD R0, 0xf3(R0) + MOVD R0, 0xf0(R0) RET TEXT runtime·madvise(SB),NOSPLIT|NOFRAME,$0 @@ -366,7 +366,7 @@ TEXT runtime·sigaltstack(SB),NOSPLIT|NOFRAME,$0 MOVD old+8(FP), R4 SYSCALL $SYS_sigaltstack BVC 2(PC) - MOVD R0, 0xf1(R0) // crash + MOVD R0, 0xf0(R0) // crash RET TEXT runtime·osyield(SB),NOSPLIT|NOFRAME,$0 -- cgit v1.3-5-g9baa