<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/vhost/vringh.c, branch linux-5.18.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.18.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.18.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2022-06-14T16:45:15Z</updated>
<entry>
<title>vringh: Fix loop descriptors check in the indirect cases</title>
<updated>2022-06-14T16:45:15Z</updated>
<author>
<name>Xie Yongji</name>
</author>
<published>2022-05-05T10:09:10Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8df021ccdf956192e7e9cb4325f47ad26dba2cae'/>
<id>urn:sha1:8df021ccdf956192e7e9cb4325f47ad26dba2cae</id>
<content type='text'>
[ Upstream commit dbd29e0752286af74243cf891accf472b2f3edd8 ]

We should use size of descriptor chain to test loop condition
in the indirect case. And another statistical count is also introduced
for indirect descriptors to avoid conflict with the statistical count
of direct descriptors.

Fixes: f87d0fbb5798 ("vringh: host-side implementation of virtio rings.")
Signed-off-by: Xie Yongji &lt;xieyongji@bytedance.com&gt;
Signed-off-by: Fam Zheng &lt;fam.zheng@bytedance.com&gt;
Message-Id: &lt;20220505100910.137-1-xieyongji@bytedance.com&gt;
Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
Acked-by: Jason Wang &lt;jasowang@redhat.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>vringh: Use wiov-&gt;used to check for read/write desc order</title>
<updated>2021-08-11T10:44:24Z</updated>
<author>
<name>Neeraj Upadhyay</name>
</author>
<published>2021-06-25T03:25:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e74cfa91f42c50f7f649b0eca46aa049754ccdbd'/>
<id>urn:sha1:e74cfa91f42c50f7f649b0eca46aa049754ccdbd</id>
<content type='text'>
As __vringh_iov() traverses a descriptor chain, it populates
each descriptor entry into either read or write vring iov
and increments that iov's -&gt;used member. So, as we iterate
over a descriptor chain, at any point, (riov/wriov)-&gt;used
value gives the number of descriptor enteries available,
which are to be read or written by the device. As all read
iovs must precede the write iovs, wiov-&gt;used should be zero
when we are traversing a read descriptor. Current code checks
for wiov-&gt;i, to figure out whether any previous entry in the
current descriptor chain was a write descriptor. However,
iov-&gt;i is only incremented, when these vring iovs are consumed,
at a later point, and remain 0 in __vringh_iov(). So, correct
the check for read and write descriptor order, to use
wiov-&gt;used.

Acked-by: Jason Wang &lt;jasowang@redhat.com&gt;
Reviewed-by: Stefano Garzarella &lt;sgarzare@redhat.com&gt;
Signed-off-by: Neeraj Upadhyay &lt;neeraju@codeaurora.org&gt;
Link: https://lore.kernel.org/r/1624591502-4827-1-git-send-email-neeraju@codeaurora.org
Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
</content>
</entry>
<entry>
<title>vringh: implement vringh_kiov_advance()</title>
<updated>2021-05-03T08:55:53Z</updated>
<author>
<name>Stefano Garzarella</name>
</author>
<published>2021-03-15T16:34:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b8c06ad4d67db56ed6bdfb685c134da74e92a2c7'/>
<id>urn:sha1:b8c06ad4d67db56ed6bdfb685c134da74e92a2c7</id>
<content type='text'>
In some cases, it may be useful to provide a way to skip a number
of bytes in a vringh_kiov.

Let's implement vringh_kiov_advance() for this purpose, reusing the
code from vringh_iov_xfer().
We replace that code calling the new vringh_kiov_advance().

Acked-by: Jason Wang &lt;jasowang@redhat.com&gt;
Signed-off-by: Stefano Garzarella &lt;sgarzare@redhat.com&gt;
Link: https://lore.kernel.org/r/20210315163450.254396-6-sgarzare@redhat.com
Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
</content>
</entry>
<entry>
<title>vringh: explain more about cleaning riov and wiov</title>
<updated>2021-05-03T08:55:53Z</updated>
<author>
<name>Stefano Garzarella</name>
</author>
<published>2021-03-15T16:34:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=69c13c58bd10f036d6e697e664948952e61acfb1'/>
<id>urn:sha1:69c13c58bd10f036d6e697e664948952e61acfb1</id>
<content type='text'>
riov and wiov can be reused with subsequent calls of vringh_getdesc_*().

Let's add a paragraph in the documentation of these functions to better
explain when riov and wiov need to be cleaned up.

Acked-by: Jason Wang &lt;jasowang@redhat.com&gt;
Signed-off-by: Stefano Garzarella &lt;sgarzare@redhat.com&gt;
Link: https://lore.kernel.org/r/20210315163450.254396-5-sgarzare@redhat.com
Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
</content>
</entry>
<entry>
<title>vringh: reset kiov 'consumed' field in __vringh_iov()</title>
<updated>2021-05-03T08:55:53Z</updated>
<author>
<name>Stefano Garzarella</name>
</author>
<published>2021-03-15T16:34:39Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bbc2c372a83d74d5499ad21d0ade2b71f5bde620'/>
<id>urn:sha1:bbc2c372a83d74d5499ad21d0ade2b71f5bde620</id>
<content type='text'>
__vringh_iov() overwrites the contents of riov and wiov, in fact it
resets the 'i' and 'used' fields, but also the 'consumed' field should
be reset to avoid an inconsistent state.

Acked-by: Jason Wang &lt;jasowang@redhat.com&gt;
Signed-off-by: Stefano Garzarella &lt;sgarzare@redhat.com&gt;
Link: https://lore.kernel.org/r/20210315163450.254396-4-sgarzare@redhat.com
Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
</content>
</entry>
<entry>
<title>vringh: add 'iotlb_lock' to synchronize iotlb accesses</title>
<updated>2021-05-03T08:55:52Z</updated>
<author>
<name>Stefano Garzarella</name>
</author>
<published>2021-03-15T16:34:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f53d9910d009bc015b42d88114e2d86a93b0e6b7'/>
<id>urn:sha1:f53d9910d009bc015b42d88114e2d86a93b0e6b7</id>
<content type='text'>
Usually iotlb accesses are synchronized with a spinlock.
Let's request it as a new parameter in vringh_set_iotlb() and
hold it when we navigate the iotlb in iotlb_translate() to avoid
race conditions with any new additions/deletions of ranges from
the ioltb.

Acked-by: Jason Wang &lt;jasowang@redhat.com&gt;
Signed-off-by: Stefano Garzarella &lt;sgarzare@redhat.com&gt;
Link: https://lore.kernel.org/r/20210315163450.254396-3-sgarzare@redhat.com
Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
</content>
</entry>
<entry>
<title>vhost: vringh: use krealloc_array()</title>
<updated>2020-12-15T20:13:37Z</updated>
<author>
<name>Bartosz Golaszewski</name>
</author>
<published>2020-12-15T03:04:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3a99974872ccb2f625c68a7444e7575f1c7fd06d'/>
<id>urn:sha1:3a99974872ccb2f625c68a7444e7575f1c7fd06d</id>
<content type='text'>
Use the helper that checks for overflows internally instead of manually
calculating the size of the new array.

Link: https://lkml.kernel.org/r/20201109110654.12547-5-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski &lt;bgolaszewski@baylibre.com&gt;
Acked-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
Cc: Alexander Shishkin &lt;alexander.shishkin@linux.intel.com&gt;
Cc: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Cc: Borislav Petkov &lt;bp@alien8.de&gt;
Cc: Borislav Petkov &lt;bp@suse.de&gt;
Cc: Christian Knig &lt;christian.koenig@amd.com&gt;
Cc: Christoph Lameter &lt;cl@linux.com&gt;
Cc: Daniel Vetter &lt;daniel@ffwll.ch&gt;
Cc: Daniel Vetter &lt;daniel.vetter@ffwll.ch&gt;
Cc: David Airlie &lt;airlied@linux.ie&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Cc: Gustavo Padovan &lt;gustavo@padovan.org&gt;
Cc: James Morse &lt;james.morse@arm.com&gt;
Cc: Jaroslav Kysela &lt;perex@perex.cz&gt;
Cc: Jason Wang &lt;jasowang@redhat.com&gt;
Cc: Joonsoo Kim &lt;iamjoonsoo.kim@lge.com&gt;
Cc: Linus Walleij &lt;linus.walleij@linaro.org&gt;
Cc: Maarten Lankhorst &lt;maarten.lankhorst@linux.intel.com&gt;
Cc: Mauro Carvalho Chehab &lt;mchehab@kernel.org&gt;
Cc: Maxime Ripard &lt;mripard@kernel.org&gt;
Cc: Pekka Enberg &lt;penberg@kernel.org&gt;
Cc: Robert Richter &lt;rric@kernel.org&gt;
Cc: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Cc: Takashi Iwai &lt;tiwai@suse.com&gt;
Cc: Takashi Iwai &lt;tiwai@suse.de&gt;
Cc: Thomas Zimmermann &lt;tzimmermann@suse.de&gt;
Cc: Tony Luck &lt;tony.luck@intel.com&gt;
Cc: Vlastimil Babka &lt;vbabka@suse.cz&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>vringh: fix vringh_iov_push_*() documentation</title>
<updated>2020-11-25T09:22:48Z</updated>
<author>
<name>Stefano Garzarella</name>
</author>
<published>2020-11-16T16:16:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8009b0f4ab3151f3b8c1675ceb0f9151f09dddaa'/>
<id>urn:sha1:8009b0f4ab3151f3b8c1675ceb0f9151f09dddaa</id>
<content type='text'>
vringh_iov_push_*() functions don't have 'dst' parameter, but have
the 'src' parameter.

Replace 'dst' description with 'src' description.

Signed-off-by: Stefano Garzarella &lt;sgarzare@redhat.com&gt;
Link: https://lore.kernel.org/r/20201116161653.102904-1-sgarzare@redhat.com
Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
</content>
</entry>
<entry>
<title>vringh: fix __vringh_iov() when riov and wiov are different</title>
<updated>2020-10-21T14:38:45Z</updated>
<author>
<name>Stefano Garzarella</name>
</author>
<published>2020-10-08T20:42:56Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5745bcfbbf89b158416075374254d3c013488f21'/>
<id>urn:sha1:5745bcfbbf89b158416075374254d3c013488f21</id>
<content type='text'>
If riov and wiov are both defined and they point to different
objects, only riov is initialized. If the wiov is not initialized
by the caller, the function fails returning -EINVAL and printing
"Readable desc 0x... after writable" error message.

This issue happens when descriptors have both readable and writable
buffers (eg. virtio-blk devices has virtio_blk_outhdr in the readable
buffer and status as last byte of writable buffer) and we call
__vringh_iov() to get both type of buffers in two different iovecs.

Let's replace the 'else if' clause with 'if' to initialize both
riov and wiov if they are not NULL.

As checkpatch pointed out, we also avoid crashing the kernel
when riov and wiov are both NULL, replacing BUG() with WARN_ON()
and returning -EINVAL.

Fixes: f87d0fbb5798 ("vringh: host-side implementation of virtio rings.")
Cc: stable@vger.kernel.org
Signed-off-by: Stefano Garzarella &lt;sgarzare@redhat.com&gt;
Link: https://lore.kernel.org/r/20201008204256.162292-1-sgarzare@redhat.com
Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
</content>
</entry>
<entry>
<title>virtio: force spec specified alignment on types</title>
<updated>2020-06-02T06:45:13Z</updated>
<author>
<name>Michael S. Tsirkin</name>
</author>
<published>2020-04-06T12:42:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a865e420b9561235851c3f5d483c82ef389d29bd'/>
<id>urn:sha1:a865e420b9561235851c3f5d483c82ef389d29bd</id>
<content type='text'>
The ring element addresses are passed between components with different
alignments assumptions. Thus, if guest/userspace selects a pointer and
host then gets and dereferences it, we might need to decrease the
compiler-selected alignment to prevent compiler on the host from
assuming pointer is aligned.

This actually triggers on ARM with -mabi=apcs-gnu - which is a
deprecated configuration, but it seems safer to handle this
generally.

Note that userspace that allocates the memory is actually OK and does
not need to be fixed, but userspace that gets it from guest or another
process does need to be fixed. The later doesn't generally talk to the
kernel so while it might be buggy it's not talking to the kernel in the
buggy way - it's just using the header in the buggy way - so fixing
header and asking userspace to recompile is the best we can do.

I verified that the produced kernel binary on x86 is exactly identical
before and after the change.

Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
Acked-by: Jason Wang &lt;jasowang@redhat.com&gt;
</content>
</entry>
</feed>
