hk: use 0 pointer for 0-sized buffers

allows eliding bounds checks

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31532>
This commit is contained in:
Alyssa Rosenzweig 2024-09-19 13:16:33 -04:00 committed by Marge Bot
parent 675b876b8c
commit 802c30beab

View file

@ -35,7 +35,11 @@ static inline struct hk_addr_range
hk_buffer_addr_range(const struct hk_buffer *buffer, uint64_t offset,
uint64_t range)
{
if (buffer == NULL)
/* If range == 0, return a NULL pointer. Thanks to soft fault, that allows
* eliding robustness2 bounds checks for index = 0, as the bottom of VA space
* is reserved.
*/
if (buffer == NULL || range == 0)
return (struct hk_addr_range){.range = 0};
return (struct hk_addr_range){