Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5749761img; Wed, 27 Mar 2019 14:37:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8HOOR3MfZX9rnK8Hu4wGl7SRB4uI9Go76xApclI+aIB14/WeD16B96IQ0Pvqj6sZxA1vP X-Received: by 2002:a63:28f:: with SMTP id 137mr10067357pgc.377.1553722674268; Wed, 27 Mar 2019 14:37:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553722674; cv=none; d=google.com; s=arc-20160816; b=vrtZbi5V2X+pAJ/po+TP9TRa53I1ytTfl1t8f9ems0RdcfmaoVbtn8uZTe9YF0LFJf SE+gHLHzxYPS9fFjheeSZUaXtY8wa41G0dcoESe1WQFvh5nVU4TrIEFyQ9miSYEEJqWw 4xyJyJNQCl26hwgIy8goWcYRSnGiCFTxx4uqG1s1o5O+2MrEVBQVW8vOSSd46EE5BUR+ Mpd9d7ztgY6QNqPH53i12wuFUTmmoFGu2u4SKoU7pf9sjU8ziTcebIAKxDzslasZhIZt MzooTQbRYyEu1GwBKkao0V3EmB6jEv0aFGvKHDr+mDY7ahXKYvJMlaViiSOybCI0peL4 HFpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:cc:to:from; bh=w6hzd+I5Kw5xMkuKrHhNXstHvgTMyWxw1ttzaoDJK14=; b=Ohcj+ZZhMqtjtW56lTac1EcDZzkBkOuBp1ZCT0/UzJK4JiEj1o2qAB8WmT68BQneKI 8d6H2uO09IE3AabFxcQ95pl5itPGaDAV+PJXKRpp77pTWNZhmyLf0OX95vq0zAV77l1X swUl9cLvOXGnNxaefsS8A2qweJ6hAx789X+rOROuhY0csJoP7ICTk3R/NSol0BUp4aTE cQjJZ/821R/Un9hyf7mb7vwaMSktQGXS9vgvjIeSMT12Mp/bP8zsXtR6rySNVS39vw1s tS4aiuYNpOMqCKoNQBsJCz+rJni+GYWnyMIOg3RUqpKUiz711vgIeUABu+F98deuSUoY /RSg== 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 y11si19704790plk.323.2019.03.27.14.37.38; Wed, 27 Mar 2019 14:37:54 -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 S1730034AbfC0Vg7 (ORCPT + 99 others); Wed, 27 Mar 2019 17:36:59 -0400 Received: from ale.deltatee.com ([207.54.116.67]:58672 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728329AbfC0Vgu (ORCPT ); Wed, 27 Mar 2019 17:36:50 -0400 Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1h9GE4-0006DN-EM; Wed, 27 Mar 2019 15:36:49 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1h9GE2-0006Cq-Is; Wed, 27 Mar 2019 15:36:46 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Stephen Bates , Palmer Dabbelt , Christoph Hellwig , Albert Ou , Logan Gunthorpe , Laurent Dufour , Mike Rapoport , Anup Patel , Zong Li , Guo Ren , "Stefan O'Rear" Date: Wed, 27 Mar 2019 15:36:43 -0600 Message-Id: <20190327213643.23789-8-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190327213643.23789-1-logang@deltatee.com> References: <20190327213643.23789-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, sbates@raithlin.com, palmer@sifive.com, hch@lst.de, aou@eecs.berkeley.edu, logang@deltatee.com, ldufour@linux.vnet.ibm.com, rppt@linux.vnet.ibm.com, anup.patel@wdc.com, zong@andestech.com, ren_guo@c-sky.com, sorear2@gmail.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-6.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, MYRULES_NO_TEXT autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH 7/7] RISC-V: Implement pte_devmap() X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the 2nd software bit in the PTE as the devmap bit and add the appropriate accessors. This also allows us to set ARCH_HAS_ZONE_DEVICE. Signed-off-by: Logan Gunthorpe Cc: Palmer Dabbelt Cc: Albert Ou Cc: Laurent Dufour Cc: Mike Rapoport Cc: Anup Patel Cc: Zong Li Cc: Guo Ren Cc: "Stefan O'Rear" --- arch/riscv/Kconfig | 1 + arch/riscv/include/asm/pgtable-bits.h | 8 ++++++-- arch/riscv/include/asm/pgtable.h | 10 ++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 2cb39b4d6d6b..d365d7e17ed2 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -49,6 +49,7 @@ config RISCV select GENERIC_IRQ_MULTI_HANDLER select ARCH_HAS_PTE_SPECIAL select HAVE_EBPF_JIT if 64BIT + select ARCH_HAS_ZONE_DEVICE config MMU def_bool y diff --git a/arch/riscv/include/asm/pgtable-bits.h b/arch/riscv/include/asm/pgtable-bits.h index 470755cb7558..9555d419a46f 100644 --- a/arch/riscv/include/asm/pgtable-bits.h +++ b/arch/riscv/include/asm/pgtable-bits.h @@ -30,9 +30,11 @@ #define _PAGE_GLOBAL (1 << 5) /* Global */ #define _PAGE_ACCESSED (1 << 6) /* Set by hardware on any access */ #define _PAGE_DIRTY (1 << 7) /* Set by hardware on any write */ -#define _PAGE_SOFT (1 << 8) /* Reserved for software */ +#define _PAGE_SOFT1 (1 << 8) /* Reserved for software */ +#define _PAGE_SOFT2 (1 << 9) /* Reserved for software */ -#define _PAGE_SPECIAL _PAGE_SOFT +#define _PAGE_SPECIAL _PAGE_SOFT1 +#define _PAGE_DEVMAP _PAGE_SOFT2 #define _PAGE_TABLE _PAGE_PRESENT /* @@ -41,6 +43,8 @@ */ #define _PAGE_PROT_NONE _PAGE_READ +#define __HAVE_ARCH_PTE_DEVMAP + #define _PAGE_PFN_SHIFT 10 /* Set of bits to preserve across pte_modify() */ diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index e071e2be3a6c..a0e6a5f8bbb5 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -248,6 +248,11 @@ static inline int pte_special(pte_t pte) return pte_val(pte) & _PAGE_SPECIAL; } +static inline int pte_devmap(pte_t pte) +{ + return pte_val(pte) & _PAGE_DEVMAP; +} + /* static inline pte_t pte_rdprotect(pte_t pte) */ static inline pte_t pte_wrprotect(pte_t pte) @@ -289,6 +294,11 @@ static inline pte_t pte_mkspecial(pte_t pte) return __pte(pte_val(pte) | _PAGE_SPECIAL); } +static inline pte_t pte_mkdevmap(pte_t pte) +{ + return __pte(pte_val(pte) | _PAGE_SPECIAL | _PAGE_DEVMAP); +} + /* Modify page protection bits */ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) { -- 2.20.1