<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Reviewed-by: Christian König
      <a class="moz-txt-link-rfc2396E" href="mailto:christian.koenig@amd.com"><christian.koenig@amd.com></a><br>
      <br>
      Am 17.06.19 um 20:21 schrieb Tom St Denis:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAAzXoRK9vy-qC36mSzJ3aJr6YB8kuWMujxfuNFAqAzbWEk+gTA@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">ping?</div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Fri, Jun 14, 2019 at 12:51
          PM StDenis, Tom <<a href="mailto:Tom.StDenis@amd.com"
            moz-do-not-send="true">Tom.StDenis@amd.com</a>> wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On
          32-bit hosts mem->num_pages is 32-bits and can overflow<br>
          when shifted.  Add a cast to avoid this.<br>
          <br>
          Signed-off-by: Tom St Denis <<a
            href="mailto:tom.stdenis@amd.com" target="_blank"
            moz-do-not-send="true">tom.stdenis@amd.com</a>><br>
          ---<br>
           drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 8 +++++---<br>
           1 file changed, 5 insertions(+), 3 deletions(-)<br>
          <br>
          diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
          b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c<br>
          index c963ad86072e..31895d3c33de 100644<br>
          --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c<br>
          +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c<br>
          @@ -279,14 +279,16 @@ static int amdgpu_vram_mgr_new(struct
          ttm_mem_type_manager *man,<br>
                  uint64_t vis_usage = 0;<br>
                  unsigned i;<br>
                  int r;<br>
          +       uint64_t mem_bytes;<br>
          <br>
                  lpfn = place->lpfn;<br>
                  if (!lpfn)<br>
                          lpfn = man->size;<br>
          <br>
                  /* bail out quickly if there's likely not enough VRAM
          for this BO */<br>
          -       if (atomic64_add_return(mem->num_pages <<
          PAGE_SHIFT, &mgr->usage) >
          adev->gmc.mc_vram_size) {<br>
          -               atomic64_sub(mem->num_pages <<
          PAGE_SHIFT, &mgr->usage);<br>
          +       mem_bytes = (u64)mem->num_pages <<
          PAGE_SHIFT;<br>
          +       if (atomic64_add_return(mem_bytes, &mgr->usage)
          > adev->gmc.mc_vram_size) {<br>
          +               atomic64_sub(mem_bytes, &mgr->usage);<br>
                          mem->mm_node = NULL;<br>
                          return 0;<br>
                  }<br>
          @@ -308,7 +310,7 @@ static int amdgpu_vram_mgr_new(struct
          ttm_mem_type_manager *man,<br>
                  nodes = kvmalloc_array((uint32_t)num_nodes,
          sizeof(*nodes),<br>
                                         GFP_KERNEL | __GFP_ZERO);<br>
                  if (!nodes) {<br>
          -               atomic64_sub(mem->num_pages <<
          PAGE_SHIFT, &mgr->usage);<br>
          +               atomic64_sub(mem_bytes, &mgr->usage);<br>
                          return -ENOMEM;<br>
                  }<br>
          <br>
          -- <br>
          2.21.0<br>
          <br>
          _______________________________________________<br>
          amd-gfx mailing list<br>
          <a href="mailto:amd-gfx@lists.freedesktop.org" target="_blank"
            moz-do-not-send="true">amd-gfx@lists.freedesktop.org</a><br>
          <a
            href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx"
            rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a></blockquote>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
amd-gfx mailing list
<a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a></pre>
    </blockquote>
    <br>
  </body>
</html>