Skip to content

Commit d013905

Browse files
hcahcafrankjaa
authored andcommitted
KVM: s390: Enable and disable interrupts in entry code
Move enabling and disabling of interrupts around the SIE instruction to entry code. Enabling interrupts only after the __TI_sie flag has been set guarantees that the SIE instruction is not executed if an interrupt happens between enabling interrupts and the execution of the SIE instruction. Interrupt handlers and machine check handler forward the PSW to the sie_exit label in such cases. This is a prerequisite for VIRT_XFER_TO_GUEST_WORK to prevent that guest context is entered when e.g. a scheduler IPI, indicating that a reschedule is required, happens right before the SIE instruction, which could lead to long delays. Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Tested-by: Andrew Donnellan <ajd@linux.ibm.com> Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> Reviewed-by: Janosch Frank <frankja@linux.ibm.com> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
1 parent c067847 commit d013905

4 files changed

Lines changed: 4 additions & 5 deletions

File tree

arch/s390/include/asm/stacktrace.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ struct stack_frame {
6666
unsigned long sie_flags;
6767
unsigned long sie_control_block_phys;
6868
unsigned long sie_guest_asce;
69+
unsigned long sie_irq;
6970
};
7071
};
7172
unsigned long gprs[10];

arch/s390/kernel/asm-offsets.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ int main(void)
6464
OFFSET(__SF_SIE_FLAGS, stack_frame, sie_flags);
6565
OFFSET(__SF_SIE_CONTROL_PHYS, stack_frame, sie_control_block_phys);
6666
OFFSET(__SF_SIE_GUEST_ASCE, stack_frame, sie_guest_asce);
67+
OFFSET(__SF_SIE_IRQ, stack_frame, sie_irq);
6768
DEFINE(STACK_FRAME_OVERHEAD, sizeof(struct stack_frame));
6869
BLANK();
6970
OFFSET(__SFUSER_BACKCHAIN, stack_frame_user, back_chain);

arch/s390/kernel/entry.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ SYM_FUNC_START(__sie64a)
189189
mvc __SF_SIE_FLAGS(8,%r15),__TI_flags(%r14) # copy thread flags
190190
lmg %r0,%r13,0(%r4) # load guest gprs 0-13
191191
mvi __TI_sie(%r14),1
192+
stosm __SF_SIE_IRQ(%r15),0x03 # enable interrupts
192193
lctlg %c1,%c1,__SF_SIE_GUEST_ASCE(%r15) # load primary asce
193194
lg %r14,__SF_SIE_CONTROL(%r15) # get control block pointer
194195
oi __SIE_PROG0C+3(%r14),1 # we are going into SIE now
@@ -212,6 +213,7 @@ SYM_FUNC_START(__sie64a)
212213
lg %r14,__LC_CURRENT(%r14)
213214
mvi __TI_sie(%r14),0
214215
SYM_INNER_LABEL(sie_exit, SYM_L_GLOBAL)
216+
stnsm __SF_SIE_IRQ(%r15),0xfc # disable interrupts
215217
lg %r14,__SF_SIE_SAVEAREA(%r15) # load guest register save area
216218
stmg %r0,%r13,0(%r14) # save guest gprs 0-13
217219
xgr %r0,%r0 # clear guest registers to

arch/s390/kvm/kvm-s390.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4962,13 +4962,8 @@ int noinstr kvm_s390_enter_exit_sie(struct kvm_s390_sie_block *scb,
49624962
* The guest_state_{enter,exit}_irqoff() functions inform lockdep and
49634963
* tracing that entry to the guest will enable host IRQs, and exit from
49644964
* the guest will disable host IRQs.
4965-
*
4966-
* We must not use lockdep/tracing/RCU in this critical section, so we
4967-
* use the low-level arch_local_irq_*() helpers to enable/disable IRQs.
49684965
*/
4969-
arch_local_irq_enable();
49704966
ret = sie64a(scb, gprs, gasce);
4971-
arch_local_irq_disable();
49724967

49734968
guest_state_exit_irqoff();
49744969

0 commit comments

Comments
 (0)