1 ## Jailhouse support layer
4 Yocto layer that enables the use of the Jailhouse partitioning hypervisor - <https://github.com/siemens/jailhouse>.
6 ### How to Enable and Use
10 > Note: Right now the below setup is only working for Intel Machines.
12 The AGL feature `agl-jailhouse` has to be enabled. That needs to be done when including aglsetup.sh, for example:
15 $ source meta-agl/scripts/aglsetup.sh -m qemux86-64 -b build agl-devel agl-jailhouse
18 That will enable this layer and include the `jailhouse` package in the image.
21 Then, in the target system, the cell configurations (*.cell) are placed in `/usr/share/jailhouse/cells/` and the demo inmates (bare-metal applications to run in a non-root cell) are located in `/usr/share/jailhouse/inmates`.
24 After that follow the [AGL-Documentation](https://docs.automotivelinux.org/en/master/#0_Getting_Started/2_Building_AGL_Image/2_Downloading_AGL_Software/) as usual and build the image using `bitbake core-image-minimal`.
27 After successfully building the image we need to QEmulate the Image using `runqemu`:
32 $ runqemu qemux86-64 slirp kvm publicvnc serial bootparams="verbose ipv6.disable=1 intel_iommu=off"
36 After successful emulation of the Image, you will see something similar to this:
41 [ 0.021231] [Firmware Bug]: TSC_DEADLINE disabled due to Errata; please update microcode to version: 0xb2 (or later)
43 [ 0.588075] kvm: already loaded the other module
45 [ 0.926525] hdaudio hdaudioC0D0: Unable to bind the codec
47 Automotive Grade Linux 11.91.0 qemux86-64 ttyS0
49 qemux86-64 login: root
53 ### For Running the Linux Cell
56 In order to spin-up the Root cell and Inmates, you will need Cell Configurations (*.cell) and Inmates, which you will find at `/usr/share/jailhouse/cell` and `/usr/share/jailhouse/inmates`.
59 But for Linux-Cell some preparation is needed and the things which you will require include:
67 These files you can find easily in the `build/tmp/deploy/images/qemux86-64/`.
69 After obtaining these files you have to `scp` these to the emulated Image.
71 Now you should have everything in the target system and you can now spin up the things but before that check, if `jailhouse` is present or not:
82 As you can see it’s showing present, In case if it’s not present then run `modprobe jailhouse`, it will load the Jailhouse kernel module.
84 After loading the module now we have to enable the Jailhouse-Root-Cell, enable this by the below command:
88 qemux86-64:~# jailhouse enable /usr/share/jailhouse/cells/qemu-agl.cell
92 And check the console for the logs.
94 After loading jailhouse Root-cell, now we have to load the Non-root Linux cell, so for that run the below commands:
99 qemux86-64:~# jailhouse cell linux /usr/share/jailhouse/cells/agl-linux-x86-demo.cell bzImage -i rootfs.cpio -w out.file -c "console=ttyS2,115200 earlycon earlyprintk"
104 > Note: In the above command, when you add the `-w out.file` option then it will spit out some commands to start the non-root cell, if not then the cell will boot as usual. Those spitted out commands would look something like these below, you have to run it one by one:
110 qemux86-64:~# jailhouse cell create /usr/share/jailhouse/cells/agl-linux-x86-demo.cell
112 qemux86-64:~# jailhouse cell load linux-x86-demo linux-loader.bin -a 0x0 bzImage -a 0xffc600 rootfs.cpio -a 0x3d89000 out.file -a 0x1000
114 qemux86-64:~# jailhouse cell start linux-x86-demo.cell
118 > Note: As you can see in the spit-out commands there is a `linux-loader.bin` is present, this is a tiny bootloader that is required to boot the Linux-inmate or Linux-non-root cell. It is located in `/usr/libexec/jailhouse/linux-loader.bin` in the Emulated Image.
120 After running the above commands you will see that Linux is booting in another console.
122 Some helper scripts are present to automate all this, and it can be found [here](https://gerrit.automotivelinux.org/gerrit/gitweb?p=AGL/meta-agl-devel.git;a=tree;f=meta-agl-jailhouse/recipes-extended/jailhouse/files/helper-scripts).
125 ### For Testing Virtio over IVSHMEM Block
127 You can test the Virtio-block over IVSHMEM by following the steps below:
129 **This is for the Root-cell <---> Non-Root-Cell communication.**
131 First, you have to boot the Image and enable the `qemu-agl.cell` into the target system, as described in the above sections.
133 After that follow the below steps to get it spinning:
137 qemux86-64:~# jailhouse enable /usr/share/jailhouse/cells/qemu-agl.cell
138 qemux86-64:~# modprobe uio_ivshmem
142 After this check for the PCI device using `lspci -k`, you will see something like this below:
146 qemux86-64:~# lspci -k
154 00:0c.0 Unassigned class [ff80]: Siemens AG Device 4106
156 Subsystem: Siemens AG Device 4106
166 After confirming, run the below command, this will create a virtio block backend
170 qemux86-64:~# echo "110a 4106 110a 4106 ffc002 ffffff" >
172 /sys/bus/pci/drivers/uio_ivshmem/new_id
176 And after that, start the backend service like this:
180 qemux86-64:~# ./virtio-ivshmem-block /dev/uio0 disk.img
182 Waiting for peer to be ready...
186 After running the backend-service boot or reboot another cell, and backend will show something like this:
190 qemux86-64:~ # ./virtio-ivshmem-block /dev/uio0 disk.img
192 Waiting for peer to be ready...
194 Starting virtio device
202 device_features_sel: 1
204 device_features_sel: 0
214 In the Non-Root-Linux, the disk will show up as /dev/vda and can be accessed normally.
218 >- For the `virtio-ivshmem-block` you can find it in target system at `/usr/bin/`, if not then copy it from here `build/tmp/work-shared/qemux86-64/kernel-source/tools/virtio/virtio-ivshmem-block`.
220 >- For the `disk.img`, It needs to be a raw image. But its size matters as that defines the virtual disk size, but you may even leave it empty and only partition or format it from the front-end guest.
224 > $ dd if=/dev/zero of=disk.img bs=1M count=1024
226 > $ mkfs.ext4 disk.img
229 For manually configuring the setup, refer [`meta-agl-jailhouse.md`](meta-agl-jailhouse.md).