Fix T_INFO_FIRST_OFFSET calculation This wasn't defined correctly, thus allowing in the num_online_cpus() == NR_CPUS case to pass a corrupted MFN to Dom0. Reported-by: Jan Beulich Signed-off-by: George Dunlap diff -r 39f71ef422bd xen/common/trace.c --- a/xen/common/trace.c Tue Jun 29 17:23:53 2010 +0100 +++ b/xen/common/trace.c Wed Jun 30 15:50:33 2010 +0100 @@ -50,8 +50,11 @@ static struct t_info *t_info; #define T_INFO_PAGES 2 /* Size fixed at 2 pages for now. */ #define T_INFO_SIZE ((T_INFO_PAGES)*(PAGE_SIZE)) -/* t_info.tbuf_size + list of mfn offsets + 1 to round up / sizeof uint32_t */ -#define T_INFO_FIRST_OFFSET ((sizeof(int16_t) + NR_CPUS * sizeof(int16_t) + 1) / sizeof(uint32_t)) +/* Return the number of elements _type necessary to store at least _x bytes of data + * i.e., sizeof(_type) * ans >= _x. */ +#define fit_to_type(_type, _x) (((_x)+sizeof(_type)-1) / sizeof(_type)) +/* t_info.tbuf_size + list of mfn offsets rounded up / sizeof uint32_t */ +#define T_INFO_FIRST_OFFSET fit_to_type( uint32_t, (sizeof(int16_t) + NR_CPUS * sizeof(int16_t)) ) static DEFINE_PER_CPU_READ_MOSTLY(struct t_buf *, t_bufs); static DEFINE_PER_CPU_READ_MOSTLY(unsigned char *, t_data); static DEFINE_PER_CPU_READ_MOSTLY(spinlock_t, t_lock);