From patchwork Fri May 17 19:00:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 13667319 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63A24C04FFE for ; Fri, 17 May 2024 19:00:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B85556B00A4; Fri, 17 May 2024 15:00:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B35146B00A5; Fri, 17 May 2024 15:00:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D7726B00A6; Fri, 17 May 2024 15:00:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 79CDA6B00A4 for ; Fri, 17 May 2024 15:00:54 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2C9891C06BB for ; Fri, 17 May 2024 19:00:54 +0000 (UTC) X-FDA: 82128804828.24.0AD3161 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf06.hostedemail.com (Postfix) with ESMTP id 3BBEF18002E for ; Fri, 17 May 2024 19:00:52 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=pass (policy=quarantine) header.from=csgroup.eu ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715972452; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1LEF0FBfIWkD0Dapc9OnydL745ir+QFOaLYB1wlnJh8=; b=PBnJGHnFO6cIB4WAvJTD2J7Ye/NZyQZM6SH4newEaugRyxLKgLSz/ylPLacyB2NAyosC2Y Gb3n8PRmtXI6OphOUtWhJu7gHxvSNY833S+gDCPNYhKE4sHeuiVSRkbh2Jc1YNt6oSVtCs VkPnv5TiwflNPohjwmzCZvRn7scuMAg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715972452; a=rsa-sha256; cv=none; b=b66HXo28/4aNcbN54hHhyA/ra4B67YQQyYyuFRAbaXuGvzVj8K+VrygAx29r4SwVYI4+Te YB2G280fLt5rX43Igbme8xXbl/eqJcIpvPxy9mjYnZkE2oJkEk/AuFwuUvhh3e7rpZyPyH oZ43VETVOxhD67YF1LPt92VDyLAxI8Q= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=pass (policy=quarantine) header.from=csgroup.eu Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4Vgx9W5BDZz9tBX; Fri, 17 May 2024 21:00:15 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id APkE2dAeSGeG; Fri, 17 May 2024 21:00:15 +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 4Vgx9P35mKz9sy4; Fri, 17 May 2024 21:00:09 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 665F98B775; Fri, 17 May 2024 21:00:09 +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 1qih5qF9Tb3h; Fri, 17 May 2024 21:00:09 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.232.121]) by messagerie.si.c-s.fr (Postfix) with ESMTP id DF5778B766; Fri, 17 May 2024 21:00:08 +0200 (CEST) From: Christophe Leroy To: Andrew Morton , Jason Gunthorpe , Peter Xu , Oscar Salvador , Michael Ellerman , Nicholas Piggin Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH v2 11/20] powerpc/mm: Complement huge_pte_alloc() for all non HUGEPD setups Date: Fri, 17 May 2024 21:00:05 +0200 Message-ID: <59a1390923c40b0b83ae062e3041873292186577.1715971869.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1715972397; l=1444; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=IT/tSfyWdCwFAQquhyDiq+kzMKWp84Hw7YMsyU+LWjk=; b=xeNYo6T9SlQCmQdaVEVuhPSLO92GVMmtdd8ewCjcRyAthyc3B93Izly6FJnXDDAqd3LJCizPr Ho/DtnJbATqBF1PnhrmfagQSJ1vAzdiSBSQ3lX4IQlpG+4gBP9OGJa+ X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= X-Rspam-User: X-Stat-Signature: 4fft3qy1654xt8ehettt48t3196ai6o9 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3BBEF18002E X-HE-Tag: 1715972452-320749 X-HE-Meta: U2FsdGVkX1/vge9ctOU0Br//IjCWBqF2giS/Hb/lzM9LJaOrwQ1GXX3299WcMfAzBCyFAoNEom+ye7BiVFbg0E9HExumwbUVdEBBo8iTGOQZa2B07cm7Q6Ufs100QHxAQlWcLtbK39yLhXJtx06uHUWCQ97yE2W2SYMMU1H2sxbkZq+VVSYf6lA0K5hUqfzLIgs87o7f0j/b6xsRqbFw+VxLZC7aQngceW+9m1eK2UWYY93NIGZwvpNzloUgdHTvO3iDHS4QuWbur+96k2r+GCGo/aISaSn8vK1bH/5kEi1wALUoCKv0IfQBLjyIGIg3Rg4yHP7tJiGnv+Rig+qrP1wS9WSMhGGOUPgPUcsMOlbiUH1ejfAsWk2YiMyaQrPUXy+M2/xMKHiil5dibzDCSNhjmHEdeMWvoriJcAXr7zn9ez7krtfh+14NfUBdkt6hxpudfXU3FHPNAxUr1ipvBmw09yGwwrBBRcls4EA3TjtKadUzi+Sh3a+sgJSaY7Ha6txr73SnZldkYZC3vuvJVd7iuJ6AeYvaAgqJiLp1ZQ08fNb2cuf/EKiUMIwfs2R4BrQOF4Xkyx6C2FmBqUvugXaK8Xrz8oqumHHKySkLrFfSBdeYZX/C9xpZlk/RZV2vTHr8+xFhIqIz24C/XkJzIcmajUD6EVylI3glEaQ70V1Ng46NRWqtMitTDJqYFxT+GplW+mJTLChYETUU0pu8Z8u2SARC3Q9JX0ZHEtKbAiS29Qp26oZXjsgTlQUEGlFkNVy3FcqNRBEq3jZ+Owg0uaVBl2PuzZBHrESJ71CgvpFVNP3YD2joVCGSrQQKVgq7PAMRqnNR0AxD90GHx4P8vGbPnjHq9pp6MfXKXSHQ9lk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: huge_pte_alloc() for non-HUGEPD targets is reserved for 8xx at the moment. In order to convert other targets for non-HUGEPD, complement huge_pte_alloc() to support any standard cont-PxD setup. Signed-off-by: Christophe Leroy --- arch/powerpc/mm/hugetlbpage.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index 42b12e1ec851..f8aefa1e7363 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -195,11 +195,34 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned long sz) { - pmd_t *pmd = pmd_off(mm, addr); + pgd_t *pgd; + p4d_t *p4d; + pud_t *pud; + pmd_t *pmd; + + addr &= ~(sz - 1); + pgd = pgd_offset(mm, addr); + + p4d = p4d_offset(pgd, addr); + if (sz >= PGDIR_SIZE) + return (pte_t *)p4d; + + pud = pud_alloc(mm, p4d, addr); + if (!pud) + return NULL; + if (sz >= PUD_SIZE) + return (pte_t *)pud; + + pmd = pmd_alloc(mm, pud, addr); + if (!pmd) + return NULL; if (sz < PMD_SIZE) return pte_alloc_huge(mm, pmd, addr, sz); + if (!IS_ENABLED(CONFIG_PPC_8xx)) + return (pte_t *)pmd; + if (sz != SZ_8M) return NULL; if (!pte_alloc_huge(mm, pmd, addr, sz))