KVM: arm/arm64: vgic-v3: Fix off-by-one LR access
authorMarc Zyngier <marc.zyngier@arm.com>
Mon, 10 Apr 2017 09:19:44 +0000 (10:19 +0100)
committerChristoffer Dall <cdall@linaro.org>
Wed, 19 Apr 2017 15:28:38 +0000 (17:28 +0200)
When iterating over the used LRs, be careful not to try to access
an unused LR, or even an unimplemented one if you're unlucky...

Reviewed-by: Christoffer Dall <cdall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <cdall@linaro.org>
virt/kvm/arm/hyp/vgic-v3-sr.c

index 91922c1..bce6037 100644 (file)
@@ -143,7 +143,7 @@ void __hyp_text __vgic_v3_save_state(struct kvm_vcpu *vcpu)
                val = read_gicreg(ICH_VTR_EL2);
                nr_pri_bits = vtr_to_nr_pri_bits(val);
 
-               for (i = 0; i <= used_lrs; i++) {
+               for (i = 0; i < used_lrs; i++) {
                        if (cpu_if->vgic_elrsr & (1 << i))
                                cpu_if->vgic_lr[i] &= ~ICH_LR_STATE;
                        else