summaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2015-12-01 08:48:56 -0500
committerMarc Zyngier <marc.zyngier@arm.com>2015-12-14 06:30:38 -0500
commit3c13b8f435acb452eac62d966148a8b6fa92151f (patch)
tree2632e4a1f49c247191ef4a47f76ffafddf265a20 /virt
parent06282fd2c2bf61619649a2b13e4a08556598a64c (diff)
KVM: arm/arm64: vgic-v3: Make the LR indexing macro public
We store GICv3 LRs in reverse order so that the CPU can save/restore them in rever order as well (don't ask why, the design is crazy), and yet generate memory traffic that doesn't completely suck. We need this macro to be available to the C version of save/restore. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/arm/vgic-v3.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/virt/kvm/arm/vgic-v3.c b/virt/kvm/arm/vgic-v3.c
index 487d6357b7e7..3813d23ebb80 100644
--- a/virt/kvm/arm/vgic-v3.c
+++ b/virt/kvm/arm/vgic-v3.c
@@ -36,18 +36,12 @@
36#define GICH_LR_PHYSID_CPUID (7UL << GICH_LR_PHYSID_CPUID_SHIFT) 36#define GICH_LR_PHYSID_CPUID (7UL << GICH_LR_PHYSID_CPUID_SHIFT)
37#define ICH_LR_VIRTUALID_MASK (BIT_ULL(32) - 1) 37#define ICH_LR_VIRTUALID_MASK (BIT_ULL(32) - 1)
38 38
39/*
40 * LRs are stored in reverse order in memory. make sure we index them
41 * correctly.
42 */
43#define LR_INDEX(lr) (VGIC_V3_MAX_LRS - 1 - lr)
44
45static u32 ich_vtr_el2; 39static u32 ich_vtr_el2;
46 40
47static struct vgic_lr vgic_v3_get_lr(const struct kvm_vcpu *vcpu, int lr) 41static struct vgic_lr vgic_v3_get_lr(const struct kvm_vcpu *vcpu, int lr)
48{ 42{
49 struct vgic_lr lr_desc; 43 struct vgic_lr lr_desc;
50 u64 val = vcpu->arch.vgic_cpu.vgic_v3.vgic_lr[LR_INDEX(lr)]; 44 u64 val = vcpu->arch.vgic_cpu.vgic_v3.vgic_lr[VGIC_V3_LR_INDEX(lr)];
51 45
52 if (vcpu->kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3) 46 if (vcpu->kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3)
53 lr_desc.irq = val & ICH_LR_VIRTUALID_MASK; 47 lr_desc.irq = val & ICH_LR_VIRTUALID_MASK;
@@ -111,7 +105,7 @@ static void vgic_v3_set_lr(struct kvm_vcpu *vcpu, int lr,
111 lr_val |= ((u64)lr_desc.hwirq) << ICH_LR_PHYS_ID_SHIFT; 105 lr_val |= ((u64)lr_desc.hwirq) << ICH_LR_PHYS_ID_SHIFT;
112 } 106 }
113 107
114 vcpu->arch.vgic_cpu.vgic_v3.vgic_lr[LR_INDEX(lr)] = lr_val; 108 vcpu->arch.vgic_cpu.vgic_v3.vgic_lr[VGIC_V3_LR_INDEX(lr)] = lr_val;
115 109
116 if (!(lr_desc.state & LR_STATE_MASK)) 110 if (!(lr_desc.state & LR_STATE_MASK))
117 vcpu->arch.vgic_cpu.vgic_v3.vgic_elrsr |= (1U << lr); 111 vcpu->arch.vgic_cpu.vgic_v3.vgic_elrsr |= (1U << lr);