Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3755211pxk; Tue, 8 Sep 2020 01:18:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOkEjHmb+RTId5EJGyq4v3+htt3rXe3rFIhLuLaReReOoQ4WL5FzC0dpXjYtVksLXtviTl X-Received: by 2002:a17:906:a101:: with SMTP id t1mr5080477ejy.203.1599553124931; Tue, 08 Sep 2020 01:18:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599553124; cv=none; d=google.com; s=arc-20160816; b=y2KB9hEvldpyi8jqtd9Lp3LHnpQyCEGfPYnfMk2+vrbzu6APGbYgDm9ifIf7brfQuu 4duRdH6avGSv5N0GMpHoEz+lvArl5oPTuCfLYpB7ACrNwgaNnzzwMVjBaJ+U2GhkrEDk 8zqlC1fCDJ1W21q4H8uIah0QMim6mY6fZpw08B7PFGSdkrIBlVXwilJBZlQQuvLYOMJ+ 4bB6wq98gMOeFaYjvddONEdTUW0ENrYlFNWf6Q4DlzxsNz+2nsm55j3x+tZp7gOi9+8f taxLDuV549INZ/26Dl8He4BnQ4vcvA7iWkDqpRr9DDqN6/WFRpC1coRgK7vFc5uurCMW 4aJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=7Ek+0nAEykCpr9UwcN7zaGMTy3d2/+wzks8laHpHmsI=; b=aJGNkQj8APkr5SdpoyMazpihc7UexepS/WsOWpG2CsYnNtcI7NEQpf/lJ3IcTdjQX3 WTYZLdxwgKWO8WN/EZuz8dUqlEhhbHZs/0bhGipWOLRC9w1AEHynPHIpft30Hn6ZnSmb JmjEn5BAbr6W2YClBp2m2SdYZhPQNtWXFusQ+jPeB5IU3bMZQu/VFiltdAmpiInARkOz 4GMDJlxyLvUmeQVPHjgi0+3I2cgUVJOBa88SKSiOAialqsCquOSBrCtMyUIgIP9vmE0b I0PUQnHB4BKGy8jZZK+4WHItUju9YStWqyG8AOKXJguqV5azma3Y9eND9MwZLxI+evwF UT4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m26si11072077ejc.349.2020.09.08.01.18.22; Tue, 08 Sep 2020 01:18:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730000AbgIHIRe (ORCPT + 99 others); Tue, 8 Sep 2020 04:17:34 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:20076 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729432AbgIHIRb (ORCPT ); Tue, 8 Sep 2020 04:17:31 -0400 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 Cc: Gerald Schaefer , Jason Gunthorpe , John Hubbard , Peter Zijlstra , Dave Hansen , linux-mm , Paul Mackerras , linux-sparc , Claudio Imbrenda , Will Deacon , linux-arch , linux-s390 , Vasily Gorbik , Richard Weinberger , linux-x86 , Russell King , Christian Borntraeger , Ingo Molnar , Catalin Marinas , Andrey Ryabinin , Heiko Carstens , Arnd Bergmann , Jeff Dike , linux-um , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , linux-arm , linux-power , LKML , Andrew Morton , Linus Torvalds , Mike Rapoport 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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