Commit fe68b750 authored by Josh Kunz's avatar Josh Kunz

Re-work the old ops to use the new CDT interface

This commit does three main things:
  1. Full CDT reference counting. When CDT locks are acquired, all
     intermediate root's reference counts are update safely.
  2. Re-factor's the operations to use two generic locking routines with
     special handlers (binop, and unop). This removes a lot of code duplication
     which made adding the locking code much easier, and should help
     prevent bugs.
  3. Removes the `delete` callback, now `delete` will be called whenever
     a cnode is created. It's the object's decision if this requires a
     memory free or not. Also adds three new callbacks:
       * `grant(src, dst)`: called when a grant from src -> dst happens.
          Only the handler for `src` is called.
       * `derive_src(src, dst)`: called on `src` when dst is derived from src.
       * `derive_dst(src, dst)`: called on `dst` when dst is derived from src.
    Objects are now responsible for doing some sort of reference
    counting in the grant and delete callbacks to prevent leaks. The
    grant and derive callbacks will also be the main hooks for capnet.
parent cde57a05
Pipeline #441 failed with stage
This diff is collapsed.
......@@ -9,10 +9,10 @@
#define CAP_TYPE_NUM_BUILTIN CAP_TYPE_FIRST_NONBUILTIN
static struct cap_type_ops builtin_cap_types[CAP_TYPE_NUM_BUILTIN] = {
{"none", NULL, NULL,},
{"invalid", NULL, NULL},
{"free", NULL, NULL},
{"cnode", NULL, NULL},
{"none", NULL, NULL, NULL, NULL},
{"invalid", NULL, NULL, NULL, NULL},
{"free", NULL, NULL, NULL, NULL},
{"cnode", NULL, NULL, NULL, NULL},
};
int cap_type_system_alloc(struct cap_type_system **ts)
......@@ -92,7 +92,9 @@ cap_type_t cap_register_private_type(struct cap_type_system *ts,
} else {
ts->types[i].name = strdup(ops->name);
ts->types[i].delete = ops->delete;
ts->types[i].revoke = ops->revoke;
ts->types[i].grant = ops->grant;
ts->types[i].derive_src = ops->derive_src;
ts->types[i].derive_dst = ops->derive_dst;
ret = i;
goto out;
}
......
......@@ -91,7 +91,6 @@ struct cdt_root_node {
/* Points to the parent CDT root node of this CDT root node if it
* exists. If CDT root node has no parent, it is NULL. */
struct cdt_root_node *parent;
struct cnode *cnode;
enum allocation_state state;
};
......
......@@ -73,8 +73,15 @@ struct cnode;
struct cap_type_ops {
char *name;
int (*delete)(struct cspace *cspace, struct cnode *cnode, void *object);
int (*revoke)(struct cspace *cspace, struct cnode *cnode, void *object);
/* Invoked when a cnode is deleted. The cptr, cspace, and object associated
* with this cnode can obtained using the cnode accessor functions. */
int (*delete)(struct cnode *cnode);
/* Invoked when a cnode is involed in a grant operation. */
int (*grant)(struct cnode *src, struct cnode *dst);
/* Invoked when a cnode is the source in a cap_derive operation. */
int (*derive_src)(struct cnode *src, struct cnode *dst);
/* Invoked when a cnode is the destination in a cap_derive operation. */
int (*derive_dst)(struct cnode *src, struct cnode *dst);
};
/* CAP TYPE SYSTEMS -------------------------------------------------- */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment