From patchwork Thu Jun 4 07:44:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 11587225 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7EDD0138C for ; Thu, 4 Jun 2020 07:44:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4D3B7206C3 for ; Thu, 4 Jun 2020 07:44:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D3B7206C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=8bytes.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5A28A80015; Thu, 4 Jun 2020 03:44:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 553FE8000E; Thu, 4 Jun 2020 03:44:51 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4687380015; Thu, 4 Jun 2020 03:44:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0245.hostedemail.com [216.40.44.245]) by kanga.kvack.org (Postfix) with ESMTP id 2D0408000E for ; Thu, 4 Jun 2020 03:44:51 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id DAC6E181AEF10 for ; Thu, 4 Jun 2020 07:44:50 +0000 (UTC) X-FDA: 76890742740.07.cook27_6473924d75b02 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id BB8961803F9A2 for ; Thu, 4 Jun 2020 07:44:50 +0000 (UTC) X-Spam-Summary: 2,0,0,c6891c1c8e6542c4,d41d8cd98f00b204,joro@8bytes.org,,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1345:1431:1437:1534:1543:1711:1730:1747:1777:1792:1981:2194:2199:2393:2559:2562:3138:3139:3140:3141:3142:3354:3865:3866:3867:3870:3871:3872:4321:4605:5007:6261:6742:7576:9592:10004:11026:11473:11658:11914:12043:12296:12297:12438:12555:12679:12895:12986:13161:13221:13229:14093:14096:14181:14394:14721:21080:21451:21627:21990:30003:30054:30070,0,RBL:81.169.241.247:@8bytes.org:.lbl8.mailshell.net-62.14.6.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: cook27_6473924d75b02 X-Filterd-Recvd-Size: 4178 Received: from theia.8bytes.org (8bytes.org [81.169.241.247]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Jun 2020 07:44:50 +0000 (UTC) Received: by theia.8bytes.org (Postfix, from userid 1000) id A93F826F; Thu, 4 Jun 2020 09:44:48 +0200 (CEST) From: Joerg Roedel To: Andrew Morton Cc: peterz@infradead.org, jroedel@suse.de, Andy Lutomirski , Abdul Haleem , Satheesh Rajendran , Stephen Rothwell , manvanth@linux.vnet.ibm.com, linux-next@vger.kernel.org, Steven Rostedt , linuxppc-dev@lists.ozlabs.org, hch@lst.de, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH] mm: Fix pud_alloc_track() Date: Thu, 4 Jun 2020 09:44:46 +0200 Message-Id: <20200604074446.23944-1-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 X-Rspamd-Queue-Id: BB8961803F9A2 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Joerg Roedel The pud_alloc_track() needs to do different checks based on whether __ARCH_HAS_5LEVEL_HACK is defined, like it already does in pud_alloc(). Otherwise it causes boot failures on PowerPC. Provide the correct implementations for both possible settings of __ARCH_HAS_5LEVEL_HACK to fix the boot problems. Reported-by: Abdul Haleem Tested-by: Abdul Haleem Tested-by: Satheesh Rajendran Fixes: d8626138009b ("mm: add functions to track page directory modifications") Signed-off-by: Joerg Roedel Tested-by: Guenter Roeck --- include/asm-generic/5level-fixup.h | 5 +++++ include/linux/mm.h | 26 +++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/include/asm-generic/5level-fixup.h b/include/asm-generic/5level-fixup.h index 58046ddc08d0..afbab31fbd7e 100644 --- a/include/asm-generic/5level-fixup.h +++ b/include/asm-generic/5level-fixup.h @@ -17,6 +17,11 @@ ((unlikely(pgd_none(*(p4d))) && __pud_alloc(mm, p4d, address)) ? \ NULL : pud_offset(p4d, address)) +#define pud_alloc_track(mm, p4d, address, mask) \ + ((unlikely(pgd_none(*(p4d))) && \ + (__pud_alloc(mm, p4d, address) || ({*(mask)|=PGTBL_P4D_MODIFIED;0;})))? \ + NULL : pud_offset(p4d, address)) + #define p4d_alloc(mm, pgd, address) (pgd) #define p4d_alloc_track(mm, pgd, address, mask) (pgd) #define p4d_offset(pgd, start) (pgd) diff --git a/include/linux/mm.h b/include/linux/mm.h index 66e0977f970a..ad3b31c5bcc3 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2088,35 +2088,35 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, p4d_t *p4d, NULL : pud_offset(p4d, address); } -static inline p4d_t *p4d_alloc_track(struct mm_struct *mm, pgd_t *pgd, +static inline pud_t *pud_alloc_track(struct mm_struct *mm, p4d_t *p4d, unsigned long address, pgtbl_mod_mask *mod_mask) - { - if (unlikely(pgd_none(*pgd))) { - if (__p4d_alloc(mm, pgd, address)) + if (unlikely(p4d_none(*p4d))) { + if (__pud_alloc(mm, p4d, address)) return NULL; - *mod_mask |= PGTBL_PGD_MODIFIED; + *mod_mask |= PGTBL_P4D_MODIFIED; } - return p4d_offset(pgd, address); + return pud_offset(p4d, address); } -#endif /* !__ARCH_HAS_5LEVEL_HACK */ - -static inline pud_t *pud_alloc_track(struct mm_struct *mm, p4d_t *p4d, +static inline p4d_t *p4d_alloc_track(struct mm_struct *mm, pgd_t *pgd, unsigned long address, pgtbl_mod_mask *mod_mask) + { - if (unlikely(p4d_none(*p4d))) { - if (__pud_alloc(mm, p4d, address)) + if (unlikely(pgd_none(*pgd))) { + if (__p4d_alloc(mm, pgd, address)) return NULL; - *mod_mask |= PGTBL_P4D_MODIFIED; + *mod_mask |= PGTBL_PGD_MODIFIED; } - return pud_offset(p4d, address); + return p4d_offset(pgd, address); } +#endif /* !__ARCH_HAS_5LEVEL_HACK */ + static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address) { return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?