Commit 72398f8c authored by Du Yilong's avatar Du Yilong Committed by Zheng Zengkai
Browse files

sw64: kvm: fix bug when open file with the O_DIRECT flag

Sunway inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I56WV8



--------------------------------

sw_64/kvm map the memory of VM instance to QEMU's user space by
remap_pfn_range(), which set the vma flag with VM_IO and VM_PFNMAP.

The previous commit set these pages as reserved and follow_pfn()
method will get pfn of a PFNMAP vma correctly to fix bug if user
do munmap on the vma.

But in generic_file_read_iter() with O_DIRECT flag will call
__get_user_pages() and return -EFAULT because of VM_IO and
VM_PFNMAP, then bio_iov_iter_get_pages() failed to get the
physical pages corresponding to the user virtual address.

To solve this problem, VM_IO and VM_PFNMAP of the vma flag were
cleared and set again before release this vma.

Signed-off-by: default avatarDu Yilong <duyilong@wxiat.com>

Signed-off-by: default avatarGu Zitao <guzitao@wxiat.com>
Acked-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 565036e2
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment