From patchwork Fri Sep 22 03:01:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 9965593 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 2944B600C5 for ; Fri, 22 Sep 2017 09:12:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2196228501 for ; Fri, 22 Sep 2017 09:12:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16A702891D; Fri, 22 Sep 2017 09:12:23 +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=-2.7 required=2.0 tests=BAYES_00, DATE_IN_PAST_06_12, 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 CB0DA28501 for ; Fri, 22 Sep 2017 09:12:21 +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 1dvJyH-0003pJ-DB; Fri, 22 Sep 2017 09:10:05 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dvJyG-0003cc-CM for xen-devel@lists.xen.org; Fri, 22 Sep 2017 09:10:04 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id E2/18-01809-B63D4C95; Fri, 22 Sep 2017 09:10:03 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjkeJIrShJLcpLzFFi42Jpa+tI0c2+fCT SYNYrZoslHxezODB6HN39mymAMYo1My8pvyKBNWPTo/nsBf9lK75umMfWwPhdoouRk0NIoELi 48mHzCC2hACvxJFlM1gh7ACJxi0XmboYuYBqOhgltu1/xAiSYBNQlzixeCKYLSIgLXHt82VGk CJmgc1MEnPXzGIBSQgLuEism34AzGYRUJU4//07O4jNK+Aq8WAeyFSQDQoSUx6+B9vMCRT/1b edCeIiF4nWpfuZJjDyLmBkWMWoXpxaVJZapGuql1SUmZ5RkpuYmaNraGCql5taXJyYnpqTmFS sl5yfu4kRGA4MQLCD8Uu/8yFGSQ4mJVHe9+ePRArxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4PW7 BJQTLEpNT61Iy8wBBiZMWoKDR0mEVw0kzVtckJhbnJkOkTrFaMlxbNPlP0wcByZcAZIdN+/+Y RJiycvPS5US59UDaRAAacgozYMbB4ueS4yyUsK8jEAHCvEUpBblZpagyr9iFOdgVBLmNQCZwp OZVwK39RXQQUxAB5WvBjuoJBEhJdXA6BDAu+HcjcmtO895KwjX7Ew+2OF468abSZz6dyev2iX A8yfsX3j++XT21bznnsY2McY1rvI7u6+vVfz83PcaE/6JbZaxEhSVKwhccH6V5H/ND/PSJwVp tWza5q53Py/eJDPo7HK9uD3OJnuNc/3+6jhq5XrfYFc2nat+6Gpo9aROvj3X+ZabKbEUZyQaa jEXFScCAHFotimZAgAA X-Env-Sender: tianyu.lan@intel.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1506071401!76473808!1 X-Originating-IP: [134.134.136.100] X-SpamReason: No, hits=0.8 required=7.0 tests=DATE_IN_PAST_06_12 X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33448 invoked from network); 22 Sep 2017 09:10:02 -0000 Received: from mga07.intel.com (HELO mga07.intel.com) (134.134.136.100) by server-12.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 22 Sep 2017 09:10:02 -0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP; 22 Sep 2017 02:10:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.42,427,1500966000"; d="scan'208"; a="1174772709" Received: from sky-ws.sh.intel.com (HELO localhost) ([10.239.48.141]) by orsmga001.jf.intel.com with ESMTP; 22 Sep 2017 02:09:57 -0700 From: Lan Tianyu To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 23:01:50 -0400 Message-Id: <1506049330-11196-10-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1506049330-11196-1-git-send-email-tianyu.lan@intel.com> References: <1506049330-11196-1-git-send-email-tianyu.lan@intel.com> Cc: Lan Tianyu , kevin.tian@intel.com, sstabellini@kernel.org, wei.liu2@citrix.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, tim@xen.org, jbeulich@suse.com, roger.pau@citrix.com, Chao Gao Subject: [Xen-devel] [PATCH V3 9/29] 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 From: Chao Gao This patch adds XEN_DOMCTL_viommu_op hypercall. This hypercall comprises two sub-commands: - create(): create a vIOMMU in Xen, given viommu type, register-set location and capabilities - destroy(): destroy a vIOMMU specified by viommu_id Signed-off-by: Chao Gao Signed-off-by: Lan Tianyu --- v3: - Remove API for querying viommu capabilities - Remove pointless cast - Polish commit message - Coding style --- tools/libxc/Makefile | 1 + tools/libxc/include/xenctrl.h | 4 +++ tools/libxc/xc_viommu.c | 64 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 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 43151cb..bedca1f 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -2501,6 +2501,10 @@ 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); +int xc_viommu_destroy(xc_interface *xch, domid_t dom, 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..17507c5 --- /dev/null +++ b/tools/libxc/xc_viommu.c @@ -0,0 +1,64 @@ +/* + * 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_create_viommu; + domctl.u.viommu_op.u.create.viommu_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.viommu_id; + + return rc; +} + +int xc_viommu_destroy(xc_interface *xch, domid_t dom, uint32_t viommu_id) +{ + DECLARE_DOMCTL; + + domctl.cmd = XEN_DOMCTL_viommu_op; + domctl.domain = dom; + domctl.u.viommu_op.cmd = XEN_DOMCTL_destroy_viommu; + domctl.u.viommu_op.u.destroy.viommu_id = viommu_id; + + return do_domctl(xch, &domctl); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */