Skip to content

Commit

Permalink
Revert "KVM: No need to retry for hva_to_pfn_remapped()"
Browse files Browse the repository at this point in the history
This reverts commit 5b494ae.
If unlocked==true then the vma pointer could be invalidated, so the 2nd
follow_pfn() is potentially racy: we do need to get out and redo
find_vma_intersection().

Signed-off-by: Peter Xu <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
bonzini committed Jun 1, 2020
1 parent cc440cd commit a8387d0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1831,6 +1831,8 @@ static int hva_to_pfn_remapped(struct vm_area_struct *vma,
r = fixup_user_fault(current, current->mm, addr,
(write_fault ? FAULT_FLAG_WRITE : 0),
&unlocked);
if (unlocked)
return -EAGAIN;
if (r)
return r;

Expand Down Expand Up @@ -1901,12 +1903,15 @@ static kvm_pfn_t hva_to_pfn(unsigned long addr, bool atomic, bool *async,
goto exit;
}

retry:
vma = find_vma_intersection(current->mm, addr, addr + 1);

if (vma == NULL)
pfn = KVM_PFN_ERR_FAULT;
else if (vma->vm_flags & (VM_IO | VM_PFNMAP)) {
r = hva_to_pfn_remapped(vma, addr, async, write_fault, writable, &pfn);
if (r == -EAGAIN)
goto retry;
if (r < 0)
pfn = KVM_PFN_ERR_FAULT;
} else {
Expand Down

0 comments on commit a8387d0

Please sign in to comment.