Received: by 10.213.65.68 with SMTP id h4csp655877imn; Tue, 27 Mar 2018 06:27:38 -0700 (PDT) X-Google-Smtp-Source: AG47ELum8SCT/mrk1RwMcwpsYJbJslYYVxnJsSTJc+b42um/6enudX88PmEKLg4kbaX8HpCZCdZK X-Received: by 2002:a17:902:7295:: with SMTP id d21-v6mr28938274pll.130.1522157258279; Tue, 27 Mar 2018 06:27:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522157258; cv=none; d=google.com; s=arc-20160816; b=gzMZcSUXWGI4vuzTb1MMaY4gvF9uz+bZ39Q0dCrx4GjIm5vBIxNVt4mzOmGIzau/sY e6RlKw+/R6nNkG4z6FpfrfZ11mp6DR5iexefFsON3ePabCafIsPiwwCpLcaZRooB7y0L 5AgCvWVZPsbkE8p6bUwfS/fKovc8ve9n3vO43EOxF4C0ILoPQdGb9O6l1edZfZh3ynkj CSPlacuyH8X+KYRW17XP4DYqAUh4/sOXvMOPo5gFz8miq098mEhSjRTmfN5uNCElKePc Ro+QlPL0j0801cw5QqZB40od1uVQQg8UGPW+r8BweSgYdJmrfZG8720BDPTOiAC6ncJQ nttA== 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=yvgadhUzE8DRiB8jLHlNc7eYLhA8HO3byMvDAHg0sdA=; b=ZhvytXN8VPzniUGu3wEXy6CogTQTwJEKfHCrXmcD3INsvYF9yRAikpBlwceZKi7x6Z oUKFXJiGHhA6d8fDRdLyYdkOb97MJFlUeIZ2bvWbIxWXA3zjyjtULJBLE/3MJGPd00R9 VQEKXHtP0o+uYNk/Irk7K9M12MS3CgtaarrFpxm756+8DnaloOEbYxG8ULEU8bROVIEp K6NnCh4CqHPFJVmpm5OZgXpZDN1cO4D0i12jqeFIDWq1GjB2Av8PyPMqQfW0/XXyuwyf whXib00Sq4lB1xah4budW36/1QEBfMCDQcc9qVglldjzDSvSYTHzDA/CTz+SWyqH3uy7 DJ9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=VUADsD56; dkim=pass header.i=@codeaurora.org header.s=default header.b=DvICk5QG; 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 f15-v6si1230499plr.454.2018.03.27.06.27.24; Tue, 27 Mar 2018 06:27:38 -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=VUADsD56; dkim=pass header.i=@codeaurora.org header.s=default header.b=DvICk5QG; 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 S1752783AbeC0NZn (ORCPT + 99 others); Tue, 27 Mar 2018 09:25:43 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:34026 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752841AbeC0NZj (ORCPT ); Tue, 27 Mar 2018 09:25:39 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 162F160F61; Tue, 27 Mar 2018 13:25:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522157139; bh=NAEp+V9NzyNE2wZcjRscs8/TJjwtlXLqeanXNUYygek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VUADsD56zrrrQzNOv7uB5wsusKhMt55lZg0nyZToqaJEjP5puImdoP7+vGB25n3wp sTc2vULsAz8wuuYK6+bSNUsaXitHOtPD93u/s0qTntyNskQbI4rcXtpMOxc+ZizR2O H2OwKPxljCqiRpxkVWfaE4b7mcLIEYBdo3c6OBlU= 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 6FA3160FAA; Tue, 27 Mar 2018 13:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522157137; bh=NAEp+V9NzyNE2wZcjRscs8/TJjwtlXLqeanXNUYygek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DvICk5QGBssCWt+1fGYt0fCB80VYvytvtyhhMRbdnSzyBbiXCgWlE5I5aXnB5vMAO /wywNZG3xp76CtKD7mBf6ihs06wSMJZ/rOTX+7eWnW9a3VzSJgim0fTw87FJiMWlIy Jo3s04tDDU4Bs6DSfmuqfbLjPSAfS9VkGkT70/HU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6FA3160FAA 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 Cc: arnd@arndb.de, ard.biesheuvel@linaro.org, marc.zyngier@arm.com, james.morse@arm.com, kristina.martsenko@arm.com, takahiro.akashi@linaro.org, gregkh@linuxfoundation.org, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, akpm@linux-foundation.org, Chintan Pandya Subject: [PATCH v5 3/4] arm64: Implement page table free interfaces Date: Tue, 27 Mar 2018 18:54:59 +0530 Message-Id: <1522157100-16879-4-git-send-email-cpandya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1522157100-16879-1-git-send-email-cpandya@codeaurora.org> References: <1522157100-16879-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) Freeing of the un-used next level page tables 2) Clearing off the current pud/pmd entry 3) Invalidate TLB which could have previously valid but not stale entry Signed-off-by: Chintan Pandya --- V4->V5: - Using __flush_tlb_kernel_pgtable instead of flush_tlb_kernel_range arch/arm64/mm/mmu.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index da98828..3552c7a 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,40 @@ int pmd_clear_huge(pmd_t *pmdp) return 1; } +static int __pmd_free_pte_page(pmd_t *pmd, unsigned long addr, bool tlb_inv) +{ + pmd_t *table; + + if (pmd_val(*pmd)) { + table = __va(pmd_val(*pmd)); + pmd_clear(pmd); + if (tlb_inv) + __flush_tlb_kernel_pgtable(addr); + + free_page((unsigned long) table); + } + return 1; +} + int pud_free_pmd_page(pud_t *pud, unsigned long addr) { - return pud_none(*pud); + pmd_t *table; + int i; + + if (pud_val(*pud)) { + table = __va(pud_val(*pud)); + for (i = 0; i < PTRS_PER_PMD; i++) + __pmd_free_pte_page(&table[i], addr + (i * PMD_SIZE), + false); + + pud_clear(pud); + flush_tlb_kernel_range(addr, addr + PUD_SIZE); + free_page((unsigned long) table); + } + return 1; } int pmd_free_pte_page(pmd_t *pmd, unsigned long addr) { - return pmd_none(*pmd); + return __pmd_free_pte_page(pmd, addr, true); } -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project