From: BitKeeper B. <ri...@su...> - 2005-01-28 17:03:09
|
ChangeSet 1.1736, 2005/01/28 16:34:08+00:00, ka...@sc... Make page allocator 64-bit safe. Signed-off-by: kei...@cl... arch/x86/memory.c | 11 ++++++++--- common/page_alloc.c | 23 ++++++++++++----------- 2 files changed, 20 insertions(+), 14 deletions(-) diff -Nru a/xen/arch/x86/memory.c b/xen/arch/x86/memory.c --- a/xen/arch/x86/memory.c 2005-01-28 12:02:34 -05:00 +++ b/xen/arch/x86/memory.c 2005-01-28 12:02:34 -05:00 @@ -148,13 +148,18 @@ void __init init_frametable(void) { -#ifdef __i386__ +#if defined(__i386__) unsigned long i, p; +#endif - frame_table = (struct pfn_info *)FRAMETABLE_VIRT_START; frame_table_size = max_page * sizeof(struct pfn_info); frame_table_size = (frame_table_size + PAGE_SIZE - 1) & PAGE_MASK; +#if defined(__x86_64__) + frame_table = __va(alloc_boot_pages(frame_table_size, 4UL << 20)); +#elif defined(__i386__) + frame_table = (struct pfn_info *)FRAMETABLE_VIRT_START; + for ( i = 0; i < frame_table_size; i += (4UL << 20) ) { p = alloc_boot_pages(min(frame_table_size - i, 4UL << 20), 4UL << 20); @@ -163,9 +168,9 @@ idle_pg_table[(FRAMETABLE_VIRT_START + i) >> L2_PAGETABLE_SHIFT] = mk_l2_pgentry(p | __PAGE_HYPERVISOR | _PAGE_PSE); } +#endif memset(frame_table, 0, frame_table_size); -#endif } void arch_init_memory(void) diff -Nru a/xen/common/page_alloc.c b/xen/common/page_alloc.c --- a/xen/common/page_alloc.c 2005-01-28 12:02:34 -05:00 +++ b/xen/common/page_alloc.c 2005-01-28 12:02:34 -05:00 @@ -49,8 +49,9 @@ static unsigned long *alloc_bitmap; #define PAGES_PER_MAPWORD (sizeof(unsigned long) * 8) -#define allocated_in_map(_pn) \ -(alloc_bitmap[(_pn)/PAGES_PER_MAPWORD] & (1<<((_pn)&(PAGES_PER_MAPWORD-1)))) +#define allocated_in_map(_pn) \ +( !! (alloc_bitmap[(_pn)/PAGES_PER_MAPWORD] & \ + (1UL<<((_pn)&(PAGES_PER_MAPWORD-1)))) ) /* * Hint regarding bitwise arithmetic in map_{alloc,free}: @@ -79,13 +80,13 @@ if ( curr_idx == end_idx ) { - alloc_bitmap[curr_idx] |= ((1<<end_off)-1) & -(1<<start_off); + alloc_bitmap[curr_idx] |= ((1UL<<end_off)-1) & -(1UL<<start_off); } else { - alloc_bitmap[curr_idx] |= -(1<<start_off); - while ( ++curr_idx < end_idx ) alloc_bitmap[curr_idx] = ~0L; - alloc_bitmap[curr_idx] |= (1<<end_off)-1; + alloc_bitmap[curr_idx] |= -(1UL<<start_off); + while ( ++curr_idx < end_idx ) alloc_bitmap[curr_idx] = ~0UL; + alloc_bitmap[curr_idx] |= (1UL<<end_off)-1; } } @@ -108,13 +109,13 @@ if ( curr_idx == end_idx ) { - alloc_bitmap[curr_idx] &= -(1<<end_off) | ((1<<start_off)-1); + alloc_bitmap[curr_idx] &= -(1UL<<end_off) | ((1UL<<start_off)-1); } else { - alloc_bitmap[curr_idx] &= (1<<start_off)-1; + alloc_bitmap[curr_idx] &= (1UL<<start_off)-1; while ( ++curr_idx != end_idx ) alloc_bitmap[curr_idx] = 0; - alloc_bitmap[curr_idx] &= -(1<<end_off); + alloc_bitmap[curr_idx] &= -(1UL<<end_off); } } @@ -483,11 +484,11 @@ pfn_stamp = pg[i].tlbflush_timestamp; for ( j = 0; (mask != 0) && (j < smp_num_cpus); j++ ) { - if ( mask & (1<<j) ) + if ( mask & (1UL<<j) ) { cpu_stamp = tlbflush_time[j]; if ( !NEED_FLUSH(cpu_stamp, pfn_stamp) ) - mask &= ~(1<<j); + mask &= ~(1UL<<j); } } |