mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 22:02:02 +00:00
iommu/amd: Cleanup error handling in do_fault()
Get rid of the three error paths that look the same and move error handling to a single place. Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org> Acked-By: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
43c0ea20de
commit
492e74594e
1 changed files with 9 additions and 17 deletions
|
@ -514,10 +514,10 @@ static void do_fault(struct work_struct *work)
|
||||||
{
|
{
|
||||||
struct fault *fault = container_of(work, struct fault, work);
|
struct fault *fault = container_of(work, struct fault, work);
|
||||||
struct vm_area_struct *vma;
|
struct vm_area_struct *vma;
|
||||||
|
int ret = VM_FAULT_ERROR;
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
struct mm_struct *mm;
|
struct mm_struct *mm;
|
||||||
u64 address;
|
u64 address;
|
||||||
int ret;
|
|
||||||
|
|
||||||
mm = fault->state->mm;
|
mm = fault->state->mm;
|
||||||
address = fault->address;
|
address = fault->address;
|
||||||
|
@ -529,31 +529,23 @@ static void do_fault(struct work_struct *work)
|
||||||
|
|
||||||
down_read(&mm->mmap_sem);
|
down_read(&mm->mmap_sem);
|
||||||
vma = find_extend_vma(mm, address);
|
vma = find_extend_vma(mm, address);
|
||||||
if (!vma || address < vma->vm_start) {
|
if (!vma || address < vma->vm_start)
|
||||||
/* failed to get a vma in the right range */
|
/* failed to get a vma in the right range */
|
||||||
up_read(&mm->mmap_sem);
|
|
||||||
handle_fault_error(fault);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if we have the right permissions on the vma */
|
/* Check if we have the right permissions on the vma */
|
||||||
if (access_error(vma, fault)) {
|
if (access_error(vma, fault))
|
||||||
up_read(&mm->mmap_sem);
|
|
||||||
handle_fault_error(fault);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
ret = handle_mm_fault(mm, vma, address, flags);
|
ret = handle_mm_fault(mm, vma, address, flags);
|
||||||
if (ret & VM_FAULT_ERROR) {
|
|
||||||
/* failed to service fault */
|
|
||||||
up_read(&mm->mmap_sem);
|
|
||||||
handle_fault_error(fault);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
up_read(&mm->mmap_sem);
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
up_read(&mm->mmap_sem);
|
||||||
|
|
||||||
|
if (ret & VM_FAULT_ERROR)
|
||||||
|
/* failed to service fault */
|
||||||
|
handle_fault_error(fault);
|
||||||
|
|
||||||
finish_pri_tag(fault->dev_state, fault->state, fault->tag);
|
finish_pri_tag(fault->dev_state, fault->state, fault->tag);
|
||||||
|
|
||||||
put_pasid_state(fault->state);
|
put_pasid_state(fault->state);
|
||||||
|
|
Loading…
Reference in a new issue