]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - arch/arm64/mm/mmap.c
arm64: Fix race condition on PG_dcache_clean in __sync_icache_dcache()
[mirror_ubuntu-jammy-kernel.git] / arch / arm64 / mm / mmap.c
CommitLineData
caab277b 1// SPDX-License-Identifier: GPL-2.0-only
1d18c47c
CM
2/*
3 * Based on arch/arm/mm/mmap.c
4 *
5 * Copyright (C) 2012 ARM Ltd.
1d18c47c
CM
6 */
7
c7b9095e 8#include <linux/io.h>
1151f838 9#include <linux/memblock.h>
507d6644 10#include <linux/types.h>
1d18c47c 11
507d6644 12#include <asm/page.h>
1d18c47c 13
1d18c47c
CM
14/*
15 * You really shouldn't be using read() or write() on /dev/mem. This might go
16 * away in the future.
17 */
097cbd8d 18int valid_phys_addr_range(phys_addr_t addr, size_t size)
1d18c47c 19{
1151f838
AB
20 /*
21 * Check whether addr is covered by a memory region without the
22 * MEMBLOCK_NOMAP attribute, and whether that region covers the
23 * entire range. In theory, this could lead to false negatives
24 * if the range is covered by distinct but adjacent memory regions
25 * that only differ in other attributes. However, few of such
26 * attributes have been defined, and it is debatable whether it
27 * follows that /dev/mem read() calls should be able traverse
28 * such boundaries.
29 */
30 return memblock_is_region_memory(addr, size) &&
31 memblock_is_map_memory(addr);
1d18c47c
CM
32}
33
34/*
35 * Do not allow /dev/mem mappings beyond the supported physical range.
36 */
37int valid_mmap_phys_addr_range(unsigned long pfn, size_t size)
38{
39 return !(((pfn << PAGE_SHIFT) + size) & ~PHYS_MASK);
40}