Ian Campbell
2011-May-13 13:42 UTC
[Xen-devel] [PATCH 0 of 8] tools: libx[cl]: support alternative HVM firmware
The following series makes it possible to use any ELF file as the initial HVM domain firmware and begins to setup libxl to cope with this. Primarily this involves making the HVM domain builder happy and behave correctly with unaligned firmware images and changing the libxl API to refer to "firmware" rather than "hvmloader". It is possible that this will turn out to be the right approach for supporting SeaBIOS, although this isn''t confirmed yet so I haven''t proposed removing any of the hvmloader changes I proposed and I include the final patch ("load SeaBIOS directly rather than via hvmloader") here just as a proof of concept rather than for application. I understand that the people working on integrating tianocore support are also interested in this functionality so I''m posting the series before the SeaBIOS side is really figured out, there isn''t really anything seabios specific here. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-May-13 13:42 UTC
[Xen-devel] [PATCH 1 of 8] tools: libxc: allow HVM firmware to be loaded at an arbitrary alignment
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1305294079 -3600 # Node ID c5c7ae5f33b16ee03535e9c688ad9bee2510b2b6 # Parent 9476bc07db2c654b266ab1f1c9ff0c65f401d74d tools: libxc: allow HVM firmware to be loaded at an arbitrary alignment Enables direct loading of e.g. seabios.elf. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 9476bc07db2c -r c5c7ae5f33b1 tools/libxc/xc_hvm_build.c --- a/tools/libxc/xc_hvm_build.c Fri May 13 14:41:19 2011 +0100 +++ b/tools/libxc/xc_hvm_build.c Fri May 13 14:41:19 2011 +0100 @@ -88,7 +88,9 @@ static int loadelfimage( struct elf_binary *elf, uint32_t dom, unsigned long *parray) { privcmd_mmap_entry_t *entries = NULL; - size_t pages = (elf->pend - elf->pstart + PAGE_SIZE - 1) >> PAGE_SHIFT; + unsigned long pfn_start = elf->pstart >> PAGE_SHIFT; + unsigned long pfn_end = (elf->pend + PAGE_SIZE - 1) >> PAGE_SHIFT; + size_t pages = pfn_end - pfn_start; int i, rc = -1; /* Map address space for initial elf image. */ @@ -105,6 +107,8 @@ static int loadelfimage( if ( elf->dest == NULL ) goto err; + elf->dest += elf->pstart & 4095; + /* Load the initial elf image. */ elf_load_binary(elf); rc = 0; @@ -169,12 +173,6 @@ static int setup_guest(xc_interface *xch goto error_out; } - if ( (elf.pstart & (PAGE_SIZE - 1)) != 0 ) - { - PERROR("Guest OS must load to a page boundary."); - goto error_out; - } - IPRINTF("VIRTUAL MEMORY ARRANGEMENT:\n" " Loader: %016"PRIx64"->%016"PRIx64"\n" " TOTAL: %016"PRIx64"->%016"PRIx64"\n" _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-May-13 13:42 UTC
[Xen-devel] [PATCH 2 of 8] tools: libxc: enable libelf logging for HVM domain builder
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1305294079 -3600 # Node ID 996d74359377c4c0c15c1e988a017613f872af65 # Parent c5c7ae5f33b16ee03535e9c688ad9bee2510b2b6 tools: libxc: enable libelf logging for HVM domain builder. Signed-off-by: Ian Campbell <ian.campbell@citrix.com>: diff -r c5c7ae5f33b1 -r 996d74359377 tools/libxc/xc_hvm_build.c --- a/tools/libxc/xc_hvm_build.c Fri May 13 14:41:19 2011 +0100 +++ b/tools/libxc/xc_hvm_build.c Fri May 13 14:41:19 2011 +0100 @@ -163,6 +163,9 @@ static int setup_guest(xc_interface *xch memset(&elf, 0, sizeof(elf)); if ( elf_init(&elf, image, image_size) != 0 ) goto error_out; + + xc_elf_set_logfile(xch, &elf, 1); + elf_parse_binary(&elf); v_start = 0; v_end = (unsigned long long)memsize << 20; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-May-13 13:42 UTC
[Xen-devel] [PATCH 3 of 8] tools: libxl/xl: Use "firmware" rather than "hvmloader" in API
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1305294079 -3600 # Node ID 84c3d1d16ddc3bc674354e5da8e97bac2ac9cc14 # Parent 996d74359377c4c0c15c1e988a017613f872af65 tools: libxl/xl: Use "firmware" rather than "hvmloader" in API. 23251:0710f53cef4a turned build_info.kernel into build_info.hvm.hvmloader however this is a rather specific name for a field which may be used to load things which aren''t hvmloader in the future. Switch to calling the field and associated configuration itmes "firmware" instead. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 996d74359377 -r 84c3d1d16ddc tools/libxl/libxl.idl --- a/tools/libxl/libxl.idl Fri May 13 14:41:19 2011 +0100 +++ b/tools/libxl/libxl.idl Fri May 13 14:41:19 2011 +0100 @@ -160,7 +160,7 @@ libxl_domain_build_info = Struct("domain ("hvm", bool), ("u", KeyedUnion(None, "hvm", [("hvm", "%s", Struct(None, - [("hvmloader", string), + [("firmware", string), ("pae", bool), ("apic", bool), ("acpi", bool), diff -r 996d74359377 -r 84c3d1d16ddc tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Fri May 13 14:41:19 2011 +0100 +++ b/tools/libxl/libxl_create.c Fri May 13 14:41:19 2011 +0100 @@ -85,7 +85,7 @@ void libxl_init_build_info(libxl_domain_ if (c_info->hvm) { b_info->video_memkb = 8 * 1024; b_info->hvm = 1; - b_info->u.hvm.hvmloader = NULL; + b_info->u.hvm.firmware = NULL; b_info->u.hvm.pae = 1; b_info->u.hvm.apic = 1; b_info->u.hvm.acpi = 1; diff -r 996d74359377 -r 84c3d1d16ddc tools/libxl/libxl_dom.c --- a/tools/libxl/libxl_dom.c Fri May 13 14:41:19 2011 +0100 +++ b/tools/libxl/libxl_dom.c Fri May 13 14:41:19 2011 +0100 @@ -269,11 +269,11 @@ static int hvm_build_set_params(xc_inter return 0; } -static const char *libxl__domain_hvmloader(libxl__gc *gc, +static const char *libxl__domain_firmware(libxl__gc *gc, libxl_domain_build_info *info) { return libxl__abs_path(gc, - info->u.hvm.hvmloader ? : "hvmloader", + info->u.hvm.firmware ? : "hvmloader", libxl_xenfirmwaredir_path()); } @@ -289,7 +289,7 @@ int libxl__build_hvm(libxl__gc *gc, uint domid, (info->max_memkb - info->video_memkb) / 1024, (info->target_memkb - info->video_memkb) / 1024, - libxl__domain_hvmloader(gc, info)); + libxl__domain_firmware(gc, info)); if (ret) { LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "hvm building failed"); goto out; diff -r 996d74359377 -r 84c3d1d16ddc tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Fri May 13 14:41:19 2011 +0100 +++ b/tools/libxl/xl_cmdimpl.c Fri May 13 14:41:19 2011 +0100 @@ -337,7 +337,7 @@ static void printf_info(int domid, printf("\t(image\n"); if (c_info->hvm) { printf("\t\t(hvm\n"); - printf("\t\t\t(loader %s)\n", b_info->u.hvm.hvmloader); + printf("\t\t\t(firmware %s)\n", b_info->u.hvm.firmware); printf("\t\t\t(video_memkb %d)\n", b_info->video_memkb); printf("\t\t\t(shadow_memkb %d)\n", b_info->shadow_memkb); printf("\t\t\t(pae %d)\n", b_info->u.hvm.pae); @@ -748,10 +748,10 @@ static void parse_config_data(const char if (c_info->hvm == 1) { if (!xlu_cfg_get_string (config, "kernel", &buf)) fprintf(stderr, "WARNING: ignoring \"kernel\" directive for HVM guest. " - "Use \"hvmloader_override\" instead if you really want a non-default hvmloader\n"); - - xlu_cfg_replace_string (config, "hvmloader_override", - &b_info->u.hvm.hvmloader); + "Use \"firmware_override\" instead if you really want a non-default firmware\n"); + + xlu_cfg_replace_string (config, "firmware_override", + &b_info->u.hvm.firmware); if (!xlu_cfg_get_long (config, "pae", &l)) b_info->u.hvm.pae = l; if (!xlu_cfg_get_long (config, "apic", &l)) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-May-13 13:42 UTC
[Xen-devel] [PATCH 4 of 8] tools: libxl: constify parameter to libxl__abs_path
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1305294079 -3600 # Node ID 66579385ed4e553740ac8e44c514bb10336686e7 # Parent 84c3d1d16ddc3bc674354e5da8e97bac2ac9cc14 tools: libxl: constify parameter to libxl__abs_path Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 84c3d1d16ddc -r 66579385ed4e tools/libxl/libxl_internal.c --- a/tools/libxl/libxl_internal.c Fri May 13 14:41:19 2011 +0100 +++ b/tools/libxl/libxl_internal.c Fri May 13 14:41:19 2011 +0100 @@ -184,10 +184,10 @@ void libxl__log(libxl_ctx *ctx, xentooll va_end(ap); } -char *libxl__abs_path(libxl__gc *gc, char *s, const char *path) +char *libxl__abs_path(libxl__gc *gc, const char *s, const char *path) { if (!s || s[0] == ''/'') - return s; + return libxl__strdup(gc, s); return libxl__sprintf(gc, "%s/%s", path, s); } diff -r 84c3d1d16ddc -r 66579385ed4e tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Fri May 13 14:41:19 2011 +0100 +++ b/tools/libxl/libxl_internal.h Fri May 13 14:41:19 2011 +0100 @@ -309,7 +309,7 @@ _hidden void libxl__exec(int stdinfd, in _hidden void libxl__log_child_exitstatus(libxl__gc *gc, const char *what, pid_t pid, int status); -_hidden char *libxl__abs_path(libxl__gc *gc, char *s, const char *path); +_hidden char *libxl__abs_path(libxl__gc *gc, const char *s, const char *path); #define LIBXL__LOG_DEBUG XTL_DEBUG #define LIBXL__LOG_INFO XTL_INFO _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-May-13 13:42 UTC
[Xen-devel] [PATCH 5 of 8] tools: libxl: pass device model info down into HVM domain build functions
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1305294079 -3600 # Node ID 5e7615dbe3008fd25edabb3fda3cb80a76015ed1 # Parent 66579385ed4e553740ac8e44c514bb10336686e7 tools: libxl: pass device model info down into HVM domain build functions. The builder will soon need to know the device model version in order to select the correct firmware. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 66579385ed4e -r 5e7615dbe300 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Fri May 13 14:41:19 2011 +0100 +++ b/tools/libxl/libxl_create.c Fri May 13 14:41:19 2011 +0100 @@ -144,8 +144,11 @@ static int init_console_info(libxl_devic return 0; } -int libxl__domain_build(libxl__gc *gc, libxl_domain_build_info *info, - uint32_t domid, libxl__domain_build_state *state) +int libxl__domain_build(libxl__gc *gc, + libxl_domain_build_info *info, + libxl_device_model_info *dm_info, + uint32_t domid, + libxl__domain_build_state *state) { char **vments = NULL, **localents = NULL; struct timeval start_time; @@ -158,7 +161,7 @@ int libxl__domain_build(libxl__gc *gc, l gettimeofday(&start_time, NULL); if (info->hvm) { - ret = libxl__build_hvm(gc, domid, info, state); + ret = libxl__build_hvm(gc, domid, info, dm_info, state); if (ret) goto out; @@ -437,7 +440,7 @@ static int do_domain_create(libxl__gc *g free(dm_info->saved_state); dm_info->saved_state = NULL; } - ret = libxl__domain_build(gc, &d_config->b_info, domid, &state); + ret = libxl__domain_build(gc, &d_config->b_info, dm_info, domid, &state); } if (ret) { diff -r 66579385ed4e -r 5e7615dbe300 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Fri May 13 14:41:19 2011 +0100 +++ b/tools/libxl/libxl_dm.c Fri May 13 14:41:19 2011 +0100 @@ -611,7 +611,7 @@ static int libxl__create_stubdom(libxl__ ret = libxl__domain_make(gc, &c_info, &domid); if (ret) goto out_free; - ret = libxl__domain_build(gc, &b_info, domid, &state); + ret = libxl__domain_build(gc, &b_info, info, domid, &state); if (ret) goto out_free; diff -r 66579385ed4e -r 5e7615dbe300 tools/libxl/libxl_dom.c --- a/tools/libxl/libxl_dom.c Fri May 13 14:41:19 2011 +0100 +++ b/tools/libxl/libxl_dom.c Fri May 13 14:41:19 2011 +0100 @@ -270,7 +270,8 @@ static int hvm_build_set_params(xc_inter } static const char *libxl__domain_firmware(libxl__gc *gc, - libxl_domain_build_info *info) + libxl_domain_build_info *info, + libxl_device_model_info *dm_info) { return libxl__abs_path(gc, info->u.hvm.firmware ? : "hvmloader", @@ -278,7 +279,9 @@ static const char *libxl__domain_firmwar } int libxl__build_hvm(libxl__gc *gc, uint32_t domid, - libxl_domain_build_info *info, libxl__domain_build_state *state) + libxl_domain_build_info *info, + libxl_device_model_info *dm_info, + libxl__domain_build_state *state) { libxl_ctx *ctx = libxl__gc_owner(gc); int ret, rc = ERROR_INVAL; @@ -289,7 +292,7 @@ int libxl__build_hvm(libxl__gc *gc, uint domid, (info->max_memkb - info->video_memkb) / 1024, (info->target_memkb - info->video_memkb) / 1024, - libxl__domain_firmware(gc, info)); + libxl__domain_firmware(gc, info, dm_info)); if (ret) { LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "hvm building failed"); goto out; diff -r 66579385ed4e -r 5e7615dbe300 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Fri May 13 14:41:19 2011 +0100 +++ b/tools/libxl/libxl_internal.h Fri May 13 14:41:19 2011 +0100 @@ -186,7 +186,9 @@ _hidden int libxl__build_post(libxl__gc _hidden int libxl__build_pv(libxl__gc *gc, uint32_t domid, libxl_domain_build_info *info, libxl__domain_build_state *state); _hidden int libxl__build_hvm(libxl__gc *gc, uint32_t domid, - libxl_domain_build_info *info, libxl__domain_build_state *state); + libxl_domain_build_info *info, + libxl_device_model_info *dm_info, + libxl__domain_build_state *state); _hidden int libxl__domain_rename(libxl__gc *gc, uint32_t domid, const char *old_name, const char *new_name, @@ -245,7 +247,9 @@ typedef struct { /* from xl_create */ _hidden int libxl__domain_make(libxl__gc *gc, libxl_domain_create_info *info, uint32_t *domid); -_hidden int libxl__domain_build(libxl__gc *gc, libxl_domain_build_info *info, +_hidden int libxl__domain_build(libxl__gc *gc, + libxl_domain_build_info *info, + libxl_device_model_info *dm_info, uint32_t domid, libxl__domain_build_state *state); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-May-13 13:42 UTC
[Xen-devel] [PATCH 6 of 8] tools: libxl: fixup error handling in libxl__build_hvm
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1305294079 -3600 # Node ID e2aa33c8019ebd849f87e3d68350e2d26f42b15d # Parent 5e7615dbe3008fd25edabb3fda3cb80a76015ed1 tools: libxl: fixup error handling in libxl__build_hvm. We first pointless initialise rc and immediately overwrite the value, then fail to return it on error anyway... Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 5e7615dbe300 -r e2aa33c8019e tools/libxl/libxl_dom.c --- a/tools/libxl/libxl_dom.c Fri May 13 14:41:19 2011 +0100 +++ b/tools/libxl/libxl_dom.c Fri May 13 14:41:19 2011 +0100 @@ -284,15 +284,17 @@ int libxl__build_hvm(libxl__gc *gc, uint libxl__domain_build_state *state) { libxl_ctx *ctx = libxl__gc_owner(gc); - int ret, rc = ERROR_INVAL; + int ret, rc = ERROR_FAIL; + const char *firmware = libxl__domain_firmware(gc, info, dm_info); - rc = ERROR_FAIL; + if (!firmware) + goto out; ret = xc_hvm_build_target_mem( ctx->xch, domid, (info->max_memkb - info->video_memkb) / 1024, (info->target_memkb - info->video_memkb) / 1024, - libxl__domain_firmware(gc, info, dm_info)); + firmware); if (ret) { LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "hvm building failed"); goto out; @@ -305,7 +307,7 @@ int libxl__build_hvm(libxl__gc *gc, uint } rc = 0; out: - return 0; + return rc; } int libxl__domain_restore_common(libxl__gc *gc, uint32_t domid, _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-May-13 13:42 UTC
[Xen-devel] [PATCH 7 of 8] tools: libxl: refactor libxl__domain_firmware to choose based on device_model_version
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1305294079 -3600 # Node ID ee045454129076b77fbc51e09cbb3b50e2160e89 # Parent e2aa33c8019ebd849f87e3d68350e2d26f42b15d tools: libxl: refactor libxl__domain_firmware to choose based on device_model_version Note that the default remains "hvmloader" in both cases, this just clarifies the intent for now. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r e2aa33c8019e -r ee0454541290 tools/libxl/libxl_dom.c --- a/tools/libxl/libxl_dom.c Fri May 13 14:41:19 2011 +0100 +++ b/tools/libxl/libxl_dom.c Fri May 13 14:41:19 2011 +0100 @@ -273,9 +273,28 @@ static const char *libxl__domain_firmwar libxl_domain_build_info *info, libxl_device_model_info *dm_info) { - return libxl__abs_path(gc, - info->u.hvm.firmware ? : "hvmloader", - libxl_xenfirmwaredir_path()); + libxl_ctx *ctx = libxl__gc_owner(gc); + const char *firmware; + + if (info->u.hvm.firmware) + firmware = info->u.hvm.firmware; + else { + switch (dm_info->device_model_version) + { + case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: + firmware = "hvmloader"; + break; + case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: + firmware = "hvmloader"; + break; + default: + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "invalid device model version %d", + dm_info->device_model_version); + return NULL; + break; + } + } + return libxl__abs_path(gc, firmware, libxl_xenfirmwaredir_path()); } int libxl__build_hvm(libxl__gc *gc, uint32_t domid, _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-May-13 13:42 UTC
[Xen-devel] [PATCH 8 of 8] [RFC] tools: libxl: load SeaBIOS directly rather than via hvmloader
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1305294079 -3600 # Node ID cb87c80d59924d0ce80635c827327f834a035ded # Parent ee045454129076b77fbc51e09cbb3b50e2160e89 [RFC] tools: libxl: load SeaBIOS directly rather than via hvmloader Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r ee0454541290 -r cb87c80d5992 tools/libxl/libxl_dom.c --- a/tools/libxl/libxl_dom.c Fri May 13 14:41:19 2011 +0100 +++ b/tools/libxl/libxl_dom.c Fri May 13 14:41:19 2011 +0100 @@ -285,7 +285,7 @@ static const char *libxl__domain_firmwar firmware = "hvmloader"; break; case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: - firmware = "hvmloader"; + firmware = "seabios.elf"; break; default: LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "invalid device model version %d", _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Konrad Rzeszutek Wilk
2011-May-13 14:03 UTC
Re: [Xen-devel] [PATCH 1 of 8] tools: libxc: allow HVM firmware to be loaded at an arbitrary alignment
On Fri, May 13, 2011 at 02:42:30PM +0100, Ian Campbell wrote:> # HG changeset patch > # User Ian Campbell <ian.campbell@citrix.com> > # Date 1305294079 -3600 > # Node ID c5c7ae5f33b16ee03535e9c688ad9bee2510b2b6 > # Parent 9476bc07db2c654b266ab1f1c9ff0c65f401d74d > tools: libxc: allow HVM firmware to be loaded at an arbitrary alignment > > Enables direct loading of e.g. seabios.elf. > > Signed-off-by: Ian Campbell <ian.campbell@citrix.com> > > diff -r 9476bc07db2c -r c5c7ae5f33b1 tools/libxc/xc_hvm_build.c > --- a/tools/libxc/xc_hvm_build.c Fri May 13 14:41:19 2011 +0100 > +++ b/tools/libxc/xc_hvm_build.c Fri May 13 14:41:19 2011 +0100 > @@ -88,7 +88,9 @@ static int loadelfimage( > struct elf_binary *elf, uint32_t dom, unsigned long *parray) > { > privcmd_mmap_entry_t *entries = NULL; > - size_t pages = (elf->pend - elf->pstart + PAGE_SIZE - 1) >> PAGE_SHIFT; > + unsigned long pfn_start = elf->pstart >> PAGE_SHIFT; > + unsigned long pfn_end = (elf->pend + PAGE_SIZE - 1) >> PAGE_SHIFT; > + size_t pages = pfn_end - pfn_start; > int i, rc = -1; > > /* Map address space for initial elf image. */ > @@ -105,6 +107,8 @@ static int loadelfimage( > if ( elf->dest == NULL ) > goto err; > > + elf->dest += elf->pstart & 4095;Whoa. Decimal numbers! Threw me off when I saw this - so used to 0xfff. :-) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-May-13 14:29 UTC
Re: [Xen-devel] [PATCH 1 of 8] tools: libxc: allow HVM firmware to be loaded at an arbitrary alignment
On Fri, 2011-05-13 at 15:03 +0100, Konrad Rzeszutek Wilk wrote:> On Fri, May 13, 2011 at 02:42:30PM +0100, Ian Campbell wrote: > > # HG changeset patch > > # User Ian Campbell <ian.campbell@citrix.com> > > # Date 1305294079 -3600 > > # Node ID c5c7ae5f33b16ee03535e9c688ad9bee2510b2b6 > > # Parent 9476bc07db2c654b266ab1f1c9ff0c65f401d74d > > tools: libxc: allow HVM firmware to be loaded at an arbitrary alignment > > > > Enables direct loading of e.g. seabios.elf. > > > > Signed-off-by: Ian Campbell <ian.campbell@citrix.com> > > > > diff -r 9476bc07db2c -r c5c7ae5f33b1 tools/libxc/xc_hvm_build.c > > --- a/tools/libxc/xc_hvm_build.c Fri May 13 14:41:19 2011 +0100 > > +++ b/tools/libxc/xc_hvm_build.c Fri May 13 14:41:19 2011 +0100 > > @@ -88,7 +88,9 @@ static int loadelfimage( > > struct elf_binary *elf, uint32_t dom, unsigned long *parray) > > { > > privcmd_mmap_entry_t *entries = NULL; > > - size_t pages = (elf->pend - elf->pstart + PAGE_SIZE - 1) >> PAGE_SHIFT; > > + unsigned long pfn_start = elf->pstart >> PAGE_SHIFT; > > + unsigned long pfn_end = (elf->pend + PAGE_SIZE - 1) >> PAGE_SHIFT; > > + size_t pages = pfn_end - pfn_start; > > int i, rc = -1; > > > > /* Map address space for initial elf image. */ > > @@ -105,6 +107,8 @@ static int loadelfimage( > > if ( elf->dest == NULL ) > > goto err; > > > > + elf->dest += elf->pstart & 4095; > > Whoa. Decimal numbers! Threw me off when I saw this - so used to 0xfff. :-)Oops, I switch to the symbolic names for everything else but missed that one. Should be (PAGE_SIZE - 1). Updated version below. 8<--------------------------------------------------------------- # HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1305296917 -3600 # Node ID 07b02c79fc9c71ff3c8a966ad78cd8aa94210df5 # Parent 9476bc07db2c654b266ab1f1c9ff0c65f401d74d tools: libxc: allow HVM firmware to be loaded at an arbitrary alignment Enables direct loading of e.g. seabios.elf. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 9476bc07db2c -r 07b02c79fc9c tools/libxc/xc_hvm_build.c --- a/tools/libxc/xc_hvm_build.c Fri May 13 14:41:19 2011 +0100 +++ b/tools/libxc/xc_hvm_build.c Fri May 13 15:28:37 2011 +0100 @@ -88,7 +88,9 @@ static int loadelfimage( struct elf_binary *elf, uint32_t dom, unsigned long *parray) { privcmd_mmap_entry_t *entries = NULL; - size_t pages = (elf->pend - elf->pstart + PAGE_SIZE - 1) >> PAGE_SHIFT; + unsigned long pfn_start = elf->pstart >> PAGE_SHIFT; + unsigned long pfn_end = (elf->pend + PAGE_SIZE - 1) >> PAGE_SHIFT; + size_t pages = pfn_end - pfn_start; int i, rc = -1; /* Map address space for initial elf image. */ @@ -105,6 +107,8 @@ static int loadelfimage( if ( elf->dest == NULL ) goto err; + elf->dest += elf->pstart & (PAGE_SIZE - 1); + /* Load the initial elf image. */ elf_load_binary(elf); rc = 0; @@ -169,12 +173,6 @@ static int setup_guest(xc_interface *xch goto error_out; } - if ( (elf.pstart & (PAGE_SIZE - 1)) != 0 ) - { - PERROR("Guest OS must load to a page boundary."); - goto error_out; - } - IPRINTF("VIRTUAL MEMORY ARRANGEMENT:\n" " Loader: %016"PRIx64"->%016"PRIx64"\n" " TOTAL: %016"PRIx64"->%016"PRIx64"\n" _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2011-May-24 17:29 UTC
Re: [Xen-devel] [PATCH 0 of 8] tools: libx[cl]: support alternative HVM firmware
Ian Campbell writes ("[Xen-devel] [PATCH 0 of 8] tools: libx[cl]: support alternative HVM firmware"):> The following series makes it possible to use any ELF file as the > initial HVM domain firmware and begins to setup libxl to cope with > this.Thanks, for patches 1-7 (revised version, for no.1): Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com> How close are we to making the switch to seabios for new qemu ? Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-May-25 09:02 UTC
Re: [Xen-devel] [PATCH 0 of 8] tools: libx[cl]: support alternative HVM firmware
On Tue, 2011-05-24 at 18:29 +0100, Ian Jackson wrote:> Ian Campbell writes ("[Xen-devel] [PATCH 0 of 8] tools: libx[cl]: support alternative HVM firmware"): > > The following series makes it possible to use any ELF file as the > > initial HVM domain firmware and begins to setup libxl to cope with > > this. > > Thanks, for patches 1-7 (revised version, for no.1): > > Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> > Committed-by: Ian Jackson <ian.jackson@eu.citrix.com> > > How close are we to making the switch to seabios for new qemu ?I think strictly speaking we already have -- libxl in current xen-unstable.hg will tell hvmloader to use seabios already and hvmloader will barf unless you fed it a seabios binary at build time. The http://wiki.xen.org/xenwiki/QEMUUpstream wiki page covers acquiring all the necessary bits. I suspect your question was more "when will it be properly integrated with patches accepted into both projects". Initially I started working on an approach where SeaBIOS was loaded directly as the hvm firmware and did all the machine setup (PCI enumeration, ACPI table generation, chipset init etc etc). I had this approach working but was not happy with the amount of intrusion into SeaBIOS code. I''ve now reset and am trying the hvmloader->SeaBIOS approach. This is progressing well and the set of patches required on the SeaBIOS side is far smaller (without an equivalent growth on the hvmloader side since most of this stuff is already there for rombios). I''ve now changed my mind and think this is likely the best approach. I hope to get an initial set of patches to both projects for this second approach sent out soon (either this week or early next). Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel