All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Timur Kristóf" <timur.kristof@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/4] drm/amdgpu: Convert tiling flags to modifiers on GFX6-8
Date: Mon, 20 Jul 2026 14:43:55 +0000	[thread overview]
Message-ID: <20260720144357.251511F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260720142440.22076-3-timur.kristof@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Missing cpp factor in GFX6 block size calculation enables out-of-bounds VRAM read vulnerability.
- [High] Strict rejection of RENDER microtiling introduces a functional regression for legacy GFX6 compositors.
- [Low] Usage of undefined/DC-specific ASSERT macro in generic AMDGPU code causes build failures or macro misuse.
--

--- Patch [2]: [PATCH 2/4] drm/amdgpu: Convert tiling flags to modifiers on GFX6-8 ---
commit 44a2b5305f951bc68d3e2665bc5db9defc35dd24
Author: Timur Kristóf <timur.kristof@gmail.com>
Subject: drm/amdgpu: Convert tiling flags to modifiers on GFX6-8

This commit converts tiling flags to DRM format modifiers for AMD GFX8 and
older GPUs, ensuring consistency across generations and allowing the display
driver to rely on them. It includes logic to map array modes to modifiers and
verify block sizes for GFX6 specifically.

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c

[ ... ]

> +	if (array_mode != AMD_FMT_MOD_TILE_GFX6_1D_TILED_THIN1 &&
> +	    array_mode != AMD_FMT_MOD_TILE_GFX6_2D_TILED_THIN1) {
> +		drm_dbg_kms(dev, "Array mode %u not supported by display driver\n", array_mode);
> +		return -EINVAL;
> +	}
> +	if (micro_tile_mode != AMD_FMT_MOD_MICROTILE_DISPLAY) {
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[Severity: High]
Does this break legacy userspace compositors? 

Looking at check_tiling_flags_gfx6(), it explicitly supports RENDER 
microtiling (mode 3):

	micro_tile_mode = AMDGPU_TILING_GET(afb->tiling_flags, MICRO_TILE_MODE);
	switch (micro_tile_mode) {
	case 0: /* DISPLAY */
	case 3: /* RENDER */
		return 0;

Could returning -EINVAL here for RENDER mode cause a regression for legacy 
clients allocating display buffers for 3D performance?

> +		drm_dbg_kms(dev, "Microtile mode %u not displayable\n", micro_tile_mode);
> +		return -EINVAL;
> +	}

[ ... ]

> @@ -1120,6 +1247,15 @@ static int amdgpu_display_verify_sizes(struct amdgpu_framebuffer *rfb)
>  
>  			get_block_dimensions(block_size_log2, format_info->cpp[i],
>  					     &block_width, &block_height);
> +		} else if (AMD_FMT_MOD_GET(TILE_VERSION, modifier) == AMD_FMT_MOD_TILE_VER_GFX6) {
> +			ret = amdgpu_display_verify_sizes_gfx6(rfb->base.dev, modifier,
> +							       &block_width, &block_height);
> +			if (ret)
> +				return ret;
> +
> +			ASSERT(is_power_of_2(block_width));
                        ^^^^^^

[Severity: Low]
Are these ASSERT() macros defined in this context? 

ASSERT is typically a Display Core (DC) specific macro (from dc/os_types.h). 
Since amdgpu_display.c is part of the core driver, would WARN_ON() be more 
appropriate here to avoid potential build failures?

> +			ASSERT(is_power_of_2(block_height));
> +			block_size_log2 = ilog2(block_width * block_height);
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[Severity: High]
Should this calculation include the bytes-per-pixel factor? 

By omitting the format_info->cpp[i] multiplier, block_size_log2 appears to 
underestimate the block size. 

When this is later passed into amdgpu_display_verify_plane(), it calculates:

	unsigned int block_size = 1 << block_size_log2;
        ...
	size = rfb->base.offsets[plane] +
		(uint64_t)rfb->base.pitches[plane] / block_pitch *
		block_size * DIV_ROUND_UP(height, block_height);

	if (rfb->base.obj[0]->size < size) {

An underestimated block_size results in a vastly smaller size requirement, 
which might allow an undersized Buffer Object to pass validation, 
potentially leading to out-of-bounds VRAM reads.

>  		}
>  
>  		ret = amdgpu_display_verify_plane(rfb, i, format_info,

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260720142440.22076-1-timur.kristof@gmail.com?part=2

  reply	other threads:[~2026-07-20 14:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20 14:24 [PATCH 0/4] drm/amdgpu: Support DRM format modifiers on GFX6-8 (v3) Timur Kristóf
2026-07-20 14:24 ` [PATCH 1/4] drm/fourcc: Add modifiers for AMD GFX6-8 Timur Kristóf
2026-07-20 14:28   ` sashiko-bot
2026-07-20 14:24 ` [PATCH 2/4] drm/amdgpu: Convert tiling flags to modifiers on GFX6-8 Timur Kristóf
2026-07-20 14:43   ` sashiko-bot [this message]
2026-07-20 14:24 ` [PATCH 3/4] drm/amd/display: Support DRM format " Timur Kristóf
2026-07-20 14:42   ` sashiko-bot
2026-07-20 14:24 ` [PATCH 4/4] drm/amd/display: Don't use tiling flags anymore Timur Kristóf
2026-07-20 15:00   ` sashiko-bot
  -- strict thread matches above, loose matches on Subject: below --
2026-07-15 10:57 [PATCH 0/4] drm/amdgpu: Support DRM format modifiers on GFX6-8 (v2) Timur Kristóf
2026-07-15 10:57 ` [PATCH 2/4] drm/amdgpu: Convert tiling flags to modifiers on GFX6-8 Timur Kristóf
2026-07-15 11:10   ` sashiko-bot
2026-07-15 20:33     ` Timur Kristóf
2026-05-13 20:43 [PATCH 0/4] drm/amdgpu: Support DRM format " Timur Kristóf
2026-05-13 20:43 ` [PATCH 2/4] drm/amdgpu: Convert tiling flags to " Timur Kristóf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260720144357.251511F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=timur.kristof@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.