I'm trying to implement some kind of Interrupt routine.
It's related to virtualization with GIC v2 H/W support.
My question is :
When catch a interrupt number, Hypervisor should distingush if it's for
own itself or for guests ran on the hypervisor.
But how to check it? if it's for hyp or guest?
it's my question. Please let me know if correct or not. I need more backgrounds. Thank you for your replay before.
The simplest way is for FIQ interrupt assigned to the secure world and IRQ to the normal world. There is a trustzone register (SCR or secure configuration registers) that will route IRQ/FIQ to the monitor or straight to the OS in the current world. The GIC itself allows all interrupt to be either FIQ or IRQ (I think the documentation calls it type 0 and type 1). You can always route to the monitor or you can dynamically switch (on a world switch) where the interrupt are routed.
World | Normal | Secure
------+--------+--------
FIQ | Monitor| Through
IRQ | Through| Monitor
The monitor trap will require saving a lot of registers (a world switch to save registers). You can trust the secure interrupt handler somewhat, but all bets should be off for the normal world.
There maybe other ways to handle it, but this is the least complex. For instance, you can always have a fixed table of interrupt sources owners (which world they belong to). I imagine there are many other ways. Most will always trap to monitor mode which is somewhat undesirable for performance reasons.
For your hypervisor case, you would have to disallow FIQ interrupts in the guest OS. Probably they will not work well as they are suppose to be FAST and the virtualization is going to interfere with this. You can leave the SCR in the Normal column if this is the case (so the SCR is constant).