On Monday, April 9, 2018 at 8:26:56 PM UTC+8, Qiu Shui wrote:
> On Monday, April 9, 2018 at 5:40:48 PM UTC+8, Qiu Shui wrote:
> > On Monday, April 9, 2018 at 2:19:13 PM UTC+8, J. Kiszka wrote:
> > > On 2018-04-09 02:42, Qiu Shui wrote:
> > > > On Sunday, April 8, 2018 at 2:18:28 PM UTC+8, Qiu Shui wrote:
> > > >> On Sunday, April 8, 2018 at 11:29:01 AM UTC+8, Qiu Shui wrote:
> > > >>> On Monday, April 2, 2018 at 4:33:40 PM UTC+8, Qiu Shui wrote:
> > > >>>> On Monday, April 2, 2018 at 3:05:08 PM UTC+8, Nikhil Devshatwar 
> > > >>>> wrote:
> > > >>>>> On Monday 02 April 2018 11:16 AM, Qiu Shui wrote:
> > > >>>>>> On Monday, April 2, 2018 at 11:12:12 AM UTC+8, Qiu Shui wrote:
> > > >>>>>>> On Thursday, March 29, 2018 at 1:09:46 PM UTC+8, Jan Kiszka wrote:
> > > >>>>>>>> On 2018-03-29 06:36, Qiu Shui wrote:
> > > >>>>>>>>> I build the armbian with these two patches to the kernel:
> > > >>>>>>>>> [1]
> > > >>>>>>>>> http://git.kiszka.org/?p=linux.git;a=commit;h=f057e9bb4ba2fca0b435d36893eb41ddd57b4208
> > > >>>>>>>>> [2]
> > > >>>>>>>>> http://git.kiszka.org/?p=linux.git;a=commit;h=1c926e27072d4cca76a756058554485067ce472b
> > > >>>>>>>>>
> > > >>>>>>>>> But when I build jailhouse with the armbian kernel source 
> > > >>>>>>>>> files(version: Linux orangepizero 4.16.0-rc6-sunxi #2 SMP Wed 
> > > >>>>>>>>> Mar 28 15:33:44 CST 2018 armv7l GNU/Linux), I got these 
> > > >>>>>>>>> warnings:
> > > >>>>>>>>> WARNING: "__stack_chk_fail" 
> > > >>>>>>>>> [/home/liu/project/kiszka/jailhouse-0.8/driver/jailhouse.ko] 
> > > >>>>>>>>> undefined!
> > > >>>>>>>>> WARNING: "__hyp_stub_vectors" 
> > > >>>>>>>>> [/home/liu/project/kiszka/jailhouse-0.8/driver/jailhouse.ko] 
> > > >>>>>>>>> undefined!
> > > >>>>>>>>> WARNING: "__stack_chk_guard" 
> > > >>>>>>>>> [/home/liu/project/kiszka/jailhouse-0.8/driver/jailhouse.ko] 
> > > >>>>>>>>> undefined!
> > > >>>>>>>>>
> > > >>>>>>>>> I have tried some google solutions but still not solved.
> > > >>>>>>>>>
> > > >>>>>>>>> Are there any suggestions?
> > > >>>>>>>>
> > > >>>>>>>> Regarding __hyp_stub_vectors: you also need
> > > >>>>>>>> http://git.kiszka.org/?p=linux.git;a=commitdiff;h=2a681cb2213e3ea0f142fae7345fb80208a88a53
> > > >>>>>>>>
> > > >>>>>>>> The other two issue seem to be related to some build 
> > > >>>>>>>> inconsistency: Your
> > > >>>>>>>> kernel was built without CONFIG_CC_STACKPROTECTOR, but when you 
> > > >>>>>>>> build
> > > >>>>>>>> the Jailhouse module, this feature is considered to be enabled.
> > > >>>>>>>>
> > > >>>>>>>> Jan
> > > >>>>>>>
> > > >>>>>>> Thank you very much!
> > > >>>>>>> After two days trying, I've finally built the kernel and 
> > > >>>>>>> jailhouse module successfully.
> > > >>>>>>> (I am using armbian building scripts and modified the 
> > > >>>>>>> linux-sunxi-dev.config with "# CONFIG_THUMB2_KERNEL is not set")
> > > >>>>>>>
> > > >>>>>>> Now I can enable jailhouse and create cell:
> > > >>>>>>> # jailhouse enable configs/orangepi0.cell
> > > >>>>>>> # jailhouse cell create configs/orangepi0-gic-demo.cell
> > > >>>>>>> # jailhouse cell list
> > > >>>>>>> ID      Name                    State           Assigned CPUs     
> > > >>>>>>>       Failed CPUs
> > > >>>>>>> 0       Orange-Pi0              running         0,2-3
> > > >>>>>>> 1       orangepi0-gic-demo      shut down       1
> > > >>>>>>>
> > > >>>>>>> But when I load the gic-demo.bin, it failed:
> > > >>>>>>> # jailhouse cell load orangepi0-gic-demo 
> > > >>>>>>> inmates/demos/arm/gic-demo.bin
> > > >>>>>>> Unhandled data read at 0x1f00000(4)
> > > >>>>>>> FATAL: unhandled trap (exception class 0x24)
> > > >>>>>>> pc=0xc08cc6c0 cpsr=0x20000013 hsr=0x93830007
> > > >>>>>>> r0=0x00000190 r1=0x00020000 r2=0x0000a035 r3=0xcf807000
> > > >>>>>>> r4=0xcda54e10 r5=0xc1103d00 r6=0x00300402 r7=0xcd8d7480
> > > >>>>>>> r8=0x0002300c r9=0x00000285 r10=0x00000000 r11=0xcda47df4
> > > >>>>>>> r12=0x00300000 r13=0xcda47dd0 r14=0xc08c9ab8
> > > >>>>>>> Parking CPU 3 (Cell: "Orange-Pi0")
> > > >>>>>>> Cell "orangepi0-gic-demo" can be loaded
> > > >>>>>>>
> > > >>>>>>> Any suggestions would be greatly appreciated :)
> > > >>>>>>>
> > > >>>>>>> Is there any demo can be used to make sure my jailhouse 
> > > >>>>>>> environments are ready?
> > > >>>>>>>
> > > >>>>>>> Thanks!
> > > >>>>>>
> > > >>>>>> I solved this problem by trying some different memory 
> > > >>>>>> configurations.
> > > >>>>>> The following does work:
> > > >>>>>> mem=448M vmalloc=256M
> > > >>>>>> /* Orangepi0.c */
> > > >>>>>>            .hypervisor_memory = {
> > > >>>>>>                    .phys_start = 0x5f800000,
> > > >>>>>>                    .size = 0x800000,
> > > >>>>>>            },
> > > >>>>>> ...
> > > >>>>>>            /* RAM */ {
> > > >>>>>>                    .phys_start = 0x40000000,
> > > >>>>>>                    .virt_start = 0x40000000,
> > > >>>>>>                    .size =        0x1f700000,
> > > >>>>>>                    .flags = JAILHOUSE_MEM_READ | 
> > > >>>>>> JAILHOUSE_MEM_WRITE |
> > > >>>>>>                            JAILHOUSE_MEM_EXECUTE,
> > > >>>>>>            },
> > > >>>>>>            /* IVSHMEM shared memory region */ {
> > > >>>>>>                    .phys_start = 0x5f700000,
> > > >>>>>>                    .virt_start = 0x5f700000,
> > > >>>>>>                    .size =         0x100000,
> > > >>>>>>                    .flags = JAILHOUSE_MEM_READ | 
> > > >>>>>> JAILHOUSE_MEM_WRITE,
> > > >>>>>>            },
> > > >>>>>> --------
> > > >>>>>>
> > > >>>>>> But if I use the following configuration. When I enable jailhouse, 
> > > >>>>>> it says "JAILHOUSE_ENABLE: Invalid argument".
> > > >>>>>> /* orangepi0.c */
> > > >>>>>>            .hypervisor_memory = {
> > > >>>>>>                    .phys_start = 0x5c000000,
> > > >>>>>>                    .size = 0x4000000,
> > > >>>>>>            },
> > > >>>>>> ......
> > > >>>>>>            /* RAM */ {
> > > >>>>>>                    .phys_start = 0x40000000,
> > > >>>>>>                    .virt_start = 0x40000000,
> > > >>>>>>                    .size =        0x1bf00000,
> > > >>>>>>                    .flags = JAILHOUSE_MEM_READ | 
> > > >>>>>> JAILHOUSE_MEM_WRITE |
> > > >>>>>>                            JAILHOUSE_MEM_EXECUTE,
> > > >>>>>>            },
> > > >>>>>>            /* IVSHMEM shared memory region */ {
> > > >>>>>>                    .phys_start = 0x5bf00000,
> > > >>>>>>                    .virt_start = 0x5bf00000,
> > > >>>>>>                    .size =         0x100000,
> > > >>>>>>                    .flags = JAILHOUSE_MEM_READ | 
> > > >>>>>> JAILHOUSE_MEM_WRITE,
> > > >>>>>>            },
> > > >>>>>> --------
> > > >>>>>> cat /proc/iomem
> > > >>>>>> 01c02000-01c02fff : dma-controller@1c02000
> > > >>>>>> 01c0f000-01c0ffff : mmc@1c0f000
> > > >>>>>> 01c10000-01c10fff : mmc@1c10000
> > > >>>>>> 01c19000-01c193ff : usb@1c19000
> > > >>>>>>    01c19000-01c193ff : usb@1c19000
> > > >>>>>> 01c19400-01c1942b : phy_ctrl
> > > >>>>>> 01c1a000-01c1a0ff : usb@1c1a000
> > > >>>>>> 01c1a400-01c1a4ff : usb@1c1a400
> > > >>>>>> 01c1a800-01c1a803 : pmu0
> > > >>>>>> 01c1b000-01c1b0ff : usb@1c1b000
> > > >>>>>> 01c1b400-01c1b4ff : usb@1c1b400
> > > >>>>>> 01c1b800-01c1b803 : pmu1
> > > >>>>>> 01c1c000-01c1c0ff : usb@1c1c000
> > > >>>>>> 01c1c400-01c1c4ff : usb@1c1c400
> > > >>>>>> 01c1c800-01c1c803 : pmu2
> > > >>>>>> 01c1d000-01c1d0ff : usb@1c1d000
> > > >>>>>> 01c1d400-01c1d4ff : usb@1c1d400
> > > >>>>>> 01c1d800-01c1d803 : pmu3
> > > >>>>>> 01c20000-01c203ff : clock@1c20000
> > > >>>>>> 01c20800-01c20bff : pinctrl@1c20800
> > > >>>>>> 01c20ca0-01c20cbf : watchdog@1c20ca0
> > > >>>>>> 01c28000-01c2801f : serial
> > > >>>>>> 01c30000-01c3ffff : ethernet@1c30000
> > > >>>>>> 01f00000-01f00053 : rtc@1f00000
> > > >>>>>> 01f01400-01f014ff : clock@1f01400
> > > >>>>>> 01f015c0-01f015c3 : codec-analog@1f015c0
> > > >>>>>> 01f02c00-01f02fff : pinctrl@1f02c00
> > > >>>>>> 40000000-5bffffff : System RAM
> > > >>>>>>    40008000-40ffffff : Kernel code
> > > >>>>>>    41100000-412296cb : Kernel data
> > > >>>>>> ---------
> > > >>>>>> I don't know what's wrong with the second cell configuration
> > > >>>>>
> > > >>>>> Make sure that the region described by .hypervisor_memory in the 
> > > >>>>> config matches with the
> > > >>>>> reserved_memory node in the root cell device tree.
> > > >>>>> EINVAL is possibly due to the mismatch in root cell DT and root 
> > > >>>>> cell config.
> > > >>>>>
> > > >>>>> Nikhil D
> > > >>>>>
> > > >>>>>>
> > > >>>>>> Thanks!
> > > >>>>>>
> > > >>>>
> > > >>>> After trying different parameters combination, I found that:
> > > >>>>              .hypervisor_memory = {
> > > >>>>                      .phys_start = 0x5f000000,
> > > >>>>                      .size = 0x1000000,
> > > >>>> where the "size" can not exceed "0x1000000".
> > > >>>
> > > >>> I want to use FreeRTOS on my second core. So I tried 
> > > >>> "https://github.com/siemens/freertos-cell.git"; project.
> > > >>> After some modifications, I finally reached these errors:
> > > >>> arm-linux-gnueabihf-ld -T lscript.lds -o freertos-demo.elf main.o 
> > > >>> boot_stub.o libfreertos.a
> > > >>> libfreertos.a(serial.o): In function `serial_irq_getchar':
> > > >>> serial.c:(.text+0xaa): undefined reference to `__printf_chk'
> > > >>> serial.c:(.text+0xbe): undefined reference to `__printf_chk'
> > > >>> serial.c:(.text+0xd4): undefined reference to `__printf_chk'
> > > >>> libfreertos.a(gic-v2.o): In function `gic_v2_init':
> > > >>> gic-v2.c:(.text+0x2c): undefined reference to `__printf_chk'
> > > >>> libfreertos.a(gic-v2.o): In function `gic_v2_irq_set_prio':
> > > >>> gic-v2.c:(.text+0xc4): undefined reference to `__printf_chk'
> > > >>> libfreertos.a(gic-v2.o):gic-v2.c:(.text+0xdc): more undefined 
> > > >>> references to `__printf_chk' follow
> > > >>> Makefile:49: recipe for target 'freertos-demo.elf' failed
> > > >>> make: *** [freertos-demo.elf] Error 1
> > > >>>
> > > >>> I have tried to include libc.a or libc.so by adding "-l" options to 
> > > >>> compiler but still failed.
> > > >>>
> > > >>> Are there any suggestions? 
> > > >>>
> > > >>> Thanks a lot!
> > > >>
> > > >> I changed the cross compiler from version "arm-linux-gnueabihf-gcc 
> > > >> (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609" to 
> > > >> "arm-linux-gnueabihf-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011".
> > > >>
> > > >> The problem solved but I don't know why!
> > > > 
> > > > I can build and create cell for FreeRTOS. But when I load the 
> > > > "freertos-demo.bin",it said "JAILHOUSE_CELL_LOAD: Invalid argument". My 
> > > > cell config file attached. Are there any other parameters need to 
> > > > modify? Thanks a lot!
> > > 
> > > Your guest RAM region is ID-mapped, i.e. it starts at the same virtual
> > > address like its physical one. However, the reset address of the VCPU is
> > > 0, and that is also where jailhouse cell load puts artifacts by default.
> > > You need at least the startup stub of your cell at address 0, thus you
> > > need memory there.
> > > 
> > > ID-mapping for RAM may still make sense if you do DMA: the Orange PI
> > > lack a SMMU (IOMMU) to translate virtual to physical DMA addresses. If
> > > you don't do DMA, you are free with your guest virtual memory layout.
> > > 
> > > Jan
> > > 
> > > -- 
> > > Siemens AG, Corporate Technology, CT RDA IOT SES-DE
> > > Corporate Competence Center Embedded Linux
> > 
> > Thanks for your help! My OrangePi Zero does work.
> 
> Orange PI Zero's processor Allwinner H2+ doesn't support SMMU. In the 
> attached non-root-linux demo config file, what's the following section for?
>               /* RAM */ {
>                       .phys_start = 0x57000000,
>                       .virt_start = 0x57000000,
>                       .size = 0x7ef0000,
>                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
>                               JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
>                               JAILHOUSE_MEM_LOADABLE,
>               },
> 
> Thanks!
> 
> Dong

When I run Free-RTOS cell, I found I couldn't modify the UART 1 registers by 
the following codes:
        mmio_write32(uart_base + UART_LCR, UART_LCR_8N1);
        mmio_write32(uart_base + UART_IER, 0); /* IRQ off */
        mmio_write32(uart_base + UART_FCR, 0x7); /* FIFO reset and enable */
        mmio_write32(uart_base + UART_MCR, 0x3); /* DTR + RTS on */

        /* Set Divisor Latch Access Bit */
        mmio_write32(uart_base + UART_LCR, UART_LCR_DLAB | 
mmio_read32(uart_base + UART_LCR));
        /* Program baudrate */
        mmio_write32(uart_base + UART_DLL, 0xff & divisor); /* Divisor Latch 
Low Register */
        mmio_write32(uart_base + UART_DLM, 0xff & (divisor >> 8)); /* Divisor 
Latch High Register */
        mmio_write32(uart_base + UART_LCR, ~UART_LCR_DLAB & 
mmio_read32(uart_base + UART_LCR));

Attached are my root cell and guest cell configuration files.

How to access the IOMEM in the cell? Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jailhouse-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
/*
 * Jailhouse, a Linux-based partitioning hypervisor
 *
 * Test configuration for Orange Pi Zero (H2+ quad-core Cortex-A7, 256MB RAM)
 *
 * Copyright (c) Siemens AG, 2014-2016
 *
 * Authors:
 *  Jan Kiszka <jan.kis...@siemens.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2.  See
 * the COPYING file in the top-level directory.
 */

#include <jailhouse/types.h>
#include <jailhouse/cell-config.h>

#define ARRAY_SIZE(a) sizeof(a) / sizeof(a[0])

struct {
	struct jailhouse_system header;
	__u64 cpus[1];
	struct jailhouse_memory mem_regions[11];
	struct jailhouse_irqchip irqchips[1];
	struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
	.header = {
		.signature = JAILHOUSE_SYSTEM_SIGNATURE,
		.revision = JAILHOUSE_CONFIG_REVISION,
		.hypervisor_memory = {
			.phys_start = 0x5f000000,
			.size = 0x1000000,
		},
		.debug_console = {
			.address = 0x01c28000,
			.size = 0x0400,
			/* .clock_reg = 0x01c2006c, */
			/* .gate_nr = 16, */
			/* .divider = 0x0d, */
			.flags = JAILHOUSE_CON1_TYPE_8250 |
				 JAILHOUSE_CON1_ACCESS_MMIO |
				 JAILHOUSE_CON1_REGDIST_4 |
				 JAILHOUSE_CON2_TYPE_ROOTPAGE,
		},
		.platform_info = {
			.pci_mmconfig_base = 0x2000000,
			.pci_mmconfig_end_bus = 0,
			.pci_is_virtual = 1,
			.arm = {
				.gic_version = 2,
				.gicd_base = 0x01c81000,
				.gicc_base = 0x01c82000,
				.gich_base = 0x01c84000,
				.gicv_base = 0x01c86000,
				.maintenance_irq = 25,
			},
		},
		.root_cell = {
			.name = "Orange-Pi0",

			.cpu_set_size = sizeof(config.cpus),
			.num_memory_regions = ARRAY_SIZE(config.mem_regions),
			.num_irqchips = ARRAY_SIZE(config.irqchips),
			.num_pci_devices = ARRAY_SIZE(config.pci_devices),

			.vpci_irq_base = 108,
		},
	},

	.cpus = {
		0xf,
	},

	.mem_regions = {
		/* MMIO 1 (permissive) */ {
			.phys_start = 0x01c00000,
			.virt_start = 0x01c00000,
			.size =          0x20000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_IO,
		},
		/* PIO: port ACDEFGL */ {
			.phys_start = 0x01c20800,
			.virt_start = 0x01c20800,
			.size =            0x400,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32 |
				JAILHOUSE_MEM_ROOTSHARED,
		},
		/* Timer */ {
			.phys_start = 0x01c20c00,
			.virt_start = 0x01c20c00,
			.size =             0xa0,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32,
		},
		/* watchdog */ {
			.phys_start = 0x01c20ca0,
			.virt_start = 0x01c20ca0,
			.size =             0x20,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32,
		},
		/* UART 0 */ {
			.phys_start = 0x01c28000,
			.virt_start = 0x01c28000,
			.size =             0x20,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32 |
				JAILHOUSE_MEM_ROOTSHARED,
		},
		/* UART 1 */ {
			.phys_start = 0x01c28400,
			.virt_start = 0x01c28400,
			.size =             0x20,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32 |
				JAILHOUSE_MEM_ROOTSHARED,
		},
		/* Ethernet */ {
			.phys_start = 0x01c30000,
			.virt_start = 0x01c30000,
			.size =          0x10000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32,
		},
		/* RTC */ {
			.phys_start = 0x01f00000,
			.virt_start = 0x01f00000,
			.size =            0x400,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32 |
				JAILHOUSE_MEM_ROOTSHARED,
		},
		/* MMIO 3 (permissive) */ {
			.phys_start = 0x01f01000,
			.virt_start = 0x01f01000,
			.size =           0x3000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_IO,
		},
		/* RAM */ {
			.phys_start = 0x40000000,
			.virt_start = 0x40000000,
			.size =       0x1ef00000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_EXECUTE,
		},
		/* IVSHMEM shared memory region */ {
			.phys_start = 0x5ef00000,
			.virt_start = 0x5ef00000,
			.size =         0x100000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
	},

	.irqchips = {
		/* GIC */ {
			.address = 0x01c82000,
			.pin_base = 32,
			.pin_bitmap = {
				0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
			},
		},
	},

	.pci_devices = {
		{
			.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
			.bdf = 0x00,
			.bar_mask = {
				0xffffff00, 0xffffffff, 0x00000000,
				0x00000000, 0x00000000, 0x00000000,
			},
			.shmem_region = 10,
			.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
		},
	},
};
/*
 * Jailhouse, a Linux-based partitioning hypervisor
 *
 * Configuration for linux-demo inmate on Orange Pi Zero:
 * 1 CPU, 64M RAM, serial port 0
 *
 * Copyright (c) Siemens AG, 2014-2017
 *
 * Authors:
 *  Jan Kiszka <jan.kis...@siemens.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2.  See
 * the COPYING file in the top-level directory.
 */

#include <jailhouse/types.h>
#include <jailhouse/cell-config.h>

#define ARRAY_SIZE(a) sizeof(a) / sizeof(a[0])

#define MBYTE(m) ((m)<<20)

/* Root-Cell linux mem: 40000000-59ffffff, 416M */
/* 		Guest cell mem: 5a000000-5eefffff, 79M  */
/*		    Shared mem: 5ef00000-5effffff, 1M   */
/*      Hypervisor mem:	5f000000-5fffffff, 16M  */

/*	 FreeRTOS cell mem: 5b000000-5bffffff, 16M  */
#define GUEST_MEM_START 0x5B000000
#define GUEST_MEM_SIZE MBYTE(16)

#define IVSH_MEM_START 	0x5ef00000
#define IVSH_MEM_SIZE MBYTE(1)


struct {
	struct jailhouse_cell_desc cell;
	__u64 cpus[1];
	struct jailhouse_memory mem_regions[4];
	struct jailhouse_irqchip irqchips[1];
	struct jailhouse_pci_device pci_devices[1];
} __attribute__((packed)) config = {
	.cell = {
		.signature = JAILHOUSE_CELL_DESC_SIGNATURE,
		.revision = JAILHOUSE_CONFIG_REVISION,
		.name = "FreeRTOS",
		.flags = JAILHOUSE_CELL_PASSIVE_COMMREG|JAILHOUSE_CELL_DEBUG_CONSOLE,

		.cpu_set_size = sizeof(config.cpus),
		.num_memory_regions = ARRAY_SIZE(config.mem_regions),
		.num_irqchips = ARRAY_SIZE(config.irqchips),
		.num_pci_devices = ARRAY_SIZE(config.pci_devices),

		.vpci_irq_base = 123,
	},

	.cpus = {
		0x4,
	},

	.mem_regions = {
		/* PIO: port ACDEFGL */ {
			.phys_start = 0x01c20800,
			.virt_start = 0x01c20800,
			.size =            0x400,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32 |
				JAILHOUSE_MEM_ROOTSHARED,
		},
		/* UART 1 */ {
			.phys_start = 0x01c28400,
			.virt_start = 0x01c28400,
			.size =             0x20,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32 |
				JAILHOUSE_MEM_ROOTSHARED,
		},
		/* RAM */ {
			.phys_start = GUEST_MEM_START,
			.virt_start = 0,
			.size = GUEST_MEM_SIZE,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_LOADABLE,
		},
		/* IVSHMEM shared memory region */ {
			.phys_start = IVSH_MEM_START,
			.virt_start = IVSH_MEM_START,
			.size = IVSH_MEM_SIZE,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_ROOTSHARED,
		},
	},

	.irqchips = {
		/* GIC */ {
			.address = 0x01c82000,
			.pin_base = 32,
			/* Interrupt of UART 1 belongs to the client */
			.pin_bitmap = {
				1 << (33-32), 
			},
		},
	},

	.pci_devices = {
		{
			.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
			.bdf = 0x00,
			.bar_mask = {
				0xffffff00, 0xffffffff, 0x00000000,
				0x00000000, 0x00000000, 0x00000000,
			},
			.shmem_region = 3,
			.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
		},
	},
};

Reply via email to