Received: by 10.213.65.68 with SMTP id h4csp1488150imn; Mon, 19 Mar 2018 05:42:50 -0700 (PDT) X-Google-Smtp-Source: AG47ELsPXtzZ2ezwLqKxqTOwwCs6vL2QENw2AJHCsmowXmnfVBc8VzG+es9Fd4Ih87aTFp6/42H5 X-Received: by 2002:a17:902:e5:: with SMTP id a92-v6mr12122415pla.26.1521463370164; Mon, 19 Mar 2018 05:42:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521463370; cv=none; d=google.com; s=arc-20160816; b=P4B2h+UcThs7G0ZkHliuYDD2Kn20hmhWhwIsGvixD31HC6YJWqbK0yCdeGmsTorfYc fn/OLwLQIfOY2sAwI+kXv3+pG9Jv7qy7iAkR4qhtosjpweCi/4HV5wYfrHhsTkoAhDIk XJyjcPPUt3oCB3hW5r6vtaSJTOksQp8vagTBpZfNkgqbx+dMuSMTxlkij40R7bF2IP0a Oddh+mfDkrtlRDvrxnflmk2UDkgzDJ4/Z8MkBeARc6ZwrwN5EbMmCZ9zQf4VQqFVsSyL hIPPuqtQlnS8qdTgoJXNuxLDQ4UcQA4ejhemIdpTMBizcYNL+V/2TsapQyDe+Chvdd4J NN5w== 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=RUyRu+BmX3uuUIhAP/3YMJ5uvgcG7dJi8mXraNrl3kg=; b=VrPfqVns2l3D6LZKfFhc09lcSDUeWOsZTPN1A5lcTQrb9LdPpHTb6J7t/xGYgqZUjl LBo0xCyjv4wgZYUs/kcJ2Mz06uDpvTaWO6k7PJECDN/7zmOOqzHK7I8gzdz60MRn56e4 JzBiPav3pE8Ge8NFCa6s7zYOMxvGpFqfwj/mRvJeTdlRtuW+o/+efp9D9fjeMG5AnqvY kHiZKjmhVMjurhpmV8nSQAo0zCxoigX9uyM1SVqelA+CvUxqYSLCEpmHMDiPyUAgApXj s+ThH7Ywe0CMziUrKhETIk4s9R867r/zSJztJANHcJjHfxxZBXHg16aVcC4DMi4FCtUQ 408Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Ob0hQ4zd; dkim=pass header.i=@codeaurora.org header.s=default header.b=MrMXWP7R; 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 t188si9501735pgt.387.2018.03.19.05.42.35; Mon, 19 Mar 2018 05:42:50 -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=Ob0hQ4zd; dkim=pass header.i=@codeaurora.org header.s=default header.b=MrMXWP7R; 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 S932913AbeCSMld (ORCPT + 99 others); Mon, 19 Mar 2018 08:41:33 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:34958 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932415AbeCSMl2 (ORCPT ); Mon, 19 Mar 2018 08:41:28 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 1F6E66081C; Mon, 19 Mar 2018 12:41:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521463288; bh=fW0NgLF04tXG6F3HOe3P6dXgrVXLzA+u/6aPeGpSF5U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ob0hQ4zdTqpyUmHG+HEELn8PGEEFNd1q/erJ+WiKfO0d2tFYBT+nQat5wsyPlRb0X HrefwWlUuxE5HE3lvpnzIkLzCLaa4Z8ONFq9qr3I+hfZ8Scgk69YLjES+WNLuaVBHH oK2IHJwC7LXf0RCzy5mBKymn5oBSuKEVhA1mBxUI= 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 C847B60C67; Mon, 19 Mar 2018 12:41:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521463287; bh=fW0NgLF04tXG6F3HOe3P6dXgrVXLzA+u/6aPeGpSF5U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MrMXWP7RLk+hCevrnAcS41T0tDq9c79bY9QMHISqzyu18HIZDEhIrlEPKIATrimXX sYvqYU3zH5lxKv1UQP2hHBmwKdGa4cn9WYVP/Wr2EkXlFNUa+0Ugz92zEEHIrsk1rY sM+nos5xbNOTlxUcV/t4HB4WwEzX89xcmp1Q6Z+Y= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C847B60C67 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 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, toshi.kani@hpe.com, Chintan Pandya Subject: [PATCH v3 2/3] arm64: Implement page table free interfaces Date: Mon, 19 Mar 2018 18:10:55 +0530 Message-Id: <1521463256-19858-3-git-send-email-cpandya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1521463256-19858-1-git-send-email-cpandya@codeaurora.org> References: <1521463256-19858-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 --- arch/arm64/mm/mmu.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index da98828..c70f139 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) @@ -975,10 +976,35 @@ int pmd_clear_huge(pmd_t *pmdp) int pud_free_pmd_page(pud_t *pud, unsigned long addr) { - return pud_none(*pud); + pmd_t *pmd; + int i; + + pmd = __va(pud_val(*pud)); + if (pud_val(*pud)) { + for (i = 0; i < PTRS_PER_PMD; i++) + pmd_free_pte_page(&pmd[i], addr + (i * PMD_SIZE)); + + free_page((unsigned long) pmd); + pud_clear(pud); + flush_tlb_kernel_range(addr, addr + PUD_SIZE); + } + return 1; } int pmd_free_pte_page(pmd_t *pmd, unsigned long addr) { - return pmd_none(*pmd); + if (pmd_val(*pmd)) { + free_page((unsigned long)__va(pmd_val(*pmd))); + + pmd_clear(pmd); + /* + * FIXME: __flush_tlb_pgtable(&init_mm, addr) is + * ideal candidate here, which exactly + * flushes intermediate pgtables. But, + * this is broken (evident from tests). + * So, use safe TLB op unless that is fixed. + */ + flush_tlb_kernel_range(addr, addr + PMD_SIZE); + } + 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