[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v3 01/24] xen: Extend DOMCTL createdomain to support arch configuration



On Tue, 13 Jan 2015, Julien Grall wrote:
> On ARM the virtual GIC may differ between each guest (emulated GIC version,
> number of SPIs...). Those informations are already known at the domain 
> creation
> and can never change.
> 
> For now only the gic_version is set. In long run, there will be more 
> parameters
> such as the number of SPIs. All will be required to be set at the same time.
> 
> A new arch-specific structure arch_domainconfig has been created, the x86
> one doesn't have any specific configuration, a dummy structure
> (C-spec compliant) has been created to factorize the code on the toolstack.
> 
> Some external tools (qemu, xenstore) may require to create a domain. Rather
> than asking them to take care of the arch-specific domain configuration, let
> the current function (xc_domain_create) to chose a default configuration and
> introduce a new one (xc_domain_create_config).
> 
> This patch also drop the previously DOMCTL arm_configure_domain introduced
> in Xen 4.5, as it has been made useless.
> 
> Signed-off-by: Julien Grall <julien.grall@xxxxxxxxxx>
> Cc: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
> Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
> Cc: Wei Liu <wei.liu2@xxxxxxxxxx>
> Cc: Stefano Stabellini <stefano.stabellini@xxxxxxxxxx>
> Cc: Keir Fraser <keir@xxxxxxx>
> Cc: Jan Beulich <jbeulich@xxxxxxxx>
> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> Cc: George Dunlap <george.dunlap@xxxxxxxxxxxxx>

Acked-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>


>     This is a follow-up of 
> http://lists.xen.org/archives/html/xen-devel/2014-11/msg00522.html
> 
>     TODO: What about migration? For now the configuration lives in internal
>     libxl structure. We need a way to pass the domain configuration to the
>     other end.
> 
>     I'm not sure if we should care of this right now as migration doesn't
>     yet exists on ARM.
> 
>     For the xc_domain_create, Stefano S. was looking to drop PV domain
>     creation support in QEMU. So maybe I could simply extend xc_domain_create
>     and drop the xc_domain_create_config.
> 
>     Changes in v3:
>         - Patch was previously sent in a separate series [1]
>         - Rename arch_domainconfig to xen_arch_domainconfig
>         - Drop the typedef
>         - Pass NULL for DOM0 config on x86
>         - Drop spurious changes
>         - Update comment in start_xen in arch/arm/setup.c
> 
>         [1] https://patches.linaro.org/41083/
> ---
>  tools/flask/policy/policy/modules/xen/xen.if |  2 +-
>  tools/libxc/include/xenctrl.h                | 14 +++++----
>  tools/libxc/xc_domain.c                      | 46 
> ++++++++++++++++------------
>  tools/libxl/libxl_arch.h                     |  6 ++++
>  tools/libxl/libxl_arm.c                      | 28 ++++++++++-------
>  tools/libxl/libxl_create.c                   | 21 ++++++++++---
>  tools/libxl/libxl_dm.c                       |  3 +-
>  tools/libxl/libxl_dom.c                      |  2 +-
>  tools/libxl/libxl_internal.h                 |  7 +++--
>  tools/libxl/libxl_x86.c                      | 10 ++++++
>  xen/arch/arm/domain.c                        | 28 ++++++++++++++++-
>  xen/arch/arm/domctl.c                        | 34 --------------------
>  xen/arch/arm/mm.c                            |  6 ++--
>  xen/arch/arm/setup.c                         |  6 +++-
>  xen/arch/x86/domain.c                        |  3 +-
>  xen/arch/x86/mm.c                            |  6 ++--
>  xen/arch/x86/setup.c                         |  8 +++--
>  xen/common/domain.c                          |  7 +++--
>  xen/common/domctl.c                          |  3 +-
>  xen/common/schedule.c                        |  3 +-
>  xen/include/public/arch-arm.h                |  8 +++++
>  xen/include/public/arch-x86/xen.h            |  4 +++
>  xen/include/public/domctl.h                  | 18 +----------
>  xen/include/xen/domain.h                     |  3 +-
>  xen/include/xen/sched.h                      |  9 ++++--
>  xen/xsm/flask/hooks.c                        |  3 --
>  xen/xsm/flask/policy/access_vectors          |  2 --
>  27 files changed, 170 insertions(+), 120 deletions(-)
> 
> diff --git a/tools/flask/policy/policy/modules/xen/xen.if 
> b/tools/flask/policy/policy/modules/xen/xen.if
> index 2d32e1c..620d151 100644
> --- a/tools/flask/policy/policy/modules/xen/xen.if
> +++ b/tools/flask/policy/policy/modules/xen/xen.if
> @@ -51,7 +51,7 @@ define(`create_domain_common', `
>                       getaffinity setaffinity setvcpuextstate };
>       allow $1 $2:domain2 { set_cpuid settsc setscheduler setclaim
>                       set_max_evtchn set_vnumainfo get_vnumainfo cacheflush
> -                     psr_cmt_op configure_domain };
> +                     psr_cmt_op };
>       allow $1 $2:security check_context;
>       allow $1 $2:shadow enable;
>       allow $1 $2:mmu { map_read map_write adjust memorymap physmap pinpage 
> mmuext_op updatemp };
> diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
> index 0ad8b8d..d66571f 100644
> --- a/tools/libxc/include/xenctrl.h
> +++ b/tools/libxc/include/xenctrl.h
> @@ -477,18 +477,20 @@ typedef union
>  } start_info_any_t;
>  #endif
>  
> +
> +typedef struct xen_arch_domainconfig xc_domain_configuration_t;
> +int xc_domain_create_config(xc_interface *xch,
> +                            uint32_t ssidref,
> +                            xen_domain_handle_t handle,
> +                            uint32_t flags,
> +                            uint32_t *pdomid,
> +                            xc_domain_configuration_t *config);
>  int xc_domain_create(xc_interface *xch,
>                       uint32_t ssidref,
>                       xen_domain_handle_t handle,
>                       uint32_t flags,
>                       uint32_t *pdomid);
>  
> -#if defined(__arm__) || defined(__aarch64__)
> -typedef xen_domctl_arm_configuredomain_t xc_domain_configuration_t;
> -
> -int xc_domain_configure(xc_interface *xch, uint32_t domid,
> -                        xc_domain_configuration_t *config);
> -#endif
>  
>  /* Functions to produce a dump of a given domain
>   *  xc_domain_dumpcore - produces a dump to a specified file
> diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
> index b864872..eebc121 100644
> --- a/tools/libxc/xc_domain.c
> +++ b/tools/libxc/xc_domain.c
> @@ -27,11 +27,12 @@
>  #include <xen/memory.h>
>  #include <xen/hvm/hvm_op.h>
>  
> -int xc_domain_create(xc_interface *xch,
> -                     uint32_t ssidref,
> -                     xen_domain_handle_t handle,
> -                     uint32_t flags,
> -                     uint32_t *pdomid)
> +int xc_domain_create_config(xc_interface *xch,
> +                            uint32_t ssidref,
> +                            xen_domain_handle_t handle,
> +                            uint32_t flags,
> +                            uint32_t *pdomid,
> +                            xc_domain_configuration_t *config)
>  {
>      int err;
>      DECLARE_DOMCTL;
> @@ -41,32 +42,39 @@ int xc_domain_create(xc_interface *xch,
>      domctl.u.createdomain.ssidref = ssidref;
>      domctl.u.createdomain.flags   = flags;
>      memcpy(domctl.u.createdomain.handle, handle, 
> sizeof(xen_domain_handle_t));
> +    /* xc_domain_configure_t is an alias of arch_domainconfig_t */
> +    memcpy(&domctl.u.createdomain.config, config, sizeof(*config));
>      if ( (err = do_domctl(xch, &domctl)) != 0 )
>          return err;
>  
>      *pdomid = (uint16_t)domctl.domain;
> +    memcpy(config, &domctl.u.createdomain.config, sizeof(*config));
> +
>      return 0;
>  }
>  
> -#if defined(__arm__) || defined(__aarch64__)
> -int xc_domain_configure(xc_interface *xch, uint32_t domid,
> -                        xc_domain_configuration_t *config)
> +int xc_domain_create(xc_interface *xch,
> +                     uint32_t ssidref,
> +                     xen_domain_handle_t handle,
> +                     uint32_t flags,
> +                     uint32_t *pdomid)
>  {
> -    int rc;
> -    DECLARE_DOMCTL;
> +    xc_domain_configuration_t config;
>  
> -    domctl.cmd = XEN_DOMCTL_arm_configure_domain;
> -    domctl.domain = (domid_t)domid;
> -    /* xc_domain_configure_t is an alias of xen_domctl_arm_configuredomain */
> -    memcpy(&domctl.u.configuredomain, config, sizeof(*config));
> +    memset(&config, 0, sizeof(config));
>  
> -    rc = do_domctl(xch, &domctl);
> -    if ( !rc )
> -        memcpy(config, &domctl.u.configuredomain, sizeof(*config));
> +#if defined (__i386) || defined(__x86_64__)
> +    /* No arch-specific configuration for now */
> +#elif defined (__arm__) || defined(__aarch64__)
> +    config.gic_version = XEN_DOMCTL_CONFIG_GIC_DEFAULT;
> +#else
> +    errno = ENOSYS;
> +    return -1;
> +#endif
>  
> -    return rc;
> +    return xc_domain_create_config(xch, ssidref, handle,
> +                                   flags, pdomid, &config);
>  }
> -#endif
>  
>  int xc_domain_cacheflush(xc_interface *xch, uint32_t domid,
>                           xen_pfn_t start_pfn, xen_pfn_t nr_pfns)
> diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h
> index d3bc136..f806ed1 100644
> --- a/tools/libxl/libxl_arch.h
> +++ b/tools/libxl/libxl_arch.h
> @@ -15,6 +15,11 @@
>  #ifndef LIBXL_ARCH_H
>  #define LIBXL_ARCH_H
>  
> +/* fill the arch specific configuration for the domain */
> +int libxl__arch_domain_prepare_config(libxl__gc *gc,
> +                                      libxl_domain_config *d_config,
> +                                      xc_domain_configuration_t *xc_config);
> +
>  /* arch specific internal domain creation function */
>  int libxl__arch_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
>                 uint32_t domid);
> @@ -22,6 +27,7 @@ int libxl__arch_domain_create(libxl__gc *gc, 
> libxl_domain_config *d_config,
>  /* setup arch specific hardware description, i.e. DTB on ARM */
>  int libxl__arch_domain_init_hw_description(libxl__gc *gc,
>                                             libxl_domain_build_info *info,
> +                                           libxl__domain_build_state *state,
>                                             struct xc_dom_image *dom);
>  /* finalize arch specific hardware description. */
>  int libxl__arch_domain_finalise_hw_description(libxl__gc *gc,
> diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
> index 65a762b..cddce6e 100644
> --- a/tools/libxl/libxl_arm.c
> +++ b/tools/libxl/libxl_arm.c
> @@ -35,6 +35,15 @@ static const char *gicv_to_string(uint8_t gic_version)
>      }
>  }
>  
> +int libxl__arch_domain_prepare_config(libxl__gc *gc,
> +                                      libxl_domain_config *d_config,
> +                                      xc_domain_configuration_t *xc_config)
> +{
> +    xc_config->gic_version = XEN_DOMCTL_CONFIG_GIC_DEFAULT;
> +
> +    return 0;
> +}
> +
>  int libxl__arch_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
>                                uint32_t domid)
>  {
> @@ -516,9 +525,9 @@ out:
>  
>  int libxl__arch_domain_init_hw_description(libxl__gc *gc,
>                                             libxl_domain_build_info *info,
> +                                           libxl__domain_build_state *state,
>                                             struct xc_dom_image *dom)
>  {
> -    xc_domain_configuration_t config;
>      void *fdt = NULL;
>      int rc, res;
>      size_t fdt_size = 0;
> @@ -526,6 +535,9 @@ int libxl__arch_domain_init_hw_description(libxl__gc *gc,
>      const libxl_version_info *vers;
>      const struct arch_info *ainfo;
>  
> +    /* convenience aliases */
> +    xc_domain_configuration_t *xc_config = &state->config;
> +
>      assert(info->type == LIBXL_DOMAIN_TYPE_PV);
>  
>      vers = libxl_get_version_info(CTX);
> @@ -534,16 +546,9 @@ int libxl__arch_domain_init_hw_description(libxl__gc *gc,
>      ainfo = get_arch_info(gc, dom);
>      if (ainfo == NULL) return ERROR_FAIL;
>  
> -    LOG(DEBUG, "configure the domain");
> -    config.gic_version = XEN_DOMCTL_CONFIG_GIC_DEFAULT;
> -    if (xc_domain_configure(CTX->xch, dom->guest_domid, &config) != 0) {
> -        LOG(ERROR, "couldn't configure the domain");
> -        return ERROR_FAIL;
> -    }
> -
>      LOG(DEBUG, "constructing DTB for Xen version %d.%d guest",
>          vers->xen_version_major, vers->xen_version_minor);
> -    LOG(DEBUG, "  - vGIC version: %s", gicv_to_string(config.gic_version));
> +    LOG(DEBUG, " - vGIC version: %s\n", 
> gicv_to_string(xc_config->gic_version));
>  
>  /*
>   * Call "call" handling FDT_ERR_*. Will either:
> @@ -592,7 +597,7 @@ next_resize:
>  
>          FDT( make_memory_nodes(gc, fdt, dom) );
>  
> -        switch (config.gic_version) {
> +        switch (xc_config->gic_version) {
>          case XEN_DOMCTL_CONFIG_GIC_V2:
>              FDT( make_gicv2_node(gc, fdt,
>                                   GUEST_GICD_BASE, GUEST_GICD_SIZE,
> @@ -602,7 +607,8 @@ next_resize:
>              FDT( make_gicv3_node(gc, fdt) );
>              break;
>          default:
> -            LOG(ERROR, "Unknown GIC version %d", config.gic_version);
> +            LOG(ERROR, "Unknown GIC version %s",
> +                gicv_to_string(xc_config->gic_version));
>              rc = ERROR_FAIL;
>              goto out;
>          }
> diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
> index 6f87d1c..029d2e2 100644
> --- a/tools/libxl/libxl_create.c
> +++ b/tools/libxl/libxl_create.c
> @@ -489,8 +489,8 @@ out:
>      return ret;
>  }
>  
> -int libxl__domain_make(libxl__gc *gc, libxl_domain_create_info *info,
> -                       uint32_t *domid)
> +int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config,
> +                       uint32_t *domid, xc_domain_configuration_t *xc_config)
>  {
>      libxl_ctx *ctx = libxl__gc_owner(gc);
>      int flags, ret, rc, nb_vm;
> @@ -503,6 +503,8 @@ int libxl__domain_make(libxl__gc *gc, 
> libxl_domain_create_info *info,
>      xen_domain_handle_t handle;
>      libxl_vminfo *vm_list;
>  
> +    /* convenience aliases */
> +    libxl_domain_create_info *info = &d_config->c_info;
>  
>      assert(!libxl_domid_valid_guest(*domid));
>  
> @@ -531,7 +533,16 @@ int libxl__domain_make(libxl__gc *gc, 
> libxl_domain_create_info *info,
>      /* Ultimately, handle is an array of 16 uint8_t, same as uuid */
>      libxl_uuid_copy(ctx, (libxl_uuid *)handle, &info->uuid);
>  
> -    ret = xc_domain_create(ctx->xch, info->ssidref, handle, flags, domid);
> +    ret = libxl__arch_domain_prepare_config(gc, d_config, xc_config);
> +    if (ret < 0) {
> +        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "fail to get domain config");
> +        rc = ERROR_FAIL;
> +        goto out;
> +    }
> +
> +    ret = xc_domain_create_config(ctx->xch, info->ssidref,
> +                                  handle, flags, domid,
> +                                  xc_config);
>      if (ret < 0) {
>          LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "domain creation fail");
>          rc = ERROR_FAIL;
> @@ -764,9 +775,11 @@ static void initiate_domain_create(libxl__egc *egc,
>  
>      /* convenience aliases */
>      libxl_domain_config *const d_config = dcs->guest_config;
> +    libxl__domain_build_state *const state = &dcs->build_state;
>      const int restore_fd = dcs->restore_fd;
>      memset(&dcs->build_state, 0, sizeof(dcs->build_state));
>  
> +
>      domid = 0;
>  
>      if (d_config->c_info.ssid_label) {
> @@ -848,7 +861,7 @@ static void initiate_domain_create(libxl__egc *egc,
>      ret = libxl__domain_create_info_setdefault(gc, &d_config->c_info);
>      if (ret) goto error_out;
>  
> -    ret = libxl__domain_make(gc, &d_config->c_info, &domid);
> +    ret = libxl__domain_make(gc, d_config, &domid, &state->config);
>      if (ret) {
>          LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot make domain: %d", ret);
>          dcs->guest_domid = domid;
> diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
> index c2b0487..f5f9e6d 100644
> --- a/tools/libxl/libxl_dm.c
> +++ b/tools/libxl/libxl_dm.c
> @@ -1063,7 +1063,8 @@ void libxl__spawn_stub_dm(libxl__egc *egc, 
> libxl__stub_dm_spawn_state *sdss)
>      stubdom_state->pv_ramdisk.path = "";
>  
>      /* fixme: this function can leak the stubdom if it fails */
> -    ret = libxl__domain_make(gc, &dm_config->c_info, 
> &sdss->pvqemu.guest_domid);
> +    ret = libxl__domain_make(gc, dm_config, &sdss->pvqemu.guest_domid,
> +                             &stubdom_state->config);
>      if (ret)
>          goto out;
>      uint32_t dm_domid = sdss->pvqemu.guest_domid;
> diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
> index 48d661a..1bea260 100644
> --- a/tools/libxl/libxl_dom.c
> +++ b/tools/libxl/libxl_dom.c
> @@ -586,7 +586,7 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid,
>          LOGE(ERROR, "xc_dom_parse_image failed");
>          goto out;
>      }
> -    if ( (ret = libxl__arch_domain_init_hw_description(gc, info, dom)) != 0 
> ) {
> +    if ( (ret = libxl__arch_domain_init_hw_description(gc, info, state, 
> dom)) != 0 ) {
>          LOGE(ERROR, "libxl__arch_domain_init_hw_description failed");
>          goto out;
>      }
> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index 934465a..be5ed82 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -973,6 +973,8 @@ typedef struct {
>      libxl__file_reference pv_ramdisk;
>      const char * pv_cmdline;
>      bool pvh_enabled;
> +
> +    xc_domain_configuration_t config;
>  } libxl__domain_build_state;
>  
>  _hidden int libxl__build_pre(libxl__gc *gc, uint32_t domid,
> @@ -1462,8 +1464,9 @@ _hidden  void libxl__exec(libxl__gc *gc, int stdinfd, 
> int stdoutfd,
>   /* on entry, libxl_domid_valid_guest(domid) must be false;
>    * on exit (even error exit), domid may be valid and refer to a domain */
>  _hidden int libxl__domain_make(libxl__gc *gc,
> -                               libxl_domain_create_info *info,
> -                               uint32_t *domid);
> +                               libxl_domain_config *d_config,
> +                               uint32_t *domid,
> +                               xc_domain_configuration_t *xc_config);
>  
>  _hidden int libxl__domain_build(libxl__gc *gc,
>                                  libxl_domain_config *d_config,
> diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c
> index 9ceb373..b054d9d 100644
> --- a/tools/libxl/libxl_x86.c
> +++ b/tools/libxl/libxl_x86.c
> @@ -1,6 +1,15 @@
>  #include "libxl_internal.h"
>  #include "libxl_arch.h"
>  
> +int libxl__arch_domain_prepare_config(libxl__gc *gc,
> +                                      libxl_domain_config *d_config,
> +                                      xc_domain_configuration_t *xc_config)
> +{
> +    /* No specific configuration right now */
> +
> +    return 0;
> +}
> +
>  static const char *e820_names(int type)
>  {
>      switch (type) {
> @@ -313,6 +322,7 @@ int libxl__arch_domain_create(libxl__gc *gc, 
> libxl_domain_config *d_config,
>  
>  int libxl__arch_domain_init_hw_description(libxl__gc *gc,
>                                             libxl_domain_build_info *info,
> +                                           libxl__domain_build_state *state,
>                                             struct xc_dom_image *dom)
>  {
>      return 0;
> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> index 589b095..2473b10 100644
> --- a/xen/arch/arm/domain.c
> +++ b/xen/arch/arm/domain.c
> @@ -504,9 +504,11 @@ void vcpu_destroy(struct vcpu *v)
>      free_xenheap_pages(v->arch.stack, STACK_ORDER);
>  }
>  
> -int arch_domain_create(struct domain *d, unsigned int domcr_flags)
> +int arch_domain_create(struct domain *d, unsigned int domcr_flags,
> +                       struct xen_arch_domainconfig *config)
>  {
>      int rc;
> +    uint8_t gic_version;
>  
>      d->arch.relmem = RELMEM_not_started;
>  
> @@ -514,6 +516,7 @@ int arch_domain_create(struct domain *d, unsigned int 
> domcr_flags)
>      if ( is_idle_domain(d) )
>          return 0;
>  
> +    ASSERT(config != NULL);
>      if ( (rc = p2m_init(d)) != 0 )
>          goto fail;
>  
> @@ -534,6 +537,29 @@ int arch_domain_create(struct domain *d, unsigned int 
> domcr_flags)
>      if ( (rc = p2m_alloc_table(d)) != 0 )
>          goto fail;
>  
> +    /*
> +     * Currently the vGIC is emulating the same version of the
> +     * hardware GIC. Only the value XEN_DOMCTL_CONFIG_GIC_DEFAULT
> +     * is allowed. The DOMCTL will return the actual version of the
> +     * GIC.
> +     */
> +    rc = -EOPNOTSUPP;
> +    if ( config->gic_version != XEN_DOMCTL_CONFIG_GIC_DEFAULT )
> +        goto fail;
> +
> +    switch ( gic_hw_version() )
> +    {
> +    case GIC_V3:
> +        gic_version = XEN_DOMCTL_CONFIG_GIC_V3;
> +        break;
> +    case GIC_V2:
> +        gic_version = XEN_DOMCTL_CONFIG_GIC_V2;
> +        break;
> +    default:
> +        BUG();
> +    }
> +    config->gic_version = gic_version;
> +
>      if ( (rc = gicv_setup(d)) != 0 )
>          goto fail;
>  
> diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c
> index d246e84..485d3aa 100644
> --- a/xen/arch/arm/domctl.c
> +++ b/xen/arch/arm/domctl.c
> @@ -32,40 +32,6 @@ long arch_do_domctl(struct xen_domctl *domctl, struct 
> domain *d,
>  
>          return p2m_cache_flush(d, s, e);
>      }
> -    case XEN_DOMCTL_arm_configure_domain:
> -    {
> -        uint8_t gic_version;
> -
> -        /*
> -         * Currently the vGIC is emulating the same version of the
> -         * hardware GIC. Only the value XEN_DOMCTL_CONFIG_GIC_DEFAULT
> -         * is allowed. The DOMCTL will return the actual version of the
> -         * GIC.
> -         */
> -        if ( domctl->u.configuredomain.gic_version != 
> XEN_DOMCTL_CONFIG_GIC_DEFAULT )
> -            return -EOPNOTSUPP;
> -
> -        switch ( gic_hw_version() )
> -        {
> -        case GIC_V3:
> -            gic_version = XEN_DOMCTL_CONFIG_GIC_V3;
> -            break;
> -        case GIC_V2:
> -            gic_version = XEN_DOMCTL_CONFIG_GIC_V2;
> -            break;
> -        default:
> -            BUG();
> -        }
> -
> -        domctl->u.configuredomain.gic_version = gic_version;
> -
> -        /* TODO: Make the copy generic for all ARCH domctl */
> -        if ( __copy_to_guest(u_domctl, domctl, 1) )
> -            return -EFAULT;
> -
> -        return 0;
> -    }
> -
>      default:
>          return subarch_do_domctl(domctl, d, u_domctl);
>      }
> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index 7d4ba0c..9128af1 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -399,7 +399,7 @@ void __init arch_init_memory(void)
>       * Any Xen-heap pages that we will allow to be mapped will have
>       * their domain field set to dom_xen.
>       */
> -    dom_xen = domain_create(DOMID_XEN, DOMCRF_dummy, 0);
> +    dom_xen = domain_create(DOMID_XEN, DOMCRF_dummy, 0, NULL);
>      BUG_ON(IS_ERR(dom_xen));
>  
>      /*
> @@ -407,14 +407,14 @@ void __init arch_init_memory(void)
>       * This domain owns I/O pages that are within the range of the page_info
>       * array. Mappings occur at the priv of the caller.
>       */
> -    dom_io = domain_create(DOMID_IO, DOMCRF_dummy, 0);
> +    dom_io = domain_create(DOMID_IO, DOMCRF_dummy, 0, NULL);
>      BUG_ON(IS_ERR(dom_io));
>  
>      /*
>       * Initialise our COW domain.
>       * This domain owns sharable pages.
>       */
> -    dom_cow = domain_create(DOMID_COW, DOMCRF_dummy, 0);
> +    dom_cow = domain_create(DOMID_COW, DOMCRF_dummy, 0, NULL);
>      BUG_ON(IS_ERR(dom_cow));
>  }
>  
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index f49569d..4d242e0 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -697,6 +697,7 @@ void __init start_xen(unsigned long boot_phys_offset,
>      const char *cmdline;
>      struct bootmodule *xen_bootmodule;
>      struct domain *dom0;
> +    struct xen_arch_domainconfig config;
>  
>      setup_cache();
>  
> @@ -811,7 +812,10 @@ void __init start_xen(unsigned long boot_phys_offset,
>      do_initcalls();
>  
>      /* Create initial domain 0. */
> -    dom0 = domain_create(0, 0, 0);
> +    /* The vGIC for DOM0 is exactly emulated the hardware GIC */
> +    config.gic_version = XEN_DOMCTL_CONFIG_GIC_DEFAULT;
> +
> +    dom0 = domain_create(0, 0, 0, &config);
>      if ( IS_ERR(dom0) || (alloc_dom0_vcpu0(dom0) == NULL) )
>              panic("Error creating domain 0");
>  
> diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
> index c8832c6..e174f28 100644
> --- a/xen/arch/x86/domain.c
> +++ b/xen/arch/x86/domain.c
> @@ -514,7 +514,8 @@ void vcpu_destroy(struct vcpu *v)
>          xfree(v->arch.pv_vcpu.trap_ctxt);
>  }
>  
> -int arch_domain_create(struct domain *d, unsigned int domcr_flags)
> +int arch_domain_create(struct domain *d, unsigned int domcr_flags,
> +                       struct xen_arch_domainconfig *config)
>  {
>      int i, paging_initialised = 0;
>      int rc = -ENOMEM;
> diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
> index 6e9c2c0..ef4d149 100644
> --- a/xen/arch/x86/mm.c
> +++ b/xen/arch/x86/mm.c
> @@ -275,7 +275,7 @@ void __init arch_init_memory(void)
>       * Hidden PCI devices will also be associated with this domain
>       * (but be [partly] controlled by Dom0 nevertheless).
>       */
> -    dom_xen = domain_create(DOMID_XEN, DOMCRF_dummy, 0);
> +    dom_xen = domain_create(DOMID_XEN, DOMCRF_dummy, 0, NULL);
>      BUG_ON(IS_ERR(dom_xen));
>      INIT_LIST_HEAD(&dom_xen->arch.pdev_list);
>  
> @@ -284,14 +284,14 @@ void __init arch_init_memory(void)
>       * This domain owns I/O pages that are within the range of the page_info
>       * array. Mappings occur at the priv of the caller.
>       */
> -    dom_io = domain_create(DOMID_IO, DOMCRF_dummy, 0);
> +    dom_io = domain_create(DOMID_IO, DOMCRF_dummy, 0, NULL);
>      BUG_ON(IS_ERR(dom_io));
>      
>      /*
>       * Initialise our COW domain.
>       * This domain owns sharable pages.
>       */
> -    dom_cow = domain_create(DOMID_COW, DOMCRF_dummy, 0);
> +    dom_cow = domain_create(DOMID_COW, DOMCRF_dummy, 0, NULL);
>      BUG_ON(IS_ERR(dom_cow));
>  
>      /* First 1MB of RAM is historically marked as I/O. */
> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> index c27c49c..6ce51f6 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -1347,8 +1347,12 @@ void __init noreturn __start_xen(unsigned long mbi_p)
>      if ( opt_dom0pvh )
>          domcr_flags |= DOMCRF_pvh | DOMCRF_hap;
>  
> -    /* Create initial domain 0. */
> -    dom0 = domain_create(0, domcr_flags, 0);
> +    /*
> +     * Create initial domain 0.
> +     * x86 doesn't support arch-configuration. So it's fine to pass
> +     * NULL.
> +     */
> +    dom0 = domain_create(0, domcr_flags, 0, NULL);
>      if ( IS_ERR(dom0) || (alloc_dom0_vcpu0(dom0) == NULL) )
>          panic("Error creating domain 0");
>  
> diff --git a/xen/common/domain.c b/xen/common/domain.c
> index 336e9ea..9448bf6 100644
> --- a/xen/common/domain.c
> +++ b/xen/common/domain.c
> @@ -242,8 +242,9 @@ static void __init parse_extra_guest_irqs(const char *s)
>  }
>  custom_param("extra_guest_irqs", parse_extra_guest_irqs);
>  
> -struct domain *domain_create(
> -    domid_t domid, unsigned int domcr_flags, uint32_t ssidref)
> +struct domain *domain_create(domid_t domid, unsigned int domcr_flags,
> +                             uint32_t ssidref,
> +                             struct xen_arch_domainconfig *config)
>  {
>      struct domain *d, **pd, *old_hwdom = NULL;
>      enum { INIT_xsm = 1u<<0, INIT_watchdog = 1u<<1, INIT_rangeset = 1u<<2,
> @@ -353,7 +354,7 @@ struct domain *domain_create(
>              goto fail;
>      }
>  
> -    if ( (err = arch_domain_create(d, domcr_flags)) != 0 )
> +    if ( (err = arch_domain_create(d, domcr_flags, config)) != 0 )
>          goto fail;
>      init_status |= INIT_arch;
>  
> diff --git a/xen/common/domctl.c b/xen/common/domctl.c
> index ee578c0..6a0f53a 100644
> --- a/xen/common/domctl.c
> +++ b/xen/common/domctl.c
> @@ -582,7 +582,8 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) 
> u_domctl)
>          if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_oos_off )
>              domcr_flags |= DOMCRF_oos_off;
>  
> -        d = domain_create(dom, domcr_flags, op->u.createdomain.ssidref);
> +        d = domain_create(dom, domcr_flags, op->u.createdomain.ssidref,
> +                          &op->u.createdomain.config);
>          if ( IS_ERR(d) )
>          {
>              ret = PTR_ERR(d);
> diff --git a/xen/common/schedule.c b/xen/common/schedule.c
> index 6285a6e..ab2561a 100644
> --- a/xen/common/schedule.c
> +++ b/xen/common/schedule.c
> @@ -1421,7 +1421,8 @@ void __init scheduler_init(void)
>          sched_ratelimit_us = SCHED_DEFAULT_RATELIMIT_US;
>      }
>  
> -    idle_domain = domain_create(DOMID_IDLE, 0, 0);
> +    /* There is no need of arch-specific configuration for an idle domain */
> +    idle_domain = domain_create(DOMID_IDLE, 0, 0, NULL);
>      BUG_ON(IS_ERR(idle_domain));
>      idle_domain->vcpu = idle_vcpu;
>      idle_domain->max_vcpus = nr_cpu_ids;
> diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h
> index e711606..4c1b9f9 100644
> --- a/xen/include/public/arch-arm.h
> +++ b/xen/include/public/arch-arm.h
> @@ -314,6 +314,14 @@ struct arch_shared_info {
>  typedef struct arch_shared_info arch_shared_info_t;
>  typedef uint64_t xen_callback_t;
>  
> +#define XEN_DOMCTL_CONFIG_GIC_DEFAULT   0
> +#define XEN_DOMCTL_CONFIG_GIC_V2        1
> +#define XEN_DOMCTL_CONFIG_GIC_V3        2
> +struct xen_arch_domainconfig {
> +    /* IN/OUT */
> +    uint8_t gic_version;
> +};
> +
>  #endif
>  
>  #if defined(__XEN__) || defined(__XEN_TOOLS__)
> diff --git a/xen/include/public/arch-x86/xen.h 
> b/xen/include/public/arch-x86/xen.h
> index c5e880b..d07d550 100644
> --- a/xen/include/public/arch-x86/xen.h
> +++ b/xen/include/public/arch-x86/xen.h
> @@ -258,6 +258,10 @@ struct arch_shared_info {
>  };
>  typedef struct arch_shared_info arch_shared_info_t;
>  
> +struct xen_arch_domainconfig {
> +    char dummy;
> +};
> +
>  #endif /* !__ASSEMBLY__ */
>  
>  /*
> diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
> index 57e2ed7..b742b23 100644
> --- a/xen/include/public/domctl.h
> +++ b/xen/include/public/domctl.h
> @@ -64,23 +64,11 @@ struct xen_domctl_createdomain {
>  #define _XEN_DOMCTL_CDF_pvh_guest     4
>  #define XEN_DOMCTL_CDF_pvh_guest      (1U<<_XEN_DOMCTL_CDF_pvh_guest)
>      uint32_t flags;
> +    struct xen_arch_domainconfig config;
>  };
>  typedef struct xen_domctl_createdomain xen_domctl_createdomain_t;
>  DEFINE_XEN_GUEST_HANDLE(xen_domctl_createdomain_t);
>  
> -#if defined(__arm__) || defined(__aarch64__)
> -#define XEN_DOMCTL_CONFIG_GIC_DEFAULT   0
> -#define XEN_DOMCTL_CONFIG_GIC_V2        1
> -#define XEN_DOMCTL_CONFIG_GIC_V3        2
> -/* XEN_DOMCTL_configure_domain */
> -struct xen_domctl_arm_configuredomain {
> -    /* IN/OUT parameters */
> -    uint8_t gic_version;
> -};
> -typedef struct xen_domctl_arm_configuredomain 
> xen_domctl_arm_configuredomain_t;
> -DEFINE_XEN_GUEST_HANDLE(xen_domctl_arm_configuredomain_t);
> -#endif
> -
>  /* XEN_DOMCTL_getdomaininfo */
>  struct xen_domctl_getdomaininfo {
>      /* OUT variables. */
> @@ -1069,7 +1057,6 @@ struct xen_domctl {
>  #define XEN_DOMCTL_set_vcpu_msrs                 73
>  #define XEN_DOMCTL_setvnumainfo                  74
>  #define XEN_DOMCTL_psr_cmt_op                    75
> -#define XEN_DOMCTL_arm_configure_domain          76
>  #define XEN_DOMCTL_gdbsx_guestmemio            1000
>  #define XEN_DOMCTL_gdbsx_pausevcpu             1001
>  #define XEN_DOMCTL_gdbsx_unpausevcpu           1002
> @@ -1078,9 +1065,6 @@ struct xen_domctl {
>      domid_t  domain;
>      union {
>          struct xen_domctl_createdomain      createdomain;
> -#if defined(__arm__) || defined(__aarch64__)
> -        struct xen_domctl_arm_configuredomain configuredomain;
> -#endif
>          struct xen_domctl_getdomaininfo     getdomaininfo;
>          struct xen_domctl_getmemlist        getmemlist;
>          struct xen_domctl_getpageframeinfo  getpageframeinfo;
> diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h
> index 72667da..6b5c0c5 100644
> --- a/xen/include/xen/domain.h
> +++ b/xen/include/xen/domain.h
> @@ -55,7 +55,8 @@ void vcpu_destroy(struct vcpu *v);
>  int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset);
>  void unmap_vcpu_info(struct vcpu *v);
>  
> -int arch_domain_create(struct domain *d, unsigned int domcr_flags);
> +int arch_domain_create(struct domain *d, unsigned int domcr_flags,
> +                       struct xen_arch_domainconfig *config);
>  
>  void arch_domain_destroy(struct domain *d);
>  
> diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
> index 46fc6e3..9759015 100644
> --- a/xen/include/xen/sched.h
> +++ b/xen/include/xen/sched.h
> @@ -525,8 +525,13 @@ static inline void get_knownalive_domain(struct domain 
> *d)
>  int domain_set_node_affinity(struct domain *d, const nodemask_t *affinity);
>  void domain_update_node_affinity(struct domain *d);
>  
> -struct domain *domain_create(
> -    domid_t domid, unsigned int domcr_flags, uint32_t ssidref);
> +/*
> + * Create a domain: the configuration is only necessary for real domain
> + * (i.e !DOMCRF_dummy, excluded idle domain).
> + */
> +struct domain *domain_create(domid_t domid, unsigned int domcr_flags,
> +                             uint32_t ssidref,
> +                             struct xen_arch_domainconfig *config);
>   /* DOMCRF_hvm: Create an HVM domain, as opposed to a PV domain. */
>  #define _DOMCRF_hvm           0
>  #define DOMCRF_hvm            (1U<<_DOMCRF_hvm)
> diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c
> index d48463f..36410cc 100644
> --- a/xen/xsm/flask/hooks.c
> +++ b/xen/xsm/flask/hooks.c
> @@ -729,9 +729,6 @@ static int flask_domctl(struct domain *d, int cmd)
>      case XEN_DOMCTL_psr_cmt_op:
>          return current_has_perm(d, SECCLASS_DOMAIN2, DOMAIN2__PSR_CMT_OP);
>  
> -    case XEN_DOMCTL_arm_configure_domain:
> -        return current_has_perm(d, SECCLASS_DOMAIN2, 
> DOMAIN2__CONFIGURE_DOMAIN);
> -
>      default:
>          printk("flask_domctl: Unknown op %d\n", cmd);
>          return -EPERM;
> diff --git a/xen/xsm/flask/policy/access_vectors 
> b/xen/xsm/flask/policy/access_vectors
> index 1da9f63..9a98fc3 100644
> --- a/xen/xsm/flask/policy/access_vectors
> +++ b/xen/xsm/flask/policy/access_vectors
> @@ -218,8 +218,6 @@ class domain2
>      get_vnumainfo
>  # XEN_DOMCTL_psr_cmt_op
>      psr_cmt_op
> -# XEN_DOMCTL_configure_domain
> -    configure_domain
>  }
>  
>  # Similar to class domain, but primarily contains domctls related to HVM 
> domains
> -- 
> 2.1.4
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.