Revision 9a291a7c9428155e8e623e4a3989f8be47134df5 authored by James Morse on 02 June 2017, 21:46:46 UTC, committed by Linus Torvalds on 02 June 2017, 22:07:38 UTC
KVM uses get_user_pages() to resolve its stage2 faults.  KVM sets the
FOLL_HWPOISON flag causing faultin_page() to return -EHWPOISON when it
finds a VM_FAULT_HWPOISON.  KVM handles these hwpoison pages as a
special case.  (check_user_page_hwpoison())

When huge pages are involved, this doesn't work so well.
get_user_pages() calls follow_hugetlb_page(), which stops early if it
receives VM_FAULT_HWPOISON from hugetlb_fault(), eventually returning
-EFAULT to the caller.  The step to map this to -EHWPOISON based on the
FOLL_ flags is missing.  The hwpoison special case is skipped, and
-EFAULT is returned to user-space, causing Qemu or kvmtool to exit.

Instead, move this VM_FAULT_ to errno mapping code into a header file
and use it from faultin_page() and follow_hugetlb_page().

With this, KVM works as expected.

This isn't a problem for arm64 today as we haven't enabled
MEMORY_FAILURE, but I can't see any reason this doesn't happen on x86
too, so I think this should be a fix.  This doesn't apply earlier than
stable's v4.11.1 due to all sorts of cleanup.

[james.morse@arm.com: add vm_fault_to_errno() call to faultin_page()]
suggested.
  Link: http://lkml.kernel.org/r/20170525171035.16359-1-james.morse@arm.com
[akpm@linux-foundation.org: coding-style fixes]
Link: http://lkml.kernel.org/r/20170524160900.28786-1-james.morse@arm.com
Signed-off-by: James Morse <james.morse@arm.com>
Acked-by: Punit Agrawal <punit.agrawal@arm.com>
Acked-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
Cc: <stable@vger.kernel.org>	[4.11.1+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 70feee0
History
File Mode Size
Kconfig -rw-r--r-- 7.3 KB
Makefile -rw-r--r-- 805 bytes
block.c -rw-r--r-- 5.5 KB
cache.c -rw-r--r-- 11.6 KB
decompressor.c -rw-r--r-- 3.7 KB
decompressor.h -rw-r--r-- 1.9 KB
decompressor_multi.c -rw-r--r-- 4.6 KB
decompressor_multi_percpu.c -rw-r--r-- 2.3 KB
decompressor_single.c -rw-r--r-- 1.8 KB
dir.c -rw-r--r-- 5.9 KB
export.c -rw-r--r-- 4.6 KB
file.c -rw-r--r-- 14.1 KB
file_cache.c -rw-r--r-- 961 bytes
file_direct.c -rw-r--r-- 4.3 KB
fragment.c -rw-r--r-- 3.1 KB
id.c -rw-r--r-- 2.9 KB
inode.c -rw-r--r-- 12.4 KB
lz4_wrapper.c -rw-r--r-- 2.9 KB
lzo_wrapper.c -rw-r--r-- 3.0 KB
namei.c -rw-r--r-- 7.4 KB
page_actor.c -rw-r--r-- 2.6 KB
page_actor.h -rw-r--r-- 1.9 KB
squashfs.h -rw-r--r-- 3.9 KB
squashfs_fs.h -rw-r--r-- 10.8 KB
squashfs_fs_i.h -rw-r--r-- 1.4 KB
squashfs_fs_sb.h -rw-r--r-- 2.1 KB
super.c -rw-r--r-- 13.7 KB
symlink.c -rw-r--r-- 3.7 KB
xattr.c -rw-r--r-- 7.3 KB
xattr.h -rw-r--r-- 1.5 KB
xattr_id.c -rw-r--r-- 2.7 KB
xz_wrapper.c -rw-r--r-- 4.3 KB
zlib_wrapper.c -rw-r--r-- 3.1 KB

back to top