~ubuntu-branches/ubuntu/intrepid/xen-3.3/intrepid-updates

« back to all changes in this revision

Viewing changes to xen/include/xsm/xsm.h

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2008-08-14 10:28:57 UTC
  • Revision ID: james.westby@ubuntu.com-20080814102857-a832fn5gowurz5do
Tags: upstream-3.3.0
ImportĀ upstreamĀ versionĀ 3.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  This file contains the XSM hook definitions for Xen.
 
3
 *
 
4
 *  This work is based on the LSM implementation in Linux 2.6.13.4.
 
5
 *
 
6
 *  Author:  George Coker, <gscoker@alpha.ncsc.mil>
 
7
 *
 
8
 *  Contributors: Michael LeMay, <mdlemay@epoch.ncsc.mil>
 
9
 *
 
10
 *  This program is free software; you can redistribute it and/or modify
 
11
 *  it under the terms of the GNU General Public License version 2,
 
12
 *  as published by the Free Software Foundation.
 
13
 */
 
14
 
 
15
#ifndef __XSM_H__
 
16
#define __XSM_H__
 
17
 
 
18
#include <xen/sched.h>
 
19
#include <xen/multiboot.h>
 
20
 
 
21
typedef void xsm_op_t;
 
22
DEFINE_XEN_GUEST_HANDLE(xsm_op_t);
 
23
 
 
24
extern long do_xsm_op (XEN_GUEST_HANDLE(xsm_op_t) op);
 
25
 
 
26
#ifdef XSM_ENABLE
 
27
    #define xsm_call(fn) xsm_ops->fn
 
28
#else
 
29
    #define xsm_call(fn) 0
 
30
#endif
 
31
 
 
32
/* policy magic number (defined by XSM_MAGIC) */
 
33
typedef u32 xsm_magic_t;
 
34
#ifndef XSM_MAGIC
 
35
#define XSM_MAGIC 0x00000000
 
36
#endif
 
37
 
 
38
#ifdef XSM_ENABLE
 
39
 
 
40
extern char *policy_buffer;
 
41
extern u32 policy_size;
 
42
 
 
43
typedef int (*xsm_initcall_t)(void);
 
44
 
 
45
extern xsm_initcall_t __xsm_initcall_start[], __xsm_initcall_end[];
 
46
 
 
47
#define xsm_initcall(fn) \
 
48
    static xsm_initcall_t __initcall_##fn \
 
49
    __attribute_used__ __attribute__((__section__(".xsm_initcall.init"))) = fn
 
50
 
 
51
struct xsm_operations {
 
52
    void (*security_domaininfo) (struct domain *d,
 
53
                                        struct xen_domctl_getdomaininfo *info);
 
54
    int (*setvcpucontext) (struct domain *d);
 
55
    int (*pausedomain) (struct domain *d);
 
56
    int (*unpausedomain) (struct domain *d);
 
57
    int (*resumedomain) (struct domain *d);
 
58
    int (*domain_create) (struct domain *d, u32 ssidref);
 
59
    int (*max_vcpus) (struct domain *d);
 
60
    int (*destroydomain) (struct domain *d);
 
61
    int (*vcpuaffinity) (int cmd, struct domain *d);
 
62
    int (*scheduler) (struct domain *d);
 
63
    int (*getdomaininfo) (struct domain *d);
 
64
    int (*getvcpucontext) (struct domain *d);
 
65
    int (*getvcpuinfo) (struct domain *d);
 
66
    int (*domain_settime) (struct domain *d);
 
67
    int (*tbufcontrol) (void);
 
68
    int (*readconsole) (uint32_t clear);
 
69
    int (*sched_id) (void);
 
70
    int (*setdomainmaxmem) (struct domain *d);
 
71
    int (*setdomainhandle) (struct domain *d);
 
72
    int (*setdebugging) (struct domain *d);
 
73
    int (*irq_permission) (struct domain *d, uint8_t pirq, uint8_t access);
 
74
    int (*iomem_permission) (struct domain *d, unsigned long mfn, 
 
75
                                                                uint8_t access);
 
76
    int (*perfcontrol) (void);
 
77
 
 
78
    int (*evtchn_unbound) (struct domain *d, struct evtchn *chn, domid_t id2);
 
79
    int (*evtchn_interdomain) (struct domain *d1, struct evtchn *chn1,
 
80
                                        struct domain *d2, struct evtchn *chn2);
 
81
    void (*evtchn_close_post) (struct evtchn *chn);
 
82
    int (*evtchn_send) (struct domain *d, struct evtchn *chn);
 
83
    int (*evtchn_status) (struct domain *d, struct evtchn *chn);
 
84
    int (*evtchn_reset) (struct domain *d1, struct domain *d2);
 
85
 
 
86
    int (*grant_mapref) (struct domain *d1, struct domain *d2, uint32_t flags);
 
87
    int (*grant_unmapref) (struct domain *d1, struct domain *d2);
 
88
    int (*grant_setup) (struct domain *d1, struct domain *d2);
 
89
    int (*grant_transfer) (struct domain *d1, struct domain *d2);
 
90
    int (*grant_copy) (struct domain *d1, struct domain *d2);
 
91
    int (*grant_query_size) (struct domain *d1, struct domain *d2);
 
92
 
 
93
    int (*alloc_security_domain) (struct domain *d);
 
94
    void (*free_security_domain) (struct domain *d);
 
95
    int (*alloc_security_evtchn) (struct evtchn *chn);
 
96
    void (*free_security_evtchn) (struct evtchn *chn);
 
97
 
 
98
    int (*translate_gpfn_list) (struct domain *d, unsigned long mfn);
 
99
    int (*memory_adjust_reservation) (struct domain *d1, struct domain *d2);
 
100
    int (*memory_stat_reservation) (struct domain *d1, struct domain *d2);
 
101
    int (*memory_pin_page) (struct domain *d, struct page_info *page);
 
102
 
 
103
    int (*console_io) (struct domain *d, int cmd);
 
104
 
 
105
    int (*profile) (struct domain *d, int op);
 
106
 
 
107
    int (*kexec) (void);
 
108
    int (*schedop_shutdown) (struct domain *d1, struct domain *d2);
 
109
 
 
110
    long (*__do_xsm_op) (XEN_GUEST_HANDLE(xsm_op_t) op);
 
111
 
 
112
#ifdef CONFIG_X86
 
113
    int (*shadow_control) (struct domain *d, uint32_t op);
 
114
    int (*ioport_permission) (struct domain *d, uint32_t ioport, 
 
115
                                                                uint8_t access);
 
116
    int (*getpageframeinfo) (struct page_info *page);
 
117
    int (*getmemlist) (struct domain *d);
 
118
    int (*hypercall_init) (struct domain *d);
 
119
    int (*hvmcontext) (struct domain *d, uint32_t op);
 
120
    int (*address_size) (struct domain *d, uint32_t op);
 
121
    int (*machine_address_size) (struct domain *d, uint32_t op);
 
122
    int (*hvm_param) (struct domain *d, unsigned long op);
 
123
    int (*hvm_set_pci_intx_level) (struct domain *d);
 
124
    int (*hvm_set_isa_irq_level) (struct domain *d);
 
125
    int (*hvm_set_pci_link_route) (struct domain *d);
 
126
    int (*apic) (struct domain *d, int cmd);
 
127
    int (*assign_vector) (struct domain *d, uint32_t pirq);
 
128
    int (*xen_settime) (void);
 
129
    int (*memtype) (uint32_t access);
 
130
    int (*microcode) (void);
 
131
    int (*physinfo) (void);
 
132
    int (*platform_quirk) (uint32_t);
 
133
    int (*machine_memory_map) (void);
 
134
    int (*domain_memory_map) (struct domain *d);
 
135
    int (*mmu_normal_update) (struct domain *d, intpte_t fpte);
 
136
    int (*mmu_machphys_update) (struct domain *d, unsigned long mfn);
 
137
    int (*update_va_mapping) (struct domain *d, l1_pgentry_t pte);
 
138
    int (*add_to_physmap) (struct domain *d1, struct domain *d2);
 
139
#endif
 
140
};
 
141
 
 
142
#endif
 
143
 
 
144
extern struct xsm_operations *xsm_ops;
 
145
 
 
146
static inline void xsm_security_domaininfo (struct domain *d,
 
147
                                        struct xen_domctl_getdomaininfo *info)
 
148
{
 
149
    xsm_call(security_domaininfo(d, info));
 
150
}
 
151
 
 
152
static inline int xsm_setvcpucontext(struct domain *d)
 
153
{
 
154
    return xsm_call(setvcpucontext(d));
 
155
}
 
156
 
 
157
static inline int xsm_pausedomain (struct domain *d)
 
158
{
 
159
    return xsm_call(pausedomain(d));
 
160
}
 
161
 
 
162
static inline int xsm_unpausedomain (struct domain *d)
 
163
{
 
164
    return xsm_call(unpausedomain(d));
 
165
}
 
166
 
 
167
static inline int xsm_resumedomain (struct domain *d)
 
168
{
 
169
    return xsm_call(resumedomain(d));
 
170
}
 
171
 
 
172
static inline int xsm_domain_create (struct domain *d, u32 ssidref)
 
173
{
 
174
    return xsm_call(domain_create(d, ssidref));
 
175
}
 
176
 
 
177
static inline int xsm_max_vcpus(struct domain *d)
 
178
{
 
179
    return xsm_call(max_vcpus(d));
 
180
}
 
181
 
 
182
static inline int xsm_destroydomain (struct domain *d)
 
183
{
 
184
    return xsm_call(destroydomain(d));
 
185
}
 
186
 
 
187
static inline int xsm_vcpuaffinity (int cmd, struct domain *d)
 
188
{
 
189
    return xsm_call(vcpuaffinity(cmd, d));
 
190
}
 
191
 
 
192
static inline int xsm_scheduler (struct domain *d)
 
193
{
 
194
    return xsm_call(scheduler(d));
 
195
}
 
196
 
 
197
static inline int xsm_getdomaininfo (struct domain *d)
 
198
{
 
199
    return xsm_call(getdomaininfo(d));
 
200
}
 
201
 
 
202
static inline int xsm_getvcpucontext (struct domain *d)
 
203
{
 
204
    return xsm_call(getvcpucontext(d));
 
205
}
 
206
 
 
207
static inline int xsm_getvcpuinfo (struct domain *d)
 
208
{
 
209
    return xsm_call(getvcpuinfo(d));
 
210
}
 
211
 
 
212
static inline int xsm_domain_settime (struct domain *d)
 
213
{
 
214
    return xsm_call(domain_settime(d));
 
215
}
 
216
 
 
217
static inline int xsm_tbufcontrol (void)
 
218
{
 
219
    return xsm_call(tbufcontrol());
 
220
}
 
221
 
 
222
static inline int xsm_readconsole (uint32_t clear)
 
223
{
 
224
    return xsm_call(readconsole(clear));
 
225
}
 
226
 
 
227
static inline int xsm_sched_id (void)
 
228
{
 
229
    return xsm_call(sched_id());
 
230
}
 
231
 
 
232
static inline int xsm_setdomainmaxmem (struct domain *d)
 
233
{
 
234
    return xsm_call(setdomainmaxmem(d));
 
235
}
 
236
 
 
237
static inline int xsm_setdomainhandle (struct domain *d)
 
238
{
 
239
    return xsm_call(setdomainhandle(d));
 
240
}
 
241
 
 
242
static inline int xsm_setdebugging (struct domain *d)
 
243
{
 
244
    return xsm_call(setdebugging(d));
 
245
}
 
246
 
 
247
static inline int xsm_irq_permission (struct domain *d, uint8_t pirq,
 
248
                                                                uint8_t access)
 
249
{
 
250
    return xsm_call(irq_permission(d, pirq, access));
 
251
 
252
 
 
253
static inline int xsm_iomem_permission (struct domain *d, unsigned long mfn,
 
254
                                                                uint8_t access)
 
255
{
 
256
    return xsm_call(iomem_permission(d, mfn, access));
 
257
}
 
258
 
 
259
static inline int xsm_perfcontrol (void)
 
260
{
 
261
    return xsm_call(perfcontrol());
 
262
}
 
263
 
 
264
static inline int xsm_evtchn_unbound (struct domain *d1, struct evtchn *chn,
 
265
                                                                    domid_t id2)
 
266
{
 
267
    return xsm_call(evtchn_unbound(d1, chn, id2));
 
268
}
 
269
 
 
270
static inline int xsm_evtchn_interdomain (struct domain *d1, 
 
271
                struct evtchn *chan1, struct domain *d2, struct evtchn *chan2)
 
272
{
 
273
    return xsm_call(evtchn_interdomain(d1, chan1, d2, chan2));
 
274
}
 
275
 
 
276
static inline void xsm_evtchn_close_post (struct evtchn *chn)
 
277
{
 
278
    xsm_call(evtchn_close_post(chn));
 
279
}
 
280
 
 
281
static inline int xsm_evtchn_send (struct domain *d, struct evtchn *chn)
 
282
{
 
283
    return xsm_call(evtchn_send(d, chn));
 
284
}
 
285
 
 
286
static inline int xsm_evtchn_status (struct domain *d, struct evtchn *chn)
 
287
{
 
288
    return xsm_call(evtchn_status(d, chn));
 
289
}
 
290
 
 
291
static inline int xsm_evtchn_reset (struct domain *d1, struct domain *d2)
 
292
{
 
293
    return xsm_call(evtchn_reset(d1, d2));
 
294
}
 
295
 
 
296
static inline int xsm_grant_mapref (struct domain *d1, struct domain *d2,
 
297
                                                                uint32_t flags)
 
298
{
 
299
    return xsm_call(grant_mapref(d1, d2, flags));
 
300
}
 
301
 
 
302
static inline int xsm_grant_unmapref (struct domain *d1, struct domain *d2)
 
303
{
 
304
    return xsm_call(grant_unmapref(d1, d2));
 
305
}
 
306
 
 
307
static inline int xsm_grant_setup (struct domain *d1, struct domain *d2)
 
308
{
 
309
    return xsm_call(grant_setup(d1, d2));
 
310
}
 
311
 
 
312
static inline int xsm_grant_transfer (struct domain *d1, struct domain *d2)
 
313
{
 
314
    return xsm_call(grant_transfer(d1, d2));
 
315
}
 
316
 
 
317
static inline int xsm_grant_copy (struct domain *d1, struct domain *d2)
 
318
{
 
319
    return xsm_call(grant_copy(d1, d2));
 
320
}
 
321
 
 
322
static inline int xsm_grant_query_size (struct domain *d1, struct domain *d2)
 
323
{
 
324
    return xsm_call(grant_query_size(d1, d2));
 
325
}
 
326
 
 
327
static inline int xsm_alloc_security_domain (struct domain *d)
 
328
{
 
329
    return xsm_call(alloc_security_domain(d));
 
330
}
 
331
 
 
332
static inline void xsm_free_security_domain (struct domain *d)
 
333
{
 
334
    xsm_call(free_security_domain(d));
 
335
}
 
336
 
 
337
static inline int xsm_alloc_security_evtchn (struct evtchn *chn)
 
338
{
 
339
    return xsm_call(alloc_security_evtchn(chn));
 
340
}
 
341
 
 
342
static inline void xsm_free_security_evtchn (struct evtchn *chn)
 
343
{
 
344
    xsm_call(free_security_evtchn(chn));
 
345
}
 
346
 
 
347
static inline int xsm_translate_gpfn_list (struct domain *d, unsigned long mfn)
 
348
{
 
349
    return xsm_call(translate_gpfn_list(d, mfn));
 
350
}
 
351
 
 
352
static inline int xsm_memory_adjust_reservation (struct domain *d1, struct
 
353
                                                                    domain *d2)
 
354
{
 
355
    return xsm_call(memory_adjust_reservation(d1, d2));
 
356
}
 
357
 
 
358
static inline int xsm_memory_stat_reservation (struct domain *d1,
 
359
                                                            struct domain *d2)
 
360
{
 
361
    return xsm_call(memory_stat_reservation(d1, d2));
 
362
}
 
363
 
 
364
static inline int xsm_memory_pin_page(struct domain *d, struct page_info *page)
 
365
{
 
366
    return xsm_call(memory_pin_page(d, page));
 
367
}
 
368
 
 
369
static inline int xsm_console_io (struct domain *d, int cmd)
 
370
{
 
371
    return xsm_call(console_io(d, cmd));
 
372
}
 
373
 
 
374
static inline int xsm_profile (struct domain *d, int op)
 
375
{
 
376
    return xsm_call(profile(d, op));
 
377
}
 
378
 
 
379
static inline int xsm_kexec (void)
 
380
{
 
381
    return xsm_call(kexec());
 
382
}
 
383
 
 
384
static inline int xsm_schedop_shutdown (struct domain *d1, struct domain *d2)
 
385
{
 
386
    return xsm_call(schedop_shutdown(d1, d2));
 
387
}
 
388
 
 
389
static inline long __do_xsm_op (XEN_GUEST_HANDLE(xsm_op_t) op)
 
390
{
 
391
    return xsm_call(__do_xsm_op(op));
 
392
}
 
393
 
 
394
#ifdef XSM_ENABLE
 
395
extern int xsm_init(unsigned int *initrdidx, const multiboot_info_t *mbi,
 
396
                                          unsigned long initial_images_start);
 
397
extern int xsm_policy_init(unsigned int *initrdidx, const multiboot_info_t *mbi,
 
398
                                           unsigned long initial_images_start);
 
399
extern int register_xsm(struct xsm_operations *ops);
 
400
extern int unregister_xsm(struct xsm_operations *ops);
 
401
#else
 
402
static inline int xsm_init (unsigned int *initrdidx,
 
403
                const multiboot_info_t *mbi, unsigned long initial_images_start)
 
404
{
 
405
    return 0;
 
406
}
 
407
#endif
 
408
 
 
409
#ifdef CONFIG_X86
 
410
static inline int xsm_shadow_control (struct domain *d, uint32_t op)
 
411
{
 
412
    return xsm_call(shadow_control(d, op));
 
413
}
 
414
 
 
415
static inline int xsm_ioport_permission (struct domain *d, uint32_t ioport,
 
416
                                                                uint8_t access)
 
417
{
 
418
    return xsm_call(ioport_permission(d, ioport, access));
 
419
}
 
420
 
 
421
static inline int xsm_getpageframeinfo (struct page_info *page)
 
422
{
 
423
    return xsm_call(getpageframeinfo(page));
 
424
}
 
425
 
 
426
static inline int xsm_getmemlist (struct domain *d)
 
427
{
 
428
    return xsm_call(getmemlist(d));
 
429
}
 
430
 
 
431
static inline int xsm_hypercall_init (struct domain *d)
 
432
{
 
433
    return xsm_call(hypercall_init(d));
 
434
}
 
435
 
 
436
static inline int xsm_hvmcontext (struct domain *d, uint32_t cmd)
 
437
{
 
438
    return xsm_call(hvmcontext(d, cmd));
 
439
}
 
440
 
 
441
static inline int xsm_address_size (struct domain *d, uint32_t cmd)
 
442
{
 
443
    return xsm_call(address_size(d, cmd));
 
444
}
 
445
 
 
446
static inline int xsm_machine_address_size (struct domain *d, uint32_t cmd)
 
447
{
 
448
    return xsm_call(machine_address_size(d, cmd));
 
449
}
 
450
 
 
451
static inline int xsm_hvm_param (struct domain *d, unsigned long op)
 
452
{
 
453
    return xsm_call(hvm_param(d, op));
 
454
}
 
455
 
 
456
static inline int xsm_hvm_set_pci_intx_level (struct domain *d)
 
457
{
 
458
    return xsm_call(hvm_set_pci_intx_level(d));
 
459
}
 
460
 
 
461
static inline int xsm_hvm_set_isa_irq_level (struct domain *d)
 
462
{
 
463
    return xsm_call(hvm_set_isa_irq_level(d));
 
464
}
 
465
 
 
466
static inline int xsm_hvm_set_pci_link_route (struct domain *d)
 
467
{
 
468
    return xsm_call(hvm_set_pci_link_route(d));
 
469
}
 
470
 
 
471
static inline int xsm_apic (struct domain *d, int cmd)
 
472
{
 
473
    return xsm_call(apic(d, cmd));
 
474
}
 
475
 
 
476
static inline int xsm_assign_vector (struct domain *d, uint32_t pirq)
 
477
{
 
478
    return xsm_call(assign_vector(d, pirq));
 
479
}
 
480
 
 
481
static inline int xsm_xen_settime (void)
 
482
{
 
483
    return xsm_call(xen_settime());
 
484
}
 
485
 
 
486
static inline int xsm_memtype (uint32_t access)
 
487
{
 
488
    return xsm_call(memtype(access));
 
489
}
 
490
 
 
491
static inline int xsm_microcode (void)
 
492
{
 
493
    return xsm_call(microcode());
 
494
}
 
495
 
 
496
static inline int xsm_physinfo (void)
 
497
{
 
498
    return xsm_call(physinfo());
 
499
}
 
500
 
 
501
static inline int xsm_platform_quirk (uint32_t quirk)
 
502
{
 
503
    return xsm_call(platform_quirk(quirk));
 
504
}
 
505
 
 
506
static inline int xsm_machine_memory_map(void)
 
507
{
 
508
    return xsm_call(machine_memory_map());
 
509
}
 
510
 
 
511
static inline int xsm_domain_memory_map(struct domain *d)
 
512
{
 
513
    return xsm_call(domain_memory_map(d));
 
514
}
 
515
 
 
516
static inline int xsm_mmu_normal_update (struct domain *d, intpte_t fpte)
 
517
{
 
518
    return xsm_call(mmu_normal_update(d, fpte));
 
519
}
 
520
 
 
521
static inline int xsm_mmu_machphys_update (struct domain *d, unsigned long mfn)
 
522
{
 
523
    return xsm_call(mmu_machphys_update(d, mfn));
 
524
}
 
525
 
 
526
static inline int xsm_update_va_mapping(struct domain *d, l1_pgentry_t pte)
 
527
{
 
528
    return xsm_call(update_va_mapping(d, pte));
 
529
}
 
530
 
 
531
static inline int xsm_add_to_physmap(struct domain *d1, struct domain *d2)
 
532
{
 
533
    return xsm_call(add_to_physmap(d1, d2));
 
534
}
 
535
#endif /* CONFIG_X86 */
 
536
 
 
537
#endif /* __XSM_H */