debuggers.hg

view xen/xsm/xsm_policy.c @ 22855:1d1eec7e1fb4

xl: Perform minimal validation of virtual disk file while parsing config file

This patch performs some very basic validation on the virtual disk
file passed through the config file. This validation ensures that we
don't go too far with the initialization like spawn qemu and more
while there could be some potentially fundamental issues.

[ Patch fixed up to work with PHYSTYPE_EMPTY 22808:6ec61438713a -iwj ]

Signed-off-by: Kamala Narasimhan <kamala.narasimhan@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Kamala Narasimhan <kamala.narasimhan@gmail.com>
date Tue Jan 25 18:09:49 2011 +0000 (2011-01-25)
parents 426f3a265784
children
line source
1 /*
2 * Copyright (C) 2005 IBM Corporation
3 *
4 * Authors:
5 * Reiner Sailer, <sailer@watson.ibm.com>
6 * Stefan Berger, <stefanb@watson.ibm.com>
7 *
8 * Contributors:
9 * Michael LeMay, <mdlemay@epoch.ncsc.mil>
10 * George Coker, <gscoker@alpha.ncsc.mil>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2,
14 * as published by the Free Software Foundation.
15 *
16 *
17 * This file contains the XSM policy init functions for Xen.
18 * This file is based on the ACM functions of the same name.
19 *
20 */
22 #include <xsm/xsm.h>
23 #include <xen/multiboot.h>
25 char *__initdata policy_buffer = NULL;
26 u32 __initdata policy_size = 0;
28 int xsm_policy_init(unsigned int *initrdidx, const multiboot_info_t *mbi,
29 void *(*bootstrap_map)(const module_t *))
30 {
31 int i;
32 module_t *mod = (module_t *)__va(mbi->mods_addr);
33 int rc = 0;
34 u32 *_policy_start;
35 unsigned long start, _policy_len;
37 /*
38 * Try all modules and see whichever could be the binary policy.
39 * Adjust the initrdidx if module[1] is the binary policy.
40 */
41 for ( i = mbi->mods_count-1; i >= 1; i-- )
42 {
43 _policy_start = bootstrap_map(mod + i);
44 _policy_len = mod[i].mod_end;
46 if ( (xsm_magic_t)(*_policy_start) == XSM_MAGIC )
47 {
48 policy_buffer = (char *)_policy_start;
49 policy_size = _policy_len;
51 printk("Policy len 0x%lx, start at %p.\n",
52 _policy_len,_policy_start);
54 if ( i == 1 )
55 *initrdidx = (mbi->mods_count > 2) ? 2 : 0;
56 break;
58 }
60 bootstrap_map(NULL);
61 }
63 return rc;
64 }