summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorAndrew Jones <drjones@redhat.com>2020-08-04 19:06:00 +0200
committerMarc Zyngier <maz@kernel.org>2020-08-21 14:04:14 +0100
commit2dbd780e34ac53e79c6c359ce12b89ed665ef562 (patch)
tree6cf98418dfa7d1f93a3888324920e8a68b56259d /arch
parent38480df564cc68f081bb38998927d164b9010995 (diff)
KVM: arm64: pvtime: Fix potential loss of stolen time
We should only check current->sched_info.run_delay once when updating stolen time. Otherwise there's a chance there could be a change between checks that we miss (preemption disabling comes after vcpu request checks). Signed-off-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20200804170604.42662-3-drjones@redhat.com
Diffstat (limited to 'arch')
-rw-r--r--arch/arm64/kvm/pvtime.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/arm64/kvm/pvtime.c b/arch/arm64/kvm/pvtime.c
index c3ef4ebd6846..95f9580275b1 100644
--- a/arch/arm64/kvm/pvtime.c
+++ b/arch/arm64/kvm/pvtime.c
@@ -13,6 +13,7 @@
void kvm_update_stolen_time(struct kvm_vcpu *vcpu)
{
struct kvm *kvm = vcpu->kvm;
+ u64 last_steal = vcpu->arch.steal.last_steal;
u64 steal;
__le64 steal_le;
u64 offset;
@@ -24,8 +25,8 @@ void kvm_update_stolen_time(struct kvm_vcpu *vcpu)
/* Let's do the local bookkeeping */
steal = vcpu->arch.steal.steal;
- steal += current->sched_info.run_delay - vcpu->arch.steal.last_steal;
- vcpu->arch.steal.last_steal = current->sched_info.run_delay;
+ vcpu->arch.steal.last_steal = READ_ONCE(current->sched_info.run_delay);
+ steal += vcpu->arch.steal.last_steal - last_steal;
vcpu->arch.steal.steal = steal;
steal_le = cpu_to_le64(steal);