Phil Howard <[EMAIL PROTECTED]> writes:

> I'm looking for a simple example, not a full tool suite, of a program
> that uses the kernel kexec syscall.  The reason is I need to use the
> kexec syscall at a point where the kexec-tools won't be available.  An
> example of such a scenario would be executing kexec() from within early
> userspace (before init runs).  Another example is when no filesystems
> are available and the kernel image is being obtained from a network
> connection by the program running in PID 1.  Would an earlier version of
> kexec-tools provide this simplicity?  Or would there be another package
> around that does this?  Documentation of the kexec syscall interface
> might also be another way to figure out what to code to use it, if you
> know of any.

So actually using sys_kexec_load to get something done may not be as simple as
you would like.

The basic pieces are:

struct kexec_segment {
        void __user *buf;
        size_t bufsz;
        unsigned long mem;      /* User space sees this as a (void *) ... */
        size_t memsz;
};
long sys_kexec_load(unsigned long entry,
                        unsigned long nr_segments,
                        struct kexec_segment __user *segments,
                        unsigned long flags);

followed by:
sys_reboot(LINUX_REBOOT_CMD_KEXEC);


All destination address passed to sys_kexec_load are machine physical address.

Each segment is a pair of a user space buffer plus the physical address it is
destined to go to.  If the destination memory size is greater then the source 
memory
size the extra bytes are zero padded.

Currently the destination addresses and sizes must be in page aligned
and in page sized chunks.  

entry is the physical address to jump to start the process.

The processor operating mode is the same mode the kernel runs the
process in with virtual address identity mapped to physical address,
or with the MMU disabled.


The kexec flags field is a little more complicated.  In the normal
case just passing 0 should work.

The upper 16 bites of the flags field specifies the architecture
the kernel is running on.  This allows safely for things like
32bit binaries on 64bit kernels to be used.  As they tell kexec
yes I know my destination is 64bits. Passing zero only works
for non-compatibility mode applications.

Of the lower 16bits only two values have been defined.
0 - A normal kexec image is being loaded.
1 - A kexec on panic image is being loaded.

What to load is left up to user space.
Good Luck,

Eric
_______________________________________________
fastboot mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/fastboot

Reply via email to