Commit a528c66c authored by Yathindra Naik's avatar Yathindra Naik

Changed xsm_cap hooks to refer to current->domain.

parent 8d4b6557
......@@ -167,6 +167,7 @@ CFLAGS += -Wall -Wstrict-prototypes
#
CFLAGS += -DCONFIG_XENCAP
CONFIG_XENCAP ?= y
CAP_DEBUG ?= y
# Clang complains about macros that expand to 'if ( ( foo == bar ) ) ...'
# and is over-zealous with the printf format lint
......
......@@ -882,7 +882,11 @@ int libxl_domain_setcap(libxl_ctx *ctx, libxl_capabilities *info, uint32_t domid
*/
char *tok;
int size = 0;
int list[64] = {-1};
int list[100];
int i;
for ( i = 0; i < 100; ++i )
list[i] = -1;
printf ("Splitting string \"%s\" into tokens:\n",info->cap_values);
tok = strtok (info->cap_values," ,.-");
......@@ -891,89 +895,145 @@ int libxl_domain_setcap(libxl_ctx *ctx, libxl_capabilities *info, uint32_t domid
{
printf ("%s\n",tok);
if ( strncmp(tok,"memory_pin_page",strlen("memory_pin_page")) == 0 )
list[1] = 1;
list[size] = 1;
if ( strncmp(tok,"security_domaininfo",strlen("security_domaininfo")) == 0 )
list[2] = 2;
list[size] = 2;
if ( strncmp(tok,"setvcpucontext",strlen("setvcpucontext")) == 0 )
list[3] = 3;
list[size] = 3;
if ( strncmp(tok,"pausedomain",strlen("pausedomain")) == 0 )
list[4] = 4;
list[size] = 4;
if ( strncmp(tok,"unpausedomain",strlen("unpausedomain")) == 0 )
list[5] = 5;
list[size] = 5;
if ( strncmp(tok,"resumedomain",strlen("resumedomain")) == 0 )
list[6] = 6;
list[size] = 6;
if ( strncmp(tok,"max_vcpus",strlen("max_vcpus")) == 0)
list[7] = 7;
list[size] = 7;
if ( strncmp(tok,"destroydomain",strlen("destroydomain")) == 0 )
list[8] = 8;
list[size] = 8;
if ( strncmp(tok,"vcpuaffinity",strlen("vcpuaffinity")) == 0 )
list[9] = 9;
list[size] = 9;
if ( strncmp(tok,"scheduler",strlen("schedule")) == 0)
list[10] = 10;
list[size] = 10;
if ( strncmp(tok,"getdomaininfo",strlen("getdomaininfo")) == 0 )
list[11] = 11;
list[size] = 11;
if ( strncmp(tok,"getvcpucontext",strlen("getvcpucontext")) == 0 )
list[12] = 12;
list[size] = 12;
if ( strncmp(tok,"getvcpuinfo",strlen("getvcpuinfo")) == 0 )
list[13] = 13;
list[size] = 13;
if ( strncmp(tok,"domain_settime",strlen("domain_settime")) == 0 )
list[14] = 14;
list[size] = 14;
if ( strncmp(tok,"set_target",strlen("set_target")) == 0 )
list[15] = 15;
list[size] = 15;
if ( strncmp(tok,"domctl",strlen("domctl")) == 0 )
list[16] = 16;
list[size] = 16;
if ( strncmp(tok,"set_virq_handler",strlen("set_virq_handler")) == 0 )
list[17] = 17;
list[size] = 17;
if ( strncmp(tok,"tbufcontrol",strlen("tbufcontrol")) == 0 )
list[size] = 18;
if ( strncmp(tok,"readconsole",strlen("readconsole")) == 0 )
list[size] = 19;
if ( strncmp(tok,"cap_sched_id",strlen("cap_sched_id")) == 0 )
list[size] = 20;
if ( strncmp(tok,"setdomainmaxmem",strlen("setdomainmaxmem")) == 0 )
list[21] = 21;
list[size] = 21;
if ( strncmp(tok,"setdomainhandle",strlen("setdomainhandle")) == 0 )
list[22] = 22;
list[size] = 22;
if ( strncmp(tok,"setdebugging",strlen("setdebugging")) == 0 )
list[23] = 23;
list[size] = 23;
if ( strncmp(tok,"perfcontrol",strlen("perfcontrol")) == 0 )
list[size] = 24;
if ( strncmp(tok,"debug_keys",strlen("debug_keys")) == 0 )
list[size] = 25;
if ( strncmp(tok,"getcpuinfo",strlen("getcpuinfo")) == 0 )
list[size] = 26;
if ( strncmp(tok,"get_pmstat",strlen("get_pmstat")) == 0 )
list[size] = 27;
if ( strncmp(tok,"setpminfo",strlen("setpminfo")) == 0 )
list[size] = 28;
if ( strncmp(tok,"pm_op",strlen("pm_op")) == 0 )
list[size] = 29;
if ( strncmp(tok,"do_mca",strlen("do_mca")) == 0 )
list[size] = 30;
if ( strncmp(tok,"availheap",strlen("availheap")) == 0 )
list[size] = 31;
if ( strncmp(tok,"kexec",strlen("kexec")) == 0 )
list[size] = 33;
if ( strncmp(tok,"evtchn_close_post",strlen("evtchn_close_post")) == 0 )
list[size] = 34;
if ( strncmp(tok,"grant_mapref",strlen("grant_mapref")) == 0 )
list[35] = 35;
list[size] = 35;
if ( strncmp(tok,"grant_unmapref",strlen("grant_unmapref")) == 0 )
list[36] = 36;
list[size] = 36;
if ( strncmp(tok,"grant_setup",strlen("grant_setup")) == 0 )
list[37] = 37;
list[size] = 37;
if ( strncmp(tok,"grant_transfer",strlen("grant_transfer")) == 0 )
list[38] = 38;
list[size] = 38;
if ( strncmp(tok,"grant_copy",strlen("grant_copy")) == 0 )
list[39] = 39;
list[size] = 39;
if ( strncmp(tok,"grant_query_size",strlen("grant_query_size")) == 0 )
list[40] = 40;
list[size] = 40;
if ( strncmp(tok,"memory_adjust_reservation",strlen("memory_adjust_reservation")) == 0 )
list[41] = 41;
list[size] = 41;
if ( strncmp(tok,"memory_stat_reservation",strlen("memory_stat_reservation")) == 0 )
list[42] = 42;
list[size] = 42;
if ( strncmp(tok,"console_io",strlen("console_io")) == 0 )
list[43] = 43;
list[size] = 43;
if( strncmp(tok, "profile",strlen("profile")) == 0 )
list[44] = 44;
list[size] = 44;
if ( strncmp(tok,"schedop_shutdown",strlen("schedop_shutdown")) == 0 )
list[45] = 45;
list[size] = 45;
if( strncmp(tok,"evtchn_unbound",strlen("evtchn_unbound")) == 0 )
list[46] = 46;
list[size] = 46;
if ( strncmp(tok,"evtchn_interdomain",strlen("evtchn_interdomain")) == 0 )
list[47] = 47;
list[size] = 47;
if ( strncmp(tok,"evtchn_send",strlen("evtchn_send")) == 0 )
list[48] = 48;
list[size] = 48;
if ( strncmp(tok,"evtchn_status",strlen("evtchn_status")) == 0 )
list[49] = 49;
list[size] = 49;
if ( strncmp(tok,"evtchn_reset",strlen("evtchn_reset")) == 0 )
list[50] = 50;
list[size] = 50;
if ( strncmp(tok,"alloc_security_evtchn",strlen("alloc_security_evtchn")) == 0 )
list[size] = 51;
if ( strncmp(tok,"free_security_evtchn",strlen("free_security_evtchn")) == 0 )
list[size] = 52;
if ( strncmp(tok,"show_security_evtchn",strlen("show_security_evtchn")) == 0 )
list[size] = 53;
if ( strncmp(tok,"get_pod_target",strlen("get_pod_target")) == 0 )
list[52] = 52;
list[size] = 54;
if ( strncmp(tok,"set_pod_target",strlen("set_pod_target")) == 0 )
list[53] = 53;
list[size] = 55;
if ( strncmp(tok,"resource_plug_core",strlen("resource_plug_core")) == 0 )
list[size] = 56;
if ( strncmp(tok,"resource_unplug_core",strlen("resource_unplug_core")) == 0 )
list[size] = 57;
if ( strncmp(tok,"resource_plug_pci",strlen("resource_plug_pci")) == 0 )
list[size] = 58;
if ( strncmp(tok,"resource_unplug_pci",strlen("resource_unplug_pci")) == 0 )
list[size] = 59;
if ( strncmp(tok,"resource_setup_pci",strlen("resource_setup_pci")) == 0 )
list[size] = 60;
if ( strncmp(tok,"resource_setup_gsi",strlen("resource_setup_gsi")) == 0 )
list[size] = 61;
if ( strncmp(tok,"resource_setup_misc",strlen("resource_setup_misc")) == 0 )
list[size] = 62;
if ( strncmp(tok,"page_offline",strlen("page_offline")) == 0 )
list[size] = 63;
if ( strncmp(tok,"lockprof",strlen("lockprof")) == 0 )
list[size] = 64;
if ( strncmp(tok,"cpupool_op",strlen("cpupool_op")) == 0 )
list[size] = 65;
if ( strncmp(tok,"sched_op",strlen("sched_op")) == 0 )
list[size] = 66;
if ( strncmp(tok,"show_irq_sid",strlen("show_irq_show")) == 0 )
list[size] = 67;
if ( strncmp(tok,"map_domain_pirq",strlen("map_domain_pirq")) == 0 )
list[54] = 54;
list[size] = 68;
if ( strncmp(tok,"irq_permission",strlen("irq_permission")) == 0 )
list[55] = 55;
list[size] = 69;
if ( strncmp(tok,"iomem_permission",strlen("iomem_permission")) == 0 )
list[56] = 56;
list[size] = 70;
if ( strncmp(tok,"pci_config_permission",strlen("pci_config_permission")) == 0 )
list[57] = 57;
list[size] = 71;
++size;
tok = strtok (NULL, " ,.-");
......
......@@ -159,17 +159,10 @@ int cap_grant(struct domain *from, struct domain *to, int type, void *list, int
int *ptr = (int*)list;
TT_DBG("In cap_grant()\n");
printk("from domain: 0x%p\n",from);
printk("to domain: 0x%p\n",to);
if(from == NULL || to == NULL)
return 1;
if(from->cap_space)
printk("from->cap_space: 0x%p\n",from->cap_space);
if(to->cap_space)
printk("to->cap_space: 0x%p\n",to->cap_space);
switch(type)
{
case 1:
......@@ -178,6 +171,7 @@ int cap_grant(struct domain *from, struct domain *to, int type, void *list, int
{
index = ptr[i];
printk("cap_grant: index=%d, i=%d\n",index,i);
if(index == -1)
continue;
to->cap_space->cap_hypercalls[index] = from->cap_space->cap_hypercalls[index];
......@@ -194,11 +188,15 @@ int cap_check(struct domain *d, int type, struct capability *cap)
int i;
int ret = 0;
if ( d->domain_id != 0 )
{
TT_DBG("In cap_check()\n");
TT_DBG("Checking Capability: Domain %d, Cap_id: 0x%x\n",d->domain_id, cap->magic);
}
if ( IS_PRIV(d) )
return 1;
if ( d->domain_id < 0 || d->domain_id > 100 )
return 1;
// TT_DBG("In cap_check()\n");
// TT_DBG("Checking Capability: Domain %d, Cap_id: 0x%x\n",d->domain_id, cap->magic);
switch(type)
{
case 1:
......
......@@ -10,8 +10,8 @@
#ifndef __XEN_CAP_H__
#define __XEN_CAP_H__
#include <xen/sched.h>
#include <xen/lib.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
......@@ -19,9 +19,10 @@
*/
#define PHI 0x9e3779b9
#define NUM_HYPERCALLS 65
#define NUM_HYPERCALLS 100
#define SEED 41 /* initial seed valure for RNG */
extern int cap_debug;
/* This is a simple structure for capabilities. */
/* It is on a list for now. Later I'll consider a more efficient structure. */
......@@ -30,7 +31,7 @@ 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 list_head cap_list;
};
struct cap_boot_info
......
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