[igt-dev] [PATCH i-g-t 1/1] lib/intel_allocator: Check validity of the file descriptor

Petri Latvala petri.latvala at intel.com
Wed Jun 16 12:05:50 UTC 2021


On Wed, Jun 16, 2021 at 01:37:14PM +0200, Andrzej Turko wrote:
> All procedures for opening particular types of allocators
> query the gtt size. Even if the user has provided the
> boundaries of the address space managed by the allocator,
> the query is performed for the sake of validation.
> 
> gem_aperture_size() called with an invalid id returns a
> default value instead of failing. Thus, we need to
> additionally check whether the file descriptor is valid.
> 
> Signed-off-by: Andrzej Turko <andrzej.turko at linux.intel.com>
> Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> ---
>  lib/intel_allocator.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/lib/intel_allocator.c b/lib/intel_allocator.c
> index 96f839d4b..c060e10c3 100644
> --- a/lib/intel_allocator.c
> +++ b/lib/intel_allocator.c
> @@ -166,6 +166,15 @@ static inline void map_entry_free_func(struct igt_map_entry *entry)
>  	free(entry->data);
>  }
>  
> +static bool can_report_gtt_size(int fd)
> +{
> +	struct drm_i915_gem_context_param p = {
> +		.param = I915_CONTEXT_PARAM_GTT_SIZE
> +	};
> +
> +	return (__gem_context_get_param(fd, &p) == 0);
> +}
> +
>  static uint64_t __handle_create(struct allocator *al)
>  {
>  	struct handle_entry *h = malloc(sizeof(*h));
> @@ -271,6 +280,8 @@ static struct intel_allocator *intel_allocator_create(int fd,
>  {
>  	struct intel_allocator *ial = NULL;
>  
> +	igt_assert(can_report_gtt_size(fd));
> +

Is igt_assert correct here (as opposed to igt_require)? Or in other
words, is inability to report gtt size a kernel bug or not?


-- 
Petri Latvala


More information about the igt-dev mailing list