This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / xen / interface / acm.h
1 /*
2  * acm.h: Xen access control module interface defintions
3  *
4  * Reiner Sailer <sailer@watson.ibm.com>
5  * Copyright (c) 2005, International Business Machines Corporation.
6  */
7
8 #ifndef _XEN_PUBLIC_ACM_H
9 #define _XEN_PUBLIC_ACM_H
10
11 #include "xen.h"
12 #include "sched_ctl.h"
13
14 /* if ACM_DEBUG defined, all hooks should
15  * print a short trace message (comment it out
16  * when not in testing mode )
17  */
18 /* #define ACM_DEBUG */
19
20 #ifdef ACM_DEBUG
21 #  define printkd(fmt, args...) printk(fmt,## args)
22 #else
23 #  define printkd(fmt, args...)
24 #endif
25
26 /* default ssid reference value if not supplied */
27 #define ACM_DEFAULT_SSID  0x0
28 #define ACM_DEFAULT_LOCAL_SSID  0x0
29
30 /* Internal ACM ERROR types */
31 #define ACM_OK     0
32 #define ACM_UNDEF   -1
33 #define ACM_INIT_SSID_ERROR  -2
34 #define ACM_INIT_SOID_ERROR  -3
35 #define ACM_ERROR          -4
36
37 /* External ACCESS DECISIONS */
38 #define ACM_ACCESS_PERMITTED        0
39 #define ACM_ACCESS_DENIED           -111
40 #define ACM_NULL_POINTER_ERROR      -200
41
42 /* primary policy in lower 4 bits */
43 #define ACM_NULL_POLICY 0
44 #define ACM_CHINESE_WALL_POLICY 1
45 #define ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY 2
46 #define ACM_POLICY_UNDEFINED 15
47
48 /* combinations have secondary policy component in higher 4bit */
49 #define ACM_CHINESE_WALL_AND_SIMPLE_TYPE_ENFORCEMENT_POLICY \
50     ((ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY << 4) | ACM_CHINESE_WALL_POLICY)
51
52 /* policy: */
53 #define ACM_POLICY_NAME(X) \
54  ((X) == (ACM_NULL_POLICY)) ? "NULL" :                        \
55     ((X) == (ACM_CHINESE_WALL_POLICY)) ? "CHINESE WALL" :        \
56     ((X) == (ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY)) ? "SIMPLE TYPE ENFORCEMENT" : \
57     ((X) == (ACM_CHINESE_WALL_AND_SIMPLE_TYPE_ENFORCEMENT_POLICY)) ? "CHINESE WALL AND SIMPLE TYPE ENFORCEMENT" : \
58      "UNDEFINED"
59
60 /* the following policy versions must be increased
61  * whenever the interpretation of the related
62  * policy's data structure changes
63  */
64 #define ACM_POLICY_VERSION 2
65 #define ACM_CHWALL_VERSION 1
66 #define ACM_STE_VERSION  1
67
68 /* defines a ssid reference used by xen */
69 typedef uint32_t ssidref_t;
70
71 /* hooks that are known to domains */
72 #define ACMHOOK_none    0
73 #define ACMHOOK_sharing 1
74
75 /* -------security policy relevant type definitions-------- */
76
77 /* type identifier; compares to "equal" or "not equal" */
78 typedef uint16_t domaintype_t;
79
80 /* CHINESE WALL POLICY DATA STRUCTURES
81  *
82  * current accumulated conflict type set:
83  * When a domain is started and has a type that is in
84  * a conflict set, the conflicting types are incremented in
85  * the aggregate set. When a domain is destroyed, the 
86  * conflicting types to its type are decremented.
87  * If a domain has multiple types, this procedure works over
88  * all those types.
89  *
90  * conflict_aggregate_set[i] holds the number of
91  *   running domains that have a conflict with type i.
92  *
93  * running_types[i] holds the number of running domains
94  *        that include type i in their ssidref-referenced type set
95  *
96  * conflict_sets[i][j] is "0" if type j has no conflict
97  *    with type i and is "1" otherwise.
98  */
99 /* high-16 = version, low-16 = check magic */
100 #define ACM_MAGIC  0x0001debc
101
102 /* each offset in bytes from start of the struct they
103  * are part of */
104
105 /* each buffer consists of all policy information for
106  * the respective policy given in the policy code
107  *
108  * acm_policy_buffer, acm_chwall_policy_buffer,
109  * and acm_ste_policy_buffer need to stay 32-bit aligned
110  * because we create binary policies also with external
111  * tools that assume packed representations (e.g. the java tool)
112  */
113 struct acm_policy_buffer {
114     uint32_t policy_version; /* ACM_POLICY_VERSION */
115     uint32_t magic;
116     uint32_t len;
117     uint32_t policy_reference_offset;
118     uint32_t primary_policy_code;
119     uint32_t primary_buffer_offset;
120     uint32_t secondary_policy_code;
121     uint32_t secondary_buffer_offset;
122 };
123
124 struct acm_policy_reference_buffer {
125     uint32_t len;
126 };
127
128 struct acm_chwall_policy_buffer {
129     uint32_t policy_version; /* ACM_CHWALL_VERSION */
130     uint32_t policy_code;
131     uint32_t chwall_max_types;
132     uint32_t chwall_max_ssidrefs;
133     uint32_t chwall_max_conflictsets;
134     uint32_t chwall_ssid_offset;
135     uint32_t chwall_conflict_sets_offset;
136     uint32_t chwall_running_types_offset;
137     uint32_t chwall_conflict_aggregate_offset;
138 };
139
140 struct acm_ste_policy_buffer {
141     uint32_t policy_version; /* ACM_STE_VERSION */
142     uint32_t policy_code;
143     uint32_t ste_max_types;
144     uint32_t ste_max_ssidrefs;
145     uint32_t ste_ssid_offset;
146 };
147
148 struct acm_stats_buffer {
149     uint32_t magic;
150     uint32_t len;
151     uint32_t primary_policy_code;
152     uint32_t primary_stats_offset;
153     uint32_t secondary_policy_code;
154     uint32_t secondary_stats_offset;
155 };
156
157 struct acm_ste_stats_buffer {
158     uint32_t ec_eval_count;
159     uint32_t gt_eval_count;
160     uint32_t ec_denied_count;
161     uint32_t gt_denied_count;
162     uint32_t ec_cachehit_count;
163     uint32_t gt_cachehit_count;
164 };
165
166 struct acm_ssid_buffer {
167     uint32_t len;
168     ssidref_t ssidref;
169     uint32_t policy_reference_offset;
170     uint32_t primary_policy_code;
171     uint32_t primary_max_types;
172     uint32_t primary_types_offset;
173     uint32_t secondary_policy_code;
174     uint32_t secondary_max_types;
175     uint32_t secondary_types_offset;
176 };
177
178 #endif
179
180 /*
181  * Local variables:
182  * mode: C
183  * c-set-style: "BSD"
184  * c-basic-offset: 4
185  * tab-width: 4
186  * indent-tabs-mode: nil
187  * End:
188  */