From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8AD1C433E1 for ; Thu, 9 Jul 2020 20:08:38 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9104F2077D for ; Thu, 9 Jul 2020 20:08:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="wBdDcTb8"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=dabbelt-com.20150623.gappssmtp.com header.i=@dabbelt-com.20150623.gappssmtp.com header.b="UidihMQg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9104F2077D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dabbelt.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4lok2UDxQkLBUQfpxZ/3XkAO6hGX3ejJXAntq7mJJ2c=; b=wBdDcTb8NLcpJPlxrefa+HXnG YyYByBkbhtDd8N45rNtj4rmhl+1i2bs6GaLj+8RoS18KNKgNzoY4kAwUQ/7VYv8Fl0P9hJHq5RiA4 bJvAg9NpQxkD4KOLfTWq0bZ7SBtIXNyxpSuT0btyQhJvpUDVflIxUuK6j48Odqq1kWln7tzTiJwg7 LlT1/RGA/WDhzQ/9V2fawqSBXpJPbHTZBsVa4BWOwlT9bBf3yYVsA3E0Ay5E+CHoZfOCeW0rJrCz+ QsYtZCFQ+iDpArBwF6yHOpkKxiGFevz8w3kenZKJgvaMtaZHOS+S4qEcjWVBud+MfYj1XkEgHAHXr yF+0cndvg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jtcqK-00044Y-J6; Thu, 09 Jul 2020 20:08:28 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jtcqC-0003ys-2l for linux-riscv@lists.infradead.org; Thu, 09 Jul 2020 20:08:25 +0000 Received: by mail-pf1-x443.google.com with SMTP id i14so1457936pfu.13 for ; Thu, 09 Jul 2020 13:08:19 -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=yWhgfwfFiWb3PPj/shWsgqQNA2FBCAQDX3yO4Pd/fvs=; b=UidihMQgn2FU6yC2vnYywcLHy80gmEP9wasmFMA2FlkEOEYTxHQih0uQR6O7Clo+mX 0vBe960gmixo51qTavUcsu7f79VBEK4Ea1o8CWFjYkwORC6cCPO9tlF95AOw76zlUqXG Wfgx4JfueZJ9c3aHa6PuHQZfF1qkaR/A8oUxBKoggm4NiQSkC5yZUVIZHjXnzNPJR4+g DpZHy1v1JfLzUmZT4WnmjLIiiDne7KMbo5woYP8NSZP1K5U3Dth0aVUglHKD1Bj0E5Jg Phtv3EtzK3PPX/5tDAhceOtP3IYeciop4OaIcjUai+E/BfoTXjh4QYa6Ppdda/hyZcQd jW8g== 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=yWhgfwfFiWb3PPj/shWsgqQNA2FBCAQDX3yO4Pd/fvs=; b=D/vSKycAYr3ijW6oy3+9shTY8YRhMHPwQDaIVyToe3N9F3kHq8mWjoAob1NkZxUlMP 0bRhcMotQTsond2KJzRldC2BN7+wuonnN4r1ud77RGJDNezGOtiO+Gl11tlsbVRcnBF0 g5DpNcITLgvsPEfRFiT97ISBUK+pZV9DLZsFyvGidw4jvnLzoe4zBJZwtvuZSd/LRxa0 L8xDsQGBSHSJ0rYT06Q8qbQ1pmXobrvNzirsDoEUTkNPWK0MnkBnjZwhPqMMQTCACNCo XZkQNFBBZdsjLw2/rXDWrdi7DdyDLyCRDqgOJ8NYAvwI0lpetE0E7UWyqkInxT4STeI0 ymOQ== X-Gm-Message-State: AOAM530StNRv0zYYQgEKGRFYJoUDD36Xfp2KklHBVqxYdZiTj6dCbP6b puJjO4iEwDvEYDHyGPJ4vdkX2g== X-Google-Smtp-Source: ABdhPJw9INn3TgtDhWTqhvvgdVynTI7UXM1Nes0eUQhBvbIdfIkX0ekLoOzvL8jdp0+OswC8wE+weQ== X-Received: by 2002:a63:6c1:: with SMTP id 184mr57192840pgg.262.1594325298146; Thu, 09 Jul 2020 13:08:18 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id y65sm3499465pfb.75.2020.07.09.13.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2020 13:08:17 -0700 (PDT) Subject: [PATCH 4/5] arm64: Use the generic devmem_is_allowed() Date: Thu, 9 Jul 2020 13:05:51 -0700 Message-Id: <20200709200552.1910298-5-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 From: Palmer Dabbelt To: linux-riscv@lists.infradead.org, zong.li@sifive.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200709_160820_231873_B314341B X-CRM114-Status: GOOD ( 14.07 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, steve@sk2.org, davidgow@google.com, ardb@kernel.org, catalin.marinas@arm.com, linus.walleij@linaro.org, Palmer Dabbelt , elver@google.com, glider@google.com, willy@infradead.org, mchehab+samsung@kernel.org, linux-riscv@lists.infradead.org, alex.shi@linux.alibaba.com, will@kernel.org, dan.j.williams@intel.com, linux-arch@vger.kernel.org, uwe@kleine-koenig.org, alex@ghiti.fr, takahiro.akashi@linaro.org, paulmck@kernel.org, masahiroy@kernel.org, linux@armlinux.org.uk, krzk@kernel.org, rppt@linux.ibm.com, bgolaszewski@baylibre.com, james.morse@arm.com, kernel-team@android.com, pmladek@suse.com, zaslonko@linux.ibm.com, aou@eecs.berkeley.edu, keescook@chromium.org, Arnd Bergmann , rostedt@goodmis.org, broonie@kernel.org, matti.vaittinen@fi.rohmeurope.com, gregory.0xf0@gmail.com, Paul Walmsley , tglx@linutronix.de, andriy.shevchenko@linux.intel.com, gxt@pku.edu.cn, linux-arm-kernel@lists.infradead.org, rdunlap@infradead.org, Nick Desaulniers , linux-kernel@vger.kernel.org, mcgrof@kernel.org, Palmer Dabbelt , mhiramat@kernel.org, akpm@linux-foundation.org, davem@davemloft.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Palmer Dabbelt I recently copied this 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/arm64/Kconfig | 1 + arch/arm64/include/asm/io.h | 2 -- arch/arm64/mm/mmap.c | 21 --------------------- 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 66dc41fd49f2..0770ed21a8c4 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -110,6 +110,7 @@ config ARM64 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_PTDUMP select GENERIC_SCHED_CLOCK diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h index ff50dd731852..c53eba1a7fd2 100644 --- a/arch/arm64/include/asm/io.h +++ b/arch/arm64/include/asm/io.h @@ -200,6 +200,4 @@ extern void __iomem *ioremap_cache(phys_addr_t phys_addr, size_t size); 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 /* __ASM_IO_H */ diff --git a/arch/arm64/mm/mmap.c b/arch/arm64/mm/mmap.c index 3028bacbc4e9..07937b49cb88 100644 --- a/arch/arm64/mm/mmap.c +++ b/arch/arm64/mm/mmap.c @@ -47,24 +47,3 @@ int valid_mmap_phys_addr_range(unsigned long pfn, size_t size) { return !(((pfn << PAGE_SHIFT) + size) & ~PHYS_MASK); } - -#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 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv