Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp505925yba; Wed, 3 Apr 2019 13:08:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeJJrtR+m04T4SXZ/n4zIDJfhfXQMNAOKLmvuM3DQ/QzEGP4iD4pjSgQBJSBSWyUGyGOCm X-Received: by 2002:a17:902:b94a:: with SMTP id h10mr2032597pls.82.1554322117181; Wed, 03 Apr 2019 13:08:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554322117; cv=none; d=google.com; s=arc-20160816; b=y+vmRLOL46L2DlWNZwI4hhGgeK3UtdHNWWE2pseTTGPBEK4XNDxjJ83j3LVtzks7n5 AN5yeKyri+FYWYwxAaOJ3m6LxYgJ43v4HJ0UQt6xGIp6hiFpVRw+HNbRMpMLXEwFf8Tj RtsOE8JsWZJLMMrnYDi5v0LrQWZU6XJih7Dbm1DDVJyXHheb9hGL5qG/BDFEyrMpXNHO 5mS+JMvTcSv2DspSJp8xLaPoRX3OiRbrzbYNr77q9S1aOyVsTkMKvFOCsExg7WLeDZ9T 4Dg1jOauNlzh05In07my9xWWjhez5mAkqhJKUYGN8tz0eSFYO9pdZKkOFZBS+qWo8oEb RKdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id:dkim-signature; bh=XiMjxBUPhiN74HOYzIXa7EKgRGmh9waO0nn5quBwI8I=; b=VtDUibr8S1uyi9Lslb9Gm59nT6iP7weBFa6pH1kUx3ELiSZhvn3x+6Gebmv49i8uvJ ZMjwlOJUez/ZG1bALSY9eis3RuAbgr1zs9vYXB19qmk0liFD4QRS+MS1l3A3sBfH/XlB kcOIxEw5IFhFApY+MGUL/RXq01gx1uHus5mhAgjnannuhtB8/5sutBKKl3gYiRcE81RM tyxBMwnQguRTMhuWDnR1wt68wgYLhpKpy1NX3Tur4b/OMp1G+E4jXN8fZ6zPU5UsdSJ5 lRSqynsCNRgAmpL3B71zogUmokdOGamjpeoCS8Ydmqn8FqTsHcAz7vJNHWR7wx1i4EPb AAig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=engR7EGy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gn11si14304849plb.205.2019.04.03.13.08.21; Wed, 03 Apr 2019 13:08:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=engR7EGy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726920AbfDCUGZ (ORCPT + 99 others); Wed, 3 Apr 2019 16:06:25 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:8856 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726843AbfDCUGW (ORCPT ); Wed, 3 Apr 2019 16:06:22 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 44ZHCJ4zxLz9v3pt; Wed, 3 Apr 2019 22:06:20 +0200 (CEST) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=engR7EGy; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id 12emPzzJmuOk; Wed, 3 Apr 2019 22:06:20 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 44ZHCJ3wJQz9v3pp; Wed, 3 Apr 2019 22:06:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1554321980; bh=XiMjxBUPhiN74HOYzIXa7EKgRGmh9waO0nn5quBwI8I=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=engR7EGy/oio3I6+XaD5RTXCY6RHfLBawyX5a6yCXJc4dGqv5KcI/Z1IVoPagpPK7 Anhx9Azot74q5gYJ7VV5mpt9BsicdtWD9GlUhU6qBrL1V2780S5x0sQyre/rKM8MgU HMaHxMqsx42aDGbyfOkgb6MLNeZ7hJkaujVUUUoU= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id AA9548B905; Wed, 3 Apr 2019 22:06:20 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 93u_JhDh0yb7; Wed, 3 Apr 2019 22:06:20 +0200 (CEST) Received: from po16846vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 83E768B902; Wed, 3 Apr 2019 22:06:20 +0200 (CEST) Received: by po16846vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 6CBFA655EC; Wed, 3 Apr 2019 20:06:20 +0000 (UTC) Message-Id: <570d98c68283d7d5039bf8e261fea9c5d891f219.1554321743.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v1 08/15] powerpc/mm: don't use pte_alloc_kernel() until slab is available on PPC32 To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , aneesh.kumar@linux.ibm.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Wed, 3 Apr 2019 20:06:20 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the same way as PPC64, implement early allocation functions and avoid calling pte_alloc_kernel() before slab is available. Signed-off-by: Christophe Leroy --- arch/powerpc/mm/pgtable_32.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c index 6e56a6240bfa..a1c3062f0665 100644 --- a/arch/powerpc/mm/pgtable_32.c +++ b/arch/powerpc/mm/pgtable_32.c @@ -43,11 +43,8 @@ EXPORT_SYMBOL(ioremap_bot); /* aka VMALLOC_END */ extern char etext[], _stext[], _sinittext[], _einittext[]; -__ref pte_t *pte_alloc_one_kernel(struct mm_struct *mm) +pte_t *pte_alloc_one_kernel(struct mm_struct *mm) { - if (!slab_is_available()) - return memblock_alloc(PTE_FRAG_SIZE, PTE_FRAG_SIZE); - return (pte_t *)pte_fragment_alloc(mm, 1); } @@ -205,7 +202,29 @@ void iounmap(volatile void __iomem *addr) } EXPORT_SYMBOL(iounmap); -int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot) +static void __init *early_alloc_pgtable(unsigned long size) +{ + void *ptr = memblock_alloc(size, size); + + if (!ptr) + panic("%s: Failed to allocate %lu bytes align=0x%lx\n", + __func__, size, size); + + return ptr; +} + +static pte_t __init *early_pte_alloc_kernel(pmd_t *pmdp, unsigned long va) +{ + if (pmd_none(*pmdp)) { + pte_t *ptep = early_alloc_pgtable(PTE_FRAG_SIZE); + + pmd_populate_kernel(&init_mm, pmdp, ptep); + } + return pte_offset_kernel(pmdp, va); +} + + +int __ref map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot) { pmd_t *pd; pte_t *pg; @@ -214,7 +233,10 @@ int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot) /* Use upper 10 bits of VA to index the first level map */ pd = pmd_offset(pud_offset(pgd_offset_k(va), va), va); /* Use middle 10 bits of VA to index the second-level map */ - pg = pte_alloc_kernel(pd, va); + if (likely(slab_is_available())) + pg = pte_alloc_kernel(pd, va); + else + pg = early_pte_alloc_kernel(pd, va); if (pg != 0) { err = 0; /* The PTE should never be already set nor present in the -- 2.13.3