Received: by 10.213.65.68 with SMTP id h4csp3240967imn; Tue, 3 Apr 2018 01:04:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx49IqWseIWU9bwGmuJj4kz5bUKRyKMOcBUMHoWR1Au4KdZOlUWKL77FA2RA/srCuJLUznRpO X-Received: by 2002:a17:902:8548:: with SMTP id d8-v6mr13374529plo.241.1522742644133; Tue, 03 Apr 2018 01:04:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522742644; cv=none; d=google.com; s=arc-20160816; b=K2LVmPyGYlNVPRVt9ofibxWcl5Pa1WSg06QZGysJMScF7qGGkOc4rZmgvna73Ab8g+ 47OWE7LtLPM55+O0OMUwY8VLacfyJsUTd7J3tRt6r7esmy+2KPAOeVe/rz1d9Og/ZKiv W2zdzATv5TG83A+hce8y8m4VcHF0u86ozPi3eGdOXum4Dtq2NF/1isBPqy+0pq1vq1W0 yVuhqnddtkloPzhLDWdRGv5xxzNAh2PjorFdF1gRViae85vQKO/Llz2d7Uf/mgF+KB/V gQChLLtyE0hamzbQiDlmxAZ7U9Lp/gKRs3p6BXMlfw2sjK3Fshe0fBdfpQJjy/XFIPcw R3HQ== 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=qlMlxBon7Z2SnSm72VTuBCT0JpmMM9AineTAWOP/W0MtBREBIV+kbXBWwJD7wO0Tcg mvOiWAyTGLEIhH8PPsqJx2Kzp8exUsbIMegfFUaLxeFRmJ8/B6WslbLw8P1aJXJrSG0L F/V6dlN0IGBbrNrUhN+0obXSKnwjtBWhmN67eB1rTAQIJ2EA2q06Uzv3YpPshmMzqQoi yV6s5ZykOR3bXlnI7lI3nwzTz53yGl++kvdL08J0iSNHfp56cL2tpVSEKhuz70e/Rulo sfLeVvCzvqiifOavQS/I2TnkI4JF2ulvvL4gGBUVau68dz55BLwlXHWudlYb58NYUMC2 8BbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=HDmVRHr2; dkim=pass header.i=@codeaurora.org header.s=default header.b=CQbN9WKH; 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 h6-v6si2155859pll.726.2018.04.03.01.03.50; Tue, 03 Apr 2018 01:04:04 -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=HDmVRHr2; dkim=pass header.i=@codeaurora.org header.s=default header.b=CQbN9WKH; 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 S1755088AbeDCICW (ORCPT + 99 others); Tue, 3 Apr 2018 04:02:22 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:42642 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755052AbeDCICT (ORCPT ); Tue, 3 Apr 2018 04:02:19 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 5AC2E60C5F; Tue, 3 Apr 2018 08:02:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522742539; bh=swHMmpGOMeJEu+AQwrWMNOjuNZVaqGhk/HuSQzYnKzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HDmVRHr2FQcWfm2vOyQGZTIUBuAWnCXPI4d4306ruL9a1nUyQmp1iT0cPjFgOqpOq 47PloJPrA9+Aycib5bpTltBcEfYVHXANfp18Ej8LnThwjdkPNwE+dg/9v7owSGFTEc R+g0tcUmSom8dWIfLcLKvxBxHM/zEonVPmLJCSGE= 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 C677060C5F; Tue, 3 Apr 2018 08:02:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522742538; bh=swHMmpGOMeJEu+AQwrWMNOjuNZVaqGhk/HuSQzYnKzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CQbN9WKHvfiRIGQ97zBpKiEEA7YdBKQpdGcuYlYoXUyC6CeOI7DUdm84dO/tdyv36 j0UzQIRl7SU1hL6Cpw7JmhuYpMbSJ0s10HtdlNFfwNbMW+IkXdYDUkADnMOBSHqflq fkMFvcLu9+Kf8icl/NnL8iI8ZkyPMB2M7wr7Igi4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C677060C5F 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 v8 3/4] arm64: Implement page table free interfaces Date: Tue, 3 Apr 2018 13:30:45 +0530 Message-Id: <1522742446-5084-4-git-send-email-cpandya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1522742446-5084-1-git-send-email-cpandya@codeaurora.org> References: <1522742446-5084-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