From patchwork Fri Jun 1 12:39:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chintan Pandya X-Patchwork-Id: 10443271 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9953D602BD for ; Fri, 1 Jun 2018 12:51:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8896528D82 for ; Fri, 1 Jun 2018 12:51:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B6BF28D8D; Fri, 1 Jun 2018 12:51:57 +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 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 27C4A28D82 for ; Fri, 1 Jun 2018 12:51:56 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=TwUQPso1CEl10j8S3Orr1COAYvm65QKPxNjZUCylHOM=; b=AlM5GqCazr5FwZAFVA6I0XXQiB 1ubGEikX/PWAZ6FMz3pneUR0cLbITL+tqOBKR8FkquEf5HA/eKhrmGITsv9gCd5iTh+29rHaGb4T/ z0mDuM69ksO0SlLW+B8W+bkGUGr+RWgKaTQtEchHYmncns+na2AtI1z7KgE9uibDbd3yYQNevPyoe BvETTsZ5KxvM5pqoBrV5r2v9ChLWmHG5oRpfUiZ7bJmv0FgdV52lXMZgDQSxDGQJZZqojo+P+vNWa rBBZjHbk0xvtRdDLi5Q0Ll5l8MDXnLMv4MdrkFPvh4a8rGMs6kuP5ui2mAC0x1n9ABHYffqDk2c0p tj4Jo2DQ==; 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 1fOjX5-0000aj-Rz; Fri, 01 Jun 2018 12:51:51 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fOjLX-0001hS-7w for linux-arm-kernel@lists.infradead.org; Fri, 01 Jun 2018 12:40:17 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id F0E3A6074F; Fri, 1 Jun 2018 12:39:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527856793; bh=IaKYqnf/m30tICaLVB6G1nzz5o4yUd9CpYfkMsCXcoQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LO7FNYr8Kl3UR4rO4ZQJWK/3Yz+ShgTV55DWYiNGApaavdQ4Updi9pneFTy3odH3F I4X5ZAxvOvV8oTcjga048WlcIwX3JGqhNJrXNppQ2j8zbcSULg1l2VbCRAa2gS4nkV 0BDL3RMXAGHM5XMb2GvwwHTjwexPyYXOO8tNsGqc= Received: from cpandya-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: cpandya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A22E2606FA; Fri, 1 Jun 2018 12:39:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527856793; bh=IaKYqnf/m30tICaLVB6G1nzz5o4yUd9CpYfkMsCXcoQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LO7FNYr8Kl3UR4rO4ZQJWK/3Yz+ShgTV55DWYiNGApaavdQ4Updi9pneFTy3odH3F I4X5ZAxvOvV8oTcjga048WlcIwX3JGqhNJrXNppQ2j8zbcSULg1l2VbCRAa2gS4nkV 0BDL3RMXAGHM5XMb2GvwwHTjwexPyYXOO8tNsGqc= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A22E2606FA Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=cpandya@codeaurora.org From: Chintan Pandya To: will.deacon@arm.com, catalin.marinas@arm.com, mark.rutland@arm.com, akpm@linux-foundation.org Subject: [PATCH v12 4/5] arm64: Implement page table free interfaces Date: Fri, 1 Jun 2018 18:09:17 +0530 Message-Id: <1527856758-27169-5-git-send-email-cpandya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527856758-27169-1-git-send-email-cpandya@codeaurora.org> References: <1527856758-27169-1-git-send-email-cpandya@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180601_053955_342756_9BE874D6 X-CRM114-Status: GOOD ( 12.67 ) 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: Chintan Pandya , linux-arm-kernel@lists.infradead.org, toshi.kani@hpe.com, linux-kernel@vger.kernel.org MIME-Version: 1.0 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 Implement pud_free_pmd_page() and pmd_free_pte_page(). Implementation requires, 1) Clearing off the current pud/pmd entry 2) Invalidate TLB which could have previously valid but not stale entry 3) Freeing of the un-used next level page tables Signed-off-by: Chintan Pandya --- arch/arm64/mm/mmu.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 8ae5d7a..6e7e16c 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -45,6 +45,7 @@ #include #include #include +#include #define NO_BLOCK_MAPPINGS BIT(0) #define NO_CONT_MAPPINGS BIT(1) @@ -977,12 +978,41 @@ int pmd_clear_huge(pmd_t *pmdp) return 1; } -int pud_free_pmd_page(pud_t *pud, unsigned long addr) +int pmd_free_pte_page(pmd_t *pmdp, unsigned long addr) { - return pud_none(*pud); + pte_t *table; + pmd_t pmd; + + pmd = READ_ONCE(*pmdp); + if (pmd_present(pmd)) { + table = pmd_page_vaddr(pmd); + pmd_clear(pmdp); + __flush_tlb_kernel_pgtable(addr); + pte_free_kernel(NULL, table); + } + return 1; } -int pmd_free_pte_page(pmd_t *pmd, unsigned long addr) +int pud_free_pmd_page(pud_t *pudp, unsigned long addr) { - return pmd_none(*pmd); + pmd_t *table; + pmd_t *entry; + pud_t pud; + unsigned long next, end; + + pud = READ_ONCE(*pudp); + if (pud_present(pud)) { + table = pud_page_vaddr(pud); + entry = table; + next = addr; + end = addr + PUD_SIZE; + do { + pmd_free_pte_page(entry, next); + } while (entry++, next += PMD_SIZE, next != end); + + pud_clear(pudp); + __flush_tlb_kernel_pgtable(addr); + pmd_free(NULL, table); + } + return 1; }