ia64/xen-unstable

view xen/include/xsm/xsm.h @ 15910:c36292e83f07

Fix two memory leaks in xend.
Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
author kfraser@localhost.localdomain
date Fri Sep 14 16:04:33 2007 +0100 (2007-09-14)
parents 453f87d6e7f0
children d2bef6551c12
line source
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 */
15 #ifndef __XSM_H__
16 #define __XSM_H__
18 #include <xen/sched.h>
19 #include <xen/multiboot.h>
21 typedef void xsm_op_t;
22 DEFINE_XEN_GUEST_HANDLE(xsm_op_t);
24 extern long do_xsm_op (XEN_GUEST_HANDLE(xsm_op_t) op);
26 #ifdef XSM_ENABLE
27 #define xsm_call(fn) xsm_ops->fn
28 #else
29 #define xsm_call(fn) 0
30 #endif
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
38 #ifdef XSM_ENABLE
40 extern char *policy_buffer;
41 extern u32 policy_size;
43 typedef int (*xsm_initcall_t)(void);
45 extern xsm_initcall_t __xsm_initcall_start[], __xsm_initcall_end[];
47 #define xsm_initcall(fn) \
48 static xsm_initcall_t __initcall_##fn \
49 __attribute_used__ __attribute__((__section__(".xsm_initcall.init"))) = fn
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);
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);
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);
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);
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);
103 int (*console_io) (struct domain *d, int cmd);
105 int (*profile) (struct domain *d, int op);
107 int (*kexec) (void);
108 int (*schedop_shutdown) (struct domain *d1, struct domain *d2);
110 long (*__do_xsm_op) (XEN_GUEST_HANDLE(xsm_op_t) op);
111 void (*complete_init) (struct domain *d);
113 #ifdef CONFIG_X86
114 int (*shadow_control) (struct domain *d, uint32_t op);
115 int (*ioport_permission) (struct domain *d, uint32_t ioport,
116 uint8_t access);
117 int (*getpageframeinfo) (struct page_info *page);
118 int (*getmemlist) (struct domain *d);
119 int (*hypercall_init) (struct domain *d);
120 int (*hvmcontext) (struct domain *d, uint32_t op);
121 int (*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 };
142 #endif
144 extern struct xsm_operations *xsm_ops;
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 }
152 static inline int xsm_setvcpucontext(struct domain *d)
153 {
154 return xsm_call(setvcpucontext(d));
155 }
157 static inline int xsm_pausedomain (struct domain *d)
158 {
159 return xsm_call(pausedomain(d));
160 }
162 static inline int xsm_unpausedomain (struct domain *d)
163 {
164 return xsm_call(unpausedomain(d));
165 }
167 static inline int xsm_resumedomain (struct domain *d)
168 {
169 return xsm_call(resumedomain(d));
170 }
172 static inline int xsm_domain_create (struct domain *d, u32 ssidref)
173 {
174 return xsm_call(domain_create(d, ssidref));
175 }
177 static inline int xsm_max_vcpus(struct domain *d)
178 {
179 return xsm_call(max_vcpus(d));
180 }
182 static inline int xsm_destroydomain (struct domain *d)
183 {
184 return xsm_call(destroydomain(d));
185 }
187 static inline int xsm_vcpuaffinity (int cmd, struct domain *d)
188 {
189 return xsm_call(vcpuaffinity(cmd, d));
190 }
192 static inline int xsm_scheduler (struct domain *d)
193 {
194 return xsm_call(scheduler(d));
195 }
197 static inline int xsm_getdomaininfo (struct domain *d)
198 {
199 return xsm_call(getdomaininfo(d));
200 }
202 static inline int xsm_getvcpucontext (struct domain *d)
203 {
204 return xsm_call(getvcpucontext(d));
205 }
207 static inline int xsm_getvcpuinfo (struct domain *d)
208 {
209 return xsm_call(getvcpuinfo(d));
210 }
212 static inline int xsm_domain_settime (struct domain *d)
213 {
214 return xsm_call(domain_settime(d));
215 }
217 static inline int xsm_tbufcontrol (void)
218 {
219 return xsm_call(tbufcontrol());
220 }
222 static inline int xsm_readconsole (uint32_t clear)
223 {
224 return xsm_call(readconsole(clear));
225 }
227 static inline int xsm_sched_id (void)
228 {
229 return xsm_call(sched_id());
230 }
232 static inline int xsm_setdomainmaxmem (struct domain *d)
233 {
234 return xsm_call(setdomainmaxmem(d));
235 }
237 static inline int xsm_setdomainhandle (struct domain *d)
238 {
239 return xsm_call(setdomainhandle(d));
240 }
242 static inline int xsm_setdebugging (struct domain *d)
243 {
244 return xsm_call(setdebugging(d));
245 }
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 }
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 }
259 static inline int xsm_perfcontrol (void)
260 {
261 return xsm_call(perfcontrol());
262 }
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 }
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 }
276 static inline void xsm_evtchn_close_post (struct evtchn *chn)
277 {
278 xsm_call(evtchn_close_post(chn));
279 }
281 static inline int xsm_evtchn_send (struct domain *d, struct evtchn *chn)
282 {
283 return xsm_call(evtchn_send(d, chn));
284 }
286 static inline int xsm_evtchn_status (struct domain *d, struct evtchn *chn)
287 {
288 return xsm_call(evtchn_status(d, chn));
289 }
291 static inline int xsm_evtchn_reset (struct domain *d1, struct domain *d2)
292 {
293 return xsm_call(evtchn_reset(d1, d2));
294 }
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 }
302 static inline int xsm_grant_unmapref (struct domain *d1, struct domain *d2)
303 {
304 return xsm_call(grant_unmapref(d1, d2));
305 }
307 static inline int xsm_grant_setup (struct domain *d1, struct domain *d2)
308 {
309 return xsm_call(grant_setup(d1, d2));
310 }
312 static inline int xsm_grant_transfer (struct domain *d1, struct domain *d2)
313 {
314 return xsm_call(grant_transfer(d1, d2));
315 }
317 static inline int xsm_grant_copy (struct domain *d1, struct domain *d2)
318 {
319 return xsm_call(grant_copy(d1, d2));
320 }
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 }
327 static inline int xsm_alloc_security_domain (struct domain *d)
328 {
329 return xsm_call(alloc_security_domain(d));
330 }
332 static inline void xsm_free_security_domain (struct domain *d)
333 {
334 xsm_call(free_security_domain(d));
335 }
337 static inline int xsm_alloc_security_evtchn (struct evtchn *chn)
338 {
339 return xsm_call(alloc_security_evtchn(chn));
340 }
342 static inline void xsm_free_security_evtchn (struct evtchn *chn)
343 {
344 xsm_call(free_security_evtchn(chn));
345 }
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 }
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 }
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 }
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 }
369 static inline int xsm_console_io (struct domain *d, int cmd)
370 {
371 return xsm_call(console_io(d, cmd));
372 }
374 static inline int xsm_profile (struct domain *d, int op)
375 {
376 return xsm_call(profile(d, op));
377 }
379 static inline int xsm_kexec (void)
380 {
381 return xsm_call(kexec());
382 }
384 static inline int xsm_schedop_shutdown (struct domain *d1, struct domain *d2)
385 {
386 return xsm_call(schedop_shutdown(d1, d2));
387 }
389 static inline long __do_xsm_op (XEN_GUEST_HANDLE(xsm_op_t) op)
390 {
391 return xsm_call(__do_xsm_op(op));
392 }
394 static inline void xsm_complete_init (struct domain *d)
395 {
396 xsm_call(complete_init(d));
397 }
399 #ifdef XSM_ENABLE
400 extern int xsm_init(unsigned int *initrdidx, const multiboot_info_t *mbi,
401 unsigned long initial_images_start);
402 extern int xsm_policy_init(unsigned int *initrdidx, const multiboot_info_t *mbi,
403 unsigned long initial_images_start);
404 extern int register_xsm(struct xsm_operations *ops);
405 extern int unregister_xsm(struct xsm_operations *ops);
406 #else
407 static inline int xsm_init (unsigned int *initrdidx,
408 const multiboot_info_t *mbi, unsigned long initial_images_start)
409 {
410 return 0;
411 }
412 #endif
414 #ifdef CONFIG_X86
415 static inline int xsm_shadow_control (struct domain *d, uint32_t op)
416 {
417 return xsm_call(shadow_control(d, op));
418 }
420 static inline int xsm_ioport_permission (struct domain *d, uint32_t ioport,
421 uint8_t access)
422 {
423 return xsm_call(ioport_permission(d, ioport, access));
424 }
426 static inline int xsm_getpageframeinfo (struct page_info *page)
427 {
428 return xsm_call(getpageframeinfo(page));
429 }
431 static inline int xsm_getmemlist (struct domain *d)
432 {
433 return xsm_call(getmemlist(d));
434 }
436 static inline int xsm_hypercall_init (struct domain *d)
437 {
438 return xsm_call(hypercall_init(d));
439 }
441 static inline int xsm_hvmcontext (struct domain *d, uint32_t cmd)
442 {
443 return xsm_call(hvmcontext(d, cmd));
444 }
446 static inline int xsm_address_size (struct domain *d, uint32_t cmd)
447 {
448 return xsm_call(address_size(d, cmd));
449 }
451 static inline int xsm_hvm_param (struct domain *d, unsigned long op)
452 {
453 return xsm_call(hvm_param(d, op));
454 }
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 }
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 }
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 }
471 static inline int xsm_apic (struct domain *d, int cmd)
472 {
473 return xsm_call(apic(d, cmd));
474 }
476 static inline int xsm_assign_vector (struct domain *d, uint32_t pirq)
477 {
478 return xsm_call(assign_vector(d, pirq));
479 }
481 static inline int xsm_xen_settime (void)
482 {
483 return xsm_call(xen_settime());
484 }
486 static inline int xsm_memtype (uint32_t access)
487 {
488 return xsm_call(memtype(access));
489 }
491 static inline int xsm_microcode (void)
492 {
493 return xsm_call(microcode());
494 }
496 static inline int xsm_physinfo (void)
497 {
498 return xsm_call(physinfo());
499 }
501 static inline int xsm_platform_quirk (uint32_t quirk)
502 {
503 return xsm_call(platform_quirk(quirk));
504 }
506 static inline int xsm_machine_memory_map(void)
507 {
508 return xsm_call(machine_memory_map());
509 }
511 static inline int xsm_domain_memory_map(struct domain *d)
512 {
513 return xsm_call(domain_memory_map(d));
514 }
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 }
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 }
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 }
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 */
537 #endif /* __XSM_H */