From: Manos Pitsidianakis <manos@pitsidianak.is>
To: Eugenio Perez Martin <eperezma@redhat.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
"Peter Hilber" <peter.hilber@oss.qualcomm.com>,
"Stefano Garzarella" <sgarzare@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Viresh Kumar" <viresh.kumar@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
rust-for-linux@vger.kernel.org,
"Jason Wang" <jasowang@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
virtualization@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC v3 2/6] rust/helpers: add virtio.c
Date: Mon, 25 May 2026 10:51:35 +0300 [thread overview]
Message-ID: <tfl1yw.godamgwg8dfs@pitsidianak.is> (raw)
In-Reply-To: <CAJaqyWexdTrXcVoxxZb+frrfnr+xYCm67GGtWajWY-ygdyJfKw@mail.gmail.com>
On Thu, 21 May 2026 12:03, Eugenio Perez Martin <eperezma@redhat.com> wrote:
>On Sun, May 10, 2026 at 3:38 PM Manos Pitsidianakis
><manos@pitsidianak.is> wrote:
>>
>> Some internal kernel virtio API functions are inline macros, so define
>> their symbols in a helper file.
>>
>> Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
>> ---
>> MAINTAINERS | 6 ++++++
>> rust/helpers/helpers.c | 1 +
>> rust/helpers/virtio.c | 37 +++++++++++++++++++++++++++++++++++++
>> 3 files changed, 44 insertions(+)
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index d1cc0e12fe1f004da89b1aa339116908f642e894..48c9c666d90b5a256ab6fae1f42508b789a0ce50 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -27930,6 +27930,12 @@ F: include/uapi/linux/virtio_*.h
>> F: net/vmw_vsock/virtio*
>> F: tools/virtio/
>>
>> +VIRTIO CORE API BINDINGS [RUST]
>> +M: Manos Pitsidianakis <manos@pitsidianak.is>
>> +L: virtualization@lists.linux.dev
>> +S: Maintained
>> +F: rust/helpers/virtio.c
>> +
>> VIRTIO CRYPTO DRIVER
>> M: Gonglei <arei.gonglei@huawei.com>
>> L: virtualization@lists.linux.dev
>> diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
>> index a3c42e51f00a0990bea81ebce6e99bb397ce7533..5dc0d2f2ee6bd2ae8e6abfe4baa247c1963967f6 100644
>> --- a/rust/helpers/helpers.c
>> +++ b/rust/helpers/helpers.c
>> @@ -61,6 +61,7 @@
>> #include "time.c"
>> #include "uaccess.c"
>> #include "usb.c"
>> +#include "virtio.c"
>> #include "vmalloc.c"
>> #include "wait.c"
>> #include "workqueue.c"
>> diff --git a/rust/helpers/virtio.c b/rust/helpers/virtio.c
>> new file mode 100644
>> index 0000000000000000000000000000000000000000..46aeeb063158823e66477777b3cd4bd1525df330
>> --- /dev/null
>> +++ b/rust/helpers/virtio.c
>> @@ -0,0 +1,37 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +
>> +#ifdef CONFIG_VIRTIO
>> +#include <linux/virtio_config.h>
>> +
>> +__rust_helper bool
>> +rust_helper_virtio_has_feature(const struct virtio_device *vdev,
>> + unsigned int fbit)
>> +{
>> + return virtio_has_feature(vdev, fbit);
>> +}
>> +__rust_helper void rust_helper_virtio_get_features(struct virtio_device *vdev,
>> + u64 *features_out)
>> +{
>> + return virtio_get_features(vdev, features_out);
>
>As a suggestion, perhaps an API that allows getting feature bits > 64,
>like VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO (65) or VIRTIO_NET_F_IPSEC (70)
>could save the need to add more functions in the future.
Yes, this will be needed indeed. I think however that as long as no
driver that uses features exists, this would be dead code so we should
not include it until it's needed.
I plan on dropping these helper bindings that have no user in my patches
in the next revisions.
>
>> +}
>> +
>> +__rust_helper int rust_helper_virtio_find_vqs(struct virtio_device *vdev,
>> + unsigned int nvqs,
>> + struct virtqueue *vqs[],
>> + struct virtqueue_info vqs_info[],
>> + struct irq_affinity *desc)
>> +{
>> + return virtio_find_vqs(vdev, nvqs, vqs, vqs_info, desc);
>> +}
>> +
>> +__rust_helper void rust_helper_virtio_device_ready(struct virtio_device *dev)
>> +{
>> + return virtio_device_ready(dev);
>> +}
>> +
>> +__rust_helper bool
>> +rust_helper_virtio_is_little_endian(struct virtio_device *vdev)
>> +{
>> + return virtio_is_little_endian(vdev);
>> +}
>> +#endif /* CONFIG_VIRTIO */
>>
>> --
>> 2.47.3
>>
>
next prev parent reply other threads:[~2026-05-25 7:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-10 13:38 [PATCH RFC v3 0/6] Add Rust virtio bindings and sample device Manos Pitsidianakis
2026-05-10 13:38 ` [PATCH RFC v3 1/6] rust/bindings: generate virtio bindings Manos Pitsidianakis
2026-05-10 13:38 ` [PATCH RFC v3 2/6] rust/helpers: add virtio.c Manos Pitsidianakis
2026-05-21 9:03 ` Eugenio Perez Martin
2026-05-25 7:51 ` Manos Pitsidianakis [this message]
2026-05-10 13:38 ` [PATCH RFC v3 3/6] rust/kernel/device: return parent at same context Manos Pitsidianakis
2026-05-10 13:38 ` [PATCH RFC v3 4/6] rust: add virtio module Manos Pitsidianakis
2026-05-10 13:38 ` [PATCH RFC v3 5/6] rust: impl interruptible waits for Completion Manos Pitsidianakis
2026-05-10 13:38 ` [PATCH RFC v3 6/6] samples/rust: Add sample virtio-rtc driver [WIP] Manos Pitsidianakis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tfl1yw.godamgwg8dfs@pitsidianak.is \
--to=manos@pitsidianak.is \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=eperezma@redhat.com \
--cc=gary@garyguo.net \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=manos.pitsidianakis@linaro.org \
--cc=mst@redhat.com \
--cc=ojeda@kernel.org \
--cc=peter.hilber@oss.qualcomm.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=sgarzare@redhat.com \
--cc=stefanha@redhat.com \
--cc=tmgross@umich.edu \
--cc=viresh.kumar@linaro.org \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox