diff mbox series

[043/120] MIPS: PS2: ROM: Permit /dev/mem to access read-only memory

Message ID 644f2908571adb1c66d27ab0ecb0c32a3f8581c9.1567326213.git.noring@nocrew.org (mailing list archive)
State RFC
Headers show
Series Linux for the PlayStation 2 | expand

Commit Message

Fredrik Noring Sept. 1, 2019, 3:53 p.m. UTC
Signed-off-by: Fredrik Noring <noring@nocrew.org>
---
 arch/mips/include/asm/io.h |  6 ++++++
 arch/mips/ps2/memory.c     | 16 ++++++++++++++++
 2 files changed, 22 insertions(+)
diff mbox series

Patch

diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index f7115472f530..f449a27c2b79 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -709,4 +709,10 @@  extern void (*_dma_cache_inv)(unsigned long start, unsigned long size);
 
 void __ioread64_copy(void *to, const void __iomem *from, size_t count);
 
+#ifdef CONFIG_SONY_PS2
+#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);
+#endif /* CONFIG_SONY_PS2 */
+
 #endif /* _ASM_IO_H */
diff --git a/arch/mips/ps2/memory.c b/arch/mips/ps2/memory.c
index 66ca37f38330..c513b6912bb0 100644
--- a/arch/mips/ps2/memory.c
+++ b/arch/mips/ps2/memory.c
@@ -7,9 +7,25 @@ 
 
 #include <linux/init.h>
 #include <linux/ioport.h>
+#include <linux/mm.h>
 #include <linux/types.h>
 
 #include <asm/bootinfo.h>
+#include <asm/io.h>
+
+#include <asm/mach-ps2/rom.h>
+
+int valid_phys_addr_range(phys_addr_t addr, size_t size)
+{
+	return addr + size <= __pa(high_memory) ||
+	       (ROM0_BASE <= addr && addr + size <= ROM0_BASE + ROM0_SIZE) ||
+	       (ROM1_BASE <= addr && addr + size <= ROM1_BASE + ROM1_SIZE);
+}
+
+int valid_mmap_phys_addr_range(unsigned long pfn, size_t size)
+{
+	return 1;
+}
 
 void __init plat_mem_setup(void)
 {