Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1727297ybg; Sat, 19 Oct 2019 01:11:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXGsgasKkRvtcJPXS3kPUzMSntRCS0KjfT0xQ4VOP3OtPbQx5FgDfk0Rkpxk+/HDUw50bk X-Received: by 2002:a50:ee81:: with SMTP id f1mr14031653edr.243.1571472685416; Sat, 19 Oct 2019 01:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571472685; cv=none; d=google.com; s=arc-20160816; b=fK3nCbMeSatxTGXrf0A16K8PZrouPkOAo9L5ysJyfu+xUtVS1jOXe3b8DHWE9Zw7df T7nLj8/J5cUy6b9wnqaJcMZ8d1XODAnA+On7RiCs1TiYNZN9v/CfkfB+7CCMqYXautuw 1opf9RowPRVPm8eplq8K4E1c46gsKSV9Zp7aZoJAvfJ2CNreyWnptDWQrcg0jYY9xo+Q ZwT2T0mK2iNFs+fvFckFWNCdZY/S/fSPj+WKsoMqeu+f/BL7OH3NBnlYk4TQmfnqaWy6 s5alTy9G1LfKr0QQAhR2B+x7TPy7pwzkOr5BHt7hCqvghhAK0fkp5v6vuJk3EyEGT4W8 kZaw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=cNVL+PP6BBGhdBKx3oO5rtHzVN9chpTtdcEtVk88EUY=; b=FA6o7kdxkvyBMnOYoM6LZICC8GqSCCn8RuinX5jH7IVxT1KDq847bHQk9L26Y7up26 gsm16g6FRYRVNf7ouW8lIY5MODjdEDNK1Mbw5ngliwih+E8/aZcbXgDkP8RCJzNRc3G9 JVp0BbP9UbCCfz2jD5foFgACbW9qHT3rPAETGRugLX7kaKuT5Mc2vr4PXg/0ixTed9Vh NBbfvLo+SIDCang/ylfLYR8A9Mi1kJksfGRynyIqIATEnBzpeNu0AU9KJwoVnp8ekVWO /MwZWvUwZbxpP55eR+ju0Bw9FiNNGi0Qvy5vynm6Rha8bzISLOzsjopdt5X/1LE71Gi3 NL8w== 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 s21si895011edm.311.2019.10.19.01.11.02; Sat, 19 Oct 2019 01:11:25 -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 S2442473AbfJRKNu (ORCPT + 99 others); Fri, 18 Oct 2019 06:13:50 -0400 Received: from [217.140.110.172] ([217.140.110.172]:32776 "EHLO foss.arm.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S2442460AbfJRKNs (ORCPT ); Fri, 18 Oct 2019 06:13:48 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 505165B1; Fri, 18 Oct 2019 03:13:22 -0700 (PDT) Received: from e112269-lin.cambridge.arm.com (e112269-lin.cambridge.arm.com [10.1.194.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 33FF43F6C4; Fri, 18 Oct 2019 03:13:19 -0700 (PDT) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , 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, Alexandre Ghiti , Paul Walmsley Subject: [PATCH v12 07/22] riscv: mm: Add p?d_leaf() definitions Date: Fri, 18 Oct 2019 11:12:33 +0100 Message-Id: <20191018101248.33727-8-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191018101248.33727-1-steven.price@arm.com> References: <20191018101248.33727-1-steven.price@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Alexandre Ghiti Acked-by: Paul Walmsley # for arch/riscv 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; -- 2.20.1