From patchwork Wed Apr 1 16:21:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 46637 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0001B216D1 for ; Wed, 1 Apr 2015 16:24:42 +0000 (UTC) Received: by labtp8 with SMTP id tp8sf12318178lab.2 for ; Wed, 01 Apr 2015 09:24:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=a2ldUlS4jjaEncKDubwGCjkK0wifLvZZ+QPi/wDwzzc=; b=IWYw49bvGXlh0HIUujwY2/XFznnuD4j62Mlh5UVr+J5CVBjpi42Z6Mo25WCS6XGNzs 0Ffm489WP6hZ7bFd35hElMWiQg3sKsg+XAsfo63JWEhG6+a7XkFDZO1rv/IkG0WkEoNv EDJY9WSV69IYna/vc5AKwPHgGLCfkbjzvucP6uyZo/BdnlselBvct7dCFTS4hT5DzYJC pry7kLa0A5bU+Rkt+GlKE+SgI7W+fvj2aVF4wUv18GIEf9r7BgVTGHJi8fTYs3czjpEe +O9D5mDXLZ6hJbFw48dQrjmNB+NQ/RSk/7yKILDX/heVc30qD+ENA8WP9kcWLvQb3hvE lcOA== X-Gm-Message-State: ALoCoQn98AtRhiH6eWDOIY7tjRoQWZlALlgb9FHpWdvIkQPsT8TbFZc4iAphoXI8ma46JVvajbGt X-Received: by 10.112.151.232 with SMTP id ut8mr2256720lbb.9.1427905481893; Wed, 01 Apr 2015 09:24:41 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.101 with SMTP id lf5ls101322lac.9.gmail; Wed, 01 Apr 2015 09:24:41 -0700 (PDT) X-Received: by 10.153.4.12 with SMTP id ca12mr7892044lad.90.1427905481763; Wed, 01 Apr 2015 09:24:41 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id e4si2016442lab.13.2015.04.01.09.24.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 09:24:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by labe2 with SMTP id e2so40812744lab.3 for ; Wed, 01 Apr 2015 09:24:41 -0700 (PDT) X-Received: by 10.152.8.161 with SMTP id s1mr27601310laa.41.1427905481546; Wed, 01 Apr 2015 09:24:41 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.57.201 with SMTP id k9csp771206lbq; Wed, 1 Apr 2015 09:24:40 -0700 (PDT) X-Received: by 10.140.32.202 with SMTP id h68mr18666463qgh.77.1427905479389; Wed, 01 Apr 2015 09:24:39 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id a73si2321397qka.35.2015.04.01.09.24.37 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 01 Apr 2015 09:24:39 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YdLPo-0004i6-9k; Wed, 01 Apr 2015 16:22:52 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YdLPm-0004g3-Gl for xen-devel@lists.xenproject.org; Wed, 01 Apr 2015 16:22:50 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id CD/4B-18531-95B1C155; Wed, 01 Apr 2015 16:22:49 +0000 X-Env-Sender: julien.grall@citrix.com X-Msg-Ref: server-11.tower-31.messagelabs.com!1427905366!13144311!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 6.13.6; banners=-,-,- X-VirusChecked: Checked Received: (qmail 1318 invoked from network); 1 Apr 2015 16:22:48 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-11.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 1 Apr 2015 16:22:48 -0000 X-IronPort-AV: E=Sophos;i="5.11,504,1422921600"; d="scan'208";a="250389334" From: Julien Grall To: Date: Wed, 1 Apr 2015 17:21:41 +0100 Message-ID: <1427905307-23749-9-git-send-email-julien.grall@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1427905307-23749-1-git-send-email-julien.grall@citrix.com> References: <1427905307-23749-1-git-send-email-julien.grall@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Wei Liu , ian.campbell@citrix.com, Stefano Stabellini , George Dunlap , Ian Jackson , Julien Grall , tim@xen.org, stefano.stabellini@citrix.com, Jan Beulich , Andrew Cooper , Keir Fraser , Daniel De Graaf Subject: [Xen-devel] [PATCH v5 p1 08/14] xen: Extend DOMCTL createdomain to support arch configuration X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: From: Julien Grall On ARM the virtual GIC may differ between each guest (emulated GIC version, number of SPIs...). This information is already known at the domain creation and can never change. For now only the gic_version is set. In the 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, for now, a dummy structure (C-spec compliant) has been created. Some external tools (qemu, xenstore) may be required to create a domain. Rather than asking them to take care of the arch-specific domain configuration, let the current function (xc_domain_create) chose a default configuration and introduce a new one (xc_domain_create_config). This patch also drops the previously introduced DOMCTL arm_configure_domain in Xen 4.5, as it has been made useless. Signed-off-by: Julien Grall Acked-by: Jan Beulich Acked-by: Daniel De Graaf Acked-by: Stefano Stabellini Acked-by: Ian Campbell Cc: Ian Jackson Cc: Wei Liu Cc: Keir Fraser Cc: Andrew Cooper Cc: George Dunlap --- This is a follow-up of http://lists.xen.org/archives/html/xen-devel/2014-11/msg00522.html Interesting discussion about the implication of this series: - http://lists.xen.org/archives/html/xen-devel/2015-02/msg02721.html - http://lists.xen.org/archives/html/xen-devel/2015-02/msg03306.html As ARM will only support migration v2, it would be possible to create a specific section which will store arch-configuration. 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. Note: XEN_DOMCTL_INTERFACE_VERSION has been bumped by the commit e1890c4 "time: widen wallclock seconds to 64 bits". Changes in v5: - Remove "\n" in LOG - Typoes in comment - Add Ian's ack Changes in v4: - Typoes in the commit message - Bump the XEN_DOMCTL_INTERFACE_VERSION - Add Jan's ack for x86 and the common hypervisors pieces - Add Daniel's ack for XSM - Add Stefano's ack - Drop unused include in arch/arm/domctl.c (was added specially for the DOMCTL) - Remove a spurious line change in libxl_create.c 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 | 20 +++++++++--- 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 | 36 ---------------------- 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, 169 insertions(+), 122 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 552ace8..44c7ac0 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 ae33234..95e3098 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -27,11 +27,12 @@ #include #include -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 e249048..cae64c0 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 7da254f..946618c 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", 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 af04248..e5a343f 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -497,8 +497,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; @@ -511,6 +511,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)); @@ -539,7 +541,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; @@ -772,6 +783,7 @@ 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)); @@ -865,7 +877,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 1a6333a..f20565a 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1098,7 +1098,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 26a0382..a88db69 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -707,7 +707,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 7f81dd3..3aba221 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -993,6 +993,8 @@ typedef struct { xen_vmemrange_t *vmemranges; uint32_t num_vmemranges; + + xc_domain_configuration_t config; } libxl__domain_build_state; _hidden int libxl__build_pre(libxl__gc *gc, uint32_t domid, @@ -1482,8 +1484,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 376b477..5e9a8d2 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) { @@ -324,6 +333,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 887fc10..e4d6fc8 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -531,9 +531,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; @@ -541,6 +543,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; @@ -561,6 +564,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..6f30af7 100644 --- a/xen/arch/arm/domctl.c +++ b/xen/arch/arm/domctl.c @@ -10,8 +10,6 @@ #include #include #include -#include -#include #include long arch_do_domctl(struct xen_domctl *domctl, struct domain *d, @@ -32,40 +30,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 d103f8f..11a0be8 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 4f05f57..4ec7c13 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -710,6 +710,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(); @@ -827,7 +828,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 emulating 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 393aa26..d2d9663 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -507,7 +507,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 3e38761..b724aa5 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 c7885ff..89e4827 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1360,8 +1360,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 2b192ab..4ddaadf 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 c8bcb2d..b502a49 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -592,7 +592,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 462ff91..88770c6 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1418,7 +1418,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 c2dcb66..ed7e98f 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -309,6 +309,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 232d4a5..cea3fe7 100644 --- a/xen/include/public/arch-x86/xen.h +++ b/xen/include/public/arch-x86/xen.h @@ -262,6 +262,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 0c9f474..8803ab2 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. */ @@ -1080,7 +1068,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 @@ -1089,9 +1076,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 920f524..848db8a 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -56,7 +56,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 ecdcdec..026c072 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 4e2c1b7..34e5ab4 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 fe5406d..f89825c 100644 --- a/xen/xsm/flask/policy/access_vectors +++ b/xen/xsm/flask/policy/access_vectors @@ -219,8 +219,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