Received: by 10.213.65.68 with SMTP id h4csp1642503imn; Thu, 15 Mar 2018 05:48:01 -0700 (PDT) X-Google-Smtp-Source: AG47ELveg4boJu3HpetUI/9qhEF+5uQ7e4UY9EzNV1em4T2ZhLx1tS1ORt3K9mThrM4/oAeYZGt4 X-Received: by 10.98.152.86 with SMTP id q83mr7613818pfd.218.1521118081033; Thu, 15 Mar 2018 05:48:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521118080; cv=none; d=google.com; s=arc-20160816; b=qd7fNnygMV2WuSPAvRMLe9zTkS4LQlnz5oFhWlvze9r5LNMtwHYFFv85QrRJZUODtb Ih+WkAKdgtBQStzsl7J3Hzge1uVQqLk03iQn9EtsNZYYq2a/tU02ZTNMkETFJNd/fa2I 89A7sAqZfJ0XGXA93rbhJVRgjU8ihtpC9ULuStL1eS5Qe6MCI4kmBCtCedrnNUCWB+zS cm/ktiI+1sUK+XTk9EKcc3XmXQvTf6AJMLK7YE2BKmvyXcXdboftdkqFEQtwGqkS6Qd8 lFlcCtqJFVXLcs6po0klA6RfQJctWpV2T8cEvGYrkhj+s41h6EZI6fscUNPjFYR3NoFg ellQ== 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=3YwshX0zoWhp0xTSQrkM+fNVERFrg8iHu7XR6W22Zpg=; b=Xnl74dTWQno9qTls10YmRSTR2hMUJavo8UnFtcu3yJTguxpGM3xGiYj1RmZvmMkOhm aT2WNx7fzoCytoTbqMGOQLHz0xxz4B/MdoRvaW72bbY1kZcOUpznaRxfVnIG8U5b6BjU ERK7tT3UW+vMCgANk3CvQqeGxHFiMvPgEPjmPL1tXk5mpWXKq7S+ytStAbCbtNFQVpZV NnOvMmEyzpMiCnxQR10nsQ5SsLO2FpQLNABwNEOGzGrStoPrh2vSPTvva4pjOocECkpm T+V08guYQ2EnoCs7U+KwekbyddXPTXtxwgvhL41scRjjxsNfiBFxSHL9eJ3d79jbXD4L bLCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=oh9Zz6ZB; dkim=pass header.i=@codeaurora.org header.s=default header.b=QsVxzI93; 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 h71si3410320pgc.3.2018.03.15.05.47.46; Thu, 15 Mar 2018 05:48: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=oh9Zz6ZB; dkim=pass header.i=@codeaurora.org header.s=default header.b=QsVxzI93; 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 S1751999AbeCOMpw (ORCPT + 99 others); Thu, 15 Mar 2018 08:45:52 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:56074 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751357AbeCOMpv (ORCPT ); Thu, 15 Mar 2018 08:45:51 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 889D160FF0; Thu, 15 Mar 2018 12:45:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521117950; bh=0BOM2gecTTOJbxQog2wJBGLKOZAAlmb/XrkauoRihb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oh9Zz6ZBxLR7l2i1W81quzVVkijP+FCywucHJHztv1tY47VO7B4tQaiYb4kYZTAsj I47kh/VkA1cWn3VJfEyCaERE8v7pQsfT/HvutGDMULrwSKT7ej/sW5Ahl8n7cFYNwN uDWojsNLKLd9xli4HmcRr94ClOEvFiEn/oqTmv7s= 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 88DFE60F71; Thu, 15 Mar 2018 12:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521117944; bh=0BOM2gecTTOJbxQog2wJBGLKOZAAlmb/XrkauoRihb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QsVxzI93SufOzWujk1qPffJ+TUAejQ68ocYfRXaXNL6hlIgCY3M5AaTHLB5Gc2rrB dhbb3DzpidwmA9Sa2jTd1J/thVU4TvSqDvXxw5tPo9g9DYCyDqXbAsyxW2WWTm23Fc +d2L2qx3OFK2J+YKwuYlQUcCxECHaq2N7sVd+bhw= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 88DFE60F71 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, arnd@arndb.de Cc: mark.rutland@arm.com, 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 v2 3/4] arm64: Implement page table free interfaces Date: Thu, 15 Mar 2018 18:15:05 +0530 Message-Id: <1521117906-20107-4-git-send-email-cpandya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1521117906-20107-1-git-send-email-cpandya@codeaurora.org> References: <1521117906-20107-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(). Make sure, that they are indeed a page table before taking them to free. Signed-off-by: Chintan Pandya --- arch/arm64/mm/mmu.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 2dbb2c9..6f21a65 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -45,6 +46,7 @@ #include #include #include +#include #define NO_BLOCK_MAPPINGS BIT(0) #define NO_CONT_MAPPINGS BIT(1) @@ -975,10 +977,24 @@ int pmd_clear_huge(pmd_t *pmdp) int pud_free_pmd_page(pud_t *pud) { - return pud_none(*pud); + pmd_t *pmd; + int i; + + pmd = __va(pud_val(*pud)); + if (pud_val(*pud) && !pud_huge(*pud)) { + for (i = 0; i < PTRS_PER_PMD; i++) + pmd_free_pte_page(&pmd[i]); + + free_page((unsigned long)pmd); + } + + return 1; } int pmd_free_pte_page(pmd_t *pmd) { - return pmd_none(*pmd); + if (pmd_val(*pmd) && !pmd_huge(*pmd)) + free_page((unsigned long)__va(pmd_val(*pmd))); + + 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