From patchwork Thu Nov 19 00:38:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 11916271 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2347DC5519F for ; Thu, 19 Nov 2020 00:39:56 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A588F2467A for ; Thu, 19 Nov 2020 00:39:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tWmd/1Bj"; dkim=permerror (0-bit key) header.d=wdc.com header.i=@wdc.com header.b="auLqOSDG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A588F2467A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.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=QmtyHQkUUnb4E5t+cljlJK8DpC9yrZNv9TK+DvhACEA=; b=tWmd/1BjJ7enChjDk6fbiq8Lh fwe0GkMzZXMb34xqNuXbWJqAGUNCjbYQlE4sesz2e+yJouX9SzytOZj0n9j63JTH1AR7tavoWEaIh 5NWaR/3cGkywoYoV4bs+6vkryvHBOq1/Vnc2pPd77YsGxqrElaUQxj3e4i4jWCS0Wrdd4fe+Epr9T xFMRy1FjBNfUPsdF5L/ln3+/pa/XLwOu4UjaNDksvU7s9t8i+cHjmyp+iFjQG+ocvrsT8v8B1aXU4 OYKgvqXc0Chgn4VGf9FshcYnhSPdEti+u7dWX+GD/+Img69J7Gtc67KIGJO5URJ2XWJHVKApsIgh/ 2x8VzgTig==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfXyq-0006IZ-5f; Thu, 19 Nov 2020 00:39:20 +0000 Received: from esa2.hgst.iphmx.com ([68.232.143.124]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfXyD-0006CB-Ba; Thu, 19 Nov 2020 00:38:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1605746721; x=1637282721; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tBpauZx+fMSCAhtcJtgaXTjyMk4K33HNxdPCRgo5eAU=; b=auLqOSDGDeUH/ZgE0RfihCrdK7paKWK2VYIGQb40iqFI9VGRXTKVIpqh p2hcdL5J8tvKTBaTkJYhHbBsT9pBjRqF822ozxB8EEIZSIwGzmAmERaY8 RqbgCv3WtD6iw8SUme9R3RY7dAMwTC6BI+g+14BSK6yZzWSLuU8DA/F30 X/h6cLnLHh7gTl+B8WLv5rhgBLqDzhNSoiS3Vo1vx9owNgdO8fi1v/ymc jeuYs/qC8MwZc5rih/OipKrml8bpYI6W8UAjoDoZ/lr5XRsJ/sQRq0PRk Qe4yPfBhCM7jnxjfkDWjcaC/Kk2z3Oe0z3PNTqFdB0ge1c5yYczenzgvv w==; IronPort-SDR: 3bGiiIWpW+OSLnKfbEEqObRNwGP8yerBMu5XBuFBDr3Fw4OQK0yR1VMxEvTzLHUKj1+F3KZKYb nW1fXHvzbaf0BQs6KHmPDuGb/oCgLr7HVCPGC7ih47HA2/JZa6jwdPVpm6X16pJp03YwDdnltL FUacKfUIoCmhUh7+nGxfcorAUr5icVgOAtbtG7zS+lmngK/Y0+iBs9XPLSzAzXvSjAq7KOMNTB 53hpy176M34B80cWC27lWLCGuXb83AnKvLbrqYBYEcSIgkymws7qPe4GRpoIUzVhl3ahoCl8MZ dNw= X-IronPort-AV: E=Sophos;i="5.77,488,1596470400"; d="scan'208";a="256529115" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Nov 2020 08:45:18 +0800 IronPort-SDR: LSKsZZ7Eg+8HT398Ev5KTgXC5NXTXksDh6hXzQpih7aL+5IqKBJqy0tN+oNSi2Vku4v2usK3aX FafrjtUQtX0C1Syiyf2dZxBPvfOsK3HGCne294B5bbnAHRaZNa39G3Q2BBNTahA1vOBz9f97Rf HlEaO68yeEIuOvD9C+FJl8++Kp96zW61KDnN7tl0tqpKSEwgiKgRd/hT3vxM6hGodUSctmS9Hk Au3fPe3s5m1ZNXFoUzIdZ0Pp/JJfkmVrvlDTW26ePEsrBFr3FJcFfK6Iz+7kxVvGBJJE2kZKvQ ZsFaKZPJJFTPhMzNY3KB6pE7 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Nov 2020 16:23:10 -0800 IronPort-SDR: WCaCsrsQeD76vs6BFx7SRimVV5INxI7DErIY0dh+zHL6r7f7mSDPhUNFrE4WqDFTIutVZMMunu wqhTxTrVS1A9vDQVtpsuWjd/gi0VH2iIABey0qs6WV6Xv3BZacKVArX7YI67nLhsntgDW28ipN Xn4BjRUZbX1axB9UG2WOz118O/X055REKNgOJ3MBAMk7DUnaK/LdNxI5NBZ3Gzj6oL4LbP1s1d VwgDTQ2No147z99s/TxQB3G3eNk7wdpCEnmu3aYGSBmgCYjZBFQ4NDa3q2K0v3fseBt1l/zGNy 6x0= WDCIronportException: Internal Received: from 6hj08h2.ad.shared (HELO jedi-01.hgst.com) ([10.86.61.71]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Nov 2020 16:38:37 -0800 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [PATCH v5 4/5] riscv: Add support pte_protnone and pmd_protnone if CONFIG_NUMA_BALANCING Date: Wed, 18 Nov 2020 16:38:28 -0800 Message-Id: <20201119003829.1282810-5-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201119003829.1282810-1-atish.patra@wdc.com> References: <20201119003829.1282810-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201118_193841_626553_EFFBD5CE X-CRM114-Status: GOOD ( 14.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J. Wysocki" , Catalin Marinas , Palmer Dabbelt , Atish Patra , linux-riscv@lists.infradead.org, Will Deacon , Ard Biesheuvel , linux-arch@vger.kernel.org, Zhengyuan Liu , Baoquan He , Anup Patel , Daniel Lezcano , Steven Price , Greentime Hu , Albert Ou , Arnd Bergmann , Anshuman Khandual , Paul Walmsley , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , Palmer Dabbelt , Jonathan Cameron , Andrew Morton , Mike Rapoport Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Greentime Hu These two functions are used to distinguish between PROT_NONENUMA protections and hinting fault protections. Signed-off-by: Greentime Hu Reviewed-by: Anup Patel Reviewed-by: Palmer Dabbelt --- arch/riscv/include/asm/pgtable.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index a0f8a86236e8..64aba4f7a0ed 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -187,6 +187,11 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd) return (unsigned long)pfn_to_virt(pmd_val(pmd) >> _PAGE_PFN_SHIFT); } +static inline pte_t pmd_pte(pmd_t pmd) +{ + return __pte(pmd_val(pmd)); +} + /* Yields the page frame number (PFN) of a page table entry */ static inline unsigned long pte_pfn(pte_t pte) { @@ -290,6 +295,21 @@ static inline pte_t pte_mkhuge(pte_t pte) return pte; } +#ifdef CONFIG_NUMA_BALANCING +/* + * See the comment in include/asm-generic/pgtable.h + */ +static inline int pte_protnone(pte_t pte) +{ + return (pte_val(pte) & (_PAGE_PRESENT | _PAGE_PROT_NONE)) == _PAGE_PROT_NONE; +} + +static inline int pmd_protnone(pmd_t pmd) +{ + return pte_protnone(pmd_pte(pmd)); +} +#endif + /* Modify page protection bits */ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) {