aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2013-06-04 06:02:10 -0400
committerChristoffer Dall <christoffer.dall@linaro.org>2014-07-11 07:57:32 -0400
commit495dd859f304689a7cd5ef413c439cb090dc25e6 (patch)
treeefeaef9196b6b31c93edfa83607c58dcc7913104 /virt
parent8d6a0313c125c3c7b208b75695fe6ab00afab4c5 (diff)
KVM: ARM: vgic: abstract MISR decoding
Instead of directly dealing with the GICH_MISR bits, move the code to its own function and use a couple of public flags to represent the actual state. Acked-by: Catalin Marinas <catalin.marinas@arm.com> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/arm/vgic.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 1e857e6e66b5..c0bcc9735424 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -1050,12 +1050,26 @@ static u64 vgic_v2_get_eisr(const struct kvm_vcpu *vcpu)
1050 return val; 1050 return val;
1051} 1051}
1052 1052
1053static u32 vgic_v2_get_interrupt_status(const struct kvm_vcpu *vcpu)
1054{
1055 u32 misr = vcpu->arch.vgic_cpu.vgic_v2.vgic_misr;
1056 u32 ret = 0;
1057
1058 if (misr & GICH_MISR_EOI)
1059 ret |= INT_STATUS_EOI;
1060 if (misr & GICH_MISR_U)
1061 ret |= INT_STATUS_UNDERFLOW;
1062
1063 return ret;
1064}
1065
1053static const struct vgic_ops vgic_ops = { 1066static const struct vgic_ops vgic_ops = {
1054 .get_lr = vgic_v2_get_lr, 1067 .get_lr = vgic_v2_get_lr,
1055 .set_lr = vgic_v2_set_lr, 1068 .set_lr = vgic_v2_set_lr,
1056 .sync_lr_elrsr = vgic_v2_sync_lr_elrsr, 1069 .sync_lr_elrsr = vgic_v2_sync_lr_elrsr,
1057 .get_elrsr = vgic_v2_get_elrsr, 1070 .get_elrsr = vgic_v2_get_elrsr,
1058 .get_eisr = vgic_v2_get_eisr, 1071 .get_eisr = vgic_v2_get_eisr,
1072 .get_interrupt_status = vgic_v2_get_interrupt_status,
1059}; 1073};
1060 1074
1061static struct vgic_lr vgic_get_lr(const struct kvm_vcpu *vcpu, int lr) 1075static struct vgic_lr vgic_get_lr(const struct kvm_vcpu *vcpu, int lr)
@@ -1085,6 +1099,11 @@ static inline u64 vgic_get_eisr(struct kvm_vcpu *vcpu)
1085 return vgic_ops.get_eisr(vcpu); 1099 return vgic_ops.get_eisr(vcpu);
1086} 1100}
1087 1101
1102static inline u32 vgic_get_interrupt_status(struct kvm_vcpu *vcpu)
1103{
1104 return vgic_ops.get_interrupt_status(vcpu);
1105}
1106
1088static void vgic_retire_lr(int lr_nr, int irq, struct kvm_vcpu *vcpu) 1107static void vgic_retire_lr(int lr_nr, int irq, struct kvm_vcpu *vcpu)
1089{ 1108{
1090 struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; 1109 struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
@@ -1282,11 +1301,12 @@ epilog:
1282static bool vgic_process_maintenance(struct kvm_vcpu *vcpu) 1301static bool vgic_process_maintenance(struct kvm_vcpu *vcpu)
1283{ 1302{
1284 struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; 1303 struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
1304 u32 status = vgic_get_interrupt_status(vcpu);
1285 bool level_pending = false; 1305 bool level_pending = false;
1286 1306
1287 kvm_debug("MISR = %08x\n", vgic_cpu->vgic_v2.vgic_misr); 1307 kvm_debug("STATUS = %08x\n", status);
1288 1308
1289 if (vgic_cpu->vgic_v2.vgic_misr & GICH_MISR_EOI) { 1309 if (status & INT_STATUS_EOI) {
1290 /* 1310 /*
1291 * Some level interrupts have been EOIed. Clear their 1311 * Some level interrupts have been EOIed. Clear their
1292 * active bit. 1312 * active bit.
@@ -1319,7 +1339,7 @@ static bool vgic_process_maintenance(struct kvm_vcpu *vcpu)
1319 } 1339 }
1320 } 1340 }
1321 1341
1322 if (vgic_cpu->vgic_v2.vgic_misr & GICH_MISR_U) 1342 if (status & INT_STATUS_UNDERFLOW)
1323 vgic_cpu->vgic_v2.vgic_hcr &= ~GICH_HCR_UIE; 1343 vgic_cpu->vgic_v2.vgic_hcr &= ~GICH_HCR_UIE;
1324 1344
1325 return level_pending; 1345 return level_pending;