Received: by 10.213.65.68 with SMTP id h4csp327417imn; Wed, 28 Mar 2018 04:30:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx49XP7FleyrMbCLUOnWye92CRP36rtTG1xYZVdIfhFDmsjQ8TGTZUKtm38ZcNFHE/e6+bBC3 X-Received: by 10.99.114.77 with SMTP id c13mr2298709pgn.286.1522236620587; Wed, 28 Mar 2018 04:30:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522236620; cv=none; d=google.com; s=arc-20160816; b=obwOJ3BN/qVr0cPkU3XADbdn5ajbL8BopHyD9f87/Kr6pTV05GUJAJsiJly6hlUGwT 62hPEeiUBTo9XUAuKC/uzlTGNYk0xIEDrPmNFZ3B9K3im5jMZJbIZ0iRZJ6StwsXSQkP n2doHYqW+grFAI4yqEU7qcCsOYemhvgcLLYR1Mmgv7lTsAj1pAOXW6MB9raTQl8TqcZA PTFaep8J3yeSqI72tmfQ2Sga/ymi31mUrjwZZP6cKshJkQr0Z/CaJUyk0brTVHWGs120 +4jtOvzVLSukMDrbtctnInLrOZtJVKATAs538JKmHJdoxHJkUSVkvREsYng/VX/3VRa3 f7lQ== 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=6bXvrwMrY4JUNp6ezaE8Flo4AeexCN8PMelvK4vasmc=; b=JnsNntRYmedLeGw1NVll5urx892Gt6+ck3wJbboPXK2N0wyI/RMJRlQMw/YiAoeko5 aKkWnzeLZSfJhU1xDMznsOZ4sKvUV0UwrMisAk6+Uk9fVmfC9aZXXKYVShM1AGI4Z9Eh KcTdTK2MWmqFUhvqkt1b2gfJxkyB7KI/CCY13RpEkgJ+OgpxTubzJ1L3hy0whtFFBeQP S2UpyYqD9jKLLI4+78vPciMcrZAmyFVJ/Q3/9gtAZI6wMPq4cX3+MlnDGE6mDVsT/+HQ Q1MV6KdhfAtQ21W/mI7zNOxF29e5SSzlB9JFpFK/ddmvvhPCk4wYH5YS0zAPxcVCx+33 gOqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=YxUgdFPI; dkim=pass header.i=@codeaurora.org header.s=default header.b=B1HjLSgH; 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 f127si2358914pgc.49.2018.03.28.04.30.05; Wed, 28 Mar 2018 04:30: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=YxUgdFPI; dkim=pass header.i=@codeaurora.org header.s=default header.b=B1HjLSgH; 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 S1752743AbeC1K7a (ORCPT + 99 others); Wed, 28 Mar 2018 06:59:30 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:35064 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752269AbeC1K71 (ORCPT ); Wed, 28 Mar 2018 06:59:27 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6CF7C60F5F; Wed, 28 Mar 2018 10:59:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522234766; bh=EoQDni/I46zUgqil1h6zFM6vu4oyHoPuougag/EmHgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YxUgdFPIgcRZBJTqMduE+iF9nehpVigZ8jLE2KIM29slSTjVkG09Y0gTikUTJKuIJ OC7YdhaqrOgI0kP48QD5+QgTX7Fs1GDt6jn+925mN+xUiCImjVdmS0xAMMIBMF3UDx amJ9d40Jr0kB1BL/+WA0Pu7rl9iO4msrVF19gTs0= 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 6BF1760F6E; Wed, 28 Mar 2018 10:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522234765; bh=EoQDni/I46zUgqil1h6zFM6vu4oyHoPuougag/EmHgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B1HjLSgHc4aUB0t+4LTnpEKwTW2abq9CRuxsU0dRqqV7gbW9H/82HTiJL4N8av8XP ca3dl1COFsut1CEbX9Gjvf5ItphOjG2w59h1Io7ZCP5jTBiwPmy00q4hyl9anLEghV PJXsKqZoqnuS2+xe+W91s25Op6lri+LfornBvFD4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6BF1760F6E 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 v6 1/2] arm64: Implement page table free interfaces Date: Wed, 28 Mar 2018 16:28:50 +0530 Message-Id: <1522234731-27397-4-git-send-email-cpandya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1522234731-27397-1-git-send-email-cpandya@codeaurora.org> References: <1522234731-27397-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 --- From V5->V6: - Removed extra bool parameter 'tlb_inv' - Doing pmd/pud TLB invalidation with __flush_tlb_kernel_pgtable() arch/arm64/mm/mmu.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index da98828..0f651db 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,32 @@ 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; + + if (pmd_present(READ_ONCE(*pmdp))) { + table = __va(pmd_val(*pmdp)); + pmd_clear(pmdp); + __flush_tlb_kernel_pgtable(addr); + free_page((unsigned long) 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; + int i; + + if (pud_present(READ_ONCE(*pudp))) { + table = __va(pud_val(*pudp)); + for (i = 0; i < PTRS_PER_PMD; i++) + pmd_free_pte_page(&table[i], addr + (i * PMD_SIZE)); + + pud_clear(pudp); + __flush_tlb_kernel_pgtable(addr); + free_page((unsigned long) 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