linux/arch
Youquan Song b6999b1912 thp: add compound tail page _mapcount when mapped
With the 3.2-rc kernel, IOMMU 2M pages in KVM works.  But when I tried
to use IOMMU 1GB pages in KVM, I encountered an oops and the 1GB page
failed to be used.

The root cause is that 1GB page allocation calls gup_huge_pud() while 2M
page calls gup_huge_pmd.  If compound pages are used and the page is a
tail page, gup_huge_pmd() increases _mapcount to record tail page are
mapped while gup_huge_pud does not do that.

So when the mapped page is relesed, it will result in kernel oops
because the page is not marked mapped.

This patch add tail process for compound page in 1GB huge page which
keeps the same process as 2M page.

Reproduce like:
1. Add grub boot option: hugepagesz=1G hugepages=8
2. mount -t hugetlbfs -o pagesize=1G hugetlbfs /dev/hugepages
3. qemu-kvm -m 2048 -hda os-kvm.img -cpu kvm64 -smp 4 -mem-path /dev/hugepages
	-net none -device pci-assign,host=07:00.1

  kernel BUG at mm/swap.c:114!
  invalid opcode: 0000 [#1] SMP
  Call Trace:
    put_page+0x15/0x37
    kvm_release_pfn_clean+0x31/0x36
    kvm_iommu_put_pages+0x94/0xb1
    kvm_iommu_unmap_memslots+0x80/0xb6
    kvm_assign_device+0xba/0x117
    kvm_vm_ioctl_assigned_device+0x301/0xa47
    kvm_vm_ioctl+0x36c/0x3a2
    do_vfs_ioctl+0x49e/0x4e4
    sys_ioctl+0x5a/0x7c
    system_call_fastpath+0x16/0x1b
  RIP  put_compound_page+0xd4/0x168

Signed-off-by: Youquan Song <youquan.song@intel.com>
Reviewed-by: Andrea Arcangeli <aarcange@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-12-09 07:50:28 -08:00
..
alpha Merge branch 'modsplit-Oct31_2011' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux 2011-11-06 19:44:47 -08:00
arm Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc 2011-12-08 13:18:38 -08:00
avr32 Merge git://git.infradead.org/mtd-2.6 2011-11-07 09:11:16 -08:00
blackfin blackfin: Fixup export.h includes 2011-11-14 17:15:23 +08:00
cris net: Fix references to deleted NET_ETHERNET Kconfig setting. 2011-11-09 19:26:53 -05:00
frv kgdb: follow rename pack_hex_byte() to hex_byte_pack() 2011-10-31 17:30:56 -07:00
h8300 Merge branch 'gpio/next' of git://git.secretlab.ca/git/linux-2.6 2011-10-29 07:27:45 -07:00
hexagon Hexagon: Add basic stacktrace functionality for Hexagon architecture. 2011-11-01 07:34:21 -07:00
ia64 Merge branch 'upstream/xen-settime' of git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen 2011-11-06 20:15:05 -08:00
m32r Merge branch 'trivial' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild 2011-11-06 18:54:53 -08:00
m68k m68k: Wire up process_vm_{read,write}v 2011-12-06 20:37:58 +01:00
microblaze microblaze: bury asm/namei.h 2011-11-21 16:48:28 -05:00
mips Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2011-12-05 16:54:00 -08:00
mn10300 kgdb: follow rename pack_hex_byte() to hex_byte_pack() 2011-10-31 17:30:56 -07:00
openrisc Merge branch 'trivial' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild 2011-11-06 18:54:53 -08:00
parisc parisc: Add export.h to files needing EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:31:00 -04:00
powerpc powerpc/44x: Add mtd ndfc to the ppx44x defconfig 2011-11-25 10:06:00 +11:00
s390 [S390] remove reset of system call restart on psw changes 2011-12-01 13:32:17 +01:00
score score: drop unused Kconfig symbols 2011-10-31 23:39:51 +01:00
sh Merge branches 'sh/pm-runtime' and 'common/clkfwk' into sh-fixes-for-linus 2011-11-11 16:16:25 +09:00
sparc sparc64: Patch sun4v code sequences properly on module load. 2011-11-17 22:44:58 -08:00
tile Merge branch 'for-linus' of git://github.com/cmetcalf-tilera/linux-tile 2011-11-04 12:33:34 -07:00
um Merge branch 'for-linus' of git://github.com/richardweinberger/linux 2011-11-02 09:45:39 -07:00
unicore32 unicore32, exec: remove redundant set_fs(USER_DS) 2011-11-16 10:50:09 +08:00
x86 thp: add compound tail page _mapcount when mapped 2011-12-09 07:50:28 -08:00
xtensa Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2011-10-26 17:15:03 +02:00
.gitignore
Kconfig Add Kconfig option ARCH_HAVE_NMI_SAFE_CMPXCHG 2011-08-03 11:12:37 -04:00