Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4453821ybp; Mon, 7 Oct 2019 08:39:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqz1wGr6hTlbcl+T/EBmSYGd5ykQhqpdY8qN9TzNKnqX4V+jENPesdL7UZcB4O2jkvrdrVIj X-Received: by 2002:a17:906:fae2:: with SMTP id lu34mr24108787ejb.53.1570462796811; Mon, 07 Oct 2019 08:39:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570462796; cv=none; d=google.com; s=arc-20160816; b=lqZkWUTcVXGR0FdZs3TXk15CNnMpPCqtc5Qd/27MCVzyKU/aN5Oj37NTU+PqTsRIXl ZfeGT5Rc6xdtkOxXPOUPIPMgews6/8ydLbadAvPvp9zAQGRGIipMuWDaIkOnN7Fhs+V7 KojUj5VkwdVlAInbiYR7+G5AVxhl7qd6Xg4+GCNryrwGBpPJOgJO3V2zrPaLjwJINPwD DGiv4FtcDyQGAOCh1tlyB6abKcbiV6TU2LBVxEOMyOWebRKmQ36942a08teuN+BKeGY9 Csp1CIBbVc2/VprVPcjyvKkDDMWfvTtg+TgEPwuGZBcOIUvgHgalk2ptuu4movrqzBHB 8Jdg== 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=n+URVRsKlWbxJ3lkwBHJp/yx7oZQPYI8s8KM6UScq5A=; b=jpDF9kumScYa3VENkfT6ECPgHGtIvVzxMg0JKHT5E97bWi/lnYa30fakTN/Am9JUn7 Wcir6lGW0w0vN7TeGDpzPuISCmctEB/6/i1D1sy42O4Tt5Y8zgVxYGtI1M8AZshqLAYh yFkQCyM51mylwTDviRCg+ihNpm/tawOJz9UvLO7voaodJrjjwqmHrIP4D/G0oTuQbwpm WtIX9+1EInDyrjDr/1skTSUcvOIpzw/JbnOxWPLTD71Aq2lYOFiv+pEgu8ibuI4bVTYg ReW5R2z0aNJrYmTBAair8fN8q2CucU/lf1EQQHm311pCSYMt9jDGHDGvQUhyGwxvUbDh E1tA== 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 29si7714143eje.235.2019.10.07.08.39.33; Mon, 07 Oct 2019 08:39:56 -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 S1728962AbfJGPjF (ORCPT + 99 others); Mon, 7 Oct 2019 11:39:05 -0400 Received: from foss.arm.com ([217.140.110.172]:38428 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727745AbfJGPjD (ORCPT ); Mon, 7 Oct 2019 11:39:03 -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 AB25915AB; Mon, 7 Oct 2019 08:39:02 -0700 (PDT) Received: from e112269-lin.arm.com (unknown [10.1.197.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C2AE13F6C4; Mon, 7 Oct 2019 08:38:59 -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 Subject: [PATCH v11 07/22] riscv: mm: Add p?d_leaf() definitions Date: Mon, 7 Oct 2019 16:38:07 +0100 Message-Id: <20191007153822.16518-8-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191007153822.16518-1-steven.price@arm.com> References: <20191007153822.16518-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 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