From patchwork Tue Oct 6 00:17:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 11817989 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A8BE112E for ; Tue, 6 Oct 2020 00:18:30 +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 BE2E7206F4 for ; Tue, 6 Oct 2020 00:18:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="nK4fVySJ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="MAIcQVZf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BE2E7206F4 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-riscv-bounces+patchwork-linux-riscv=patchwork.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=edeTmFDuPgYN86XCtypOgH+XoLjNQBxjFB040y6ngkI=; b=nK4fVySJLM/0uTk/+Esh32xMQ ieJQLaLb85StHAyfrSTxhl7zvq37VD0D1hYnKwqfcUzDHPk4wwdfHpjmZCbvEPR/K06bHNCuCWWTk /zf9ICpCxcqwHzCgovSMDfEXm80T6GN+5SLx3uCBM5S7UYU/P6sFGhzWN1F2Ppx3D4VSZbfnpWlFK RPJaLQvTY8Fi3z8UaAaOIgLKE5r7n4BunFjhuGQNV7gNa/FuS1OwdplvTYFNAXdijPoNf6Ha/2okd 4gG56MNiTlbnFo72P30rm1W3LE7vCfFa5I+pe6ZOxfzWrM6KGg0arjDaNGM9kX+woZ7XhiflPJDHS LrTu7gpPw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPagK-0006uD-WD; Tue, 06 Oct 2020 00:18:17 +0000 Received: from esa3.hgst.iphmx.com ([216.71.153.141]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPag9-0006oV-As; Tue, 06 Oct 2020 00:18:06 +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=1601943485; x=1633479485; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yFZiLxGXA9elMo70n32xkkNg4f+3DGRCZkaVt0joPmw=; b=MAIcQVZf3S7lRkmvt/lc2qSrRYh4wxbkUZpHPnBfbW0N944ANzAmN8Ss 7xZwyGa7UEhml3e+BuNm0i9mmIIDMti8ktKaW47YGJo0ZbbeQpoieAN/O E6k8FA1WAKrj4xJtnBYfHIyAXZFttp0OSWfiEib24czVJXsrQeXJJ40UG 2jvO8h+UiJcPpgtnmP2b02R8mwhXNdmbqqwsaJndCaFs0rPS/f32ZR0CI Hr/XsDDpyiaNunBWi90kcxrFazBfFuIRT48n3uKCVYS+4h5ccG1s8lsVL 4DZP3LfG/qCnab5Dk8BlpJWk2x2mgSy4maql07Ies4c3pdFAhAHD1llLi w==; IronPort-SDR: QIkijBYI2RuJ3HT4OF0se2qA/5KI5KPToLvZRRuEGYKCqKBJCmYqaOAxoJ0wssShB8YYFDK5Ir IhCphpzPp/hAM4hLgpKyyd3PlGJ0BzDFXiLquXoK3/pYVr1djlHOB6+tWLqqTq3bLTYRm/cEB8 l88QraUGuG7b6i3H/mx7cO3iFTB5prFtXFznhqa/K2inf2faRBFo9Xbe8lAapiZaOrJX6Fbyli FMS8zNjd2elZbPWAGEr3QFi8WRzJl7ElpCjjh8/4SA+B0m+vbIOHBsE/bTt6I4c6FJnL5/LPJf gCU= X-IronPort-AV: E=Sophos;i="5.77,341,1596470400"; d="scan'208";a="153530929" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 06 Oct 2020 08:18:00 +0800 IronPort-SDR: 9inOiNd4Zqp0T+hyMh+MFr4WtPbSN9J4QwlnMmKiYzSfLmVYxBwk75vN/zHuEiPKYeO73uKZ8c K8Xejc0kVYYA== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2020 17:04:46 -0700 IronPort-SDR: rD45YZG01rzAHCHeb+UWPggXpioB4z171xHwJ8hS9et3cvwetahVQCKI4OLiFEf7barKvGm8Kv 6Qg7IhGQ58+Q== WDCIronportException: Internal Received: from b9f8262.ad.shared (HELO jedi-01.hgst.com) ([10.86.59.253]) by uls-op-cesaip01.wdc.com with ESMTP; 05 Oct 2020 17:17:59 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [PATCH v4 4/5] riscv: Add support pte_protnone and pmd_protnone if CONFIG_NUMA_BALANCING Date: Mon, 5 Oct 2020 17:17:51 -0700 Message-Id: <20201006001752.248564-5-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201006001752.248564-1-atish.patra@wdc.com> References: <20201006001752.248564-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-20201005_201805_569076_FA3C5983 X-CRM114-Status: GOOD ( 14.15 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.153.141 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kefeng Wang , David Hildenbrand , Catalin Marinas , Jonathan Cameron , Atish Patra , Zong Li , linux-riscv@lists.infradead.org, Will Deacon , linux-arch@vger.kernel.org, Jia He , Anup Patel , "Rafael J. Wysocki" , Steven Price , Greentime Hu , Albert Ou , Arnd Bergmann , Anshuman Khandual , Paul Walmsley , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , Palmer Dabbelt , Mike Rapoport , Andrew Morton , Nicolas Saenz Julienne Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.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 515b42f98d34..2751110675e6 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -183,6 +183,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) { @@ -286,6 +291,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) {