<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div>On Mon, 2024-04-15 at 16:06 +0000, Timur Tabi wrote:</div>
<blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex">
<div><br>
</div>
<blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex">
<blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex">
<pre>+ u32 dword; /* TYPE_DWORD */</pre>
<pre>+ u8 binary[] __counted_by(vlen); /* TYPE_BINARY or TYPE_STRING */</pre>
</blockquote>
<pre><br></pre>
<pre>NIT: Can't we put these two into a union?</pre>
</blockquote>
<div><br>
</div>
<div>Sure.</div>
</blockquote>
<div><br>
</div>
<div>It turns out that it can't be a union:</div>
<div><br>
</div>
<pre>drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c:1125:20: error: flexible array member in union</pre>
<pre> 1125 | u8 binary[] __counted_by(vlen); /* TYPE_BINARY or TYPE_STRING */</pre>
<pre> | ^~~~~~</pre>
<pre><br></pre>
<blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex">
<div><br>
</div>
<div>... it can't be vlen here because the value has to be '4' for dwords, and 'vlen' is 0 for dwords.</div>
</blockquote>
<div><br>
</div>
<div><br>
</div>
<div>I also noticed a bug that is relevant:</div>
<div><br>
</div>
<div>
<div><span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">+static void build_registry(struct nvkm_gsp *gsp, PACKED_REGISTRY_TABLE *registry)</span><br style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">
<span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">+{</span><br style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">
<span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">+</span><span class="Apple-tab-span" style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px; white-space: pre;">
</span><span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">struct registry_list_entry *reg, *n;</span><br style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">
<span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">+</span><span class="Apple-tab-span" style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px; white-space: pre;">
</span><span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">size_t str_offset;</span><br style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">
<span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">+</span><span class="Apple-tab-span" style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px; white-space: pre;">
</span><span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">unsigned int i = 0;</span><br style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">
<span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">+</span><br style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">
<span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">+</span><span class="Apple-tab-span" style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px; white-space: pre;">
</span><span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">registry->numEntries = list_count_nodes(&gsp->registry_list);</span><br style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">
<span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">+</span><span class="Apple-tab-span" style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px; white-space: pre;">
</span><span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">str_offset = struct_size(registry, entries, registry->numEntries);</span><br style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">
<span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">+</span><br style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">
<span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">+</span><span class="Apple-tab-span" style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px; white-space: pre;">
</span><span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">list_for_each_entry_safe(reg, n, &gsp->registry_list, head) {</span><br style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">
<span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">+</span><span class="Apple-tab-span" style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px; white-space: pre;">
</span><span class="Apple-tab-span" style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px; white-space: pre;"></span><span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">registry->entries[i].type
= reg->type;</span><br style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">
<span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">+</span><span class="Apple-tab-span" style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px; white-space: pre;">
</span><span class="Apple-tab-span" style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px; white-space: pre;"></span><span style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">registry->entries[i].length
= reg->klen;</span><br style="caret-color: rgb(61, 61, 61); color: rgb(61, 61, 61); font-family: "Ubuntu Mono"; font-size: 17.333334px;">
<br>
</div>
</div>
<div><font color="#3d3d3d" face="Ubuntu Mono" size="4"><span style="caret-color: rgb(61, 61, 61);">This is supposed to be reg->vlen.</span></font></div>
<div><font color="#3d3d3d" face="Ubuntu Mono" size="4"><span style="caret-color: rgb(61, 61, 61);"><br>
</span></font></div>
<div><span></span></div>
</body>
</html>