[Intel-gfx] [igt-dev] [RFT i-g-t] lib/i915: Assert mmap size alignment

Chris Wilson chris at chris-wilson.co.uk
Tue Mar 5 09:30:48 UTC 2019


Quoting Tvrtko Ursulin (2019-03-05 09:23:02)
> 
> On 05/03/2019 08:38, Chris Wilson wrote:
> > Quoting Tvrtko Ursulin (2019-03-05 07:55:43)
> >>
> >> On 04/03/2019 14:45, Chris Wilson wrote:
> >>> Quoting Tvrtko Ursulin (2019-03-04 14:11:31)
> >>>> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> >>>>
> >>>> Fishing for fails...
> >>>>
> >>>> /*
> >>>> mmap(2) mandates size is page aligned so check this in our wrappers.
> >>>> */
> >>>>
> >>>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> >>>> ---
> >>>>    lib/i915/gem_mman.c |  4 ++++
> >>>>    lib/igt_fb.c        | 14 ++++++++------
> >>>>    tests/kms_ccs.c     | 14 ++++++++------
> >>>>    tests/kms_psr.c     |  8 ++++----
> >>>>    4 files changed, 24 insertions(+), 16 deletions(-)
> >>>>
> >>>> diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
> >>>> index 3cf9a6bbdb31..084dbb3b3678 100644
> >>>> --- a/lib/i915/gem_mman.c
> >>>> +++ b/lib/i915/gem_mman.c
> >>>> @@ -57,6 +57,8 @@ void *__gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot)
> >>>>           struct drm_i915_gem_mmap_gtt mmap_arg;
> >>>>           void *ptr;
> >>>>    
> >>>> +       igt_assert(!(size & 4095));
> >>>
> >>> Fwiw, it's probably best if we had some kind of IGT_BUG_ON() that caused
> >>> a much more visible explosion than a mere test failure.
> >>>
> >>> #define IGT_BUG_ON(cond) if (!(cond)) raise(SIGILL)
> >>
> >> No idea if that would be worthwhile.
> >>
> >> But anyway, it seems I have identified all the tests which do
> >> non-page-aligned mmap. So..
> >>
> >> a) leave the assert in low level mmap helpers
> >> b) move the assert to higher level wrappers
> >> c) round up in wrappers is not an option due unmap
> >> d) do nothing in igt
> > 
> > Imo leave the wrappers alone, fix the bugs in the callers, fume that it
> > didn't explode earlier.
> 
> Not even a small igt_warn or tiny igt_debug in the wrappers? :)

Not particularly, if it didn't impact the result, at worst it's a small
mysterious leak (which should be catchable by valgrind).
-Chris


More information about the Intel-gfx mailing list