From patchwork Mon Sep 17 00:44:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 10601943 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 B14926CB for ; Mon, 17 Sep 2018 00:48:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0B28294CD for ; Mon, 17 Sep 2018 00:48:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91A1F294D0; Mon, 17 Sep 2018 00:48:49 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE 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 EC326294CD for ; Mon, 17 Sep 2018 00:48:48 +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=hzAWzeZZHe+/AncrKazKLCf32T+ZneUBVzLdsIT0cxw=; b=CUFi0MV7k4FsBV XiQz4hk9lpNkxfFZ9SBXX5F6U4j7bDBExhP/9Bvc+csmBR+hjAvYgTJtd8U2DQIo0r70cVoebq23e Kpr01LM2SarsqpVcayyS35ckwTay+fWUj+R8iLrlI4ik1MKBZzY2LhavYggcbXV1lr49mUdhghOmj CMs0gJ6zYupqqQtksYd1kij+l9xbZc9Ue+mPsQyWe5mNrTnjvXC236ba+A2SafM8q4es3JXZnk3Sy 27NnrjiUbipWxS//HhlzFCxWNJPvvNA0igXoPkOJufWWxdlj/xO0vTL9qkjGrtBg9vCnGlekXul+z y6fIjIZ92RQiUbgTU44w==; 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 1g1hiK-0005Qz-AH; Mon, 17 Sep 2018 00:48:32 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g1hhE-0004uF-N1 for linux-arm-kernel@lists.infradead.org; Mon, 17 Sep 2018 00:47:38 +0000 Received: by mail-pf1-x429.google.com with SMTP id k19-v6so6731294pfi.1 for ; Sun, 16 Sep 2018 17:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PGS6nKqUJ9lJAuL339gEx3gSAHIukbdG4jY5J92aO50=; b=jtAiITlY827cbDYM7291xDxLTQZOB1khzhBFf1EGHfUHeBm7gWxLnWtGScLxNL1Mdu 2GW8ugp4q28BB5Ml/mJeLUl2+vloD1QGUj0NRiqzD2EHlbqj3r7Vq43jmuu3dJR42W/u LiWZ3Qp0LGF7aD0obd/vuavOK39DD2lc4h4BwTuvUUxGQeUlWe1PhXJgfMD6PUFLEDwi lPmsxR0meY1w9S6V7wrUb+muczrKixOE+zALN2odcf0CmnfMkNQeBXLfiuR/ysb1jLLU YKZDsb3Yw9sV7Zkg0y830fJW4VRgxQ4RF0rSNVFoeODwQ2IHZeUv+xbmvwydMp/B3qZN dt5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=PGS6nKqUJ9lJAuL339gEx3gSAHIukbdG4jY5J92aO50=; b=lJXxHEC4fX3bVfH54wm28yrYQIno8brde2kEYqEr5+S/Gpp+MgSx8EFpNeS4fmVJam yGRQ07TSA17RBhlgTXCDa4y6hTsu7vUKjGN5ffbwvJNkIT+rTHWqhNwD3EPGqvLcUmoR LM9qzRYApHiF3t8VI3F3ryfRFc3MXTWiZz+UMt4YvD8ot5ektWjYtvN3k430ckwtFSDD l0bUiBufQVqlKAQako6cwwfeAw39Y0o1v7mCQZA+WPwzZx7O7K5glXZ4Q/+D9rrAvbc7 NNRPotqsQ86n5k3R1/KerE7v+GlZOJTshItWbcsrRZ+AuoE4Odr2DKSNicGipC+IqSg+ 9Npg== X-Gm-Message-State: APzg51AjAdRf4nPCkYNBKb2nnwTf05ho6LWg/49TGXPWGUhprRUkiiyk 9gQ7fxwSmekXt3rPAPw0MSQ= X-Google-Smtp-Source: ANB0VdYoyr8MklBn37knXbkcs5GOv/llBrfyTql3oqYOR0rlw0UQRtTCpzxpw6mJTM1ZtjIAQU4UqA== X-Received: by 2002:a62:1157:: with SMTP id z84-v6mr23541419pfi.66.1537145233644; Sun, 16 Sep 2018 17:47:13 -0700 (PDT) Received: from bbox-2.seo.corp.google.com ([2401:fa00:d:10:affa:813f:5380:6613]) by smtp.gmail.com with ESMTPSA id w16-v6sm29311503pfi.101.2018.09.16.17.47.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Sep 2018 17:47:12 -0700 (PDT) From: Minchan Kim To: Andrew Morton , linux@armlinux.org.uk Subject: [PATCH v1 2/3] arm: mm: introduce L_PTE_SPECIAL Date: Mon, 17 Sep 2018 09:44:50 +0900 Message-Id: <20180917004451.174527-3-minchan@kernel.org> X-Mailer: git-send-email 2.19.0.397.gdd90340f6a-goog In-Reply-To: <20180917004451.174527-1-minchan@kernel.org> References: <20180917004451.174527-1-minchan@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180916_174724_827794_CAA27F1A X-CRM114-Status: GOOD ( 13.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: steve.capper@linaro.org, juju.sung@mediatek.com, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, Minchan Kim , miles.chen@mediatek.com, jian-min.lui@mediatek.com, kernel-team@android.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch introduces L_PTE_SPECIAL and pte functions for supporting get_user_pages_fast. Cc: Russell King Cc: Catalin Marinas Cc: Will Deacon Cc: Steve Capper Signed-off-by: Minchan Kim --- arch/arm/Kconfig | 2 +- arch/arm/include/asm/pgtable-2level.h | 3 +-- arch/arm/include/asm/pgtable-3level.h | 6 ------ arch/arm/include/asm/pgtable.h | 13 +++++++++++++ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index e8cd55a5b04c..278cf22b5aa1 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -10,7 +10,7 @@ config ARM select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_KCOV select ARCH_HAS_MEMBARRIER_SYNC_CORE - select ARCH_HAS_PTE_SPECIAL if ARM_LPAE + select ARCH_HAS_PTE_SPECIAL if (ARM_LPAE || CPU_V7 || CPU_V6 || CPUV6K) select ARCH_HAS_PHYS_TO_DMA select ARCH_HAS_SET_MEMORY select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h index 514b13c27b43..378668420642 100644 --- a/arch/arm/include/asm/pgtable-2level.h +++ b/arch/arm/include/asm/pgtable-2level.h @@ -120,6 +120,7 @@ #define L_PTE_VALID (_AT(pteval_t, 1) << 0) /* Valid */ #define L_PTE_PRESENT (_AT(pteval_t, 1) << 0) #define L_PTE_YOUNG (_AT(pteval_t, 1) << 1) +#define L_PTE_SPECIAL (_AT(pteval_t, 1) << 5) #define L_PTE_DIRTY (_AT(pteval_t, 1) << 6) #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) #define L_PTE_USER (_AT(pteval_t, 1) << 8) @@ -224,8 +225,6 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr) #define pmd_addr_end(addr,end) (end) #define set_pte_ext(ptep,pte,ext) cpu_set_pte_ext(ptep,pte,ext) -#define pte_special(pte) (0) -static inline pte_t pte_mkspecial(pte_t pte) { return pte; } /* * We don't have huge page support for short descriptors, for the moment diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h index 6d50a11d7793..b6f52e16b478 100644 --- a/arch/arm/include/asm/pgtable-3level.h +++ b/arch/arm/include/asm/pgtable-3level.h @@ -213,12 +213,6 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr) #define pmd_present(pmd) (pmd_isset((pmd), L_PMD_SECT_VALID)) #define pmd_young(pmd) (pmd_isset((pmd), PMD_SECT_AF)) -#define pte_special(pte) (pte_isset((pte), L_PTE_SPECIAL)) -static inline pte_t pte_mkspecial(pte_t pte) -{ - pte_val(pte) |= L_PTE_SPECIAL; - return pte; -} #define pmd_write(pmd) (pmd_isclear((pmd), L_PMD_SECT_RDONLY)) #define pmd_dirty(pmd) (pmd_isset((pmd), L_PMD_SECT_DIRTY)) diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h index a757401129f9..6cc7ce0e423e 100644 --- a/arch/arm/include/asm/pgtable.h +++ b/arch/arm/include/asm/pgtable.h @@ -228,6 +228,11 @@ static inline pte_t *pmd_page_vaddr(pmd_t pmd) #define pte_dirty(pte) (pte_isset((pte), L_PTE_DIRTY)) #define pte_young(pte) (pte_isset((pte), L_PTE_YOUNG)) #define pte_exec(pte) (pte_isclear((pte), L_PTE_XN)) +#ifdef CONFIG_ARCH_HAS_PTE_SPECIAL +#define pte_special(pte) (pte_isset((pte), L_PTE_SPECIAL)) +#else +#define pte_special(pte) (0) +#endif #define pte_valid_user(pte) \ (pte_valid(pte) && pte_isset((pte), L_PTE_USER) && pte_young(pte)) @@ -318,6 +323,14 @@ static inline pte_t pte_mknexec(pte_t pte) return set_pte_bit(pte, __pgprot(L_PTE_XN)); } +#ifdef CONFIG_ARCH_HAS_PTE_SPECIAL +static inline pte_t pte_mkspecial(pte_t pte) +{ + return set_pte_bit(pte, __pgprot(L_PTE_SPECIAL)); +} +#else +static inline pte_t pte_mkspecial(pte_t pte) { return pte; } +#endif static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) { const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |