kernel: capabilities: treat full object retypes with identical source and dest types as copy
@@ -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]);
