Here is my current linux inmate cell configuration for my OK8MP
board(imx8mp CPU, 2G RAM + 16G eMMC version), I didn't change the imx8mp.c
for now.
I edited the RAM region as:
/* RAM */ {
/*
* We could not use 0x80000000 which conflicts with
* COMM_REGION_BASE
*/
.phys_start = 0x60000000,
.virt_start = 0x60000000,
.size = 0x10000000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
On Tuesday, January 9, 2024 at 8:19:59 PM UTC+8 wheatfox wrote:
> Thanks for your instruction! I tried to edit the linux inmate cell
> configuration file (imx8mp-linux-demo.c) and I finally get the linux inmate
> to boot, so I think it was mainly a memory region misconfiguration problem.
> (However, the boot progress failed due to VFS fatal error, which I will
> investigate later...)
> The current full output log is attached as attachment.
>
> On Monday, January 8, 2024 at 7:12:46 PM UTC+8 Ralf Ramsauer wrote:
>
>> Hi,
>>
>> On 08/01/2024 09:26, wheatfox wrote:
>> > I'm using OK8MP board with i.MX8MP CPU. I have already started
>> jailhouse
>> > with imx8mp.cell configuration, and the example gic-demo works fine.
>> > However, when I try to start a linux inmate using
>> > imx8mp-linux-demo.cell, the jailhouse's load progress seems stuck.
>> >
>> > After adding some debug print in jailhouse's python script, firmware
>> > code and kernel module code, I found out that the *copy_from_user* call
>> > in *load_image* function (driver/cell.c) doesn't return and halt
>> forever: >
>> > jailhouse commands:
>> > ./tools/jailhouse enable ./imx8mp.cell
>> > ./tools/jailhouse cell linux \
>> > ./imx8mp-linux-demo.cell \
>> > ./kernel/Image \
>> > -i ./kernel/ramdisk.img \
>>
>> For testing, try to not load the ramdisk. The kernel should at least
>> boot and crash. If that works, we know that there's something odd with
>> the ramdisk.
>>
>> Second, double and triple check addresses where things get loaded.
>> What's in your non-root cell configuration, and where does the
>> linux-loader try to load stuff? Does that match?
>>
>> Thanks,
>> Ralf
>>
>> > -d ./kernel/imx8mp-evk-inmate-wheatfox.dtb \
>> > -c "clk_ignore_unused console=ttymxc1,0x30890000,115200
>> > earlycon=ec_imx6q,0x30890000,115200"
>> >
>> > start linux cell output(with the string 'wheatfox' means it's my custom
>> > debug print):
>> > root@OK8MP:/mnt# ./start-linux.sh
>> > [wheatfox|python] Jailhouse Linux Cell Boot Helper
>> > [wheatfox|python] linux_loader=/m[ 129.965933] [wheatfox]
>> > (jailhouse_ioctl) ioctl=0x5401 arg=281474720244744
>> > nt/tools/../inmates/tools/arm64/l[ 129.975611] [wheatfox]
>> > (jailhouse_ioctl) ioctl=0x5401 arg=281474720244728
>> > inux-loader.bin
>> > [ 129.988033] [wheatfox] (jailhouse_ioctl) ioctl=0x40100002
>> > arg=281474720244800
>> > [ 129.995192] [wheatfox] (jailhouse_ioctl) JAILHOUSE_CELL_CREATE
>> > [ 130.001072] [wheatfox] (jailhouse_cmd_cell_create) start
>> > [ 130.006404] [wheatfox] (jailhouse_cmd_cell_create) copy_from_user
>> done
>> > [ 130.012960] [wheatfox] (jailhouse_cmd_cell_create) copy_from_user
>> done
>> > [ 130.019507] [wheatfox] (jailhouse_cmd_cell_create) cell_id.id = -1
>> > [ 130.095151] IRQ 6: no longer affine to CPU2
>> > [ 130.095333] CPU2: shutdown
>> > [ 130.102251] psci: CPU2 killed (polled 0 ms)
>> > [ 130.155283] CPU3: shutdown
>> > [ 130.157999] psci: CPU3 killed (polled 0 ms)
>> > [wheatfox] in hypercall, code = 1, arg1 = 2955416576, arg2 = 2
>> > [wheatfox] in hypercall, JAILHOUSE_HC_CELL_CREATE
>> > Adding virtual PCI device 00:00.0 to cell "linux-inmate-demo"
>> > Shared memory connection established, peer cells:
>> > "imx8mp"
>> > Adding virtual PCI device 00:01.0 to cell "linux-inmate-demo"
>> > Shared memory connection established, peer cells:
>> > "imx8mp"
>> > [wheatfox] in resume_cpu, cpu_id = 2
>> > [wheatfox] in resume_cpu, target_data->cpu_suspended = 1
>> > [wheatfox] in resume_cpu, cpu_id = 3
>> > [wheatfox] in resume_cpu, target_data->cpu_suspended = 1
>> > Created cell "linux-inmate-demo"
>> > Page pool usage after cell creation: mem 82/992, remap 144/131072
>> > [wheatfox] in resume_cpu, cpu_id = 0
>> > [wheatfox] in resume_cpu, target_data->cpu_suspended = 1
>> > [ 130.231800] [wheatfox] (jailhouse_cmd_cell_create) Created cell
>> > "linux-inmate-demo"
>> > [wheatfox|python] cell created,
>> >
>> name=b'linux-inmate-demo\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
>>
>>
>> > [wheatf[ 130.249264] [wheatfox] (jailhouse_ioctl) ioctl=0x40300003
>> > arg=281474720245360
>> > ox|python] trying to load linux_l[ 130.257905] [wheatfox]
>> > (jailhouse_ioctl) JAILHOUSE_CELL_LOAD
>> > oader.bin into cell, addr=0x0
>> > [ 130.266684] [wheatfox] (jailhouse_cmd_cell_load) start
>> > [ 130.274322] [wheatfox] (jailhouse_cmd_cell_load)
>> > cell_management_prologue(&cell_load.cell_id, &cell) done
>> > [wheatfox] in hypercall, code = 3, arg1 = 1, arg2 = 4308871775073466112
>> > [wheatfox] in hypercall, JAILHOUSE_HC_CELL_SET_LOADABLE
>> > [wheatfox] in cell_set_loadable, id = 1
>> > [wheatfox] cell_management_prologue finished
>> > [wheatfox] in resume_cpu, cpu_id = 2
>> > [wheatfox] in resume_cpu, target_data->cpu_suspended = 1
>> > [wheatfox] in resume_cpu, cpu_id = 3
>> > [wheatfox] in resume_cpu, target_data->cpu_suspended = 1
>> > [wheatfox] finished arch_park_cpu
>> > [wheatfox] cell->loadable = 0
>> > [wheatfox] not jumped to out_resume
>> > Cell "linux-inmate-demo" can be loaded
>> > [wheatfox] in out_resume
>> > [wheatfox] in resume_cpu, cpu_id = 1
>> > [wheatfox] in resume_cpu, target_data->cpu_suspended = 1
>> > [ 130.342417] [wheatfox] (jailhouse_cmd_cell_load)
>> > jailhouse_call_arg1(JAILHOUSE_HC_CELL_SET_LOADABLE, cell->id) done
>> > [ 130.353079] [wheatfox] (jailhouse_cmd_cell_load)
>> > cell_load.num_preload_images = 1
>> > [ 130.360584] [wheatfox] (jailhouse_cmd_cell_load) load_image(cell,
>> > image) start, n = 1
>> > [ 130.368444] [wheatfox] (load_image) start
>> > [ 130.372468] [wheatfox] (load_image) copy_from_user done
>> > [ 130.377712] [wheatfox] (load_image) image.size = 34b0
>> > [ 130.382776] [wheatfox] (load_image) found suitable memory region,
>> > mem->virt_start = 0, mem->size = 10000
>> > [ 130.392280] [wheatfox] (load_image) image load mem region found
>> > [ 130.398228] [wheatfox] (load_image) phys_start = fdb00000
>> > [ 130.403653] [wheatfox] (load_image) page_offs = 0
>> > [ 130.408373] [wheatfox] (load_image) image_mem = 0000000079dd6ce3
>> > [ 130.414405] [wheatfox] (load_image) copy_from_user params:
>> > [ 130.419905] [wheatfox] (load_image) to = 0000000079dd6ce3
>> > [ 130.425329] [wheatfox] (load_image) from = 00000000c239ec71
>> > [ 130.430915] [wheatfox] (load_image) n = 34b0
>> > [ 130.435220] [wheatfox] (load_image) copy_from_user start
>> > [ 130.440563] [wheatfox] (load_image) copy_from_user done
>> > [ 130.445822] [wheatfox] (load_image) flush_icache_range done
>> > [ 130.451429] [wheatfox] (jailhouse_cmd_cell_load) load_image(cell,
>> > image) done, n = 1
>> > [ 130.459186] [wheatfox] (jailhouse_cmd_cell_load) unlock_out done,
>> > exiting jailhouse_cmd_cell_load
>> > [wheatfox|python] linux_loader.bin loaded
>> > [wheatfox|python] trying to load kernel into cell, addr=0xc0280000
>> > [ 130.500262] [wheatfox] (jailhouse_ioctl) ioctl=0x40300003
>> > arg=281474720245360
>> > [ 130.507454] [wheatfox] (jailhouse_ioctl) JAILHOUSE_CELL_LOAD
>> > [ 130.513165] [wheatfox] (jailhouse_cmd_cell_load) start
>> > [ 130.518321] [wheatfox] (jailhouse_cmd_cell_load)
>> > cell_management_prologue(&cell_load.cell_id, &cell) done
>> > [wheatfox] in hypercall, code = 3, arg1 = 1, arg2 = 4308871775073466112
>> > [wheatfox] in hypercall, JAILHOUSE_HC_CELL_SET_LOADABLE
>> > [wheatfox] in cell_set_loadable, id = 1
>> > [wheatfox] cell_management_prologue finished
>> > [wheatfox] in resume_cpu, cpu_id = 2
>> > [wheatfox] in resume_cpu, target_data->cpu_suspended = 1
>> > [wheatfox] in resume_cpu, cpu_id = 3
>> > [wheatfox] in resume_cpu, target_data->cpu_suspended = 1
>> > [wheatfox] finished arch_park_cpu
>> > [wheatfox] cell->loadable = 1
>> > [wheatfox] in out_resume
>> > [wheatfox] in resume_cpu, cpu_id = 1
>> > [wheatfox] in resume_cpu, target_data->cpu_suspended = 1
>> > [ 130.579626] [wheatfox] (jailhouse_cmd_cell_load)
>> > jailhouse_call_arg1(JAILHOUSE_HC_CELL_SET_LOADABLE, cell->id) done
>> > [ 130.590182] [wheatfox] (jailhouse_cmd_cell_load)
>> > cell_load.num_preload_images = 1
>> > [ 130.597678] [wheatfox] (jailhouse_cmd_cell_load) load_image(cell,
>> > image) start, n = 1
>> > [ 130.605532] [wheatfox] (load_image) start
>> > [ 130.609557] [wheatfox] (load_image) copy_from_user done
>> > [ 130.614795] [wheatfox] (load_image) image.size = 1ab7200
>> > [ 130.620131] [wheatfox] (load_image) found suitable memory region,
>> > mem->virt_start = c0000000, mem->size = 3d700000
>> > [ 130.630505] [wheatfox] (load_image) image load mem region found
>> > [ 130.636699] [wheatfox] (load_image) phys_start = c0280000
>> > [ 130.642128] [wheatfox] (load_image) page_offs = 0
>> > [ 130.646853] [wheatfox] (load_image) image_mem = 000000007135b443
>> > [ 130.652883] [wheatfox] (load_image) copy_from_user params:
>> > [ 130.658387] [wheatfox] (load_image) to = 000000007135b443
>> > [ 130.663808] [wheatfox] (load_image) from = 00000000ebdde5d4
>> > [ 130.669399] [wheatfox] (load_image) n = 1ab7200
>> > [ 130.673952] [wheatfox] (load_image) copy_from_user start
>> >
>> > then nothing happens after this 'copy_from_user start`, the source code
>> is:
>> > printk("[wheatfox] (load_image) copy_from_user start\n");
>> > if (copy_from_user(image_mem + page_offs,
>> > (void __user *)(unsigned long)image.source_address,
>> > image.size))
>> > err = -EFAULT;
>> > printk("[wheatfox] (load_image) copy_from_user done\n");
>> >
>> >
>> > --
>> > 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 [email protected]
>> > <mailto:[email protected]>.
>> > To view this discussion on the web visit
>> >
>> https://groups.google.com/d/msgid/jailhouse-dev/f81eedab-debe-4d19-954a-06b55f2fa4a9n%40googlegroups.com
>>
>> <
>> https://groups.google.com/d/msgid/jailhouse-dev/f81eedab-debe-4d19-954a-06b55f2fa4a9n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>
>>
>>
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jailhouse-dev/91a64cf9-a3b4-419b-b030-fc3d295e577en%40googlegroups.com.
/*
* iMX8MM target - linux-demo
*
* Copyright 2019 NXP
*
* Authors:
* Peng Fan <[email protected]>
*
* This work is licensed under the terms of the GNU GPL, version 2. See
* the COPYING file in the top-level directory.
*/
/*
* Boot 2nd Linux cmdline:
* export PATH=$PATH:/usr/share/jailhouse/tools/
* jailhouse cell linux imx8mp-linux-demo.cell Image -d imx8mp-evk-inmate.dtb -c "clk_ignore_unused console=ttymxc3,115200 earlycon=ec_imx6q,0x30890000,115200 root=/dev/mmcblk2p2 rootwait rw"
*/
#include <jailhouse/types.h>
#include <jailhouse/cell-config.h>
struct {
struct jailhouse_cell_desc cell;
__u64 cpus[1];
struct jailhouse_memory mem_regions[15];
struct jailhouse_irqchip irqchips[2];
struct jailhouse_pci_device pci_devices[2];
} __attribute__((packed)) config = {
.cell = {
.signature = JAILHOUSE_CELL_DESC_SIGNATURE,
.revision = JAILHOUSE_CONFIG_REVISION,
.name = "linux-inmate-demo",
.flags = JAILHOUSE_CELL_PASSIVE_COMMREG,
.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 = 154, /* Not include 32 base */
},
.cpus = {
0xc,
},
.mem_regions = {
/* IVHSMEM shared memory region for 00:00.0 (demo )*/ {
.phys_start = 0xfd900000,
.virt_start = 0xfd900000,
.size = 0x1000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED,
},
{
.phys_start = 0xfd901000,
.virt_start = 0xfd901000,
.size = 0x9000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_ROOTSHARED,
},
{
.phys_start = 0xfd90a000,
.virt_start = 0xfd90a000,
.size = 0x2000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED,
},
{
.phys_start = 0xfd90c000,
.virt_start = 0xfd90c000,
.size = 0x2000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED,
},
{
.phys_start = 0xfd90e000,
.virt_start = 0xfd90e000,
.size = 0x2000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_ROOTSHARED,
},
/* IVSHMEM shared memory regions for 00:01.0 (networking) */
JAILHOUSE_SHMEM_NET_REGIONS(0xfda00000, 1),
/* UART2 earlycon */ {
.phys_start = 0x30890000,
.virt_start = 0x30890000,
.size = 0x1000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_IO | JAILHOUSE_MEM_ROOTSHARED,
},
/* UART4 */ {
.phys_start = 0x30a60000,
.virt_start = 0x30a60000,
.size = 0x1000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_IO,
},
/* SHDC3 */ {
.phys_start = 0x30b60000,
.virt_start = 0x30b60000,
.size = 0x10000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_IO,
},
/* RAM: Top at 4GB Space */ {
.phys_start = 0xfdb00000,
.virt_start = 0,
.size = 0x10000, /* 64KB */
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_LOADABLE,
},
/* RAM */ {
/*
* We could not use 0x80000000 which conflicts with
* COMM_REGION_BASE
*/
.phys_start = 0x60000000,
.virt_start = 0x60000000,
.size = 0x10000000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
JAILHOUSE_MEM_LOADABLE,
},
/* communication region */ {
.virt_start = 0x80000000,
.size = 0x00001000,
.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
JAILHOUSE_MEM_COMM_REGION,
},
},
.irqchips = {
/* uart2/sdhc1 */ {
.address = 0x38800000,
.pin_base = 32,
.pin_bitmap = {
(1 << (24 + 32 - 32)) | (1 << (29 + 32 - 32))
},
},
/* IVSHMEM */ {
.address = 0x38800000,
.pin_base = 160,
.pin_bitmap = {
0xf << (154 + 32 - 160) /* SPI 154-157 */
},
},
},
.pci_devices = {
{ /* IVSHMEM 00:00.0 (demo) */
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 0,
.bdf = 0 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 0,
.shmem_dev_id = 2,
.shmem_peers = 3,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_UNDEFINED,
},
{ /* IVSHMEM 00:01.0 (networking) */
.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
.domain = 0,
.bdf = 1 << 3,
.bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
.shmem_regions_start = 5,
.shmem_dev_id = 1,
.shmem_peers = 2,
.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
},
},
};