Skip to content

Commit 1886297

Browse files
toshikaniIngo Molnar
authored andcommitted
x86/mm/pat: Fix BUG_ON() in mmap_mem() on QEMU/i386
The following BUG_ON() crash was reported on QEMU/i386: kernel BUG at arch/x86/mm/physaddr.c:79! Call Trace: phys_mem_access_prot_allowed mmap_mem ? mmap_region mmap_region do_mmap vm_mmap_pgoff SyS_mmap_pgoff do_int80_syscall_32 entry_INT80_32 after commit: edfe63e ("x86/mtrr: Fix Xorg crashes in Qemu sessions") PAT is now set to disabled state when MTRRs are disabled. Thus, reactivating the __pa(high_memory) check in phys_mem_access_prot_allowed(). When CONFIG_DEBUG_VIRTUAL is set, __pa() calls __phys_addr(), which in turn calls slow_virt_to_phys() for 'high_memory'. Because 'high_memory' is set to (the max direct mapped virt addr + 1), it is not a valid virtual address. Hence, slow_virt_to_phys() returns 0 and hit the BUG_ON. Using __pa_nodebug() instead of __pa() will fix this BUG_ON. However, this code block, originally written for Pentiums and earlier, is no longer adequate since a 32-bit Xen guest has MTRRs disabled and supports ZONE_HIGHMEM. In this setup, this code sets UC attribute for accessing RAM in high memory range. Delete this code block as it has been unused for a long time. Reported-by: kernel test robot <[email protected]> Reviewed-by: Borislav Petkov <[email protected]> Signed-off-by: Toshi Kani <[email protected]> Cc: Andrew Morton <[email protected]> Cc: David Vrabel <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Paul E. McKenney <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Link: https://lkml.org/lkml/2016/4/1/608 Signed-off-by: Ingo Molnar <[email protected]>
1 parent 568a58e commit 1886297

File tree

1 file changed

+0
-19
lines changed

1 file changed

+0
-19
lines changed

arch/x86/mm/pat.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -778,25 +778,6 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
778778
if (file->f_flags & O_DSYNC)
779779
pcm = _PAGE_CACHE_MODE_UC_MINUS;
780780

781-
#ifdef CONFIG_X86_32
782-
/*
783-
* On the PPro and successors, the MTRRs are used to set
784-
* memory types for physical addresses outside main memory,
785-
* so blindly setting UC or PWT on those pages is wrong.
786-
* For Pentiums and earlier, the surround logic should disable
787-
* caching for the high addresses through the KEN pin, but
788-
* we maintain the tradition of paranoia in this code.
789-
*/
790-
if (!pat_enabled() &&
791-
!(boot_cpu_has(X86_FEATURE_MTRR) ||
792-
boot_cpu_has(X86_FEATURE_K6_MTRR) ||
793-
boot_cpu_has(X86_FEATURE_CYRIX_ARR) ||
794-
boot_cpu_has(X86_FEATURE_CENTAUR_MCR)) &&
795-
(pfn << PAGE_SHIFT) >= __pa(high_memory)) {
796-
pcm = _PAGE_CACHE_MODE_UC;
797-
}
798-
#endif
799-
800781
*vma_prot = __pgprot((pgprot_val(*vma_prot) & ~_PAGE_CACHE_MASK) |
801782
cachemode2protval(pcm));
802783
return 1;

0 commit comments

Comments
 (0)