<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#317100;margin:15pt;" align="Left">
[AMD Public Use]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks Lyude for testing the patch.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Are you referring to this issue [1] ?</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Is it reproducible after applying this patch as well ?</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
[1] <a href="https://gitlab.freedesktop.org/drm/amd/-/issues/1473" id="LPlnk">https://gitlab.freedesktop.org/drm/amd/-/issues/1473</a></div>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
-- Anson</div>
</div>
</div>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Lyude Paul <lyude@redhat.com><br>
<b>Sent:</b> Friday, March 5, 2021 6:08 PM<br>
<b>To:</b> Jacob, Anson <Anson.Jacob@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Deucher, Alexander <Alexander.Deucher@amd.com>; Kuehling, Felix <Felix.Kuehling@amd.com><br>
<b>Subject:</b> Re: [PATCH] drm/amdkfd: Fix UBSAN shift-out-of-bounds warning</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Tested-by: Lyude Paul <lyude@redhat.com><br>
<br>
That just leaves the KASAN error from read_indirect_azalia_reg, thanks for the<br>
fix!<br>
<br>
On Thu, 2021-03-04 at 15:08 -0500, Anson Jacob wrote:<br>
> If get_num_sdma_queues or get_num_xgmi_sdma_queues is 0, we end up<br>
> doing a shift operation where the number of bits shifted equals<br>
> number of bits in the operand. This behaviour is undefined.<br>
> <br>
> Set num_sdma_queues or num_xgmi_sdma_queues to ULLONG_MAX, if the<br>
> count is >= number of bits in the operand.<br>
> <br>
> Bug: <a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.freedesktop.org%2Fdrm%2Famd%2F-%2Fissues%2F1472&amp;data=04%7C01%7Canson.jacob%40amd.com%7Ce9ea7130bcd945a194aa08d8e02ba9f8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637505826204096667%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=GEyObPt%2FnEeU9Y7K2I30RS1TBMGbbUneQ6hWkR7pJLM%3D&amp;reserved=0">
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.freedesktop.org%2Fdrm%2Famd%2F-%2Fissues%2F1472&amp;data=04%7C01%7Canson.jacob%40amd.com%7Ce9ea7130bcd945a194aa08d8e02ba9f8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637505826204096667%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=GEyObPt%2FnEeU9Y7K2I30RS1TBMGbbUneQ6hWkR7pJLM%3D&amp;reserved=0</a><br>
> Reported-by: Lyude Paul <lyude@redhat.com><br>
> Signed-off-by: Anson Jacob <Anson.Jacob@amd.com><br>
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com><br>
> Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com><br>
> ---<br>
>  .../drm/amd/amdkfd/kfd_device_queue_manager.c   | 17 +++++++++++++++--<br>
>  1 file changed, 15 insertions(+), 2 deletions(-)<br>
> <br>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c<br>
> b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c<br>
> index c37e9c4b1fb4..e7a3c496237f 100644<br>
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c<br>
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c<br>
> @@ -1128,6 +1128,9 @@ static int set_sched_resources(struct<br>
> device_queue_manager *dqm)<br>
>  <br>
>  static int initialize_cpsch(struct device_queue_manager *dqm)<br>
>  {<br>
> +       uint64_t num_sdma_queues;<br>
> +       uint64_t num_xgmi_sdma_queues;<br>
> +<br>
>         pr_debug("num of pipes: %d\n", get_pipes_per_mec(dqm));<br>
>  <br>
>         mutex_init(&dqm->lock_hidden);<br>
> @@ -1136,8 +1139,18 @@ static int initialize_cpsch(struct device_queue_manager<br>
> *dqm)<br>
>         dqm->active_cp_queue_count = 0;<br>
>         dqm->gws_queue_count = 0;<br>
>         dqm->active_runlist = false;<br>
> -       dqm->sdma_bitmap = ~0ULL >> (64 - get_num_sdma_queues(dqm));<br>
> -       dqm->xgmi_sdma_bitmap = ~0ULL >> (64 - get_num_xgmi_sdma_queues(dqm));<br>
> +<br>
> +       num_sdma_queues = get_num_sdma_queues(dqm);<br>
> +       if (num_sdma_queues >= BITS_PER_TYPE(dqm->sdma_bitmap))<br>
> +               dqm->sdma_bitmap = ULLONG_MAX;<br>
> +       else<br>
> +               dqm->sdma_bitmap = (BIT_ULL(num_sdma_queues) - 1);<br>
> +<br>
> +       num_xgmi_sdma_queues = get_num_xgmi_sdma_queues(dqm);<br>
> +       if (num_xgmi_sdma_queues >= BITS_PER_TYPE(dqm->xgmi_sdma_bitmap))<br>
> +               dqm->xgmi_sdma_bitmap = ULLONG_MAX;<br>
> +       else<br>
> +               dqm->xgmi_sdma_bitmap = (BIT_ULL(num_xgmi_sdma_queues) - 1);<br>
>  <br>
>         INIT_WORK(&dqm->hw_exception_work, kfd_process_hw_exception);<br>
>  <br>
<br>
-- <br>
Sincerely,<br>
   Lyude Paul (she/her)<br>
   Software Engineer at Red Hat<br>
   <br>
Note: I deal with a lot of emails and have a lot of bugs on my plate. If you've<br>
asked me a question, are waiting for a review/merge on a patch, etc. and I<br>
haven't responded in a while, please feel free to send me another email to check<br>
on my status. I don't bite!<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>