ia64/xen-unstable

view xen/xsm/dummy.c @ 18394:dade7f0bdc8d

hvm: Use main memory for video memory.

When creating an HVM domain, if e.g. another domain is created before
qemu allocates video memory, the extra 8MB memory ballooning is not
available any more, because it got consumed by the other domain.

This fixes it by taking video memory from the main memory:

- make hvmloader use e820_malloc to reserve some of the main memory
and notify ioemu of its address through the Xen platform PCI card.
- add XENMAPSPACE_mfn to the xen_add_to_physmap memory op, to allow
ioemu to move the MFNs between the original position and the PCI
mapping, when LFB acceleration is disabled/enabled
- add a remove_from_physmap memory op, to allow ioemu to unmap it
completely for the case of old guests with acceleration disabled.
- add xc_domain_memory_translate_gpfn_list to libxc to allow ioemu to
get the MFNs of the video memory.
- have xend save the PCI memory space instead of ioemu: if a memory
page is there, the guest can access it like usual memory, so xend
can safely be responsible to save it. The extra benefit is that
live migration will apply the logdirty optimization there too.
- handle old saved images, populating the video memory from ioemu if
really needed.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Aug 27 14:53:39 2008 +0100 (2008-08-27)
parents 217c8b6ebfab
children 44f039c4aee4
line source
1 /*
2 * This work is based on the LSM implementation in Linux 2.6.13.4.
3 *
4 * Author: George Coker, <gscoker@alpha.ncsc.mil>
5 *
6 * Contributors: Michael LeMay, <mdlemay@epoch.ncsc.mil>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2,
10 * as published by the Free Software Foundation.
11 */
13 #include <xen/sched.h>
14 #include <xsm/xsm.h>
16 static void dummy_security_domaininfo(struct domain *d,
17 struct xen_domctl_getdomaininfo *info)
18 {
19 return;
20 }
22 static int dummy_setvcpucontext(struct domain *d)
23 {
24 return 0;
25 }
27 static int dummy_pausedomain (struct domain *d)
28 {
29 return 0;
30 }
32 static int dummy_unpausedomain (struct domain *d)
33 {
34 return 0;
35 }
37 static int dummy_resumedomain (struct domain *d)
38 {
39 return 0;
40 }
42 static int dummy_domain_create(struct domain *d, u32 ssidref)
43 {
44 return 0;
45 }
47 static int dummy_max_vcpus(struct domain *d)
48 {
49 return 0;
50 }
52 static int dummy_destroydomain (struct domain *d)
53 {
54 return 0;
55 }
57 static int dummy_vcpuaffinity (int cmd, struct domain *d)
58 {
59 return 0;
60 }
62 static int dummy_scheduler (struct domain *d)
63 {
64 return 0;
65 }
67 static int dummy_getdomaininfo (struct domain *d)
68 {
69 return 0;
70 }
72 static int dummy_getvcpucontext (struct domain *d)
73 {
74 return 0;
75 }
77 static int dummy_getvcpuinfo (struct domain *d)
78 {
79 return 0;
80 }
82 static int dummy_domain_settime (struct domain *d)
83 {
84 return 0;
85 }
87 static int dummy_tbufcontrol (void)
88 {
89 return 0;
90 }
92 static int dummy_readconsole (uint32_t clear)
93 {
94 return 0;
95 }
97 static int dummy_sched_id (void)
98 {
99 return 0;
100 }
102 static int dummy_setdomainmaxmem (struct domain *d)
103 {
104 return 0;
105 }
107 static int dummy_setdomainhandle (struct domain *d)
108 {
109 return 0;
110 }
112 static int dummy_setdebugging (struct domain *d)
113 {
114 return 0;
115 }
117 static int dummy_irq_permission (struct domain *d, uint8_t pirq, uint8_t access)
118 {
119 return 0;
120 }
122 static int dummy_iomem_permission (struct domain *d, unsigned long mfn,
123 uint8_t access)
124 {
125 return 0;
126 }
128 static int dummy_perfcontrol (void)
129 {
130 return 0;
131 }
133 static int dummy_alloc_security_domain (struct domain *d)
134 {
135 return 0;
136 }
138 static void dummy_free_security_domain (struct domain *d)
139 {
140 return;
141 }
143 static int dummy_grant_mapref (struct domain *d1, struct domain *d2,
144 uint32_t flags)
145 {
146 return 0;
147 }
149 static int dummy_grant_unmapref (struct domain *d1, struct domain *d2)
150 {
151 return 0;
152 }
154 static int dummy_grant_setup (struct domain *d1, struct domain *d2)
155 {
156 return 0;
157 }
159 static int dummy_grant_transfer (struct domain *d1, struct domain *d2)
160 {
161 return 0;
162 }
164 static int dummy_grant_copy (struct domain *d1, struct domain *d2)
165 {
166 return 0;
167 }
169 static int dummy_grant_query_size (struct domain *d1, struct domain *d2)
170 {
171 return 0;
172 }
174 static int dummy_translate_gpfn_list (struct domain *d, unsigned long mfn)
175 {
176 return 0;
177 }
179 static int dummy_memory_adjust_reservation (struct domain *d1,
180 struct domain *d2)
181 {
182 return 0;
183 }
185 static int dummy_memory_stat_reservation (struct domain *d1, struct domain *d2)
186 {
187 return 0;
188 }
190 static int dummy_console_io (struct domain *d, int cmd)
191 {
192 return 0;
193 }
195 static int dummy_profile (struct domain *d, int op)
196 {
197 return 0;
198 }
200 static int dummy_kexec (void)
201 {
202 return 0;
203 }
205 static int dummy_schedop_shutdown (struct domain *d1, struct domain *d2)
206 {
207 return 0;
208 }
210 static int dummy_memory_pin_page(struct domain *d, struct page_info *page)
211 {
212 return 0;
213 }
215 static int dummy_evtchn_unbound (struct domain *d, struct evtchn *chn,
216 domid_t id2)
217 {
218 return 0;
219 }
221 static int dummy_evtchn_interdomain (struct domain *d1, struct evtchn
222 *chan1, struct domain *d2, struct evtchn *chan2)
223 {
224 return 0;
225 }
227 static void dummy_evtchn_close_post (struct evtchn *chn)
228 {
229 return;
230 }
232 static int dummy_evtchn_send (struct domain *d, struct evtchn *chn)
233 {
234 return 0;
235 }
237 static int dummy_evtchn_status (struct domain *d, struct evtchn *chn)
238 {
239 return 0;
240 }
242 static int dummy_evtchn_reset (struct domain *d1, struct domain *d2)
243 {
244 return 0;
245 }
247 static int dummy_alloc_security_evtchn (struct evtchn *chn)
248 {
249 return 0;
250 }
252 static void dummy_free_security_evtchn (struct evtchn *chn)
253 {
254 return;
255 }
257 static long dummy___do_xsm_op(XEN_GUEST_HANDLE(xsm_op_t) op)
258 {
259 return -ENOSYS;
260 }
262 #ifdef CONFIG_X86
263 static int dummy_shadow_control (struct domain *d, uint32_t op)
264 {
265 return 0;
266 }
268 static int dummy_ioport_permission (struct domain *d, uint32_t ioport,
269 uint8_t access)
270 {
271 return 0;
272 }
274 static int dummy_getpageframeinfo (struct page_info *page)
275 {
276 return 0;
277 }
279 static int dummy_getmemlist (struct domain *d)
280 {
281 return 0;
282 }
284 static int dummy_hypercall_init (struct domain *d)
285 {
286 return 0;
287 }
289 static int dummy_hvmcontext (struct domain *d, uint32_t cmd)
290 {
291 return 0;
292 }
294 static int dummy_address_size (struct domain *d, uint32_t cmd)
295 {
296 return 0;
297 }
299 static int dummy_machine_address_size (struct domain *d, uint32_t cmd)
300 {
301 return 0;
302 }
304 static int dummy_hvm_param (struct domain *d, unsigned long op)
305 {
306 return 0;
307 }
309 static int dummy_hvm_set_pci_intx_level (struct domain *d)
310 {
311 return 0;
312 }
314 static int dummy_hvm_set_isa_irq_level (struct domain *d)
315 {
316 return 0;
317 }
319 static int dummy_hvm_set_pci_link_route (struct domain *d)
320 {
321 return 0;
322 }
324 static int dummy_apic (struct domain *d, int cmd)
325 {
326 return 0;
327 }
329 static int dummy_assign_vector (struct domain *d, uint32_t pirq)
330 {
331 return 0;
332 }
334 static int dummy_xen_settime (void)
335 {
336 return 0;
337 }
339 static int dummy_memtype (uint32_t access)
340 {
341 return 0;
342 }
344 static int dummy_microcode (void)
345 {
346 return 0;
347 }
349 static int dummy_physinfo (void)
350 {
351 return 0;
352 }
354 static int dummy_platform_quirk (uint32_t quirk)
355 {
356 return 0;
357 }
359 static int dummy_machine_memory_map (void)
360 {
361 return 0;
362 }
364 static int dummy_domain_memory_map (struct domain *d)
365 {
366 return 0;
367 }
369 static int dummy_mmu_normal_update (struct domain *d, intpte_t fpte)
370 {
371 return 0;
372 }
374 static int dummy_mmu_machphys_update (struct domain *d, unsigned long mfn)
375 {
376 return 0;
377 }
379 static int dummy_update_va_mapping (struct domain *d, l1_pgentry_t pte)
380 {
381 return 0;
382 }
384 static int dummy_add_to_physmap (struct domain *d1, struct domain *d2)
385 {
386 return 0;
387 }
389 static int dummy_remove_from_physmap (struct domain *d1, struct domain *d2)
390 {
391 return 0;
392 }
393 #endif
395 struct xsm_operations dummy_xsm_ops;
397 #define set_to_dummy_if_null(ops, function) \
398 do { \
399 if ( !ops->function ) \
400 { \
401 ops->function = dummy_##function; \
402 dprintk(XENLOG_DEBUG, "Had to override the " #function \
403 " security operation with the dummy one.\n"); \
404 } \
405 } while (0)
407 void xsm_fixup_ops (struct xsm_operations *ops)
408 {
409 set_to_dummy_if_null(ops, security_domaininfo);
410 set_to_dummy_if_null(ops, setvcpucontext);
411 set_to_dummy_if_null(ops, pausedomain);
412 set_to_dummy_if_null(ops, unpausedomain);
413 set_to_dummy_if_null(ops, resumedomain);
414 set_to_dummy_if_null(ops, domain_create);
415 set_to_dummy_if_null(ops, max_vcpus);
416 set_to_dummy_if_null(ops, destroydomain);
417 set_to_dummy_if_null(ops, vcpuaffinity);
418 set_to_dummy_if_null(ops, scheduler);
419 set_to_dummy_if_null(ops, getdomaininfo);
420 set_to_dummy_if_null(ops, getvcpucontext);
421 set_to_dummy_if_null(ops, getvcpuinfo);
422 set_to_dummy_if_null(ops, domain_settime);
423 set_to_dummy_if_null(ops, tbufcontrol);
424 set_to_dummy_if_null(ops, readconsole);
425 set_to_dummy_if_null(ops, sched_id);
426 set_to_dummy_if_null(ops, setdomainmaxmem);
427 set_to_dummy_if_null(ops, setdomainhandle);
428 set_to_dummy_if_null(ops, setdebugging);
429 set_to_dummy_if_null(ops, irq_permission);
430 set_to_dummy_if_null(ops, iomem_permission);
431 set_to_dummy_if_null(ops, perfcontrol);
433 set_to_dummy_if_null(ops, evtchn_unbound);
434 set_to_dummy_if_null(ops, evtchn_interdomain);
435 set_to_dummy_if_null(ops, evtchn_close_post);
436 set_to_dummy_if_null(ops, evtchn_send);
437 set_to_dummy_if_null(ops, evtchn_status);
438 set_to_dummy_if_null(ops, evtchn_reset);
440 set_to_dummy_if_null(ops, grant_mapref);
441 set_to_dummy_if_null(ops, grant_unmapref);
442 set_to_dummy_if_null(ops, grant_setup);
443 set_to_dummy_if_null(ops, grant_transfer);
444 set_to_dummy_if_null(ops, grant_copy);
445 set_to_dummy_if_null(ops, grant_query_size);
447 set_to_dummy_if_null(ops, alloc_security_domain);
448 set_to_dummy_if_null(ops, free_security_domain);
449 set_to_dummy_if_null(ops, alloc_security_evtchn);
450 set_to_dummy_if_null(ops, free_security_evtchn);
452 set_to_dummy_if_null(ops, translate_gpfn_list);
453 set_to_dummy_if_null(ops, memory_adjust_reservation);
454 set_to_dummy_if_null(ops, memory_stat_reservation);
455 set_to_dummy_if_null(ops, memory_pin_page);
457 set_to_dummy_if_null(ops, console_io);
459 set_to_dummy_if_null(ops, profile);
461 set_to_dummy_if_null(ops, kexec);
462 set_to_dummy_if_null(ops, schedop_shutdown);
464 set_to_dummy_if_null(ops, __do_xsm_op);
466 #ifdef CONFIG_X86
467 set_to_dummy_if_null(ops, shadow_control);
468 set_to_dummy_if_null(ops, ioport_permission);
469 set_to_dummy_if_null(ops, getpageframeinfo);
470 set_to_dummy_if_null(ops, getmemlist);
471 set_to_dummy_if_null(ops, hypercall_init);
472 set_to_dummy_if_null(ops, hvmcontext);
473 set_to_dummy_if_null(ops, address_size);
474 set_to_dummy_if_null(ops, machine_address_size);
475 set_to_dummy_if_null(ops, hvm_param);
476 set_to_dummy_if_null(ops, hvm_set_pci_intx_level);
477 set_to_dummy_if_null(ops, hvm_set_isa_irq_level);
478 set_to_dummy_if_null(ops, hvm_set_pci_link_route);
479 set_to_dummy_if_null(ops, apic);
480 set_to_dummy_if_null(ops, assign_vector);
481 set_to_dummy_if_null(ops, xen_settime);
482 set_to_dummy_if_null(ops, memtype);
483 set_to_dummy_if_null(ops, microcode);
484 set_to_dummy_if_null(ops, physinfo);
485 set_to_dummy_if_null(ops, platform_quirk);
486 set_to_dummy_if_null(ops, machine_memory_map);
487 set_to_dummy_if_null(ops, domain_memory_map);
488 set_to_dummy_if_null(ops, mmu_normal_update);
489 set_to_dummy_if_null(ops, mmu_machphys_update);
490 set_to_dummy_if_null(ops, update_va_mapping);
491 set_to_dummy_if_null(ops, add_to_physmap);
492 set_to_dummy_if_null(ops, remove_from_physmap);
493 #endif
494 }