Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp545009imm; Fri, 1 Jun 2018 05:41:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI9YARMHbK7o/TPl7VBPO2qPZGXUroZuABf/GhECj8bphzqYqVcJP4mFZRPPk6fNyUe2NCx X-Received: by 2002:a63:7145:: with SMTP id b5-v6mr8864446pgn.45.1527856880051; Fri, 01 Jun 2018 05:41:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527856880; cv=none; d=google.com; s=arc-20160816; b=aohUACJDYuNJoBLlBwW1tShdmtsPEyWQesk02kIvdfCqKQtfhL7HQHFw95vnSS7t2G MQ56Blc5BGxHoEBvvjPjD+djdiW9x/K6tqbENqlYrRLBXEge4yhjnTqhL8fVY59KPkcs aaYwoGJwF0iacoMteVyqxGTibrCjwFuueSeBCGznAD53FMEscVmG9DicOCrqX+VJC3i/ 3YQL+2B8Wihrcn1Cu2V2kZvSLMkyDEtghfeXhkoJH3rLImkcrl+lcnwKBh30VB34AFHD MTSveB2LLA13JPVvPrwrZ4zK6HkbHbUZHLXbIQcquKr7WVPJNzPrhxFgOobfSzsD8bAI umlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=QEsXcoZnUe5INMvUGtYy7sc6IKgluydBtTydkO3NtRA=; b=kJ+bAvR5m9GTkVRkRnI8LO0jYKF0Z5VXdv8rwsPYux+imvhCHBpO17CigLBD3h2ZG2 H4+06fmOTrGtktj35AfEKMKHshFE/UzU+eifQ8wr85NWtS1LLW/eI6lkC+QacKiQnMAW /kuECw/PaRRWUZB78Q0eU1Siyv+96ekjRxF/46fpYjJg9iCwVyC8euQmOFvTYesxEvqI qI2169EVjs86fXgX0pAx2XZ+B9nmdUHWakJ/FFXIYVsBP6suJ/7yPcOCT+jM+lO6Y8Ch OoKy4MvWE5l/WauuI8/lC7NyQZyY3r0KDjnGbyAuLzOuzz44sKgyDYMvjOGroZSPULdV 7/mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=LO7FNYr8; dkim=pass header.i=@codeaurora.org header.s=default header.b=LO7FNYr8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j14-v6si1699651pfd.207.2018.06.01.05.41.06; Fri, 01 Jun 2018 05:41:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=LO7FNYr8; dkim=pass header.i=@codeaurora.org header.s=default header.b=LO7FNYr8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752050AbeFAMkA (ORCPT + 99 others); Fri, 1 Jun 2018 08:40:00 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:50232 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751854AbeFAMjy (ORCPT ); Fri, 1 Jun 2018 08:39:54 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 99EB160263; 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= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 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 Cc: toshi.kani@hpe.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Chintan Pandya 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project