kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL 0/1] KVM: s390: Fix potential crash in preemptible kernels
@ 2021-04-17  7:28 Christian Borntraeger
  2021-04-17  7:28 ` [GIT PULL 1/1] KVM: s390: fix guarded storage control register handling Christian Borntraeger
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Borntraeger @ 2021-04-17  7:28 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: KVM, Janosch Frank, David Hildenbrand, Cornelia Huck, linux-s390,
	Christian Borntraeger

Paolo,

a 2nd batch for kvm/next (no need to hurry this into 5.12) with a fix
for preemptible kernels.

The following changes since commit c3171e94cc1cdcc3229565244112e869f052b8d9:

  KVM: s390: VSIE: fix MVPG handling for prefixing and MSO (2021-03-24 10:31:55 +0100)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git  tags/kvm-s390-next-5.13-2

for you to fetch changes up to 44bada28219031f9e8e86b84460606efa57b871e:

  KVM: s390: fix guarded storage control register handling (2021-04-15 15:35:38 +0200)

----------------------------------------------------------------
KVM: s390: Fix potential crash in preemptible kernels

There is a potential race for preemptible kernels, where
the host kernel would get a fault when it is preempted as
the wrong point in time.

----------------------------------------------------------------
Heiko Carstens (1):
      KVM: s390: fix guarded storage control register handling

 arch/s390/kvm/kvm-s390.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [GIT PULL 1/1] KVM: s390: fix guarded storage control register handling
  2021-04-17  7:28 [GIT PULL 0/1] KVM: s390: Fix potential crash in preemptible kernels Christian Borntraeger
@ 2021-04-17  7:28 ` Christian Borntraeger
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Borntraeger @ 2021-04-17  7:28 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: KVM, Janosch Frank, David Hildenbrand, Cornelia Huck, linux-s390,
	Christian Borntraeger, Heiko Carstens

From: Heiko Carstens <hca@linux.ibm.com>

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: 4e0b1ab72b8a ("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>
---
 arch/s390/kvm/kvm-s390.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index cfe720d16a6a..95ef9193f12e 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -4313,16 +4313,16 @@ static void store_regs_fmt2(struct kvm_vcpu *vcpu)
 	kvm_run->s.regs.bpbc = (vcpu->arch.sie_block->fpf & FPF_BPBC) == FPF_BPBC;
 	kvm_run->s.regs.diag318 = vcpu->arch.diag318_info.val;
 	if (MACHINE_HAS_GS) {
+		preempt_disable();
 		__ctl_set_bit(2, 4);
 		if (vcpu->arch.gs_enabled)
 			save_gs_cb(current->thread.gs_cb);
-		preempt_disable();
 		current->thread.gs_cb = vcpu->arch.host_gscb;
 		restore_gs_cb(vcpu->arch.host_gscb);
-		preempt_enable();
 		if (!vcpu->arch.host_gscb)
 			__ctl_clear_bit(2, 4);
 		vcpu->arch.host_gscb = NULL;
+		preempt_enable();
 	}
 	/* SIE will save etoken directly into SDNX and therefore kvm_run */
 }
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-17  7:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-17  7:28 [GIT PULL 0/1] KVM: s390: Fix potential crash in preemptible kernels Christian Borntraeger
2021-04-17  7:28 ` [GIT PULL 1/1] KVM: s390: fix guarded storage control register handling Christian Borntraeger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).