2009/12/7 Christoffer Dall <cd2436 at columbia.edu>: > Hi all. > > I finally got past my issues with interrupts injection and timer interrupts. > Basically, I am letting QEMU emulate a timer, which works by way of a > standard SIGALRM signal. When the emulated timer code wants to raise an > interrupt it calls a handler in the emulated ARM PIC, which in turn calls > cpu_interrupt. cpu_interrupt simply sets a flag, which would abort the main > emulation loop when not using KVM, but I have amended the ARM PIC handler to > call a new architecture-specific KVM hook: kvm_arch_interrupt. > > kvm_arch_interrupt(...) issues an IOCTL call to KVM, which sets a flag on > the virtual CPU. This could all have been done by checking the CPU flags in > kvm_arch_pre_run (which is invoked before each call to vcpu_run in KVM), but > I liked this more asynchronous approach, as one might imagine a separate > thread for the timer (perhaps one day running on its own ARM core) injecting > interrupts in this way. I'm not sure why interrupt injection was done via kvm_arch_pre_run(). It may have been because it avoided a KVM-specific hook in cpu_interrupt(), and one of the issues Fabrice raised when the KVM patches were originally submitted was that they affected too many parts of the qemu codebase. Regardless, I would *strongly* recommend bringing up issues like these on qemu-devel. I can tell you from experience that you do not want to be unique unless necessary. If the existing model works, use it, and if not, change it for everybody. If you implement a different parallel model instead, nobody will be able to update your code except you. Imagine an x86 person changing the way interrupt injection works, and since PPC is similar they do the same, and then they get to ARM and it's completely different. They will shrug, commit the patch, and break you. To avoid that, you should try to share as much code as possible. -Hollis