]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
xen/xenbus: xen_shim_domain() support
authorAnkur Arora <ankur.a.arora@oracle.com>
Tue, 4 Dec 2018 12:08:53 +0000 (07:08 -0500)
committerJoao Martins <joao.m.martins@oracle.com>
Wed, 20 Feb 2019 17:30:52 +0000 (12:30 -0500)
Fixup the gnttab unmap_ops (and other data structures) to handle
host_addr as an OUT parameter from the call to GNTTABOP_map_grant_ref.

Also, allow xenstored to be hosted in XS_LOCAL mode for
xen_shim_domain() -- this means that it does not need to acquire
xenstore evtchn and pfn externally.

Co-developed-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com>
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
drivers/xen/xenbus/xenbus_client.c
drivers/xen/xenbus/xenbus_dev_backend.c
drivers/xen/xenbus/xenbus_dev_frontend.c
drivers/xen/xenbus/xenbus_probe.c

index ada1c9aa6525bd60c4fa859b9822aa3117a2e5f1..b22149a789d4c43da38550e207afb3c9e8ccc99d 100644 (file)
@@ -487,8 +487,11 @@ static int __xenbus_map_ring(struct xenbus_device *dev,
                                         "mapping in shared page %d from domain %d",
                                         gnt_refs[i], dev->otherend_id);
                        goto fail;
-               } else
+               } else {
                        handles[i] = map[i].handle;
+                       if (xen_shim_domain())
+                               addrs[i] = map[i].host_addr;
+               }
        }
 
        return GNTST_okay;
@@ -498,7 +501,8 @@ static int __xenbus_map_ring(struct xenbus_device *dev,
                if (handles[i] != INVALID_GRANT_HANDLE) {
                        memset(&unmap[j], 0, sizeof(unmap[j]));
                        gnttab_set_unmap_op(&unmap[j], (phys_addr_t)addrs[i],
-                                           GNTMAP_host_map, handles[i]);
+                                           !xen_shim_domain()?GNTMAP_host_map:0,
+                                           handles[i]);
                        j++;
                }
        }
@@ -546,7 +550,7 @@ static int xenbus_map_ring_valloc_hvm(struct xenbus_device *dev,
                                      void **vaddr)
 {
        struct xenbus_map_node *node;
-       int err;
+       int i, err;
        void *addr;
        bool leaked = false;
        struct map_ring_valloc_hvm info = {
@@ -572,9 +576,16 @@ static int xenbus_map_ring_valloc_hvm(struct xenbus_device *dev,
                             &info);
 
        err = __xenbus_map_ring(dev, gnt_ref, nr_grefs, node->handles,
-                               info.phys_addrs, GNTMAP_host_map, &leaked);
+                               info.phys_addrs,
+                               !xen_shim_domain() ? GNTMAP_host_map : 0,
+                               &leaked);
        node->nr_handles = nr_grefs;
 
+       if (xen_shim_domain()) {
+               for (i = 0; i < nr_grefs; i++)
+                       node->hvm.pages[i] = virt_to_page(info.phys_addrs[i]);
+       }
+
        if (err)
                goto out_free_ballooned_pages;
 
@@ -882,7 +893,7 @@ int xenbus_unmap_ring(struct xenbus_device *dev,
 
        for (i = 0; i < nr_handles; i++)
                gnttab_set_unmap_op(&unmap[i], vaddrs[i],
-                                   GNTMAP_host_map, handles[i]);
+                                   !xen_shim_domain()?GNTMAP_host_map:0, handles[i]);
 
        if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap, i))
                BUG();
@@ -926,7 +937,7 @@ static const struct xenbus_ring_ops ring_ops_hvm = {
        .unmap = xenbus_unmap_ring_vfree_hvm,
 };
 
-void __init xenbus_ring_ops_init(void)
+void xenbus_ring_ops_init(void)
 {
 #ifdef CONFIG_XEN_PV
        if (!xen_feature(XENFEAT_auto_translated_physmap))
index edba5fecde4ddc6c3f8d9640a50b19650769bbfe..b605c87bff76503e45fc911a10664ca621230a27 100644 (file)
@@ -119,11 +119,11 @@ static struct miscdevice xenbus_backend_dev = {
        .fops = &xenbus_backend_fops,
 };
 
-static int __init xenbus_backend_init(void)
+int xenbus_backend_init(void)
 {
        int err;
 
-       if (!xen_initial_domain())
+       if (!xen_initial_domain() && !xen_shim_domain())
                return -ENODEV;
 
        err = misc_register(&xenbus_backend_dev);
index a4080d04a01c246ce93d880ad0fa0ee980ee1294..c6fca6cca6c8b187ca6ea0cfe421ccfc208f5e35 100644 (file)
@@ -680,11 +680,11 @@ static struct miscdevice xenbus_dev = {
        .fops = &xen_xenbus_fops,
 };
 
-static int __init xenbus_frontend_init(void)
+static int xenbus_frontend_init(void)
 {
        int err;
 
-       if (!xen_domain())
+       if (!xen_domain() && !xen_shim_domain())
                return -ENODEV;
 
        err = misc_register(&xenbus_dev);
index 2e0ed46b05e7569d54c1d6acbc045f2821628d20..bbc405cd01ef9065d72953074176e0fad6898c74 100644 (file)
@@ -693,7 +693,7 @@ EXPORT_SYMBOL_GPL(xenbus_probe);
 
 static int __init xenbus_probe_initcall(void)
 {
-       if (!xen_domain())
+       if (!xen_domain() && !xen_shim_domain())
                return -ENODEV;
 
        if (xen_initial_domain() || xen_hvm_domain())
@@ -790,7 +790,7 @@ int xenbus_init(void)
        uint64_t v = 0;
        xen_store_domain_type = XS_UNKNOWN;
 
-       if (!xen_domain())
+       if (!xen_domain() && !xen_shim_domain())
                return -ENODEV;
 
        xenbus_ring_ops_init();
@@ -799,7 +799,7 @@ int xenbus_init(void)
                xen_store_domain_type = XS_PV;
        if (xen_hvm_domain())
                xen_store_domain_type = XS_HVM;
-       if (xen_hvm_domain() && xen_initial_domain())
+       if ((xen_hvm_domain() && xen_initial_domain()) || xen_shim_domain())
                xen_store_domain_type = XS_LOCAL;
        if (xen_pv_domain() && !xen_start_info->store_evtchn)
                xen_store_domain_type = XS_LOCAL;
@@ -863,7 +863,7 @@ postcore_initcall(xenbus_init);
 
 void xenbus_deinit(void)
 {
-       if (!xen_domain())
+       if (!xen_domain() && !xen_shim_domain())
                return;
 
 #ifdef CONFIG_XEN_COMPAT_XENFS