Skip to content

Commit 495dd85

Browse files
Marc Zyngierchazy
authored andcommitted
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>
1 parent 8d6a031 commit 495dd85

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

‎include/kvm/arm_vgic.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ struct vgic_ops {
8787
void (*sync_lr_elrsr)(struct kvm_vcpu *, int, struct vgic_lr);
8888
u64 (*get_elrsr)(const struct kvm_vcpu *vcpu);
8989
u64 (*get_eisr)(const struct kvm_vcpu *vcpu);
90+
u32 (*get_interrupt_status)(const struct kvm_vcpu *vcpu);
9091
};
9192

9293
struct vgic_dist {
@@ -165,6 +166,9 @@ struct vgic_cpu {
165166

166167
#define LR_EMPTY 0xff
167168

169+
#define INT_STATUS_EOI (1 << 0)
170+
#define INT_STATUS_UNDERFLOW (1 << 1)
171+
168172
struct kvm;
169173
struct kvm_vcpu;
170174
struct kvm_run;

‎virt/kvm/arm/vgic.c‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,12 +1050,26 @@ static u64 vgic_v2_get_eisr(const struct kvm_vcpu *vcpu)
10501050
return val;
10511051
}
10521052

1053+
static 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+
10531066
static const struct vgic_ops vgic_ops = {
10541067
.get_lr = vgic_v2_get_lr,
10551068
.set_lr = vgic_v2_set_lr,
10561069
.sync_lr_elrsr = vgic_v2_sync_lr_elrsr,
10571070
.get_elrsr = vgic_v2_get_elrsr,
10581071
.get_eisr = vgic_v2_get_eisr,
1072+
.get_interrupt_status = vgic_v2_get_interrupt_status,
10591073
};
10601074

10611075
static 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)
10851099
return vgic_ops.get_eisr(vcpu);
10861100
}
10871101

1102+
static inline u32 vgic_get_interrupt_status(struct kvm_vcpu *vcpu)
1103+
{
1104+
return vgic_ops.get_interrupt_status(vcpu);
1105+
}
1106+
10881107
static void vgic_retire_lr(int lr_nr, int irq, struct kvm_vcpu *vcpu)
10891108
{
10901109
struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
@@ -1282,11 +1301,12 @@ static void __kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu)
12821301
static bool vgic_process_maintenance(struct kvm_vcpu *vcpu)
12831302
{
12841303
struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
1304+
u32 status = vgic_get_interrupt_status(vcpu);
12851305
bool level_pending = false;
12861306

1287-
kvm_debug("MISR = %08x\n", vgic_cpu->vgic_v2.vgic_misr);
1307+
kvm_debug("STATUS = %08x\n", status);
12881308

1289-
if (vgic_cpu->vgic_v2.vgic_misr & GICH_MISR_EOI) {
1309+
if (status & INT_STATUS_EOI) {
12901310
/*
12911311
* Some level interrupts have been EOIed. Clear their
12921312
* active bit.
@@ -1319,7 +1339,7 @@ static bool vgic_process_maintenance(struct kvm_vcpu *vcpu)
13191339
}
13201340
}
13211341

1322-
if (vgic_cpu->vgic_v2.vgic_misr & GICH_MISR_U)
1342+
if (status & INT_STATUS_UNDERFLOW)
13231343
vgic_cpu->vgic_v2.vgic_hcr &= ~GICH_HCR_UIE;
13241344

13251345
return level_pending;

0 commit comments

Comments
 (0)