kernel: capabilities: treat full object retypes with identical source and dest types...
authorSimon Gerber <simon.gerber@inf.ethz.ch>
Thu, 31 Aug 2017 14:03:53 +0000 (16:03 +0200)
committerSimon Gerber <simon.gerber@inf.ethz.ch>
Thu, 31 Aug 2017 14:51:09 +0000 (16:51 +0200)
Signed-off-by: Simon Gerber <simon.gerber@inf.ethz.ch>

kernel/capabilities.c

index 3b05d2c..b24e205 100644 (file)
@@ -1674,6 +1674,21 @@ errval_t caps_retype(enum objtype type, gensize_t objsize, size_t count,
         dest_cap->u.endpoint.listener = src_cap->u.dispatcher.dcb;
     }
 
+    // XXX: Treat full object retypes to same type as copies as calling
+    // is_copy(dst, src) will return true for such retypes.
+    if (count == 1 && objsize == get_size(src_cap) && type == src_cap->type) {
+        // sanity check: is_copy() really returns true for the two caps
+        assert(is_copy(&dest_cte[0].cap, src_cap));
+        // If we're not owner, and type needs locality
+        if (src_cte->mdbnode.owner != my_core_id &&
+            distcap_needs_locality(dest_cte[0].cap.type))
+        {
+            // fix owner for new cap and set remote_copies bit
+            dest_cte[0].mdbnode.owner = src_cte->mdbnode.owner;
+            dest_cte[0].mdbnode.remote_copies = true;
+        }
+    }
+
     /* Handle mapping */
     for (size_t i = 0; i < count; i++) {
         mdb_insert(&dest_cte[i]);