Received: by 10.213.65.68 with SMTP id h4csp884492imn; Tue, 27 Mar 2018 10:33:19 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/XPWlxU+6R0PFSRcZyI5JN2HuCA+8ssYQcV2VHzD98R9rMzAEjups125fhxLrANnMV321L X-Received: by 2002:a17:902:6ac1:: with SMTP id i1-v6mr238389plt.152.1522171999673; Tue, 27 Mar 2018 10:33:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522171999; cv=none; d=google.com; s=arc-20160816; b=wIsP2HmAD6wLg+zeMpHvN+ZNR4xIV5GvzHKsjLJTyf7nM7V+9YzVoiRDrWLzpnxMga E8r2rcddqtWc1noJ5bku64/eSeZ0Wj5zC0h6bMSBBK5goWzvH3yDYMPkRaKF7B3FLnJp EyGjokbDqCMXdbzbLW7snhz04sickUIDoX1bOgrNbdcm9mw6o0W0al5MOjpyFbWMJ+Uv /bN/63tkY+TXasA3gwka/YgEVfMB+KGGltCT6FX8DknMhIuEhKaL/zaATDVtqM4QUdD9 Nv05hkJCcwdGsm36G+bBTK/9U4a+AT9yc5gLXzQg8qv0JzLhAf7I0EdZY/7uHqO5u7fO X8Tg== 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=y15QJTofS7grVwKzCP1u2SWBrICxJwQd3Kitu0BRpmk=; b=QfdsYgPxFhTqyz/7rO/4wVCSTJ1VfDfEpxZUKpHYN4w5fF6nDx2VJI8fGz03dLljPo qO5VEj4TgYdTndgrPLghTybSEMSVhEncMW2GY9O0DAme3bC6AbLXWLroajtUKTrjLG28 vPKny8eJPkat1m7c8uxJG525rEfmI8ZF8hh6cwsJSiZJ+1TKgeK7Zfs3ImzBMQPCtPj5 iNAmT/xmF7rqBNC+aTuE/cJu+aZz9389kxpUlSkRQSq70Q/LrE+StXQerXUcF36h8BfK 42H40ALFPFuTj3247Op1b3yBg9ZLiz33rNFI3YxMDgGQPOAP/6cG9P33bWGoF6Vghmlk p+wQ== 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 g15si1119887pgf.541.2018.03.27.10.33.04; Tue, 27 Mar 2018 10:33:19 -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 S1754597AbeC0Qfw (ORCPT + 99 others); Tue, 27 Mar 2018 12:35:52 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45512 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754065AbeC0Qfs (ORCPT ); Tue, 27 Mar 2018 12:35:48 -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 2CA6240C; Tue, 27 Mar 2018 16:35:44 +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.14 048/101] x86/mm: implement free pmd/pte page interfaces Date: Tue, 27 Mar 2018 18:27:20 +0200 Message-Id: <20180327162752.983665316@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162749.993880276@linuxfoundation.org> References: <20180327162749.993880276@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.14-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 @@ -712,7 +712,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; } /** @@ -724,6 +739,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 */