From: Lan Tianyu <tianyu.lan@intel.com>
To: xen-devel@lists.xen.org
Cc: Lan Tianyu <tianyu.lan@intel.com>,
kevin.tian@intel.com, wei.liu2@citrix.com,
andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com,
julien.grall@arm.com, jbeulich@suse.com,
Chao Gao <chao.gao@intel.com>
Subject: [PATCH V2 8/25] tools/libxl: Add a user configurable parameter to control vIOMMU attributes
Date: Wed, 9 Aug 2017 16:34:09 -0400 [thread overview]
Message-ID: <1502310866-10450-9-git-send-email-tianyu.lan@intel.com> (raw)
In-Reply-To: <1502310866-10450-1-git-send-email-tianyu.lan@intel.com>
From: Chao Gao <chao.gao@intel.com>
A field, viommu_info, is added to struct libxl_domain_build_info. Several
attributes can be specified by guest config file for virtual IOMMU. These
attributes are used for DMAR construction and vIOMMU creation.
Signed-off-by: Chao Gao <chao.gao@intel.com>
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
docs/man/xl.cfg.pod.5.in | 34 ++++++++++++++++++++++-
tools/libxl/libxl_types.idl | 16 +++++++++++
tools/xl/xl_parse.c | 66 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 115 insertions(+), 1 deletion(-)
diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in
index 79cb2ea..f259e22 100644
--- a/docs/man/xl.cfg.pod.5.in
+++ b/docs/man/xl.cfg.pod.5.in
@@ -1545,7 +1545,39 @@ Do not provide a VM generation ID.
See also "Virtual Machine Generation ID" by Microsoft:
L<http://www.microsoft.com/en-us/download/details.aspx?id=30707>
-=back
+=back
+
+=item B<viommu="VIOMMU_STRING">
+
+Specifies the vIOMMU which are to be provided to the guest.
+
+B<VIOMMU_STRING> has the form C<KEY=VALUE,KEY=VALUE,...> where:
+
+=over 4
+
+=item B<KEY=VALUE>
+
+Possible B<KEY>s are:
+
+=over 4
+
+=item B<type="STRING">
+
+Currently there is only one valid type:
+
+(x86 only) "intel_vtd" means providing a emulated Intel VT-d to the guest.
+
+=item B<intremap=BOOLEAN>
+
+Specifies whether the vIOMMU should support interrupt remapping
+and default 'true'.
+
+=item B<x2apic=BOOLEAN>
+
+Specifies whether the vIOMMU should support x2apic mode and default 'true'.
+Only valid for "intel_vtd".
+
+=back
=head3 Guest Virtual Time Controls
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 8a9849c..7abd70c 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -450,6 +450,21 @@ libxl_altp2m_mode = Enumeration("altp2m_mode", [
(3, "limited"),
], init_val = "LIBXL_ALTP2M_MODE_DISABLED")
+libxl_viommu_type = Enumeration("viommu_type", [
+ (1, "intel_vtd"),
+ ])
+
+libxl_viommu_info = Struct("viommu_info", [
+ ("u", KeyedUnion(None, libxl_viommu_type, "type",
+ [("intel_vtd", Struct(None, [
+ ("x2apic", libxl_defbool)]))
+ ])),
+ ("intremap", libxl_defbool),
+ ("cap", uint64),
+ ("base_addr", uint64),
+ ("len", uint64),
+ ])
+
libxl_domain_build_info = Struct("domain_build_info",[
("max_vcpus", integer),
("avail_vcpus", libxl_bitmap),
@@ -506,6 +521,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
# 65000 which is reserved by the toolstack.
("device_tree", string),
("acpi", libxl_defbool),
+ ("viommu", libxl_viommu_info),
("u", KeyedUnion(None, libxl_domain_type, "type",
[("hvm", Struct(None, [("firmware", string),
("bios", libxl_bios_type),
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index 5c2bf17..11c4eb2 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -17,6 +17,7 @@
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
+#include <xen/domctl.h>
#include <xen/hvm/e820.h>
#include <xen/hvm/params.h>
@@ -30,6 +31,9 @@
extern void set_default_nic_values(libxl_device_nic *nic);
+#define VIOMMU_VTD_BASE_ADDR 0xfed90000ULL
+#define VIOMMU_VTD_REGISTER_LEN 0x1000ULL
+
#define ARRAY_EXTEND_INIT__CORE(array,count,initfn,more) \
({ \
typeof((count)) array_extend_old_count = (count); \
@@ -804,6 +808,61 @@ int parse_usbdev_config(libxl_device_usbdev *usbdev, char *token)
return 0;
}
+/* Parses viommu data and adds info into viommu
+ * Returns 1 if the input doesn't form a valid viommu
+ * or parsed values are not correct. Successful parse returns 0 */
+static int parse_viommu_config(libxl_viommu_info *viommu, const char *info)
+{
+ char *ptr, *oparg, *saveptr = NULL, *buf = xstrdup(info);
+
+ ptr = strtok_r(buf, ",", &saveptr);
+ if (MATCH_OPTION("type", ptr, oparg)) {
+ if (!strcmp(oparg, "intel_vtd")) {
+ viommu->type = LIBXL_VIOMMU_TYPE_INTEL_VTD;
+ } else {
+ fprintf(stderr, "Invalid viommu type: %s\n", oparg);
+ return 1;
+ }
+ } else {
+ fprintf(stderr, "viommu type should be set first: %s\n", oparg);
+ return 1;
+ }
+
+ ptr = strtok_r(NULL, ",", &saveptr);
+ if (MATCH_OPTION("intremap", ptr, oparg)) {
+ libxl_defbool_set(&viommu->intremap, !!strtoul(oparg, NULL, 0));
+ }
+
+ if (viommu->type == LIBXL_VIOMMU_TYPE_INTEL_VTD) {
+ for (ptr = strtok_r(NULL, ",", &saveptr); ptr;
+ ptr = strtok_r(NULL, ",", &saveptr)) {
+ if (MATCH_OPTION("x2apic", ptr, oparg)) {
+ libxl_defbool_set(&viommu->u.intel_vtd.x2apic,
+ !!strtoul(oparg, NULL, 0));
+ } else {
+ fprintf(stderr, "Unknown string `%s' in viommu spec\n", ptr);
+ return 1;
+ }
+ }
+
+ if (libxl_defbool_is_default(viommu->intremap))
+ libxl_defbool_set(&viommu->intremap, true);
+
+ if (!libxl_defbool_val(viommu->intremap)) {
+ fprintf(stderr, "Cannot create one virtual VTD without intremap\n");
+ return 1;
+ }
+
+ /* Set default values to unexposed fields */
+ viommu->base_addr = VIOMMU_VTD_BASE_ADDR;
+ viommu->len = VIOMMU_VTD_REGISTER_LEN;
+
+ /* Set desired capbilities */
+ viommu->cap = VIOMMU_CAP_IRQ_REMAPPING;
+ }
+ return 0;
+}
+
void parse_config_data(const char *config_source,
const char *config_data,
int config_len,
@@ -1037,6 +1096,13 @@ void parse_config_data(const char *config_source,
xlu_cfg_get_defbool(config, "driver_domain", &c_info->driver_domain, 0);
xlu_cfg_get_defbool(config, "acpi", &b_info->acpi, 0);
+ if (!xlu_cfg_get_string(config, "viommu", &buf, 0)) {
+ if (parse_viommu_config(&b_info->viommu, buf)) {
+ fprintf(stderr, "ERROR: invalid viommu setting\n");
+ exit (1);
+ }
+ }
+
switch(b_info->type) {
case LIBXL_DOMAIN_TYPE_HVM:
kernel_basename = libxl_basename(b_info->kernel);
--
1.8.3.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-08-09 20:34 UTC|newest]
Thread overview: 136+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-09 20:34 [PATCH V2 00/25] xen/vIOMMU: Add vIOMMU support with irq remapping fucntion of virtual vtd Lan Tianyu
2017-08-09 20:34 ` [PATCH V2 1/25] DOMCTL: Introduce new DOMCTL commands for vIOMMU support Lan Tianyu
2017-08-17 11:18 ` Wei Liu
2017-08-18 2:57 ` Lan Tianyu
2017-08-22 14:32 ` Roger Pau Monné
2017-08-23 6:06 ` Lan Tianyu
2017-08-23 7:22 ` Roger Pau Monné
2017-08-23 9:12 ` Lan Tianyu
2017-08-23 10:19 ` Julien Grall
2017-08-23 14:05 ` Roger Pau Monné
2017-08-24 14:03 ` Julien Grall
2017-08-24 14:25 ` Roger Pau Monné
2017-08-09 20:34 ` [PATCH V2 2/25] VIOMMU: Add irq request callback to deal with irq remapping Lan Tianyu
2017-08-17 11:18 ` Wei Liu
2017-08-18 0:22 ` [PATCH V2 1/25] VIOMMU: Add vIOMMU helper functions to create, destroy and query capabilities Lan Tianyu
2017-08-18 8:41 ` Jan Beulich
2017-08-18 8:50 ` Lan Tianyu
2017-08-18 13:32 ` Wei Liu
2017-08-22 15:27 ` Roger Pau Monné
2017-08-23 7:10 ` Lan Tianyu
2017-08-23 7:38 ` Roger Pau Monné
2017-08-24 8:14 ` Tian, Kevin
2017-08-18 7:09 ` [PATCH V2 2/25] VIOMMU: Add irq request callback to deal with irq remapping Lan Tianyu
2017-08-18 10:13 ` Wei Liu
2017-08-22 8:04 ` Lan Tianyu
2017-08-22 8:42 ` Wei Liu
2017-08-22 10:39 ` Lan Tianyu
2017-08-22 10:53 ` Wei Liu
2017-08-22 10:54 ` Lan Tianyu
2017-08-22 15:32 ` Roger Pau Monné
2017-08-23 7:42 ` Lan Tianyu
2017-08-23 9:24 ` Jan Beulich
2017-08-23 9:47 ` Lan Tianyu
2017-08-09 20:34 ` [PATCH V2 3/25] VIOMMU: Add get irq info callback to convert irq remapping request Lan Tianyu
2017-08-17 11:19 ` Wei Liu
2017-08-22 15:38 ` Roger Pau Monné
2017-08-23 7:43 ` Lan Tianyu
2017-08-23 9:25 ` Jan Beulich
2017-08-09 20:34 ` [PATCH V2 4/25] Xen/doc: Add Xen virtual IOMMU doc Lan Tianyu
2017-08-17 11:19 ` Wei Liu
2017-08-18 7:17 ` Lan Tianyu
2017-08-18 10:15 ` Wei Liu
2017-08-22 8:07 ` Lan Tianyu
2017-08-22 11:03 ` Wei Liu
2017-08-23 2:06 ` Lan Tianyu
2017-08-22 15:55 ` Roger Pau Monné
2017-08-23 7:36 ` Lan Tianyu
2017-08-23 13:53 ` Roger Pau Monné
2017-08-09 20:34 ` [PATCH V2 5/25] tools/libxc: Add viommu operations in libxc Lan Tianyu
2017-08-22 11:09 ` Wei Liu
2017-08-22 16:25 ` Roger Pau Monné
2017-08-09 20:34 ` [PATCH V2 6/25] tools/libacpi: Add DMA remapping reporting (DMAR) ACPI table structures Lan Tianyu
2017-08-22 12:56 ` Wei Liu
2017-08-23 2:47 ` Lan Tianyu
2017-08-09 20:34 ` [PATCH V2 7/25] tools/libacpi: Add new fields in acpi_config for DMAR table Lan Tianyu
2017-08-22 13:12 ` Wei Liu
2017-08-23 2:36 ` Lan Tianyu
2017-08-23 8:07 ` Wei Liu
2017-08-22 16:41 ` Roger Pau Monné
2017-08-23 7:52 ` Lan Tianyu
2017-08-23 8:04 ` Roger Pau Monné
2017-08-23 14:11 ` Roger Pau Monné
2017-08-24 2:33 ` Lan Tianyu
2017-08-24 6:54 ` Jan Beulich
2017-08-24 8:36 ` Lan Tianyu
2017-08-09 20:34 ` Lan Tianyu [this message]
2017-08-22 13:19 ` [PATCH V2 8/25] tools/libxl: Add a user configurable parameter to control vIOMMU attributes Wei Liu
2017-08-23 2:46 ` Lan Tianyu
2017-08-23 8:09 ` Wei Liu
2017-08-22 16:48 ` Roger Pau Monné
2017-08-09 20:34 ` [PATCH V2 9/25] tools/libxl: build DMAR table for a guest with one virtual VTD Lan Tianyu
2017-08-17 11:32 ` Wei Liu
2017-08-17 12:28 ` Wei Liu
2017-08-18 5:45 ` Chao Gao
2017-08-18 13:45 ` Wei Liu
2017-08-18 13:56 ` Jan Beulich
2017-08-22 13:44 ` Wei Liu
2017-08-22 13:48 ` Wei Liu
2017-08-23 5:35 ` Lan Tianyu
2017-08-23 8:34 ` Wei Liu
2017-08-24 3:24 ` Lan Tianyu
2017-08-24 11:08 ` Wei Liu
2017-08-25 3:19 ` Lan Tianyu
2017-08-25 7:33 ` Lan Tianyu
2017-08-25 9:11 ` Wei Liu
2017-08-09 20:34 ` [PATCH V2 10/25] tools/libxl: create vIOMMU during domain construction Lan Tianyu
2017-08-23 7:45 ` Roger Pau Monné
2017-08-23 8:02 ` Lan Tianyu
2017-08-23 13:53 ` Roger Pau Monné
2017-08-09 20:34 ` [PATCH V2 11/25] x86/hvm: Introduce a emulated VTD for HVM Lan Tianyu
2017-08-23 7:58 ` Roger Pau Monné
2017-08-24 2:16 ` Lan Tianyu
2017-08-24 8:49 ` Roger Pau Monné
2017-08-24 8:54 ` Lan Tianyu
2017-08-24 9:02 ` Roger Pau Monné
2017-08-09 20:34 ` [PATCH V2 12/25] x86/vvtd: Add MMIO handler for VVTD Lan Tianyu
2017-08-23 8:27 ` Roger Pau Monné
2017-08-09 20:34 ` [PATCH V2 13/25] x86/vvtd: Set Interrupt Remapping Table Pointer through GCMD Lan Tianyu
2017-08-23 8:47 ` Roger Pau Monné
2017-08-09 20:34 ` [PATCH V2 14/25] x86/vvtd: Process interrupt remapping request Lan Tianyu
2017-08-23 9:49 ` Roger Pau Monné
2017-08-23 9:59 ` Jan Beulich
2017-08-09 20:34 ` [PATCH V2 15/25] x86/vvtd: decode interrupt attribute from IRTE Lan Tianyu
2017-08-23 9:57 ` Roger Pau Monné
2017-08-09 20:34 ` [PATCH V2 16/25] x86/vioapic: Hook interrupt delivery of vIOAPIC Lan Tianyu
2017-08-23 9:59 ` Roger Pau Monné
2017-08-24 5:28 ` Lan Tianyu
2017-08-09 20:34 ` [PATCH V2 17/25] x86/vvtd: Enable Queued Invalidation through GCMD Lan Tianyu
2017-08-23 10:03 ` Roger Pau Monné
2017-08-09 20:34 ` [PATCH V2 18/25] x86/vvtd: Enable Interrupt Remapping " Lan Tianyu
2017-08-23 10:07 ` Roger Pau Monné
2017-08-09 20:34 ` [PATCH V2 19/25] x86/vioapic: extend vioapic_get_vector() to support remapping format RTE Lan Tianyu
2017-08-23 10:14 ` Roger Pau Monné
2017-08-24 6:11 ` Lan Tianyu
2017-08-24 6:59 ` Jan Beulich
2017-08-24 8:04 ` Lan Tianyu
2017-08-09 20:34 ` [PATCH V2 20/25] passthrough: move some fields of hvm_gmsi_info to a sub-structure Lan Tianyu
2017-08-09 20:34 ` [PATCH V2 21/25] tools/libxc: Add a new interface to bind remapping format msi with pirq Lan Tianyu
2017-08-23 10:41 ` Roger Pau Monné
2017-08-25 7:28 ` Chao Gao
2017-08-25 9:35 ` Roger Pau Monné
2017-08-09 20:34 ` [PATCH V2 22/25] x86/vmsi: Hook delivering remapping format msi to guest Lan Tianyu
2017-08-23 10:55 ` Roger Pau Monné
2017-08-23 12:17 ` Jan Beulich
2017-08-09 20:34 ` [PATCH V2 23/25] x86/vvtd: Handle interrupt translation faults Lan Tianyu
2017-08-23 11:51 ` Roger Pau Monné
2017-08-25 7:17 ` Chao Gao
2017-08-25 9:43 ` Roger Pau Monné
2017-08-09 20:34 ` [PATCH V2 24/25] x86/vvtd: Add queued invalidation (QI) support Lan Tianyu
2017-08-23 12:16 ` Roger Pau Monné
2017-08-24 6:31 ` Lan Tianyu
2017-08-09 20:34 ` [PATCH V2 25/25] x86/vvtd: save and restore emulated VT-d Lan Tianyu
2017-08-23 12:19 ` Roger Pau Monné
2017-08-25 6:35 ` Chao Gao
2017-08-25 9:00 ` Jan Beulich
2017-08-25 8:27 ` Chao Gao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1502310866-10450-9-git-send-email-tianyu.lan@intel.com \
--to=tianyu.lan@intel.com \
--cc=andrew.cooper3@citrix.com \
--cc=chao.gao@intel.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=julien.grall@arm.com \
--cc=kevin.tian@intel.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).