From patchwork Fri Nov 17 06:22:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Gao X-Patchwork-Id: 10062361 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 51834604D4 for ; Fri, 17 Nov 2017 06:27:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 443122A539 for ; Fri, 17 Nov 2017 06:27:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38D9E2A990; Fri, 17 Nov 2017 06:27:43 +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 A4B7D2A825 for ; Fri, 17 Nov 2017 06:27:42 +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-00021V-9v; 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-0001r4-Ha for xen-devel@lists.xen.org; Fri, 17 Nov 2017 06:26:03 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id A4/F5-19430-BF08E0A5; Fri, 17 Nov 2017 06:26:03 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjkeJIrShJLcpLzFFi42Jpa+uQ0P3VwBd lcPS+icWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmtH+ZApjwRSpip7dF9gaGM+LdjFycQgJTGeU uP/tHGsXIyeHhACvxJFlM6DsAImuXUfBbCGBKomJUxpZQGw2AWWJi1972UBsEQFpiWufLzOCD GIWmMoicbSrFcjh4BAWcJWYf8MFpIZFQFXi1vatYPW8As4SH98vZ4KYryAx5eF7ZhCbEyi+/8 1BJohdThIH101jmsDIu4CRYRWjRnFqUVlqka6hqV5SUWZ6RkluYmaOrqGBqV5uanFxYnpqTmJ SsV5yfu4mRmA4MADBDsaG7Z6HGCU5mJREeXnM+aKE+JLyUyozEosz4otKc1KLDzHKcHAoSfAe qwfKCRalpqdWpGXmAAMTJi3BwaMkwpsIDE4h3uKCxNzizHSI1ClGS44DE678YeJ4NvN1AzPHt KutTcxCLHn5ealS4rz3QeYJgDRklObBjYNFzyVGWSlhXkagA4V4ClKLcjNLUOVfMYpzMCoJ81 aCTOHJzCuB2/oK6CAmoINsbnCDHFSSiJCSamB0bo2PO3nXbc9JAU2DY0ychR+mLHH4EHlSdP8 a7337mE6XpWVmsFSHvoqVurR2U2ZglJ/X97Ty86H9plKtPzvmqt++X3vw9M7/fk9EJfPMNusX OO68H67w3+LDkk3zbq3QUr8psGDFDU9r82vdKc3Wgnt3JE8KK1taJFQb9GaKKXP1j4ecjJVKL MUZiYZazEXFiQAhtTKhmQIAAA== X-Env-Sender: chao.gao@intel.com X-Msg-Ref: server-11.tower-206.messagelabs.com!1510899922!87798367!14 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 55140 invoked from network); 17 Nov 2017 06:26:02 -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:26:02 -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:26:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.44,407,1505804400"; d="scan'208"; a="1245165394" Received: from skl-4s-chao.sh.intel.com ([10.239.48.9]) by fmsmga002.fm.intel.com with ESMTP; 16 Nov 2017 22:25:59 -0800 From: Chao Gao To: xen-devel@lists.xen.org Date: Fri, 17 Nov 2017 14:22:35 +0800 Message-Id: <1510899755-40237-29-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 , Ian Jackson , Tim Deegan , Jan Beulich , Andrew Cooper , Chao Gao , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [Xen-devel] [PATCH v4 28/28] tools/libxc: Add viommu operations in libxc 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 libxc helpers for XEN_DOMCTL_viommu_op. Now, it has one sub-command - create(): create a vIOMMU in Xen, given viommu type, register-set location and capabilities Signed-off-by: Chao Gao Signed-off-by: Lan Tianyu --- v4: - remove destroy() sub-command v3: - Remove API for querying viommu capabilities - Remove pointless cast - Polish commit message - Coding style --- tools/libxc/Makefile | 1 + tools/libxc/include/xenctrl.h | 3 +++ tools/libxc/xc_viommu.c | 51 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 tools/libxc/xc_viommu.c diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile index 9a019e8..7d8c4b4 100644 --- a/tools/libxc/Makefile +++ b/tools/libxc/Makefile @@ -51,6 +51,7 @@ CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c CTRL_SRCS-y += xc_evtchn_compat.c CTRL_SRCS-y += xc_gnttab_compat.c CTRL_SRCS-y += xc_devicemodel_compat.c +CTRL_SRCS-y += xc_viommu.c GUEST_SRCS-y := GUEST_SRCS-y += xg_private.c xc_suspend.c diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 8ade90c..69cf03f 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -2537,6 +2537,9 @@ enum xc_static_cpu_featuremask { const uint32_t *xc_get_static_cpu_featuremask(enum xc_static_cpu_featuremask); const uint32_t *xc_get_feature_deep_deps(uint32_t feature); +int xc_viommu_create(xc_interface *xch, domid_t dom, uint64_t type, + uint64_t base_addr, uint64_t cap, uint32_t *viommu_id); + #endif int xc_livepatch_upload(xc_interface *xch, diff --git a/tools/libxc/xc_viommu.c b/tools/libxc/xc_viommu.c new file mode 100644 index 0000000..a72b2f4 --- /dev/null +++ b/tools/libxc/xc_viommu.c @@ -0,0 +1,51 @@ +/* + * xc_viommu.c + * + * viommu related API functions. + * + * Copyright (C) 2017 Intel Corporation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License, version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; If not, see . + */ + +#include "xc_private.h" + +int xc_viommu_create(xc_interface *xch, domid_t dom, uint64_t type, + uint64_t base_addr, uint64_t cap, uint32_t *viommu_id) +{ + int rc; + DECLARE_DOMCTL; + + domctl.cmd = XEN_DOMCTL_viommu_op; + domctl.domain = dom; + domctl.u.viommu_op.cmd = XEN_DOMCTL_viommu_create; + domctl.u.viommu_op.u.create.type = type; + domctl.u.viommu_op.u.create.base_address = base_addr; + domctl.u.viommu_op.u.create.capabilities = cap; + + rc = do_domctl(xch, &domctl); + if ( !rc ) + *viommu_id = domctl.u.viommu_op.u.create.id; + + return rc; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */