mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 11:26:02 +09:00
KVM: s390: fix guarded storage control register handling
commit44bada2821upstream. 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:4e0b1ab72b("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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
34a6d1d57c
commit
9ea2c4fd1a
@@ -3980,16 +3980,16 @@ static void store_regs(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
|
|||||||
current->thread.fpu.fpc = vcpu->arch.host_fpregs.fpc;
|
current->thread.fpu.fpc = vcpu->arch.host_fpregs.fpc;
|
||||||
current->thread.fpu.regs = vcpu->arch.host_fpregs.regs;
|
current->thread.fpu.regs = vcpu->arch.host_fpregs.regs;
|
||||||
if (MACHINE_HAS_GS) {
|
if (MACHINE_HAS_GS) {
|
||||||
|
preempt_disable();
|
||||||
__ctl_set_bit(2, 4);
|
__ctl_set_bit(2, 4);
|
||||||
if (vcpu->arch.gs_enabled)
|
if (vcpu->arch.gs_enabled)
|
||||||
save_gs_cb(current->thread.gs_cb);
|
save_gs_cb(current->thread.gs_cb);
|
||||||
preempt_disable();
|
|
||||||
current->thread.gs_cb = vcpu->arch.host_gscb;
|
current->thread.gs_cb = vcpu->arch.host_gscb;
|
||||||
restore_gs_cb(vcpu->arch.host_gscb);
|
restore_gs_cb(vcpu->arch.host_gscb);
|
||||||
preempt_enable();
|
|
||||||
if (!vcpu->arch.host_gscb)
|
if (!vcpu->arch.host_gscb)
|
||||||
__ctl_clear_bit(2, 4);
|
__ctl_clear_bit(2, 4);
|
||||||
vcpu->arch.host_gscb = NULL;
|
vcpu->arch.host_gscb = NULL;
|
||||||
|
preempt_enable();
|
||||||
}
|
}
|
||||||
/* SIE will save etoken directly into SDNX and therefore kvm_run */
|
/* SIE will save etoken directly into SDNX and therefore kvm_run */
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user