Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2836015imm; Thu, 24 May 2018 17:13:00 -0700 (PDT) X-Google-Smtp-Source: AB8JxZols+mFT/C1/wvgb9HRz/Wu8ITPhTxp32cEqhSNAKsQszxqRnemQdZkRtPh3eM/s+vn4pnc X-Received: by 2002:a17:902:1e3:: with SMTP id b90-v6mr144129plb.273.1527207180863; Thu, 24 May 2018 17:13:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527207180; cv=none; d=google.com; s=arc-20160816; b=GMB9AEKmxbmNdJbj/RNVoMUslRkkINSKK+h9ka5THxFBXoWFcse/hgqKH0AXBBLUNt eh+2NVtU5PyN2RfVjLS2jFuPgKE5EQj9GlgDSlygFEt4wIr7lRkggJY2BdgUI5Qj/q+a fXqhbG9Z0rYOl8Vw+iSSwaCbxXGyFVDVFGiJsedAjZQf0SZTy17s+dH6KLn6/P1MyORx rl94a2Cik1o0cq/jP2tLxfU+uFj4vNpDV9xeUmHcNqfSeeVA8dr5gkr4WwUS1kEJj+xa yR2fH6ZZ/JmF5eRG+ZoH3faryGZ6bDZ0Qqf7BVwxkHlyTb8SnevIo6fsKfx/83Y8EV5M hZsQ== 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=+EfiBvMhq7LY8hFxHqY2pTNG3WP3jJSmdW+j8DJ9Gow=; b=zZ14SJowkOkbFqmZQCyYO/p+xie3FVsHVG24163cfY4TP0DT7iOdU57WBMxqJDRPHX kgLWh+vJRic9fWHIZ1HJM2UjfAgfJkkpQhEIfbymQWiwKWElAg9aaSgirA49zk1Qw508 72eH/YxjY/IrgjrlO/ndov1wq8gu1e/xeNQT77esziUnuLzcIPhG+5E++Hh3nj7y26If Hygv9txtR4O3uSYa5/OE7O+85inlWq13Z9yq+YaWm6EcaLWXFnAXEW0qi9ZcNd+M+9gi frXZjZIGGJB1psue+98Fte4LByGC8pkVRLbPcyf0SHs/ipXRauQG7Gpcosb3QgntiTL3 Kzxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=nqINE04b; dkim=pass header.i=@codeaurora.org header.s=default header.b=NaEPVhKb; 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 i27-v6si23129322pfa.219.2018.05.24.17.12.46; Thu, 24 May 2018 17:13: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=nqINE04b; dkim=pass header.i=@codeaurora.org header.s=default header.b=NaEPVhKb; 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 S970201AbeEXN6N (ORCPT + 99 others); Thu, 24 May 2018 09:58:13 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:39420 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S970161AbeEXN6I (ORCPT ); Thu, 24 May 2018 09:58:08 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 4E87360A00; Thu, 24 May 2018 13:58:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527170287; bh=7qYFydu7jKVG+PqZ5bWbjYtwM5RIPpdQKnhu6Qi1va0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nqINE04bm2pDV5P847M5eOnKh56G0JzyBeslEH+WXf8yyUROpIiA1Qk2rKVxDB2pe Y+n5I49chw+NqWNaELaod+dcSpph2bMAjf0ef9fniYeM2ocoH6dYlW/gMqFz7zqB3D OKCY7i6rxnuVZlfjvB1RVD9sZjq63xksYEeVVvNU= 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 B91FF60C66; Thu, 24 May 2018 13:58:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527170285; bh=7qYFydu7jKVG+PqZ5bWbjYtwM5RIPpdQKnhu6Qi1va0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NaEPVhKbJ6X+iaATHxOc1omVhWE4sMbXLS0+cpUsGqSeSj15mKkFmQRdd64C+dO9L XRnyVpKxRU38sSejeyXt/YhJkOlbvkxAea8eGE/gzIBu7DmCoane2dn9JQjFfwHej2 JkDoYSNH9yrcTC+/0xg/9pPBRkayvzMHcOVGOjSk= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B91FF60C66 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 v10 3/4] arm64: Implement page table free interfaces Date: Thu, 24 May 2018 19:27:29 +0530 Message-Id: <1527170250-5291-4-git-send-email-cpandya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527170250-5291-1-git-send-email-cpandya@codeaurora.org> References: <1527170250-5291-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 | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index da98828..17d9282 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,37 @@ 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; + pmd_t pmd; + + pmd = READ_ONCE(*pmdp); + if (pmd_present(pmd)) { + table = __va(pmd_val(pmd)); + pmd_clear(pmdp); + __flush_tlb_kernel_pgtable(addr); + pte_free_kernel(NULL, (pte_t *) 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; + pud_t pud; + int i = 0; + + pud = READ_ONCE(*pudp); + if (pud_present(pud)) { + table = __va(pud_val(pud)); + do { + pmd_free_pte_page(&table[i], addr + (i * PMD_SIZE)); + } while (i++, i < PTRS_PER_PMD); + + 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