All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <stefanos@xilinx.com>,
	julien.grall@arm.com, sstabellini@kernel.org,
	ian.jackson@eu.citrix.com, wei.liu2@citrix.com
Subject: [PATCH 3/6] libxl/xl: add cacheability option to iomem
Date: Tue, 26 Feb 2019 15:07:04 -0800	[thread overview]
Message-ID: <1551222427-21749-3-git-send-email-sstabellini@kernel.org> (raw)
In-Reply-To: <alpine.DEB.2.10.1902261501020.20689@sstabellini-ThinkPad-X260>

Parse a new cacheability option for the iomem parameter, it can be
"devmem" for device memory mappings, which is the default, or "memory"
for normal memory mappings.

Store the parameter in a new field in libxl_iomem_range.

Pass the cacheability option to xc_domain_memory_mapping.

Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>
CC: ian.jackson@eu.citrix.com
CC: wei.liu2@citrix.com
---
 docs/man/xl.cfg.pod.5.in    |  4 +++-
 tools/libxl/libxl_create.c  | 12 +++++++++++-
 tools/libxl/libxl_types.idl |  7 +++++++
 tools/xl/xl_parse.c         | 17 +++++++++++++++--
 4 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in
index b1c0be1..655008a 100644
--- a/docs/man/xl.cfg.pod.5.in
+++ b/docs/man/xl.cfg.pod.5.in
@@ -1222,7 +1222,7 @@ is given in hexadecimal format and may either be a range, e.g. C<2f8-2ff>
 It is recommended to only use this option for trusted VMs under
 administrator's control.
 
-=item B<iomem=[ "IOMEM_START,NUM_PAGES[@GFN]", "IOMEM_START,NUM_PAGES[@GFN]", ...]>
+=item B<iomem=[ "IOMEM_START,NUM_PAGES[@GFN],CACHEABILITY", "IOMEM_START,NUM_PAGES[@GFN],CACHEABILITY", ...]>
 
 Allow auto-translated domains to access specific hardware I/O memory pages.
 
@@ -1233,6 +1233,8 @@ B<GFN> is not specified, the mapping will be performed using B<IOMEM_START>
 as a start in the guest's address space, therefore performing a 1:1 mapping
 by default.
 All of these values must be given in hexadecimal format.
+B<CACHEABILITY> can be "devmem" for device memory, the default if not
+specified, or it can be "memory" for normal memory.
 
 Note that the IOMMU won't be updated with the mappings specified with this
 option. This option therefore should not be used to pass through any
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 9a9b953..15edf1c 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -415,6 +415,14 @@ static void init_console_info(libxl__gc *gc,
        Only 'channels' when mapped to consoles have a string name. */
 }
 
+static uint32_t libxl__cacheability_to_xc(libxl_cacheability c)
+{
+    if (c == LIBXL_CACHEABILITY_MEMORY)
+        return CACHEABILITY_MEMORY;
+    /* default to devmem */
+    return CACHEABILITY_DEVMEM;
+}
+
 int libxl__domain_build(libxl__gc *gc,
                         libxl_domain_config *d_config,
                         uint32_t domid,
@@ -1348,7 +1356,9 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
         }
         ret = xc_domain_memory_mapping(CTX->xch, domid,
                                        io->gfn, io->start,
-                                       io->number, 1, CACHEABILITY_DEVMEM);
+                                       io->number, 1,
+                                       libxl__cacheability_to_xc(
+                                           io->cache_policy));
         if (ret < 0) {
             LOGED(ERROR, domid,
                   "failed to map to domain iomem range %"PRIx64"-%"PRIx64
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 3b8f967..897c539 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -262,6 +262,11 @@ libxl_ioport_range = Struct("ioport_range", [
     ("number", uint32),
     ])
 
+libxl_cacheability = Enumeration("cacheability", [
+    (0, "devmem"),
+    (1, "memory"),
+    ], init_val = "LIBXL_CACHEABILITY_DEVMEM")
+
 libxl_iomem_range = Struct("iomem_range", [
     # start host frame number to be mapped to the guest
     ("start", uint64),
@@ -269,6 +274,8 @@ libxl_iomem_range = Struct("iomem_range", [
     ("number", uint64),
     # guest frame number used as a start for the mapping
     ("gfn", uint64, {'init_val': "LIBXL_INVALID_GFN"}),
+    # cacheability of the memory region
+    ("cache_policy", libxl_cacheability),
     ])
 
 libxl_vga_interface_info = Struct("vga_interface_info", [
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index 352cd21..1da2670 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -1883,6 +1883,7 @@ void parse_config_data(const char *config_source,
         }
         for (i = 0; i < num_iomem; i++) {
             int used;
+            char cache[7];
 
             buf = xlu_cfg_get_listitem (iomem, i);
             if (!buf) {
@@ -1891,15 +1892,27 @@ void parse_config_data(const char *config_source,
                 exit(1);
             }
             libxl_iomem_range_init(&b_info->iomem[i]);
-            ret = sscanf(buf, "%" SCNx64",%" SCNx64"%n@%" SCNx64"%n",
+            ret = sscanf(buf, "%" SCNx64",%" SCNx64"%n@%" SCNx64"%n,%6s%n",
                          &b_info->iomem[i].start,
                          &b_info->iomem[i].number, &used,
-                         &b_info->iomem[i].gfn, &used);
+                         &b_info->iomem[i].gfn, &used,
+                         cache, &used);
             if (ret < 2 || buf[used] != '\0') {
                 fprintf(stderr,
                         "xl: Invalid argument parsing iomem: %s\n", buf);
                 exit(1);
             }
+            if (ret == 4) {
+                if (!strcmp(cache, "memory"))
+                    b_info->iomem[i].cache_policy = LIBXL_CACHEABILITY_MEMORY;
+                else if (!strcmp(cache, "devmem"))
+                    b_info->iomem[i].cache_policy = LIBXL_CACHEABILITY_DEVMEM;
+                else {
+                    fprintf(stderr,
+                            "xl: Invalid iomem cache parameter: %s\n", cache);
+                    exit(1);
+                }
+            }
         }
     }
 
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-02-26 23:07 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-26 23:06 [PATCH 0/6] iomem cacheability Stefano Stabellini
2019-02-26 23:07 ` [PATCH 1/6] xen: extend XEN_DOMCTL_memory_mapping to handle cacheability Stefano Stabellini
2019-02-26 23:18   ` Julien Grall
2019-04-20  0:02     ` Stefano Stabellini
2019-04-20  0:02       ` [Xen-devel] " Stefano Stabellini
2019-04-21 17:32       ` Julien Grall
2019-04-21 17:32         ` [Xen-devel] " Julien Grall
2019-04-22 21:59         ` Stefano Stabellini
2019-04-22 21:59           ` [Xen-devel] " Stefano Stabellini
2019-04-24 10:42           ` Julien Grall
2019-04-24 10:42             ` [Xen-devel] " Julien Grall
2019-02-27 10:34   ` Jan Beulich
2019-04-17 21:12     ` Stefano Stabellini
2019-04-17 21:12       ` [Xen-devel] " Stefano Stabellini
2019-04-17 21:25       ` Julien Grall
2019-04-17 21:25         ` [Xen-devel] " Julien Grall
2019-04-17 21:55         ` Stefano Stabellini
2019-04-17 21:55           ` [Xen-devel] " Stefano Stabellini
2019-04-25 10:41       ` Jan Beulich
2019-04-25 10:41         ` [Xen-devel] " Jan Beulich
2019-04-25 22:31         ` Stefano Stabellini
2019-04-25 22:31           ` [Xen-devel] " Stefano Stabellini
2019-04-26  7:12           ` Jan Beulich
2019-04-26  7:12             ` [Xen-devel] " Jan Beulich
2019-02-27 19:28   ` Julien Grall
2019-04-19 23:20     ` Stefano Stabellini
2019-04-19 23:20       ` [Xen-devel] " Stefano Stabellini
2019-04-21 17:14       ` Julien Grall
2019-04-21 17:14         ` [Xen-devel] " Julien Grall
2019-04-22 17:33         ` Stefano Stabellini
2019-04-22 17:33           ` [Xen-devel] " Stefano Stabellini
2019-04-22 17:42           ` Julien Grall
2019-04-22 17:42             ` [Xen-devel] " Julien Grall
2019-02-27 21:02   ` Julien Grall
2019-02-26 23:07 ` [PATCH 2/6] libxc: xc_domain_memory_mapping, " Stefano Stabellini
2019-02-26 23:07 ` Stefano Stabellini [this message]
2019-02-27 20:02   ` [PATCH 3/6] libxl/xl: add cacheability option to iomem Julien Grall
2019-04-19 23:13     ` Stefano Stabellini
2019-04-19 23:13       ` [Xen-devel] " Stefano Stabellini
2019-02-26 23:07 ` [PATCH 4/6] xen/arm: keep track of reserved-memory regions Stefano Stabellini
2019-02-28 14:38   ` Julien Grall
2019-02-26 23:07 ` [PATCH 5/6] xen/arm: map reserved-memory regions as normal memory in dom0 Stefano Stabellini
2019-02-26 23:45   ` Julien Grall
2019-04-22 22:42     ` Stefano Stabellini
2019-04-22 22:42       ` [Xen-devel] " Stefano Stabellini
2019-04-23  8:09       ` Julien Grall
2019-04-23  8:09         ` [Xen-devel] " Julien Grall
2019-04-23 17:32         ` Stefano Stabellini
2019-04-23 17:32           ` [Xen-devel] " Stefano Stabellini
2019-04-23 18:37           ` Julien Grall
2019-04-23 18:37             ` [Xen-devel] " Julien Grall
2019-04-23 21:34             ` Stefano Stabellini
2019-04-23 21:34               ` [Xen-devel] " Stefano Stabellini
2019-02-26 23:07 ` [PATCH 6/6] xen/docs: how to map a page between dom0 and domU using iomem Stefano Stabellini
2019-03-03 17:20 ` [PATCH 0/6] iomem cacheability Amit Tomer
2019-03-05 21:22   ` Stefano Stabellini
2019-03-05 22:45     ` Julien Grall
2019-03-06 11:46       ` Amit Tomer
2019-03-06 22:42         ` Stefano Stabellini
2019-03-06 22:59           ` Julien Grall
2019-03-07  8:42             ` Amit Tomer
2019-03-07 10:04               ` Julien Grall
2019-03-07 21:24                 ` Stefano Stabellini
2019-03-08 10:10                   ` Amit Tomer
2019-03-08 16:37                     ` Julien Grall
2019-03-08 17:44                       ` Amit Tomer
2019-03-06 11:30     ` Amit Tomer

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=1551222427-21749-3-git-send-email-sstabellini@kernel.org \
    --to=sstabellini@kernel.org \
    --cc=ian.jackson@eu.citrix.com \
    --cc=julien.grall@arm.com \
    --cc=stefanos@xilinx.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.