Hi,
I am facing an issue where I am setting virtual timer to fire at particular interval (Juno PPI4 , interrupt no 27) from EL1NS mode and
when the timer interrupt happens the control is falling to EL2t IRQ handler rather than guest aarch64 IRQ handler. I confirm that I am setting EL1 to aarch64 state into HCR_EL2 register (RW = 1).
I see below register values -
PC = 0x80214480
VBAR_EL2 = 0x80214400
ESR_EL2 = 0x356ABA3B { EC = 13, IL = 16 bit instruction trapped, ISS = 23771707 }
Does any one knows how to resolve this ? I am not sure if i am missing anything ?
Thanks,
Despite the name, the Virtual Timer will be generating a physical interrupt. I'm guessing you've got it configured as Group 1 in the GIC, which means it will be sent as an IRQ exception. If your taking the exception to EL2, then you'll have HCR_EL2.IMO==1 (route physical IRQs to EL2, unless already routed to EL3).
If you want the IRQ taken to NS.EL1 you have a couple of choices:
* HCR_EL2.IMO==0: this will route physical IRQs to EL1 instead of EL2. This might not be what you want if you only need certain IRQs in EL1 and others in EL2.
* Add EL2 code to forward the interrupt to NS.EL1 as a virtual IRQ, using the GIC's list registers.
NOTE: The ESR_ELx registers aren't used for IRQs or FIQs.
Hi Martin,
Yes I am configuring the virtual timer interrupt to Group 1 and setting HCR_EL2.IMO bit in order to route it to EL2 mode.
I am not able to understand as why control is reaching EL2t IRQ vector entry rather than AArch64 Guest IRQ vector entry ?
My understanding is if IRQ is received in EL2 mode then control should jump to EL2t or EL2h IRQ vector entry (based on SPSel)
and if IRQ received at EL1 then control should jump to either aarch32 IRQ or aarch64 IRQ entry based on (EL1 aarch mode) ?
Is my understanding wrong and how to resolve above ?
Thanks.
My understanding is if IRQ is received in EL2 mode then control should jump to EL2t or EL2h IRQ vector entry (based on SPSel) and if IRQ received at EL1 then control should jump to either aarch32 IRQ or aarch64 IRQ entry based on (EL1 aarch mode) ? Is my understanding wrong and how to resolve above ?
My understanding is if IRQ is received in EL2 mode then control should jump to EL2t or EL2h IRQ vector entry (based on SPSel) and if IRQ received at EL1 then control should jump to either aarch32 IRQ or aarch64 IRQ entry based on (EL1 aarch mode) ?
I'm afraid that's not how it works. Let's ignore EL3 (and assume SCR_EL3.IRQ=0 and SCR_EL3.NS=1) for the moment.
HCR_EL2.IMO==1: Route IRQs to EL2.
An IRQ exception while at EL0/EL1/EL2 will be taken to EL2.
HCR_EL2.IMO==0: Route IRQs to EL1
An IRQ exception while at EL0/EL1 will be taken to EL1.
An IRQ exception while at EL2 will be masked, until execution returns to EL0 or EL1.
What if I want some interrupts to go to EL2 and others to EL1?
One option is to use different types (e.g. IRQ for EL1, and FIQ for EL2). Problem with that is in GICv2 FIQs are used for Secure (Group 0) interrupts, and in GICv3 for interrupts for EL3/non-current Security state.
The other option is have the physical interrupt routed to EL2, and then have EL2 forward on virtual interrupts to EL1 as necessary.
My question is actually regarding which IRQ entry of vector table control will jump once it goes to EL2 mode ?
I understand that all IRQs will be routed to EL2 mode if i set HCR_EL2.IMO = 1 but the vector table at EL2 mode has 4 entries for IRQ as below -
0x80 (EL2/SP_EL0)
0x280 (EL2/SP_EL2)
0x480 (Guest OS aarch64)
0x680 (Guest OS aarch32)
Based on my understanding when IRQ arrives at EL1NS (aarch64) mode then control should jump to 0x480 vector entry ?
What I am observing in my scenario is that it is reaching 0x80 (EL2/SP_EL0).
So I am facing two issues -
1) Why it is 0x80 if I am selecting SPSel = 1 and my Mode.M = 9 when I break through DS-5 ?
2) It should reach to 0x480 ?
If you put a breakpoint on both IRQ vector entries. When you hit on the 0x80 entry, what do SPSR_EL2 and ELR_EL2 report?
"1) Why it is 0x80 if I am selecting SPSel = 1 and my Mode.M = 9 when I break through DS-5 ?"
Where/when are you selecting Mode.M=0x9? Not sure I follow - but 0x9 is the value for EL2 not EL1.