Commit | Line | Data |
---|---|---|
a80313ff GS |
1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | /* | |
3 | * Code that needs to run below 2 GB. | |
4 | * | |
5 | * Copyright IBM Corp. 2019 | |
6 | */ | |
7 | ||
8 | #include <linux/linkage.h> | |
d09a307f | 9 | #include <asm/asm-extable.h> |
a80313ff GS |
10 | #include <asm/errno.h> |
11 | #include <asm/sigp.h> | |
12 | ||
c78d0c74 | 13 | .section .amode31.text,"ax" |
a80313ff GS |
14 | /* |
15 | * Simplified version of expoline thunk. The normal thunks can not be used here, | |
16 | * because they might be more than 2 GB away, and not reachable by the relative | |
17 | * branch. No comdat, exrl, etc. optimizations used here, because it only | |
18 | * affects a few functions that are not performance-relevant. | |
19 | */ | |
c78d0c74 | 20 | .macro BR_EX_AMODE31_r14 |
90c5515d | 21 | exrl 0,0f |
463f36c7 AE |
22 | j . |
23 | 0: br %r14 | |
a80313ff GS |
24 | .endm |
25 | ||
26 | /* | |
c78d0c74 | 27 | * int _diag14_amode31(unsigned long rx, unsigned long ry1, unsigned long subcode) |
a80313ff | 28 | */ |
ac0c06a1 | 29 | SYM_FUNC_START(_diag14_amode31) |
a80313ff GS |
30 | lgr %r1,%r2 |
31 | lgr %r2,%r3 | |
32 | lgr %r3,%r4 | |
33 | lhi %r5,-EIO | |
34 | sam31 | |
35 | diag %r1,%r2,0x14 | |
36 | .Ldiag14_ex: | |
37 | ipm %r5 | |
38 | srl %r5,28 | |
39 | .Ldiag14_fault: | |
40 | sam64 | |
41 | lgfr %r2,%r5 | |
c78d0c74 HC |
42 | BR_EX_AMODE31_r14 |
43 | EX_TABLE_AMODE31(.Ldiag14_ex, .Ldiag14_fault) | |
ac0c06a1 | 44 | SYM_FUNC_END(_diag14_amode31) |
a80313ff GS |
45 | |
46 | /* | |
c78d0c74 | 47 | * int _diag210_amode31(struct diag210 *addr) |
a80313ff | 48 | */ |
ac0c06a1 | 49 | SYM_FUNC_START(_diag210_amode31) |
a80313ff GS |
50 | lgr %r1,%r2 |
51 | lhi %r2,-1 | |
52 | sam31 | |
53 | diag %r1,%r0,0x210 | |
54 | .Ldiag210_ex: | |
55 | ipm %r2 | |
56 | srl %r2,28 | |
57 | .Ldiag210_fault: | |
58 | sam64 | |
59 | lgfr %r2,%r2 | |
c78d0c74 HC |
60 | BR_EX_AMODE31_r14 |
61 | EX_TABLE_AMODE31(.Ldiag210_ex, .Ldiag210_fault) | |
ac0c06a1 | 62 | SYM_FUNC_END(_diag210_amode31) |
a80313ff | 63 | |
fbaee746 SS |
64 | /* |
65 | * int diag8c(struct diag8c *addr, struct ccw_dev_id *devno, size_t len) | |
66 | */ | |
ac0c06a1 | 67 | SYM_FUNC_START(_diag8c_amode31) |
fbaee746 SS |
68 | llgf %r3,0(%r3) |
69 | sam31 | |
70 | diag %r2,%r4,0x8c | |
71 | .Ldiag8c_ex: | |
72 | sam64 | |
73 | lgfr %r2,%r3 | |
74 | BR_EX_AMODE31_r14 | |
75 | EX_TABLE_AMODE31(.Ldiag8c_ex, .Ldiag8c_ex) | |
ac0c06a1 | 76 | SYM_FUNC_END(_diag8c_amode31) |
a80313ff | 77 | /* |
c78d0c74 | 78 | * int _diag26c_amode31(void *req, void *resp, enum diag26c_sc subcode) |
a80313ff | 79 | */ |
ac0c06a1 | 80 | SYM_FUNC_START(_diag26c_amode31) |
a80313ff GS |
81 | lghi %r5,-EOPNOTSUPP |
82 | sam31 | |
83 | diag %r2,%r4,0x26c | |
84 | .Ldiag26c_ex: | |
85 | sam64 | |
86 | lgfr %r2,%r5 | |
c78d0c74 HC |
87 | BR_EX_AMODE31_r14 |
88 | EX_TABLE_AMODE31(.Ldiag26c_ex, .Ldiag26c_ex) | |
ac0c06a1 | 89 | SYM_FUNC_END(_diag26c_amode31) |
a80313ff GS |
90 | |
91 | /* | |
e98eda92 | 92 | * void _diag0c_amode31(unsigned long rx) |
a80313ff | 93 | */ |
ac0c06a1 | 94 | SYM_FUNC_START(_diag0c_amode31) |
a80313ff GS |
95 | sam31 |
96 | diag %r2,%r2,0x0c | |
97 | sam64 | |
c78d0c74 | 98 | BR_EX_AMODE31_r14 |
ac0c06a1 | 99 | SYM_FUNC_END(_diag0c_amode31) |
a80313ff | 100 | |
a80313ff | 101 | /* |
c78d0c74 | 102 | * void _diag308_reset_amode31(void) |
a80313ff GS |
103 | * |
104 | * Calls diag 308 subcode 1 and continues execution | |
105 | */ | |
ac0c06a1 HC |
106 | SYM_FUNC_START(_diag308_reset_amode31) |
107 | larl %r4,ctlregs # Save control registers | |
a80313ff GS |
108 | stctg %c0,%c15,0(%r4) |
109 | lg %r2,0(%r4) # Disable lowcore protection | |
110 | nilh %r2,0xefff | |
ac0c06a1 | 111 | larl %r4,ctlreg0 |
a80313ff GS |
112 | stg %r2,0(%r4) |
113 | lctlg %c0,%c0,0(%r4) | |
ac0c06a1 | 114 | larl %r4,fpctl # Floating point control register |
a80313ff | 115 | stfpc 0(%r4) |
ac0c06a1 | 116 | larl %r4,prefix # Save prefix register |
a80313ff | 117 | stpx 0(%r4) |
ac0c06a1 | 118 | larl %r4,prefix_zero # Set prefix register to 0 |
a80313ff | 119 | spx 0(%r4) |
ac0c06a1 | 120 | larl %r4,continue_psw # Save PSW flags |
a80313ff GS |
121 | epsw %r2,%r3 |
122 | stm %r2,%r3,0(%r4) | |
2879048c | 123 | larl %r4,.Lrestart_part2 # Setup restart PSW at absolute 0 |
ac0c06a1 | 124 | larl %r3,restart_diag308_psw |
a80313ff GS |
125 | og %r4,0(%r3) # Save PSW |
126 | lghi %r3,0 | |
127 | sturg %r4,%r3 # Use sturg, because of large pages | |
128 | lghi %r1,1 | |
129 | lghi %r0,0 | |
130 | diag %r0,%r1,0x308 | |
2879048c | 131 | .Lrestart_part2: |
a80313ff GS |
132 | lhi %r0,0 # Load r0 with zero |
133 | lhi %r1,2 # Use mode 2 = ESAME (dump) | |
134 | sigp %r1,%r0,SIGP_SET_ARCHITECTURE # Switch to ESAME mode | |
135 | sam64 # Switch to 64 bit addressing mode | |
ac0c06a1 | 136 | larl %r4,ctlregs # Restore control registers |
a80313ff | 137 | lctlg %c0,%c15,0(%r4) |
ac0c06a1 | 138 | larl %r4,fpctl # Restore floating point ctl register |
a80313ff | 139 | lfpc 0(%r4) |
ac0c06a1 | 140 | larl %r4,prefix # Restore prefix register |
a80313ff | 141 | spx 0(%r4) |
ac0c06a1 | 142 | larl %r4,continue_psw # Restore PSW flags |
7accd1f8 AE |
143 | larl %r2,.Lcontinue |
144 | stg %r2,8(%r4) | |
a80313ff GS |
145 | lpswe 0(%r4) |
146 | .Lcontinue: | |
c78d0c74 | 147 | BR_EX_AMODE31_r14 |
ac0c06a1 | 148 | SYM_FUNC_END(_diag308_reset_amode31) |
a80313ff | 149 | |
c78d0c74 | 150 | .section .amode31.data,"aw",@progbits |
ac0c06a1 HC |
151 | .balign 8 |
152 | SYM_DATA_LOCAL(restart_diag308_psw, .long 0x00080000,0x80000000) | |
153 | SYM_DATA_LOCAL(continue_psw, .quad 0,0) | |
154 | SYM_DATA_LOCAL(ctlreg0, .quad 0) | |
155 | SYM_DATA_LOCAL(ctlregs, .fill 16,8,0) | |
156 | SYM_DATA_LOCAL(fpctl, .long 0) | |
157 | SYM_DATA_LOCAL(prefix, .long 0) | |
158 | SYM_DATA_LOCAL(prefix_zero, .long 0) |