Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Brzezinka <sebastian.brzezinka@intel.com>
To: Krzysztof Karas <krzysztof.karas@intel.com>
Cc: <intel-gfx@lists.freedesktop.org>, <andi.shyti@linux.intel.com>
Subject: Re: [PATCH v2 1/3] drm/i915: Improve readability of eb_relocate_vma
Date: Fri, 18 Jul 2025 09:26:46 +0000	[thread overview]
Message-ID: <DBF2NW71CEZ0.J6AHO8HO3YF1@intel.com> (raw)
In-Reply-To: <wrum6ugu3qzexliktlvkz45uc5okcs5peiqrx63hfzmpb2ujko@do3mxsmdeaty>

Hi Krzysztof
On Thu Jul 17, 2025 at 2:38 PM UTC, Krzysztof Karas wrote:
> Hi Sebastian,
>
>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
>> @@ -1529,6 +1529,7 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
>>  	struct drm_i915_gem_relocation_entry __user *urelocs =
>>  		u64_to_user_ptr(entry->relocs_ptr);
>>  	unsigned long remain = entry->relocation_count;
>> +	int ret = 0;
>>  
>>  	if (unlikely(remain > N_RELOC(INT_MAX)))
>>  		return -EINVAL;
>> @@ -1541,11 +1542,10 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
>>  	if (unlikely(!access_ok(urelocs, remain * sizeof(*urelocs))))
>>  		return -EFAULT;
>>  
>> -	do {
>> -		struct drm_i915_gem_relocation_entry *r = stack;
>> -		unsigned int count =
>> -			min_t(unsigned long, remain, ARRAY_SIZE(stack));
>> +	while (remain > 0) {
> Is it possible for "remain" variable to be initialized to 0?
> If that would be the case then after your change we'd skip this
> loop entirely, where previously we'd run at least one iteration.
> Would that be a problem?
-- 
This should not occur, as there are several direct and indirect safeguards
verifying that entry->relocation_count is non-zero.
e.g.
```eb_relocate_vma_slow
1622 ›       for (i = 0; i < entry->relocation_count; i++) {
```
or

```check_relocations
1642 ›       size = entry->relocation_count;
1643 ›       if (size == 0)
1644 ›       ›       return 0;
```
And it would be a peculiar choice to copy 0 bytes

Best regards,
Sebastian


  reply	other threads:[~2025-07-18  9:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-17 12:38 [PATCH v2 0/3] drm/i915: i915_gem_execbuffer.c minor improved Sebastian Brzezinka
2025-07-17 12:38 ` [PATCH v2 1/3] drm/i915: Improve readability of eb_relocate_vma Sebastian Brzezinka
2025-07-17 14:38   ` Krzysztof Karas
2025-07-18  9:26     ` Sebastian Brzezinka [this message]
2025-07-18  0:38   ` Andi Shyti
2025-07-17 12:38 ` [PATCH v2 2/3] drm/i915: Add braces around the else block in clflush_write32() Sebastian Brzezinka
2025-07-17 14:41   ` Krzysztof Karas
2025-07-18  9:04   ` Andi Shyti
2025-07-17 12:38 ` [PATCH v2 3/3] drm/i915: Replaced hardcoded value 4095 with PAGE_SIZE - 1 Sebastian Brzezinka
2025-07-17 14:58   ` Krzysztof Karas
2025-07-17 15:16   ` Andi Shyti
2025-07-17 13:07 ` ✗ LGCI.VerificationFailed: failure for drm/i915: i915_gem_execbuffer.c minor improved (rev2) Patchwork

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=DBF2NW71CEZ0.J6AHO8HO3YF1@intel.com \
    --to=sebastian.brzezinka@intel.com \
    --cc=andi.shyti@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=krzysztof.karas@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox