Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13428138ybl; Sun, 29 Dec 2019 11:38:08 -0800 (PST) X-Google-Smtp-Source: APXvYqyJq9zhCkZo2Khxc6EPy9tFuZgtQvqaZqOyBG0l+p0T+mTg/rhlS0kRlL6mUZBuzNRimKq/ X-Received: by 2002:a05:6830:2102:: with SMTP id i2mr67958636otc.123.1577648288710; Sun, 29 Dec 2019 11:38:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577648288; cv=none; d=google.com; s=arc-20160816; b=IsxZ1o1X09k6vXYY3D+UxEfVzKqbrqIFdoLykhM0P4yLfdMBV95X1jD5mwolPiDO1A fjTjyyGwDmNSM0fXrHzlsJOmqlVodhzsCS59Y/wGeliHvgOIIyTnPhd5fDtBozfzu9vk 1NjzcLVTA2vZfK6JxRlAK/UYzofXct3CwRQdI68OK2h/EbNjOOh8US4fR4ercCNLV0Sz PS9KiMf6ONT5nWVOMoYU8NngKXyVtT66fQZizR6XZokce2A/igFAAtqMpzFvInBkgU6z 8Dg94ChCTcHn50nAYu6XEzLPJ5x8vv7N1PmT0ihNIf04pGPssA4Psk//qP7D+zU+CtGi 7+fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Gp5s6UomJDIohS1iTBM0S28U2Z6EyYpugPw16QLDYbA=; b=AHAmOOT+BlxpAoz4XsQD/wADSIW97YXkPxg9ZloM+5eEmPqPrld9LL3akoN+ZHBmFb ot/ncj5pBtBbl71x+ibbvWC5bzuJuP3KnKLO5MfqXaRnk+ctiy+rXW2ojmgr0qeE1fKF Xsy3+1U7+7W1AHPrH4NxP3R4APuPoRdo3oLpXldMzzcG020eDlvQmL+TkVUpbeElPb/8 e5dnHUlOK1hwc332M6SGmYcmDeStHci/tSQO0oCVxEyaUFriRRAUz6OYldk4T/Jt/Drz MoniaMQeHlm04po93ZlKOp1eIdMQh3cIiXuDK1O5YhdoYCqZQzjYVOGs5u7vFiUa0onm 0X2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1QvF3jNl; 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 q66si18827371oig.65.2019.12.29.11.37.57; Sun, 29 Dec 2019 11:38:08 -0800 (PST) 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=@kernel.org header.s=default header.b=1QvF3jNl; 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 S1729216AbfL2Rbp (ORCPT + 99 others); Sun, 29 Dec 2019 12:31:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:59414 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729207AbfL2Rbo (ORCPT ); Sun, 29 Dec 2019 12:31:44 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A7784208E4; Sun, 29 Dec 2019 17:31:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640704; bh=KlQYiksmKM5kFTzFIj/mG8dWpKkR4NxVlxj5Oju68XM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1QvF3jNlKyV2iUSgkh1W9+Bf2FeIabX8wGqy+UgZYiWVm7U0Zv5BxZJrNsdmhxf/l U7MhJwoI77yms12uvOQBMhiE97HvYek91w8Xz2aFtr7aWC4bOvkQfW8wC98r3JCLCn cRRcK4YU3onGl90G9f76ChCAecDrOk2JE/qshPXs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gerald Schaefer , Vasily Gorbik , Sasha Levin Subject: [PATCH 4.19 105/219] s390/mm: add mm_pxd_folded() checks to pxd_free() Date: Sun, 29 Dec 2019 18:18:27 +0100 Message-Id: <20191229162524.536681246@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162508.458551679@linuxfoundation.org> References: <20191229162508.458551679@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gerald Schaefer [ Upstream commit 2416cefc504ba8ae9b17e3e6b40afc72708f96be ] Unlike pxd_free_tlb(), the pxd_free() functions do not check for folded page tables. This is not an issue so far, as those functions will actually never be called, since no code will reach them when page tables are folded. In order to avoid future issues, and to make the s390 code more similar to other architectures, add mm_pxd_folded() checks, similar to how it is done in pxd_free_tlb(). This was found by testing a patch from from Anshuman Khandual, which is currently discussed on LKML ("mm/debug: Add tests validating architecture page table helpers"). Signed-off-by: Gerald Schaefer Signed-off-by: Vasily Gorbik Signed-off-by: Sasha Levin --- arch/s390/include/asm/pgalloc.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/s390/include/asm/pgalloc.h b/arch/s390/include/asm/pgalloc.h index 5ee733720a57..67838df3f3f9 100644 --- a/arch/s390/include/asm/pgalloc.h +++ b/arch/s390/include/asm/pgalloc.h @@ -56,7 +56,12 @@ static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long address) crst_table_init(table, _REGION2_ENTRY_EMPTY); return (p4d_t *) table; } -#define p4d_free(mm, p4d) crst_table_free(mm, (unsigned long *) p4d) + +static inline void p4d_free(struct mm_struct *mm, p4d_t *p4d) +{ + if (!mm_p4d_folded(mm)) + crst_table_free(mm, (unsigned long *) p4d); +} static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long address) { @@ -65,7 +70,12 @@ static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long address) crst_table_init(table, _REGION3_ENTRY_EMPTY); return (pud_t *) table; } -#define pud_free(mm, pud) crst_table_free(mm, (unsigned long *) pud) + +static inline void pud_free(struct mm_struct *mm, pud_t *pud) +{ + if (!mm_pud_folded(mm)) + crst_table_free(mm, (unsigned long *) pud); +} static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long vmaddr) { @@ -83,6 +93,8 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long vmaddr) static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) { + if (mm_pmd_folded(mm)) + return; pgtable_pmd_page_dtor(virt_to_page(pmd)); crst_table_free(mm, (unsigned long *) pmd); } -- 2.20.1