[PATCH] powerpc: fix for hugepage areas straddling 4GB boundary

Commit 7d24f0b8a53261709938ffabe3e00f88f6498df9 fixed bugs in the ppc64 SLB
miss handler with respect to hugepage handling, and in the process tweaked
the semantics of the hugepage address masks in mm_context_t.

Unfortunately, it left out a couple of necessary changes to go with that
change. First, the in_hugepage_area() macro was not updated to match,
second prepare_hugepage_range() was not updated to correctly handle
hugepages regions which straddled the 4GB point.

The latter appears only to cause process-hangs when attempting to map such
a region, but the former can cause oopses if a get_user_pages() is
triggered at the wrong point. This patch addresses both bugs.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by David Gibson and committed by Linus Torvalds 5e391dc9 e9b15b54

+6 -6
+3 -3
arch/powerpc/mm/hugetlbpage.c
··· 287 287 288 288 int prepare_hugepage_range(unsigned long addr, unsigned long len) 289 289 { 290 - int err; 290 + int err = 0; 291 291 292 292 if ( (addr+len) < addr ) 293 293 return -EINVAL; 294 294 295 - if ((addr + len) < 0x100000000UL) 295 + if (addr < 0x100000000UL) 296 296 err = open_low_hpage_areas(current->mm, 297 297 LOW_ESID_MASK(addr, len)); 298 - else 298 + if ((addr + len) >= 0x100000000UL) 299 299 err = open_high_hpage_areas(current->mm, 300 300 HTLB_AREA_MASK(addr, len)); 301 301 if (err) {
+3 -3
include/asm-powerpc/page_64.h
··· 135 135 136 136 #define in_hugepage_area(context, addr) \ 137 137 (cpu_has_feature(CPU_FTR_16M_PAGE) && \ 138 - ( ((1 << GET_HTLB_AREA(addr)) & (context).high_htlb_areas) || \ 139 - ( ((addr) < 0x100000000L) && \ 140 - ((1 << GET_ESID(addr)) & (context).low_htlb_areas) ) ) ) 138 + ( ( (addr) >= 0x100000000UL) \ 139 + ? ((1 << GET_HTLB_AREA(addr)) & (context).high_htlb_areas) \ 140 + : ((1 << GET_ESID(addr)) & (context).low_htlb_areas) ) ) 141 141 142 142 #else /* !CONFIG_HUGETLB_PAGE */ 143 143