Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1696173ybt; Thu, 9 Jul 2020 13:09:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWSTpu9LPW4gSCuRs6ue6R9ns4el4zzYPOD7hpu6QjR3NGutwsn4sacyHH3knBxWfnaNvw X-Received: by 2002:a05:6402:b99:: with SMTP id cf25mr71701068edb.291.1594325395086; Thu, 09 Jul 2020 13:09:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594325395; cv=none; d=google.com; s=arc-20160816; b=jQLaUG6buw118QQ/6BqSzsjRS823xHWYcii5fiZ8702mrQLXPZsLBdQRbsH2Et8VnP sD4ITzbNNcL/Xvd6Bce7iHTZufBCpBy1UzybezwoqkUh/tG7plrmTHU4xXhpIaHpqzep 80dXodSlymZFkmEeRNHwTiJhNnpfu/aLiy03qJVgwSxbOQkSmLBxzsauHC1hBSpm5dgA pRtu71oUWpR7ErC62qRXs5I10I26Tln9SIxtRV9pI9hKanHVwoLRYr9b6hbqlPEDxNJL 95ecWm0QZ4gnFPMJvLaGNTS+CEueWDw3cK/iO2kr2TEU2AH1JfmJsEt/Xu98WaJrVabG 4QOQ== 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=QnurR7K6BPRfnTLUtwHY4Q88UHUkQ5JhJ6oRLe/Vy2I=; b=BypDp4LbZxZ00HIyzGOgwQHCahfs9ghUfMMqnyAb6wnFX30HdN0hqJnYymyoU4GOel 3Veu61wejsgbIuiz7RZWwopOW7/14h3oA6VIVgncinL4Lzc5l1YnCjmlUreKp+eOee8O DYDFiMoq1XNpl11Vz0jisKeC05w2j+7/ULXTP22d8n73eiZizLWsU5hP+QMpf6XhwnMQ dhWGo1ZIDxj4FuxeE424ZcfAoa9iuDYFsjeBZZrWP8r2X3OWJjrIO9nJw6bWmajTh5Ji UvylVqzukcKmcWRBis6Q8a1mYH1CoZsN46J+naArgAMrVyrZJyvZL1ggPAZyONq+IMDA kLKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20150623.gappssmtp.com header.s=20150623 header.b=mUoQh16L; 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 r16si2680261edo.473.2020.07.09.13.09.31; Thu, 09 Jul 2020 13:09:55 -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=mUoQh16L; 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 S1726794AbgGIUIb (ORCPT + 99 others); Thu, 9 Jul 2020 16:08:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726546AbgGIUIR (ORCPT ); Thu, 9 Jul 2020 16:08:17 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 427F1C08C5CE for ; Thu, 9 Jul 2020 13:08:17 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id j20so1479344pfe.5 for ; Thu, 09 Jul 2020 13:08:17 -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=QnurR7K6BPRfnTLUtwHY4Q88UHUkQ5JhJ6oRLe/Vy2I=; b=mUoQh16LfS76JjXiApvCLtUURIrln8QBy4z4KJ9cxNLpVN1HsGpQr1kBYvlfEpIda/ LoU2sTePgiPsVUktY9PLay5T/LWuA3SDlvl4EC+tzu4MnafyF/ciaZHGkNU/HG8T9OpE KVzeCoEIRng2pW5XYTVTkZpES51Xe5P8EaOR57UDK6McQDJBkaQ7s22u07OnYIAhRxj3 8Kym3DKDmDIbQhedwXAnH996hmuesUoUcKdZZw2jmgUP8rky9R9IycIEElXJJBJQ9h6D EwVHGVT8826dl07WOOq2aung0LV8qgk3FPr4NBe71Evllt8Mlkwq1HzZ++bm+1vYZdAP KcgA== 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=QnurR7K6BPRfnTLUtwHY4Q88UHUkQ5JhJ6oRLe/Vy2I=; b=pAru9GuuCyzWHqsY3v+eh3+9MrQeyg1rbvNsBvOCc7hNojH0XrjUKXkoMOpBO8mhW2 VsnGha7Fdm1H1YbOa/z9/6UVj3ZHqJfEWNdmY9sBMgi+NbhyuWES6YMnuPo631kz/4Cm UK/yNINk7/PKEwN+YGKT/hxVGI7nTqUgTlDbPN/o3JL9sE+p8mBs87lTqwrTcf1RKpXI oc4gAiPRKhju5IZYLNYhTdcg0pvd5cL2OkVIyMlFqBzAPKa4kgoGVgokLx82aZ4/YH0z IaOUg2/zyrON70If5QcJPngCqIKHgVaVhhWUHXLvjB2Xd0KUYwe1jmBwGDqLo6zsZS/o y+6w== X-Gm-Message-State: AOAM531nSzc4STWZGswSQ+U1HqGfeOBKnCkaFo5lBA4xLP/pzj2DpLvS zfl7tgAi0DRMNXg6gfK0a2ozoQ== X-Received: by 2002:a62:2c48:: with SMTP id s69mr18582019pfs.63.1594325296622; Thu, 09 Jul 2020 13:08:16 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id m9sm3442448pjs.18.2020.07.09.13.08.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2020 13:08:16 -0700 (PDT) Subject: [PATCH 3/5] arm: Use the generic devmem_is_allowed() Date: Thu, 9 Jul 2020 13:05:50 -0700 Message-Id: <20200709200552.1910298-4-palmer@dabbelt.com> X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog In-Reply-To: <20200709200552.1910298-1-palmer@dabbelt.com> References: <20200709200552.1910298-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 , akpm@linux-foundation.org, linus.walleij@linaro.org, rppt@linux.ibm.com, mchehab+samsung@kernel.org, gregory.0xf0@gmail.com, masahiroy@kernel.org, Nick Desaulniers , bgolaszewski@baylibre.com, tglx@linutronix.de, steve@sk2.org, keescook@chromium.org, mcgrof@kernel.org, alex@ghiti.fr, mark.rutland@arm.com, james.morse@arm.com, andriy.shevchenko@linux.intel.com, alex.shi@linux.alibaba.com, davem@davemloft.net, rdunlap@infradead.org, broonie@kernel.org, uwe@kleine-koenig.org, rostedt@goodmis.org, dan.j.williams@intel.com, mhiramat@kernel.org, matti.vaittinen@fi.rohmeurope.com, zaslonko@linux.ibm.com, krzk@kernel.org, willy@infradead.org, paulmck@kernel.org, pmladek@suse.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: linux-riscv@lists.infradead.org, zong.li@sifive.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 | 1 + arch/arm/include/asm/io.h | 1 - arch/arm/mm/mmap.c | 22 ---------------------- 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 2ac74904a3ce..0c9da68835c2 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -54,6 +54,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