linux/arch/x86/boot
Kirill A. Shutemov 70f1528747 x86/mm: Fix regression with huge pages on PAE
Recent PAT patchset has caused issue on 32-bit PAE machines:

  page:eea45000 count:0 mapcount:-128 mapping:  (null) index:0x0 flags: 0x40000000()
  page dumped because: VM_BUG_ON_PAGE(page_mapcount(page) < 0)
  ------------[ cut here ]------------
  kernel BUG at /home/build/linux-boris/mm/huge_memory.c:1485!
  invalid opcode: 0000 [#1] SMP
  [...]
  Call Trace:
   unmap_single_vma
   ? __wake_up
   unmap_vmas
   unmap_region
   do_munmap
   vm_munmap
   SyS_munmap
   do_fast_syscall_32
   ? __do_page_fault
   sysenter_past_esp
  Code: ...
  EIP: [<c11bde80>] zap_huge_pmd+0x240/0x260 SS:ESP 0068:f6459d98

The problem is in pmd_pfn_mask() and pmd_flags_mask(). These
helpers use PMD_PAGE_MASK to calculate resulting mask.
PMD_PAGE_MASK is 'unsigned long', not 'unsigned long long' as
phys_addr_t is on 32-bit PAE (ARCH_PHYS_ADDR_T_64BIT). As a
result, the upper bits of resulting mask get truncated.

pud_pfn_mask() and pud_flags_mask() aren't problematic since we
don't have PUD page table level on 32-bit systems, but it's
reasonable to keep them consistent with PMD counterpart.

Introduce PHYSICAL_PMD_PAGE_MASK and PHYSICAL_PUD_PAGE_MASK in
addition to existing PHYSICAL_PAGE_MASK and reworks helpers to
use them.

Reported-and-Tested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
[ Fix -Woverflow warnings from the realmode code. ]
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Toshi Kani <toshi.kani@hpe.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jürgen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: elliott@hpe.com
Cc: konrad.wilk@oracle.com
Cc: linux-mm <linux-mm@kvack.org>
Fixes: f70abb0fc3 ("x86/asm: Fix pud/pmd interfaces to handle large PAT bit")
Link: http://lkml.kernel.org/r/1448878233-11390-2-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>

Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-12-04 09:14:27 +01:00
..
compressed * Make the EFI System Resource Table (ESRT) driver explicitly 2015-10-14 16:51:34 +02:00
tools x86/efi: Include a .bss section within the PE/COFF headers 2014-07-10 14:21:39 +01:00
.gitignore
Makefile kasan: move KASAN_SANITIZE in arch/x86/boot/Makefile 2015-11-05 19:34:48 -08:00
a20.c
apm.c
bioscall.S
bitops.h
boot.h x86/mm: Fix regression with huge pages on PAE 2015-12-04 09:14:27 +01:00
cmdline.c
code16gcc.h x86, build: Change code16gcc.h from a C header to an assembly header 2014-06-04 13:16:48 -07:00
copy.S
cpu.c x86: Support compiling out human-friendly processor feature names 2014-08-17 15:54:00 -07:00
cpucheck.c Merge branch 'x86/boot' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2014-04-02 12:23:49 -07:00
cpuflags.c
cpuflags.h
ctype.h x86, setup: Rename BOOT_ISDIGIT_H to BOOT_CTYPE_H 2015-01-13 11:59:04 +01:00
early_serial_console.c x86, early_serial_console: Remove unnecessary check 2015-01-13 12:14:44 +01:00
edd.c x86, boot: Create a separate string.h file to provide standard string functions 2014-03-19 15:43:45 -07:00
header.S Merge branch 'x86/urgent' into core/efi, to pick up a pending EFI fix 2015-10-14 16:05:18 +02:00
install.sh
main.c x86/boot: Obsolete the MCA sys_desc_table 2015-07-21 10:55:11 +02:00
memory.c
mkcpustr.c x86: Introduce disabled-features 2014-09-11 14:30:02 -07:00
mtools.conf.in
pm.c
pmjump.S
printf.c
regs.c x86, boot: Create a separate string.h file to provide standard string functions 2014-03-19 15:43:45 -07:00
setup.ld
string.c x86/boot: Standardize strcmp() 2015-03-23 10:24:12 +01:00
string.h x86, boot: Move memcmp() into string.h and string.c 2014-03-19 15:44:04 -07:00
tty.c
version.c
vesa.h
video-bios.c
video-mode.c x86/mm: Fix regression with huge pages on PAE 2015-12-04 09:14:27 +01:00
video-vesa.c x86, boot: Create a separate string.h file to provide standard string functions 2014-03-19 15:43:45 -07:00
video-vga.c
video.c x86/mm: Fix regression with huge pages on PAE 2015-12-04 09:14:27 +01:00
video.h x86/boot/video: Move the 'video_segment' variable to video.c 2015-02-19 00:25:05 +01:00