Re: RFC: text for cell loading documentation

2018-04-12 Thread Jan Kiszka
On Wednesday, April 11, 2018 at 12:23:21 PM UTC+2, f1f0 wrote:
>
> 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) 

inmate.bin

>  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 0x100 \ 
> ramfs.bin -a 0x200 
>
> 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 0x100. 
> Should inmate.bin be larger than 0x100, 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 

default

But it is not fixed, inmates may expand it. None of the demo inmates
does, though.

> 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 0x100 \ 
> ramfs.bin -a 0x200 
>
> 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 "" -a $OFFSET \ 
> sharedobject.so -a 0x100 \ 
> ramfs.bin -a 0x200 
>
> 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 pointed out this limit above already.

Thanks for kicking this off. As I wrote in the other thread, I think
this information is best located in a man page for the jailhouse tool.
Of course, that would imply writing more than "just" about jailhouse
cell load... :D But maybe we can start the man page with "to-be-written"
stubs.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

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


RFC: text for cell loading documentation

2018-04-11 Thread ff

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 0x100 \
ramfs.bin -a 0x200

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 0x100.
Should inmate.bin be larger than 0x100, 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 0x100 \
ramfs.bin -a 0x200

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 "" -a $OFFSET \
sharedobject.so -a 0x100 \
ramfs.bin -a 0x200

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.