0
votes

My question is regarding interrupts and how are they handed when the guest is executing in KVM?

Lets say when kvm calls vmentry or vmresume, the guest code starts executing. Now when an external interrupt say timer interrupt occurs, the guest will cause a vmexit. After Vmexit will the next instruction in kvm execute or will the host interrupt caller gets called. If the next instruction in kvm gets called then kvm can do whatever it wants to and then call the appropriate host interrupt handler.

Thanks,

1
It will always run under the kernel process, why should userspace processes or rights have anything to with kernel space?leppie

1 Answers

2
votes

On Intel VT-x, all interrupts cause a trap into the host operating system. The host will then determine if the interrupt is:

  • For itself (in which case it will handle it, possibly causing KVM to sit unscheduled for quite some time); or

  • For the guest, in which case it will inform KVM about the interrupt. KVM will then, in turn, inject the interrupt into the guest. (Note that this part of KVM runs in kernel mode; but I presume that you would still consider this to be KVM).

In either case, the host operating system takes control first.

Somewhat unrelated, but one extension to VT-x that would make us virtualisation guys happier is if certain interrupts could be sent directly to the guest, avoiding the trap into the host (and associated performance penalty) altogether. Alas, this doesn't seem to be on the cards just yet.