Commit 1d8445b3 authored by Yathindra Naik's avatar Yathindra Naik

Backing out debugging changes

parent 58bb8738
......@@ -22,7 +22,7 @@
#include "xc_private.h"
//struct evtchn_getcaps cap_arg;
struct evtchn_getcaps cap_arg;
static int do_evtchn_op(xc_interface *xch, int cmd, void *arg,
size_t arg_size, int silently_fail)
......@@ -49,28 +49,26 @@ 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*/
#else
evtchn_port_or_error_t
xc_evtchn_alloc_unbound(xc_interface *xch,
uint32_t dom,
uint32_t remote_dom)
//#endif
#endif
{
int rc;
struct evtchn_alloc_unbound arg = {
.dom = (domid_t)dom,
.remote_dom = (domid_t)remote_dom
/*
.remote_dom = (domid_t)remote_dom,
#ifdef CONFIG_XENCAP
.cap_flag = cap_flag
#endif*/
#endif
};
rc = do_evtchn_op(xch, EVTCHNOP_alloc_unbound, &arg, sizeof(arg), 0);
......@@ -86,7 +84,7 @@ int xc_evtchn_reset(xc_interface *xch,
struct evtchn_reset arg = { .dom = (domid_t)dom };
return do_evtchn_op(xch, EVTCHNOP_reset, &arg, sizeof(arg), 0);
}
/*
#ifdef CONFIG_XENCAP
evtchn_cap_t *
xc_evtchn_getcaps(xc_interface *xch, uint32_t dom, evtchn_port_t port)
......@@ -102,7 +100,7 @@ xc_evtchn_getcaps(xc_interface *xch, uint32_t dom, evtchn_port_t port)
return NULL;
}
#endif
*/
int xc_evtchn_status(xc_interface *xch, xc_evtchn_status_t *status)
{
return do_evtchn_op(xch, EVTCHNOP_status, status,
......
......@@ -901,30 +901,28 @@ 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*/
#else
evtchn_port_or_error_t
xc_evtchn_alloc_unbound(xc_interface *xch,
uint32_t dom,
uint32_t remote_dom);
//#endif
#endif
int xc_evtchn_reset(xc_interface *xch,
uint32_t dom);
/*
* Return capabilities for a given event channel.
*/
/*
#ifdef CONFIG_XENCAP
evtchn_cap_t *
xc_evtchn_getcaps(xc_interface *xch, uint32_t dom, evtchn_port_t port);
#endif*/
#endif
typedef struct evtchn_status xc_evtchn_status_t;
int xc_evtchn_status(xc_interface *xch, xc_evtchn_status_t *status);
......
......@@ -104,10 +104,9 @@ struct xc_osdep_ops
evtchn_port_or_error_t (*pending)(xc_evtchn *xce, xc_osdep_handle h);
int (*unmask)(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port);
/*
#ifdef CONFIG_XENCAP
int (*get_evtchn_caps)(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port);
#endif*/
#endif
} evtchn;
struct {
#define XC_GRANT_MAP_SINGLE_DOMAIN 0x1
......
......@@ -955,9 +955,9 @@ int libxl_domain_evtchn(libxl_ctx *ctx, libxl_capabilities *info, uint32_t domid
int ret = 0, x = 0;
uint32_t remote_domain = -1;
int num_ports = -1;
// int port = -1;
int port = -1;
char *tok, *sub_tok, *str, *s;
// struct capability *cap;
struct capability *cap;
// xc_evtchn *xce_handle = NULL;
// xce_handle = xc_evtchn_open(NULL,0);
......@@ -996,7 +996,7 @@ int libxl_domain_evtchn(libxl_ctx *ctx, libxl_capabilities *info, uint32_t domid
}
}
/*
for ( ;num_ports >= 0; num_ports--)
{
if ( (port = xc_evtchn_alloc_unbound(ctx->xch, domid, remote_domain, 1)) != -1)
......@@ -1015,7 +1015,7 @@ int libxl_domain_evtchn(libxl_ctx *ctx, libxl_capabilities *info, uint32_t domid
}
else
printf("xc_evtchn_alloc_unbound failed\n");
}*/
}
printf("remote_domain %d and num_ports %d\n",remote_domain,num_ports);
}
......
......@@ -283,15 +283,15 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
con_domid = xs_read(ctx->xsh, XBT_NULL, "/tool/xenconsoled/domid", NULL);
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, 0);
state->console_port = xc_evtchn_alloc_unbound(ctx->xch, domid, state->console_domid, 0);
#else*/
#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
#endif
return 0;
}
......
......@@ -504,14 +504,13 @@ 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*/
#else
result = xc_evtchn_alloc_unbound(_H(xch), c_local_domid,
c_remote_domid);
//#endif
#endif
caml_leave_blocking_section();
if (result < 0)
......
......@@ -1101,12 +1101,11 @@ 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*/
#else
if ( (port = xc_evtchn_alloc_unbound(self->xc_handle, dom, remote_dom)) < 0 )
//#endif
#endif
return pyxc_error_to_exception(self->xc_handle);
return PyInt_FromLong(port);
......
......@@ -398,7 +398,7 @@ static struct domain *new_domain(void *context, unsigned int domid,
list_add(&domain->list, &domains);
talloc_set_destructor(domain, destroy_domain);
xprintf("new_domain: evtchn_bind_interdomain: domid:%d port:%d\n",domid,port);
xprintf("new_domain: evtchn_bind_interdomain.\n");
/* Tell kernel we're interested in this event. */
rc = xc_evtchn_bind_interdomain(xce_handle, domid, port);
if (rc == -1)
......@@ -587,7 +587,7 @@ void do_introduce(struct connection *conn, struct buffered_data *in)
#ifdef CONFIG_XENCAP
xc_domain_getinfo(*xc_handle, domid, 1, &dominfo);
xprintf("Introduce domain (%d), evtchn_port: %d, cap_flag: %d\n",domid, port, dominfo.cap_flag);
xprintf("Introduce domain (%d), cap_flag: %d\n",domid, dominfo.cap_flag);
#endif
/* Sanity check args. */
......@@ -840,7 +840,6 @@ static int dom0_init(void)
struct domain *dom0;
port = xenbus_evtchn();
xprintf("xenbus_evtchn: port %d\n",port);
if (port == -1)
return -1;
......
......@@ -174,12 +174,12 @@ static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc)
if ( (port = get_free_port(d)) < 0 )
ERROR_EXIT_DOM(port, d);
chn = evtchn_from_port(d, port);
/*
#ifdef CONFIG_XENCAP
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);
chn->cap_flag = alloc->cap_flag;
#endif
*/
rc = xsm_evtchn_unbound(d, chn, alloc->remote_dom);
if ( rc )
goto out;
......@@ -973,7 +973,7 @@ out:
return rc;
}
/*
#ifdef CONFIG_XENCAP
int evtchn_getcaps(evtchn_getcaps_t *t)
{
......@@ -1001,7 +1001,7 @@ out:
return rc;
}
#endif
*/
long do_event_channel_op(int cmd, XEN_GUEST_HANDLE(void) arg)
{
long rc;
......@@ -1109,19 +1109,16 @@ 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 )
return -EFAULT;
rc = evtchn_getcaps(&getcaps);
if ( (rc == 0) && (copy_to_guest(arg, &getcaps, 1) != 0) )
rc = -EFAULT;
rc = -EFAULT; /* Cleaning up here would be a mess! */
break;
}
#endif
*/
}
default:
rc = -ENOSYS;
......
......@@ -8,6 +8,9 @@
* Authors: Yathindra Naik
* Date: September 2012
*/
#include <xen/mm.h>
#include <xen/xmalloc.h>
#include <xen/sched.h>
......
......@@ -28,7 +28,7 @@
#define __XEN_PUBLIC_EVENT_CHANNEL_H__
#include "xen.h"
/*#include "xen-cap.h"*/
#include "xen-cap.h"
/*
* `incontents 150 evtchn Event Channels
......@@ -261,15 +261,14 @@ typedef struct evtchn_unmask evtchn_unmask_t;
* EVTCHNOP_getcaps: Return capability associated with an
* event-channel
*/
//struct evtchn_getcaps {
struct evtchn_getcaps {
/* IN parameters. */
// domid_t dom;
// evtchn_port_t port;
domid_t dom;
evtchn_port_t port;
/* OUT parameters. */
// evtchn_cap_t caps;
//};
//typedef struct evtchn_getcaps evtchn_getcaps_t;
evtchn_cap_t caps;
};
typedef struct evtchn_getcaps evtchn_getcaps_t;
#endif
/*
......@@ -303,10 +302,9 @@ struct evtchn_op {
struct evtchn_status status;
struct evtchn_bind_vcpu bind_vcpu;
struct evtchn_unmask unmask;
/*
#ifdef CONFIG_XENCAP
struct evtchn_getcaps getcaps;
#endif*/
#endif
} u;
};
typedef struct evtchn_op evtchn_op_t;
......
......@@ -71,10 +71,10 @@ struct evtchn
#ifdef FLASK_ENABLE
void *ssid;
#endif
/*#ifdef CONFIG_XENCAP
#ifdef CONFIG_XENCAP
u8 cap_flag;
struct capability *cap;
#endif*/
#endif
};
int evtchn_init(struct domain *d); /* from domain_create */
......
/**
* This file is a part of the Flux Xen Capabilities infrastructure.
*
* Capabilities Support for Xen
*
* Author: Yathindra Naik
* Date: September 2012
*/
#ifndef __XEN_CAP_H__
#define __XEN_CAP_H__
#include <xen/sched.h>
//#include <xen/lib.h>
/* Capability tokens are random numbers for now. This implementation is taken from wikipedia.
* Source: http://en.wikipedia.org/wiki/Multiply-with-carry
* This is based on Multiply-with-carry random number generation algorithm invented by George Marsaglia.
*/
#define PHI 0x9e3779b9
#define NUM_HYPERCALLS 100
#define NUM_CAPS 100000
#define SEED 41 /* initial seed valure for RNG */
extern int cap_debug;
extern struct domain *d;
/* This is a simple structure for capabilities. */
/* It is on a list for now. Later I'll consider a more efficient structure. */
struct capability
{
uint32_t magic;
/* We may need to encode the rights here too ? */
/* CAP_READ, CAP_WRITE, CAP_SHARE etc */
//struct list_head cap_list;
};
struct cap_boot_info
{
struct capability cap_hypercalls[NUM_HYPERCALLS];
};
extern struct cap_boot_info *CAP_BOOT_INFO;
/* Pointer to capability boot info page */
//struct cap_boot_info *CAP_BOOT_INFO;
/* Domains maintain their capabilities in cap_space */
struct cap_space
{
/* Different resources maintain their capabilities
* in efficient lookup structures. Hence, we need
* to have different pointers.
*/
int num_caps;
struct capability *caps;
};
#define CAP_INIT(x,y) { (x), (y) }
#define CAP_DEFINE(name,x,y) \
struct capability cap_##name = CAP_INIT(x,y)
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);
extern void init_rand(uint32_t x);
extern uint32_t rand_cmwc(void);
#endif /* __XEN_CAP_H__ */
......@@ -1563,8 +1563,7 @@ static int cap_evtchn_unbound (struct domain *d, struct evtchn *chn,
if ( (ret = cap_check(current->domain, cap)) == 1 )
{
TT_DBG_ON(cap_debug,"cap_check success\n");
return 0;
/*
if (chn->cap_flag == 0)
return 0;
......@@ -1574,11 +1573,11 @@ static int cap_evtchn_unbound (struct domain *d, struct evtchn *chn,
return 0;
}
else
return 1;*/
return 1;
}
else
{
TT_DBG_ON(cap_debug,"cap_check failed!\n");
TT_DBG_ON(cap_debug,"cap_check failed!\nLeaving cap_evtchn_unbound()\n");
return 1;
}
......
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