From: Robin Murphy <robin.murphy@arm.com>
To: Alyssa Rosenzweig <alyssa@collabora.com>
Cc: robh@kernel.org, tomeu.vizoso@collabora.com,
steven.price@arm.com, alyssa.rosenzweig@collabora.com,
dri-devel@lists.freedesktop.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] drm/panfrost: Update io-pgtable API
Date: Tue, 23 Aug 2022 11:42:33 +0100 [thread overview]
Message-ID: <bbff1b5b-020c-7f61-1530-20fb0d6a1ef9@arm.com> (raw)
In-Reply-To: <YwRAnbNdx9nbGLom@maud>
On 2022-08-23 03:51, Alyssa Rosenzweig wrote:
>> -static size_t get_pgsize(u64 addr, size_t size)
>> +static size_t get_pgsize(u64 addr, size_t size, size_t *count)
>> {
>> - if (addr & (SZ_2M - 1) || size < SZ_2M)
>> - return SZ_4K;
>> + size_t blk_offset = -addr % SZ_2M;
>
> addr is unsigned. if this is correct, it's magic.
Eh, it's just well-defined unsigned integer overflow. Take "SZ_2M -
(addr % SZ_2M)", realise the first term can be anything that's zero
modulo SZ_2M, including zero, then also that the operations can be done
in either order to give the same result, and there you go.
Cheers,
Robin.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Robin Murphy <robin.murphy@arm.com>
To: Alyssa Rosenzweig <alyssa@collabora.com>
Cc: tomeu.vizoso@collabora.com, dri-devel@lists.freedesktop.org,
steven.price@arm.com, alyssa.rosenzweig@collabora.com,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] drm/panfrost: Update io-pgtable API
Date: Tue, 23 Aug 2022 11:42:33 +0100 [thread overview]
Message-ID: <bbff1b5b-020c-7f61-1530-20fb0d6a1ef9@arm.com> (raw)
In-Reply-To: <YwRAnbNdx9nbGLom@maud>
On 2022-08-23 03:51, Alyssa Rosenzweig wrote:
>> -static size_t get_pgsize(u64 addr, size_t size)
>> +static size_t get_pgsize(u64 addr, size_t size, size_t *count)
>> {
>> - if (addr & (SZ_2M - 1) || size < SZ_2M)
>> - return SZ_4K;
>> + size_t blk_offset = -addr % SZ_2M;
>
> addr is unsigned. if this is correct, it's magic.
Eh, it's just well-defined unsigned integer overflow. Take "SZ_2M -
(addr % SZ_2M)", realise the first term can be anything that's zero
modulo SZ_2M, including zero, then also that the operations can be done
in either order to give the same result, and there you go.
Cheers,
Robin.
next prev parent reply other threads:[~2022-08-23 10:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-22 22:01 [PATCH] drm/panfrost: Update io-pgtable API Robin Murphy
2022-08-22 22:01 ` Robin Murphy
2022-08-23 2:51 ` Alyssa Rosenzweig
2022-08-23 2:51 ` Alyssa Rosenzweig
2022-08-23 10:42 ` Robin Murphy [this message]
2022-08-23 10:42 ` Robin Murphy
2022-08-31 12:49 ` Alyssa Rosenzweig
2022-08-31 12:49 ` Alyssa Rosenzweig
2022-09-01 10:17 ` Steven Price
2022-09-01 10:17 ` Steven Price
2022-11-04 20:11 ` Dmitry Osipenko
2022-11-04 20:11 ` Dmitry Osipenko
2022-11-04 20:37 ` Robin Murphy
2022-11-04 20:37 ` Robin Murphy
2022-11-04 20:48 ` Dmitry Osipenko
2022-11-04 20:48 ` Dmitry Osipenko
2022-11-07 16:50 ` Robin Murphy
2022-11-07 16:50 ` Robin Murphy
2022-11-08 14:11 ` Dmitry Osipenko
2022-11-08 14:11 ` Dmitry Osipenko
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=bbff1b5b-020c-7f61-1530-20fb0d6a1ef9@arm.com \
--to=robin.murphy@arm.com \
--cc=alyssa.rosenzweig@collabora.com \
--cc=alyssa@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=robh@kernel.org \
--cc=steven.price@arm.com \
--cc=tomeu.vizoso@collabora.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.