Skip to content

Conversation

@soburi
Copy link
Member

@soburi soburi commented Jun 13, 2025

This PR introduces the VHost driver framework for Zephyr, enabling VIRTIO backend implementations with initial support for Xen hypervisor environments.

This means we can use(create) Zephyr as VIRTIO devices in a Xen (and potentially other hypervisors).

VHost Driver Framework

Standard VHost API: Unified interface for VirtIO backend implementations
vringh Integration: Host-side VirtIO ring handling based on Linux kernel design

Xen MMIO VIRTIO Backend

Implementing VIRTIO-MMIO in a Xen environment using the VHost driver framework

Enhanced Xen Infrastructure

Some enhancements of Xen functions

XenStore Integration: Key-value store access for domain configuration

Add more hypercall wrapper: DM-op, scheduler, ...

note:
This pr needs #91643 finished.

@github-actions
Copy link

github-actions bot commented Jun 13, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
zephyr-xenlib 🆕 N/A (Added) soburi/zephyr-xenlib@xs-client N/A

DNM label due to: 1 added project

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@soburi soburi force-pushed the xen-virtio-backend branch 6 times, most recently from 9451269 to 144315f Compare June 15, 2025 23:30
@soburi soburi changed the title drivers: virtio: Add Xen virtio-mmio backend drivers: virtio: Add Xen VIRTIO-MMIO backend Jun 17, 2025
@soburi soburi force-pushed the xen-virtio-backend branch from 144315f to 91ba84f Compare June 18, 2025 23:13
@soburi soburi force-pushed the xen-virtio-backend branch 3 times, most recently from 4741c1a to 141d60f Compare July 17, 2025 10:53
@soburi soburi force-pushed the xen-virtio-backend branch 9 times, most recently from 21b1787 to 98d1f30 Compare July 27, 2025 07:40
@soburi soburi added the DNM This PR should not be merged (Do Not Merge) label Jul 27, 2025
@soburi soburi force-pushed the xen-virtio-backend branch 2 times, most recently from d64559b to 986ef95 Compare July 29, 2025 13:35
@firscity
Copy link
Contributor

Generic comment regarding this PR - a see a lot of force-pushes and no much replies to previous comment. Thus, I don't understand if I should re-review it, if you decided to rework it - please mark it as draft (unfortunately, it will not prevent e-mail storm, but at least I will be sure, that no re-review needed).

dsemenets and others added 13 commits October 13, 2025 23:57
Xen API contains hypercall, which allows domains to identify Xen
version, that is currently used on the system. It can be used to check
if current version is supported by Zephyr or to change behavior of the
drivers or services.

Signed-off-by: Dmytro Semenets <[email protected]>
Signed-off-by: Dmytro Firsov <[email protected]>
This hypercall can be used get some information about physical machine
and running guests:

- sysctl hypercall "xen_sysctl_getphysinfo" allows read information about
physical machine: number CPUs, memory sizes, hardware capabilities, etc.

- sysctl hypercall "xen_sysctl_getdomaininfolist" returns array of domain
info structures that provide information about particular domain(s).

Signed-off-by: Dmytro Semenets <[email protected]>
Signed-off-by: Mykyta Poturai <[email protected]>
Signed-off-by: Dmytro Firsov <[email protected]>
Add the XEN_DOMCTL_getvcpuinfo domain control call to allow Domain-0 to
query information about a domain's virtual CPUs. This can be used by
management tools and services for gathering statistics and monitoring
the current status of vCPUs.

Signed-off-by: Dmytro Semenets <[email protected]>
Signed-off-by: Dmytro Firsov <[email protected]>
The size is passed in bytes, not in megabytes. So rename the parameter
to avoid confusion.

Signed-off-by: Mykyta Poturai <[email protected]>
Signed-off-by: Dmytro Firsov <[email protected]>
Document all of the public functions in the domctl API with doxygen

Signed-off-by: Mykyta Poturai <[email protected]>
Signed-off-by: Dmytro Firsov <[email protected]>
If 0 is passed as domain id to the Xen createdomain hypercall, it will
allocate a new domain id and return it via the domctl structure.
Allow callers to access this new domain id via a pointer arg.
This will allow to create domains without explicitly specifying the
domain id for them.

Signed-off-by: Mykyta Poturai <[email protected]>
Signed-off-by: Dmytro Firsov <[email protected]>
Add a new Kconfig option CONFIG_XEN_DOMCTL_INTERFACE_VERSION that allows
to change the version of the Domctl interface used by Zephyr to issue
domctl hypercalls. Add compile-time checks to enable or disable certain
Domctl operations based on the selected Domctl interface version.
For now versions 0x15, 0x16, and 0x17 are supported.

Also it required to correctly guard domctl call that were not supported
prior to specified version.

Signed-off-by: Mykyta Poturai <[email protected]>
Signed-off-by: Dmytro Firsov <[email protected]>
Add a new Kconfig option CONFIG_XEN_SYSCTL_INTERFACE_VERSION that allows
to change the version of the Sysctl interface used by Zephyr to issue
sysctl hypercalls.
For now versions 0x15 is supported.

Signed-off-by: Mykyta Poturai <[email protected]>
Signed-off-by: Dmytro Firsov <[email protected]>
Add wrappers for following XEN_DMOP_* hypercalls.
These enables Xen device model control path:
dm_op provides operations to create/manage the ioreq server
so guest MMIO accesses are trapped and handled by the hypervisor.
These are guarded by CONFIG_XEN_DMOP.

- dmop
  - dmop_create_ioreq_server
    XEN_DMOP_create_ioreq_server
  - dmop_map_io_range_to_ioreq_server
    XEN_DMOP_map_io_range_to_ioreq_server
  - dmop_set_ioreq_server_state
    XEN_DMOP_set_ioreq_server_state
  - dmop_nr_vcpus
    XEN_DMOP_nr_vcpus
  - dmop_set_irq_level:
    XEN_DMOP_set_irq_level

Signed-off-by: TOKITA Hiroshi <[email protected]>
Import `zephyr-xenlib` module.
That contains xen public headers.

Signed-off-by: TOKITA Hiroshi <[email protected]>
This introduces the vhost driver framework, providing standard APIs
for VIRTIO backend implementations in Zephyr. Includes vringh utility
for host-side VIRTIO ring processing based on Linux kernel
implementation.

Signed-off-by: TOKITA Hiroshi <[email protected]>
Implements VirtIO backend over Xen MMIO interface

Signed-off-by: TOKITA Hiroshi <[email protected]>
Add sample application demonstrating vhost driver usage for
VIRTIO backend implementations. Includes basic setup and
configuration examples for Xen MMIO VirtIO backend.

Signed-off-by: TOKITA Hiroshi <[email protected]>
@sonarqubecloud
Copy link

@soburi
Copy link
Member Author

soburi commented Oct 13, 2025

@firscity

FYI regarding xenstore (for Zephyr Dom0): after some discussions we decided to move it to separate project instead of having it as a driver (and potentially move it to userspace) - please check zephyr-xenlib/xenstore-srv

The xenstore client functionality has been moved to zephyr-xenlib.
Please review xen-troops/zephyr-xenlib#103.

Generic comment regarding this PR - a see a lot of force-pushes and no much replies to previous comment. Thus, I don't understand if I should re-review it, if you decided to rework it - please mark it as draft (unfortunately, it will not prevent e-mail storm, but at least I will be sure, that no re-review needed).

In Zephyr, we rebase every time there's a conflict,
so this is a common occurrence.
The PRs have already been split and reviewed individually,
so I've updated each one to reflect that.

#95525, #95556, and #96727 have not yet been merged, but once they are merged, there will only be the last three primary commits.

We apologize for the inconvenience and appreciate your continued support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants