ia64/xen-unstable

view xen/include/xsm/xsm.h @ 19673:f3bed18decfc

[VTD] laying the ground work for ATS

These changes lay the ground work for ATS enabling in Xen. It will be
followed by patch which enables PCI MMCFG which is needed for actual
enabling of ATS functionality.

Signed-off-by: Allen Kay <allen.m.kay@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri May 29 09:19:30 2009 +0100 (2009-05-29)
parents 5966b71195b4
children
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 (*set_target) (struct domain *d, struct domain *e);
68 int (*tbufcontrol) (void);
69 int (*readconsole) (uint32_t clear);
70 int (*sched_id) (void);
71 int (*setdomainmaxmem) (struct domain *d);
72 int (*setdomainhandle) (struct domain *d);
73 int (*setdebugging) (struct domain *d);
74 int (*perfcontrol) (void);
75 int (*debug_keys) (void);
76 int (*getcpuinfo) (void);
77 int (*availheap) (void);
78 int (*get_pmstat) (void);
79 int (*pm_op) (void);
81 int (*evtchn_unbound) (struct domain *d, struct evtchn *chn, domid_t id2);
82 int (*evtchn_interdomain) (struct domain *d1, struct evtchn *chn1,
83 struct domain *d2, struct evtchn *chn2);
84 void (*evtchn_close_post) (struct evtchn *chn);
85 int (*evtchn_send) (struct domain *d, struct evtchn *chn);
86 int (*evtchn_status) (struct domain *d, struct evtchn *chn);
87 int (*evtchn_reset) (struct domain *d1, struct domain *d2);
89 int (*grant_mapref) (struct domain *d1, struct domain *d2, uint32_t flags);
90 int (*grant_unmapref) (struct domain *d1, struct domain *d2);
91 int (*grant_setup) (struct domain *d1, struct domain *d2);
92 int (*grant_transfer) (struct domain *d1, struct domain *d2);
93 int (*grant_copy) (struct domain *d1, struct domain *d2);
94 int (*grant_query_size) (struct domain *d1, struct domain *d2);
96 int (*alloc_security_domain) (struct domain *d);
97 void (*free_security_domain) (struct domain *d);
98 int (*alloc_security_evtchn) (struct evtchn *chn);
99 void (*free_security_evtchn) (struct evtchn *chn);
101 int (*memory_adjust_reservation) (struct domain *d1, struct domain *d2);
102 int (*memory_stat_reservation) (struct domain *d1, struct domain *d2);
103 int (*memory_pin_page) (struct domain *d, struct page_info *page);
105 int (*console_io) (struct domain *d, int cmd);
107 int (*profile) (struct domain *d, int op);
109 int (*kexec) (void);
110 int (*schedop_shutdown) (struct domain *d1, struct domain *d2);
111 int (*add_range) (struct domain *d, char *name, unsigned long s, unsigned long e);
112 int (*remove_range) (struct domain *d, char *name, unsigned long s, unsigned long e);
114 long (*__do_xsm_op) (XEN_GUEST_HANDLE(xsm_op_t) op);
116 #ifdef CONFIG_X86
117 int (*shadow_control) (struct domain *d, uint32_t op);
118 int (*getpageframeinfo) (struct page_info *page);
119 int (*getmemlist) (struct domain *d);
120 int (*hypercall_init) (struct domain *d);
121 int (*hvmcontext) (struct domain *d, uint32_t op);
122 int (*address_size) (struct domain *d, uint32_t op);
123 int (*machine_address_size) (struct domain *d, uint32_t op);
124 int (*hvm_param) (struct domain *d, unsigned long op);
125 int (*hvm_set_pci_intx_level) (struct domain *d);
126 int (*hvm_set_isa_irq_level) (struct domain *d);
127 int (*hvm_set_pci_link_route) (struct domain *d);
128 int (*apic) (struct domain *d, int cmd);
129 int (*assign_vector) (struct domain *d, uint32_t pirq);
130 int (*xen_settime) (void);
131 int (*memtype) (uint32_t access);
132 int (*microcode) (void);
133 int (*physinfo) (void);
134 int (*platform_quirk) (uint32_t);
135 int (*firmware_info) (void);
136 int (*acpi_sleep) (void);
137 int (*change_freq) (void);
138 int (*getidletime) (void);
139 int (*machine_memory_map) (void);
140 int (*domain_memory_map) (struct domain *d);
141 int (*mmu_normal_update) (struct domain *d, struct domain *f,
142 intpte_t fpte);
143 int (*mmu_machphys_update) (struct domain *d, unsigned long mfn);
144 int (*update_va_mapping) (struct domain *d, struct domain *f,
145 l1_pgentry_t pte);
146 int (*add_to_physmap) (struct domain *d1, struct domain *d2);
147 int (*sendtrigger) (struct domain *d);
148 int (*test_assign_device) (uint32_t machine_bdf);
149 int (*assign_device) (struct domain *d, uint32_t machine_bdf);
150 int (*deassign_device) (struct domain *d, uint32_t machine_bdf);
151 int (*bind_pt_irq) (struct domain *d, struct xen_domctl_bind_pt_irq *bind);
152 int (*pin_mem_cacheattr) (struct domain *d);
153 int (*ext_vcpucontext) (struct domain *d, uint32_t cmd);
154 #endif
155 };
157 #endif
159 extern struct xsm_operations *xsm_ops;
161 static inline void xsm_security_domaininfo (struct domain *d,
162 struct xen_domctl_getdomaininfo *info)
163 {
164 xsm_call(security_domaininfo(d, info));
165 }
167 static inline int xsm_setvcpucontext(struct domain *d)
168 {
169 return xsm_call(setvcpucontext(d));
170 }
172 static inline int xsm_pausedomain (struct domain *d)
173 {
174 return xsm_call(pausedomain(d));
175 }
177 static inline int xsm_unpausedomain (struct domain *d)
178 {
179 return xsm_call(unpausedomain(d));
180 }
182 static inline int xsm_resumedomain (struct domain *d)
183 {
184 return xsm_call(resumedomain(d));
185 }
187 static inline int xsm_domain_create (struct domain *d, u32 ssidref)
188 {
189 return xsm_call(domain_create(d, ssidref));
190 }
192 static inline int xsm_max_vcpus(struct domain *d)
193 {
194 return xsm_call(max_vcpus(d));
195 }
197 static inline int xsm_destroydomain (struct domain *d)
198 {
199 return xsm_call(destroydomain(d));
200 }
202 static inline int xsm_vcpuaffinity (int cmd, struct domain *d)
203 {
204 return xsm_call(vcpuaffinity(cmd, d));
205 }
207 static inline int xsm_scheduler (struct domain *d)
208 {
209 return xsm_call(scheduler(d));
210 }
212 static inline int xsm_getdomaininfo (struct domain *d)
213 {
214 return xsm_call(getdomaininfo(d));
215 }
217 static inline int xsm_getvcpucontext (struct domain *d)
218 {
219 return xsm_call(getvcpucontext(d));
220 }
222 static inline int xsm_getvcpuinfo (struct domain *d)
223 {
224 return xsm_call(getvcpuinfo(d));
225 }
227 static inline int xsm_domain_settime (struct domain *d)
228 {
229 return xsm_call(domain_settime(d));
230 }
232 static inline int xsm_set_target (struct domain *d, struct domain *e)
233 {
234 return xsm_call(set_target(d, e));
235 }
237 static inline int xsm_tbufcontrol (void)
238 {
239 return xsm_call(tbufcontrol());
240 }
242 static inline int xsm_readconsole (uint32_t clear)
243 {
244 return xsm_call(readconsole(clear));
245 }
247 static inline int xsm_sched_id (void)
248 {
249 return xsm_call(sched_id());
250 }
252 static inline int xsm_setdomainmaxmem (struct domain *d)
253 {
254 return xsm_call(setdomainmaxmem(d));
255 }
257 static inline int xsm_setdomainhandle (struct domain *d)
258 {
259 return xsm_call(setdomainhandle(d));
260 }
262 static inline int xsm_setdebugging (struct domain *d)
263 {
264 return xsm_call(setdebugging(d));
265 }
267 static inline int xsm_perfcontrol (void)
268 {
269 return xsm_call(perfcontrol());
270 }
272 static inline int xsm_debug_keys (void)
273 {
274 return xsm_call(debug_keys());
275 }
277 static inline int xsm_availheap (void)
278 {
279 return xsm_call(availheap());
280 }
282 static inline int xsm_getcpuinfo (void)
283 {
284 return xsm_call(getcpuinfo());
285 }
287 static inline int xsm_get_pmstat(void)
288 {
289 return xsm_call(get_pmstat());
290 }
292 static inline int xsm_pm_op(void)
293 {
294 return xsm_call(pm_op());
295 }
297 static inline int xsm_evtchn_unbound (struct domain *d1, struct evtchn *chn,
298 domid_t id2)
299 {
300 return xsm_call(evtchn_unbound(d1, chn, id2));
301 }
303 static inline int xsm_evtchn_interdomain (struct domain *d1,
304 struct evtchn *chan1, struct domain *d2, struct evtchn *chan2)
305 {
306 return xsm_call(evtchn_interdomain(d1, chan1, d2, chan2));
307 }
309 static inline void xsm_evtchn_close_post (struct evtchn *chn)
310 {
311 xsm_call(evtchn_close_post(chn));
312 }
314 static inline int xsm_evtchn_send (struct domain *d, struct evtchn *chn)
315 {
316 return xsm_call(evtchn_send(d, chn));
317 }
319 static inline int xsm_evtchn_status (struct domain *d, struct evtchn *chn)
320 {
321 return xsm_call(evtchn_status(d, chn));
322 }
324 static inline int xsm_evtchn_reset (struct domain *d1, struct domain *d2)
325 {
326 return xsm_call(evtchn_reset(d1, d2));
327 }
329 static inline int xsm_grant_mapref (struct domain *d1, struct domain *d2,
330 uint32_t flags)
331 {
332 return xsm_call(grant_mapref(d1, d2, flags));
333 }
335 static inline int xsm_grant_unmapref (struct domain *d1, struct domain *d2)
336 {
337 return xsm_call(grant_unmapref(d1, d2));
338 }
340 static inline int xsm_grant_setup (struct domain *d1, struct domain *d2)
341 {
342 return xsm_call(grant_setup(d1, d2));
343 }
345 static inline int xsm_grant_transfer (struct domain *d1, struct domain *d2)
346 {
347 return xsm_call(grant_transfer(d1, d2));
348 }
350 static inline int xsm_grant_copy (struct domain *d1, struct domain *d2)
351 {
352 return xsm_call(grant_copy(d1, d2));
353 }
355 static inline int xsm_grant_query_size (struct domain *d1, struct domain *d2)
356 {
357 return xsm_call(grant_query_size(d1, d2));
358 }
360 static inline int xsm_alloc_security_domain (struct domain *d)
361 {
362 return xsm_call(alloc_security_domain(d));
363 }
365 static inline void xsm_free_security_domain (struct domain *d)
366 {
367 xsm_call(free_security_domain(d));
368 }
370 static inline int xsm_alloc_security_evtchn (struct evtchn *chn)
371 {
372 return xsm_call(alloc_security_evtchn(chn));
373 }
375 static inline void xsm_free_security_evtchn (struct evtchn *chn)
376 {
377 xsm_call(free_security_evtchn(chn));
378 }
380 static inline int xsm_memory_adjust_reservation (struct domain *d1, struct
381 domain *d2)
382 {
383 return xsm_call(memory_adjust_reservation(d1, d2));
384 }
386 static inline int xsm_memory_stat_reservation (struct domain *d1,
387 struct domain *d2)
388 {
389 return xsm_call(memory_stat_reservation(d1, d2));
390 }
392 static inline int xsm_memory_pin_page(struct domain *d, struct page_info *page)
393 {
394 return xsm_call(memory_pin_page(d, page));
395 }
397 static inline int xsm_console_io (struct domain *d, int cmd)
398 {
399 return xsm_call(console_io(d, cmd));
400 }
402 static inline int xsm_profile (struct domain *d, int op)
403 {
404 return xsm_call(profile(d, op));
405 }
407 static inline int xsm_kexec (void)
408 {
409 return xsm_call(kexec());
410 }
412 static inline int xsm_schedop_shutdown (struct domain *d1, struct domain *d2)
413 {
414 return xsm_call(schedop_shutdown(d1, d2));
415 }
417 static inline int xsm_add_range (struct domain *d, char *name, unsigned long s,
418 unsigned long e)
419 {
420 return xsm_call(add_range(d, name, s, e));
421 }
423 static inline int xsm_remove_range (struct domain *d, char *name, unsigned long s,
424 unsigned long e)
425 {
426 return xsm_call(remove_range(d, name, s, e));
427 }
429 static inline long __do_xsm_op (XEN_GUEST_HANDLE(xsm_op_t) op)
430 {
431 return xsm_call(__do_xsm_op(op));
432 }
434 #ifdef XSM_ENABLE
435 extern int xsm_init(unsigned int *initrdidx, const multiboot_info_t *mbi,
436 unsigned long initial_images_start);
437 extern int xsm_policy_init(unsigned int *initrdidx, const multiboot_info_t *mbi,
438 unsigned long initial_images_start);
439 extern int register_xsm(struct xsm_operations *ops);
440 extern int unregister_xsm(struct xsm_operations *ops);
441 #else
442 static inline int xsm_init (unsigned int *initrdidx,
443 const multiboot_info_t *mbi, unsigned long initial_images_start)
444 {
445 return 0;
446 }
447 #endif
449 #ifdef CONFIG_X86
450 static inline int xsm_shadow_control (struct domain *d, uint32_t op)
451 {
452 return xsm_call(shadow_control(d, op));
453 }
455 static inline int xsm_getpageframeinfo (struct page_info *page)
456 {
457 return xsm_call(getpageframeinfo(page));
458 }
460 static inline int xsm_getmemlist (struct domain *d)
461 {
462 return xsm_call(getmemlist(d));
463 }
465 static inline int xsm_hypercall_init (struct domain *d)
466 {
467 return xsm_call(hypercall_init(d));
468 }
470 static inline int xsm_hvmcontext (struct domain *d, uint32_t cmd)
471 {
472 return xsm_call(hvmcontext(d, cmd));
473 }
475 static inline int xsm_address_size (struct domain *d, uint32_t cmd)
476 {
477 return xsm_call(address_size(d, cmd));
478 }
480 static inline int xsm_machine_address_size (struct domain *d, uint32_t cmd)
481 {
482 return xsm_call(machine_address_size(d, cmd));
483 }
485 static inline int xsm_hvm_param (struct domain *d, unsigned long op)
486 {
487 return xsm_call(hvm_param(d, op));
488 }
490 static inline int xsm_hvm_set_pci_intx_level (struct domain *d)
491 {
492 return xsm_call(hvm_set_pci_intx_level(d));
493 }
495 static inline int xsm_hvm_set_isa_irq_level (struct domain *d)
496 {
497 return xsm_call(hvm_set_isa_irq_level(d));
498 }
500 static inline int xsm_hvm_set_pci_link_route (struct domain *d)
501 {
502 return xsm_call(hvm_set_pci_link_route(d));
503 }
505 static inline int xsm_apic (struct domain *d, int cmd)
506 {
507 return xsm_call(apic(d, cmd));
508 }
510 static inline int xsm_assign_vector (struct domain *d, uint32_t pirq)
511 {
512 return xsm_call(assign_vector(d, pirq));
513 }
515 static inline int xsm_xen_settime (void)
516 {
517 return xsm_call(xen_settime());
518 }
520 static inline int xsm_memtype (uint32_t access)
521 {
522 return xsm_call(memtype(access));
523 }
525 static inline int xsm_microcode (void)
526 {
527 return xsm_call(microcode());
528 }
530 static inline int xsm_physinfo (void)
531 {
532 return xsm_call(physinfo());
533 }
535 static inline int xsm_platform_quirk (uint32_t quirk)
536 {
537 return xsm_call(platform_quirk(quirk));
538 }
540 static inline int xsm_firmware_info (void)
541 {
542 return xsm_call(firmware_info());
543 }
545 static inline int xsm_acpi_sleep (void)
546 {
547 return xsm_call(acpi_sleep());
548 }
550 static inline int xsm_change_freq (void)
551 {
552 return xsm_call(change_freq());
553 }
555 static inline int xsm_getidletime (void)
556 {
557 return xsm_call(getidletime());
558 }
560 static inline int xsm_machine_memory_map(void)
561 {
562 return xsm_call(machine_memory_map());
563 }
565 static inline int xsm_domain_memory_map(struct domain *d)
566 {
567 return xsm_call(domain_memory_map(d));
568 }
570 static inline int xsm_mmu_normal_update (struct domain *d, struct domain *f,
571 intpte_t fpte)
572 {
573 return xsm_call(mmu_normal_update(d, f, fpte));
574 }
576 static inline int xsm_mmu_machphys_update (struct domain *d, unsigned long mfn)
577 {
578 return xsm_call(mmu_machphys_update(d, mfn));
579 }
581 static inline int xsm_update_va_mapping(struct domain *d, struct domain *f,
582 l1_pgentry_t pte)
583 {
584 return xsm_call(update_va_mapping(d, f, pte));
585 }
587 static inline int xsm_add_to_physmap(struct domain *d1, struct domain *d2)
588 {
589 return xsm_call(add_to_physmap(d1, d2));
590 }
592 static inline int xsm_sendtrigger(struct domain *d)
593 {
594 return xsm_call(sendtrigger(d));
595 }
597 static inline int xsm_test_assign_device(uint32_t machine_bdf)
598 {
599 return xsm_call(test_assign_device(machine_bdf));
600 }
602 static inline int xsm_assign_device(struct domain *d, uint32_t machine_bdf)
603 {
604 return xsm_call(assign_device(d, machine_bdf));
605 }
607 static inline int xsm_deassign_device(struct domain *d, uint32_t machine_bdf)
608 {
609 return xsm_call(deassign_device(d, machine_bdf));
610 }
612 static inline int xsm_bind_pt_irq(struct domain *d,
613 struct xen_domctl_bind_pt_irq *bind)
614 {
615 return xsm_call(bind_pt_irq(d, bind));
616 }
618 static inline int xsm_pin_mem_cacheattr(struct domain *d)
619 {
620 return xsm_call(pin_mem_cacheattr(d));
621 }
623 static inline int xsm_ext_vcpucontext(struct domain *d, uint32_t cmd)
624 {
625 return xsm_call(ext_vcpucontext(d, cmd));
626 }
627 #endif /* CONFIG_X86 */
629 #endif /* __XSM_H */