[1/2] drm/i915/gvt: Release gvt->lock at the failure of finding page track

Submitted by Wang, Zhi A on March 5, 2018, 6:01 a.m.

Details

Message ID F3B0350DF4CB6849A642218320DE483D7D6DD819@SHSMSX104.ccr.corp.intel.com
State New
Headers show
Series "Series without cover letter" ( rev: 2 ) in Intel GVT devel

Not browsing as part of any series.

Commit Message

Wang, Zhi A March 5, 2018, 6:01 a.m.
Do you wish this patch going to gvt-fixes? :)

-----Original Message-----
From: intel-gvt-dev [mailto:intel-gvt-dev-bounces@lists.freedesktop.org] On Behalf Of Xiong Zhang

Sent: Tuesday, March 6, 2018 6:07 AM
To: intel-gvt-dev@lists.freedesktop.org
Cc: Zhang, Xiong Y <xiong.y.zhang@intel.com>
Subject: [PATCH 1/2] drm/i915/gvt: Release gvt->lock at the failure of finding page track

page_track_handler take lock at the beginning, the lock should be released at the failure of finding page track. Otherwise deadlock will happen.

Fixes:7772c6f723e1("drm/i915/gvt:Provide generic page_track in infrastructure for write_protected page")
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>

---
 drivers/gpu/drm/i915/gvt/page_track.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

 			gvt_err("guest page write error, gpa %llx\n", gpa);
 	}
 
+out:
 	mutex_unlock(&gvt->lock);
 	return ret;
 }
--
2.7.4

_______________________________________________
intel-gvt-dev mailing list
intel-gvt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/i915/gvt/page_track.c b/drivers/gpu/drm/i915/gvt/page_track.c
index 09bd56e..2d03054 100644
--- a/drivers/gpu/drm/i915/gvt/page_track.c
+++ b/drivers/gpu/drm/i915/gvt/page_track.c
@@ -165,7 +165,7 @@  int intel_vgpu_page_track_handler(struct intel_vgpu *vgpu, u64 gpa,
 
 	page_track = intel_vgpu_find_page_track(vgpu, gpa >> PAGE_SHIFT);
 	if (!page_track)
-		return 0;
+		goto out;
 
 	if (unlikely(vgpu->failsafe)) {
 		/* Remove write protection to prevent furture traps. */ @@ -176,6 +176,7 @@ int intel_vgpu_page_track_handler(struct intel_vgpu *vgpu, u64 gpa,

Comments

On 2018.03.05 06:01:43 +0000, Wang, Zhi A wrote:
> Do you wish this patch going to gvt-fixes? :)
>

As this is to fix recent page track rework, so should be for gvt-next.

> -----Original Message-----
> From: intel-gvt-dev [mailto:intel-gvt-dev-bounces@lists.freedesktop.org] On Behalf Of Xiong Zhang
> Sent: Tuesday, March 6, 2018 6:07 AM
> To: intel-gvt-dev@lists.freedesktop.org
> Cc: Zhang, Xiong Y <xiong.y.zhang@intel.com>
> Subject: [PATCH 1/2] drm/i915/gvt: Release gvt->lock at the failure of finding page track
> 
> page_track_handler take lock at the beginning, the lock should be released at the failure of finding page track. Otherwise deadlock will happen.
> 
> Fixes:7772c6f723e1("drm/i915/gvt:Provide generic page_track in infrastructure for write_protected page")
> Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
> ---
>  drivers/gpu/drm/i915/gvt/page_track.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/page_track.c b/drivers/gpu/drm/i915/gvt/page_track.c
> index 09bd56e..2d03054 100644
> --- a/drivers/gpu/drm/i915/gvt/page_track.c
> +++ b/drivers/gpu/drm/i915/gvt/page_track.c
> @@ -165,7 +165,7 @@ int intel_vgpu_page_track_handler(struct intel_vgpu *vgpu, u64 gpa,
>  
>  	page_track = intel_vgpu_find_page_track(vgpu, gpa >> PAGE_SHIFT);
>  	if (!page_track)
> -		return 0;
> +		goto out;
>  
>  	if (unlikely(vgpu->failsafe)) {
>  		/* Remove write protection to prevent furture traps. */ @@ -176,6 +176,7 @@ int intel_vgpu_page_track_handler(struct intel_vgpu *vgpu, u64 gpa,
>  			gvt_err("guest page write error, gpa %llx\n", gpa);
>  	}
>  
> +out:
>  	mutex_unlock(&gvt->lock);
>  	return ret;
>  }

nice catch, thx!