I've been studying interrupt delivery in KVM myself lately. I hope I
can explain what I've found, but, as I'm pretty new to this, please
take my answer with a grain of salt (as I could be wrong). I would
really appreciate if someone could correct me here if I am wrong or
provide more details!
Interrupts from the guest might be delivered via the ioctl
KVM_INTERRUPT only when the KVM kmod can do interrupt routing.
However, the default setup for KVM these days implements the interrupt
controller in the kernel, so this ioctl is unused, and thus,
vmx_inject_irq is not directly triggered from userspace. The call to
vmx_inject_irq is made upon re-entry to the guest after I.E. the local
APIC in the kmod flags that it needs service.
To use the example of a PS2 keyboard press, the control flow works
like this:
1. Userspace writes to appropriate locations as defined by the i8042
emulator
2. Userspace calls vm ioctl KVM_IRQ_LINE (IRQ=1, Level=1)
3. Control in the kmod eventually makes a call to kvm_apic_set_irq
4. In the local APIC, __apic_accept_irq does a part in setting up the
need for service
5. Upon guest entry (vcpu_enter_guest), if there is no nmi and
kvm_apic_has_interrupt, the host will call inject_pending_irq
6. inject_pending_irq calls vmx_inject_irq
In attempting to answer the second part of your question, I realize
this point isn't 100% clear to me either. It would seem the point at
which the interrupt is delivered to KVM is always the point at which
the guest VCPU is entered. Obviously, if you have a multi-cpu setup
the calls to set up the local apic can be done in parallel to running
the guest, but interrupt delivery won't happen until the vcpu is re-
entered. This seems to mean that interrupts are only delivered when
the guest is scheduled out and back in by the kernel. Is this right,
guys?
Kurt
On Nov 23, 2009, at 4:49 PM, Liang YANG wrote:
Does the vmx_inject_irq and vmx_inject_nmi inject all the interrupt
from outer space ?
Then when the interrrupt yielded from hardware is delieved to the
QEMU or KVM ?
Anyone can help me,, Thanks in advance!!
--
BestRegards.
YangLiang
_____________________________________________
Master Candidate.
Department of Computer Science .
School of Electronics Engineering & Computer Science .
_____________________________________________
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html