Skip to content

Commit be4ed1a

Browse files
hcahcagregkh
authored andcommitted
KVM: s390: fix guarded storage control register handling
commit 44bada2 upstream. store_regs_fmt2() has an ordering problem: first the guarded storage facility is enabled on the local cpu, then preemption disabled, and then the STGSC (store guarded storage controls) instruction is executed. If the process gets scheduled away between enabling the guarded storage facility and before preemption is disabled, this might lead to a special operation exception and therefore kernel crash as soon as the process is scheduled back and the STGSC instruction is executed. Fixes: 4e0b1ab ("KVM: s390: gs support for kvm guests") Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Reviewed-by: David Hildenbrand <david@redhat.com> Reviewed-by: Janosch Frank <frankja@linux.ibm.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Cc: <stable@vger.kernel.org> # 4.12 Link: https://lore.kernel.org/r/20210415080127.1061275-1-hca@linux.ibm.com Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2705bc3 commit be4ed1a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎arch/s390/kvm/kvm-s390.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4308,16 +4308,16 @@ static void store_regs_fmt2(struct kvm_vcpu *vcpu)
43084308
kvm_run->s.regs.bpbc = (vcpu->arch.sie_block->fpf & FPF_BPBC) == FPF_BPBC;
43094309
kvm_run->s.regs.diag318 = vcpu->arch.diag318_info.val;
43104310
if (MACHINE_HAS_GS) {
4311+
preempt_disable();
43114312
__ctl_set_bit(2, 4);
43124313
if (vcpu->arch.gs_enabled)
43134314
save_gs_cb(current->thread.gs_cb);
4314-
preempt_disable();
43154315
current->thread.gs_cb = vcpu->arch.host_gscb;
43164316
restore_gs_cb(vcpu->arch.host_gscb);
4317-
preempt_enable();
43184317
if (!vcpu->arch.host_gscb)
43194318
__ctl_clear_bit(2, 4);
43204319
vcpu->arch.host_gscb = NULL;
4320+
preempt_enable();
43214321
}
43224322
/* SIE will save etoken directly into SDNX and therefore kvm_run */
43234323
}

0 commit comments

Comments
 (0)