* [PATCH] powerpc/kasan: fix early boot failure on PPC32
@ 2019-07-31 6:01 Christophe Leroy
2019-07-31 8:02 ` Christophe Leroy
2019-08-02 2:28 ` Michael Ellerman
0 siblings, 2 replies; 3+ messages in thread
From: Christophe Leroy @ 2019-07-31 6:01 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linux-kernel, linuxppc-dev
Due to commit 4a6d8cf90017 ("powerpc/mm: don't use pte_alloc_kernel()
until slab is available on PPC32"), pte_alloc_kernel() cannot be used
during early KASAN init.
Fix it by using memblock_alloc() instead.
Reported-by: Erhard F. <erhard_f@mailbox.org>
Fixes: 2edb16efc899 ("powerpc/32: Add KASAN support")
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/mm/kasan/kasan_init_32.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/mm/kasan/kasan_init_32.c b/arch/powerpc/mm/kasan/kasan_init_32.c
index 0d62be3cba47..74f4555a62ba 100644
--- a/arch/powerpc/mm/kasan/kasan_init_32.c
+++ b/arch/powerpc/mm/kasan/kasan_init_32.c
@@ -21,7 +21,7 @@ static void kasan_populate_pte(pte_t *ptep, pgprot_t prot)
__set_pte_at(&init_mm, va, ptep, pfn_pte(PHYS_PFN(pa), prot), 0);
}
-static int kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_end)
+static int __ref kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_end)
{
pmd_t *pmd;
unsigned long k_cur, k_next;
@@ -35,7 +35,10 @@ static int kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_
if ((void *)pmd_page_vaddr(*pmd) != kasan_early_shadow_pte)
continue;
- new = pte_alloc_one_kernel(&init_mm);
+ if (slab_is_available())
+ new = pte_alloc_one_kernel(&init_mm);
+ else
+ new = memblock_alloc(PTE_FRAG_SIZE, PTE_FRAG_SIZE);
if (!new)
return -ENOMEM;
--
2.13.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc/kasan: fix early boot failure on PPC32
2019-07-31 6:01 [PATCH] powerpc/kasan: fix early boot failure on PPC32 Christophe Leroy
@ 2019-07-31 8:02 ` Christophe Leroy
2019-08-02 2:28 ` Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Christophe Leroy @ 2019-07-31 8:02 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linuxppc-dev, linux-kernel
Le 31/07/2019 à 08:01, Christophe Leroy a écrit :
> Due to commit 4a6d8cf90017 ("powerpc/mm: don't use pte_alloc_kernel()
> until slab is available on PPC32"), pte_alloc_kernel() cannot be used
> during early KASAN init.
>
> Fix it by using memblock_alloc() instead.
>
> Reported-by: Erhard F. <erhard_f@mailbox.org>
> Fixes: 2edb16efc899 ("powerpc/32: Add KASAN support")
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Cc: stable@vger.kernel.org
> ---
> arch/powerpc/mm/kasan/kasan_init_32.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/mm/kasan/kasan_init_32.c b/arch/powerpc/mm/kasan/kasan_init_32.c
> index 0d62be3cba47..74f4555a62ba 100644
> --- a/arch/powerpc/mm/kasan/kasan_init_32.c
> +++ b/arch/powerpc/mm/kasan/kasan_init_32.c
> @@ -21,7 +21,7 @@ static void kasan_populate_pte(pte_t *ptep, pgprot_t prot)
> __set_pte_at(&init_mm, va, ptep, pfn_pte(PHYS_PFN(pa), prot), 0);
> }
>
> -static int kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_end)
> +static int __ref kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_end)
> {
> pmd_t *pmd;
> unsigned long k_cur, k_next;
> @@ -35,7 +35,10 @@ static int kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_
> if ((void *)pmd_page_vaddr(*pmd) != kasan_early_shadow_pte)
> continue;
>
> - new = pte_alloc_one_kernel(&init_mm);
> + if (slab_is_available())
> + new = pte_alloc_one_kernel(&init_mm);
> + else
> + new = memblock_alloc(PTE_FRAG_SIZE, PTE_FRAG_SIZE);
>
> if (!new)
> return -ENOMEM;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc/kasan: fix early boot failure on PPC32
2019-07-31 6:01 [PATCH] powerpc/kasan: fix early boot failure on PPC32 Christophe Leroy
2019-07-31 8:02 ` Christophe Leroy
@ 2019-08-02 2:28 ` Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2019-08-02 2:28 UTC (permalink / raw)
To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras
Cc: linuxppc-dev, linux-kernel
On Wed, 2019-07-31 at 06:01:42 UTC, Christophe Leroy wrote:
> Due to commit 4a6d8cf90017 ("powerpc/mm: don't use pte_alloc_kernel()
> until slab is available on PPC32"), pte_alloc_kernel() cannot be used
> during early KASAN init.
>
> Fix it by using memblock_alloc() instead.
>
> Reported-by: Erhard F. <erhard_f@mailbox.org>
> Fixes: 2edb16efc899 ("powerpc/32: Add KASAN support")
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Applied to powerpc fixes, thanks.
https://git.kernel.org/powerpc/c/d7e23b887f67178c4f840781be7a6aa6aeb52ab1
cheers
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-08-02 2:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-31 6:01 [PATCH] powerpc/kasan: fix early boot failure on PPC32 Christophe Leroy
2019-07-31 8:02 ` Christophe Leroy
2019-08-02 2:28 ` Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).