Received: by 10.213.65.68 with SMTP id h4csp906016imn; Tue, 27 Mar 2018 10:57:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx48SCMQUb/zdACVGfjEuP8pJnZvZDKc5ttLUti2+o6HNJEtv4m2v85UJ82+fzQSRDX+DprgC X-Received: by 2002:a17:902:9692:: with SMTP id n18-v6mr286895plp.67.1522173433890; Tue, 27 Mar 2018 10:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522173433; cv=none; d=google.com; s=arc-20160816; b=e66k1bjUDBpBU38g2RzyWybdEmWCx3UUxydkFvB26/2k6Ku7E1A7iX+QFS8IGa3Hc7 Hh4kPuDZTFa3h1kvpt2Z1Jbh5zNc2C/krEUbhaETrOZDtKj00F4Zw21at9YdU8YmL83J 0cSf5djZPUt18aFaBK3na/jk3PcZE7HK4b0xDr1IW0ncmSrloEvc/FcXa2CRMEqtGy0y iVt7E6j6VblWBBt7vrtb+Vt/1xGqN+uCm6tdyHX0uZERLbpez6wgv5aqi+OMWu0Qk0lv zVegbA73+p+ozLMwXtGbeXOUiGkbcVSgkOPvVcK/pK4JFk1GJ12XPWoT0U6QahLb7rJc v12Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=aGjR5YMjp1ieq7FdTbFkqCuEUCPl13M+WLWuTE1kU2k=; b=XQjw9dOSfRthqym2Oid0ohJW0EEZk0TnDbjdq+Hv8Zyzq41p18jO3+QWngLc2/bXKw IEJLvbUhOPFFgGIc1RqypaqDIQJKQCC7HIeJZyzmsIziTRmQjaa9DDG0aSH15dKUuzVD OjwGg8cQ0Y1K8L7PdEnv9nnwvySZsoSSQakIcxpef4DZjEp6u9qHwcn1ngGz4aezxbYJ 1I0Pm58WXLZvMN2CDnqgnQFB1pIzkQSf7EOQS9cj5am2FkjSxUZWB7RFQmEk2jKbUoZu HjKmrIdb2N2iB2jXs8YdE+aNMNzRgazVwZjS7wEf9WvzDYvLZ9dyRdS42xrbJuDIw67A dFLg== ARC-Authentication-Results: i=1; mx.google.com; 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 m13si1118260pgs.482.2018.03.27.10.56.59; Tue, 27 Mar 2018 10:57:13 -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; 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 S1753494AbeC0RzU (ORCPT + 99 others); Tue, 27 Mar 2018 13:55:20 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42946 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753338AbeC0QbY (ORCPT ); Tue, 27 Mar 2018 12:31:24 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D5ECCEB5; Tue, 27 Mar 2018 16:31:23 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Toshi Kani , Lei Li , Michal Hocko , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Borislav Petkov , Matthew Wilcox , Andrew Morton , Linus Torvalds Subject: [PATCH 4.9 25/67] x86/mm: implement free pmd/pte page interfaces Date: Tue, 27 Mar 2018 18:27:17 +0200 Message-Id: <20180327162728.298358483@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162726.702411083@linuxfoundation.org> References: <20180327162726.702411083@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Toshi Kani commit 28ee90fe6048fa7b7ceaeb8831c0e4e454a4cf89 upstream. Implement pud_free_pmd_page() and pmd_free_pte_page() on x86, which clear a given pud/pmd entry and free up lower level page table(s). The address range associated with the pud/pmd entry must have been purged by INVLPG. Link: http://lkml.kernel.org/r/20180314180155.19492-3-toshi.kani@hpe.com Fixes: e61ce6ade404e ("mm: change ioremap to set up huge I/O mappings") Signed-off-by: Toshi Kani Reported-by: Lei Li Cc: Michal Hocko Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: Borislav Petkov Cc: Matthew Wilcox Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- arch/x86/mm/pgtable.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c @@ -653,7 +653,22 @@ int pmd_clear_huge(pmd_t *pmd) */ int pud_free_pmd_page(pud_t *pud) { - return pud_none(*pud); + pmd_t *pmd; + int i; + + if (pud_none(*pud)) + return 1; + + pmd = (pmd_t *)pud_page_vaddr(*pud); + + for (i = 0; i < PTRS_PER_PMD; i++) + if (!pmd_free_pte_page(&pmd[i])) + return 0; + + pud_clear(pud); + free_page((unsigned long)pmd); + + return 1; } /** @@ -665,6 +680,15 @@ int pud_free_pmd_page(pud_t *pud) */ int pmd_free_pte_page(pmd_t *pmd) { - return pmd_none(*pmd); + pte_t *pte; + + if (pmd_none(*pmd)) + return 1; + + pte = (pte_t *)pmd_page_vaddr(*pmd); + pmd_clear(pmd); + free_page((unsigned long)pte); + + return 1; } #endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */