Commit 336cd518 authored by Yathindra Naik's avatar Yathindra Naik

This change contains

- Bug fix for xenstore message corruption
- Explicit grant of capabilities for Xenstore
- Few patches to make Xen-4.3-unstable play nice with multi-core CPUs
- Still Linux Guest OS cannot use cap_grant which needs to be implemented
parent e8cb9fbd
......@@ -140,8 +140,8 @@ char **xs_directory(struct xs_handle *h, xs_transaction_t t,
msg = xenbus_ls(t, path, &res);
if (msg) {
printk("xs_directory(%s): %s\n", path, msg);
return NULL;
printk("xs_directory(%s): %s\n", path, msg);
return NULL;
}
size = 0;
......
......@@ -361,13 +361,6 @@ int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Granting caps for %s failed\n",name_path);
}
// delete this
if (!xc_cap_check(ctx->xch, domid, 2, &caps[1])) {
list[0] = caps[1];
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Granting caps for %s failed\n",name_path);
}
#endif
if (stub_dm_domid) {
rc = libxl__domain_rename(gc, stub_dm_domid,
......@@ -526,13 +519,6 @@ int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid,
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s/vm failed\n",dom_path);
}
// delete this
if (!xc_cap_check(ctx->xch, domid, 2, &caps[1])) {
list[0] = caps[1];
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s/vm failed\n",dom_path);
}
#endif
rc = libxl__domain_rename(gc, domid, info->name, preserved_name, t);
if (rc) {
......@@ -550,12 +536,6 @@ int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid,
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s/uuid failed\n",vm_path);
}
// delete this
if (!xc_cap_check(ctx->xch, domid, 2, &caps[1])) {
list[0] = caps[1];
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s/uuid failed\n",vm_path);
}
caps = NULL;
caps = xs_get_caps(ctx->xsh, t, vm_path);
......@@ -566,13 +546,6 @@ int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid,
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s failed\n",vm_path);
}
//delete this
if (!xc_cap_check(ctx->xch, domid, 2, &caps[1])) {
list[0] = caps[1];
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s failed\n",vm_path);
}
#endif
if (!xs_transaction_end(ctx->xsh, t, 0))
if (errno == EAGAIN)
......
......@@ -503,12 +503,6 @@ retry_transaction:
if (xc_cap_grant(ctx->xch, *domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s/vm failed\n",dom_path);
}
// delete this
if (!xc_cap_check(ctx->xch, *domid, 2, &caps[1])) {
list[0] = caps[1];
if (xc_cap_grant(ctx->xch, *domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s/vm failed\n",dom_path);
}
#endif
rc = libxl__domain_rename(gc, *domid, 0, info->name, t);
if (rc)
......@@ -609,12 +603,6 @@ retry_transaction:
LOG(ERROR, "Granting caps for %s/uuid failed\n",vm_path);
}
//delete this
if (!xc_cap_check(ctx->xch, *domid, 2, &caps[1])) {
list[0] = caps[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);
......@@ -625,12 +613,6 @@ retry_transaction:
if (xc_cap_grant(ctx->xch, *domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s/name failed\n",vm_path);
}
//delete this
if (!xc_cap_check(ctx->xch, *domid, 2, &caps[1])) {
list[0] = caps[1];
if (xc_cap_grant(ctx->xch, *domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s/name failed\n",vm_path);
}
#endif
#ifdef CONFIG_XENCAP
libxl__xs_writev(gc, t, dom_path, info->xsdata, *domid, 'r');
......@@ -653,13 +635,6 @@ retry_transaction:
LOG(ERROR, "Granting caps for %s/control/platform-feature-multiprocessor-suspend is NULL", dom_path);
}
//delete this
if (!xc_cap_check(ctx->xch, *domid, 2, &caps[1])) {
list[0] = caps[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);
......@@ -670,12 +645,6 @@ retry_transaction:
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);
}
// delete this
if (!xc_cap_check(ctx->xch, *domid, 2, &caps[1])) {
list[0] = caps[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);
}
#endif
if (!xs_transaction_end(ctx->xsh, t, 0)) {
if (errno == EAGAIN) {
......
......@@ -166,12 +166,6 @@ retry_transaction:
if (xc_cap_grant(ctx->xch, device->domid, 2, &list, 1))
LOG(DEBUG, "Granting caps for %s failed\n",frontend_child);
}
//delete this
if (!xc_cap_check(ctx->xch, device->domid, 2, &caps[1])) {
list[0] = caps[1];
if (xc_cap_grant(ctx->xch, device->domid, 2, &list, 1))
LOG(DEBUG, "Granting caps for %s failed\n",frontend_child);
}
#endif
#ifdef CONFIG_XENCAP
libxl__xs_writev(gc, t, frontend_path, fents, device->domid, 'b');
......@@ -196,12 +190,6 @@ retry_transaction:
if (xc_cap_grant(ctx->xch, device->domid, 2, &list, 1))
LOG(DEBUG, "Granting caps for %s/frontend failed\n",backend_path);
}
// delete this
if (!xc_cap_check(ctx->xch, device->domid, 2, &caps[1])) {
list[0] = caps[1];
if (xc_cap_grant(ctx->xch, device->domid, 2, &list, 1))
LOG(DEBUG, "Granting caps for %s/frontend failed\n",backend_path);
}
#endif
#ifdef CONFIG_XENCAP
libxl__xs_writev(gc, t, backend_path, bents, device->domid, 'b');
......
......@@ -309,7 +309,7 @@ int libxl__build_post(libxl__gc *gc, uint32_t domid,
libxl_cpuid_apply_policy(ctx, domid);
if (info->cpuid != NULL)
libxl_cpuid_set(ctx, domid, info->cpuid);
ents = libxl__calloc(gc, 12 + (info->max_vcpus * 2) + 2, sizeof(char *));
ents[0] = "memory/static-max";
ents[1] = libxl__sprintf(gc, "%"PRId64, info->max_memkb);
......
......@@ -222,12 +222,6 @@ retry_transaction:
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s/state-%d failed\n",be_path, i);
}
// delete this
if (!xc_cap_check(ctx->xch, domid, 2, &caps[1])) {
list[0] = caps[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)
......@@ -237,12 +231,6 @@ retry_transaction:
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s/state failed\n",be_path);
}
// delete this
if (!xc_cap_check(ctx->xch, domid, 2, &caps[1])) {
list[0] = caps[1];
if (xc_cap_grant(ctx->xch, domid, 2, &list, 1))
LOG(ERROR, "Granting caps for %s/state failed\n",be_path);
}
#endif
if (!xs_transaction_end(ctx->xsh, t, 0))
if (errno == EAGAIN)
......
......@@ -477,7 +477,8 @@ static bool write_node(struct connection *conn, const struct node *node)
key.dptr = (void *)node->name;
key.dsize = strlen(node->name);
log("write_node: node.name %s\n",node->name);
data.dsize = 6*sizeof(uint32_t)
+ node->num_perms*sizeof(node->perms[0])
+ node->num_caps*sizeof(node->caps[0])
......@@ -597,8 +598,8 @@ static int caps_for_conn(struct connection *conn,
return success for now.
*/
log("caps_for_conn (conn:%p,domid:%d,perm:%d) WARRNING:return the default capability\n", conn, domid, perm);
ret = 0;
log("caps_for_conn (conn:%p,domid:%d,perm:%d) WARRNING:return the default capability\n", conn, domid, perm);
ret = 1;
}
xc_interface_close(xch);
......@@ -657,7 +658,7 @@ static enum xs_perm_type ask_parents(struct connection *conn, const char *name)
#ifdef CONFIG_XENCAP
if ( conn != NULL && conn->cap_flag ) {
trace("ask_parents: caps_for_conn: (conn:%p) name %s\n", conn, name);
//trace("ask_parents: caps_for_conn: (conn:%p) name %s\n", conn, name);
if (caps_for_conn(conn, node->caps, XS_PERM_READ, (char*) name))
xs_perms = XS_PERM_READ;
if (caps_for_conn(conn, node->caps, XS_PERM_WRITE,(char *) name))
......@@ -1635,9 +1636,6 @@ static void do_rm(struct connection *conn, const char *name)
name = canonicalize(conn, name);
node = get_node(conn, name, XS_PERM_WRITE);
if (!node) {
#ifdef CONFIG_XENCAP
log("do_rm: did not get node: %s\n",name);
#endif
/* Didn't exist already? Fine, if parent exists. */
if (errno == ENOENT) {
node = read_node(conn, get_parent(name));
......@@ -1645,9 +1643,6 @@ static void do_rm(struct connection *conn, const char *name)
send_ack(conn, XS_RM);
return;
}
#ifdef CONFIG_XENCAP
log("do_rm: even parent does not exist for %s\n",name);
#endif
/* Restore errno, just in case. */
errno = ENOENT;
}
......
......@@ -68,7 +68,6 @@ static void add_event(struct connection *conn,
* But this breaks device-channel teardown!
* Really we should fix this better...
*/
xprintf("add_event: got back node %p for %s\n",node,name);
if (!node && errno != ENOENT && errno != EACCES)
return;
}
......@@ -134,7 +133,6 @@ void do_watch(struct connection *conn, struct buffered_data *in)
} else {
relative = !strstarts(vec[0], "/");
vec[0] = canonicalize(conn, vec[0]);
xprintf("do_watch: watching node %s\n",vec[0]);
if (!is_valid_nodename(vec[0])) {
send_error(conn, EINVAL);
return;
......
......@@ -152,6 +152,12 @@ int cap_create(struct capability *cap)
struct domain *d = current->domain;
init_rand(41);
if (d->cap_flag == 0)
{
TT_DBG("Domain %d not in capability mode!\n",current->domain->domain_id);
return 0;
}
if ( d->cap_space != NULL )
num_caps = d->cap_space->num_caps;
else
......@@ -197,6 +203,12 @@ int cap_check(struct domain *d, int type, struct capability *cap)
if ( d->domain_id < 0 || d->domain_id > 100 )
return 1;
if (d->cap_flag == 0)
{
TT_DBG("Domain %d not in capability mode!\n",d->domain_id);
return ret;
}
switch(type)
{
......@@ -234,6 +246,12 @@ int cap_grant(struct domain *to, int type, void *list, int size)
int *ptr = NULL;
struct capability *cap_ptr = NULL;
if (to->cap_flag == 0)
{
TT_DBG("Domain %d not in capability mode!\n",to->domain_id);
return 0;
}
if ( type == 1 )
ptr = (int*)list;
if ( type == 2 )
......
......@@ -61,6 +61,7 @@ bool_t pci_known_segment(u16 seg)
static struct pci_seg *alloc_pseg(u16 seg)
{
struct pci_seg *pseg = get_pseg(seg);
TT_DBG("Entered\n");
if ( pseg )
return pseg;
......@@ -87,6 +88,7 @@ static int pci_segments_iterate(
{
u16 seg = 0;
int rc = 0;
TT_DBG("Entered\n");
do {
struct pci_seg *pseg;
......@@ -101,7 +103,7 @@ static int pci_segments_iterate(
}
void __init pt_pci_init(void)
{
{ TT_DBG("Entered\n");
radix_tree_init(&pci_segments);
if ( !alloc_pseg(0) )
panic("Could not initialize PCI segment 0\n");
......@@ -180,7 +182,7 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg, u8 bus, u8 devfn)
}
static void free_pdev(struct pci_seg *pseg, struct pci_dev *pdev)
{
{ TT_DBG("Entered\n");
/* update bus2bridge */
switch ( pdev_type(pseg->nr, pdev->bus, pdev->devfn) )
{
......@@ -207,7 +209,7 @@ static void free_pdev(struct pci_seg *pseg, struct pci_dev *pdev)
}
static void _pci_hide_device(struct pci_dev *pdev)
{
{ TT_DBG("Entered\n");
if ( pdev->domain )
return;
pdev->domain = dom_xen;
......@@ -218,6 +220,7 @@ int __init pci_hide_device(int bus, int devfn)
{
struct pci_dev *pdev;
int rc = -ENOMEM;
TT_DBG("Entered\n");
spin_lock(&pcidevs_lock);
pdev = alloc_pdev(get_pseg(0), bus, devfn);
......@@ -235,6 +238,7 @@ int __init pci_ro_device(int seg, int bus, int devfn)
{
struct pci_seg *pseg = alloc_pseg(seg);
struct pci_dev *pdev;
TT_DBG("Entered\n");
if ( !pseg )
return -ENOMEM;
......@@ -263,6 +267,7 @@ struct pci_dev *pci_get_pdev(int seg, int bus, int devfn)
{
struct pci_seg *pseg = get_pseg(seg);
struct pci_dev *pdev = NULL;
TT_DBG("Entered\n");
ASSERT(spin_is_locked(&pcidevs_lock));
ASSERT(seg != -1 || bus == -1);
......@@ -292,6 +297,7 @@ struct pci_dev *pci_get_pdev_by_domain(
{
struct pci_seg *pseg = get_pseg(seg);
struct pci_dev *pdev = NULL;
TT_DBG("Entered\n");
ASSERT(seg != -1 || bus == -1);
ASSERT(bus != -1 || devfn == -1);
......@@ -327,6 +333,7 @@ static void pci_enable_acs(struct pci_dev *pdev)
u8 bus = pdev->bus;
u8 dev = PCI_SLOT(pdev->devfn);
u8 func = PCI_FUNC(pdev->devfn);
TT_DBG("Entered\n");
if ( !iommu_enabled )
return;
......@@ -360,6 +367,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, const struct pci_dev_info *info)
unsigned int slot = PCI_SLOT(devfn), func = PCI_FUNC(devfn);
const char *pdev_type;
int ret;
TT_DBG("Entered\n");
if (!info)
pdev_type = "device";
......@@ -527,6 +535,7 @@ static int pci_clean_dpci_irq(struct domain *d,
struct hvm_pirq_dpci *pirq_dpci, void *arg)
{
struct dev_intx_gsi_link *digl, *tmp;
TT_DBG("Entered\n");
pirq_guest_unbind(d, dpci_pirq(pirq_dpci));
......@@ -545,6 +554,7 @@ static int pci_clean_dpci_irq(struct domain *d,
static void pci_clean_dpci_irqs(struct domain *d)
{
struct hvm_irq_dpci *hvm_irq_dpci = NULL;
TT_DBG("Entered\n");
if ( !iommu_enabled )
return;
......@@ -570,6 +580,7 @@ void pci_release_devices(struct domain *d)
{
struct pci_dev *pdev;
u8 bus, devfn;
TT_DBG("Entered\n");
spin_lock(&pcidevs_lock);
pci_clean_dpci_irqs(d);
......@@ -628,6 +639,7 @@ int find_upstream_bridge(u16 seg, u8 *bus, u8 *devfn, u8 *secbus)
struct pci_seg *pseg = get_pseg(seg);
int ret = 0;
int cnt = 0;
TT_DBG("Entered\n");
if ( *bus == 0 )
return 0;
......@@ -663,6 +675,7 @@ out:
int __init pci_device_detect(u16 seg, u8 bus, u8 dev, u8 func)
{
u32 vendor;
TT_DBG("Entered\n");
vendor = pci_conf_read32(seg, bus, dev, func, PCI_VENDOR_ID);
/* some broken boards return 0 or ~0 if a slot is empty: */
......@@ -680,6 +693,7 @@ static int __init _scan_pci_devices(struct pci_seg *pseg, void *arg)
{
struct pci_dev *pdev;
int bus, dev, func;
TT_DBG("Entered\n");
for ( bus = 0; bus < 256; bus++ )
{
......@@ -714,6 +728,7 @@ static int __init _scan_pci_devices(struct pci_seg *pseg, void *arg)
int __init scan_pci_devices(void)
{
int ret;
TT_DBG("Entered\n");
spin_lock(&pcidevs_lock);
ret = pci_segments_iterate(_scan_pci_devices, NULL);
......@@ -731,6 +746,7 @@ static int __init _setup_dom0_pci_devices(struct pci_seg *pseg, void *arg)
{
struct setup_dom0 *ctxt = arg;
int bus, devfn;
TT_DBG("Entered\n");
for ( bus = 0; bus < 256; bus++ )
{
......@@ -768,6 +784,8 @@ void __init setup_dom0_pci_devices(
{
struct setup_dom0 ctxt = { .d = d, .handler = handler };
TT_DBG("Entered\n");
spin_lock(&pcidevs_lock);
pci_segments_iterate(_setup_dom0_pci_devices, &ctxt);
spin_unlock(&pcidevs_lock);
......
......@@ -43,16 +43,16 @@ enum xsd_sockmsg_type
XS_MKDIR,
XS_RM,
XS_SET_PERMS,
#ifdef CONFIG_XENCAP
XS_GET_CAPS,
#endif
XS_WATCH_EVENT,
XS_ERROR,
XS_IS_DOMAIN_INTRODUCED,
XS_RESUME,
XS_SET_TARGET,
XS_RESTRICT,
XS_RESET_WATCHES
XS_RESET_WATCHES,
#ifdef CONFIG_XENCAP
XS_GET_CAPS
#endif
};
#define XS_WRITE_NONE "NONE"
......
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