lkml.org 
[lkml]   [2002]   [Feb]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC] x86 ELF bootable kernels/Linux booting Linux/LinuxBIOS
From
Date
Werner Almesberger <wa@almesberger.net> writes:

> Hi guys,
>

> Having said this, I still think a bootimg-like API would be better than
> a file based API. So, concerning this thread:

I have come to agree with this sentiment. However I do have a small
issue with the current bootimg api. Everything is done in page sized
chunks. Which feels like it is exporting too much of the current
implementation.

struct boot_image {
void **image_map; /* pointers to image pages in user memory */
int pages; /* length in pages */
unsigned long *load_map;/* list of destination pages (physical addr) */
unsigned long start; /* jump to this physical address */
int flags; /* for future use, must be zero for now */
};
asmlinkage int sys_bootimg(struct boot_image *user_dsc)

My preference goes to something like:
struct segment {
void *vaddr; /* virtual address of the data to start with */
unsigned long paddr; /* physical address to copy this segment to */
unsigned long size; /* size in bytes of this segment */
};
asmlinkage int sys_kexec(struct segment *segments, int nr_segments, unsigned long start_addr);

The big difference I believe is that you will have far fewer segments,
in my scheme, and where everything is on a byte granularity the user
space implementation doesn't have to know how the kernel side of
the implementation interacts with pages.

I hadn't realized until just a minute ago when I looked again that you
were exporting pages.

> My assumption is that you need to do some processing before telling the
> kernel to reboot, and that you want to be able to do such processing in
> user space (e.g. extract the current memory map and pass it to the new
> kernel, forward the results of bus scans, create a RAM disk with driver
> modules on the fly, etc.)
>
> In particular, the "old" kernel may need to pass information obtained
> from the firmware to the "new" kernel.

Except for the case of Loadlin where the old firmware is destroyed,
and you cannot requery the firmware. You have a more robust solution
if you let the new kernel query the firmware itself. In general it is
not safe to use firmware device drivers, but otherwise you are o.k.

> With decent firmware, there
> could also be user-provided data that needs to be propagated, such as
> portions of the command line. Well-known information of this type can
> be encoded in the kernel, but I think this just leads to bloat, as more
> and more policy will have to be encoded there, let alone the packing
> and unpacking issues.

For the most part I agree, that the bootimg type interface will avoid
bloat. At the same time, some of this information that we would like
to pass is easier to get at in kernel space, oh well.

> Also, in many cases, interactions beween the kernel side of the boot
> loader and the rest of the kernel would actually be a good thing to
> have in user space anyway, e.g. the ability to shut down or
> "immobilize" certain devices, or to retrieve device status
> information.

Possibly.

> As I've shown with bootimg, it's pretty trivial to load all kinds of
> formats (including ELF) via a memory-based interface, and you enjoy
> considerable freedom in how you generate the data in memory. If you
> want, you can even go and modify in-kernel data structures directly,
> so you don't need a nice and clean interface for each and every bit
> of data, but you can evolve interfaces when necessary.

I will stop just a moment to say it is extremely nasty to read the ELF
section header instead of the ELF program header for boot purposes.
For an ELF static executable it is totally valid not to have a section
header.

> In cases where a boot (pre)loader program wouldn't be desirable, a
> set of library functions could serve the same purpose. In fact, the
> boot (pre)loader should be based on them, too.

Actually a library of functions to do the conversions sounds very
reasonable.

> So, while a file-based interface looks cool, I think a "thin"
> memory-based interface will serve us better in the long run.

I actually pretty much agree. But mostly because it becomes easier to
do a clean shutdown. If you just wrote a file it is kind of hard to
have a read-only filesystem, plus it looks like it will reduce the
strife a little bit...

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:23    [W:0.192 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site