Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5537269ybp; Tue, 8 Oct 2019 04:35:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDA8T7TPL1z3Vkn4qaRU082KVtAS+GcFbLXmcq+PGmhX+m4hIELntLVm8+ZTWSuHMM07LU X-Received: by 2002:a17:906:1e57:: with SMTP id i23mr28167299ejj.204.1570534550998; Tue, 08 Oct 2019 04:35:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570534550; cv=none; d=google.com; s=arc-20160816; b=KqrZvbRdGVSmq7GolcSpmkLNkqDR4xmEinr1T/ohjWkRpxYoMkj1sSE8Cm64iIqweE VLEYu5B4Eja3xk4bqTfLgNjEw5DQ5nXIPYB9UvB6rXEEmgbvWwjvm4zyZ+WTLX4u3grL RRlEqcOonbt7arlTC+5gA/O64Ys7AQ0W/zDBqrOkZ2Ssbq985fpm5JTPO8oAjePtz+8S erVg9ej2N5lPVtnzpcWyX2E4UvZGLK6lmUgYJLVsthQypB1D6dobdP7OYhY9gqH8O1KH TqHiUEVrPJs2r5tuJEx2xmJ5J+/aB0bi3LWUCsfhEpdlbivNXA17Skmsgrr1Zm8dq+hv 00cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=XHnFnRZMMeXe6bo36oOzmP+jVB71ZdM5kHvTzE0kEyc=; b=Ad9xCdunvg4amjrKXc5MINv8phHO4en/CfnuTDIXxSy3VlbBJBhuSG4OONtHcCNH5F rNMloTzPlaZNFh37Ih12ZXm0qNpxNYrBW61OsAK6SJebNMtIzkJrfA+NpzT4gRDsFTO+ wIzoJOiNGGTlnZmiBvwuQ2ZzOIkWfWUD2dq/fVjgTlJRo3J3Q2HNWHlMgtmAJmPkEaj9 ySVxMlz4ilOaDFlXm2RiRob3i9LD/NToU/QGMoQfTgvs1ETE7e9SblP8LdFSvXUQkXGd J6bSV/mvuOgK8/qyOD2gXvO9WzquA/l7GV8VJviEMa1qjJv9clfgkVR5IkBVZueDsUxP iMBw== ARC-Authentication-Results: i=1; mx.google.com; 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 w1si9808042eda.214.2019.10.08.04.35.27; Tue, 08 Oct 2019 04:35:50 -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; 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 S1730709AbfJHLb5 (ORCPT + 99 others); Tue, 8 Oct 2019 07:31:57 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:34431 "EHLO relay9-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730495AbfJHLb5 (ORCPT ); Tue, 8 Oct 2019 07:31:57 -0400 X-Originating-IP: 81.185.168.180 Received: from [192.168.43.237] (180.168.185.81.rev.sfr.net [81.185.168.180]) (Authenticated sender: alex@ghiti.fr) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 4F5AEFF809; Tue, 8 Oct 2019 11:31:43 +0000 (UTC) Subject: Re: [PATCH v11 07/22] riscv: mm: Add p?d_leaf() definitions To: Steven Price , linux-mm@kvack.org Cc: Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Peter Zijlstra , Thomas Gleixner , Will Deacon , x86@kernel.org, "H. Peter Anvin" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Rutland , "Liang, Kan" , Andrew Morton , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org References: <20191007153822.16518-1-steven.price@arm.com> <20191007153822.16518-8-steven.price@arm.com> From: Alex Ghiti Message-ID: <69a56736-4093-202a-4eaf-feeaaa0216d1@ghiti.fr> Date: Tue, 8 Oct 2019 07:31:42 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20191007153822.16518-8-steven.price@arm.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-Language: sv-FI Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/7/19 11:38 AM, Steven Price wrote: > walk_page_range() is going to be allowed to walk page tables other than > those of user space. For this it needs to know when it has reached a > 'leaf' entry in the page tables. This information is provided by the > p?d_leaf() functions/macros. > > For riscv a page is a leaf page when it has a read, write or execute bit > set on it. > > CC: Palmer Dabbelt > CC: Albert Ou > CC: linux-riscv@lists.infradead.org > Signed-off-by: Steven Price > --- > arch/riscv/include/asm/pgtable-64.h | 7 +++++++ > arch/riscv/include/asm/pgtable.h | 7 +++++++ > 2 files changed, 14 insertions(+) > > diff --git a/arch/riscv/include/asm/pgtable-64.h b/arch/riscv/include/asm/pgtable-64.h > index 74630989006d..e88a8e8acbdf 100644 > --- a/arch/riscv/include/asm/pgtable-64.h > +++ b/arch/riscv/include/asm/pgtable-64.h > @@ -43,6 +43,13 @@ static inline int pud_bad(pud_t pud) > return !pud_present(pud); > } > > +#define pud_leaf pud_leaf > +static inline int pud_leaf(pud_t pud) > +{ > + return pud_present(pud) > + && (pud_val(pud) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC)); > +} > + > static inline void set_pud(pud_t *pudp, pud_t pud) > { > *pudp = pud; > diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h > index 7255f2d8395b..b9a679153265 100644 > --- a/arch/riscv/include/asm/pgtable.h > +++ b/arch/riscv/include/asm/pgtable.h > @@ -130,6 +130,13 @@ static inline int pmd_bad(pmd_t pmd) > return !pmd_present(pmd); > } > > +#define pmd_leaf pmd_leaf > +static inline int pmd_leaf(pmd_t pmd) > +{ > + return pmd_present(pmd) > + && (pmd_val(pmd) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC)); > +} > + > static inline void set_pmd(pmd_t *pmdp, pmd_t pmd) > { > *pmdp = pmd; Hi Steven, The way you check leaf entries is correct: we do the same for hugepages. So is there a reason you did not use the pmd/pud_huge functions that are defined in arch/riscv/mm/hugetlbpage.c ? Anyway, FWIW: Reviewed-by: Alexandre Ghiti Thanks, Alex