From 3e77efc7204407c5c8882bec42fdcaa88ef40a9b Mon Sep 17 00:00:00 2001 From: Srinivas Pokala Date: Wed, 14 Dec 2022 06:31:50 +0100 Subject: [PATCH] cmd/internal/obj/s390x, runtime: fix breakpoint in s390x 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 TryBot-Result: Gopher Robot Reviewed-by: Cherry Mui Run-TryBot: Keith Randall Reviewed-by: Keith Randall --- src/cmd/asm/internal/asm/testdata/s390x.s | 1 + src/cmd/internal/obj/s390x/a.out.go | 3 +++ src/cmd/internal/obj/s390x/anames.go | 1 + src/cmd/internal/obj/s390x/asmz.go | 7 +++++++ src/runtime/asm_s390x.s | 2 +- 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/cmd/asm/internal/asm/testdata/s390x.s b/src/cmd/asm/internal/asm/testdata/s390x.s index 7c5d26be33..78ccb96fc1 100644 --- a/src/cmd/asm/internal/asm/testdata/s390x.s +++ b/src/cmd/asm/internal/asm/testdata/s390x.s @@ -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 diff --git a/src/cmd/internal/obj/s390x/a.out.go b/src/cmd/internal/obj/s390x/a.out.go index c1bda1fced..cdfb6ddff3 100644 --- a/src/cmd/internal/obj/s390x/a.out.go +++ b/src/cmd/internal/obj/s390x/a.out.go @@ -994,6 +994,9 @@ const ( AWORD ADWORD + // Breakpoint + ABRRK + // end marker ALAST diff --git a/src/cmd/internal/obj/s390x/anames.go b/src/cmd/internal/obj/s390x/anames.go index 8b2a76b2c9..3af15a504c 100644 --- a/src/cmd/internal/obj/s390x/anames.go +++ b/src/cmd/internal/obj/s390x/anames.go @@ -716,5 +716,6 @@ var Anames = []string{ "BYTE", "WORD", "DWORD", + "BRRK", "LAST", } diff --git a/src/cmd/internal/obj/s390x/asmz.go b/src/cmd/internal/obj/s390x/asmz.go index d8a36c4e9c..d9f76061ef 100644 --- a/src/cmd/internal/obj/s390x/asmz.go +++ b/src/cmd/internal/obj/s390x/asmz.go @@ -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 { diff --git a/src/runtime/asm_s390x.s b/src/runtime/asm_s390x.s index 334e1aa909..96b20f43a8 100644 --- a/src/runtime/asm_s390x.s +++ b/src/runtime/asm_s390x.s @@ -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 -- 2.48.1