Skip to content

Commit d80aa84

Browse files
borntraegergregkh
authored andcommitted
s390/kvm: do not rely on the ILC on kvm host protection fauls
commit c0e7bb38c07cbd8269549ee0a0566021a3c729de upstream. For most cases a protection exception in the host (e.g. copy on write or dirty tracking) on the sie instruction will indicate an instruction length of 4. Turns out that there are some corner cases (e.g. runtime instrumentation) where this is not necessarily true and the ILC is unpredictable. Let's replace our 4 byte rewind_pad with 3 byte nops to prepare for all possible ILCs. Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent afb415f commit d80aa84

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

arch/s390/kernel/entry.S

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,17 @@ ENTRY(sie64a)
229229
lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
230230
.Lsie_done:
231231
# some program checks are suppressing. C code (e.g. do_protection_exception)
232-
# will rewind the PSW by the ILC, which is 4 bytes in case of SIE. Other
233-
# instructions between sie64a and .Lsie_done should not cause program
234-
# interrupts. So lets use a nop (47 00 00 00) as a landing pad.
232+
# will rewind the PSW by the ILC, which is often 4 bytes in case of SIE. There
233+
# are some corner cases (e.g. runtime instrumentation) where ILC is unpredictable.
234+
# Other instructions between sie64a and .Lsie_done should not cause program
235+
# interrupts. So lets use 3 nops as a landing pad for all possible rewinds.
235236
# See also .Lcleanup_sie
236-
.Lrewind_pad:
237-
nop 0
237+
.Lrewind_pad6:
238+
nopr 7
239+
.Lrewind_pad4:
240+
nopr 7
241+
.Lrewind_pad2:
242+
nopr 7
238243
.globl sie_exit
239244
sie_exit:
240245
lg %r14,__SF_EMPTY+8(%r15) # load guest register save area
@@ -247,7 +252,9 @@ sie_exit:
247252
stg %r14,__SF_EMPTY+16(%r15) # set exit reason code
248253
j sie_exit
249254

250-
EX_TABLE(.Lrewind_pad,.Lsie_fault)
255+
EX_TABLE(.Lrewind_pad6,.Lsie_fault)
256+
EX_TABLE(.Lrewind_pad4,.Lsie_fault)
257+
EX_TABLE(.Lrewind_pad2,.Lsie_fault)
251258
EX_TABLE(sie_exit,.Lsie_fault)
252259
#endif
253260

0 commit comments

Comments
 (0)