|
| 1 | +From a682394c7208685371139773b0aa239b24e23970 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Charalampos Mainas < [email protected]> |
| 3 | +Date: Wed, 7 Feb 2024 19:48:43 +0200 |
| 4 | +Subject: [PATCH] Export APIs for kvm_ioeventfd |
| 5 | + |
| 6 | +Hedge's virtio implementation uses ioeventfd. As a result, we need to |
| 7 | +export the kvm_ioeventfd related functions to register the eventfd in a |
| 8 | +VM. Moreover, we need to create a new eventfd and therefore we need the |
| 9 | +do_eventfd function from fs/eventfd.c |
| 10 | + |
| 11 | +Signed-off-by: Matias Ezequiel Vara Larsen < [email protected]> |
| 12 | +Signed-off-by: Charalampos Mainas < [email protected]> |
| 13 | +--- |
| 14 | + fs/eventfd.c | 6 ++++++ |
| 15 | + include/linux/eventfd.h | 1 + |
| 16 | + include/linux/kvm_host.h | 1 + |
| 17 | + virt/kvm/eventfd.c | 6 ++++++ |
| 18 | + 4 files changed, 14 insertions(+) |
| 19 | + |
| 20 | +diff --git a/fs/eventfd.c b/fs/eventfd.c |
| 21 | +index 78e41c7c3..ac664a525 100644 |
| 22 | +--- a/fs/eventfd.c |
| 23 | ++++ b/fs/eventfd.c |
| 24 | +@@ -433,6 +433,12 @@ static int do_eventfd(unsigned int count, int flags) |
| 25 | + return fd; |
| 26 | + } |
| 27 | + |
| 28 | ++int hedge_eventfd(unsigned int count, int flags) |
| 29 | ++{ |
| 30 | ++ return do_eventfd(count, flags); |
| 31 | ++} |
| 32 | ++EXPORT_SYMBOL(hedge_eventfd); |
| 33 | ++ |
| 34 | + SYSCALL_DEFINE2(eventfd2, unsigned int, count, int, flags) |
| 35 | + { |
| 36 | + return do_eventfd(count, flags); |
| 37 | +diff --git a/include/linux/eventfd.h b/include/linux/eventfd.h |
| 38 | +index dc4fd8a66..af40bbfe7 100644 |
| 39 | +--- a/include/linux/eventfd.h |
| 40 | ++++ b/include/linux/eventfd.h |
| 41 | +@@ -39,6 +39,7 @@ struct file *eventfd_fget(int fd); |
| 42 | + struct eventfd_ctx *eventfd_ctx_fdget(int fd); |
| 43 | + struct eventfd_ctx *eventfd_ctx_fileget(struct file *file); |
| 44 | + __u64 eventfd_signal(struct eventfd_ctx *ctx, __u64 n); |
| 45 | ++int hedge_eventfd(unsigned int count, int flags); |
| 46 | + int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx, wait_queue_entry_t *wait, |
| 47 | + __u64 *cnt); |
| 48 | + |
| 49 | +diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h |
| 50 | +index 06cff0c5b..d590d6ee9 100644 |
| 51 | +--- a/include/linux/kvm_host.h |
| 52 | ++++ b/include/linux/kvm_host.h |
| 53 | +@@ -1442,4 +1442,5 @@ int hedge_kvm_vm_ioctl_set_memory_region(struct kvm *kvm, |
| 54 | + struct kvm_userspace_memory_region *mem); |
| 55 | + int hedge_kvm_arch_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_event, |
| 56 | + bool line_status); |
| 57 | ++int hedge_kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args); |
| 58 | + #endif |
| 59 | +diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c |
| 60 | +index 67b6fc153..39a0e7fab 100644 |
| 61 | +--- a/virt/kvm/eventfd.c |
| 62 | ++++ b/virt/kvm/eventfd.c |
| 63 | +@@ -960,3 +960,9 @@ kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) |
| 64 | + |
| 65 | + return kvm_assign_ioeventfd(kvm, args); |
| 66 | + } |
| 67 | ++ |
| 68 | ++int hedge_kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) |
| 69 | ++{ |
| 70 | ++ return kvm_ioeventfd(kvm, args); |
| 71 | ++} |
| 72 | ++EXPORT_SYMBOL(hedge_kvm_ioeventfd); |
| 73 | +-- |
| 74 | +2.43.0 |
| 75 | + |
0 commit comments