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: 110471 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3659217vqr; Tue, 20 Jun 2023 06:19:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4gO2zUjChYstYtvUKglH2FhO7AJo204HMBy8kxiepnYh8MAu/jSkj2ihT3CHaUIfE3aum+ X-Received: by 2002:a05:6a21:6da7:b0:11f:2909:fe9c with SMTP id wl39-20020a056a216da700b0011f2909fe9cmr14768461pzb.20.1687267168721; Tue, 20 Jun 2023 06:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687267168; cv=none; d=google.com; s=arc-20160816; b=ILLGkcYbFIXI0fQnzTY9BYomaGi6TUBSwpXRNba31FHs5HTp3eMj7jTy42H/l82AQQ rtfgrNgPNaCCyZtZ5doMUlASCQxlHTxwpZCdbGZ5PsVt0034HVmFcKpagY6/JkrQEaBO qeyiBZ04pS3y14PUFdrmrCFaZOeZNsuJSPAPjDJW1D2lX3LvUAxR7yY2TPphe42IHxoI +TsYaHYSgkrnIFdjUmJXhQI6DhKlcmhr318gBcB8Wxps8fj6ao1sgoQJWiDahichBNjT FqN618q3LM7WAMW0PBodR+xeZje2be1pPoZ+s//SrARVILDMGSZ7njiVPp1NNMobqcbD 4O/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=w2IfnXMZqwx1Jn18is50whUi5yxeZ3Kn4EXboxrstks=; b=zPv9hy2zm0HzGN10KkIsrU6OYQzEyIpCwoYfSeGI8NZbNX0O9JnXWvjabtCI8bNJ/i By37T8LJqoJGz3byA2Az8Y33+f1mbEhkSdaUVenPJ3CmpZYrwEbAqWMtf36xiNJwEaAp JZupYFCOiJkD9lVFiobWZ5u/rK2DIZtDpJhSNnh4nwLLppdAJY1OUdfGcZ73fw9QpXe9 hET9Zb3K76zO278YNayQO1Cec6n/D14Ah98XFbA1OTg8ncFI+pOw51QcfdGQR0Jg4/ee iQ5XdxbsUsuShVRsJmHTEtNyWOucPJ5f04Wv/7ZGT/1exxkebehYA0pEjZ7uPC7blgGN 3fPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FXl5Arfg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h191-20020a6383c8000000b00543c1b205a5si1694216pge.149.2023.06.20.06.19.09; Tue, 20 Jun 2023 06:19:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FXl5Arfg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232549AbjFTNQi (ORCPT + 99 others); Tue, 20 Jun 2023 09:16:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232828AbjFTNQQ (ORCPT ); Tue, 20 Jun 2023 09:16:16 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 663B5120 for ; Tue, 20 Jun 2023 06:15:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687266928; 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=FXl5Arfgq2r/utdrNGPe4FrpovXezSGiUjudhqvYargbRB7FS3t1zUPTJBf7A/q1+dm2C5 gzhDIu36IvqfB7sb/dJIfYM+dqepuRjUF0DgJMlOR4XmZFo7kcUe2iyR4aNDwtKBqX/Fcn 1J6DkL6UlQdlAn45ovNo7KG5h9Axjl0= 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769227858257708294?= X-GMAIL-MSGID: =?utf-8?q?1769227858257708294?= 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)