From patchwork Fri Nov 17 06:22:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Gao X-Patchwork-Id: 10062353 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 028146023A for ; Fri, 17 Nov 2017 06:27:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9B4C2A825 for ; Fri, 17 Nov 2017 06:27:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDA6E2A990; Fri, 17 Nov 2017 06:27:37 +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 98C7F2A539 for ; Fri, 17 Nov 2017 06:27:37 +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 1eFa6G-00020w-2S; Fri, 17 Nov 2017 06:26:04 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFa6F-0001u0-0V for xen-devel@lists.xen.org; Fri, 17 Nov 2017 06:26:03 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id 5E/1A-17228-AF08E0A5; Fri, 17 Nov 2017 06:26:02 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgkeJIrShJLcpLzFFi42Jpa+uQ0P3ewBd lsLhR32LJx8UsDoweR3f/ZgpgjGLNzEvKr0hgzbj/+jdLwXmeintztrA2MH7m6GLk4hASmM4o cXXza6YuRk4OCQFeiSPLZrBC2AESZx5/YO5i5AAqqpKY+KgCJMwmoCxx8WsvG4gtIiAtce3zZ UaQOcwCz5klGibMB5sjLOAv8eHYbbA5LAKqElue/2QEsXkFnCWW77zKDDFfQWLKw/dgNidQfP +bg2C9QgJOEgfXTWOawMi7gJFhFaNGcWpRWWqRrqGpXlJRZnpGSW5iZo6uoYGpXm5qcXFiemp OYlKxXnJ+7iZGYDgwAMEOxobtnocYJTmYlER5ecz5ooT4kvJTKjMSizPii0pzUosPMcpwcChJ 8B6rB8oJFqWmp1akZeYAAxMmLcHBoyTCmwgMTiHe4oLE3OLMdIjUKUZjjmczXzcwc0y72trEL MSSl5+XKiXOex9kkgBIaUZpHtwgWMRcYpSVEuZlBDpNiKcgtSg3swRV/hWjOAejkjBvJcgUns y8Erh9r4BOYQI6xeYGN8gpJYkIKakGRtbi9bULzi7Q2dljrXL6g9EurinNFpMz9346u1DG5WL 34u3/jrOZiaSZrbi91o6xijvXsumsYmo8x5cSOQ+5nek7C2dvl5wX9Ol3/JPKKxGfbU2WJXUI Hn0rcUZX+Xl11ybreYVpupeZ9904Eddu6rHnnLjMzlCWQ337iyd/5ixb4al5Olf0gBJLcUaio RZzUXEiAMbmnEWTAgAA X-Env-Sender: chao.gao@intel.com X-Msg-Ref: server-11.tower-206.messagelabs.com!1510899922!87798367!13 X-Originating-IP: [134.134.136.24] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjQgPT4gMzkwOTcx\n X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54995 invoked from network); 17 Nov 2017 06:25:59 -0000 Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by server-11.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 17 Nov 2017 06:25:59 -0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Nov 2017 22:25:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.44,407,1505804400"; d="scan'208"; a="1245165379" Received: from skl-4s-chao.sh.intel.com ([10.239.48.9]) by fmsmga002.fm.intel.com with ESMTP; 16 Nov 2017 22:25:56 -0800 From: Chao Gao To: xen-devel@lists.xen.org Date: Fri, 17 Nov 2017 14:22:34 +0800 Message-Id: <1510899755-40237-28-git-send-email-chao.gao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1510899755-40237-1-git-send-email-chao.gao@intel.com> References: <1510899755-40237-1-git-send-email-chao.gao@intel.com> Cc: Lan Tianyu , Kevin Tian , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Tim Deegan , Jan Beulich , Chao Gao , Ian Jackson , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [Xen-devel] [PATCH v4 27/28] tools/libxl: create vIOMMU during domain construction 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 If guest is configured to have a vIOMMU, create it during domain construction. Signed-off-by: Chao Gao Signed-off-by: Lan Tianyu --- v4: - s/LOGED/LOGD v3: - Remove the process of querying capabilities. --- tools/libxl/libxl_x86.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c index cb2f494..394c70f 100644 --- a/tools/libxl/libxl_x86.c +++ b/tools/libxl/libxl_x86.c @@ -343,8 +343,25 @@ int libxl__arch_domain_create(libxl__gc *gc, libxl_domain_config *d_config, if (d_config->b_info.type != LIBXL_DOMAIN_TYPE_PV) { unsigned long shadow = DIV_ROUNDUP(d_config->b_info.shadow_memkb, 1024); + unsigned int i; + xc_shadow_control(ctx->xch, domid, XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION, NULL, 0, &shadow, 0, NULL); + + for (i = 0; i < d_config->b_info.num_viommus; i++) { + uint32_t id; + libxl_viommu_info *viommu = &d_config->b_info.viommu[i]; + + if (viommu->type == LIBXL_VIOMMU_TYPE_INTEL_VTD) { + ret = xc_viommu_create(ctx->xch, domid, VIOMMU_TYPE_INTEL_VTD, + viommu->base_addr, viommu->cap, &id); + if (ret) { + LOGD(ERROR, domid, "create vIOMMU fail (%d)", ret); + ret = ERROR_FAIL; + goto out; + } + } + } } if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_PV &&