master
s 63 lines 1.96 KB
Raw
1 /*
2 * Test s390x-softmmu precise self-modifying code handling.
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 .org 0x8e
7 program_interruption_code:
8 .org 0x150
9 program_old_psw:
10 .org 0x1D0 /* program new PSW */
11 .quad 0x180000000,pgm /* 64-bit mode */
12 .org 0x200 /* lowcore padding */
13 .globl _start
14 _start:
15 lctlg %c0,%c0,c0
16 lghi %r0,15
17
18 /* Test 1: replace sgr with agr. */
19 lghi %r1,21
20 vl %v0,patch1
21 jg 1f /* start a new TB */
22 0:
23 .org . + 6 /* pad patched code to 16 bytes */
24 1:
25 vstl %v0,%r0,0b /* start writing before TB */
26 sgr %r1,%r1 /* this becomes `agr %r1,%r1` */
27 cgijne %r1,42,failure
28
29 /* Test 2: replace agr with division by zero. */
30 vl %v0,patch2
31 jg 1f /* start a new TB */
32 0:
33 .org . + 6 /* pad patched code to 16 bytes */
34 1:
35 vstl %v0,%r0,0b /* start writing before TB */
36 sgr %r1,%r1 /* this becomes `d %r0,zero` */
37 failure:
38 lpswe failure_psw
39
40 pgm:
41 chhsi program_interruption_code,0x9 /* divide exception? */
42 jne failure
43 clc program_old_psw(16),expected_old_psw2 /* correct old PSW? */
44 jne failure
45 lpswe success_psw
46
47 patch1:
48 .fill 12 /* replaces padding and stpq */
49 agr %r1,%r1 /* replaces sgr */
50 patch2:
51 .fill 12 /* replaces padding and stpq */
52 d %r0,zero /* replaces sgr */
53 zero:
54 .long 0
55 expected_old_psw2:
56 .quad 0x200180000000,failure /* cc is from addition */
57 .align 8
58 c0:
59 .quad 0x60000 /* AFP, VX */
60 success_psw:
61 .quad 0x2000000000000,0xfff /* see is_special_wait_psw() */
62 failure_psw:
63 .quad 0x2000000000000,0 /* disabled wait */