Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[POWERPC] Fix vDSO page count calculation

The recent vDSO consolidation patches broke powerpc due to a mistake
in the definition of MAXPAGES constants. This fixes it by moving to
a dynamically allocated array of pages instead as I don't like much
hard coded size limits. Also move the vdso initialisation to an initcall
since it doesn't really need to be done -that- early.

Applogies for not catching the breakage earlier, Roland _did_ CC me on
his patches a while ago, I got busy with other things and forgot to test
them.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by

Benjamin Herrenschmidt and committed by
Paul Mackerras
7ac9a137 a334bdbd

+23 -19
+23 -11
arch/powerpc/kernel/vdso.c
··· 49 49 /* Max supported size for symbol names */ 50 50 #define MAX_SYMNAME 64 51 51 52 - #define VDSO32_MAXPAGES (((0x3000 + PAGE_MASK) >> PAGE_SHIFT) + 2) 53 - #define VDSO64_MAXPAGES (((0x3000 + PAGE_MASK) >> PAGE_SHIFT) + 2) 54 - 55 52 extern char vdso32_start, vdso32_end; 56 53 static void *vdso32_kbase = &vdso32_start; 57 - unsigned int vdso32_pages; 58 - static struct page *vdso32_pagelist[VDSO32_MAXPAGES]; 54 + static unsigned int vdso32_pages; 55 + static struct page **vdso32_pagelist; 59 56 unsigned long vdso32_sigtramp; 60 57 unsigned long vdso32_rt_sigtramp; 61 58 62 59 #ifdef CONFIG_PPC64 63 60 extern char vdso64_start, vdso64_end; 64 61 static void *vdso64_kbase = &vdso64_start; 65 - unsigned int vdso64_pages; 66 - static struct page *vdso64_pagelist[VDSO64_MAXPAGES]; 62 + static unsigned int vdso64_pages; 63 + static struct page **vdso64_pagelist; 67 64 unsigned long vdso64_rt_sigtramp; 68 65 #endif /* CONFIG_PPC64 */ 66 + 67 + static int vdso_ready; 69 68 70 69 /* 71 70 * The vdso data page (aka. systemcfg for old ppc64 fans) is here. ··· 180 181 unsigned long vdso_pages; 181 182 unsigned long vdso_base; 182 183 int rc; 184 + 185 + if (!vdso_ready) 186 + return 0; 183 187 184 188 #ifdef CONFIG_PPC64 185 189 if (test_thread_flag(TIF_32BIT)) { ··· 663 661 } 664 662 665 663 666 - void __init vdso_init(void) 664 + static int __init vdso_init(void) 667 665 { 668 666 int i; 669 667 ··· 718 716 #ifdef CONFIG_PPC64 719 717 vdso64_pages = 0; 720 718 #endif 721 - return; 719 + return 0; 722 720 } 723 721 724 722 /* Make sure pages are in the correct state */ 725 - BUG_ON(vdso32_pages + 2 > VDSO32_MAXPAGES); 723 + vdso32_pagelist = kzalloc(sizeof(struct page *) * (vdso32_pages + 2), 724 + GFP_KERNEL); 725 + BUG_ON(vdso32_pagelist == NULL); 726 726 for (i = 0; i < vdso32_pages; i++) { 727 727 struct page *pg = virt_to_page(vdso32_kbase + i*PAGE_SIZE); 728 728 ClearPageReserved(pg); ··· 735 731 vdso32_pagelist[i] = NULL; 736 732 737 733 #ifdef CONFIG_PPC64 738 - BUG_ON(vdso64_pages + 2 > VDSO64_MAXPAGES); 734 + vdso64_pagelist = kzalloc(sizeof(struct page *) * (vdso64_pages + 2), 735 + GFP_KERNEL); 736 + BUG_ON(vdso64_pagelist == NULL); 739 737 for (i = 0; i < vdso64_pages; i++) { 740 738 struct page *pg = virt_to_page(vdso64_kbase + i*PAGE_SIZE); 741 739 ClearPageReserved(pg); ··· 749 743 #endif /* CONFIG_PPC64 */ 750 744 751 745 get_page(virt_to_page(vdso_data)); 746 + 747 + smp_wmb(); 748 + vdso_ready = 1; 749 + 750 + return 0; 752 751 } 752 + arch_initcall(vdso_init); 753 753 754 754 int in_gate_area_no_task(unsigned long addr) 755 755 {
-3
arch/powerpc/mm/mem.c
··· 384 384 initsize >> 10); 385 385 386 386 mem_init_done = 1; 387 - 388 - /* Initialize the vDSO */ 389 - vdso_init(); 390 387 } 391 388 392 389 /*
-5
include/asm-powerpc/vdso.h
··· 18 18 19 19 #ifndef __ASSEMBLY__ 20 20 21 - extern unsigned int vdso64_pages; 22 - extern unsigned int vdso32_pages; 23 - 24 21 /* Offsets relative to thread->vdso_base */ 25 22 extern unsigned long vdso64_rt_sigtramp; 26 23 extern unsigned long vdso32_sigtramp; 27 24 extern unsigned long vdso32_rt_sigtramp; 28 - 29 - extern void vdso_init(void); 30 25 31 26 #else /* __ASSEMBLY__ */ 32 27