Commit fcae6417 authored by Yathindra Naik's avatar Yathindra Naik

Still Debugging... Not clear about the following:

- New connections that are created by entities other than domains. I have set the cap_flag to true by default for every new connection for now.
- In Set_permissions, Owner domain is the first domain according to protocol. I simply create caps and grant caps to others now.
- Still not clear about creating caps during construct_node. Is this the right place or not ? If it is then which is the domain that should have these caps in its cap_space?
- For now, I've been experimenting with mix and match for all of the above. Xenstored comes up fine even when domain 0 is in capability mode. That implies some of the elementary API's of xenstore protocol is playing nice with capabilities.
- When I try to boot a guest domain, it looks like some of the nodes are not getting created in xenstore or due to some bug in creating/granting caps, we simply return ENOENT and domain creation is failing. Still need to debug this.
parent 7455493f
......@@ -412,6 +412,11 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_create_info *info, libxl_capa
}
*domid = -1;
#ifdef CONFIG_XENCAP
if ( cap != NULL )
flags |= XEN_DOMCTL_CDF_cap_flag;
#endif
/* Ultimately, handle is an array of 16 uint8_t, same as uuid */
libxl_uuid_copy((libxl_uuid *)handle, &info->uuid);
......
This diff is collapsed.
......@@ -84,6 +84,8 @@ struct connection
/* The domain I'm associated with, if any. */
struct domain *domain;
/* Identify if this is a capability domain. */
int cap_flag;
/* The target of the domain I'm associated with. */
struct connection *target;
......
......@@ -269,20 +269,35 @@ bool domain_is_unprivileged(struct connection *conn)
#ifdef CONFIG_XENCAP
int get_domid(struct connection *conn)
{
return conn->domain->domid;
if ( conn != NULL && conn->domain != NULL )
return conn->domain->domid;
else
return -1;
}
#if 0
bool domain_is_cap(struct connection *conn)
{
if(conn)
xprintf("domain_is_cap: conn is 0x%x\n", conn);
if(conn->domain)
xprintf("domain_is_cap: conn->domain is 0x%x\n",conn->domain);
if(conn->domain->cap_flag)
xprintf("domain_is_cap: cap_flag is %d\n", conn->domain->cap_flag);
return (conn && conn->domain && conn->domain->cap_flag);
if( conn != NULL )
{
xprintf("domain_is_cap: conn is %p\n", conn);
if( conn->domain != NULL )
{
xprintf("domain_is_cap: conn->domain is %p\n",conn->domain);
if(conn->domain->cap_flag)
{
xprintf("domain_is_cap: cap_flag is %d\n", conn->domain->cap_flag);
//return (conn && conn->domain && conn->domain->cap_flag);
return true;
}
return false;
}
return false;
}
else
return false;
}
#endif
#if 0
/* For a given node, iterate through the domain list.
Find out which domains has the reqd capabilities
......@@ -448,6 +463,10 @@ void do_introduce(struct connection *conn, struct buffered_data *in)
evtchn_port_t port;
int rc;
struct xenstore_domain_interface *interface;
#ifdef CONFIG_XENCAP
xc_dominfo_t dominfo;
#endif
if (get_strings(in, vec, ARRAY_SIZE(vec)) < ARRAY_SIZE(vec)) {
send_error(conn, EINVAL);
......@@ -463,6 +482,12 @@ void do_introduce(struct connection *conn, struct buffered_data *in)
mfn = atol(vec[1]);
port = atoi(vec[2]);
#ifdef CONFIG_XENCAP
xc_domain_getinfo(*xc_handle, domid, 1, &dominfo);
xprintf("Introduce domain (%d), cap_flag: %d\n",domid, dominfo.cap_flag);
#endif
/* Sanity check args. */
if (port <= 0) {
send_error(conn, EINVAL);
......@@ -487,6 +512,14 @@ void do_introduce(struct connection *conn, struct buffered_data *in)
domain->interface = interface;
domain->mfn = mfn;
#ifdef CONFIG_XENCAP
if(dominfo.cap_flag) {
domain->cap_flag = dominfo.cap_flag;
domain->conn->cap_flag = dominfo.cap_flag;
xprintf("Setting cap_flag for conn: %p\n",conn);
}
#endif
/* Now domain belongs to its connection. */
talloc_steal(domain->conn, domain);
......@@ -835,19 +868,19 @@ void domain_watch_inc(struct connection *conn)
void domain_watch_dec(struct connection *conn)
{
if (!conn || !conn->domain)
if (!conn || !conn->domain)
return;
if (conn->domain->nbwatch)
conn->domain->nbwatch--;
if (conn->domain->nbwatch)
conn->domain->nbwatch--;
}
int domain_watch(struct connection *conn)
{
return (domain_is_unprivileged(conn))
? conn->domain->nbwatch
return (domain_is_unprivileged(conn))
? conn->domain->nbwatch
: 0;
}
/*
* Local variables:
* c-file-style: "linux"
......@@ -857,3 +890,5 @@ int domain_watch(struct connection *conn)
* tab-width: 8
* End:
*/
......@@ -62,7 +62,7 @@ bool domain_is_unprivileged(struct connection *conn);
int get_domid(struct connection *conn);
/* Returns true if domain is in capability mode. */
bool domain_is_cap(struct connection *conn);
//bool domain_is_cap(struct connection *conn);
//static char *caps_to_strings(struct connection *conn, unsigned int *len)
......
......@@ -6,6 +6,9 @@
#include <stdarg.h>
#include <string.h>
#include "xenstore_lib.h"
#ifdef CONFIG_XENCAP
#include <xenctrl.h>
#endif
#include "tdb.h"
#include "talloc.h"
#include "utils.h"
......@@ -14,13 +17,24 @@ struct record_hdr {
uint32_t num_perms;
uint32_t datalen;
uint32_t childlen;
#ifdef CONFIG_XENCAP
uint32_t num_caps;
#endif
struct xs_permissions perms[0];
#ifdef CONFIG_XENCAP
struct capability caps[0];
#endif
};
static uint32_t total_size(struct record_hdr *hdr)
{
#ifdef CONFIG_XENCAP
return sizeof(*hdr) + hdr->num_perms * sizeof(struct xs_permissions) + hdr->num_caps * sizeof(struct capability)
+ hdr->datalen + hdr->childlen;
#else
return sizeof(*hdr) + hdr->num_perms * sizeof(struct xs_permissions)
+ hdr->datalen + hdr->childlen;
#endif
}
static char perm_to_char(enum xs_perm_type perm)
......@@ -55,10 +69,10 @@ int main(int argc, char *argv[])
fprintf(stderr, "%.*s: BAD truncated\n",
(int)key.dsize, key.dptr);
else if (data.dsize != total_size(hdr))
fprintf(stderr, "%.*s: BAD length %i for %i/%i/%i (%i)\n",
fprintf(stderr, "%.*s: BAD length %i for %i/%i/%i/%i (%i)\n",
(int)key.dsize, key.dptr, (int)data.dsize,
hdr->num_perms, hdr->datalen,
hdr->childlen, total_size(hdr));
hdr->childlen, hdr->num_caps, total_size(hdr));
else {
unsigned int i;
char *p;
......
......@@ -123,9 +123,6 @@ void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info)
info->nr_online_vcpus = 0;
info->ssidref = 0;
#if CONFIG_XENCAP
printk("getdomainfo: Domain %d\n",d->domain_id);
#endif
/*
* - domain is marked as blocked only if all its vcpus are blocked
* - domain is marked as running if any of its vcpus is running
......@@ -474,8 +471,9 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domctl_t) u_domctl)
domcr_flags |= DOMCRF_oos_off;
#ifdef CONFIG_XENCAP
if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_cap_flag ) {
TT_DBG("Setting cap_flag for new domain\n");
domcr_flags |= DOMCRF_cap_flag;
}
}
#endif
d = domain_create(dom, domcr_flags, op->u.createdomain.ssidref);
printk("returned to XEN_GUEST_HANDLE\n");
......
......@@ -154,10 +154,15 @@ int cap_create(struct domain *d, struct capability *cap)
num_caps = d->cap_space->num_caps;
else
{
TT_DBG("cap_create: cap_space not init'ed\n");
TT_DBG("cap_create: Domain: %d cap_space not init'ed\n",d->domain_id);
return 1;
}
if ( cap == NULL )
{
TT_DBG("cap_create: Domain: %d cap is NULL!\n",d->domain_id);
return 1;
}
TT_DBG("In cap_create()\n");
cap->magic = rand_cmwc();
......
......@@ -61,7 +61,7 @@ struct xen_domctl_createdomain {
#define XEN_DOMCTL_CDF_oos_off (1U<<_XEN_DOMCTL_CDF_oos_off)
uint32_t flags;
#ifdef CONFIG_XENCAP
#define _XEN_DOMCTL_CDF_cap_flag 7
#define _XEN_DOMCTL_CDF_cap_flag 4
#define XEN_DOMCTL_CDF_cap_flag (1U<<_XEN_DOMCTL_CDF_cap_flag)
#endif
};
......
......@@ -20,6 +20,7 @@
#define PHI 0x9e3779b9
#define NUM_HYPERCALLS 100
#define NUM_CAPS 100000
#define SEED 41 /* initial seed valure for RNG */
extern int cap_debug;
......
......@@ -42,6 +42,7 @@ static int cap_domain_create(struct domain *d, u32 ssidref)
}
dom_cap_space->cap_hypercalls = xmalloc_array(struct capability, NUM_HYPERCALLS);
dom_cap_space->caps = xmalloc_array(struct capability, NUM_CAPS);
dom_cap_space->num_caps = 0;
if ( dom_cap_space->cap_hypercalls == NULL )
......@@ -72,7 +73,7 @@ static int cap_domain_create(struct domain *d, u32 ssidref)
d->cap_space = dom_cap_space;
/* Note: Currently, I'm debugging xenstore issues
and i'm setting cap_flag to 0 for domain 0. */
d->cap_flag = 0;
d->cap_flag = 1;
return rc;
}
......@@ -83,7 +84,6 @@ static int cap_domain_create(struct domain *d, u32 ssidref)
* the first time we make a hypercall.
*/
d->cap_space = dom_cap_space;
d->cap_flag = 1;
TT_DBG_ON(cap_debug,"Returning from cap_domain_create\n");
return rc;
......
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