Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1747615rwd; Mon, 15 May 2023 02:24:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6YN6ReE61OHDa4CajxG94tOd+veWcDgdO0XqqG65minJGQOcfC58N2Ahbn2cY9dOJwTZ8/ X-Received: by 2002:a17:902:c950:b0:1ac:71ae:ce2f with SMTP id i16-20020a170902c95000b001ac71aece2fmr37393101pla.20.1684142687095; Mon, 15 May 2023 02:24:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684142687; cv=none; d=google.com; s=arc-20160816; b=XkHxvHOAXqKspIDrSYepprqeJHbPG1Be61Xxt7q47AiplZM09kVM3TNK44/fSuLa1R L8xPmowkthRyq99JEAwcqVrtD+dsokA6ZRWe3gTdX1mLA29T8PmS4wK5ZUp5WvLPEtt4 6UZUjA4oQ3UttQpxfcgxPJVwgJ+sNU0Pc9wME+T19o6nFA8CPAgy7m2e3id5wFPW1Pu2 SkUe+wmblzNJqwX/vh2RvZe5O2tKDzQXMtf24kpLhx8Lv4Ne7S9l9/MGUuPZ3sL4yRk1 5SQnxIIVh0NArl7HH/OVSKrQMoQOpi0aDgtJSxWk2Vhk6jiwBf52H7IToZmESqhqnOFR ouqg== 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=b04gx2CEsZva7MKdHssokOo8Q5KwYfP6QKwltziak5c=; b=yir5hTQTiNE8BbH/Y/BaxCZvxcBdbVHbBZ7vHi/hr2RjAzwNbWWgZn55npexFezItO zQs+8WmTFLwD14rYc0U8baQc0r8jtyJHoPmUKoGd127Mn1rxepnyB+MsoMXIbAgofIHU zcb/9IxkYsR/Ijb5F2URz63XY9shW7K62qwqJkfzdsaw2ZCOJAXOEp/nMpqvJuTMgvzr Ujm1zzHl3HFIo8H0BDtvVVFGF7gjOLh2H/w3NQN5EWSgnYNXleL7yazivbYpBABpM1WS rgeAtBi5hK1thRq3nId3KjHj/B4Zpe8ZlFLBffLBXjelkxdCjWh2FkrBHYVoMc6tLBGA 0bEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AdeXtHno; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k7-20020a635607000000b0052cb36e0bfdsi15086864pgb.429.2023.05.15.02.24.34; Mon, 15 May 2023 02:24:47 -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=AdeXtHno; 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 S238623AbjEOJK7 (ORCPT + 99 others); Mon, 15 May 2023 05:10:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230107AbjEOJKb (ORCPT ); Mon, 15 May 2023 05:10:31 -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 DBCA010C2 for ; Mon, 15 May 2023 02:09:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684141793; 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=AdeXtHnoQxzJJAPLT88E0F/P5WsQJmLdiCPF7XHWsy+wrnmnc1jgBRk9ppiaSe+gNfDZbU lBbHtKWasEeqCu4mIEkoK1oGZM0aTDf/PunQXWxirNzgtGj607bY2od1Y4nKCtO/pss1hR 4i8AfiTeTKp4vtxhBIGU123jzr8Qw6U= 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 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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=unavailable 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 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) -- 2.34.1