Received: by 10.213.65.68 with SMTP id h4csp828040imn; Tue, 27 Mar 2018 09:30:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/trcipeNqEdpbXcTwYhfv1KofVfQD/892S5SLG9XnaZYDQLuvRsgn6m5xGDWWc0fj3kYEm X-Received: by 10.98.21.209 with SMTP id 200mr26263pfv.232.1522168256582; Tue, 27 Mar 2018 09:30:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522168256; cv=none; d=google.com; s=arc-20160816; b=m13l4VX0i18lSqdno6jc5vG6eLszWKYUyGzzkmqa44R5a/XxxbnZ7eKfRAMvBInB0x QsLp+yCEI13v+MuNklefm5//6pGPWU0PKmvIcqmqX4IRcJVNU4MgcsPjgF9fmJTyEqB8 jqjC4lRL+SY9YwmUV/Eoki0bcn10JO3Q+zEckmCm+aHKtXc3px++MPsPm3p+qwuy+26c ncZ8zTSUDQjPk5U1uEoLxtMp/ChvIWWTiPmhZppzJPRSbk+ZBvSHqvY1ci2Y3IlU3IA0 Q3XrGAbXvubijVUTq7nAHN8tzzBjvULyUUogJoBj0c3EBLoOLp0aGaaeUFGUBEIXShpX ZcWA== 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=CG7pll//BKYcUDhtn3mK1MFYnOsDz0PC3Lb5ioJXVsU=; b=L2ssLFTgZIY65kG939rjWlygp7pAGi0as+RaKtwgr7TIEtVrJmRhZnfpDhI9i4/x0o kcretbrZXxshhBDD3gqnlUW8zbTfVfo3i+phX7KuFuLYiKjaT3ZMAAIfQInLoahHLIex VNG1WGP4IUyQhgFaG5/5FowzGcJ18XMNu8lHU4Xe7KIAKphO+cZpWFT7mZoschVcuOA2 0ze7xOqg+wANKpLIEqz3BpyLRU8VGQdKAKNzN1ZBwwyw5JNabLYMVjdfliy+cZW8lwhZ /uBowM3XDp1lfNSxql5uQ+EickKWcmFy9x5uUfC6wAS/FhAcJngJ99ggCz94SFDA3rNU +2Tw== 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 j20-v6si1645537pll.86.2018.03.27.09.30.42; Tue, 27 Mar 2018 09:30:56 -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 S1752590AbeC0Q3P (ORCPT + 99 others); Tue, 27 Mar 2018 12:29:15 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41196 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752559AbeC0Q3L (ORCPT ); Tue, 27 Mar 2018 12:29:11 -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 0461810A7; Tue, 27 Mar 2018 16:29:11 +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.4 21/43] x86/mm: implement free pmd/pte page interfaces Date: Tue, 27 Mar 2018 18:27:25 +0200 Message-Id: <20180327162717.639376176@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162716.407986916@linuxfoundation.org> References: <20180327162716.407986916@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.4-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 @@ -676,7 +676,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; } /** @@ -688,6 +703,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 */