diff -r 68b27338e2e4 -r 64a50f90db68 xen/xsm/xsm_policy.c --- a/xen/xsm/xsm_policy.c Wed Mar 7 18:30:23 2007 -0500 +++ b/xen/xsm/xsm_policy.c Thu Mar 8 11:14:22 2007 -0500 @@ -31,46 +31,34 @@ int xsm_policy_init(unsigned int *initrd int i; module_t *mod = (module_t *)__va(mbi->mods_addr); int rc = 0; - u32 *_policy_start; - unsigned long _policy_len; - - if (mbi->mods_count > 1) - *initrdidx = 1; + char *_policy_start; + unsigned long start, _policy_len; /* * Try all modules and see whichever could be the binary policy. * Adjust the initrdidx if module[1] is the binary policy. */ for (i = mbi->mods_count-1; i >= 1; i--) { + start = initial_images_start + (mod[i].mod_start-mod[0].mod_start); #if defined(__i386__) - _policy_start = (u32 *)(initial_images_start + (mod[i].mod_start-mod[0].mod_start)); + _policy_start = (char *)start; #elif defined(__x86_64__) - _policy_start = __va(initial_images_start + (mod[i].mod_start-mod[0].mod_start)); -#else -#error Architecture unsupported by XSM + _policy_start = __va(start); #endif _policy_len = mod[i].mod_end - mod[i].mod_start; if ((xsm_magic_t)(*_policy_start) == XSM_MAGIC) { - policy_buffer = (char *)_policy_start; + policy_buffer = _policy_start; policy_size = _policy_len; printk("Policy len 0x%lx, start at %p.\n", _policy_len,_policy_start); - if (i == 1) { - if (mbi->mods_count > 2) { - *initrdidx = 2; - } else { - *initrdidx = 0; - } - } else { - *initrdidx = 1; - } - + if ( i == 1 ) + *initrdidx = (mbi->mods_count > 2) ? 2 : 0; break; - } /* end if a binary policy definition, i.e., (ntohl(pol->magic) == XSM_MAGIC ) */ + } } return rc;