]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: save and restore CR for ppc64le
authorIan Lance Taylor <iant@golang.org>
Fri, 2 Jun 2017 22:56:35 +0000 (15:56 -0700)
committerIan Lance Taylor <iant@golang.org>
Mon, 5 Jun 2017 19:59:49 +0000 (19:59 +0000)
C code expects CR2, CR3, and CR4 to be preserved across function calls.
Preserve the entire CR register across function calls in
_rt0_ppc64le_linux_lib and crosscall2. The standard ppc64le call frame
uses 8(R1) as the place to save CR; emulate that.

It's hard to write a reliable test for this as it requires writing C
code that sets CR2, CR3, or CR4 across a call to a Go function.

Change-Id: If39e771a5b574602b848227312e83598fe74eab7
Reviewed-on: https://go-review.googlesource.com/44733
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
src/runtime/cgo/asm_ppc64x.s
src/runtime/rt0_linux_ppc64le.s

index dded1be3998d8e8b1b4e21bc9c9bef3b237a5905..1cf27ddc9615155f3b12cf2c76f2de0a7164f1c6 100644 (file)
@@ -16,6 +16,8 @@ TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
        // Start with standard C stack frame layout and linkage
        MOVD    LR, R0
        MOVD    R0, 16(R1)      // Save LR in caller's frame
+       MOVW    CR, R0          // Save CR in caller's frame
+       MOVD    R0, 8(R1)
        MOVD    R2, 24(R1)      // Save TOC in caller's frame
 
        BL      saveregs2<>(SB)
@@ -38,6 +40,8 @@ TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
        BL      restoreregs2<>(SB)
 
        MOVD    24(R1), R2
+       MOVD    8(R1), R0
+       MOVFL   R0, $0xff
        MOVD    16(R1), R0
        MOVD    R0, LR
        RET
index bcbc9c7b31c31fce1712190d2f48f8c9dc33c375..81b991349a2cf36dd8b281f2859bcd28676fa1a1 100644 (file)
@@ -8,6 +8,8 @@ TEXT _rt0_ppc64le_linux_lib(SB),NOSPLIT,$-8
        // Start with standard C stack frame layout and linkage.
        MOVD    LR, R0
        MOVD    R0, 16(R1) // Save LR in caller's frame.
+       MOVW    CR, R0     // Save CR in caller's frame
+       MOVD    R0, 8(R1)
        MOVD    R2, 24(R1) // Save TOC in caller's frame.
        MOVDU   R1, -320(R1) // Allocate frame.
        
@@ -120,6 +122,8 @@ done:
 
        ADD     $320, R1
        MOVD    24(R1), R2
+       MOVD    8(R1), R0
+       MOVFL   R0, $0xff
        MOVD    16(R1), R0
        MOVD    R0, LR
        RET