Received: by 10.192.165.148 with SMTP id m20csp3490156imm; Mon, 30 Apr 2018 00:43:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpvCIvQrAb9XBgYgyoJx/r3i/7MwnJofX+dHDqfmM8T1iLRhLM4JuZcwhVt9Ez/+ObWUhlM X-Received: by 2002:a17:902:e8:: with SMTP id a95-v6mr11466698pla.274.1525074196852; Mon, 30 Apr 2018 00:43:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525074196; cv=none; d=google.com; s=arc-20160816; b=j5p1PC5CKQ4Hr4bUYs4JrQJyKCiDxtIu0CcBgfpjQCeTLa/Az9bW4Ju8aG/ZVaQdCk ZZ9+rJYdHa9OQVzJti3LZNyeRjLih2qtJ31OkUj/Qv4WUYDKcYkhtIJEx/wLTQLh1Lng ZpTY/aTgIyGlkqHMFAqt+hZm0weVyc9gHdgQHvWbhwYH6k/+m3l7+AGKSx0EoIxkV/Ld FfyEI4F6JDb3wn1yWQryCs0mJiXcsRboGxwxp/5T5QJWKm3DH6oSLSRBR9xRjcdNsrga 6hqD/L0VfID391yhhzk3+utcv15Ch19ciPqtS3SmRCrM0Yoe5027g+YcSvuEJyYAcGZT qvmw== 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=/zJNIcJfeUuQacDi4LQ10egUIeDxiQg7R+ACXjZn1tc=; b=aSSfvu8+IZr/VVv5YWuP+kcbGOCyInbnhsPZch4rGYReWD03iKgha1ubQMYBCPD/Mj zpqY3mH3ED2mD7xQsD4PP0oa9NKUVaPDwPEDdRMAgTQl+d7uEgB1f5MyNTfepPLhACC7 MMNpucfPHCKA6qHOf+ordbQVSu+S3YO6d+pWLqWcGBIMyOHv5KkVH8bOcViW8nfVvec3 4i/hYhWjLenYNBU3/XNQ8o16tI2b4Wzkv1Yg3dAK44n09zuMDMYWPEkjddu/vJzjzl2R rKPrs8ia0k/udnVb4TBg5rwHCi1q0op4VjekWDQbtfwG7u+MpVdldy2ArJbvCR/njPXx u5DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=N9kbWnPY; dkim=pass header.i=@codeaurora.org header.s=default header.b=blYnc/ty; 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 j61-v6si6992687plb.317.2018.04.30.00.43.03; Mon, 30 Apr 2018 00:43:16 -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=N9kbWnPY; dkim=pass header.i=@codeaurora.org header.s=default header.b=blYnc/ty; 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 S1752721AbeD3Hme (ORCPT + 99 others); Mon, 30 Apr 2018 03:42:34 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:47696 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752348AbeD3Hmb (ORCPT ); Mon, 30 Apr 2018 03:42:31 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 55BB560FEE; Mon, 30 Apr 2018 07:42:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525074151; bh=swHMmpGOMeJEu+AQwrWMNOjuNZVaqGhk/HuSQzYnKzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N9kbWnPYjtFQ+0hucqf0Gg4BNQKirfcp63PAJUCq3dris1zC3X8JKAidEwQVTx1Uv sPx6TrXmRIvXvbXcspE497jYnCWDrOywaKqjlH8Pu8C5x1Er/hy9sA8an/NUs8S/CU Jjp+XZ0s6Ae450KHYWDnWp5PK52ZoZ8hcQB6W8dU= 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 771F060FAA; Mon, 30 Apr 2018 07:42:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525074139; bh=swHMmpGOMeJEu+AQwrWMNOjuNZVaqGhk/HuSQzYnKzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=blYnc/ty/y8ddK1l6y3RbT6ZqImRhmTWVXq9qkvUo4HugFXZ9TVjF8qM7boO8ECdC tkTrvWHS+Rmj6d/PJmImzokxozTgK/oMvH+1DBs/+NfhZte+CdD6yvW6eFOJsnBa1n TQVMtimkpCoAzlBylzpPf0u+Tw4Kfwcpv0q6Tlbg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 771F060FAA 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 , Arnd Bergmann , Mark Rutland , Ard Biesheuvel , Marc Zyngier , Andrew Morton Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Philip Elcan , James Morse , Kristina Martsenko , Toshi Kani , Dave Hansen , Vitaly Kuznetsov , Joerg Roedel , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Chintan Pandya Subject: [PATCH v9 3/4] arm64: Implement page table free interfaces Date: Mon, 30 Apr 2018 13:11:33 +0530 Message-Id: <1525074094-25839-4-git-send-email-cpandya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1525074094-25839-1-git-send-email-cpandya@codeaurora.org> References: <1525074094-25839-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 | 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