Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp761585ybl; Fri, 6 Dec 2019 05:55:23 -0800 (PST) X-Google-Smtp-Source: APXvYqyXHIX/LkXmzdxBGRfTvIEUZxpBjp1eO5XineuL46Rvmah4d9Cd2FHnYYJwHgrWeMxEvLq/ X-Received: by 2002:aca:d803:: with SMTP id p3mr6600297oig.13.1575640523283; Fri, 06 Dec 2019 05:55:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575640523; cv=none; d=google.com; s=arc-20160816; b=LyCn8BbHvaezcyNAsM+xbeOdO/9zn51RD18akDCMM8zUVRTzFQQR5sanlPZu+50EJY 7h3fQgZiBV6QbT7sBnZKI7/GcuwELQiVjGX7630DVBvdqRdPTODi37OLcYxQV6B3toeD C3UYb8G0rXQ2IR4q9VQjVFd/at/Gw03LKN2TJRdfNL7mYjNYC/yXL7nVVE6RM21rvlha aeiNgJSoxG43AvUtHHvcNDrvJXREIiRs76blEYyVgRe4dNyogwY7tUdtUwV4mpeetL3R jtAfrskXVeXSffNLNC2ff00rUW90FbT7CXz6EzAxv213lngliiNS6cWThZtDRDBk+dh2 PGTw== 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=Ex82G6gYS1crw+YJCIjC4u3OW7Wo09p2wIY2iG4MNOk=; b=ZmVu+fJHRsbcpgFYQkLiOZT3eQCS/F7lSrgyEKMHnv4G/o9aTrlqYA0zxE/cShi9qm YNbqLR+TtuvA6+CUOo26JN+Gmjhl2pI+HU/YuUPk+J3cP0+7yBLLZ928dWb0JRUQ6icd ls13zIZw1oaUH9eqMgVnyG9lqhMNW67LjB4oPE4MsmoaMPuob42RYtrBDGkNX20dCVZl Rt+wuSckRmyw6syGC7Es9hkKlsXIaDsScieu+CHOtgf5KztXoaFcrInt6Cgc0vrrFNJA BGAKH95WB1V2I5jMILTFRrQWtQMiWkeHbWr+clGRr9W3EO1Vcf8vca0U4iUUrIeGjBiH QGfw== 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 d6si6918567otq.41.2019.12.06.05.55.11; Fri, 06 Dec 2019 05:55:23 -0800 (PST) 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 S1726608AbfLFNyI (ORCPT + 99 others); Fri, 6 Dec 2019 08:54:08 -0500 Received: from foss.arm.com ([217.140.110.172]:44582 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726579AbfLFNyF (ORCPT ); Fri, 6 Dec 2019 08:54:05 -0500 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 915941FB; Fri, 6 Dec 2019 05:54:04 -0800 (PST) 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 6373D3F718; Fri, 6 Dec 2019 05:54:01 -0800 (PST) From: Steven Price To: Andrew Morton , 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" , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, Alexandre Ghiti , Zong Li , Paul Walmsley Subject: [PATCH v16 07/25] riscv: mm: Add p?d_leaf() definitions Date: Fri, 6 Dec 2019 13:52:58 +0000 Message-Id: <20191206135316.47703-8-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191206135316.47703-1-steven.price@arm.com> References: <20191206135316.47703-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 Reviewed-by: Zong Li 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..4c4d2c65ba6c 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 7ff0ed4f292e..5cf96b2b4d5a 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -105,6 +105,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