Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp22002ybt; Thu, 9 Jul 2020 14:21:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzf2zSFzlDlJiKeUx7SCtYocJwNwwxx2yhjYI7u774iYmZqugqU4MufpriGMWaj1szgTNAV X-Received: by 2002:a05:6402:1d35:: with SMTP id dh21mr70115129edb.186.1594329673251; Thu, 09 Jul 2020 14:21:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594329673; cv=none; d=google.com; s=arc-20160816; b=C+STpR+eXXt6ejFe9PjRHR7HgeVg1CNna9YC9FxAQkMk08JLQyPmt1LhDLonDZnSNG HF7T+n8lcNqggbxFuwn3acH8LPzu/Wazt8mO0nl/XxVb9JIwOBZNpgwUY47Ae4dakwGc QfUbX7Lw5kt5rhS9RteV3nD0G0ktNIA9d9b8iK8F43TvUeIF6NdsoNle8r01ajsuYn4/ esx6Lu4FkbwodpsJ93cTLbpfHGCuUiCrjGWN+BqfW3cyHrmv5Jfd+SWyzuO8zjPGmJow Hd76y7de+QK5va+DHU/HXxmcQH8GFgwhyhgwrFPIRv1NjkVqm+h1HOtF62ipks7ZlLCU kq8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:from:cc:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject :dkim-signature; bh=humMU+Z0Exo5hJuZkhcd7ak4FYmgdKWiBrCsvIrWPuM=; b=MtkhgMN5i/ixLIcq4I1a6gw/B+UPjTyuKmlxSzgfKZx5DF4NsY6hh3j5bOrl3YDGV5 ON6cSJfLrBSEHkTG4x50/UTDqSXuKcHC90+LEQaZ1KTsWoTdvlXF0qH+0RSsMk2jGhzT dCuEwucZWqpOWIpfeycFIJU8mi0GaSIcHr06CxV5V5pj1SxNRCQZBiLJeqaNilf2eXCh et5B4UKnx98XHOfb6epWpbfaNmBYnxvtG0QvdjqsofEqJwV5OTv0ezvONLgs6zeP09ut l4Nmc1YjrxQ78oEHu1NZ+4UbuDNO7/uRhpMlhAcZuk4RQkDHLet+Dn9+dji64Qb/6f/9 Wasw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20150623.gappssmtp.com header.s=20150623 header.b=SUOLf4vQ; 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 bg17si2678704ejb.16.2020.07.09.14.20.51; Thu, 09 Jul 2020 14:21:13 -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=@dabbelt-com.20150623.gappssmtp.com header.s=20150623 header.b=SUOLf4vQ; 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 S1726774AbgGIVUe (ORCPT + 99 others); Thu, 9 Jul 2020 17:20:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726323AbgGIVU2 (ORCPT ); Thu, 9 Jul 2020 17:20:28 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D3BDC08C5DD for ; Thu, 9 Jul 2020 14:20:28 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id k71so1675328pje.0 for ; Thu, 09 Jul 2020 14:20:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20150623.gappssmtp.com; s=20150623; h=subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding:cc:from:to; bh=humMU+Z0Exo5hJuZkhcd7ak4FYmgdKWiBrCsvIrWPuM=; b=SUOLf4vQarIjvyvlOOAhhVT7P9m21jtN5ihUqtkZ9obzyZaC4L/EUFtfArBgEiwQJv 0LQWUVLHki9V8Qsi3maekJoY6vs2o6bbfZvYZnE3jyho9VJWMDcPyv2KCJjcGoDmwUXI CHj65+PTXI1vkP727zohZ6WNglt5+oFlC7NCJ1pJ+W8driafdgcKQzN5VyI7d8X7cYGo +aIIQ+X0oyE8RbAtl+uMA5dW8nX+xlGlq3gTvjc6U3SgbnTo05nPNIV3HBSP4tw+JJG9 9Y/+gHoQ6N/yB2w5gvCVPVlKITZi8MYRJyRMXvrbx2EXMb9PuPSkJ25eLkR2CZypkG8P roEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:cc:from:to; bh=humMU+Z0Exo5hJuZkhcd7ak4FYmgdKWiBrCsvIrWPuM=; b=Y8GeZWuJccrXgufihTRW50TCcH8SLG3NzQc/kt0+KvbIomvMsgoIpO+D1qbQWlR0B4 +l6DR7VfUq1y31YGbft4DB9VpavsTxUF1b8Rai2DPaD80yD5+3bTs7WOVOc4Ak3PUpct pTcDvle94v6iuAXnIIRnjkzFRiXvTrdrAaPpmE9L3cty5L9LQoTUecBumopXKO3ukTi/ TCrXQjsE3Y6Q2/sDWzbhZ44GCsNuAOQrOiiqXUyhd1cvKd9L87bsv7Qtt033/F2w/kTv vF8Njmg6raAnQapdgY/ZcSazJr6aHzR2toNgiFu6JpWbresOSCBbheYaM6j4SwPnUnIg /oqQ== X-Gm-Message-State: AOAM532Qj7qsuyNkZAC5GJt+bryekcONH/uiCrMqlk+YQUWgAjkZa5bE lhUutFZdMrQQlZhaEDGEgAktOQ== X-Received: by 2002:a17:90a:ea83:: with SMTP id h3mr2214598pjz.176.1594329627792; Thu, 09 Jul 2020 14:20:27 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id p10sm3567439pjp.52.2020.07.09.14.20.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2020 14:20:26 -0700 (PDT) Subject: [PATCH v2 3/5] arm: Use the generic devmem_is_allowed() Date: Thu, 9 Jul 2020 14:19:23 -0700 Message-Id: <20200709211925.1926557-4-palmer@dabbelt.com> X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog In-Reply-To: <20200709211925.1926557-1-palmer@dabbelt.com> References: <20200709211925.1926557-1-palmer@dabbelt.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Cc: linux@armlinux.org.uk, catalin.marinas@arm.com, will@kernel.org, Paul Walmsley , Palmer Dabbelt , aou@eecs.berkeley.edu, gxt@pku.edu.cn, Arnd Bergmann , linus.walleij@linaro.org, akpm@linux-foundation.org, mchehab+samsung@kernel.org, gregory.0xf0@gmail.com, masahiroy@kernel.org, Nick Desaulniers , bgolaszewski@baylibre.com, steve@sk2.org, tglx@linutronix.de, keescook@chromium.org, alex@ghiti.fr, mcgrof@kernel.org, mark.rutland@arm.com, james.morse@arm.com, alex.shi@linux.alibaba.com, andriy.shevchenko@linux.intel.com, broonie@kernel.org, rdunlap@infradead.org, davem@davemloft.net, rostedt@goodmis.org, dan.j.williams@intel.com, mhiramat@kernel.org, krzk@kernel.org, zaslonko@linux.ibm.com, matti.vaittinen@fi.rohmeurope.com, uwe@kleine-koenig.org, clabbe@baylibre.com, changbin.du@intel.com, Greg KH , paulmck@kernel.org, pmladek@suse.com, brendanhiggins@google.com, glider@google.com, elver@google.com, davidgow@google.com, ardb@kernel.org, takahiro.akashi@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-arch@vger.kernel.org, kernel-team@android.com, Palmer Dabbelt From: Palmer Dabbelt To: zong.li@sifive.com, linux-riscv@lists.infradead.org, rppt@linux.ibm.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Palmer Dabbelt This is exactly the same as the arm64 version, which I recently copied into lib/ for use by the RISC-V port. [I haven't even build tested this. The lib/ patch is on riscv/for-next, which I'm targeting for 5.9, so this won't work alone. See the cover letter for more details.] Signed-off-by: Palmer Dabbelt --- arch/arm/Kconfig | 2 +- arch/arm/include/asm/io.h | 1 - arch/arm/mm/mmap.c | 22 ---------------------- 3 files changed, 1 insertion(+), 24 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 2ac74904a3ce..da0f88f6c196 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -5,7 +5,6 @@ config ARM select ARCH_32BIT_OFF_T select ARCH_HAS_BINFMT_FLAT select ARCH_HAS_DEBUG_VIRTUAL if MMU - select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAS_DMA_WRITE_COMBINE if !ARM_DMA_MEM_BUFFERABLE select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_FORTIFY_SOURCE @@ -54,6 +53,7 @@ config ARM select GENERIC_IRQ_PROBE select GENERIC_IRQ_SHOW select GENERIC_IRQ_SHOW_LEVEL + select GENERIC_LIB_DEVMEM_IS_ALLOWED select GENERIC_PCI_IOMAP select GENERIC_SCHED_CLOCK select GENERIC_SMP_IDLE_THREAD diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h index ab2b654084fa..fc748122f1e0 100644 --- a/arch/arm/include/asm/io.h +++ b/arch/arm/include/asm/io.h @@ -441,7 +441,6 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr); #define ARCH_HAS_VALID_PHYS_ADDR_RANGE extern int valid_phys_addr_range(phys_addr_t addr, size_t size); extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size); -extern int devmem_is_allowed(unsigned long pfn); #endif /* diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c index b8d912ac9e61..a0f8a0ca0788 100644 --- a/arch/arm/mm/mmap.c +++ b/arch/arm/mm/mmap.c @@ -165,25 +165,3 @@ int valid_mmap_phys_addr_range(unsigned long pfn, size_t size) { return (pfn + (size >> PAGE_SHIFT)) <= (1 + (PHYS_MASK >> PAGE_SHIFT)); } - -#ifdef CONFIG_STRICT_DEVMEM - -#include - -/* - * devmem_is_allowed() checks to see if /dev/mem access to a certain - * address is valid. The argument is a physical page number. - * We mimic x86 here by disallowing access to system RAM as well as - * device-exclusive MMIO regions. This effectively disable read()/write() - * on /dev/mem. - */ -int devmem_is_allowed(unsigned long pfn) -{ - if (iomem_is_exclusive(pfn << PAGE_SHIFT)) - return 0; - if (!page_is_ram(pfn)) - return 1; - return 0; -} - -#endif -- 2.27.0.383.g050319c2ae-goog