From patchwork Wed Feb 27 17:05:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10832161 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B73D922 for ; Wed, 27 Feb 2019 18:11:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B6E42EAA0 for ; Wed, 27 Feb 2019 18:11:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0EC942EB0C; Wed, 27 Feb 2019 18:11:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A6E892EAE9 for ; Wed, 27 Feb 2019 18:11:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=c4DwnQdWMfhBinWz6biUhpqVC7gJWk/NgR8LvQRJUGo=; b=HO1TSyY/79LV5P jeln+nrTeSGASBxXyo9zAyBpl6s86r31MZiQx13xVkKtivRDqjdBkZS5APz2BCmZ2LBMNsivFNzgh SQsZc2yoUxnjmdRToDWVqni6r4HjFJkG0W40ea7c+HVcFU57HqOcX9axJPmq/Pqu0fD140xcE+PAg 7v5lKUlolNRPig4hUUWHJgYv6C1Kwn8zUoveWIV5TRI3BXChIZ2P12ke5gfJID6U3Q/WmrsYufgRP xQg42pVMP6SFV21NEXIB6xPwTE9aau19vu9SdANaxASGs9FcC63FBc4Z90SelOOP+SGL8Swz4fT7j fRITGgwA1F/F2i4Ocu3A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gz3ff-0006Sg-VI; Wed, 27 Feb 2019 18:11:07 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gz3fK-00063D-GY; Wed, 27 Feb 2019 18:10:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=d7Ez4LEs1GxX+k7wJ+eVDpmUwku09yzSGsf2pAay+/c=; b=KWdbrtM+WR54WonA4PgyhSk5un HJSFPmxU57E/9vkY81aNOABTiPMUtNkXWtIoA5ahJtawat+rsqn76NUPgx4gj4WUG2IyDcadHo8+q +C4g7lo58Losjkuf1qFQQMntnSMDDHpodREKHNRI8xuK3+7h08EKZ+wDIg8s3R2mLWmmbPiWQMK4T blbQTLLKJ8cCmoHRQaksCj2yOyY8pQG2p/EQDw09H8B6qyEeltCUZiXLjrxfFnIbXfL8XAfTSW7Lh ZT/BErW31aC+GM8PRW/nBoqOvHedIPnHnSaDTreTst/mwS4VSKS+k5mcEsqx/oW7cXOecj5auo/KT kKR34frA==; Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gz2gA-0005Uz-1X; Wed, 27 Feb 2019 17:07:34 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B989EA78; Wed, 27 Feb 2019 09:07:33 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 13FF23F738; Wed, 27 Feb 2019 09:07:29 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Subject: [PATCH v3 17/34] riscv: mm: Add p?d_large() definitions Date: Wed, 27 Feb 2019 17:05:51 +0000 Message-Id: <20190227170608.27963-18-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190227170608.27963-1-steven.price@arm.com> References: <20190227170608.27963-1-steven.price@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190227_120734_187134_CB2D6492 X-CRM114-Status: GOOD ( 14.50 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Peter Zijlstra , Catalin Marinas , Dave Hansen , Will Deacon , "H. Peter Anvin" , linux-riscv@lists.infradead.org, "Liang, Kan" , x86@kernel.org, Steven Price , Ingo Molnar , Palmer Dabbelt , Albert Ou , Arnd Bergmann , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , linux-kernel@vger.kernel.org, James Morse Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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_large() functions/macros. For riscv a page is large 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 | 6 ++++++ arch/riscv/include/asm/pgtable.h | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/arch/riscv/include/asm/pgtable-64.h b/arch/riscv/include/asm/pgtable-64.h index 7aa0ea9bd8bb..6763c44d338d 100644 --- a/arch/riscv/include/asm/pgtable-64.h +++ b/arch/riscv/include/asm/pgtable-64.h @@ -51,6 +51,12 @@ static inline int pud_bad(pud_t pud) return !pud_present(pud); } +static inline int pud_large(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 16301966d65b..17624d7e7e8b 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -111,6 +111,12 @@ static inline int pmd_bad(pmd_t pmd) return !pmd_present(pmd); } +static inline int pmd_large(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;