From: Sukadev Bhattiprolu Date: Thu, 24 Mar 2016 06:07:57 +0000 (-0400) Subject: powerpc/mm: Add memory barrier in __hugepte_alloc() X-Git-Tag: v4.8-rc1~85^2~12 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=0eab46be21449f1612791201aa029facb676bd31;p=karo-tx-linux.git powerpc/mm: Add memory barrier in __hugepte_alloc() __hugepte_alloc() uses kmem_cache_zalloc() to allocate a zeroed PTE and proceeds to use the newly allocated PTE. Add a memory barrier to make sure that the other CPUs see a properly initialized PTE. Based on a fix suggested by James Dykman. Reported-by: James Dykman Signed-off-by: Aneesh Kumar K.V Signed-off-by: Sukadev Bhattiprolu Tested-by: James Dykman Signed-off-by: Michael Ellerman --- diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index 5aac1a3f86cd..6be21e0f9095 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -81,6 +81,13 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, if (! new) return -ENOMEM; + /* + * Make sure other cpus find the hugepd set only after a + * properly initialized page table is visible to them. + * For more details look for comment in __pte_alloc(). + */ + smp_wmb(); + spin_lock(&mm->page_table_lock); #ifdef CONFIG_PPC_FSL_BOOK3E /*