Add mmio_hole_size (was Add pci_hole_min_size)
v3 cover Add mmio_hole_size (was Add pci_hole_min_size)
Changes from v3 to v4:
Jan Beulich:
s/pci_hole_min_size/mmio_hole_size/ s/HVM_BELOW_4G_RAM_END/HVM_BELOW_4G_MMIO_START/ Add ignore to hvmloader message
Adjust commit message
Dropped min; stopped mmio_hole_size changing in hvmloader
Open question: Should I switch this to max_ram_below_4g or stay with pci_hole_min_size?
This may help or fix http://bugs.xenproject.org/xen/bug/28
Changes from v2 to v3:
Dropped RFC since QEMU change will be in QEMU 2.1.0 release.
Dropped "if (dom_info.debug)" in parse_config_data() since dom_info no long passed in.
Lots more bounds checking. Since QEMU is a min(qemu_limit, max_ram_below_4g) adjust code the do the same.
Boris Ostrovsky:
More in commit message.
Changes from v1 to v2:
Boris Ostrovsky:
Need to init pci_hole_min_size
Changed the qemu name from pci_hole_min_size to
pc-memory-layout.max-ram-below-4g.
Did not change the Xen version for now.
Added quick note to xl.cfg.pod.5
Added a check for a too big value. (Most likely in the wrong place.)
If you add enough PCI devices then all mmio may not fit below 4G which may not be the layout the user wanted. This allows you to increase the below 4G address space that PCI devices can use and therefore in more cases not have any mmio that is above 4G.
There are real PCI cards that do not support mmio over 4G, so if you want to emulate them precisely, you may also need to increase the space below 4G for them. There are drivers for these cards that also do not work if they have their mmio space mapped above 4G.
This is posted as an RFC because you need the upstream version of qemu with all 4 patches:
http://marc.info/?l=qemu-devel&m=139455360016654&w=2
This allows growing the pci_hole to the size needed.
This may help with using pci passthru and HVM.
Don Slutz (1):
Add mmio_hole_size
docs/man/xl.cfg.pod.5 | 12 +++++++ tools/firmware/hvmloader/config.h | 1 - tools/firmware/hvmloader/pci.c | 71 +++++++++++++++++++++++++++------------ tools/libxc/xc_hvm_build_x86.c | 30 +++++++++++++++-- tools/libxc/xenguest.h | 11 ++++++ tools/libxl/libxl_create.c | 29 ++++++++++++---- tools/libxl/libxl_dm.c | 24 +++++++++++-- tools/libxl/libxl_dom.c | 3 +- tools/libxl/libxl_types.idl | 1 + tools/libxl/xl_cmdimpl.c | 13 +++++++ 10 files changed, 161 insertions(+), 34 deletions(-)
Signature · 1 line
1.8.4
PATCH v3 1/1 Add mmio_hole_size
If you add enough PCI devices then all mmio may not fit below 4G which may not be the layout the user wanted. This allows you to increase the below 4G address space that PCI devices can use and therefore in more cases not have any mmio that is above 4G.
There are real PCI cards that do not support mmio over 4G, so if you want to emulate them precisely, you may also need to increase the space below 4G for them. There are drivers for these cards that also do not work if they have their mmio space mapped above 4G.
This allows growing the MMIO hole to the size needed.
This may help with using pci passthru and HVM.
---
v4:
s/pci_hole_min_size/mmio_hole_size/ s/HVM_BELOW_4G_RAM_END/HVM_BELOW_4G_MMIO_START/ Add ignore to hvmloader message
Adjust commit message
Dropped min; stopped mmio_hole_size changing in hvmloader
v3:
Dropped "if (dom_info.debug)" in parse_config_data() since dom_info no long passed in.
Lots more bounds checking. Since QEMU is a min(qemu_limit, max_ram_below_4g) adjust code the do the same.
More in commit message.
docs/man/xl.cfg.pod.5 | 12 +++++++ tools/firmware/hvmloader/config.h | 1 - tools/firmware/hvmloader/pci.c | 71 +++++++++++++++++++++++++++------------ tools/libxc/xc_hvm_build_x86.c | 30 +++++++++++++++-- tools/libxc/xenguest.h | 11 ++++++ tools/libxl/libxl_create.c | 29 ++++++++++++---- tools/libxl/libxl_dm.c | 24 +++++++++++-- tools/libxl/libxl_dom.c | 3 +- tools/libxl/libxl_types.idl | 1 + tools/libxl/xl_cmdimpl.c | 13 +++++++ 10 files changed, 161 insertions(+), 34 deletions(-)
docs/man/xl.cfg.pod.5 +12 -0
@@ -1061,6 +1061,18 @@ wallclock (i.e., real) time. =back +=head3 Memory layout + +=over 4 + +=item B<mmio_hole_size=BYTES> + +Specifies the size the MMIO hole below 4GiB will be. Only valid for +device_model_version = "qemu-xen". Note: this requires QEMU 2.1.0 +or later. + +=back + =head3 Support for Paravirtualisation of HVM Guests The following options allow Paravirtualised features (such as devices)
tools/firmware/hvmloader/config.h +0 -1
@@ -53,7 +53,6 @@ extern struct bios_config ovmf_config;#define PCI_ISA_IRQ_MASK 0x0c20U/* ISA IRQs 5,10,11 are PCI connected */ /* MMIO hole: Hardcoded defaults, which can be dynamically expanded. */ -#define PCI_MEM_START 0xf0000000#define PCI_MEM_END 0xfc000000extern unsigned long pci_mem_start, pci_mem_end;
tools/firmware/hvmloader/pci.c +50 -21
97 lines not on this page · raw message
tools/libxc/xc_hvm_build_x86.c +28 -2
@@ -628,14 +628,40 @@ int xc_hvm_build_target_mem(xc_interface *xch,int target, const char *image_name) { + return xc_hvm_build_target_mem_with_hole(xch, domid, memsize, target, + image_name, 0); +} + +int xc_hvm_build_with_hole (xc_interface *xch,uint32_t domid, +struct xc_hvm_build_args *args, +uint64_t mmio_hole_size) +{ +if (mmio_hole_size) + { +uint64_t max_ram_below_4g = (1ULL <<32 ) - mmio_hole_size; + +if (max_ram_below_4g <HVM_BELOW_4G_MMIO_START ) + { + args->mmio_size = mmio_hole_size; + } + } +return xc_hvm_build (xch, domid, args); +} + +int xc_hvm_build_target_mem_with_hole (xc_interface *xch, +uint32_t domid, +int memsize, +int target, +const char *image_name, +uint64_t mmio_hole_size) +{struct xc_hvm_build_args args = {};memset (&args,0 ,sizeof (struct xc_hvm_build_args )); args.mem_size = (uint64_t )memsize <<20 ; args.mem_target = (uint64_t )target <<20 ; args.image_file_name = image_name; - -return xc_hvm_build (xch, domid, &args); +return xc_hvm_build_with_hole (xch, domid, &args, mmio_hole_size); }/*
tools/libxc/xenguest.h +11 -0
@@ -244,12 +244,23 @@ struct xc_hvm_build_args {int xc_hvm_build (xc_interface *xch,uint32_t domid,struct xc_hvm_build_args *hvm_args); +int xc_hvm_build_with_hole (xc_interface *xch,uint32_t domid, +struct xc_hvm_build_args *args, +uint64_t mmio_hole_size); +int xc_hvm_build_target_mem (xc_interface *xch,uint32_t domid,int memsize,int target,const char *image_name); +int xc_hvm_build_target_mem_with_hole (xc_interface *xch, +uint32_t domid, +int memsize, +int target, +const char *image_name, +uint64_t mmio_hole_size); +/* * Sets *lockfd to -1. * Has deallocated everything even on error.
tools/libxl/libxl_create.c +22 -7
@@ -23,6 +23,7 @@#include <xc_dom.h> #include <xenguest.h> #include <xen/hvm/hvm_info_table.h> +#include <xen/hvm/e820.h> int libxl__domain_create_info_setdefault (libxl__gc *gc,libxl_domain_create_info *c_info)
@@ -390,13 +391,26 @@ int libxl__domain_build(libxl__gc *gc, vments[4 ] ="start_time" ; vments[5 ] =libxl__sprintf (gc,"%lu.%02d" , start_time.tv_sec,(int )start_time.tv_usec/10000 ); - localents =libxl__calloc (gc,7 ,sizeof (char *)); - localents[0 ] ="platform/acpi" ; - localents[1 ] =libxl_defbool_val (info->u.hvm.acpi) ?"1" :"0" ; - localents[2 ] ="platform/acpi_s3" ; - localents[3 ] =libxl_defbool_val (info->u.hvm.acpi_s3) ?"1" :"0" ; - localents[4 ] ="platform/acpi_s4" ; - localents[5 ] =libxl_defbool_val (info->u.hvm.acpi_s4) ?"1" :"0" ; + localents =libxl__calloc (gc,9 ,sizeof (char *)); + i =0 ; + localents[i++] ="platform/acpi" ; + localents[i++] =libxl_defbool_val (info->u.hvm.acpi) ?"1" :"0" ; + localents[i++] ="platform/acpi_s3" ; + localents[i++] =libxl_defbool_val (info->u.hvm.acpi_s3) ?"1" :"0" ; + localents[i++] ="platform/acpi_s4" ; + localents[i++] =libxl_defbool_val (info->u.hvm.acpi_s4) ?"1" :"0" ; +if (info->u.hvm.mmio_hole_size) { +uint64_t max_ram_below_4g = + (1ULL <<32 ) - info->u.hvm.mmio_hole_size; + +if (max_ram_below_4g <=HVM_BELOW_4G_MMIO_START ) { + localents[i++] ="platform/mmio_hole_size" ; + localents[i++] = +libxl__sprintf (gc,"%" PRIu64, + info->u.hvm.mmio_hole_size); + } + } +assert (i <9 );break ;case LIBXL_DOMAIN_TYPE_PV :
@@ -422,6 +436,7 @@ int libxl__domain_build(libxl__gc *gc, vments[i++] ="image/cmdline" ; vments[i++] = (char *) state->pv_cmdline; } +assert (i <11 );break ;default :
tools/libxl/libxl_dm.c +22 -2
@@ -18,6 +18,7 @@#include "libxl_osdeps.h" /* must come before any other headers */ #include "libxl_internal.h" +#include <xen/hvm/e820.h> static const char *libxl_tapif_script (libxl__gc *gc) {
@@ -393,6 +394,7 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,const libxl_vnc_info *vnc =libxl__dm_vnc (guest_config);const libxl_sdl_info *sdl =dm_sdl (guest_config);const char *keymap =dm_keymap (guest_config); +char *machinearg;flexarray_t *dm_args;int i;uint64_t ram_size;
@@ -658,10 +660,28 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,/* Switching here to the machine "pc" which does not add * the xen-platform device instead of the default "xenfv" machine. */ -flexarray_append (dm_args,"pc,accel=xen" ); + machinearg =libxl__sprintf (gc,"pc,accel=xen" ); }else { -flexarray_append (dm_args,"xenfv" ); + machinearg =libxl__sprintf (gc,"xenfv" ); } +if (b_info->u.hvm.mmio_hole_size) { +uint64_t max_ram_below_4g = (1ULL <<32 ) - + b_info->u.hvm.mmio_hole_size; + +if (max_ram_below_4g >HVM_BELOW_4G_MMIO_START ) { +LIBXL__LOG (ctx,LIBXL__LOG_WARNING , +"max-ram-below-4g=%" PRIu64 +" (mmio_hole_size=%" PRIu64 +") too big > %u ignored.\n" , + max_ram_below_4g, + b_info->u.hvm.mmio_hole_size, +HVM_BELOW_4G_MMIO_START ); + }else { + machinearg =libxl__sprintf (gc,"%s,max-ram-below-4g=%" PRIu64, + machinearg, max_ram_below_4g); + } + } +flexarray_append (dm_args, machinearg);for (i =0 ; b_info->extra_hvm && b_info->extra_hvm[i] !=NULL ; i++)flexarray_append (dm_args, b_info->extra_hvm[i]);break ;
tools/libxl/libxl_dom.c +2 -1
@@ -683,7 +683,8 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid, goto out; } - ret =xc_hvm_build (ctx->xch, domid, &args); + ret =xc_hvm_build_with_hole (ctx->xch, domid, &args, + info->u.hvm.mmio_hole_size);if (ret) {LOGEV (ERROR , ret,"hvm building failed" ); goto out;
tools/libxl/libxl_types.idl +1 -0
@@ -367,6 +367,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("timeoffset", string), ("hpet", libxl_defbool), ("vpt_align", libxl_defbool), + ("mmio_hole_size", UInt(64, init_val = 0)), ("timer_mode", libxl_timer_mode), ("nested_hvm", libxl_defbool), ("smbios_firmware", string),
tools/libxl/xl_cmdimpl.c +13 -0
@@ -34,6 +34,7 @@#include <ctype.h> #include <inttypes.h> #include <limits.h> +#include <xen/hvm/e820.h> #include "libxl.h" #include "libxl_utils.h"
@@ -955,6 +956,18 @@ static void parse_config_data(const char *config_source,xlu_cfg_get_defbool (config,"hpet" , &b_info->u.hvm.hpet,0 );xlu_cfg_get_defbool (config,"vpt_align" , &b_info->u.hvm.vpt_align,0 ); +if (!xlu_cfg_get_long (config,"mmio_hole_size" , &l,0 )) { + b_info->u.hvm.mmio_hole_size = (uint64_t ) l; +if (b_info->u.hvm.mmio_hole_size <HVM_BELOW_4G_MMIO_LENGTH || + b_info->u.hvm.mmio_hole_size >HVM_BELOW_4G_MMIO_START ) { +fprintf (stderr,"ERROR: invalid value 0x%" PRIx64" (%" PRIu64 +") for \"mmio_hole_size\"\n" , + b_info->u.hvm.mmio_hole_size, + b_info->u.hvm.mmio_hole_size); +exit (1 ); + } + } +if (!xlu_cfg_get_long (config,"timer_mode" , &l,1 )) {const char *s =libxl_timer_mode_to_string (l); fprintf(stderr, "WARNING: specifying \"timer_mode\" as an integer is deprecated. "
Signature · 1 line
1.8.4
Quoted 3 lines · Don Slutz
Changes from v3 to v4:
Opps, the v3 in the title is wrong. it should be v4.
-Don Slutz