Skip to content

Commit 742aed0

Browse files
hcahcaAlexander Gordeev
authored andcommitted
s390/nmi: move storage error checking back to C, enter with DAT on
Checking for storage errors in machine check entry code was done in order to handle also storage errors on kernel page tables. However this is extremely unlikely and some basic assumptions what works on machine check entry are necessary anyway. In order to simplify machine check handling delay checking for storage errors to C code. With this also change the machine check new PSW to have DAT on, which simplifies the entry code even further. Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
1 parent 506faa5 commit 742aed0

3 files changed

Lines changed: 21 additions & 32 deletions

File tree

arch/s390/kernel/entry.S

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -122,24 +122,6 @@ _LPP_OFFSET = __LC_LPP
122122
"jnz .+8; .insn rrf,0xb2e80000,0,0,13,0", 82
123123
.endm
124124

125-
/*
126-
* The CHKSTG macro jumps to the provided label in case the
127-
* machine check interruption code reports one of unrecoverable
128-
* storage errors:
129-
* - Storage error uncorrected
130-
* - Storage key error uncorrected
131-
* - Storage degradation with Failing-storage-address validity
132-
*/
133-
.macro CHKSTG errlabel
134-
TSTMSK __LC_MCCK_CODE,(MCCK_CODE_STG_ERROR|MCCK_CODE_STG_KEY_ERROR)
135-
jnz \errlabel
136-
TSTMSK __LC_MCCK_CODE,MCCK_CODE_STG_DEGRAD
137-
jz .Loklabel\@
138-
TSTMSK __LC_MCCK_CODE,MCCK_CODE_STG_FAIL_ADDR
139-
jnz \errlabel
140-
.Loklabel\@:
141-
.endm
142-
143125
#if IS_ENABLED(CONFIG_KVM)
144126
/*
145127
* The OUTSIDE macro jumps to the provided label in case the value
@@ -546,26 +528,18 @@ ENTRY(mcck_int_handler)
546528
3: TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_MWP_VALID
547529
jno .Lmcck_panic
548530
tmhh %r8,0x0001 # interrupting from user ?
549-
jnz 6f
531+
jnz .Lmcck_user
550532
TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_IA_VALID
551533
jno .Lmcck_panic
552534
#if IS_ENABLED(CONFIG_KVM)
553-
OUTSIDE %r9,.Lsie_gmap,.Lsie_done,6f
535+
OUTSIDE %r9,.Lsie_gmap,.Lsie_done,.Lmcck_stack
554536
OUTSIDE %r9,.Lsie_entry,.Lsie_leave,4f
555537
oi __LC_CPU_FLAGS+7, _CIF_MCCK_GUEST
556-
j 5f
557-
4: CHKSTG .Lmcck_panic
558-
5: larl %r14,.Lstosm_tmp
559-
stosm 0(%r14),0x04 # turn dat on, keep irqs off
560-
BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
538+
4: BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
561539
SIEEXIT
562540
j .Lmcck_stack
563541
#endif
564-
6: CHKSTG .Lmcck_panic
565-
larl %r14,.Lstosm_tmp
566-
stosm 0(%r14),0x04 # turn dat on, keep irqs off
567-
tmhh %r8,0x0001 # interrupting from user ?
568-
jz .Lmcck_stack
542+
.Lmcck_user:
569543
BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
570544
.Lmcck_stack:
571545
lg %r15,__LC_MCCK_STACK

arch/s390/kernel/nmi.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,21 @@ int notrace s390_do_machine_check(struct pt_regs *regs)
487487
mcck->stp_queue |= stp_island_check();
488488
mcck_pending = 1;
489489
}
490-
490+
/*
491+
* Reinject storage related machine checks into the guest if they
492+
* happen when the guest is running.
493+
*/
494+
if (!test_cpu_flag(CIF_MCCK_GUEST)) {
495+
/* Storage error uncorrected */
496+
if (mci.se)
497+
s390_handle_damage();
498+
/* Storage key-error uncorrected */
499+
if (mci.ke)
500+
s390_handle_damage();
501+
/* Storage degradation */
502+
if (mci.ds && mci.fa)
503+
s390_handle_damage();
504+
}
491505
if (mci.cp) {
492506
/* Channel report word pending */
493507
mcck->channel_report = 1;

arch/s390/kernel/setup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ static void __init setup_lowcore_dat_off(void)
437437
lc->svc_new_psw.addr = (unsigned long) system_call;
438438
lc->program_new_psw.mask = int_psw_mask | PSW_MASK_MCHECK;
439439
lc->program_new_psw.addr = (unsigned long) pgm_check_handler;
440-
lc->mcck_new_psw.mask = PSW_KERNEL_BITS;
440+
lc->mcck_new_psw.mask = int_psw_mask;
441441
lc->mcck_new_psw.addr = (unsigned long) mcck_int_handler;
442442
lc->io_new_psw.mask = int_psw_mask | PSW_MASK_MCHECK;
443443
lc->io_new_psw.addr = (unsigned long) io_int_handler;
@@ -512,6 +512,7 @@ static void __init setup_lowcore_dat_on(void)
512512
S390_lowcore.external_new_psw.mask |= PSW_MASK_DAT;
513513
S390_lowcore.svc_new_psw.mask |= PSW_MASK_DAT;
514514
S390_lowcore.program_new_psw.mask |= PSW_MASK_DAT;
515+
S390_lowcore.mcck_new_psw.mask |= PSW_MASK_DAT;
515516
S390_lowcore.io_new_psw.mask |= PSW_MASK_DAT;
516517
__ctl_set_bit(0, 28);
517518
__ctl_store(S390_lowcore.cregs_save_area, 0, 15);

0 commit comments

Comments
 (0)