From: Keir Fraser Date: Wed, 1 Sep 2010 09:21:41 +0000 (+0100) Subject: x86_64: Ensure frame-table compression leaves MAX_ORDER aligned X-Git-Tag: 4.0.2-rc1~93 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=bde635b09833f8e8f9c1257e74de0ec81563eb30;p=people%2Fvhanquez%2Fxen.git x86_64: Ensure frame-table compression leaves MAX_ORDER aligned contiguous ranges of page_info structs. This allows page-pointer arithmetic in places like our buddy allocator. This restriction was already implicitly guaranteed, but it is good to make it explicit in the pdx-related initialisation. Signed-off-by: Keir Fraser xen-unstable changeset: 972d90ff3134 xen-unstable date: Wed Sep 01 10:17:49 2010 +0100 --- diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 47b2f8bc9..7f46fbef6 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -163,9 +163,15 @@ void *do_page_walk(struct vcpu *v, unsigned long addr) void __init pfn_pdx_hole_setup(unsigned long mask) { - unsigned int i, j, bottom_shift, hole_shift; + unsigned int i, j, bottom_shift = 0, hole_shift = 0; - for ( hole_shift = bottom_shift = j = 0; ; ) + /* + * We skip the first MAX_ORDER bits, as we never want to compress them. + * This guarantees that page-pointer arithmetic remains valid within + * contiguous aligned ranges of 2^MAX_ORDER pages. Among others, our + * buddy allocator relies on this assumption. + */ + for ( j = MAX_ORDER-1; ; ) { i = find_next_zero_bit(&mask, BITS_PER_LONG, j); j = find_next_bit(&mask, BITS_PER_LONG, i);