* How to trap a real interrupt to EL2 ? @ 2017-07-03 21:56 Raz 2017-07-04 1:25 ` Jintack Lim 2017-07-04 11:12 ` Christoffer Dall 0 siblings, 2 replies; 5+ messages in thread From: Raz @ 2017-07-03 21:56 UTC (permalink / raw) To: kvmarm [-- Attachment #1.1: Type: text/plain, Size: 288 bytes --] Hey I am trying to trap any real IRQ into EL2. I created a thin hypervisor with mmu enabled and set hcr_el2 as follows: hcr_el2= HCR_IMO | HCR_VM | HCR_RW. Now it seems that once I set hcr_el2 to the above value and then exit from EL2 I immediately jump back to EL2. Any idea why ? [-- Attachment #1.2: Type: text/html, Size: 397 bytes --] [-- Attachment #2: Type: text/plain, Size: 151 bytes --] _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to trap a real interrupt to EL2 ? 2017-07-03 21:56 How to trap a real interrupt to EL2 ? Raz @ 2017-07-04 1:25 ` Jintack Lim 2017-07-04 11:12 ` Christoffer Dall 1 sibling, 0 replies; 5+ messages in thread From: Jintack Lim @ 2017-07-04 1:25 UTC (permalink / raw) To: Raz; +Cc: kvmarm Hi Raz, On Mon, Jul 3, 2017 at 5:56 PM, Raz <raziebe@gmail.com> wrote: > Hey > > I am trying to trap any real IRQ into EL2. > I created a thin hypervisor with mmu enabled and set hcr_el2 as follows: > hcr_el2= HCR_IMO | HCR_VM | HCR_RW. > > > Now it seems that once I set hcr_el2 to the above value and then exit from > EL2 I immediately jump back to EL2. Did you change irq states once you received irqs in EL2? If not, my guess is that you have pending irqs when you return from EL2 to lower exception levels. Thanks, Jintack > > Any idea why ? > > > > _______________________________________________ > kvmarm mailing list > kvmarm@lists.cs.columbia.edu > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to trap a real interrupt to EL2 ? 2017-07-03 21:56 How to trap a real interrupt to EL2 ? Raz 2017-07-04 1:25 ` Jintack Lim @ 2017-07-04 11:12 ` Christoffer Dall 2017-07-04 19:32 ` Raz 1 sibling, 1 reply; 5+ messages in thread From: Christoffer Dall @ 2017-07-04 11:12 UTC (permalink / raw) To: Raz; +Cc: kvmarm On Mon, Jul 03, 2017 at 09:56:06PM +0000, Raz wrote: > Hey > > I am trying to trap any real IRQ into EL2. > I created a thin hypervisor with mmu enabled and set hcr_el2 as follows: > hcr_el2= HCR_IMO | HCR_VM | HCR_RW. > > > Now it seems that once I set hcr_el2 to the above value and then exit from > EL2 I immediately jump back to EL2. You could read the ESR_EL2 and figure out what caused the exception... -Christoffer ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to trap a real interrupt to EL2 ? 2017-07-04 11:12 ` Christoffer Dall @ 2017-07-04 19:32 ` Raz 2017-07-05 6:23 ` Christoffer Dall 0 siblings, 1 reply; 5+ messages in thread From: Raz @ 2017-07-04 19:32 UTC (permalink / raw) To: Christoffer Dall, jintack.lim; +Cc: kvmarm [-- Attachment #1.1: Type: text/plain, Size: 986 bytes --] The entry woken in the vector is IRQ 64-bit EL1 ( same as el1_irq in kvn/hyp.S ). ESR_EL2.EC = 0x16 -" HVC executed in EL2". It does not change. Jintack CPSR.I is 1 , but I do not think I can just clear it, if that what you mean... Chrtistoph You deactivate traps in kvm_vcpu_return( called from el1_irq). Does it mean we cannot exit-enter the hypervisor when hcr_el2.IMO is enabled ? thx On Tue, Jul 4, 2017 at 11:12 AM, Christoffer Dall <cdall@linaro.org> wrote: > On Mon, Jul 03, 2017 at 09:56:06PM +0000, Raz wrote: > > Hey > > > > I am trying to trap any real IRQ into EL2. > > I created a thin hypervisor with mmu enabled and set hcr_el2 as follows: > > hcr_el2= HCR_IMO | HCR_VM | HCR_RW. > > > > > > Now it seems that once I set hcr_el2 to the above value and then exit > from > > EL2 I immediately jump back to EL2. > > You could read the ESR_EL2 and figure out what caused the exception... > > -Christoffer > -- https://sites.google.com/site/ironspeedlinux/ [-- Attachment #1.2: Type: text/html, Size: 1865 bytes --] [-- Attachment #2: Type: text/plain, Size: 151 bytes --] _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to trap a real interrupt to EL2 ? 2017-07-04 19:32 ` Raz @ 2017-07-05 6:23 ` Christoffer Dall 0 siblings, 0 replies; 5+ messages in thread From: Christoffer Dall @ 2017-07-05 6:23 UTC (permalink / raw) To: Raz; +Cc: kvmarm On Tue, Jul 04, 2017 at 07:32:37PM +0000, Raz wrote: > The entry woken in the vector is IRQ 64-bit EL1 ( same as el1_irq in > kvn/hyp.S ). > ESR_EL2.EC = 0x16 -" HVC executed in EL2". It does not change. ESR_EL2 doesn't say anything meaningful if you're taking an asynchronous exception, like the IRQ. > > Jintack > CPSR.I is 1 , but I do not think I can just clear it, if that what you > mean... CPSR.I will mask virtual interrupts at EL1 when HCR_EL2.IMO is set, not physical interrupts. The only way to run code in EL1 when having the IMO bit set and interrupts arriving would involve either actually handling those interrupts at EL2, or taking more drastic measures like disabling physical interrupts entirely by disabling the interrupt controller or something like that. > > Chrtistoph *Christoffer* > > You deactivate traps in kvm_vcpu_return( called from el1_irq). > Does it mean we cannot exit-enter the hypervisor when hcr_el2.IMO is > enabled ? Not sure what you're asking, but the deactivate_traps function is a result of the split-mode virtualization design of KVM, where we have two modes of running things in EL1, either the host hypervisor, or the VM. Therefore, when we run the VM, we enable traps on all sorts of things to EL2, and when we go back to the host, we disable those traps again, making EL1 for the host more privileged. In terms of IRQs, what we do in practice is: disable_interrupts(); /* sets CPSR.I. HCR_EL2.IMO is 0 here. */ jump_to_el2(); enable_traps(); /* set HCR_EL2.IMO = 1 */ jump_to_vm_in_el1(); handle_exception_from_vm(); disable_traps(); /* set HCR_EL2.IMO = 0 */ return_to_host_el1(); /* CPSR.I is still set */ enable_interrupts(); /* clears CPSR.I. Raises new exception, now handled at EL1 by Linux default mechanism */ Overall, I recommend you study the ARM Architecture Reference Manual (ARM ARM) more closely to understand how the hardware works, and you can also read one of these to get a better understanding of how the KVM design works: http://www.cs.columbia.edu/~cdall/pubs/asplos019-dall.pdf https://lwn.net/Articles/557132/ Hope this helps, -Christoffer ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-07-05 6:23 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-07-03 21:56 How to trap a real interrupt to EL2 ? Raz 2017-07-04 1:25 ` Jintack Lim 2017-07-04 11:12 ` Christoffer Dall 2017-07-04 19:32 ` Raz 2017-07-05 6:23 ` Christoffer Dall
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox