Skip to content

Commit bcaa311

Browse files
legoaterpaulusmack
authored andcommitted
KVM: PPC: Book3S HV: XIVE: Fix page offset when clearing ESB pages
Under XIVE, the ESB pages of an interrupt are used for interrupt management (EOI) and triggering. They are made available to guests through a mapping of the XIVE KVM device. When a device is passed-through, the passthru_irq helpers, kvmppc_xive_set_mapped() and kvmppc_xive_clr_mapped(), clear the ESB pages of the guest IRQ number being mapped and let the VM fault handler repopulate with the correct page. The ESB pages are mapped at offset 4 (KVM_XIVE_ESB_PAGE_OFFSET) in the KVM device mapping. Unfortunately, this offset was not taken into account when clearing the pages. This lead to issues with the passthrough devices for which the interrupts were not functional under some guest configuration (tg3 and single CPU) or in any configuration (e1000e adapter). Reviewed-by: Greg Kurz <groug@kaod.org> Tested-by: Greg Kurz <groug@kaod.org> Signed-off-by: Cédric Le Goater <clg@kaod.org> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
1 parent aedb5b1 commit bcaa311

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/powerpc/kvm/book3s_xive_native.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ int kvmppc_xive_native_connect_vcpu(struct kvm_device *dev,
172172
static int kvmppc_xive_native_reset_mapped(struct kvm *kvm, unsigned long irq)
173173
{
174174
struct kvmppc_xive *xive = kvm->arch.xive;
175+
pgoff_t esb_pgoff = KVM_XIVE_ESB_PAGE_OFFSET + irq * 2;
175176

176177
if (irq >= KVMPPC_XIVE_NR_IRQS)
177178
return -EINVAL;
@@ -185,7 +186,7 @@ static int kvmppc_xive_native_reset_mapped(struct kvm *kvm, unsigned long irq)
185186
mutex_lock(&xive->mapping_lock);
186187
if (xive->mapping)
187188
unmap_mapping_range(xive->mapping,
188-
irq * (2ull << PAGE_SHIFT),
189+
esb_pgoff << PAGE_SHIFT,
189190
2ull << PAGE_SHIFT, 1);
190191
mutex_unlock(&xive->mapping_lock);
191192
return 0;

0 commit comments

Comments
 (0)