]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
libxl/xl: add cacheability option to iomem
authorStefano Stabellini <sstabellini@kernel.org>
Tue, 26 Feb 2019 23:00:28 +0000 (15:00 -0800)
committerStefano Stabellini <sstabellini@xilinx.com>
Wed, 18 Dec 2019 19:16:19 +0000 (11:16 -0800)
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.5.pod.in
tools/libxl/libxl_create.c
tools/libxl/libxl_types.idl
tools/xl/xl_parse.c

index 22d9d41856ec79c31bc2f0f8ba7f1b732b3c0781..004042be5fb2a8657dded8accbaa39ff56c9c1c3 100644 (file)
@@ -1293,7 +1293,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.
 
@@ -1304,6 +1304,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
index aaf0b8b7d2397929dfc956e8d110ee46148313b8..ab9a8cd219c5abf6f2404e4655a4114ba2459b9f 100644 (file)
@@ -431,6 +431,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,
@@ -1528,7 +1536,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
index 07e940d28ef00e6f40da3301516bbe6836650cb0..51f63162e87de71a6831037f62bec8bfda88b194 100644 (file)
@@ -280,6 +280,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),
@@ -287,6 +292,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", [
index 8ae898086d2314e0753b2be571a654e966027392..90d709bb4cc4a6b6ef81cce9743fb9252c26a980 100644 (file)
@@ -1955,6 +1955,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) {
@@ -1963,15 +1964,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);
+                }
+            }
         }
     }