History

xen: privcmd: Add support for ioeventfd

Virtio guests send VIRTIO_MMIO_QUEUE_NOTIFY notification when they need to notify the backend of an update to the status of the virtqueue. The backend or another entity, polls the MMIO address for updates to know when the notification is sent. It works well if the backend does this polling by itself. But as we move towards generic backend implementations, we end up implementing this in a separate user-space program. Generally, the Virtio backends are implemented to work with the Eventfd based mechanism. In order to make such backends work with Xen, another software layer needs to do the polling and send an event via eventfd to the backend once the notification from guest is received. This results in an extra context switch. This is not a new problem in Linux though. It is present with other hypervisors like KVM, etc. as well. The generic solution implemented in the kernel for them is to provide an IOCTL call to pass the address to poll and eventfd, which lets the kernel take care of polling and raise an event on the eventfd, instead of handling this in user space (which involves an extra context switch). This patch adds similar support for xen. Inspired by existing implementations for KVM, etc.. This also copies ioreq.h header file (only struct ioreq and related macros) from Xen's source tree (Top commit 5d84f07fe6bf ("xen/pci: drop remaining uses of bool_t")).

Viresh Kumar committed 3 years ago

Commit f0d7db71 parent 9e90e584 files · +476 −6Browse files

Showing the changes to include/uapi (1 of 4 files). Show all

Unified · Split

include/uapi/xen/privcmd.h+18−0
@@ -110,6 +110,22 @@ struct privcmd_irqfd { · 109 unmodified lines
110 __u8 pad[2];110 __u8 pad[2];
111};111};
112 112
113/* For privcmd_ioeventfd::flags */
114#define PRIVCMD_IOEVENTFD_FLAG_DEASSIGN (1 << 0)
115
116struct privcmd_ioeventfd {
117 __u64 ioreq;
118 __u64 ports;
119 __u64 addr;
120 __u32 addr_len;
121 __u32 event_fd;
122 __u32 vcpus;
123 __u32 vq;
124 __u32 flags;
125 domid_t dom;
126 __u8 pad[2];
127};
128
113/*129/*
114 * @cmd: IOCTL_PRIVCMD_HYPERCALL130 * @cmd: IOCTL_PRIVCMD_HYPERCALL
115 * @arg: &privcmd_hypercall_t131 * @arg: &privcmd_hypercall_t
@@ -139,5 +155,7 @@ struct privcmd_irqfd { · 23 unmodified lines
139 _IOC(_IOC_NONE, 'P', 7, sizeof(struct privcmd_mmap_resource))155 _IOC(_IOC_NONE, 'P', 7, sizeof(struct privcmd_mmap_resource))
140#define IOCTL_PRIVCMD_IRQFD \156#define IOCTL_PRIVCMD_IRQFD \
141 _IOW('P', 8, struct privcmd_irqfd)157 _IOW('P', 8, struct privcmd_irqfd)
158#define IOCTL_PRIVCMD_IOEVENTFD \
159 _IOW('P', 9, struct privcmd_ioeventfd)
142 160
143#endif /* __LINUX_PUBLIC_PRIVCMD_H__ */161#endif /* __LINUX_PUBLIC_PRIVCMD_H__ */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t