[PATCH] drm/i915/gvt: Add carefully checking in GTT walker paths

Du, Changbin changbin.du at intel.com
Thu Aug 3 02:43:16 UTC 2017


On Thu, Aug 03, 2017 at 10:27:00AM +0800, Zhenyu Wang wrote:
> On 2017.08.02 15:06:37 +0800, changbin.du at intel.com wrote:
> > From: Changbin Du <changbin.du at intel.com>
> > 
> > When debugging the gtt code, found the intel_vgpu_gma_to_gpa() can
> > translate any given GMA though the GMA is not valid. This because
> > the GTT ops suppress the possible errors, which may result in an
> > invalid PT entry is retrieved by upper caller.
> > 
> > This patch changed the prototype of pte ops to propagate status to
> > callers. Then we make sure the GTT walker stop as early as when
> > a error is detected to prevent undefined behavior.
> > 
> > Signed-off-by: Changbin Du <changbin.du at intel.com>
> > ---
> >  drivers/gpu/drm/i915/gvt/gtt.c | 77 +++++++++++++++++++++++++++---------------
> >  drivers/gpu/drm/i915/gvt/gtt.h | 24 +++++++------
> >  2 files changed, 64 insertions(+), 37 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c
> > index 6166e34..e397f5e 100644
> > --- a/drivers/gpu/drm/i915/gvt/gtt.c
> > +++ b/drivers/gpu/drm/i915/gvt/gtt.c
> > @@ -259,7 +259,7 @@ static void write_pte64(struct drm_i915_private *dev_priv,
> >  	writeq(pte, addr);
> >  }
> >  
> > -static inline struct intel_gvt_gtt_entry *gtt_get_entry64(void *pt,
> > +static inline int gtt_get_entry64(void *pt,
> >  		struct intel_gvt_gtt_entry *e,
> >  		unsigned long index, bool hypervisor_access, unsigned long gpa,
> >  		struct intel_vgpu *vgpu)
> 
> Could we fix this function call by removing "e" as pass-in/out parameter but
> only as return pointer for "struct intel_gvt_gtt_entry *" then use formal
> kernel ERR_PTR() to return error and check?
> 
The intel_gvt_gtt_entry is staticly allocated on stack, no need allocate it
dynamically here. So better keep current fashion.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/intel-gvt-dev/attachments/20170803/d9bd156c/attachment-0001.sig>


More information about the intel-gvt-dev mailing list