drivers/hv/mshv_root.h

Source file repositories/reference/linux-study-clean/drivers/hv/mshv_root.h

File Facts

System
Linux kernel
Corpus path
drivers/hv/mshv_root.h
Extension
.h
Size
12745 bytes
Lines
382
Domain
Driver Families
Bucket
drivers/hv
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct mshv_vp {
	u32 vp_index;
	struct mshv_partition *vp_partition;
	struct mutex vp_mutex;
	struct hv_vp_register_page *vp_register_page;
	struct hv_message *vp_intercept_msg_page;
	void *vp_ghcb_page;
	struct hv_stats_page *vp_stats_pages[2];
	struct {
		atomic64_t vp_signaled_count;
		struct {
			u64 intercept_suspend: 1;
			u64 root_sched_blocked: 1; /* root scheduler only */
			u64 root_sched_dispatched: 1; /* root scheduler only */
			u64 reserved: 61;
		} flags;
		unsigned int kicked_by_hv;
		wait_queue_head_t vp_suspend_queue;
	} run;
#if IS_ENABLED(CONFIG_DEBUG_FS)
	struct dentry *vp_stats_dentry;
#endif
};

#define vp_fmt(fmt) "p%lluvp%u: " fmt
#define vp_devprintk(level, v, fmt, ...) \
do { \
	const struct mshv_vp *__vp = (v); \
	const struct mshv_partition *__pt = __vp->vp_partition; \
	dev_##level(__pt->pt_module_dev, vp_fmt(fmt), __pt->pt_id, \
		    __vp->vp_index, ##__VA_ARGS__); \
} while (0)
#define vp_emerg(v, fmt, ...)	vp_devprintk(emerg, v, fmt, ##__VA_ARGS__)
#define vp_crit(v, fmt, ...)	vp_devprintk(crit, v, fmt, ##__VA_ARGS__)
#define vp_alert(v, fmt, ...)	vp_devprintk(alert, v, fmt, ##__VA_ARGS__)
#define vp_err(v, fmt, ...)	vp_devprintk(err, v, fmt, ##__VA_ARGS__)
#define vp_warn(v, fmt, ...)	vp_devprintk(warn, v, fmt, ##__VA_ARGS__)
#define vp_notice(v, fmt, ...)	vp_devprintk(notice, v, fmt, ##__VA_ARGS__)
#define vp_info(v, fmt, ...)	vp_devprintk(info, v, fmt, ##__VA_ARGS__)
#define vp_dbg(v, fmt, ...)	vp_devprintk(dbg, v, fmt, ##__VA_ARGS__)

enum mshv_region_type {
	MSHV_REGION_TYPE_MEM_PINNED,
	MSHV_REGION_TYPE_MEM_MOVABLE,
	MSHV_REGION_TYPE_MMIO
};

struct mshv_mem_region {
	struct hlist_node hnode;
	struct kref mreg_refcount;
	u64 nr_pages;
	u64 start_gfn;
	u64 start_uaddr;
	u32 hv_map_flags;
	struct mshv_partition *partition;
	enum mshv_region_type mreg_type;
	struct mmu_interval_notifier mreg_mni;
	struct mutex mreg_mutex;	/* protects region pages remapping */
	struct page *mreg_pages[];
};

struct mshv_irq_ack_notifier {
	struct hlist_node link;
	unsigned int irq_ack_gsi;
	void (*irq_acked)(struct mshv_irq_ack_notifier *mian);
};

struct mshv_partition {
	struct device *pt_module_dev;

	struct hlist_node pt_hnode;
	u64 pt_id;
	refcount_t pt_ref_count;
	struct mutex pt_mutex;

	spinlock_t pt_mem_regions_lock;
	struct hlist_head pt_mem_regions; // not ordered

	u32 pt_vp_count;
	struct mshv_vp *pt_vp_array[MSHV_MAX_VPS];

	struct mutex pt_irq_lock;
	struct srcu_struct pt_irq_srcu;
	struct hlist_head irq_ack_notifier_list;

	struct hlist_head pt_devices;

	/*
	 * MSHV does not support more than one async hypercall in flight
	 * for a single partition. Thus, it is okay to define per partition

Annotation

Implementation Notes