Skip to contentSkip to conversation

Xen interrupts when using passthrough

DISCUSSION Eli Cohen 4 participants 10 messages Oct 4, 2011 – Oct 5, 2011

lore
Share & tools
lore

Eli Cohen

author
#0 lore raw

Hi,
I am trying to debug a problem where a guest does not receive the correct interrupt. It's a passtrough system where the guest is given a virtual function and is using MSIX to recieve the interrupts. I am trying to understand how is the guest supposed to recieve the
interrupt: Is it handled by dom0 which is using event channels to pass the interrupt to domU, or is handled directly by domU. Please send pointers to the code.

Thanks in advance,
eli;

#1 lore raw
Quoted 4 lines · Eli Cohen

Hi,
I am trying to debug a problem where a guest does not receive the correct interrupt. It's a passtrough system where the guest is given a virtual function and is using MSIX to recieve the interrupts.

Do you mean that it is receiving interrupts for another device, or are you trying to pass through multiple interrupts for a device and the interrupt is appearing in the wrong event channel?

Could you describe your hardware setup in detail please, especially AMD/Intel, IOMMU features in use according to Xen, and the PCI topology of the box.

Quoted 5 lines

I am
trying to understand how is the guest supposed to recieve the
interrupt: Is it handled by dom0 which is using event channels to pass the interrupt to domU, or is handled directly by domU. Please send pointers to the code.

(I am not very familiar with guest IRQs so the following might not be accurate)

For a PCI passthrough system, the interrupts should be bound directly to domU, with no dom0 interaction. A PIRQ is bound to an event channel using the EVTCHNOP_bind_pirq in common/event_channel.c, which should be set up by qemu for the relevant domU, when it is interpreting the PCI config space reads/writes.

Quoted 7 lines

Thanks in advance,
eli;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Signature · 2 lines
Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer
T: +44 (0)1223 225 900, http://www.citrix.com
author
#2 lore raw

Andrew, thanks for your response.

Quoted 5 lines · Andrew Cooper

Do you mean that it is receiving interrupts for another device, or are you trying to pass through multiple interrupts for a device and the interrupt is appearing in the wrong event channel?

I am not sure I understand your question.

Quoted 3 lines

Could you describe your hardware setup in detail please, especially AMD/Intel, IOMMU features in use according to Xen, and the PCI topology of the box.

Here's a description. I have a PCI device which supports SRIOV, so there are several virtual functions besides the primary function. The device generates interrupts using MSI-X. I bind one of the virtual functions to the guest. The PCI device driver at the guest requests msix vectors from kernel and gets two vectors. Then it calls request_irq for those vectors.
When the device generates msix interrupt using the address/data in it's msi-x table. However, the guest kernel complains the no handler is registered for this vector. Specifically, I request_irq for vectors 48 and 49. When the device issues interrupt for vector 49, the guest complains that it received interrupt for vector 89 which has no handler routine.

Quoted 7 lines
Quoted 6 lines

I am
trying to understand how is the guest supposed to recieve the
interrupt: Is it handled by dom0 which is using event channels to pass the interrupt to domU, or is handled directly by domU. Please send pointers to the code.

Quoted 8 lines

(I am not very familiar with guest IRQs so the following might not be accurate)

For a PCI passthrough system, the interrupts should be bound directly to domU, with no dom0 interaction. A PIRQ is bound to an event channel using the EVTCHNOP_bind_pirq in common/event_channel.c, which should be set up by qemu for the relevant domU, when it is interpreting the PCI config space reads/writes.

My geust kernel is 2.6.32 based and I can't see any file with the name event_channel.c.

#3 lore raw
Quoted 13 lines
Quoted 1 line
Quoted 1 line · Eli Cohen

Here's a description. I have a PCI device which supports SRIOV, so there are several virtual functions besides the primary function. The device generates interrupts using MSI-X. I bind one of the virtual functions to the guest. The PCI device driver at the guest requests msix vectors from kernel and gets two vectors. Then it calls request_irq for those vectors.
When the device generates msix interrupt using the address/data in it's msi-x table. However, the guest kernel complains the no handler is registered for this vector. Specifically, I request_irq for vectors 48 and 49. When the device issues interrupt for vector 49, the guest complains that it received interrupt for vector 89 which has no handler routine.

Quite possibly a mixup of Xen and Linux IRQ numbers. You may want to check Xen's 'i' and 'e' debug key output for whether this might be the case.

Quoted 1 line

My geust kernel is 2.6.32 based

Upstream (pv-ops), forward-port (most likely SUSE-derived), HVM, or yet something else?

Quoted 2 lines

and I can't see any file with the name
event_channel.c.

That's a hypervisor source file, not a Linux one.

Jan

author
#4 lore raw
Quoted 4 lines · Jan Beulich

Quite possibly a mixup of Xen and Linux IRQ numbers. You may want to check Xen's 'i' and 'e' debug key output for whether this might be the case.

Can you tell how this is done - sorry, I'm not a xen expert.

Quoted 11 lines
Quoted 2 lines

My geust kernel is 2.6.32 based

Upstream (pv-ops), forward-port (most likely SUSE-derived), HVM, or yet something else?

Quoted 2 lines

and I can't see any file with the name
event_channel.c.

That's a hypervisor source file, not a Linux one.

So how do you think interrupts should reach the guest. Is it through event channels (i.e dom0 receives them first) or do they go directly to the guest with dom0 unaware that there was an interrupt?

#5 lore raw
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Eli Cohen
Quoted 4 lines · Jan Beulich

Quite possibly a mixup of Xen and Linux IRQ numbers. You may want to check Xen's 'i' and 'e' debug key output for whether this might be the case.

Can you tell how this is done - sorry, I'm not a xen expert.

Either by sending the characters from the serial console (after switching input to Xen), or by using "{xl,xm] debug-key" followed by "{xm,xl} dmesg" to view the output.

Quoted 9 lines
Quoted 9 lines
Quoted 2 lines

My geust kernel is 2.6.32 based

Upstream (pv-ops), forward-port (most likely SUSE-derived), HVM, or yet something else?

Quoted 2 lines

and I can't see any file with the name
event_channel.c.

Quoted 6 lines
Quoted 2 lines

That's a hypervisor source file, not a Linux one.

So how do you think interrupts should reach the guest. Is it through event channels (i.e dom0 receives them first) or do they go directly to the guest with dom0 unaware that there was an interrupt?

Dom0 shouldn't get involved at all - Xen does the necessary conversion. Dom0 may only be involved in setting things up. Whether they get received via event channels or virtual interrupts depends on the kind of guest.

Jan

author
#6 lore raw
Quoted 5 lines · Jan Beulich

Either by sending the characters from the serial console (after switching input to Xen), or by using "{xl,xm] debug-key" followed by "{xm,xl} dmesg" to view the output.

Thanks.

Quoted 6 lines

Dom0 shouldn't get involved at all - Xen does the necessary conversion. Dom0 may only be involved in setting things up. Whether they get received via event channels or virtual interrupts depends on the kind of guest.

I think I used the wrong terminology not distinguishing between the hypervisor and dom0 so I will ask again just to make sure. Is the hypervisor involved in passing the interrupts? Does it depend on whether the guest is paravirtualized or not? The guest I am using is paravirtualized (i.e uses xen hypercalls), so does it mean that it uses event channels or is there a possibilty that it does not use event channels.

#7 lore raw
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Eli Cohen
Quoted 5 lines · Jan Beulich

Dom0 shouldn't get involved at all - Xen does the necessary conversion. Dom0 may only be involved in setting things up. Whether they get received via event channels or virtual interrupts depends on the kind of guest.

I think I used the wrong terminology not distinguishing between the hypervisor and dom0 so I will ask again just to make sure. Is the hypervisor involved in passing the interrupts?

Yes, of course. The hypervisor receives all physical interrupts.

Quoted 1 line

Does it depend on whether the guest is paravirtualized or not?

Yes, at least to some degree.

Quoted 4 lines

The guest I am using is
paravirtualized (i.e uses xen hypercalls), so does it mean that it uses event channels or is there a possibilty that it does not use event channels.

Yes and no: PV guests can receive interrupts only via the event channel mechanism.

Jan

author
#8 lore raw

Thanks for the information.

Quoted 26 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Eli Cohen
Quoted 5 lines · Jan Beulich

Dom0 shouldn't get involved at all - Xen does the necessary conversion. Dom0 may only be involved in setting things up. Whether they get received via event channels or virtual interrupts depends on the kind of guest.

I think I used the wrong terminology not distinguishing between the hypervisor and dom0 so I will ask again just to make sure. Is the hypervisor involved in passing the interrupts?

Yes, of course. The hypervisor receives all physical interrupts.

Quoted 1 line

Does it depend on whether the guest is paravirtualized or not?

Yes, at least to some degree.

Quoted 4 lines

The guest I am using is
paravirtualized (i.e uses xen hypercalls), so does it mean that it uses event channels or is there a possibilty that it does not use event channels.

Yes and no: PV guests can receive interrupts only via the event channel mechanism.

Jan

#9 lore raw
In reply to Jan Beulich
Quoted 17 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Eli Cohen
Quoted 5 lines · Jan Beulich

Dom0 shouldn't get involved at all - Xen does the necessary conversion. Dom0 may only be involved in setting things up. Whether they get received via event channels or virtual interrupts depends on the kind of guest.

I think I used the wrong terminology not distinguishing between the hypervisor and dom0 so I will ask again just to make sure. Is the hypervisor involved in passing the interrupts?

Yes, of course. The hypervisor receives all physical interrupts.

Quoted 1 line

Does it depend on whether the guest is paravirtualized or not?

Yes, at least to some degree.

Quoted 7 lines
Quoted 4 lines

The guest I am using is
paravirtualized (i.e uses xen hypercalls), so does it mean that it uses event channels or is there a possibilty that it does not use event channels.

Yes and no: PV guests can receive interrupts only via the event channel mechanism.

While an HVM guest can receive interrupts via any of:
* Emulated interrupt injection (i.e. from the emulated APIC)
* Event channels, injected via the INTx interrupt on the PCI platform device (itself injected by the previous option)
* Event channels, injected directly to a vector.

The first is available to any HVM guest, the middle one is the older style PV Driver for HVM guest mechanism while the third is an additional feature of more recent Linux kernels using the PVHVM mechanism.

Ian.