<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<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:#0000FF;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[AMD Official Use Only - General]<br>
</p>
<br>
<div>
<blockquote type="cite">
<div class="moz-text-plain" lang="x-unicode" style="font-size:12px">
<pre class="moz-quote-pre">[AMD Official Use Only - General]
Yeah we've had JIRAs (e.g. <a href="https://ontrack-internal.amd.com/browse/SWDEV-409711" data-auth="NotApplicable" class="moz-txt-link-freetext OWAAutoLink" id="OWA35a92431-92f5-fbf9-44f1-bfb76442e6ea">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.
Kent</pre>
</div>
</blockquote>
<pre>This is kernel code, not thunk. {} and {0} are extensively used throughout
the kernel in general and our driver in particular, so I don't see this causing problems.
David
</pre>
<blockquote type="cite">
<div class="moz-text-plain" lang="x-unicode" style="font-size:12px">
<pre class="moz-quote-pre"></pre>
<blockquote type="cite" style="color: rgb(0, 124, 255);">
<pre class="moz-quote-pre">-----Original Message-----
From: amd-gfx <a href="mailto:amd-gfx-bounces@lists.freedesktop.org" class="moz-txt-link-rfc2396E OWAAutoLink" id="OWAb2b07b64-d08a-2147-8e81-46fdb9908c6e"><amd-gfx-bounces@lists.freedesktop.org></a> On Behalf Of Alex
Deucher
Sent: Tuesday, September 5, 2023 10:53 AM
To: Francis, David <a href="mailto:David.Francis@amd.com" class="moz-txt-link-rfc2396E OWAAutoLink" id="OWA19b9d6d1-b185-a501-2be6-2aeb0dcdf67b"><David.Francis@amd.com></a>
Cc: <a href="mailto:amd-gfx@lists.freedesktop.org" class="moz-txt-link-abbreviated moz-txt-link-freetext OWAAutoLink" id="OWA6f03fbef-2934-2760-386e-8fb1c8a0f4ee">amd-gfx@lists.freedesktop.org</a>
Subject: Re: [PATCH] drm/amdgpu: Handle null atom context in VBIOS info ioctl
On Tue, Sep 5, 2023 at 10:50 AM David Francis <a href="mailto:David.Francis@amd.com" class="moz-txt-link-rfc2396E OWAAutoLink" id="OWA07c77787-79ed-e9df-7a26-a4e7ce8d130d"><David.Francis@amd.com></a> wrote:
</pre>
<blockquote type="cite" style="color: rgb(0, 124, 255);">
<pre class="moz-quote-pre">On some APU systems, there is no atom context and so the
atom_context struct is null.
Add a check to the VBIOS_INFO branch of amdgpu_info_ioctl
to handle this case, returning all zeroes.
Signed-off-by: David Francis <a href="mailto:David.Francis@amd.com" class="moz-txt-link-rfc2396E OWAAutoLink" id="OWAdf0e938c-5027-05dd-74b9-ab692761ee5b"><David.Francis@amd.com></a>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
</pre>
</blockquote>
<pre class="moz-quote-pre">b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
</pre>
<blockquote type="cite" style="color: rgb(0, 124, 255);">
<pre class="moz-quote-pre">index 3a48bec10aea..86748290ead7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -947,16 +947,21 @@ int amdgpu_info_ioctl(struct drm_device *dev, void
</pre>
</blockquote>
<pre class="moz-quote-pre">*data, struct drm_file *filp)
</pre>
<blockquote type="cite" style="color: rgb(0, 124, 255);">
<pre class="moz-quote-pre"> ? -EFAULT : 0;
}
case AMDGPU_INFO_VBIOS_INFO: {
- struct drm_amdgpu_info_vbios vbios_info = {};
+ struct drm_amdgpu_info_vbios vbios_info = {0};
</pre>
</blockquote>
<pre class="moz-quote-pre">IIRC, these should be equivalent. That said, I believe memset is
generally preferred as not all compilers seem to handle these cases
correctly.
Alex
</pre>
<blockquote type="cite" style="color: rgb(0, 124, 255);">
<pre class="moz-quote-pre"> struct atom_context *atom_context;
atom_context = adev->mode_info.atom_context;
- memcpy(vbios_info.name, atom_context->name,
</pre>
</blockquote>
<pre class="moz-quote-pre">sizeof(atom_context->name));
</pre>
<blockquote type="cite" style="color: rgb(0, 124, 255);">
<pre class="moz-quote-pre">- memcpy(vbios_info.vbios_pn, atom_context->vbios_pn,
</pre>
</blockquote>
<pre class="moz-quote-pre">sizeof(atom_context->vbios_pn));
</pre>
<blockquote type="cite" style="color: rgb(0, 124, 255);">
<pre class="moz-quote-pre">- vbios_info.version = atom_context->version;
- memcpy(vbios_info.vbios_ver_str, atom_context->vbios_ver_str,
- sizeof(atom_context->vbios_ver_str));
- memcpy(vbios_info.date, atom_context->date,
</pre>
</blockquote>
<pre class="moz-quote-pre">sizeof(atom_context->date));
</pre>
<blockquote type="cite" style="color: rgb(0, 124, 255);">
<pre class="moz-quote-pre">+ if (atom_context) {
+ memcpy(vbios_info.name, atom_context->name,
+ sizeof(atom_context->name));
+ memcpy(vbios_info.vbios_pn, atom_context->vbios_pn,
+ sizeof(atom_context->vbios_pn));
+ vbios_info.version = atom_context->version;
+ memcpy(vbios_info.vbios_ver_str, atom_context-
vbios_ver_str,
+ sizeof(atom_context->vbios_ver_str));
+ memcpy(vbios_info.date, atom_context->date,
+ sizeof(atom_context->date));
+ }
return copy_to_user(out, &vbios_info,
min((size_t)size, sizeof(vbios_info))) ? -EFAULT : 0;
--
2.34.1
</pre>
</blockquote>
</blockquote>
</div>
</blockquote>
</div>
</body>
</html>