From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F0CEC433E2 for ; Tue, 8 Sep 2020 08:32:42 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7CE0E215A4 for ; Tue, 8 Sep 2020 08:32:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7CE0E215A4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=csgroup.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4Blz131YrpzDqQs for ; Tue, 8 Sep 2020 18:32:39 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=csgroup.eu (client-ip=93.17.236.30; helo=pegase1.c-s.fr; envelope-from=christophe.leroy@csgroup.eu; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=csgroup.eu Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Blygd45PqzDqKL for ; Tue, 8 Sep 2020 18:17:29 +1000 (AEST) Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4BlygQ2VM3z9tyfZ; Tue, 8 Sep 2020 10:17:22 +0200 (CEST) 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 8E9ZAY1YbiyQ; Tue, 8 Sep 2020 10:17:22 +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 4BlygQ1YKJz9tyfY; Tue, 8 Sep 2020 10:17:22 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2B1BE8B7A1; Tue, 8 Sep 2020 10:17:23 +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 k9FC2ZI-dL_g; Tue, 8 Sep 2020 10:17:23 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id D4E3E8B768; Tue, 8 Sep 2020 10:17:20 +0200 (CEST) Subject: Re: [RFC PATCH v2 2/3] mm: make pXd_addr_end() functions page-table entry aware To: Alexander Gordeev , Michael Ellerman References: <20200907180058.64880-1-gerald.schaefer@linux.ibm.com> <20200907180058.64880-3-gerald.schaefer@linux.ibm.com> <31dfb3ed-a0cc-3024-d389-ab9bd19e881f@csgroup.eu> <20200908074638.GA19099@oc3871087118.ibm.com> From: Christophe Leroy Message-ID: <5d4f5546-afd0-0b8f-664d-700ae346b9ec@csgroup.eu> Date: Tue, 8 Sep 2020 10:16:49 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200908074638.GA19099@oc3871087118.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Zijlstra , Catalin Marinas , Dave Hansen , linux-mm , Paul Mackerras , linux-sparc , Claudio Imbrenda , Will Deacon , linux-arch , linux-s390 , Vasily Gorbik , Christian Borntraeger , Richard Weinberger , linux-x86 , Russell King , Jason Gunthorpe , Ingo Molnar , Andrey Ryabinin , Gerald Schaefer , Jeff Dike , Arnd Bergmann , John Hubbard , Heiko Carstens , linux-um , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , linux-arm , Linus Torvalds , LKML , Andrew Morton , linux-power , Mike Rapoport Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Le 08/09/2020 à 09:46, Alexander Gordeev a écrit : > On Tue, Sep 08, 2020 at 07:14:38AM +0200, Christophe Leroy wrote: >> You forgot arch/powerpc/mm/book3s64/subpage_prot.c it seems. > > Yes, and also two more sources :/ > arch/powerpc/mm/kasan/8xx.c > arch/powerpc/mm/kasan/kasan_init_32.c > > But these two are not quite obvious wrt pgd_addr_end() used > while traversing pmds. Could you please clarify a bit? > > > diff --git a/arch/powerpc/mm/kasan/8xx.c b/arch/powerpc/mm/kasan/8xx.c > index 2784224..89c5053 100644 > --- a/arch/powerpc/mm/kasan/8xx.c > +++ b/arch/powerpc/mm/kasan/8xx.c > @@ -15,8 +15,8 @@ > for (k_cur = k_start; k_cur != k_end; k_cur = k_next, pmd += 2, block += SZ_8M) { > pte_basic_t *new; > > - k_next = pgd_addr_end(k_cur, k_end); > - k_next = pgd_addr_end(k_next, k_end); > + k_next = pmd_addr_end(k_cur, k_end); > + k_next = pmd_addr_end(k_next, k_end); No, I don't think so. On powerpc32 we have only two levels, so pgd and pmd are more or less the same. But pmd_addr_end() as defined in include/asm-generic/pgtable-nopmd.h is a no-op, so I don't think it will work. It is likely that this function should iterate on pgd, then you get pmd = pmd_offset(pud_offset(p4d_offset(pgd))); > if ((void *)pmd_page_vaddr(*pmd) != kasan_early_shadow_pte) > continue; > > diff --git a/arch/powerpc/mm/kasan/kasan_init_32.c b/arch/powerpc/mm/kasan/kasan_init_32.c > index fb29404..3f7d6dc6 100644 > --- a/arch/powerpc/mm/kasan/kasan_init_32.c > +++ b/arch/powerpc/mm/kasan/kasan_init_32.c > @@ -38,7 +38,7 @@ int __init kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_ > for (k_cur = k_start; k_cur != k_end; k_cur = k_next, pmd++) { > pte_t *new; > > - k_next = pgd_addr_end(k_cur, k_end); > + k_next = pmd_addr_end(k_cur, k_end); Same here I get, iterate on pgd then get pmd = pmd_offset(pud_offset(p4d_offset(pgd))); > if ((void *)pmd_page_vaddr(*pmd) != kasan_early_shadow_pte) > continue; > > @@ -196,7 +196,7 @@ void __init kasan_early_init(void) > kasan_populate_pte(kasan_early_shadow_pte, PAGE_KERNEL); > > do { > - next = pgd_addr_end(addr, end); > + next = pmd_addr_end(addr, end); > pmd_populate_kernel(&init_mm, pmd, kasan_early_shadow_pte); > } while (pmd++, addr = next, addr != end); > > Christophe