Regards,
Harikrishnan
I am a newbie and am still unclear of how to exactly run ivshmem-demo which is available in inmates->demos->x86.
According to the documentation for inter-cell communication, "You can go ahead and connect two non-root cells and run the ivshmem-demo. They will send each other interrupts".
1) Do we need two non root cells or can this work with a root cell and a non root cell?
2) If it is possible to communicate between a root cell and a non root cell, how can we " connect" these two cells?
3) How should I run ivshmem-demo?
As in, for a demo uart-demo for arm, I had a uart-demo.bin file which I had loaded in a non root cell,jetson-demo.cell.
How can I proceed to run ivshmem-demo on Jetson TK1? Could you help me in a more comprehensive manner?
Regards,
Harikrishnan
Thanks again for the reply.
Although I would look for implementing specific functionality later, I am currently trying to achieve a low-level ivshmem link between the root cell and another non-root cell. I want to see an interrupt sent from one root cell received and acknowledged by the other cell and sent another interrupt back to the root cell and provide acknowledgement for the same. I believe such a setup is written for in the ivshmem-demo. I have been able to run the uart-demo in Jetson TK1 but I am finding difficulty with ivshmem-demo. Could you help me establish a low level ivshmem link between two cells in Jetson TK1 and run the ivshmem-demo? Does the ivshmem-demo work for arm architecture? What moifications should I make to make it run in Jetson TK1?
Regards,
Harikrishnan
2)I replicated the ivshmem-demo from x86 to inmates/demos/arm and hooked it up in the Makefile
I tried to cross compile the same and I have encountered a few errors.
From what I've observed, the errors are mainly regarding the pci related functions.
How can I proceed with this?
PFA the error log.
Thanks and regards,
Harikrishnan
OK, when I remove '.num_msix_vectors = 1' from the root cell configuration, I can see the following in '/var/log/messages':
[ 69.760313] PCI host bridge //vpci@0 ranges:
[ 69.764807] MEM 0x02100000..0x02101fff -> 0x02100000
[ 69.774477] pci-host-generic 2000000.vpci: PCI host bridge to bus 0000:00
[ 69.781428] pci_bus 0000:00: root bus resource [bus 00]
[ 69.786705] pci_bus 0000:00: root bus resource [mem 0x02100000-0x02101fff]
[ 69.793830] pci_bus 0000:00: scanning bus
[ 69.794718] pci 0000:00:00.0: [1af4:1110] type 00 class 0xff0000
[ 69.794815] pci 0000:00:00.0: reg 0x10: [mem 0x00000000-0x000000ff 64bit]
[ 69.794981] pci 0000:00:00.0: calling pci_fixup_ide_bases+0x0/0x50
[ 69.797231] pci_bus 0000:00: fixups for bus
[ 69.797283] PCI: bus0: Fast back to back transfers disabled
[ 69.803007] pci_bus 0000:00: bus scan returning with max=00
[ 69.803343] pci 0000:00:00.0: fixup irq: got 124
[ 69.803363] pci 0000:00:00.0: assigning IRQ 124
[ 69.803433] pci 0000:00:00.0: BAR 0: assigned [mem 0x02100000-0x021000ff 64bit]
[ 69.813181] uio_ivshmem 0000:00:00.0: enabling device (0000 -> 0002)
[ 69.819791] uio_ivshmem 0000:00:00.0: using jailhouse mode
[ 69.825511] uio_ivshmem 0000:00:00.0: regular IRQs
[ 69.836988] The Jailhouse is opening.
How does this IRQ number correlate to the INTx I should be using when generating interrupts from the bare-metal inmate to the root-cell?
Does the uio_ivshmem driver take care of generating interrupts from the root-cell to the bare metal cell, or do I need to modify this as well?
Slightly confused - Jonas
Unfortunately not (just yet...). I've commented out the part where the bare-metal ivshmem-demo inmate writes to the IO-mapped ivshmem register of the virtual PCI device. The last thing I see in the inmate terminal window (after adding the printout prior to writing to the ivshmem register area) is:
IVSHMEM: 00:00.0 sending IRQ (by writing to 0x7c00000c)
In the terminal window of the Linux root-cell I see:
FATAL: Invalid ivshmem register read, number 04
FATAL: forbidden access (exception class 0x24)
pc=0xbf00b018 cpsr=0x600c0193 hsr=0x93800006
r0=0x0000007c r1=0xdd4f3600 r2=0x00010001 r3=0xdf948000
r4=0xc08d0000 r5=0xdd144290 r6=0xc0959325 r7=0x0000007c
r8=0x0000007c r9=0xc08a3a40 r10=0x00000000 r11=0xc08d1e0c
r12=0xc08d1e10 r13=0xc08d1e00 r14=0xc03d4dfc
Parking CPU 0 (Cell: "Banana-Pi")
If i comment out the line in the bare-metal inmate where the register is written (in ivshmem_demo.c:send_irq(), mmio_write32(d->registers + 3, 1);), all seems to be well and I am able to verify that the shared memory has been updated by the bare-metal inmate from within the root cell. I've also been able to verify that the contents of the shared memory area is picked up by the bare-metal inmate. No interrupts from the inmate to the root cell though (of course).
Since I'm able to access the virtual PCI device register area using mmio_read32() from the inmate, it looks like the area has not been mapped for write access (by Jailhouse)? Am I missing some PCI device configuration entry?
I tried to find where the FATAL:-printouts come from and found traces to jailhouse/hypervisor/ivshmem.c:ivshmem_register_mmio() and jailhouse/hypervisor/arch/arm/traps.c:arch_handle_trap(). I don't know what to do with this information at the moment. Is it possible to dump some call-stack from the hypervisor when fatal errors occur?
> Getting an IRQ sent to the inmate will be more tricky, you will need to
> program the GIC where the x86 code does "int_set_handler". The gic-demo
> should give a clue.
Yep, I've started looking at this example. Thanks for verifying that this is the way forward.
>
> > Does the uio_ivshmem driver take care of generating interrupts from
> > the root-cell to the bare metal cell, or do I need to modify this as
> > well?
>
> The uio-driver does not actually do anything. It just makes the
> ressources of the "hardware" visible to userland. I suggest you have a
> look at the jailhouse specific README.
> https://github.com/henning-schild/ivshmem-guest-code/blob/jailhouse/README.jailhouse
> If you did not come across this file yet you might be on the wrong
> branch of ivshmem-guest-code.
I've seen it. I'm on the jailhouse branch of ivshmem-guest-code.
Thanks - Jonas
Hmm... Does the access originate from the root-cell, since the root cell is being parked, not the (non-root) cell in which the bare-metal inmate is running?
Can I turn on some more debugging info in the hypervisor?
/Jonas
Yes, that does do the trick!
Before starting the ivshmem-demo bare-metal inmate the interrupt count for ivshmem as reported by /proc/interrupts is zero. After having started the inmate it is one (I just write once to the LSTATE register from the inmate).
> I do not remember why the Status register is not implemented by
> jailhouse, maybe Jan does. Or i would have to read up in the archive
> and see whether it was ever part of the patchsets that introduced
> ivshmem.
>
Hehe - That was my next question...
> I just pushed a patch to the jailhouse-next branch, it compiles but i
> did not test it .... You could give it a try.
>
OK, I'm currently on v0.6. Do I want to switch to jailhouse-next in a hurry, or am I good for now on v0.6? Eventually I will move on to newer branches/tags, of course, and upstream my findings.
Thanks a bunch for the swift response - Jonas
Let's assume that I want to modify jailhouse/inmates/demos/arm/gic-demo.c to also handle ivshmem interrupts generated by the hypervisor to the bare-metal cell when writing the virtual PCI driver config area using uio_ivshmem/uio_send in the root-cell.
The first thing I would have to do is enable the IVSHMEM_IRQ in jailhouse/inmates/demos/arm/gic-demo.c:inmate_main() by calling gic_enable_irq(IVSHMEM_IRQ); in the same manner as gic_enable_irq(TIMER_IRQ);.
I would also have to check what irqn is passed in jailhouse/inmates/demos/arm/gic-demo.c:handle_IRQ(unsigned int irqn), in order to distinguish between TIMER_IRQ and IVSHMEM_IRQ, right?
TIMER_IRQ is defined (to 27) in jailhouse/inmates/lib/arm/include/mach.h. Where does this value come from?
How do I know what value to set IVSHMEM_IRQ to?
Still a bit confused - Jonas
Thanks Henning,
I tried the suggested additions to the bare-metal cell configuration and inmate, but no success yet. I use 'uio_send /dev/uio0 10 0 0' to fire 10 interrupts from the root-cell.
Any suggestions on how to proceed?
Verify that accesses to the virtual PCI device configuration area actually are made, intercepted by the hypervisor and interrupts generated to the bare-metal cell when running 'uio_send'?
/Jonas
Good suggestion! Actually, that is exactly what I did this morning.
In hypervisor/arch/arm-common/ivshmem.c:arch_ivshmem_trigger_interrupt(), I added:
```
printk("%s(ive:%p), irq_id:%d\n", __func__, ive, irq_id);
```
When running `uio_send /dev/uio0 10 0 0` I get:
```
[UIO] ping #0
[UIO] ping #1arch_ivshmem_trigger_interrupt(ive:0xf0047090), irq_id:0
[UIO] ping #2arch_ivshmem_trigger_interrupt(ive:0xf0047090), irq_id:0
[UIO] ping #3arch_ivshmem_trigger_interrupt(ive:0xf0047090), irq_id:0
[UIO] ping #4arch_ivshmem_trigger_interrupt(ive:0xf0047090), irq_id:0
[UIO] ping #5arch_ivshmem_trigger_interrupt(ive:0xf0047090), irq_id:0
[UIO] ping #6arch_ivshmem_trigger_interrupt(ive:0xf0047090), irq_id:0
[UIO] ping #7arch_ivshmem_trigger_interrupt(ive:0xf0047090), irq_id:0
[UIO] ping #8arch_ivshmem_trigger_interrupt(ive:0xf0047090), irq_id:0
[UIO] ping #9arch_ivshmem_trigger_interrupt(ive:0xf0047090), irq_id:0
[UIO] Exiting...
```
Hence, since irq_id is 0, no interrupt is set pending in the irqchip...
I also added a printout in `hypervisor/arch/arm-common/irqchip.c`:
``` if ((irq_id != 30) && (irq_id != 33)) {
printk("%s(cpu_data:%p, irq_id:%d)\n", __func__, cpu_data, irq_id);
}
```
which shows a lot of interrupts being handled (I had to filter out 30 (PPI 14) and 33 (UART 0) in order not to drown in printouts at startup).
I can then see printouts for IRQ 2, (SGI 2), 4 (SGI 4), 64 (SD/MMC 0), 140 (IVSHMEM_IRQ for root-cell???, 108+32, as my root-cell config contains:`config.cell.vpci_irq_base = 108`?), and eventually when reaching steady state, only 117 (GMAC).
I'm guessing that I should have seen corresponding printouts for IRQ 155 (123+32, as my bare-metal cell contains:`config.cell.vpci_irq_base = 123`) if all would have been OK?
I've used the A20 User Manual Revision 1.0 Feb. 18, 2013 from Allwinner as reference for interrupt source numbers mentioned above.
According to this, it seems like 108 coincides with GPU-RSV0.
/Jonas
Sorry for asking a question that is regarding the porting of ivshmem-demo.c.
As mentioned, I was trying to replicate pci.c for the arm and I am facing some issues.
I have converted the pci_read_config() and pci_write_config() using mmio.
I have used Code that is similar to that can be found in the
hypervisor. hypervisor/pci.c include/jailhouse/mmio.h
The mmcfg_address = PCI_get_device_mmcfg_base(bdf) + address in which I replaced the function call with value from the root cell configuration " 0x48000000". But then the PCI_read/write_config() doesn't require bdf to be passed as a parameter?
Please support regarding the porting of ivshmem-demo.c to arm.
Yay! It works!
> > I also added a printout in `hypervisor/arch/arm-common/irqchip.c`:
> > ``` if ((irq_id != 30) && (irq_id != 33)) {
> > printk("%s(cpu_data:%p, irq_id:%d)\n", __func__,
> > cpu_data, irq_id); }
> > ```
> > which shows a lot of interrupts being handled (I had to filter out 30
> > (PPI 14) and 33 (UART 0) in order not to drown in printouts at
> > startup).
> >
> > I can then see printouts for IRQ 2, (SGI 2), 4 (SGI 4), 64 (SD/MMC
> > 0), 140 (IVSHMEM_IRQ for root-cell???, 108+32, as my root-cell config
> > contains:`config.cell.vpci_irq_base = 108`?), and eventually when
> > reaching steady state, only 117 (GMAC).
> >
> > I'm guessing that I should have seen corresponding printouts for IRQ
> > 155 (123+32, as my bare-metal cell
> > contains:`config.cell.vpci_irq_base = 123`) if all would have been OK?
> >
> > I've used the A20 User Manual Revision 1.0 Feb. 18, 2013 from
> > Allwinner as reference for interrupt source numbers mentioned above.
> >
> > According to this, it seems like 108 coincides with GPU-RSV0.
>
> I guess the vpci_irq_base for a SoC would be the last irq the thing
> uses plus some alignment. Jailhouse is using 140 not 108.
The last interrupt source number used by A20 is 122 (IIS 2), so the first unused is 123.
>
> Henning
>
> > /Jonas
Sorry to pick this up after this time, but I would be interested in the pci.c modifications related to ARM for inmates (using MMIO instead of PIO).
Was there a follow-up to the discussions above?(checked out the discussion archives but I can't find any). I would like to avoid re-inventing the wheel if there's one already rolling.
Thanks,
Constantin
Hey,
unfortunately Jonas never published his overall changes, maybe now he
understands why i kindly asked him to do so.
I think Jonas maybe ran into every single problem one could encounter
on the way, so if you read the thread you will probably be able to come
up with a similar patch at some point. That would be the duplication of
efforts, getting a first working patch into a mergeable form is another
story.
If there are legal reasons to not publish code on the list i suggest
you exchange patches between each other. But of cause i would like to
see contributions eventually ;).
Hi,
I'll be making an effort to contribute my work to the master branch of Jailhouse within the next couple of weeks.