Skip to contentSkip to conversation

trigger an interrupt in HVM

DISCUSSION James Harper 4 participants 11 messages Aug 21, 2008 – Aug 26, 2008

lore
Share & tools
lore
#0 lore raw

I need to trigger an interrupt on the HVM Xen PCI device. Is this possible?

Could I just set vcpu_info->evtchn_upcall_pending = 1 and then do a notify hypercall?

Thanks

James

#1 lore raw

What's the reason to try this? :-)
The interrupt injection into HVM guest doesn't use evtchn_upcall_pending -- that's for PV guest.
Maybe you can refer to tools/ioemu/hw/rtl8139.c to see how the rtl8139 device model injects interrupt into hvm guest (pls see pci_set_irq()).

-- Dexuan

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of James Harper
Sent: 2008年8月21日 8:22
To: [email protected]
Subject: [Xen-devel] trigger an interrupt in HVM

I need to trigger an interrupt on the HVM Xen PCI device. Is this possible?

Could I just set vcpu_info->evtchn_upcall_pending = 1 and then do a notify hypercall?

Thanks

James

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

#2 lore raw
Quoted 2 lines

What's the reason to try this? :-)
The interrupt injection into HVM guest doesn't use

evtchn_upcall_pending -

Quoted 3 lines

- that's for PV guest.
Maybe you can refer to tools/ioemu/hw/rtl8139.c to see how the rtl8139 device model injects interrupt into hvm guest (pls see pci_set_irq()).

I should have been more clear. This is from inside the DomU with the GPLPV drivers.

The various subsystems (xennet, xenvbd) hook onto the same IRQ as the PCI device. When the PCI device gets an IRQ, signalling that an event channel has been set, and the event channel is for one of the subsystem devices, it tells windows that the IRQ wasn't handled, so windows then tries the other devices.

Windows makes it very tricky to get 'into' the scsiport context, and an interrupt is the easiest way to do this, so if the PCI device driver wants to tell the vbd driver to prepare for a suspend, setting a flag in some shared data and triggering an interrupt is a good way to do this. The alternative is a scsiport timer that polls the shared data. The latter works but is a bit ugly.

Previously, I was attaching the subsystem drivers to fake IRQ's (eg in the range 31-47) and using the asm 'int x' instruction to call them. This is really bad for performance and caused a few other problems too.

Thanks

James

#3 lore raw

Oh, sorry, I didn't realize you meant the case of PV driver. I think PV drivers for Linux/Windows should be alike here? (I haven't read any codes of the Windows PV drivers :)

Thanks,
-- Dexuan

-----Original Message-----
From: James Harper [mailto:[email protected]]
Sent: 2008年8月21日 10:32
To: Cui, Dexuan; [email protected]
Subject: RE: [Xen-devel] trigger an interrupt in HVM

Quoted 2 lines

What's the reason to try this? :-)
The interrupt injection into HVM guest doesn't use

evtchn_upcall_pending -

Quoted 3 lines

- that's for PV guest.
Maybe you can refer to tools/ioemu/hw/rtl8139.c to see how the rtl8139 device model injects interrupt into hvm guest (pls see pci_set_irq()).

I should have been more clear. This is from inside the DomU with the GPLPV drivers.

The various subsystems (xennet, xenvbd) hook onto the same IRQ as the PCI device. When the PCI device gets an IRQ, signalling that an event channel has been set, and the event channel is for one of the subsystem devices, it tells windows that the IRQ wasn't handled, so windows then tries the other devices.

Windows makes it very tricky to get 'into' the scsiport context, and an interrupt is the easiest way to do this, so if the PCI device driver wants to tell the vbd driver to prepare for a suspend, setting a flag in some shared data and triggering an interrupt is a good way to do this. The alternative is a scsiport timer that polls the shared data. The latter works but is a bit ugly.

Previously, I was attaching the subsystem drivers to fake IRQ's (eg in the range 31-47) and using the asm 'int x' instruction to call them. This is really bad for performance and caused a few other problems too.

Thanks

James

#4 lore raw
In reply to James Harper
Quoted 8 lines

From: James Harper
Sent: 2008年8月21日 10:32

The various subsystems (xennet, xenvbd) hook onto the same IRQ as the PCI device. When the PCI device gets an IRQ, signalling that an event channel has been set, and the event channel is for one of the subsystem devices, it tells windows that the IRQ wasn't handled, so windows then tries the other devices.

Same IRQ as which PCI device? For Linux HVM, a dummy PCI device is exposed and a platform-pci driver is installed within Linux HVM. When it accepts interrupt being event pending, it then invokes into each FE driver directly which is bound to xenbus.

It seems that in your case xenbus is not present at all, and thus each FE driver is still installed into existing sub-system of same class, and then you're trying to find a communication channel between dummy PCI driver and each FE which can't be done by simple function call and is done by irq sharing by far, is that true?

Maybe to install FE driver onto xen bus type is easier, as the natural layered function call is then available like in Linux side. I guess I may still miss something here... :-(

Back to your question. It's viable but simply setting evtchn_upcall_pending is not enough, as it's not checked at each VM resume path. By far event pending caused interrupt injection is only triggered from a real event send operation. One option you may try is to use inter-domain event channel between PCI driver and each BE driver. I guess inter- domain binding should allow for remote domain equal to local one, and then you can simply use notify_remote_via_evtchn to trigger an injection.

Thanks
Kevin

#5 lore raw
In reply to James Harper
Quoted 5 lines · James Harper

I need to trigger an interrupt on the HVM Xen PCI device. Is this possible?

Could I just set vcpu_info->evtchn_upcall_pending = 1 and then do a notify hypercall?

There is no such hypercall. In PV guests we can do any hypercall and the evtchn_upcall_pending will be picked up. This isn't the case for an HVM guest -- the IRQ is only asserted if an event is set pending by the hypervisor itself.

If you must be able to trigger event delivery via the HVM IRQ mechanism from within your HVM guest then I suggest you allocate an IPI event channel and do a notify hypercall on that. That will have the side effect of triggering an interrupt and 'flushing through' all other pending events.

-- Keir

#6 lore raw
Quoted 1 line

There is no such hypercall. In PV guests we can do any hypercall and

the

Quoted 1 line

evtchn_upcall_pending will be picked up. This isn't the case for an

HVM

Quoted 4 lines

guest -- the IRQ is only asserted if an event is set pending by the hypervisor itself.

If you must be able to trigger event delivery via the HVM IRQ

mechanism

Quoted 2 lines

from
within your HVM guest then I suggest you allocate an IPI event channel

and

Quoted 4 lines

do a notify hypercall on that. That will have the side effect of triggering
an interrupt and 'flushing through' all other pending events.

As an alternative, could I do an alloc_unbound (DOMID_SELF, DOMID_SELF) and then bind_interdomain to it?

As another alternative, I have previously been using the asm 'int x' instructions to call isr's... that could work too although of course without the source code to windows it's hard to tell exactly what the implications of that might be :)

James

#7 lore raw
Quoted 2 lines · James Harper

As an alternative, could I do an alloc_unbound (DOMID_SELF, DOMID_SELF) and then bind_interdomain to it?

Yes, it's just that that burns two event-channel ports, whereas an IPI port burns just one.

Quoted 4 lines

As another alternative, I have previously been using the asm 'int x' instructions to call isr's... that could work too although of course without the source code to windows it's hard to tell exactly what the implications of that might be :)

I wouldn't advise it -- the ISR will EOI the LAPIC even though the LAPIC did not deliver the interrupt. A safer way to go might be to self-IPI via the LAPIC.

-- Keir

#8 lore raw
In reply to Keir Fraser
Quoted 1 line

If you must be able to trigger event delivery via the HVM IRQ

mechanism

Quoted 2 lines

from
within your HVM guest then I suggest you allocate an IPI event channel

and

Quoted 4 lines

do a notify hypercall on that. That will have the side effect of triggering
an interrupt and 'flushing through' all other pending events.

That doesn't seem to work... I allocate the IPI event channel which in my case gives me event channel 7, but a notify on port 7 doesn't appear to end up calling the IRQ... or if it does, it doesn't set the bits for that port.

James

#9 lore raw
Quoted 5 lines
Quoted 2 lines

If you must be able to trigger event delivery via the HVM IRQ

mechanism

Quoted 2 lines

from
within your HVM guest then I suggest you allocate an IPI event

channel

Quoted 8 lines

and

Quoted 4 lines

do a notify hypercall on that. That will have the side effect of triggering
an interrupt and 'flushing through' all other pending events.

That doesn't seem to work... I allocate the IPI event channel which in my case gives me event channel 7, but a notify on port 7 doesn't

appear

Quoted 1 line

to end up calling the IRQ... or if it does, it doesn't set the bits

for

Quoted 2 lines

that port.

Disregard that. I wasn't unmasking the event channel.

James

#10 lore raw
In reply to James Harper
Quoted 10 lines · James Harper
Quoted 1 line

If you must be able to trigger event delivery via the HVM IRQ

mechanism

Quoted 2 lines

from
within your HVM guest then I suggest you allocate an IPI event channel

and

Quoted 4 lines

do a notify hypercall on that. That will have the side effect of triggering
an interrupt and 'flushing through' all other pending events.

Quoted 4 lines

That doesn't seem to work... I allocate the IPI event channel which in my case gives me event channel 7, but a notify on port 7 doesn't appear to end up calling the IRQ... or if it does, it doesn't set the bits for that port.

You did request to bind the IPI port to vcpu0? Otherwise it won't work.

Also you will need to handle that port in your IRQ handler somehow (at least the event selector bit and the event pending bit). Otherwise the IPI will obviously only fire once.

-- Keir