From patchwork Thu Feb 16 12:34:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13143031 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0545EC636CC for ; Thu, 16 Feb 2023 12:35:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 970916B0078; Thu, 16 Feb 2023 07:35:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FAA66B0082; Thu, 16 Feb 2023 07:35:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 773BA6B0083; Thu, 16 Feb 2023 07:35:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 67D8D6B0078 for ; Thu, 16 Feb 2023 07:35:13 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 368AF1609E9 for ; Thu, 16 Feb 2023 12:35:13 +0000 (UTC) X-FDA: 80473100106.19.BE04914 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 6ECF1C0011 for ; Thu, 16 Feb 2023 12:35:11 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="II4/IOpQ"; spf=pass (imf28.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676550911; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=b04gx2CEsZva7MKdHssokOo8Q5KwYfP6QKwltziak5c=; b=U752U5AEoevJsGMXcV1jgC79WOC9TRUFNRXWMPpFvQeYxLoRBMTjbA94+2lH0bq2qYyxBN QHYOSKqqqrGjhaXWnYKD+mlFtJsnoBVmOJSFpDfmTVy1v50JkdPjUWEVTYn5NM2fV1CdDR zx8H8JwPSnGxo+oAj04BHA+POiQTl28= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="II4/IOpQ"; spf=pass (imf28.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676550911; a=rsa-sha256; cv=none; b=N1K26nss32Upm600fEcald8b4O9xoF6dScvOxweAtyg2BIv/zHU5Zv4Mn6dRVarDtRN3tl yD/E4Q8FkdRyiCVV0xo8X4+Lm+n5RNr2vlopOuUT0jYoSKHzIohOadcBIQ+UWfJDvA8a6o XAe1MxhyXyB4YAYy709Zzi5pWvtlRgM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676550910; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b04gx2CEsZva7MKdHssokOo8Q5KwYfP6QKwltziak5c=; b=II4/IOpQ/8Uf1SWu/cHABf9bLStTqTST6LuPNONlxIMGtgkfIPLgJu9PJaoJNtJs92reBR SD2rOXi0fcQ2fpHXwtPn7FfLM5Cla1rEJ43VXOhxd/mR9hoHSyuj5y8VqfIICirs7XfTzF GrxM0tjpAX4VtNEzw4GI67SLDLah41k= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-651-rRYF4ZJzMveowcX66KqSBg-1; Thu, 16 Feb 2023 07:35:07 -0500 X-MC-Unique: rRYF4ZJzMveowcX66KqSBg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0E2AE185A7A4; Thu, 16 Feb 2023 12:35:07 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-99.pek2.redhat.com [10.72.12.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D81A492C3C; Thu, 16 Feb 2023 12:34:59 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, arnd@arndb.de, Baoquan He Subject: [PATCH v4 05/16] mm/ioremap: add slab availability checking in ioremap_prot Date: Thu, 16 Feb 2023 20:34:08 +0800 Message-Id: <20230216123419.461016-6-bhe@redhat.com> In-Reply-To: <20230216123419.461016-1-bhe@redhat.com> References: <20230216123419.461016-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Stat-Signature: mz56hdfcfqoidbz8a349xhzjd41w1xrm X-Rspam-User: X-Rspamd-Queue-Id: 6ECF1C0011 X-Rspamd-Server: rspam06 X-HE-Tag: 1676550911-683969 X-HE-Meta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7m5BREWPg+bK9a/U3fLJ3j/4Cka85yqOtI/Sd2R0KBYae909wFCKQ+dRlBMHAyysm0uRF1XcRfmF/HwzfHq6gx8vFZlopW8F3irH9xRdFg35VlJHl1BOcA0zMho3/7Itdng9gvcSwgzAlylaFrq7uMzj9GcWal7/QPpqYwwWCjzuDGoajtTKOw1eoon/PqQGE50mBZSKdcjfW94xo0EBE= 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: Several architectures has done checking if slab if available in ioremap_prot(). In fact it should be done in generic ioremap_prot() since on any architecutre, slab allocator must be available before get_vm_area_caller() and vunmap() are used. Add the checking into generic_ioremap_prot(). Suggested-by: Christophe Leroy Signed-off-by: Baoquan He --- mm/ioremap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/ioremap.c b/mm/ioremap.c index 9f34a8f90b58..2fbe6b9bc50e 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -18,6 +18,10 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr_t last_addr; struct vm_struct *area; + /* An early platform driver might end up here */ + if (!slab_is_available()) + return NULL; + /* Disallow wrap-around or zero size */ last_addr = phys_addr + size - 1; if (!size || last_addr < phys_addr)