According to jailhouse-cell-linux sciprt, the load of linux_loader.bin is 
successful, but the linux kernel image's load progress stuck at 
load_image's copy_from_user. Therefore, the script never reaches the 'start 
cell' step and the linux cannot be started due to previous reason. I don't 
know what is causing the copy_from_user kernel function to halt and I 
really appreciate it if you can help me with this issue! Thanks.

On Monday, January 8, 2024 at 4:26:41 PM UTC+8 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 \
> -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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/ff6757cb-6436-4696-a05b-300d44803178n%40googlegroups.com.

Reply via email to