Skip to contentSkip to conversation

ARM: KVM: fix unbalanced get_cpu() in access_dcsw

PATCH New Marc Zyngier 3 participants 4 messages Apr 12, 2013 – Apr 15, 2013 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: KVM: fix unbalanced get_cpu() in access_dcsw

In the very unlikely event where a guest would be foolish enough to *read* from a write-only cache maintainance register, we end up with preemption disabled, due to a misplaced get_cpu().

Just move the "is_write" test outside of the critical section.

---
 arch/arm/kvm/coproc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/kvm/coproc.c +2 -2
index 94eee8b..8eea97b 100644
@@ -79,11 +79,11 @@ static bool access_dcsw(struct kvm_vcpu *vcpu,
 	unsigned long val;
 	int cpu;
 
-	cpu = get_cpu();
-
 	if (!p->is_write)
 		return read_from_write_only(vcpu, p);
 
+	cpu = get_cpu();
+
 	cpumask_setall(&vcpu->arch.require_dcache_flush);
 	cpumask_clear_cpu(cpu, &vcpu->arch.require_dcache_flush);
 
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 1/1 ARM: KVM: fix unbalanced get_cpu() in access_dcsw

Quoted 7 lines · Marc Zyngier

In the very unlikely event where a guest would be foolish enough to *read* from a write-only cache maintainance register, we end up with preemption disabled, due to a misplaced get_cpu().

Just move the "is_write" test outside of the critical section.

I found it second time around!

Will

#2 lore raw

PATCH 1/1 ARM: KVM: fix unbalanced get_cpu() in access_dcsw

Quoted 5 lines · Will Deacon
Quoted 4 lines · Marc Zyngier

In the very unlikely event where a guest would be foolish enough to *read* from a write-only cache maintainance register, we end up with preemption disabled, due to a misplaced get_cpu().

Quoted 7 lines
Quoted 3 lines

Just move the "is_write" test outside of the critical section.

I found it second time around!

Indeed you did! :-)

I'll add that to the commit, and on a couple of other as well...

        M.
Signature · 1 line
Fast, cheap, reliable. Pick two.
#3 lore raw

PATCH 1/1 ARM: KVM: fix unbalanced get_cpu() in access_dcsw

Quoted 11 lines · Marc Zyngier
Quoted 9 lines · Will Deacon
Quoted 7 lines · Marc Zyngier

In the very unlikely event where a guest would be foolish enough to *read* from a write-only cache maintainance register, we end up with preemption disabled, due to a misplaced get_cpu().

Just move the "is_write" test outside of the critical section.

Quoted 7 lines
Quoted 3 lines

I found it second time around!

Indeed you did! :-)

I'll add that to the commit, and on a couple of other as well...

I applied the patch and added the tag, thanks.

-Christoffer