add domain builder support for bzImage kernels
RFC PATCH 1/1 add domain builder support for bzImage kernels
This implements a loader for version 2.07 boot protocol bzImage format files. This allows a single bzImage kernel file to boot either native from a normal bootloader (grub, etc), or paravirtualized under Xen.
These bzImages have two changes to make this possible:
1. There's a new field for the bootloader to tell the booted kernel what kind of environment its coming up under. We can use this to tell the kernel to unambigiously tell that its booting under Xen. There's also an extra field for storing some environment-specific data; we use this to store the Xen start_info pointer.
2. The 32-part of the bzImage code, which includes a decompressor and the compressed data for the actual kernel, is wrapped in an ELF file. This allows us to decorate it with the Xen-spceific ELF notes, and also use the PHDRs to specify how much memory Xen needs to map initially. The ELF file is constructed so that the PHDRs map enough memory for the kernel to decompress itself, and run enough until it can build its own initial pagetables.
The Linux boot protocol requires that %esi point to the boot_params block on entry. Unfortunately this conflicts with the normal Xen boot protocol, which starts with %esi pointing to a struct start_info.
In order to implement this, I've had to muck up Gerd's nice clean layering a little bit. struct xc_dom_image now has a bootparams_pfn, which is set by the bzImage loader. Then, when xc_dom_x86 sees that its non-NULL when setting up the initial vcpu state, it points %esi that rather than start_info (and the boot_params contains a pointer to start_info). Fortunately, the embedded ELF file makes it easy to reuse a lot of the existing ELF machinery, so there's not a lot of new code.
tools/libxc/Makefile +1 -0
@@ -47,6 +47,7 @@ GUEST_SRCS-y += $(LIBELF_SRCS) # new domain builder GUEST_SRCS-y += xc_dom_core.c xc_dom_boot.c GUEST_SRCS-y += xc_dom_elfloader.c +GUEST_SRCS-y += xc_dom_bzimageloader.c GUEST_SRCS-y += xc_dom_binloader.c GUEST_SRCS-y += xc_dom_compat_linux.c
tools/libxc/bootparam.h new file +53 -0
53 lines not on this page · raw message
tools/libxc/xc_dom.h +6 -0
@@ -55,6 +55,7 @@ struct xc_dom_image {xen_pfn_t xenstore_pfn;xen_pfn_t shared_info_pfn;xen_pfn_t bootstack_pfn; +xen_pfn_t bootparams_pfn;xen_vaddr_t virt_alloc_end;xen_vaddr_t bsd_symtab_start;
@@ -254,6 +255,11 @@ static inline xen_pfn_t xc_dom_p2m_guestreturn dom->p2m_host[pfn]; } +char *xc_dom_guest_type (struct xc_dom_image *dom, +struct elf_binary *elf); +int xc_dom_load_elf_symtab (struct xc_dom_image *dom, +struct elf_binary *elf,int load); +/* --- arch bits --------------------------------------------------- */ int arch_setup_meminit (struct xc_dom_image *dom);
tools/libxc/xc_dom_bzimageloader.c new file +169 -0
169 lines not on this page · raw message
tools/libxc/xc_dom_elfloader.c +4 -4
@@ -18,8 +18,8 @@/* ------------------------------------------------------------------------ */ -static char *xc_dom_guest_type (struct xc_dom_image *dom, -struct elf_binary *elf) +char *xc_dom_guest_type (struct xc_dom_image *dom, +struct elf_binary *elf) {uint64_t machine =elf_uval (elf, elf->ehdr, e_machine);
@@ -78,8 +78,8 @@ static int xc_dom_probe_elf_kernel(strucreturn check_elf_kernel (dom,0 ); } -static int xc_dom_load_elf_symtab (struct xc_dom_image *dom, -struct elf_binary *elf,int load) +int xc_dom_load_elf_symtab (struct xc_dom_image *dom, +struct elf_binary *elf,int load) {struct elf_binary syms;const elf_shdr *shdr, *shdr2;
tools/libxc/xc_dom_x86.c +39 -4
67 lines not on this page · raw message
Hi,
Review
Quoted 2 lines
(quoted diff) +2
-0+ if ( dom->parms.bsd_symtab ) + xc_dom_load_elf_symtab(dom, elf, 1);
You can just drop that. The elf symtab stuff is used by BSD kernels only, it is never ever used with Linux and thus not required for the (linux-only) bzImage loader.
cheers,
Gerd