From patchwork Mon May 15 09:08:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13240987 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 8CAF9C77B75 for ; Mon, 15 May 2023 09:09:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BB92900009; Mon, 15 May 2023 05:09:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 24552900002; Mon, 15 May 2023 05:09:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 10C6F900009; Mon, 15 May 2023 05:09:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 041F9900002 for ; Mon, 15 May 2023 05:09:54 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A6E27141392 for ; Mon, 15 May 2023 09:09:53 +0000 (UTC) X-FDA: 80791917066.02.3CE8AE0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf23.hostedemail.com (Postfix) with ESMTP id E1104140016 for ; Mon, 15 May 2023 09:09:51 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QZdgSE9j; spf=pass (imf23.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=1684141791; 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=XC8U31xP5fFLjHL6RzrHHB2MczvK+57cnrfGUBCjEu1AoK+fI7vBrPOVqcZOp2p9SP8dTL YAy5QpTEX3jWNQehhM7IH+SV0ivN7JfR3ikMIfUndkiUdp7Um8LsAheXJVfeHxhvNRBAcI q83YnpheD0LvEmf6VuMhhi4/9n4qgu0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684141791; a=rsa-sha256; cv=none; b=mle6CbDksyb4/RI/sFYSHtVKdUmIAkJW4A6oiyeKh8LHCnE17DjFLPke6UtATW1UMdBPBj 2TapDuxKMGHiROJqy0D3i0JhBnoofc8mDSOO/OsYOoRDbiv5B6RsX004e1jhzYa0yVs2tv eTNBezvGvL4DH5kdYb5Jkyb7Rna3iQw= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QZdgSE9j; spf=pass (imf23.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684141791; 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=QZdgSE9jS1uEt/JxSb4nHlkXJ4IXVvV8gf+xs3eX1CXqR8WnyhDsqa/5XMv/BJlBBWzRDH 5wbnrJ8GOq5xmBZbZN7H1umWaewUjSTfIFqrNVVAh1IJSrzHkw0eYJeX/LFofotC02AW4J rFF/wuCZk4/5rRVECGF1OqsaKQrdQaI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-49-pgJ34I4-N4Gq1USkcYQgAg-1; Mon, 15 May 2023 05:09:46 -0400 X-MC-Unique: pgJ34I4-N4Gq1USkcYQgAg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1C4503C0CEFD; Mon, 15 May 2023 09:09:46 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FFEC40C2063; Mon, 15 May 2023 09:09:39 +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, deller@gmx.de, Baoquan He Subject: [PATCH v5 RESEND 06/17] mm/ioremap: add slab availability checking in ioremap_prot Date: Mon, 15 May 2023 17:08:37 +0800 Message-Id: <20230515090848.833045-7-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Stat-Signature: zikbpypumcrbzk9u5gkxnh3s5n3keki3 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E1104140016 X-Rspam-User: X-HE-Tag: 1684141791-522145 X-H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wczny9KGKqTGclKbegjnSkemzbi/6v5Vphbm9eLDYwwwiozctQW9/kPfvVTtxagDz5zx4z0az313fz/zESEIwkWqphbKeHT+lQ2WxD7PEBMa+LVJDy0S9QW62180UhH/TmekKoH2KGfeNq3ulPvK97fuuVBhNPjHrvM0LeUoxjKxPiJvevTlzTvgZypA5tIgCiPLS8n304DmAOaZQUJg= 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 Reviewed-by: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang --- 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)