linux_dsm_epyc7002/arch/x86/mm
Ralph Campbell 92c77f7c4d x86/mm: Don't exceed the valid physical address space
valid_phys_addr_range() is used to sanity check the physical address range
of an operation, e.g., access to /dev/mem. It uses __pa(high_memory)
internally.

If memory is populated at the end of the physical address space, then
__pa(high_memory) is outside of the physical address space because:

   high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1;

For the comparison in valid_phys_addr_range() this is not an issue, but if
CONFIG_DEBUG_VIRTUAL is enabled, __pa() maps to __phys_addr(), which
verifies that the resulting physical address is within the valid physical
address space of the CPU. So in the case that memory is populated at the
end of the physical address space, this is not true and triggers a
VIRTUAL_BUG_ON().

Use __pa(high_memory - 1) to prevent the conversion from going beyond
the end of valid physical addresses.

Fixes: be62a32044 ("x86/mm: Limit mmap() of /dev/mem to valid physical addresses")
Signed-off-by: Ralph Campbell <rcampbell@nvidia.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Craig Bergstrom <craigb@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Fengguang Wu <fengguang.wu@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sander Eikelenboom <linux@eikelenboom.it>
Cc: Sean Young <sean@mess.org>

Link: https://lkml.kernel.org/r/20190326001817.15413-2-rcampbell@nvidia.com
2019-03-28 14:13:51 +01:00
..
amdtopology.c
cpu_entry_area.c x86/cpu_entry_area: Move percpu_setup_debug_store() to __init section 2019-02-08 14:32:33 +01:00
debug_pagetables.c
dump_pagetables.c x86/mm/dump_pagetables: Remove the unused prev_pud variable 2019-02-14 17:09:43 +01:00
extable.c x86-64: add warning for non-canonical user access address dereferences 2019-03-04 10:08:28 -08:00
fault.c mm: create the new vm_fault_t type 2019-03-07 18:32:03 -08:00
highmem_32.c
hugetlbpage.c
ident_map.c
init_32.c mm, memory_hotplug: add nid parameter to arch_remove_memory 2018-12-28 12:11:49 -08:00
init_64.c mm, memory_hotplug: add nid parameter to arch_remove_memory 2018-12-28 12:11:49 -08:00
init.c mm: make free_reserved_area() return "const char *" 2018-12-28 12:11:48 -08:00
iomap_32.c
ioremap.c x86: Make ARCH_USE_MEMREMAP_PROT a generic Kconfig symbol 2019-02-04 08:27:29 +01:00
kasan_init_64.c memblock: drop memblock_alloc_*_nopanic() variants 2019-03-12 10:04:02 -07:00
kaslr.c
kmmio.c
Makefile
mem_encrypt_boot.S
mem_encrypt_identity.c x86/mm/mem_encrypt: Fix erroneous sizeof() 2019-01-15 11:41:58 +01:00
mem_encrypt.c
mm_internal.h
mmap.c x86/mm: Don't exceed the valid physical address space 2019-03-28 14:13:51 +01:00
mmio-mod.c
mpx.c x86/mpx: tweak header name 2019-02-18 17:49:30 +01:00
numa_32.c
numa_64.c
numa_emulation.c
numa_internal.h
numa.c memblock: drop __memblock_alloc_base() 2019-03-12 10:04:01 -07:00
pageattr-test.c
pageattr.c x86/mm: Remove unused variable 'old_pte' 2019-03-06 23:24:53 +01:00
pat_internal.h
pat_rbtree.c
pat.c
pf_in.c
pf_in.h
pgtable_32.c
pgtable.c mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
physaddr.c
physaddr.h
pkeys.c
pti.c x86/mm/pti: Make local symbols static 2019-03-22 13:31:28 +01:00
setup_nx.c
srat.c
testmmiotrace.c
tlb.c x86/mm: Remove unused variable 'cpu' 2019-03-06 23:24:52 +01:00