<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;}
span.EmailStyle21
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[AMD Official Use Only - General]<br>
</p>
<br>
<div>
<div class="WordSection1">
<p class="MsoNormal">Sorry, meant to keep the JIRA part internal. As it stands, the amd/ folder alone has 458 {0}s (plus 55 {}s), and 741 memset-to-0s. So I guess it’s a matter of whether or not we’ll start enforcing memsets vs {0} in the near future. If we
intend to switch over soon anyways, we may as well start using memset now and in all future patches.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Kent<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Francis, David <David.Francis@amd.com> <br>
<b>Sent:</b> Tuesday, September 5, 2023 11:38 AM<br>
<b>To:</b> Russell, Kent <Kent.Russell@amd.com>; amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> Re: [PATCH] drm/amdgpu: Handle null atom context in VBIOS info ioctl<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p style="margin:5.0pt"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:blue">[AMD Official Use Only - General]<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<pre>[AMD Official Use Only - General]<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>Yeah we've had JIRAs (e.g. <a href="https://ontrack-internal.amd.com/browse/SWDEV-409711">https://ontrack-internal.amd.com/browse/SWDEV-409711</a> ) raised that ASAN can't compile the thunk due to using = {0} . Using memset is definitely preferred to save trouble later.<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre> Kent<o:p></o:p></pre>
</div>
</blockquote>
<pre>This is kernel code, not thunk. {} and {0} are extensively used throughout<o:p></o:p></pre>
<pre>the kernel in general and our driver in particular, so I don't see this causing problems.<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre> David<o:p></o:p></pre>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre><span style="color:#007CFF">-----Original Message-----<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">From: amd-gfx <a href="mailto:amd-gfx-bounces@lists.freedesktop.org"><amd-gfx-bounces@lists.freedesktop.org></a> On Behalf Of Alex<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">Deucher<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">Sent: Tuesday, September 5, 2023 10:53 AM<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">To: Francis, David <a href="mailto:David.Francis@amd.com"><David.Francis@amd.com></a><o:p></o:p></span></pre>
<pre><span style="color:#007CFF">Cc: <a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><o:p></o:p></span></pre>
<pre><span style="color:#007CFF">Subject: Re: [PATCH] drm/amdgpu: Handle null atom context in VBIOS info ioctl<o:p></o:p></span></pre>
<pre><span style="color:#007CFF"><o:p> </o:p></span></pre>
<pre><span style="color:#007CFF">On Tue, Sep 5, 2023 at 10:50</span><span style="font-family:"Cambria Math",serif;color:#007CFF"> </span><span style="color:#007CFF">AM David Francis <a href="mailto:David.Francis@amd.com"><David.Francis@amd.com></a> wrote:<o:p></o:p></span></pre>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre><span style="color:#007CFF">On some APU systems, there is no atom context and so the<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">atom_context struct is null.<o:p></o:p></span></pre>
<pre><span style="color:#007CFF"><o:p> </o:p></span></pre>
<pre><span style="color:#007CFF">Add a check to the VBIOS_INFO branch of amdgpu_info_ioctl<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">to handle this case, returning all zeroes.<o:p></o:p></span></pre>
<pre><span style="color:#007CFF"><o:p> </o:p></span></pre>
<pre><span style="color:#007CFF">Signed-off-by: David Francis <a href="mailto:David.Francis@amd.com"><David.Francis@amd.com></a><o:p></o:p></span></pre>
<pre><span style="color:#007CFF">---<o:p></o:p></span></pre>
<pre><span style="color:#007CFF"> drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 19 ++++++++++++-------<o:p></o:p></span></pre>
<pre><span style="color:#007CFF"> 1 file changed, 12 insertions(+), 7 deletions(-)<o:p></o:p></span></pre>
<pre><span style="color:#007CFF"><o:p> </o:p></span></pre>
<pre><span style="color:#007CFF">diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<o:p></o:p></span></pre>
</blockquote>
<pre><span style="color:#007CFF">b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<o:p></o:p></span></pre>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre><span style="color:#007CFF">index 3a48bec10aea..86748290ead7 100644<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">@@ -947,16 +947,21 @@ int amdgpu_info_ioctl(struct drm_device *dev, void<o:p></o:p></span></pre>
</blockquote>
<pre><span style="color:#007CFF">*data, struct drm_file *filp)<o:p></o:p></span></pre>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre><span style="color:#007CFF"> ? -EFAULT : 0;<o:p></o:p></span></pre>
<pre><span style="color:#007CFF"> }<o:p></o:p></span></pre>
<pre><span style="color:#007CFF"> case AMDGPU_INFO_VBIOS_INFO: {<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">- struct drm_amdgpu_info_vbios vbios_info = {};<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">+ struct drm_amdgpu_info_vbios vbios_info = {0};<o:p></o:p></span></pre>
</blockquote>
<pre><span style="color:#007CFF">IIRC, these should be equivalent. That said, I believe memset is<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">generally preferred as not all compilers seem to handle these cases<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">correctly.<o:p></o:p></span></pre>
<pre><span style="color:#007CFF"><o:p> </o:p></span></pre>
<pre><span style="color:#007CFF">Alex<o:p></o:p></span></pre>
<pre><span style="color:#007CFF"><o:p> </o:p></span></pre>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre><span style="color:#007CFF"> struct atom_context *atom_context;<o:p></o:p></span></pre>
<pre><span style="color:#007CFF"><o:p> </o:p></span></pre>
<pre><span style="color:#007CFF"> atom_context = adev->mode_info.atom_context;<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">- memcpy(vbios_info.name, atom_context->name,<o:p></o:p></span></pre>
</blockquote>
<pre><span style="color:#007CFF">sizeof(atom_context->name));<o:p></o:p></span></pre>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre><span style="color:#007CFF">- memcpy(vbios_info.vbios_pn, atom_context->vbios_pn,<o:p></o:p></span></pre>
</blockquote>
<pre><span style="color:#007CFF">sizeof(atom_context->vbios_pn));<o:p></o:p></span></pre>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre><span style="color:#007CFF">- vbios_info.version = atom_context->version;<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">- memcpy(vbios_info.vbios_ver_str, atom_context->vbios_ver_str,<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">- sizeof(atom_context->vbios_ver_str));<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">- memcpy(vbios_info.date, atom_context->date,<o:p></o:p></span></pre>
</blockquote>
<pre><span style="color:#007CFF">sizeof(atom_context->date));<o:p></o:p></span></pre>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre><span style="color:#007CFF">+ if (atom_context) {<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">+ memcpy(vbios_info.name, atom_context->name,<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">+ sizeof(atom_context->name));<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">+ memcpy(vbios_info.vbios_pn, atom_context->vbios_pn,<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">+ sizeof(atom_context->vbios_pn));<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">+ vbios_info.version = atom_context->version;<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">+ memcpy(vbios_info.vbios_ver_str, atom_context-<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">vbios_ver_str,<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">+ sizeof(atom_context->vbios_ver_str));<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">+ memcpy(vbios_info.date, atom_context->date,<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">+ sizeof(atom_context->date));<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">+ }<o:p></o:p></span></pre>
<pre><span style="color:#007CFF"><o:p> </o:p></span></pre>
<pre><span style="color:#007CFF"> return copy_to_user(out, &vbios_info,<o:p></o:p></span></pre>
<pre><span style="color:#007CFF"> min((size_t)size, sizeof(vbios_info))) ? -EFAULT : 0;<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">--<o:p></o:p></span></pre>
<pre><span style="color:#007CFF">2.34.1<o:p></o:p></span></pre>
<pre><span style="color:#007CFF"><o:p> </o:p></span></pre>
</blockquote>
</blockquote>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</body>
</html>