]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/s390x, runtime: fix breakpoint in s390x
authorSrinivas Pokala <Pokala.Srinivas@ibm.com>
Wed, 14 Dec 2022 05:31:50 +0000 (06:31 +0100)
committerKeith Randall <khr@golang.org>
Fri, 20 Jan 2023 05:00:12 +0000 (05:00 +0000)
Currently runtime.Breakpoint generates SIGSEGV in s390x.
The solution to this is add new asm instruction BRRK of
type FORMAT_E for the breakpoint exception.

Fixes #52103

Change-Id: I8358a56e428849a5d28d5ade141e1d7310bee084
Reviewed-on: https://go-review.googlesource.com/c/go/+/457456
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
src/cmd/asm/internal/asm/testdata/s390x.s
src/cmd/internal/obj/s390x/a.out.go
src/cmd/internal/obj/s390x/anames.go
src/cmd/internal/obj/s390x/asmz.go
src/runtime/asm_s390x.s

index 7c5d26be33f8386a11a98d96cfbf952cc2399692..78ccb96fc1a0cf611603d8b6512e281c817e8fce 100644 (file)
@@ -410,6 +410,7 @@ TEXT main·foo(SB),DUPOK|NOSPLIT,$16-0 // TEXT main.foo(SB), DUPOK|NOSPLIT, $16-
        TCDB    F15, $4095             // edf00fff0011
 
        UNDEF                          // 00000000
+       BRRK                           // 0001
        NOPH                           // 0700
 
        SYNC                           // 07e0
index c1bda1fced3e5c9790996a87bee5d223771c39ee..cdfb6ddff37fd2b1ad33aeacc74ebb459d03fe50 100644 (file)
@@ -994,6 +994,9 @@ const (
        AWORD
        ADWORD
 
+       // Breakpoint
+       ABRRK
+
        // end marker
        ALAST
 
index 8b2a76b2c9aab937e3c0e62c218d7d28424a0759..3af15a504c08e0af6fb70c4a09a4494de391c982 100644 (file)
@@ -716,5 +716,6 @@ var Anames = []string{
        "BYTE",
        "WORD",
        "DWORD",
+       "BRRK",
        "LAST",
 }
index d8a36c4e9cf6c1c50b1a469b6aca9d74ec720ac6..d9f76061ef47bfd197b4af4722f6147c6263f9d8 100644 (file)
@@ -333,6 +333,9 @@ var optab = []Optab{
        // undefined (deliberate illegal instruction)
        {i: 78, as: obj.AUNDEF},
 
+       // Break point instruction(0x0001 opcode)
+       {i: 73, as: ABRRK},
+
        // 2 byte no-operation
        {i: 66, as: ANOPH},
 
@@ -2470,6 +2473,7 @@ const (
        op_XSCH    uint32 = 0xB276 // FORMAT_S          CANCEL SUBCHANNEL
        op_XY      uint32 = 0xE357 // FORMAT_RXY1       EXCLUSIVE OR (32)
        op_ZAP     uint32 = 0xF800 // FORMAT_SS2        ZERO AND ADD
+       op_BRRK    uint32 = 0x0001 // FORMAT_E          BREAKPOINT
 
        // added in z13
        op_CXPT   uint32 = 0xEDAF //    RSL-b   CONVERT FROM PACKED (to extended DFP)
@@ -3605,6 +3609,9 @@ func (c *ctxtz) asmout(p *obj.Prog, asm *[]byte) {
                        zSIL(opcode, uint32(r), uint32(d), uint32(v), asm)
                }
 
+       case 73: //Illegal opcode with SIGTRAP Exception
+               zE(op_BRRK, asm)
+
        case 74: // mov reg addr (including relocation)
                i2 := c.regoff(&p.To)
                switch p.As {
index 334e1aa909d3ef7a554cd479aef99cdf36853560..96b20f43a81bc2e5a6b92394a09307c091b51aad 100644 (file)
@@ -163,7 +163,7 @@ DATA        runtime·mainPC+0(SB)/8,$runtime·main(SB)
 GLOBL  runtime·mainPC(SB),RODATA,$8
 
 TEXT runtime·breakpoint(SB),NOSPLIT|NOFRAME,$0-0
-       MOVD    $0, 2(R0)
+       BRRK
        RET
 
 TEXT runtime·asminit(SB),NOSPLIT|NOFRAME,$0-0