linux/drivers/hv/mshv_eventfd.h
Nuno Das Neves 621191d709 Drivers: hv: Introduce mshv_root module to expose /dev/mshv to VMMs
Provide a set of IOCTLs for creating and managing child partitions when
running as root partition on Hyper-V. The new driver is enabled via
CONFIG_MSHV_ROOT.

A brief overview of the interface:

MSHV_CREATE_PARTITION is the entry point, returning a file descriptor
representing a child partition. IOCTLs on this fd can be used to map
memory, create VPs, etc.

Creating a VP returns another file descriptor representing that VP which
in turn has another set of corresponding IOCTLs for running the VP,
getting/setting state, etc.

MSHV_ROOT_HVCALL is a generic "passthrough" hypercall IOCTL which can be
used for a number of partition or VP hypercalls. This is for hypercalls
that do not affect any state in the kernel driver, such as getting and
setting VP registers and partition properties, translating addresses,
etc. It is "passthrough" because the binary input and output for the
hypercall is only interpreted by the VMM - the kernel driver does
nothing but insert the VP and partition id where necessary (which are
always in the same place), and execute the hypercall.

Co-developed-by: Anirudh Rayabharam <anrayabh@linux.microsoft.com>
Signed-off-by: Anirudh Rayabharam <anrayabh@linux.microsoft.com>
Co-developed-by: Jinank Jain <jinankjain@microsoft.com>
Signed-off-by: Jinank Jain <jinankjain@microsoft.com>
Co-developed-by: Mukesh Rathor <mrathor@linux.microsoft.com>
Signed-off-by: Mukesh Rathor <mrathor@linux.microsoft.com>
Co-developed-by: Muminul Islam <muislam@microsoft.com>
Signed-off-by: Muminul Islam <muislam@microsoft.com>
Co-developed-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Co-developed-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
Co-developed-by: Wei Liu <wei.liu@kernel.org>
Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
Reviewed-by: Roman Kisel <romank@linux.microsoft.com>
Link: https://lore.kernel.org/r/1741980536-3865-11-git-send-email-nunodasneves@linux.microsoft.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Message-ID: <1741980536-3865-11-git-send-email-nunodasneves@linux.microsoft.com>
2025-03-21 18:24:22 +00:00

71 lines
2.2 KiB
C

/* SPDX-License-Identifier: GPL-2.0-only */
/*
* irqfd: Allows an fd to be used to inject an interrupt to the guest.
* ioeventfd: Allow an fd to be used to receive a signal from the guest.
* All credit goes to kvm developers.
*/
#ifndef __LINUX_MSHV_EVENTFD_H
#define __LINUX_MSHV_EVENTFD_H
#include <linux/poll.h>
#include "mshv.h"
#include "mshv_root.h"
/* struct to contain list of irqfds sharing an irq. Updates are protected by
* partition.irqfds.resampler_lock
*/
struct mshv_irqfd_resampler {
struct mshv_partition *rsmplr_partn;
struct hlist_head rsmplr_irqfd_list;
struct mshv_irq_ack_notifier rsmplr_notifier;
struct hlist_node rsmplr_hnode;
};
struct mshv_irqfd {
struct mshv_partition *irqfd_partn;
struct eventfd_ctx *irqfd_eventfd_ctx;
struct mshv_guest_irq_ent irqfd_girq_ent;
seqcount_spinlock_t irqfd_irqe_sc;
u32 irqfd_irqnum;
struct mshv_lapic_irq irqfd_lapic_irq;
struct hlist_node irqfd_hnode;
poll_table irqfd_polltbl;
wait_queue_head_t *irqfd_wqh;
wait_queue_entry_t irqfd_wait;
struct work_struct irqfd_shutdown;
struct mshv_irqfd_resampler *irqfd_resampler;
struct eventfd_ctx *irqfd_resamplefd;
struct hlist_node irqfd_resampler_hnode;
};
void mshv_eventfd_init(struct mshv_partition *partition);
void mshv_eventfd_release(struct mshv_partition *partition);
void mshv_register_irq_ack_notifier(struct mshv_partition *partition,
struct mshv_irq_ack_notifier *mian);
void mshv_unregister_irq_ack_notifier(struct mshv_partition *partition,
struct mshv_irq_ack_notifier *mian);
bool mshv_notify_acked_gsi(struct mshv_partition *partition, int gsi);
int mshv_set_unset_irqfd(struct mshv_partition *partition,
struct mshv_user_irqfd *args);
int mshv_irqfd_wq_init(void);
void mshv_irqfd_wq_cleanup(void);
struct mshv_ioeventfd {
struct hlist_node iovntfd_hnode;
u64 iovntfd_addr;
int iovntfd_length;
struct eventfd_ctx *iovntfd_eventfd;
u64 iovntfd_datamatch;
int iovntfd_doorbell_id;
bool iovntfd_wildcard;
};
int mshv_set_unset_ioeventfd(struct mshv_partition *pt,
struct mshv_user_ioeventfd *args);
#endif /* __LINUX_MSHV_EVENTFD_H */