From patchwork Tue Jun 20 13:13:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13285831 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 8990AEB64D8 for ; Tue, 20 Jun 2023 13:15:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E2928D000A; Tue, 20 Jun 2023 09:15:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 292618D0001; Tue, 20 Jun 2023 09:15:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15A9E8D000A; Tue, 20 Jun 2023 09:15:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0846E8D0001 for ; Tue, 20 Jun 2023 09:15:34 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A63D240F75 for ; Tue, 20 Jun 2023 13:15:33 +0000 (UTC) X-FDA: 80923172946.18.1DBEE5D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 7A94E40020 for ; Tue, 20 Jun 2023 13:15:31 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=g0ezbjGC; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.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=1687266931; 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=OF4xS/zSKqXEH3knil+4AzYUscbSVX8rrhI8wKumqWCPgWetkC78NcIq7YCcc+hVCt3uhY 6l4EZr6IFm2/t6YPt+yOkAnm6P8DravhnPwst9D83MVF57li3tv28NXuonThzEoOTybL6Y QqW7P9EINNuZQ+W8G37TRnQl946zYFE= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=g0ezbjGC; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.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=1687266931; a=rsa-sha256; cv=none; b=n7uxRB2AzOGeeKy5L/7waniQuEOFvrhM6uML8VFZpuPjx+VNlr/UPn8ObkMeDWeHuFJ8Pi Kar5WvW5Iy5w32Va10Jr+9sHyAE4WhFIWPCko2HdZYmQfravckCvuLTSXhWr/EAVnmzbHV kXoX+0Tn/Nos/SI7oymhqjQbD6OK3FE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687266930; 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=g0ezbjGC46VxvcIq+UHr019/aL3Ob4NT/XBjOkhCzR3kJYsZOR0UM8UQEOICELZoiJshd7 MZeHzRq4UwCT7ZJgYJwTnOOFo5Aa0RDWlbMTs1HRRjuU+RVE/jXf3yJvGNC4n4j+KEDhy4 CGuS99QE+kTE1y7borS69q01iCrsKgA= 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-223-eZ8OPzrSP4eN5oanIq9oUw-1; Tue, 20 Jun 2023 09:15:25 -0400 X-MC-Unique: eZ8OPzrSP4eN5oanIq9oUw-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 4EDD1185A7AA; Tue, 20 Jun 2023 13:15:03 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D9FCC1ED96; Tue, 20 Jun 2023 13:14:54 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.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, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v7 06/19] mm/ioremap: add slab availability checking in ioremap_prot Date: Tue, 20 Jun 2023 21:13:43 +0800 Message-Id: <20230620131356.25440-7-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-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: 7A94E40020 X-Rspam-User: X-Rspamd-Server: rspam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OQlnMM8Za+ukk5aCE6oOERhNl045mENgEvMvdNWmN32tiaJep+IXd78LBL804zolzHrc5XKneHD4VXp3f5z8pSrcZKEHg/tQiHBVLcOYQ4gsrS/o8bOxQXDsku9YKPs6ce88bPJxTDAOpFlyGGlNz02DASZvZpw8ozgtHJUajF7xVry9PMIhhcmuocRmzNEgaB7AS/7hlqR1LtDKlAvzNYoaxVf6BSlWSgz7mj2+xfskErx5lCeafjZTKBoiMZu6O0GYl79Tc6KQ0qmZv0gFdye2a+wtGNRYpE0Ye3ve8YX0tywpZHXhxgKV+cNbl5VJ98+D4jpBibEAYO/CqOqiofE+3rPDbVCNddA39OOs= 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)