I am proposing to add a Documentation/cell-loading.md file.
Rather than proposing the .md directly, I prefer to propose raw text discussion, then work on the cosmetics and links from other parts of the Documentation.

-FF

Jailhouse loading of images is pretty flexible but can be disconcerting.

The syntax is:

jailhouse cell load \
{ ID | [--name] NAME } \
{ { IMAGE | { -s | --string } "STRING" } [-a | --address ADDRESS] } ...

Valid forms are:

        # loads inamte.bin (offset 0 assumed)
        jailhouse cell load foocell inmate.bin

        # same as above with explicit location
        jailhouse cell load foocell inmate.bin -a 0

        # load three binary objects (in order)
        jailhouse cell load foocell \
            inmate.bin \
            sharedobject.so -a 0x1000000 \
            ramfs.bin -a 0x2000000

The first example assumes "-a 0".

The last example, loads in the order specified, three binary objects,
the first one at offset 0, the second one at 0x1000000.
Should inmate.bin be larger than 0x1000000, the upper part will be overridden
by sharedobject.so.

Whatever load order, execution starts in the cell at offset 0.


This multi-image loading capability can be used to patch images and
pass parameters to the image. The following explains how parameters are passed
with the inmate library.

The inmate library assumes a command line string to be located at a fixed
location that is processor specific:
- On x86 this is offset 0x100 (see inmates/lib/x86/inmate.lds)
- On arm64, this is offset 0x1000 (see inmates/lib/arm64/inmate.lds.S)

The command line string capacity is fixed (256 bytes by defaylt) by CMDLINE_BUFFER_SIZE
in inmates/lib/cmdline.c.

Here is an example to pass  parameters stored in the file
commandline.txt to the last example on an x86 system:

        OFFSET=0x100
        jailhouse cell load foocell \
            inmate.bin \
            commanline.txt -a $OFFSET \
            sharedobject.so -a 0x1000000 \
            ramfs.bin -a 0x2000000

This command patches inmate.bin at offset 0x100 that happens to be char* cmdline for
inmates that uses Jailhouse inmates library.

Note: on an arm64 we would set OFFSET=0x1000

To be more practical and avoid using a text file, there is an image-as-string
option:

        OFFSET=0x100
        jailhouse cell load foocell \
            inmate.bin \
                -s "<command line parameters here>" -a $OFFSET \
            sharedobject.so -a 0x1000000 \
            ramfs.bin -a 0x2000000

The string in the -s need to be less than 255 characters long (CMDLINE_BUFFER_SIZE - terminatind \0)
otherwise it will silently overwrite existing code.

--
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.

Reply via email to