Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1250427pxb; Sat, 4 Sep 2021 04:43:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSsvDfylksWZWpZN2F40UjFJqMBOnUzhCXsrY+eSG3vg1CMxVBacQUsCb47cnILgE0Kvx1 X-Received: by 2002:a17:906:5e4b:: with SMTP id b11mr3946670eju.472.1630755806422; Sat, 04 Sep 2021 04:43:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630755806; cv=none; d=google.com; s=arc-20160816; b=WRBlp4/jxFVORuZlC9IkgY9/hdezn0oJ0ti1DUCtqWc+ITJB9XASc+N4qHe76Im9Ex ZEp7KoP0vEBaeDHnWNXmIghMU26rM2YVYhbS1jEYVnAvOQ8CG1IrKMFhu/jaGyIcYaOj zQQi875qDZCRtc7WI4VEZiTzZQLznhJAoe0VgtX+pu3IZbn7fbS7y4pjnCbMSDems47Q zVa0i+ybwLSS0ca8ZSgxVRDSB8JegsKwyuHqRHoX4Vvrl7R87bU1M/NiziDDwSViRLT6 yUfbee4os6mgKzNM/4kxo8Wc6JdHBm5lGvcePhwfILFzOPfxi8UocFkS2jgtOFGgpFAd FI4A== 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 :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=rKIJGr4LxNvf6bGeq19fnSd30tX36l40x3zNqhpTpvs=; b=tRtVVU4L4fDfIqUIQDZJAHzOvNHRG61rADFamMHtjVejtPrSbEigtohtd/bGFmoo+F Oiang4cMvSoYQvpBPKLz06V0z/Mdrj2tQJblua6lyAyaned0Qb5Hcji+bPxMPHW1sfUk dRLsUt5MsPCCW1u2P2ULNo2u+6PX9AbbFuaJFks/QKcNvaGIe3J6ckfDURJ7XXgWnvgT Y1KWC2GGaRXNrfVprB41+EFH+2NhBVVvIher7KCZ8MR58xj38wYXQd7tWxNHMvBUpOsC Hcyamo2P56rMWpzr4cY6FwEa5/rvfHp7XZND7lMWM+b6VyULpEHUIfjdg+XlneQCbz0v 1mhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=luaLPnw8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jg4si2182014ejc.285.2021.09.04.04.42.34; Sat, 04 Sep 2021 04:43:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=luaLPnw8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351119AbhIDLVl (ORCPT + 99 others); Sat, 4 Sep 2021 07:21:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235621AbhIDLVj (ORCPT ); Sat, 4 Sep 2021 07:21:39 -0400 Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C58B7C061575 for ; Sat, 4 Sep 2021 04:20:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1630754434; bh=rKIJGr4LxNvf6bGeq19fnSd30tX36l40x3zNqhpTpvs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=luaLPnw8QYAsNQGZqh0g5RYKx8r7mBIqT/9Y3PGDLZthzqEuG71MY6vpLer+nTjy/ w3QwMkdUjQfuwEIpnylzNgP/SwOg7Rn5kxujT/upa9icQM2g+KzdhvwKOmaR1PPHmj 3roNx8acOBkcpfMjcP4omZZl+COk4n52P0YFRB5tQ/zMn3nOWDg51633mcCQxIKzBv QR6DpFWuVfdBoJVpVF27hORP0IEgujZn7BHMHWtALMkKkRBnhmdIjYpDUfjNch6DZO iKX+/OPCkkiOZkApdopXBmM+FD20ZY1lHXjjhpoi70+cvEbs35VG0iDjSXYjCLFfXT /G6IOz1qMJzTg== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4H1sf91PV3z9sVq; Sat, 4 Sep 2021 21:20:32 +1000 (AEST) From: Michael Ellerman To: Nanyong Sun , Christophe Leroy , benh@kernel.crashing.org, paulus@samba.org, akpm@linux-foundation.org, npiggin@gmail.com, christophe.leroy@c-s.fr Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, wangkefeng 00584194 Subject: Re: [PATCH -next] powerpc/mm: check base flags in ioremap_prot In-Reply-To: References: <20210903090339.3671524-1-sunnanyong@huawei.com> <90aa2b67-24c8-4a5f-d91a-b562054d5c5d@csgroup.eu> Date: Sat, 04 Sep 2021 21:20:25 +1000 Message-ID: <87fsukzix2.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Nanyong Sun writes: > On 2021/9/3 17:16, Christophe Leroy wrote: >> Le 03/09/2021 =C3=A0 11:03, Nanyong Sun a =C3=A9crit=C2=A0: >>> Some drivers who call ioremap_prot without setting base flags like >>> ioremap_prot(addr, len, 0) may work well before >>> commit 56f3c1413f5c ("powerpc/mm: properly set PAGE_KERNEL flags in >>> ioremap()"), but now they will get a virtual address "successfully" >>> from ioremap_prot and badly fault on memory access later because that >>> patch also dropped the hack adding of base flags for ioremap_prot. >>> >>> So return NULL and throw a warning if the caller of ioremap_prot did >>> not set base flags properly. Why not just hack adding PAGE_KERNEL flags >>> in the ioremap_prot, because most scenarios can be covered by high level >>> functions like ioremap(), ioremap_coherent(), ioremap_cache()... >>> so it is better to keep max flexibility for this low level api. >> >> As far as I can see, there is no user of this fonction that sets flags=20 >> to 0 in the kernel tree. >> >> Did you find any ? If you did, I think it is better to fix the caller. >> >> Christophe >> > I see some vendor's drivers which are not on upstream ... Sorry, but we don't carry extraneous checks in upstream for the sake of out-of-tree drivers. cheers