From patchwork Fri Sep 8 06:56:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 9943275 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D4E6860224 for ; Fri, 8 Sep 2017 07:00:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4EB328520 for ; Fri, 8 Sep 2017 07:00:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B956F28538; Fri, 8 Sep 2017 07:00:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B03B22853F for ; Fri, 8 Sep 2017 07:00:04 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqDDZ-0005cO-C0; Fri, 08 Sep 2017 06:56:45 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqDDY-0005bq-R1 for xen-devel@lists.xen.org; Fri, 08 Sep 2017 06:56:44 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id 5D/94-16676-C2F32B95; Fri, 08 Sep 2017 06:56:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMLMWRWlGSWpSXmKPExsVyuP0Ov662/aZ Ig4tXRC2WfFzM4sDocXT3b6YAxijWzLyk/IoE1oxHL7cyFUxUr1j5/xBjA+MxhS5GTg4JASOJ txP/MXUxcnEICSxklDh6tZ0VJMEmoCqx4fopMFtEQFri2ufLjCBFzAKTmCQWdK9jB0kIC0RI3 Jpzg62LkYODBajh6oF0kDCvgLFE35F1zBAL5CU6DkxmAbE5BUwkjk/qYgcpFwKq+TODcQIj9w JGhlWMGsWpRWWpRbpGZnpJRZnpGSW5iZk5uoYGpnq5qcXFiempOYlJxXrJ+bmbGIHerWdgYNz BeHuy3yFGSQ4mJVHehhkbI4X4kvJTKjMSizPii0pzUosPMWpwcAj0rVl9gVGKJS8/L1VJgjfU blOkkGBRanpqRVpmDjD8YEolOHiURHgNQdK8xQWJucWZ6RCpU4zGHMc2Xf7DxNFx8+4fJiGwS VLivDwgpQIgpRmleXCDYHFxiVFWSpiXkYGBQYinILUoN7MEVf4VozgHo5Iw709boCk8mXklcP teAZ3CBHRKyfMNIKeUJCKkpBoYqzk7AuY9Utl06Y+apJc566bli17a/764M2Gv53rOa6e0Z82 92zjhVF3eZ7uQBb/cbonMmrirY43svr0ZTb8144z9s1+rXyzcESCdOumZjvb9LXu4BU7l/75b 0tS4Ps405Fr/gySGWhnjGIcbu3fP/6Suli2sd82vZ9rS3rkS36rO3szJM/7sp8RSnJFoqMVcV JwIAM4HMKiGAgAA X-Env-Sender: jgross@suse.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1504853803!107768774!1 X-Originating-IP: [195.135.220.15] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 3410 invoked from network); 8 Sep 2017 06:56:43 -0000 Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by server-7.tower-206.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 8 Sep 2017 06:56:43 -0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 003C9ACD7; Fri, 8 Sep 2017 06:56:42 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xen.org Date: Fri, 8 Sep 2017 08:56:34 +0200 Message-Id: <20170908065634.5420-9-jgross@suse.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20170908065634.5420-1-jgross@suse.com> References: <20170908065634.5420-1-jgross@suse.com> Cc: Juergen Gross , sstabellini@kernel.org, wei.liu2@citrix.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, tim@xen.org, julien.grall@arm.com, jbeulich@suse.com, dgdegra@tycho.nsa.gov Subject: [Xen-devel] [PATCH v5 8/8] libxl: add libxl support for setting grant table resource limits X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add new domain config items for setting the limits for the maximum numbers of grant table frames and maptrack frames of a domain. Signed-off-by: Juergen Gross Reviewed-by: Paul Durrant Acked-by: Wei Liu --- V4: - rename configuration items to use max_ prefixes (Wei Liu) --- docs/man/xl.cfg.pod.5.in | 15 +++++++++++++++ tools/libxl/libxl.h | 6 ++++++ tools/libxl/libxl_dom.c | 8 ++++++++ tools/libxl/libxl_types.idl | 3 +++ tools/xl/xl_parse.c | 5 +++++ tools/xl/xl_sxp.c | 2 ++ 6 files changed, 39 insertions(+) diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in index 79cb2eaea7..caa674d59d 100644 --- a/docs/man/xl.cfg.pod.5.in +++ b/docs/man/xl.cfg.pod.5.in @@ -444,6 +444,21 @@ unpausing the domain. With a properly constructed security policy (such as nomigrate_t in the example policy), this can be used to build a domain whose memory is not accessible to the toolstack domain. +=item B + +Specify the maximum number of grant frames the domain is allowed to have. +This value controls how many pages the domain is able to grant access to for +other domains, needed e.g. for the operation of paravirtualized devices. +The default is 32, if not set to another value via a Xen boot parameter. + +=item B + +Specify the maximum number of grant maptrack frames the domain is allowed +to have. This value controls how many pages of foreign domains can be accessed +via the grant mechanism by this domain. A value higher than the normal default +of 1024 is normally needed only for very large configurations for driver +domains. + =item B Disable migration of this domain. This enables certain other features diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 812b7ea95d..912f636b1a 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -311,6 +311,12 @@ #define LIBXL_HAVE_P9S 1 /* + * LIBXL_HAVE_BUILDINFO_GRANT_LIMITS indicates that libxl_domain_build_info + * has the max_grant_frames and max_maptrack_frames fields. + */ +#define LIBXL_HAVE_BUILDINFO_GRANT_LIMITS 1 + +/* * libxl ABI compatibility * * The only guarantee which libxl makes regarding ABI compatibility diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index f54fd49a73..83ba4757d2 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -322,6 +322,14 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid, return ERROR_FAIL; } + if (info->max_grant_frames || info->max_maptrack_frames) { + if (xc_domain_set_gnttab_limits(ctx->xch, domid, info->max_grant_frames, + info->max_maptrack_frames) != 0) { + LOG(ERROR, "Couldn't set grant table limits"); + return ERROR_FAIL; + } + } + /* * Check if the domain has any CPU or node affinity already. If not, try * to build up the latter via automatic NUMA placement. In fact, in case diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 173d70acec..47487d69c5 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -472,6 +472,9 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("blkdev_start", string), ("vnuma_nodes", Array(libxl_vnode_info, "num_vnuma_nodes")), + + ("max_grant_frames", uint32), + ("max_maptrack_frames", uint32), ("device_model_version", libxl_device_model_version), ("device_model_stubdomain", libxl_defbool), diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 02ddd2e90d..dc9df3ce2e 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -943,6 +943,11 @@ void parse_config_data(const char *config_source, !xlu_cfg_get_string (config, "cpus_soft", &buf, 0)) parse_vcpu_affinity(b_info, cpus, buf, num_cpus, false); + if (!xlu_cfg_get_long (config, "max_grant_frames", &l, 0)) + b_info->max_grant_frames = l; + if (!xlu_cfg_get_long (config, "max_maptrack_frames", &l, 0)) + b_info->max_maptrack_frames = l; + libxl_defbool_set(&b_info->claim_mode, claim_mode); if (xlu_cfg_get_string (config, "on_poweroff", &buf, 0)) diff --git a/tools/xl/xl_sxp.c b/tools/xl/xl_sxp.c index e738bf2465..e264cf2023 100644 --- a/tools/xl/xl_sxp.c +++ b/tools/xl/xl_sxp.c @@ -64,6 +64,8 @@ void printf_info_sexp(int domid, libxl_domain_config *d_config, FILE *fh) fprintf(fh, "\t(build_info)\n"); fprintf(fh, "\t(max_vcpus %d)\n", b_info->max_vcpus); + fprintf(fh, "\t(max_grant_frames %d)\n", b_info->max_grant_frames); + fprintf(fh, "\t(max_maptrack_frames %d)\n", b_info->max_maptrack_frames); fprintf(fh, "\t(tsc_mode %s)\n", libxl_tsc_mode_to_string(b_info->tsc_mode)); fprintf(fh, "\t(max_memkb %"PRId64")\n", b_info->max_memkb); fprintf(fh, "\t(target_memkb %"PRId64")\n", b_info->target_memkb);