From patchwork Tue Apr 3 08:00:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chintan Pandya X-Patchwork-Id: 10320793 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 D694F60390 for ; Tue, 3 Apr 2018 08:14:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7BA0289D4 for ; Tue, 3 Apr 2018 08:14:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC376289E3; Tue, 3 Apr 2018 08:14:53 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID 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 393E6289D4 for ; Tue, 3 Apr 2018 08:14:53 +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=1DquP1ej/i/e99CfUnCbt+luIZ9Y+msP3/v/bSNGaWA=; b=hvvZQccpvg7cmBkAq0VvyvGhhv 6cWxM38rAFgrRCnTBWvUpwHYfaErNiF/q+qJDeWqfTgMy1IgpMSsxqhS14e9pzSMEyMTgytajnJ4j YeAnf7/bfXx4bLKzByT6JkZsRuQCsNs0r2qosZZOUrEZHyA8dI5yUehZMeCKfe4ZRWQnfaj0NVnyC sMDllbJXBRjyITsJSBEOgUUDE7I7DIIW7BYJ1Qiy9+7R96b0TDNiVc52jLae5EcykSaObCbxEo5il VQbQbHNo62ypfX7DoxbVOO/7o2rAHAxvbDl4c5/nHnqfWtBRfa53Z5eEQIS+JJ8I5ePRwPthWZgsh tnHTSvcg==; 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 1f3H5f-0008Pi-AJ; Tue, 03 Apr 2018 08:14: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 1f3Gta-0001uq-1e for linux-arm-kernel@lists.infradead.org; Tue, 03 Apr 2018 08:02:23 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 3BBA46081C; Tue, 3 Apr 2018 08:02:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522742539; bh=swHMmpGOMeJEu+AQwrWMNOjuNZVaqGhk/HuSQzYnKzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HDmVRHr2FQcWfm2vOyQGZTIUBuAWnCXPI4d4306ruL9a1nUyQmp1iT0cPjFgOqpOq 47PloJPrA9+Aycib5bpTltBcEfYVHXANfp18Ej8LnThwjdkPNwE+dg/9v7owSGFTEc R+g0tcUmSom8dWIfLcLKvxBxHM/zEonVPmLJCSGE= 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 C677060C5F; Tue, 3 Apr 2018 08:02:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522742538; bh=swHMmpGOMeJEu+AQwrWMNOjuNZVaqGhk/HuSQzYnKzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CQbN9WKHvfiRIGQ97zBpKiEEA7YdBKQpdGcuYlYoXUyC6CeOI7DUdm84dO/tdyv36 j0UzQIRl7SU1hL6Cpw7JmhuYpMbSJ0s10HtdlNFfwNbMW+IkXdYDUkADnMOBSHqflq fkMFvcLu9+Kf8icl/NnL8iI8ZkyPMB2M7wr7Igi4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C677060C5F 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: catalin.marinas@arm.com, will.deacon@arm.com, mark.rutland@arm.com, toshi.kani@hpe.com Subject: [PATCH v8 3/4] arm64: Implement page table free interfaces Date: Tue, 3 Apr 2018 13:30:45 +0530 Message-Id: <1522742446-5084-4-git-send-email-cpandya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1522742446-5084-1-git-send-email-cpandya@codeaurora.org> References: <1522742446-5084-1-git-send-email-cpandya@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180403_010222_166245_E0AE0908 X-CRM114-Status: GOOD ( 13.04 ) 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: linux-arch@vger.kernel.org, arnd@arndb.de, ard.biesheuvel@linaro.org, marc.zyngier@arm.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, kristina.martsenko@arm.com, takahiro.akashi@linaro.org, james.morse@arm.com, Chintan Pandya , tglx@linutronix.de, akpm@linux-foundation.org, linux-arm-kernel@lists.infradead.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 | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index da98828..0f651db 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) @@ -973,12 +974,32 @@ 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); + pmd_t *table; + + if (pmd_present(READ_ONCE(*pmdp))) { + table = __va(pmd_val(*pmdp)); + pmd_clear(pmdp); + __flush_tlb_kernel_pgtable(addr); + free_page((unsigned long) 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; + int i; + + if (pud_present(READ_ONCE(*pudp))) { + table = __va(pud_val(*pudp)); + for (i = 0; i < PTRS_PER_PMD; i++) + pmd_free_pte_page(&table[i], addr + (i * PMD_SIZE)); + + pud_clear(pudp); + __flush_tlb_kernel_pgtable(addr); + free_page((unsigned long) table); + } + return 1; }