vhost-vdpa: switch to use vmf_insert_pfn() in the fault handler
Subsystems (6)
PATCH 1/1 vhost-vdpa: switch to use vmf_insert_pfn() in the fault handler
remap_pfn_page() should not be called in the fault handler as it may change the vma->flags which may trigger lockdep warning since the vma write lock is not held. Actually there's no need to modify the vma->flags as it has been set in the mmap(). So this patch switches to use vmf_insert_pfn() instead.
--- drivers/vhost/vdpa.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/vhost/vdpa.c +1 -7
@@ -1483,13 +1483,7 @@ static vm_fault_t vhost_vdpa_fault(struct vm_fault *vmf) notify = ops->get_vq_notification (vdpa, index); - vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); -if (remap_pfn_range (vma, vmf->address &PAGE_MASK , -PFN_DOWN (notify.addr),PAGE_SIZE , - vma->vm_page_prot)) -return VM_FAULT_SIGBUS ; - -return VM_FAULT_NOPAGE ; +return vmf_insert_pfn (vma, vmf->address &PAGE_MASK ,PFN_DOWN (notify.addr)); }static const struct vm_operations_struct vhost_vdpa_vm_ops = {
Signature · 1 line
2.31.1
Quoted 38 lines · Jason Wang
remap_pfn_page()should not be called in the fault handler as it may change thevma->flagswhich may trigger lockdep warning since the vma write lock is not held. Actually there's no need to modify thevma->flagsas it has been set in themmap(). So this patch switches to usevmf_insert_pfn()instead.Reported-by Dragos Tatulea <[email protected]>Tested-by Dragos Tatulea <[email protected]>Fixes ddd89d0a059d ("vhost_vdpa: support doorbell mapping via mmap")Signed-off-by Jason Wang <[email protected]>--- drivers/vhost/vdpa.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)drivers/vhost/vdpa.c +1
-7@@ -1483,13 +1483,7 @@ static vm_fault_t vhost_vdpa_fault(struct vm_fault *vmf) notify = ops->get_vq_notification (vdpa, index); - vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); -if (remap_pfn_range (vma, vmf->address &PAGE_MASK , -PFN_DOWN (notify.addr),PAGE_SIZE , - vma->vm_page_prot)) -return VM_FAULT_SIGBUS ; - -return VM_FAULT_NOPAGE ; +return vmf_insert_pfn (vma, vmf->address &PAGE_MASK ,PFN_DOWN (notify.addr)); }static const struct vm_operations_struct vhost_vdpa_vm_ops = {Signature · 1 line
2.31.1
I would only consider pasting an example warning log. (It's my suggestion only).
Anyway, the patch looks OK to me.
Thanks,