Skip to content

Conversation

soburi
Copy link
Owner

@soburi soburi commented Sep 22, 2025

Summary

  • stash the mapped page pointer and count before clearing the chunk so they can be released outside the lock
  • clear chunk bookkeeping while the spinlock is held and only drop the releasing guard once cleanup is complete

Testing

  • not run

https://chatgpt.com/codex/tasks/task_e_68d151ea36288322b296e6c288c69e87

soburi and others added 21 commits September 15, 2025 08:28
Move macros derived from the VIRTIO specification to a shared include.
This change allows the VIRTIO standard definitions to be referenced
from outside the driver implementation.

The following definitions have also been added:

- VIRTIO_F_ANY_LAYOUT
- VIRTIO_F_VERSION_1
- VIRTIO_F_ACCESS_PLATFORM
- VIRTIO_RING_F_INDIRECT_DESC
- VIRTIO_RING_F_EVENT_IDX
- VIRTQ_AVAIL_F_NO_INTERRUPT
- VIRTQ_USED_F_NO_NOTIFY

Signed-off-by: TOKITA Hiroshi <[email protected]>
This hypercall used to obtain version of xen hypervisor

Signed-off-by: Dmytro Semenets <[email protected]>
Acked-by: Volodymyr Babchuk <[email protected]>
Acked-by: Mykola Kvach <[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).

- sysctl hypercall "get_cpu_info" provides information about physical
CPU(s).

Signed-off-by: Dmytro Semenets <[email protected]>
Acked-by: Volodymyr Babchuk <[email protected]>
Acked-by: Mykola Kvach <[email protected]>
domctl hypercall "getvcpu" provides information about domain's
virtual CPU(s).

Signed-off-by: Dmytro Semenets <[email protected]>
Acked-by: Volodymyr Babchuk <[email protected]>
Acked-by: Mykola Kvach <[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]>
Acked-by: Dmytro Firsov <[email protected]>
Document all of the public functions in the domctl API with doxygen

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

Signed-off-by: Mykyta Poturai <[email protected]>
Acked-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]>
Acked-by: Mykola Kvach <[email protected]>
Acked-by: Dmytro Firsov <[email protected]>
Reviewed-by: Grygorii Strashko <[email protected]>
(cherry picked from commit eb0ed21
 zephyr-v3.6.0-xt)
Xen event channel notification may fail during hypervisor handling,
so it will be good for user to have a possibility to check results.

Previous implementation ignored hypervisor return code, now it will be
passed to caller.

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

Signed-off-by: TOKITA Hiroshi <[email protected]>
Currently, the MIT-licensed Xen public headers have been incorporated
under the `include/zephyr/xen/public` directory.

We will migrate these files to zephyr-xenlib and use them.

The recent policy is not to include sources other than
Apache-2 in the main tree, so it is the preferred method.

Signed-off-by: TOKITA Hiroshi <[email protected]>
Replace `gnttab_get_page()`/`gnttab_put_pages(addr)` with
`gnttab_get_pages(npages)`/`gnttab_put_pages(addr, npages)`
for supporting multi-page operation.

Note: This is a breaking change, update callers accordingly.

Signed-off-by: TOKITA Hiroshi <[email protected]>
Add XENMEM_acquire_resource wrapper to map device model related buffers.
This is required for communication with the ioreq server.

- memory
  - xendom_acquire_resource:
    HYPERVISOR_memory_op(XENMEM_acquire_resource)

Signed-off-by: TOKITA Hiroshi <[email protected]>
Add SCHEDOP_poll wrapper used by Xen backends to wait on event
channels efficiently.

- sched
  - sched_poll:
    HYPERVISOR_sched_op(SCHEDOP_poll)

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

Signed-off-by: TOKITA Hiroshi <[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]>
Add HYPERVISOR_dm_op hypercall implementation for ARM64 architecture.
This hypercall is required for device model operations in Xen
virtualization environment.

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants