From patchwork Wed Mar 1 03:42:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13155572 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 90207C7EE23 for ; Wed, 1 Mar 2023 03:43:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE7FE6B0082; Tue, 28 Feb 2023 22:43:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C96EB6B0083; Tue, 28 Feb 2023 22:43:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B115F6B0085; Tue, 28 Feb 2023 22:43:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 912136B0083 for ; Tue, 28 Feb 2023 22:43:44 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 497B3C0FED for ; Wed, 1 Mar 2023 03:43:44 +0000 (UTC) X-FDA: 80518935168.24.879739B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 7F7F420002 for ; Wed, 1 Mar 2023 03:43:42 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NS2w9Xrw; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677642222; 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=GWyAH3w7vV9PIjJGxq9nIlOoABeU4Oe46UfgcwCgItNSZXRWWD8EwxYBJ51YeldZut0TC3 dkb8dmLTk2OxBbYPhdPfUQ7u/wmdPyZyilODlugq9PdfD7yM3wXjRIk1LFe908VDim9us7 lHQqRm5CNf1tVCAawkx4Y05u7p8cDKI= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NS2w9Xrw; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677642222; a=rsa-sha256; cv=none; b=Z3AWEQp180SXNpeG3gGmvNFVMVNyXsuMPgyk1zDZKNXvP3274KrfH51+zgpl32IhfpvKNY KN8oTQBCLLL8Ov4vbVYr+L310/lxeKH4hJeJr3AoAMUltTCGGAV3LaEL5WBzrmHWv7ldPI fo7Ma8bu8GG5gAs/l5iQHSmSEzBwELo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677642221; 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=NS2w9Xrw/Q68vAsiqWOEQ+oFv0e800p3rZ8WfciuaVXjlEBO5rn7AjaaPFK04csVMpdYbr 0nRtlqOTj7kIMFFhh+GKe8kmukr1IRJwYdPmDtQerIzxX3qSeMsW2SIrnSckJ2sA1cNYNX qPn7hX7deJ/SVHIVi7jN5mW0GN9wwi4= 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-434-8Y9zFz3EOyOEh-jq97Zmzw-1; Tue, 28 Feb 2023 22:43:34 -0500 X-MC-Unique: 8Y9zFz3EOyOEh-jq97Zmzw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 61920811E6E; Wed, 1 Mar 2023 03:43:33 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-180.pek2.redhat.com [10.72.13.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id D76C3C15BAD; Wed, 1 Mar 2023 03:43:28 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, 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, willy@infradead.org, Baoquan He Subject: [PATCH v5 06/17] mm/ioremap: add slab availability checking in ioremap_prot Date: Wed, 1 Mar 2023 11:42:36 +0800 Message-Id: <20230301034247.136007-7-bhe@redhat.com> In-Reply-To: <20230301034247.136007-1-bhe@redhat.com> References: <20230301034247.136007-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Queue-Id: 7F7F420002 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: h9yc3mc7pu9mmyqstpyi5ceegomuoimo X-HE-Tag: 1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ZHN5NIkM9Hyj3wm0mvS6lDp5avDNACeCJCAS2ln7PVB6nfrx1hXa8dNpHKXM3AGO6twT3ISX8S68+h/ruBSQiMAWV7D6Zt3qG4xF+LmaGO7iN+vua8WNs6I7XzL+2nguTLqfay63jfJu5Z5NmCqNyOsw7/fCRw+wjuz6+MlgS+jENZIeC9tdiBMRqPOAWP2XjOZ4IRH/AcFcsNumbrbKstEZllRmmjzo= 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)