From patchwork Thu Jul 6 15:45:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13303964 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 0B852EB64DC for ; Thu, 6 Jul 2023 15:46:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A68A6B0081; Thu, 6 Jul 2023 11:46:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 956B78D0001; Thu, 6 Jul 2023 11:46:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 81F9A6B0083; Thu, 6 Jul 2023 11:46:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6FA306B0081 for ; Thu, 6 Jul 2023 11:46:34 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 1FECAA0666 for ; Thu, 6 Jul 2023 15:46:34 +0000 (UTC) X-FDA: 80981614308.24.6B6E410 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 3013514002C for ; Thu, 6 Jul 2023 15:46:31 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ENREJSos; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.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=1688658392; 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=w2IfnXMZqwx1Jn18is50whUi5yxeZ3Kn4EXboxrstks=; b=hqUS53NT8IZinL4ROVvrKIzQwht9Sg4I2LAvJRxHqOsEcMjI+MshPYDfLhNe6q0fC/tAXt StrPR/ll15yClYGsBXkh9A4ZjCh2gRk/kh72hKfsXkKR0Csueho5sT1rVqFLGxJRB16abR Hvx02Qp1w2CRU05vrLwCSJc+Cwoo9hA= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ENREJSos; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688658392; a=rsa-sha256; cv=none; b=viT1/1+IVPsbQx9mYx2P0OCuK5wPfQ9JOiui6L/zmOMuu747t3gaQcqolt2wbkgdjzQkwQ 3ysLk8kSTEmDETBnHl7AvUrHDWv6vfmFitenYnlu5lSqeg5xUvLwJh2YuS7y04S3TU11jT iT78OyhaMKpOaLkxllqiAiBjBsP/VHQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658391; 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=w2IfnXMZqwx1Jn18is50whUi5yxeZ3Kn4EXboxrstks=; b=ENREJSosXoQL59kmxBwlE3/L+OLhRqB0LEXmuxLM+EghDV65gds2IeygNqB0Ilk/79Q95V gj1ix/tRL6VnE2tXilLKOdAwGABdoJaZqKaTeNferB0IAsCLXKBWTGtyfdg8jqtijW9RlY eZ7g+ajhi6v8a9V1LzKbvks1Upw0Vck= 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-RU_tALYvP5a7WTS2Ws1CNg-1; Thu, 06 Jul 2023 11:46:27 -0400 X-MC-Unique: RU_tALYvP5a7WTS2Ws1CNg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DAE023815EF8; Thu, 6 Jul 2023 15:46:26 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47CFFF5CF0; Thu, 6 Jul 2023 15:46:18 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v8 06/19] mm/ioremap: add slab availability checking in ioremap_prot Date: Thu, 6 Jul 2023 23:45:07 +0800 Message-Id: <20230706154520.11257-7-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Queue-Id: 3013514002C X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: e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mSXgVue7e8nUwklX9+Yb8NoDVypVJAugy+UEpLXWumYi+L5kY1XqFHxDwVf6pdctlhfVsJaEu28y9r+hj6/TIAtIaUi2CxP8NRBAexVN3k3r9IUH3zcGIujfNoqkt40XGgB2ElM3uvDZTaomlawZs0BvUOUFsy8vKAwoGHnA+w0zHRJhkG0OQcpVWi50D6yYuHe/BhnRqfGySC5zP1m4nCVmnnQ1HUbKH23j1Wij7rDK0/a/Psri6CLzwB7AUYCxqXGZO8gp6UrMqde4ZdQgE3iLt9KngAAeD8vF+Ea/8Le4bH6YvkxIYW5VZBF8GwE= 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: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) --- mm/ioremap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/ioremap.c b/mm/ioremap.c index 9f34a8f90b58..86b82ec27d2b 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 (WARN_ON_ONCE(!slab_is_available())) + return NULL; + /* Disallow wrap-around or zero size */ last_addr = phys_addr + size - 1; if (!size || last_addr < phys_addr)