Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp281798ybt; Thu, 9 Jul 2020 22:54:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxo4eiIp4QLboRgWfH/oqeRB8Wbig/8/CwkjVvcPqsr9BmLwJDCCur1rJKgpF2wjUzgYKUI X-Received: by 2002:a17:906:abca:: with SMTP id kq10mr46492153ejb.515.1594360492434; Thu, 09 Jul 2020 22:54:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594360492; cv=none; d=google.com; s=arc-20160816; b=FtjGv9BNJmJhYA3D0HRY4O/w+qUoxx9xFA0mopYlmxSwrEyLmAq6mb/xt/8XPXurBx agdPAZ6znUo3TCWjitHLGWN2CzaPofsuPOspJEhnHc7fHnmnEL5RSKkl8C5T0qO/SRIO Fkl2GOJVYX5/OtVcHXyRZrJZblNTom2yzVEy81ZKrfSt04gfrSFmRwdJYdEAdsizpBxM CJLR95KlAefllzBc7A6gZ04G//Pq2a0DFLKHmyPuTwFa7jTkl8iQXeuta4cAMqTVXtLf yDLZGE0iWarn6PXz7R6uEDoxFvfjdlTbcIusRi7d4hwkJFiWjK0dOCvfBp1PRyk6qXxy OiGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=RLTu3+HsCxbyd0XHLP7eqfjDQF9m/c45x4E/TaQCods=; b=Za6/g5cHZZiRvLdMbomlDrSjWUzb6aaIiBc99WQMLSCZghWKRYfRqq2AhwkWO3CZPi qI6x2kTIXYDI+86TZ7rX4iHZV3UIf0/JJSxuActD1L14A1+K62HvNBvSOYnbynrKM9Us q/k54j6UPZwsBqtnWP+hA9B3h44IvTltmeI9Iy/N7d2a+y/4MPG28V46eIiUhrOyDJ7r SJD9k5Aai+476/0yFYLQa2r2oy1ypuQRcUSGVhvCj3mdWDdwSz2e59AFOYawLfn+D8H1 Ir9fAdBA665gYUk94XXbjWuQ5ssCNN8O1rQhBJzJJlLNUmuv1JOHApDst1ZRWAmFXWNj o5+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=TdwzKJ6K; 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 ds16si3817705ejc.112.2020.07.09.22.54.28; Thu, 09 Jul 2020 22:54:52 -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=fail header.i=@infradead.org header.s=casper.20170209 header.b=TdwzKJ6K; 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 S1726794AbgGJFvq (ORCPT + 99 others); Fri, 10 Jul 2020 01:51:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725802AbgGJFvo (ORCPT ); Fri, 10 Jul 2020 01:51:44 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 487A2C08C5CE; Thu, 9 Jul 2020 22:51:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=RLTu3+HsCxbyd0XHLP7eqfjDQF9m/c45x4E/TaQCods=; b=TdwzKJ6KbOxKPNVPgtlBSB8eCE GiUZ/mHUxX+IkLfgDjuZWly7AhMRgob3HvY24kAOGFO07yG4CWvBAsYSneiAVMIlGfl4UYsHQ6/r7 QEC9VXjWzgog2kozgtbitj5C0W6jnv/CtLWa/Z9J/dLfrjGQyH+YNPXWWyeVNVReuG5Ul1nz5OcHb Qx+GixWi/iLAkyBxaBnqMqXoOy1Z0o8ayJoShQ2zPXbf15O9YcvLUQg6FpDs5mv4VAiDi1ojjGcx5 dqa+iwhvPqxEyuWAcxCaAbqlG41xKw8VCI/n3bgrKPBIrCAc1yBi6mD54voeiD6p/mdtiAdJadxjr 0DzQw7HA==; Received: from hch by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jtlwS-0007tK-I4; Fri, 10 Jul 2020 05:51:24 +0000 Date: Fri, 10 Jul 2020 06:51:24 +0100 From: Christoph Hellwig To: Nick Kossifidis Cc: Christoph Hellwig , Mike Rapoport , mark.rutland@arm.com, steve@sk2.org, gregory.0xf0@gmail.com, catalin.marinas@arm.com, linus.walleij@linaro.org, Palmer Dabbelt , zaslonko@linux.ibm.com, glider@google.com, krzk@kernel.org, zong.li@sifive.com, mchehab+samsung@kernel.org, linux-riscv@lists.infradead.org, alex.shi@linux.alibaba.com, will@kernel.org, ardb@kernel.org, linux-arch@vger.kernel.org, paulmck@kernel.org, alex@ghiti.fr, bgolaszewski@baylibre.com, masahiroy@kernel.org, linux@armlinux.org.uk, willy@infradead.org, takahiro.akashi@linaro.org, james.morse@arm.com, kernel-team@android.com, Arnd Bergmann , pmladek@suse.com, elver@google.com, aou@eecs.berkeley.edu, keescook@chromium.org, uwe@kleine-koenig.org, rostedt@goodmis.org, broonie@kernel.org, davidgow@google.com, Paul Walmsley , dan.j.williams@intel.com, andriy.shevchenko@linux.intel.com, gxt@pku.edu.cn, linux-arm-kernel@lists.infradead.org, Nick Desaulniers , tglx@linutronix.de, rdunlap@infradead.org, matti.vaittinen@fi.rohmeurope.com, linux-kernel@vger.kernel.org, mcgrof@kernel.org, Palmer Dabbelt , mhiramat@kernel.org, akpm@linux-foundation.org, davem@davemloft.net Subject: Re: [PATCH 1/5] lib: Add a generic version of devmem_is_allowed() Message-ID: <20200710055124.GA30265@infradead.org> References: <20200709200552.1910298-1-palmer@dabbelt.com> <20200709200552.1910298-2-palmer@dabbelt.com> <20200709204921.GJ781326@linux.ibm.com> <20200710053850.GA27019@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 10, 2020 at 08:48:17AM +0300, Nick Kossifidis wrote: > ???????? 2020-07-10 08:38, Christoph Hellwig ????????????: > > On Thu, Jul 09, 2020 at 11:49:21PM +0300, Mike Rapoport wrote: > > > > +#ifndef CONFIG_GENERIC_DEVMEM_IS_ALLOWED > > > > +extern int devmem_is_allowed(unsigned long pfn); > > > > +#endif > > > > Nit: no need for the extern here. > > > > > > +config GENERIC_LIB_DEVMEM_IS_ALLOWED > > > > + bool > > > > + select ARCH_HAS_DEVMEM_IS_ALLOWED > > > > > > This seems to work the other way around from the usual Kconfig chains. > > > In the most cases ARCH_HAS_SOMETHING selects GENERIC_SOMETHING. > > > > > > I believe nicer way would be to make > > > > > > config STRICT_DEVMEM > > > bool "Filter access to /dev/mem" > > > depends on MMU && DEVMEM > > > depends on ARCH_HAS_DEVMEM_IS_ALLOWED || > > > GENERIC_LIB_DEVMEM_IS_ALLOWED > > > > > > config GENERIC_LIB_DEVMEM_IS_ALLOWED > > > bool > > > > > > and then s/select ARCH_HAS_DEVMEM_IS_ALLOWED/select > > > GENERIC_LIB_DEVMEM_IS_ALLOWED/ > > > in the arch Kconfigs and drop ARCH_HAS_DEVMEM_IS_ALLOWED in the end. > > > > To take a step back: Is there any reason to not just always > > STRICT_DEVMEM? Maybe for a few architectures that don't currently > > support a strict /dev/mem the generic version isn't quite correct, but > > someone selecting the option and finding the issue is the best way to > > figure that out.. > > > > During prototyping / testing having full access to all physical memory > through /dev/mem is very useful. We should have it enabled by default but > leave the config option there so that users / developers can disable it if > needed IMHO. I did not suggest to take the config option away. Just to unconditionally allow enabling the option on all architectures.