Skip to content

Commit ca185b2

Browse files
Zenghui YuMarc Zyngier
authored andcommitted
KVM: arm/arm64: vgic: Don't rely on the wrong pending table
It's possible that two LPIs locate in the same "byte_offset" but target two different vcpus, where their pending status are indicated by two different pending tables. In such a scenario, using last_byte_offset optimization will lead KVM relying on the wrong pending table entry. Let us use last_ptr instead, which can be treated as a byte index into a pending table and also, can be vcpu specific. Fixes: 2807712 ("KVM: arm64: vgic-v3: KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES") Cc: [email protected] Signed-off-by: Zenghui Yu <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Acked-by: Eric Auger <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent bad36e4 commit ca185b2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

virt/kvm/arm/vgic/vgic-v3.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ int vgic_v3_lpi_sync_pending_status(struct kvm *kvm, struct vgic_irq *irq)
363363
int vgic_v3_save_pending_tables(struct kvm *kvm)
364364
{
365365
struct vgic_dist *dist = &kvm->arch.vgic;
366-
int last_byte_offset = -1;
367366
struct vgic_irq *irq;
367+
gpa_t last_ptr = ~(gpa_t)0;
368368
int ret;
369369
u8 val;
370370

@@ -384,11 +384,11 @@ int vgic_v3_save_pending_tables(struct kvm *kvm)
384384
bit_nr = irq->intid % BITS_PER_BYTE;
385385
ptr = pendbase + byte_offset;
386386

387-
if (byte_offset != last_byte_offset) {
387+
if (ptr != last_ptr) {
388388
ret = kvm_read_guest_lock(kvm, ptr, &val, 1);
389389
if (ret)
390390
return ret;
391-
last_byte_offset = byte_offset;
391+
last_ptr = ptr;
392392
}
393393

394394
stored = val & (1U << bit_nr);

0 commit comments

Comments
 (0)