Commit 50086a85 authored by Yathindra Naik's avatar Yathindra Naik

Debug the crash introduced by latest changeset

parent 5ab2aae3
......@@ -18,6 +18,7 @@ int xc_cap_create(xc_interface *xch, /*uint32_t domid,*/ struct capability *cap)
int xc_cap_grant(xc_interface *xch,
/*uint32_t from_domid,*/
uint32_t to_domid,
int type,
void *list,
int size)
{
......@@ -31,6 +32,7 @@ int xc_cap_grant(xc_interface *xch,
/*cap_op.domain = (domid_t)from_domid;*/
/*cap_op.u.cap_grant.from = (domid_t)from_domid;*/
cap_op.u.cap_grant.to = (domid_t)to_domid;
cap_op.u.cap_grant.type = type;
cap_op.u.cap_grant.list = list;
cap_op.u.cap_grant.size = size;
return do_cap_op(xch, &cap_op);
......@@ -38,26 +40,15 @@ int xc_cap_grant(xc_interface *xch,
int xc_cap_check(xc_interface *xch,
uint32_t domid,
int type,
struct capability *cap)
{
DECLARE_CAP_OP;
DPRINTF("xc_cap_op: xc_cap_check().\n");
cap_op.cmd = XEN_CAP_OP_cap_check;
cap_op.domain = (domid_t)domid;
cap_op.u.cap_check.type = type;
cap_op.u.cap_check.cap = cap;
return do_cap_op(xch, &cap_op);
}
void xc_get_caps_hypercall(xc_interface *xch,
char *tok,
struct capability *cap)
{
DECLARE_CAP_OP;
DPRINTF("xc_cap_op: xc_get_caps_hypercall\n");
cap_op.cmd = XEN_CAP_OP_get_caps_hypercall;
//cap_op.domain = (domid_t)domain;
cap_op.u.get_caps_hypercall.tok = tok;
cap_op.u.get_caps_hypercall.cap = cap;
do_cap_op(xch, &cap_op);
}
......@@ -2248,16 +2248,13 @@ int xc_cap_create(xc_interface *xch, struct capability *cap);
* The owner of the capability can grant it to other VM by invoking this function.
* Returns success - 1 or failure - 0.
*/
int xc_cap_grant(xc_interface *xch, uint32_t to_domid, void *list, int size);
int xc_cap_grant(xc_interface *xch, uint32_t to_domid, int type, void *list, int size);
/**
* Check if the VM has access to a protected resource.
* Returns success - 1 or failure - 0.
*/
int xc_cap_check(xc_interface *xch, uint32_t domid, struct capability *cap);
/* Get caps for hypercalls */
void xc_get_caps_hypercall(xc_interface *xch, char *tok, struct capability *cap);
int xc_cap_check(xc_interface *xch, uint32_t domid, int type, struct capability *cap);
#endif /* CONFIG_XENCAP */
......
This diff is collapsed.
......@@ -490,7 +490,6 @@ typedef struct {
libxl_device_vkb *vkbs;
#ifdef CONFIG_XENCAP
libxl_capabilities *cap;
libxl_capabilities *cap_files;
#endif
libxl_action_on_shutdown on_poweroff;
......@@ -546,11 +545,10 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
const libxl_asyncop_how *ao_how)
LIBXL_EXTERNAL_CALLERS_ONLY;
#ifdef CONFIG_XENCAP
int libxl_domain_setcap(libxl_ctx *ctx, libxl_capabilities *info,
uint32_t domid);
int libxl_domain_setcapfiles(libxl_ctx *ctx, libxl_capabilities *info,
uint32_t domid);
#endif
int libxl_domain_shutdown(libxl_ctx *ctx, uint32_t domid);
int libxl_domain_reboot(libxl_ctx *ctx, uint32_t domid);
......
......@@ -496,11 +496,11 @@ retry_transaction:
caps = xs_get_caps(ctx->xsh, t, libxl__sprintf(gc, "%s/vm", dom_path));
if (caps == NULL)
LOG(ERROR, "Caps for %s is NULL!\n",dom_path);
if (!xc_cap_check(ctx->xch, *domid, &caps[0])) {
if (!xc_cap_check(ctx->xch, *domid, 2, &caps[0])) {
list[0] = caps[0];
LOG(DEBUG, "Granting caps for %s/vm\n",dom_path);
LOG(DEBUG, "caps[0]: %d caps[1]: %d\n",caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, *domid, &list, 1))
if (xc_cap_grant(ctx->xch, *domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s/vm failed\n",dom_path);
}
#endif
......@@ -535,11 +535,11 @@ retry_transaction:
caps = xs_get_caps(ctx->xsh, t, libxl__sprintf(gc, "%s/device/suspend", dom_path));
if (caps == NULL)
LOG(ERROR, "Caps for %s/device/suspend is NULL!\n",dom_path);
if (!xc_cap_check(ctx->xch, *domid, &caps[0])) {
if (!xc_cap_check(ctx->xch, *domid, 2, &caps[0])) {
list[0] = caps[0];
LOG(DEBUG, "Granting caps for %s/device/suspend\n",dom_path);
LOG(DEBUG, "caps[0]: %d caps[1]: %d\n",caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, *domid, &list, 1))
if (xc_cap_grant(ctx->xch, *domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s/device/suspend failed\n",dom_path);
}
#endif
......@@ -595,22 +595,22 @@ retry_transaction:
caps = xs_get_caps(ctx->xsh, t, libxl__sprintf(gc, "%s/uuid", vm_path));
if (caps == NULL)
LOG(ERROR, "Caps for %s/uuid is NULL!\n",vm_path);
if (!xc_cap_check(ctx->xch, *domid, &caps[0])) {
if (!xc_cap_check(ctx->xch, *domid, 2, &caps[0])) {
list[0] = caps[0];
LOG(DEBUG, "Granting caps for %s/uuid\n",vm_path);
LOG(DEBUG, "caps[0]: %d caps[1]: %d\n",caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, *domid, &list, 1))
if (xc_cap_grant(ctx->xch, *domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s/uuid failed\n",vm_path);
}
caps = xs_get_caps(ctx->xsh, t, libxl__sprintf(gc, "%s/name", vm_path));
if (caps == NULL)
LOG(ERROR, "Caps for %s/name is NULL!\n",vm_path);
if (!xc_cap_check(ctx->xch, *domid, &caps[0])) {
if (!xc_cap_check(ctx->xch, *domid, 2, &caps[0])) {
list[0] = caps[0];
LOG(DEBUG, "Granting caps for %s/name\n",vm_path);
LOG(DEBUG, "caps[0]: %d caps[1]: %d\n",caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, *domid, &list, 1))
if (xc_cap_grant(ctx->xch, *domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s/name failed\n",vm_path);
}
#endif
......@@ -627,22 +627,22 @@ retry_transaction:
caps = xs_get_caps(ctx->xsh, t, libxl__sprintf(gc, "%s/control/platform-feature-multiprocessor-suspend", dom_path));
if (caps == NULL)
LOG(ERROR, "Caps for %s/control/platform-feature-multiprocessor-suspend is NULL", dom_path);
if (!xc_cap_check(ctx->xch, *domid, &caps[0])) {
if (!xc_cap_check(ctx->xch, *domid, 2, &caps[0])) {
list[0] = caps[0];
LOG(DEBUG, "Granting caps for %s/control/platform-feature-multiprocessor-suspend", dom_path);
LOG(DEBUG, "caps[0]: %d caps[1]: %d\n",caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, *domid, &list, 1))
if (xc_cap_grant(ctx->xch, *domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s/control/platform-feature-multiprocessor-suspend is NULL", dom_path);
}
caps = xs_get_caps(ctx->xsh, t, libxl__sprintf(gc, "%s/control/platform-feature-xs_reset_watches", dom_path));
if (caps == NULL)
LOG(ERROR, "Caps for %s/control/platform-feature-xs_reset_watches is NULL", dom_path);
if (!xc_cap_check(ctx->xch, *domid, &caps[0])) {
if (!xc_cap_check(ctx->xch, *domid, 2, &caps[0])) {
list[0] = caps[0];
LOG(DEBUG, "Granting caps for %s/control/platform-feature-xs_reset_watches", dom_path);
LOG(DEBUG, "caps[0]: %d caps[1]: %d\n",caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, *domid, &list, 1))
if (xc_cap_grant(ctx->xch, *domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s/control/platform-feature-xs_reset_watches is NULL", dom_path);
}
#endif
......@@ -751,14 +751,16 @@ static void initiate_domain_create(libxl__egc *egc,
goto error_out;
}
#if 0
#ifdef CONFIG_XENCAP
libxl_capabilities *cap_files = d_config->cap_files;
ret = libxl_domain_setcapfiles(ctx, cap_files, domid);
libxl_capabilities *cap = d_config.cap;
ret = libxl_domain_setcap(ctx, cap, domid);
if (ret) {
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot grant capabilities: %d", ret);
ret = ERROR_FAIL;
goto error_out;
}
#endif
#endif
dcs->guest_domid = domid;
dcs->dmss.dm.guest_domid = 0; /* means we haven't spawned */
......
......@@ -143,34 +143,34 @@ retry_transaction:
caps = xs_get_caps(ctx->xsh, t, libxl__sprintf(gc, "%s/backend",frontend_path));
if (caps == NULL)
LOG(ERROR, "Caps for %s/backend is NULL!\n",frontend_path);
if (!xc_cap_check(ctx->xch, device->domid, &caps[0])) {
if (!xc_cap_check(ctx->xch, device->domid, 2, &caps[0])) {
list[0] = caps[0];
LOG(DEBUG, "Granting caps for domid %d for %s/backend\n",device->domid, frontend_path);
LOG(DEBUG, "caps[0]: %d\n",caps[0].magic);
if (xc_cap_grant(ctx->xch, device->domid, &list, 1))
if (xc_cap_grant(ctx->xch, device->domid, 2, &list, 1))
LOG(DEBUG, "Granting caps for %s/backend failed\n",frontend_path);
}
if (!xc_cap_check(ctx->xch, device->domid, &caps[1])) {
if (!xc_cap_check(ctx->xch, device->domid, 2, &caps[1])) {
list[0] = caps[1];
LOG(DEBUG, "caps[1]: %d\n", caps[1].magic);
if (xc_cap_grant(ctx->xch, device->domid, &list, 1))
if (xc_cap_grant(ctx->xch, device->domid, 2, &list, 1))
LOG(DEBUG, "Granting caps for %s/backend failed\n",frontend_path);
}
caps = xs_get_caps(ctx->xsh, t, frontend_child);
if (caps == NULL)
LOG(ERROR, "Caps for %s is NULL!\n",frontend_child);
if (!xc_cap_check(ctx->xch, device->domid, &caps[0])) {
if (!xc_cap_check(ctx->xch, device->domid, 2, &caps[0])) {
list[0] = caps[0];
LOG(DEBUG, "Granting caps for domid %d for %s\n",device->domid, frontend_child);
LOG(DEBUG, "caps[0]: %d\n",caps[0].magic);
if (xc_cap_grant(ctx->xch, device->domid, &list, 1))
if (xc_cap_grant(ctx->xch, device->domid, 2, &list, 1))
LOG(DEBUG, "Granting caps for %s failed\n",frontend_child);
}
if (!xc_cap_check(ctx->xch, device->domid, &caps[1])) {
if (!xc_cap_check(ctx->xch, device->domid, 2, &caps[1])) {
list[0] = caps[1];
LOG(DEBUG, "Granting caps for domid %d for %s\n",device->domid, frontend_child);
LOG(DEBUG, "caps[1]: %d\n",caps[1].magic);
if (xc_cap_grant(ctx->xch, device->domid, &list, 1))
if (xc_cap_grant(ctx->xch, device->domid, 2, &list, 1))
LOG(DEBUG, "Granting caps for %s failed\n",frontend_child);
}
#endif
......@@ -190,11 +190,11 @@ retry_transaction:
caps = xs_get_caps(ctx->xsh, t, libxl__sprintf(gc, "%s/frontend",backend_path));
if (caps == NULL)
LOG(ERROR, "Caps for %s/frontend is NULL!\n",backend_path);
if (!xc_cap_check(ctx->xch, device->domid, &caps[0])) {
if (!xc_cap_check(ctx->xch, device->domid, 2, &caps[0])) {
list[0] = caps[0];
LOG(DEBUG, "Granting caps for domid %d for %s/frontend\n", device->domid, backend_path);
LOG(DEBUG, "caps[0]: %d caps[1]: %d\n",caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, device->domid, &list, 1))
if (xc_cap_grant(ctx->xch, device->domid, 2, &list, 1))
LOG(DEBUG, "Granting caps for %s/frontend failed\n",backend_path);
}
#endif
......
......@@ -217,18 +217,18 @@ retry_transaction:
caps = xs_get_caps(ctx->xsh, t, libxl__sprintf(gc, "%s/state-%d", be_path, i));
if (caps == NULL)
LOG(ERROR, "Caps for %s/state-%d is NULL!\n",be_path,i);
if (!xc_cap_check(ctx->xch, domid, &caps[0])) {
if (!xc_cap_check(ctx->xch, domid, 2, &caps[0])) {
list[0] = caps[0];
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s/state-%d failed\n",be_path, i);
}
caps = xs_get_caps(ctx->xsh, t, libxl__sprintf(gc, "%s/state", be_path));
if (caps == NULL)
LOG(ERROR, "Caps for %s/state is NULL!\n",be_path);
if (!xc_cap_check(ctx->xch, domid, &caps[0])) {
if (!xc_cap_check(ctx->xch, domid, 2, &caps[0])) {
list[0] = caps[0];
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s/state failed\n",be_path);
}
#endif
......
......@@ -65,7 +65,6 @@ libxl_cap_type = Enumeration("cap_type", [
(1, "HYPERCALLS"),
(2, "MEMORY"),
(3, "PCI_DEVICES"),
(4, "FILES"),
])
#endif
......@@ -490,7 +489,6 @@ libxl_domain_cap_info = Struct("domain_cap_info",[
("hypercalls", string),
("pci_devices", string),
("memory", string),
("files", string),
])
#endif
libxl_event_type = Enumeration("event_type", [
......
......@@ -68,19 +68,19 @@ int libxl__xs_writev(libxl__gc *gc, xs_transaction_t t,
LOG(ERROR, "Caps for %s/%s is NULL!\n",dir, kvs[i]);
if (perm == 'r' || perm == 'b') {
list[0] = caps[0];
if (!xc_cap_check(ctx->xch, domid, &list[0])) {
if (!xc_cap_check(ctx->xch, domid, 2, &list[0])) {
LOG(DEBUG, "Granting caps for domain %d for %s/%s", domid, dir, kvs[i]);
LOG(DEBUG, "caps[0]: %d and caps[1]: %d", caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LOG(DEBUG, "Granting caps for %s/%s failed\n",dir, kvs[i]);
}
}
if (perm == 'w' || perm == 'b') {
list[0] = caps[1];
if (!xc_cap_check(ctx->xch, domid, &list[0])) {
if (!xc_cap_check(ctx->xch, domid, 2, &list[0])) {
LOG(DEBUG, "Granting caps for domain %d for %s/%s", domid, dir, kvs[i]);
LOG(DEBUG, "caps[0]: %d and caps[1]: %d", caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LOG(DEBUG, "Granting caps for %s/%s failed\n",dir, kvs[i]);
}
}
......@@ -91,19 +91,19 @@ int libxl__xs_writev(libxl__gc *gc, xs_transaction_t t,
LOG(ERROR, "Caps for %s is NULL!\n",dir);
if (perm == 'r' || perm == 'b') {
list[0] = caps[0];
if (!xc_cap_check(ctx->xch, domid, &list[0])) {
if (!xc_cap_check(ctx->xch, domid, 2, &list[0])) {
LOG(DEBUG, "Granting caps for domain %d for %s", domid, dir);
LOG(DEBUG, "caps[0]: %d and caps[1]: %d", caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LOG(DEBUG, "Granting caps for %s failed\n",dir);
}
}
if (perm == 'w' || perm == 'b') {
list[0] = caps[1];
if (!xc_cap_check(ctx->xch, domid, &list[1])) {
if (!xc_cap_check(ctx->xch, domid, 2, &list[1])) {
LOG(DEBUG, "Granting caps for domain %d for %s", domid, dir);
LOG(DEBUG, "caps[0]: %d and caps[1]: %d", caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LOG(DEBUG, "Granting caps for %s failed\n",dir);
}
}
......@@ -123,17 +123,17 @@ void libxl__xs_grant_caps(libxl__gc *gc, xs_transaction_t t, char *path, uint32_
LOG(ERROR, "Caps for %s is NULL!\n",path);
if (perm == 'r' || perm == 'b') {
list[0] = caps[0];
if (!xc_cap_check(ctx->xch, domid, &caps[0])) {
if (!xc_cap_check(ctx->xch, domid, 2, &caps[0])) {
LOG(DEBUG, "Granting caps for domain %d for %s", domid, path);
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LOG(DEBUG, "Granting caps for %s failed\n",path);
}
}
if (perm == 'w' || perm == 'b') {
list[0] = caps[1];
if (!xc_cap_check(ctx->xch, domid, &caps[1])) {
if (!xc_cap_check(ctx->xch, domid, 2, &caps[1])) {
LOG(DEBUG, "Granting caps for domain %d for %s", domid, path);
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LOG(DEBUG, "Granting caps for %s failed\n", path);
}
}
......@@ -205,17 +205,17 @@ int libxl__xs_write(libxl__gc *gc, xs_transaction_t t,
LOG(ERROR, "Caps for %s is NULL!\n",path);
if (perm == 'r' || perm == 'b') {
list[0] = caps[0];
if (!xc_cap_check(ctx->xch, domid, &caps[0])) {
if (!xc_cap_check(ctx->xch, domid, 2, &caps[0])) {
LOG(DEBUG, "Granting caps for %s", path);
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s failed\n",path);
}
}
if (perm == 'w' && perm == 'b') {
list[0] = caps[1];
if (!xc_cap_check(ctx->xch, domid, &caps[1])) {
if (!xc_cap_check(ctx->xch, domid, 2, &caps[1])) {
LOG(DEBUG, "Granting caps for %s", path);
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s failed\n",path);
}
}
......
......@@ -1053,20 +1053,21 @@ static void parse_config_data(const char *config_source,
}
#ifdef CONFIG_XENCAP
if (!xlu_cfg_get_string(config, "cap_hypercalls", &buf, 0)) {
printf("In parse_config_data: parsing cap_hypercalls ...\n");
if (!xlu_cfg_get_string (config, "cap_hypercalls", &buf, 0)) {
printf("In parse_config_data: read cap_hypercalls\n");
d_config->num_cap = 0;
d_config->cap = (libxl_capabilities *) realloc(d_config->cap, sizeof (libxl_capabilities));
d_config->cap->cap_type = LIBXL_CAP_TYPE_HYPERCALLS;
d_config->cap->cap_values = strdup(buf);
}
#if 0
while ((buf = xlu_cfg_get_listitem (cap, d_config->num_cap)) != NULL) {
if (!xlu_cfg_get_string(config, "cap_files", &buf, 0)) {
printf("In parse_config_data: parsing cap_files ...\n");
d_config->cap_files = (libxl_capabilities *) realloc(d_config->cap_files, sizeof (libxl_capabilities));
d_config->cap_files->cap_type = LIBXL_CAP_TYPE_FILES;
d_config->cap_files->cap_values = strdup(buf);
d_config->num_cap++;
}
}
#endif
#endif
if (!xlu_cfg_get_list (config, "vif", &nics, 0, 0)) {
......
......@@ -215,7 +215,7 @@ static PyObject *pyxc_cap_hypercalls(XcObject *self, PyObject *args)
to_dom = dom;
if ( xc_cap_grant(self->xc_handle, to_dom, hypercalls_list, 64 ) != 0 )
if ( xc_cap_grant(self->xc_handle, to_dom, 1, hypercalls_list, 64 ) != 0 )
return pyxc_error_to_exception(self->xc_handle);
Py_INCREF(Py_None);
......
......@@ -565,7 +565,7 @@ static int caps_for_conn(struct connection *conn,
* Return true if we have read capabilities
* Or we have owner capabilities - But owner has both.
*/
if ( (xc_cap_check(xch, domid, &caps[0])) == 0 ) {
if ( (xc_cap_check(xch, domid, 2, &caps[0])) == 0 ) {
log("caps_for_conn (conn:%p,domid:%d,perm:%d,name:%s) read cap does not exist!\n", conn, domid, perm, name);
ret = 0;
}
......@@ -576,7 +576,7 @@ static int caps_for_conn(struct connection *conn,
* Return true if we have write capabilities
* Or we have owner capabilities - But owner has both.
*/
if ( (xc_cap_check(xch, domid, &caps[1])) == 0 ) {
if ( (xc_cap_check(xch, domid, 2, &caps[1])) == 0 ) {
log("caps_for_conn (conn:%p,domid:%d,perm:%d,name:%s) write cap does not exist!\n", conn, domid, perm, name);
ret = 0;
}
......@@ -585,8 +585,8 @@ static int caps_for_conn(struct connection *conn,
{
/* Read | Write Capabilities */
/* Owner must have both. */
if ( (xc_cap_check(xch, domid, &caps[0])) == 0 ||
(xc_cap_check(xch, domid, &caps[1])) == 0 ) {
if ( (xc_cap_check(xch, domid, 2, &caps[0])) == 0 ||
(xc_cap_check(xch, domid, 2, &caps[1])) == 0 ) {
log("caps_for_conn (conn:%p,domid:%d,perm:%d,name:%s) either read or write cap does not exist!\n", conn, domid, perm, name);
ret = 0;
}
......@@ -979,20 +979,20 @@ bool xs_strings_to_caps(unsigned int num, struct node *node, const char *strings
goto out;
}
if (!xc_cap_check(xch,owner_domid,&node->caps[0]))
if (!xc_cap_check(xch,owner_domid,2,&node->caps[0]))
{
list[0] = node->caps[0];
if ((xc_cap_grant(xch,owner_domid,&list,1)) == 1)
if ((xc_cap_grant(xch,owner_domid,2,&list,1)) == 1)
{
log("xs_strings_to_caps: Error in xc_cap_grant.\n");
goto out;
}
}
if (!xc_cap_check(xch,owner_domid,&node->caps[1]))
if (!xc_cap_check(xch,owner_domid,2,&node->caps[1]))
{
list[0] = node->caps[1];
if ((xc_cap_grant(xch,owner_domid,&list,1)) == 1)
if ((xc_cap_grant(xch,owner_domid,2,&list,1)) == 1)
{
log("xs_strings_to_caps: Error in xc_cap_grant.\n");
goto out;
......@@ -1050,7 +1050,7 @@ bool xs_strings_to_caps(unsigned int num, struct node *node, const char *strings
if (flag && to_domid != 0)
{
/* Read or Write Caps */
if ((xc_cap_grant(xch,to_domid,&list,1)) == 1)
if ((xc_cap_grant(xch,to_domid,2,&list,1)) == 1)
{
log("xs_strings_to_caps: Error in xc_cap_grant.\n");
goto out;
......@@ -1059,7 +1059,7 @@ bool xs_strings_to_caps(unsigned int num, struct node *node, const char *strings
else if (!flag && to_domid != 0)
{
/* Both the flags */
if ((xc_cap_grant(xch,to_domid,&list,2)) == 1)
if ((xc_cap_grant(xch,to_domid,2,&list,2)) == 1)
{
log("xs_strings_to_caps: Error in xc_cap_grant.\n");
goto out;
......@@ -1230,7 +1230,7 @@ static char *caps_to_strings(struct node *node, unsigned int *len, int grant_fla
log("node: %s node->caps is NULL for domid %d\n",node->name,domid);
/* Check if this domain has the read capability. */
if (xc_cap_check(xch, domid, &node->caps[0]))
if (xc_cap_check(xch, domid, 2, &node->caps[0]))
{
perm.id = domid;
perm.perms = XS_PERM_READ;
......@@ -1245,7 +1245,7 @@ static char *caps_to_strings(struct node *node, unsigned int *len, int grant_fla
}
/* Check if this domain has the write capability. */
if (xc_cap_check(xch, domid, &node->caps[1]))
if (xc_cap_check(xch, domid, 2, &node->caps[1]))
{
/* If a node does not have read cap then we don't want
to write the same domid again. */
......@@ -1381,12 +1381,12 @@ static struct node *construct_node(struct connection *conn, const char *name)
log("Construct_node: Guest domain: %d is making an entry in Xenstore\n",domid);
list[0] = node->caps[0];
log("construct_node: Granting read cap to domain:%d for node: %s\n",domid,node->name);
if (xc_cap_grant(xch, domid, &list, 1) == 1)
if (xc_cap_grant(xch, domid, 2, &list, 1) == 1)
log("construct_node: Error in xc_cap_grant.\n");
list[0] = node->caps[1];
log("construct_node: Granting write cap to domain:%d for node: %s\n",domid,node->name);
if (xc_cap_grant(xch, domid, &list, 1) == 1)
if (xc_cap_grant(xch, domid, 2, &list, 1) == 1)
log("construct_node: Error in xc_cap_grant.\n");
}
#endif
......
......@@ -62,6 +62,7 @@ long do_cap_op(XEN_GUEST_HANDLE(xen_cap_op_t) u_cap_op)
{
//struct domain *d;
struct domain *to;
int type;
void *list;
int size;
......@@ -82,10 +83,11 @@ long do_cap_op(XEN_GUEST_HANDLE(xen_cap_op_t) u_cap_op)
break;
}
type = op->u.cap_grant.type;
list = op->u.cap_grant.list;
size = op->u.cap_grant.size;
if ( (ret = cap_grant(to,list,size)) != 0 )
if ( (ret = cap_grant(to,type,list,size)) != 0 )
{
TT_ERR("cap_grant failed when called from xc_cap_grant().\n");
rcu_unlock_domain(to);
......@@ -101,6 +103,7 @@ long do_cap_op(XEN_GUEST_HANDLE(xen_cap_op_t) u_cap_op)
case XEN_CAP_OP_cap_check:
{
struct domain *d;
int type;
struct capability *cap;
ret = -ESRCH;
......@@ -113,26 +116,14 @@ long do_cap_op(XEN_GUEST_HANDLE(xen_cap_op_t) u_cap_op)
}
cap = op->u.cap_check.cap;
type = op->u.cap_check.type;
ret = cap_check(d,cap);
ret = cap_check(d,type,cap);
rcu_unlock_domain(d);
}
break;
case XEN_CAP_OP_get_caps_hypercall:
{
struct capability *cap;
char * tok;
TT_DBG("XEN_CAP_OP_get_caps_hypercalls: domid %d\n",op->domain);
cap = op->u.get_caps_hypercall.cap;
tok = op->u.get_caps_hypercall.tok;
get_caps_hypercall(tok,cap);
}
break;
}
spin_unlock(&cap_lock);
......
This diff is collapsed.
......@@ -22,6 +22,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_cap_op_cap_create_t);
struct xen_cap_op_cap_grant {
int to;
int type;
void *list;
int size;
};
......@@ -30,30 +31,22 @@ DEFINE_XEN_GUEST_HANDLE(xen_cap_op_cap_grant_t);
struct xen_cap_op_cap_check {
struct capability *cap;
int type;
};
typedef struct xen_cap_op_cap_check xen_cap_op_cap_check_t;
DEFINE_XEN_GUEST_HANDLE(xen_cap_op_cap_check_t);
struct xen_cap_op_get_caps_hypercall {
char *tok;
struct capability *cap;
};
typedef struct xen_cap_op_get_caps_hypercall xen_cap_op_get_caps_hypercall_t;
DEFINE_XEN_GUEST_HANDLE(xen_cap_op_get_caps_hypercall_t);
struct xen_cap_op {
uint32_t cmd;
#define XEN_CAP_OP_cap_create 1
#define XEN_CAP_OP_cap_grant 2
#define XEN_CAP_OP_cap_check 3
#define XEN_CAP_OP_get_caps_hypercall 4
uint32_t interface_version; /* XEN_CAP_OP_INTERFACE_VERSION */
domid_t domain;
union {
struct xen_cap_op_cap_create cap_create;
struct xen_cap_op_cap_grant cap_grant;
struct xen_cap_op_cap_check cap_check;
struct xen_cap_op_get_caps_hypercall get_caps_hypercall;
struct xen_cap_op_cap_create cap_create;
struct xen_cap_op_cap_grant cap_grant;
struct xen_cap_op_cap_check cap_check;
} u;
};
typedef struct xen_cap_op xen_cap_op_t;
......
......@@ -55,6 +55,9 @@ struct cap_space
* to have different pointers.
*/
int num_caps;
/* Hypercalls are limited and hence can be stored
efficiently in fixed sized arrays. */
struct capability *cap_hypercalls;
struct capability *caps;
};
......@@ -67,9 +70,8 @@ int cap_init(void);
int cap_init_hypercalls(void);
int cap_share_boot_info_page(void);
int cap_create(struct capability *cap);
int cap_grant(struct domain *d, struct capability *list, int size );
int cap_check(struct domain *d, struct capability *cap);
void get_caps_hypercall(char *tok, struct capability *cap);
int cap_grant(struct domain *d, int type, void *list, int size );
int cap_check(struct domain *d, int type, struct capability *cap);
extern void init_rand(uint32_t x);
extern uint32_t rand_cmwc(void);
......
This diff is collapsed.
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