1 // SPDX-License-Identifier: GPL-2.0-only
3 * A generic version of devmem_is_allowed.
5 * Based on arch/arm64/mm/mmap.c
7 * Copyright (C) 2020 Google, Inc.
8 * Copyright (C) 2012 ARM Ltd.
12 #include <linux/ioport.h>
15 * devmem_is_allowed() checks to see if /dev/mem access to a certain address
16 * is valid. The argument is a physical page number. We mimic x86 here by
17 * disallowing access to system RAM as well as device-exclusive MMIO regions.
18 * This effectively disable read()/write() on /dev/mem.
20 int devmem_is_allowed(unsigned long pfn
)
22 if (iomem_is_exclusive(pfn
<< PAGE_SHIFT
))
24 if (!page_is_ram(pfn
))