Commit f70a2190 authored by Yathindra Naik's avatar Yathindra Naik

- New and Simpler design for event channels

- Removed all the changes from first design
- Note: cap_check is effective on alloc_unbound, bind and send for now
- Config file should list only the domains that needs to establish event channels
- Since Domain-0 has all the backend drivers, we'll need to make a driver domain to test some of the changes
- Next step is to create a driver domain and see what is missing
parent abbc2a2e
......@@ -22,7 +22,10 @@
#include "xc_private.h"
#ifdef CONFIG_XENCAP
struct evtchn_getcaps cap_arg;
struct evtchn_alloc_caps cap_alloc_arg;
#endif
static int do_evtchn_op(xc_interface *xch, int cmd, void *arg,
size_t arg_size, int silently_fail)
......@@ -49,26 +52,15 @@ static int do_evtchn_op(xc_interface *xch, int cmd, void *arg,
return ret;
}
#ifdef CONFIG_XENCAP
evtchn_port_or_error_t
xc_evtchn_alloc_unbound(xc_interface *xch,
uint32_t dom,
uint32_t remote_dom,
int cap_flag)
#else
evtchn_port_or_error_t
xc_evtchn_alloc_unbound(xc_interface *xch,
uint32_t dom,
uint32_t remote_dom)
#endif
{
int rc;
struct evtchn_alloc_unbound arg = {
.dom = (domid_t)dom,
.remote_dom = (domid_t)remote_dom,
#ifdef CONFIG_XENCAP
.cap_flag = cap_flag
#endif
};
rc = do_evtchn_op(xch, EVTCHNOP_alloc_unbound, &arg, sizeof(arg), 0);
......@@ -87,11 +79,10 @@ int xc_evtchn_reset(xc_interface *xch,
#ifdef CONFIG_XENCAP
evtchn_cap_t *
xc_evtchn_getcaps(xc_interface *xch, uint32_t dom, evtchn_port_t port)
xc_evtchn_getcaps(xc_interface *xch, uint32_t dom)
{
int rc;
cap_arg.dom = (domid_t)dom;
cap_arg.port = port;
rc = do_evtchn_op(xch, EVTCHNOP_getcaps, &cap_arg, sizeof(cap_arg), 0);
if (rc == 0)
......@@ -99,6 +90,19 @@ xc_evtchn_getcaps(xc_interface *xch, uint32_t dom, evtchn_port_t port)
else
return NULL;
}
evtchn_cap_t *
xc_evtchn_alloc_caps(xc_interface *xch, uint32_t dom)
{
int rc;
cap_alloc_arg.dom = (domid_t)dom;
rc = do_evtchn_op(xch, EVTCHNOP_alloc_caps, &cap_alloc_arg, sizeof(cap_alloc_arg), 0);
if (rc == 0)
return &(cap_alloc_arg.caps);
else
return NULL;
}
#endif
int xc_evtchn_status(xc_interface *xch, xc_evtchn_status_t *status)
......
......@@ -901,18 +901,10 @@ typedef int evtchn_port_or_error_t;
* @parm remote_dom the ID of the domain who will later bind
* @return allocated port (in @dom) on success, -1 on failure
*/
#ifdef CONFIG_XENCAP
evtchn_port_or_error_t
xc_evtchn_alloc_unbound(xc_interface *xch,
uint32_t dom,
uint32_t remote_dom,
int cap_flag);
#else
evtchn_port_or_error_t
xc_evtchn_alloc_unbound(xc_interface *xch,
uint32_t dom,
uint32_t remote_dom);
#endif
int xc_evtchn_reset(xc_interface *xch,
uint32_t dom);
......@@ -921,7 +913,10 @@ int xc_evtchn_reset(xc_interface *xch,
*/
#ifdef CONFIG_XENCAP
evtchn_cap_t *
xc_evtchn_getcaps(xc_interface *xch, uint32_t dom, evtchn_port_t port);
xc_evtchn_getcaps(xc_interface *xch, uint32_t dom);
evtchn_cap_t *
xc_evtchn_alloc_caps(xc_interface *xch, uint32_t dom);
#endif
typedef struct evtchn_status xc_evtchn_status_t;
......
......@@ -952,29 +952,74 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
#ifdef CONFIG_XENCAP
int libxl_domain_evtchn(libxl_ctx *ctx, libxl_capabilities *info, uint32_t domid)
{
int ret = 0, x = 0;
int x = 0;
uint32_t remote_domain = -1;
int num_ports = -1;
int port = -1;
char *tok, *sub_tok, *str, *s;
struct capability *cap;
char *tok;//, *sub_tok, *str, *s;
struct capability *caps;
xc_dominfo_t dom_info;
xc_evtchn_status_t status;
printf ("Splitting string \"%s\" into tokens:\n",info->cap_values);
tok = strtok (info->cap_values," ,.\n\t");
// Now we are ok to init evtchn cap
caps = xc_evtchn_alloc_caps(ctx->xch,domid);
if (caps == NULL)
{
printf("xc_evtchn_alloc_caps returned NULL\n");
return -1;
}
/*
* 1. Parse the config file
* 2. For each Domid:Num_Port pair, alloc Num_Port evtchns
* 2. For each Domid, alloc est_evtchn cap
* 3.
*/
while (tok != NULL)
{
printf("%s\n",tok);
str = strdup(tok);
for ( ; (*tok - '0' >= 0) && (*tok - '0' <= 9) ; tok++)
x = x*10 + (*tok - '0');
remote_domain = x;
printf("remote_domain is %d\n",remote_domain);
tok = strtok(NULL," ,.\n\t");
// Check if the remote domain exists.
// If yes, grant caps and then return.
if (xc_domain_getinfo(ctx->xch,remote_domain,1,&dom_info) > 0)
{
if (dom_info.running || dom_info.paused || dom_info.blocked)
printf("Remote domain %d exists\n",remote_domain);
if (dom_info.shutdown || dom_info.dying)
{
printf("Remote domain %d shutdown\n!",remote_domain);
continue;
}
if (dom_info.cap_flag == 0)
{
printf("Remote domain %d cap_flag not set!\n",remote_domain);
continue;
}
if (xc_cap_grant(ctx->xch, remote_domain, caps, 1))
{
printf("Granting caps failed\n");
return -1;
}
// Get caps for remote_domain and grant it
caps = xc_evtchn_getcaps(ctx->xch, remote_domain);
if (caps == NULL)
{
printf("Getcaps for domain %d returned NULL!\n",remote_domain);
return -1;
}
if (xc_cap_grant(ctx->xch, domid, caps, 1))
{
printf("Granting caps failed\n");
return -1;
}
}
#if 0
sub_tok = strtok(str,":");
s = strdup(sub_tok);
// simple string to int conversion with error checking
......@@ -1074,8 +1119,8 @@ int libxl_domain_evtchn(libxl_ctx *ctx, libxl_capabilities *info, uint32_t domid
}
printf("remote_domain %d and num_ports %d\n",remote_domain,num_ports);
#endif
}
printf("returning 0 from libxl_evtchn()\n");
return 0;
}
......
......@@ -284,14 +284,9 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
state->console_domid = con_domid ? atoi(con_domid) : 0;
free(con_domid);
#ifdef CONFIG_XENCAP
state->store_port = xc_evtchn_alloc_unbound(ctx->xch, domid, state->store_domid, 1);
state->console_port = xc_evtchn_alloc_unbound(ctx->xch, domid, state->console_domid, 1);
#else
state->store_port = xc_evtchn_alloc_unbound(ctx->xch, domid, state->store_domid);
state->console_port = xc_evtchn_alloc_unbound(ctx->xch, domid, state->console_domid);
state->vm_generationid_addr = 0;
#endif
return 0;
}
......
......@@ -504,13 +504,8 @@ CAMLprim value stub_xc_evtchn_alloc_unbound(value xch,
uint32_t c_remote_domid = _D(remote_domid);
caml_enter_blocking_section();
#ifdef CONFIG_XENCAP
result = xc_evtchn_alloc_unbound(_H(xch), c_local_domid,
c_remote_domid, 0);
#else
result = xc_evtchn_alloc_unbound(_H(xch), c_local_domid,
c_remote_domid);
#endif
caml_leave_blocking_section();
if (result < 0)
......
......@@ -1101,11 +1101,7 @@ static PyObject *pyxc_evtchn_alloc_unbound(XcObject *self,
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list,
&dom, &remote_dom) )
return NULL;
#ifdef CONFIG_XENCAP
if ( (port = xc_evtchn_alloc_unbound(self->xc_handle, dom, remote_dom, 0)) < 0 )
#else
if ( (port = xc_evtchn_alloc_unbound(self->xc_handle, dom, remote_dom)) < 0 )
#endif
return pyxc_error_to_exception(self->xc_handle);
return PyInt_FromLong(port);
......
......@@ -840,6 +840,7 @@ static int dom0_init(void)
struct domain *dom0;
port = xenbus_evtchn();
xprintf("dom0_init: port %d\n",port);
if (port == -1)
return -1;
......
......@@ -120,11 +120,7 @@ static int virq_is_global(uint32_t virq)
return rc;
}
#ifdef CONFIG_XENCAP
static int get_free_port(struct domain *d, uint32_t reserve)
#else
static int get_free_port(struct domain *d)
#endif
{
struct evtchn *chn;
int port;
......@@ -135,18 +131,8 @@ static int get_free_port(struct domain *d)
for ( port = 0; port_is_valid(d, port); port++ )
{
#ifdef CONFIG_XENCAP
chn = evtchn_from_port(d, port);
if ( reserve == 2 && chn->state == ECS_FREE )
return port;
if ( reserve == 1 && chn->state == ECS_CAP_FREE )
return port;
if ( reserve == 0 && chn->state == ECS_FREE )
return port;
#else
if ( evtchn_from_port(d, port)->state == ECS_FREE )
return port;
#endif
}
if ( port == MAX_EVTCHNS(d) )
......@@ -186,23 +172,10 @@ static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc)
spin_lock(&d->event_lock);
#ifdef CONFIG_XENCAP
if ( (port = get_free_port(d,alloc->cap_flag)) < 0 )
#else
if ( (port = get_free_port(d)) < 0 )
#endif
ERROR_EXIT_DOM(port, d);
chn = evtchn_from_port(d, port);
#ifdef CONFIG_XENCAP
if (alloc->cap_flag == 2)
chn->cap_flag = 1;
else
chn->cap_flag = alloc->cap_flag;
TT_DBG("cap_flag for channel: %d, Domain:%d, Port: %d, Remote_Domain:%d\n",alloc->cap_flag,(int)alloc->dom,port,alloc->remote_dom);
TT_DBG("calling xsm_evtchn_unbound\n");
#endif
rc = xsm_evtchn_unbound(d, chn, alloc->remote_dom);
if ( rc )
{
......@@ -210,31 +183,7 @@ static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc)
goto out;
}
#ifdef CONFIG_XENCAP
/* First time we are here, the channel's state
is ECS_FREE and we change it to ECS_CAP_FREE.
Second time, we know that and change it to be
ECS_CAP_UNBOUND. This makes sure that get_free_port
does not return the same port again.*/
TT_DBG("chn->state before is %d\n",chn->state);
/* Note: Since dom0 is created first and there is no way to specify
dom0's config via libxl, we need this condition. It is basically
to make sure state trasistion happens correctly. For other domains,
we allocate a pool of channels when they boot and init their state
to be ECS_CAP_FREE. After the domain comes up and drivers want to
allocate evt channels, we first get a port that has state ECS_CAP_FREE,
and then we change its state to ECS_CAP_UNBOUND.*/
if (alloc->dom == 0 || alloc->dom == 32752 || alloc->remote_dom == 0 ||
(alloc->dom == 32752 && alloc->remote_dom == 32752))
chn->state = ECS_UNBOUND;
else if ((chn->cap_flag == 1) && (chn->state == ECS_FREE))
chn->state = ECS_CAP_FREE;
else
chn->state = ECS_UNBOUND;
TT_DBG("chn->state after is %d\n",chn->state);
#endif
chn->state = ECS_UNBOUND;
if ( (chn->u.unbound.remote_domid = alloc->remote_dom) == DOMID_SELF )
chn->u.unbound.remote_domid = current->domain->domain_id;
......@@ -274,20 +223,14 @@ static long evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind)
spin_lock(&ld->event_lock);
}
/* Note: I'm assuming cap_flag to be 0. I'm not sure
if we need cap_flag here? */
#ifdef CONFIG_XENCAP
if ( (lport = get_free_port(ld, 0)) < 0 )
#else
if ( (lport = get_free_port(ld)) < 0 )
#endif
ERROR_EXIT(lport);
lchn = evtchn_from_port(ld, lport);
if ( !port_is_valid(rd, rport) )
ERROR_EXIT_DOM(-EINVAL, rd);
rchn = evtchn_from_port(rd, rport);
TT_DBG("rchn->state:%d, Domain:%d, port:%d, remoter_domain:%d, remote_port:%d\n",rchn->state,current->domain->domain_id,lport,rdom,rport);
TT_DBG("rchn->state: %d, rport: %d\n",rchn->state,rport);
if ( (rchn->state != ECS_UNBOUND) ||
(rchn->u.unbound.remote_domid != ld->domain_id) )
ERROR_EXIT_DOM(-EINVAL, rd);
......@@ -346,11 +289,7 @@ static long evtchn_bind_virq(evtchn_bind_virq_t *bind)
if ( v->virq_to_evtchn[virq] != 0 )
ERROR_EXIT(-EEXIST);
#ifdef CONFIG_XENCAP
if ( (port = get_free_port(d,0)) < 0 )
#else
if ( (port = get_free_port(d)) < 0 )
#endif
ERROR_EXIT(port);
chn = evtchn_from_port(d, port);
......@@ -380,11 +319,7 @@ static long evtchn_bind_ipi(evtchn_bind_ipi_t *bind)
spin_lock(&d->event_lock);
#ifdef CONFIG_XENCAP
if ( (port = get_free_port(d,0)) < 0 )
#else
if ( (port = get_free_port(d)) < 0 )
#endif
ERROR_EXIT(port);
chn = evtchn_from_port(d, port);
chn->state = ECS_IPI;
......@@ -443,11 +378,7 @@ static long evtchn_bind_pirq(evtchn_bind_pirq_t *bind)
if ( pirq_to_evtchn(d, pirq) != 0 )
ERROR_EXIT(-EEXIST);
#ifdef CONFIG_XENCAP
if ( (port = get_free_port(d,0)) < 0 )
#else
if ( (port = get_free_port(d)) < 0 )
#endif
ERROR_EXIT(port);
chn = evtchn_from_port(d, port);
......@@ -918,9 +849,6 @@ static long evtchn_status(evtchn_status_t *status)
BUG();
}
#ifdef CONFIG_XENCAP
status->cap_flag = chn->cap_flag;
#endif
status->vcpu = chn->notify_vcpu_id;
out:
......@@ -1047,37 +975,52 @@ int evtchn_getcaps(evtchn_getcaps_t *t)
{
domid_t dom = t->dom;
struct domain *d;
struct evtchn *chn;
struct capability *caps = NULL;
int rc = 0;
TT_DBG("Domain: %d, Port: %d\n",dom,t->port);
TT_DBG("Domain: %d\n",dom);
rc = rcu_lock_target_domain_by_id(dom, &d);
if (rc)
goto out;
if ( unlikely(!port_is_valid(d, t->port)) )
t->caps.magic = d->est_evtchn->magic;
out:
rcu_unlock_domain(d);
return rc;
}
/* Allocate capability for evtchn communication */
int evtchn_alloc_caps(evtchn_alloc_caps_t *t)
{
domid_t dom = t->dom;
struct domain *d;
int rc = 0;
TT_DBG("Domain: %d\n",dom);
rc = rcu_lock_target_domain_by_id(dom, &d);
if (rc)
goto out;
if (d->cap_flag == 0)
{
TT_ERR("port is not valid!\n");
goto out;
TT_ERR("Domain %d is not in capability mode, cap->flag is not set!\n",t->dom);
rc = -1;
goto out;
}
chn = evtchn_from_port(d, t->port);
if ( chn == NULL || chn->cap_flag == 0)
d->est_evtchn = xmalloc(struct capability);
if (cap_create(d->est_evtchn))
{
TT_ERR("channel is NULL or chn->cap_flag is not set\n");
goto out;
TT_ERR("cap_create for est_evtchn failed\n");
rc = -1;
}
if ( chn->cap == NULL)
TT_ERR("Capability for channel is NULL\n");
caps = chn->cap;
if (caps == NULL)
rc = -1;
else
t->caps = *caps;
{
t->caps.magic = d->est_evtchn->magic;
TT_DBG("est_evtchn: 0x%x\n",d->est_evtchn->magic);
}
out:
rcu_unlock_domain(d);
return rc;
rcu_unlock_domain(d);
return rc;
}
#endif
......@@ -1188,7 +1131,7 @@ long do_event_channel_op(int cmd, XEN_GUEST_HANDLE(void) arg)
rc = evtchn_reset(&reset);
break;
}
#ifdef CONFIG_XENCAP
case EVTCHNOP_getcaps: {
struct evtchn_getcaps getcaps;
if ( copy_from_guest(&getcaps, arg, 1) != 0 )
......@@ -1205,6 +1148,22 @@ long do_event_channel_op(int cmd, XEN_GUEST_HANDLE(void) arg)
break;
}
case EVTCHNOP_alloc_caps: {
struct evtchn_alloc_caps alloc_caps;
if ( copy_from_guest(&alloc_caps, arg, 1) != 0 )
{
TT_ERR("copy_from_guest failed\n");
return -EFAULT;
}
rc = evtchn_alloc_caps(&alloc_caps);
if ( (rc == 0) && (copy_to_guest(arg, &alloc_caps, 1) != 0) )
{
TT_ERR("copy_to_guest failed!\n");
rc = -EFAULT; /* Cleaning up here would be a mess! */
}
break;
}
#endif
default:
rc = -ENOSYS;
break;
......@@ -1224,11 +1183,7 @@ int alloc_unbound_xen_event_channel(
spin_lock(&d->event_lock);
#ifdef CONFIG_XENCAP
if ( (port = get_free_port(d,0)) < 0 )
#else
if ( (port = get_free_port(d)) < 0 )
#endif
goto out;
chn = evtchn_from_port(d, port);
......@@ -1304,11 +1259,7 @@ void notify_via_xen_event_channel(struct domain *ld, int lport)
int evtchn_init(struct domain *d)
{
spin_lock_init(&d->event_lock);
#ifdef CONFIG_XENCAP
if ( get_free_port(d,0) != 0 )
#else
if ( get_free_port(d) != 0 )
#endif
return -EINVAL;
evtchn_from_port(d, 0)->state = ECS_RESERVED;
......
......@@ -145,6 +145,41 @@ int cap_init_hypercalls()
return 0;
}
/*
* Since I cannot pass struct domain to cap_create
* this is a helper routine only for Domain-0
*/
int dom0_cap_create(struct domain *d, struct capability *cap)
{
TT_DBG("\n");
if (d->domain_id != 0)
{
TT_ERR("Illegal domain id\n");
return 1;
}
if ( cap == NULL )
{
TT_ERR("cap_create: Domain: %d cap is NULL!\n",d->domain_id);
return 1;
}
//TT_DBG("In cap_create()\n");
cap->magic = rand_cmwc();
/* NOTE: I'm not sure if we need to insert the newly
* create cap in calling domains cap_space.
* For now, this will help me with xenstore since
* which ever domain is calling cap_create will have
* the necessary capabilities in its cap_space.
* Also, note that the *cap below might be a local
* pointer!!!!!
*/
d->cap_space->num_caps++;
TT_DBG("Domain %d Capability 0x%x inserted at index %d\n",d->domain_id, cap->magic, d->cap_space->num_caps);
return 0;
}
/*
* Creates a capability.
*/
......@@ -154,6 +189,15 @@ int cap_create(struct capability *cap)
struct domain *d = current->domain;
init_rand(41);
if (d->domain_id > 100) // change this to DOMID_SELF ?
{
if (rcu_lock_target_domain_by_id(0,&d))
{
TT_ERR("could not lock domain 0\n");
return 1;
}
}
if (d->cap_flag == 0)
{
TT_DBG("Domain %d not in capability mode!\n",current->domain->domain_id);
......@@ -193,6 +237,8 @@ int cap_create(struct capability *cap)
d->cap_space->caps[num_caps] = *cap;
d->cap_space->num_caps++;
TT_DBG("Domain %d Capability 0x%x inserted at index %d\n",d->domain_id, cap->magic, d->cap_space->num_caps);
if (d->domain_id == 0)
rcu_unlock_domain(d);
return 0;
}
......
......@@ -74,6 +74,7 @@
#define EVTCHNOP_reset 10
#ifdef CONFIG_XENCAP
#define EVTCHNOP_getcaps 11
#define EVTCHNOP_alloc_caps 12
#endif
/* ` } */
......@@ -94,10 +95,6 @@ DEFINE_XEN_GUEST_HANDLE(evtchn_cap_t);
struct evtchn_alloc_unbound {
/* IN parameters */
domid_t dom, remote_dom;
#ifdef CONFIG_XENCAP
/* IN parameters */
uint32_t cap_flag;
#endif
/* OUT parameters */
evtchn_port_t port;
};
......@@ -213,9 +210,6 @@ struct evtchn_status {
#define EVTCHNSTAT_ipi 5 /* Channel is bound to a virtual IPI line */
uint32_t status;
uint32_t vcpu; /* VCPU to which this channel is bound. */
#ifdef CONFIG_XENCAP
uint32_t cap_flag; /* Is this channel capability protected */
#endif
union {
struct {
domid_t dom;
......@@ -267,11 +261,21 @@ typedef struct evtchn_unmask evtchn_unmask_t;
struct evtchn_getcaps {
/* IN parameters. */
domid_t dom;
evtchn_port_t port;
/* OUT parameters. */
evtchn_cap_t caps;
};
typedef struct evtchn_getcaps evtchn_getcaps_t;
/*
* EVTCHNOP_alloc_caps: Allocate a evt chn capability
*/
struct evtchn_alloc_caps {
/* IN parameters. */
domid_t dom;
/* OUT paramters. */
evtchn_cap_t caps;
};
typedef struct evtchn_alloc_caps evtchn_alloc_caps_t;
#endif
/*
......@@ -307,6 +311,7 @@ struct evtchn_op {
struct evtchn_unmask unmask;
#ifdef CONFIG_XENCAP
struct evtchn_getcaps getcaps;
struct evtchn_alloc_caps alloc_caps;
#endif
} u;
};
......
......@@ -50,9 +50,6 @@ struct evtchn
#define ECS_PIRQ 4 /* Channel is bound to a physical IRQ line. */
#define ECS_VIRQ 5 /* Channel is bound to a virtual IRQ line. */
#define ECS_IPI 6 /* Channel is bound to a virtual IPI line. */
#ifdef CONFIG_XENCAP
#define ECS_CAP_FREE 7 /* Channel is associated with a capability and is available for use */
#endif
u8 state; /* ECS_* */
u8 xen_consumer; /* Consumer in Xen, if any? (0 = send to guest) */
u16 notify_vcpu_id; /* VCPU for local delivery notification */
......@@ -74,10 +71,6 @@ struct evtchn
#ifdef FLASK_ENABLE
void *ssid;
#endif
#ifdef CONFIG_XENCAP
u8 cap_flag;
struct capability *cap;
#endif
};
int evtchn_init(struct domain *d); /* from domain_create */
......@@ -360,9 +353,8 @@ struct domain
#ifdef CONFIG_XENCAP
int cap_flag; // indicates if this domain is in capability mode
struct cap_space *cap_space; // structure to hold capabilities. And for fast lookup.
struct capability *est_evtchn; // allow this domain to establish event channel
#endif
};
......
......@@ -84,6 +84,18 @@ static int cap_domain_create(struct domain *d, u32 ssidref)
}
d->cap_space = dom_cap_space;
d->cap_flag = 1;
/* Also, init est_evtchn - allowing other domains to est event channels with domain 0 */
d->est_evtchn = xmalloc(struct capability);
if (d->est_evtchn == NULL)
{
TT_ERR("Could not alloc est_evtchn to Domain 0\n");
return -1;
}
if (dom0_cap_create(d,d->est_evtchn))
{
TT_ERR("Could not create cap for Dom0's est_evtchn\n");
return -1;
}
return rc;
}
else
......@@ -1547,8 +1559,8 @@ static int cap_evtchn_unbound (struct domain *d, struct evtchn *chn,
domid_t id2)
{
int ret = 0;
struct capability *cap;
struct domain *remote_domain;
// if ( IS_PRIV(current->domain) )
// return 0;
......@@ -1557,39 +1569,41 @@ static int cap_evtchn_unbound (struct domain *d, struct evtchn *chn,
TT_DBG("returning\n");
return 0;
}
if (DOMID_SELF == id2)
{
TT_DBG("Remote is Self domain\n");
return 0;
}
// if ( current->domain->cap_flag == 0 || d->cap_flag == 0 )
// return 0;
TT_DBG("\n");
cap = &(CAP_BOOT_INFO->cap_hypercalls[46]);
/* Are we allowed to make this hypercall? */
if ( (ret = cap_check(current->domain, cap)) == 1 )
{
TT_DBG("cap_check success\n");
if (chn->cap_flag == 0)
return 0;
if (chn->cap_flag == 1)
/* Check if the remote domain has the cap to
est evtchn. Note, remote domain must exist
for this to work. */
if (d->est_evtchn == NULL)
{
if ( chn->cap == NULL)
{
TT_DBG("alloc cap for channel\n");
chn->cap = xmalloc(struct capability);