Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3544519imm; Fri, 25 May 2018 07:31:00 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpX2Dmxgr47cAHSRrHDMDF9N0pXKN05+ATXF2hT6tHvvXFozVXazd+1yiNiQgk7/BdK73Y8 X-Received: by 2002:a63:6ec6:: with SMTP id j189-v6mr2159415pgc.71.1527258660193; Fri, 25 May 2018 07:31:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527258660; cv=none; d=google.com; s=arc-20160816; b=fF3NlUkJXqblS4irLxwvn42dqUacBimCKbajBMM/lQvivc+kWLD8GM2ANn39h0lBxE aPumdUxAYr5nChyYinb2x8GN+MEsY2DWOPlDJitY5Se746GUaTGRa0pcqm1LQWOeOhUb I5QroKc1Cs1hy2CFg/TTJFGHNinbGbbhDRc/UtVnHVlmrFh7TRApbudOFSYXzbLcLA2w J/aXJX3TXa0JA5S+DAXTcBDZL/MMZnFdD7ejjs3wvspEriGmDAyBc1SZ+wpgBW9vgeXc Ie35Tw9+wamdTaepPklNBvxzEUUXjZR0cQM5Y42GLUT/PbpC0Ej0NfInmbRFJzPUEqMZ OnDg== 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=rxT+JbfZ3GRp7iJ4kAf4LX2E2DmEtj24IZOC+l6pZ4c=; b=lfjnZCqXNrpZpN/95eDYtQkj1X4WS+MEKik0TBlZDD4WSzspm2NATdiQ67JHYwo+8/ y1MXUZLPoZy5Qv/TZu0DDnI6sm+ssaqzfdBVt/59j9v2MBQ4OEzYMv6kexvsOHGtCxJw x68k+WH50uTBbutNkmg/Ufh7dJpAcbi2GhhDETYlRirEdy7N8V+9Ye1E/599qsM+1U6c 81kzjvc+pIdO8Z5+4D4xLEbq9BhwW+or/hKbVNDn4ebcwYKY4M88U5UPA37S6h7KyVLZ JwV+wByfnE8JXx3Z2rA5gRwiDQjnMlm6oDlKGa//rM/SamkJfHXgmNaA++THtR4P+PpN 0bvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=mNFO1iM/; dkim=pass header.i=@codeaurora.org header.s=default header.b=iN9owTLs; 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 y40-v6si23857459pla.470.2018.05.25.07.30.44; Fri, 25 May 2018 07:31:00 -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=mNFO1iM/; dkim=pass header.i=@codeaurora.org header.s=default header.b=iN9owTLs; 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 S936266AbeEYO31 (ORCPT + 99 others); Fri, 25 May 2018 10:29:27 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:54404 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936164AbeEYO2p (ORCPT ); Fri, 25 May 2018 10:28:45 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id CF67960C65; Fri, 25 May 2018 14:28:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527258524; bh=E3bJKUst8q400eUBWt+1JR594kl0tgc/oGKBYx/7qOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mNFO1iM/W/VuM+5uMg7Z1U40vibAJkBsPWDXqzrKH5vOi4ps7Hcg41fqyfWePygto LyWnHfM9fw+d+c7OIWrEkffRhwfY8EPp207OUKpY3LBg+tBF7XgLZgG2h5qFIsOdTV xDzFSM2eK+q2UtQOkNi8N7Qgpj4HskoH20fabeno= 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 8FAB960881; Fri, 25 May 2018 14:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527258518; bh=E3bJKUst8q400eUBWt+1JR594kl0tgc/oGKBYx/7qOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iN9owTLsAUxiCS63QrEHeuiZCmr4aeEDN7tcs/2YBpu4tUQt3F2D9kTQwkl8B9+/v 55bsOiceMV/anqKOpAq4ViSgm4G8W4lZpnazjbVtKPcGMMIRqKCBxOXYhy/PSL/w1e oJbQCABOyPqCjKXQ40wPqup4rvBEF9xOQ1kjrhk4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8FAB960881 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, labbott@redhat.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 v11 3/4] arm64: Implement page table free interfaces Date: Fri, 25 May 2018 19:58:08 +0530 Message-Id: <1527258489-30473-4-git-send-email-cpandya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527258489-30473-1-git-send-email-cpandya@codeaurora.org> References: <1527258489-30473-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 da98828..5f2da5c 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,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 = __va(pmd_page_paddr(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 = __va(pud_page_paddr(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