From 3b2e00f167f493ca1de7451310f1ce56f0b27fcb Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Thu, 30 Nov 2023 18:56:01 +0100 Subject: KVM: s390: use READ_ONCE() to read fpc register value Use READ_ONCE() to read a vcpu's floating point register value from the memory mapped area. This avoids that, depending on code generation, a different value is tested for validity than the one that is used, since user space can modify the area concurrently and the compiler is free to generate code that reads the value multiple times. Reviewed-by: Christian Borntraeger Reviewed-by: Claudio Imbrenda Signed-off-by: Heiko Carstens Signed-off-by: Alexander Gordeev --- arch/s390/kvm/kvm-s390.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/s390/kvm/kvm-s390.c') diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 16e32174807f..1a1af4db5afc 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -4962,7 +4962,7 @@ static void sync_regs(struct kvm_vcpu *vcpu) current->thread.fpu.regs = vcpu->run->s.regs.vrs; else current->thread.fpu.regs = vcpu->run->s.regs.fprs; - current->thread.fpu.fpc = vcpu->run->s.regs.fpc; + current->thread.fpu.fpc = READ_ONCE(vcpu->run->s.regs.fpc); if (test_fp_ctl(current->thread.fpu.fpc)) /* User space provided an invalid FPC, let's clear it */ current->thread.fpu.fpc = 0; -- cgit