From patchwork Fri May 17 19:00:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 13667318 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 58A9FC25B78 for ; Fri, 17 May 2024 19:00:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF6386B00A3; Fri, 17 May 2024 15:00:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA5796B00A4; Fri, 17 May 2024 15:00:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6F176B00A5; Fri, 17 May 2024 15:00:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A8C936B00A3 for ; Fri, 17 May 2024 15:00:51 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 230231204CC for ; Fri, 17 May 2024 19:00:51 +0000 (UTC) X-FDA: 82128804702.07.FFA6B67 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf06.hostedemail.com (Postfix) with ESMTP id CB9D6180014 for ; Fri, 17 May 2024 19:00:48 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715972449; 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=B/4uJaBtjLqbS9p0On3NqGB5zQfZ1TQqFbTUkshGDFU=; b=ABDlbenTb7mP9QBTEm2KVtCt/MCmcPSlsg2eGWXtbcg6T+pcifSAgQ5R5FqsvQ4nYqBRJl b6+L+ri6unjPOHH1v5yuQB62DZyyXNlBgD4RcBt42Oht6ygMDTcQjOcvhzqRBK0l4MF+Er lPmh+BJ5hyY+OtlOZi+w3zuMcSeuzS4= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715972449; a=rsa-sha256; cv=none; b=VQI8/AE6hbHyLPkVVJXpP47l1ZtTxqEwgcGP1nLcC9xBUw5t62WEuFLZ9fETrZySakfPn9 F/Gn2aHZJ/EkRfUWW6dlGzu5FH54U2p34BlVCCpAM90CRB/4btCkku9GybqYdUkxG0u9xf U1bwUhVkfNk8sjFEH/mjMXlJuWfLGIk= Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4Vgx9V19jLz9t9W; Fri, 17 May 2024 21:00:14 +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 eKTUd7JkpiBX; Fri, 17 May 2024 21:00:14 +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 4Vgx9N6CJPz9sx4; Fri, 17 May 2024 21:00:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id D0D6A8B775; Fri, 17 May 2024 21:00:08 +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 7lIzL2huhLzn; Fri, 17 May 2024 21:00:08 +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 57D4D8B766; 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 10/20] powerpc/mm: Fix __find_linux_pte() on 32 bits with PMD leaf entries Date: Fri, 17 May 2024 21:00:04 +0200 Message-ID: <41bf05806501c0091a7d52e118b187416d24a76f.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=1715972396; l=1880; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=kVzvPEvnbNpLZgrsFncGoYKqpWB/WmWN/OrrU/zv3+M=; b=DrH60uKcoJ3TUqUVGJIHzeRTo/QEhq0NbZwQuSmTPJNyu+FPGl+QcTNq8333LXYou56YwLHFh MrWGMpoXWbAAPQ7XmRGjg4SFszqdGu3pTjfeZJ8t6mKltezMEOFfrbG X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= X-Rspamd-Queue-Id: CB9D6180014 X-Stat-Signature: 49az7jrqe96qmjcz8tiew6tr1st9rgb3 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag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ZlYDD88D1kEY/PynDBrLwwC07fKb5QbcdHZWJMckqgAcszRqLc/QaqiJmKH0ok0Zc5Bzfw0/oftUj3DXgKmQxY8Od1BXibRGpjUt1stEc= 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: Building on 32 bits with pmd_leaf() not returning always false leads to the following error: CC arch/powerpc/mm/pgtable.o arch/powerpc/mm/pgtable.c: In function '__find_linux_pte': arch/powerpc/mm/pgtable.c:506:1: error: function may return address of local variable [-Werror=return-local-addr] 506 | } | ^ arch/powerpc/mm/pgtable.c:394:15: note: declared here 394 | pud_t pud, *pudp; | ^~~ arch/powerpc/mm/pgtable.c:394:15: note: declared here This is due to pmd_offset() being a no-op in that case. So rework it for powerpc/32 so that pXd_offset() are used on real pointers and not on on-stack copies. Signed-off-by: Christophe Leroy --- arch/powerpc/mm/pgtable.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c index 59f0d7706d2f..51ee508eeb5b 100644 --- a/arch/powerpc/mm/pgtable.c +++ b/arch/powerpc/mm/pgtable.c @@ -390,8 +390,12 @@ pte_t *__find_linux_pte(pgd_t *pgdir, unsigned long ea, bool *is_thp, unsigned *hpage_shift) { pgd_t *pgdp; - p4d_t p4d, *p4dp; - pud_t pud, *pudp; + p4d_t *p4dp; + pud_t *pudp; +#ifdef CONFIG_PPC64 + p4d_t p4d; + pud_t pud; +#endif pmd_t pmd, *pmdp; pte_t *ret_pte; hugepd_t *hpdp = NULL; @@ -412,6 +416,7 @@ pte_t *__find_linux_pte(pgd_t *pgdir, unsigned long ea, */ pgdp = pgdir + pgd_index(ea); p4dp = p4d_offset(pgdp, ea); +#ifdef CONFIG_PPC64 p4d = READ_ONCE(*p4dp); pdshift = P4D_SHIFT; @@ -452,6 +457,11 @@ pte_t *__find_linux_pte(pgd_t *pgdir, unsigned long ea, pdshift = PMD_SHIFT; pmdp = pmd_offset(&pud, ea); +#else + p4dp = p4d_offset(pgdp, ea); + pudp = pud_offset(p4dp, ea); + pmdp = pmd_offset(pudp, ea); +#endif pmd = READ_ONCE(*pmdp); /*