History

Drivers: hv: Introduce mshv_vtl driver

Provide an interface for Virtual Machine Monitor like OpenVMM and its use as OpenHCL paravisor to control VTL0 (Virtual trust Level). Expose devices and support IOCTLs for features like VTL creation, VTL0 memory management, context switch, making hypercalls, mapping VTL0 address space to VTL2 userspace, getting new VMBus messages and channel events in VTL2 etc.

Naman Jain committed 1 year ago

Commit 7bfe3b81 parent cffe9f511 files · +1861 −3Browse files

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

Unified · Split

include/uapi/linux/mshv.h+80−0
@@ -322,4 +322,84 @@ struct mshv_get_set_vp_state { · 321 unmodified lines
322 * #define MSHV_ROOT_HVCALL _IOWR(MSHV_IOCTL, 0x07, struct mshv_root_hvcall)322 * #define MSHV_ROOT_HVCALL _IOWR(MSHV_IOCTL, 0x07, struct mshv_root_hvcall)
323 */323 */
324 324
325/* Structure definitions, macros and IOCTLs for mshv_vtl */
326
327#define MSHV_CAP_CORE_API_STABLE 0x0
328#define MSHV_CAP_REGISTER_PAGE 0x1
329#define MSHV_CAP_VTL_RETURN_ACTION 0x2
330#define MSHV_CAP_DR6_SHARED 0x3
331#define MSHV_MAX_RUN_MSG_SIZE 256
332
333struct mshv_vp_registers {
334 __u32 count; /* supports only 1 register at a time */
335 __u32 reserved; /* Reserved for alignment or future use */
336 __u64 regs_ptr; /* pointer to struct hv_register_assoc */
337};
338
339struct mshv_vtl_set_eventfd {
340 __s32 fd;
341 __u32 flag;
342};
343
344struct mshv_vtl_signal_event {
345 __u32 connection_id;
346 __u32 flag;
347};
348
349struct mshv_vtl_sint_post_msg {
350 __u64 message_type;
351 __u32 connection_id;
352 __u32 payload_size; /* Must not exceed HV_MESSAGE_PAYLOAD_BYTE_COUNT */
353 __u64 payload_ptr; /* pointer to message payload (bytes) */
354};
355
356struct mshv_vtl_ram_disposition {
357 __u64 start_pfn;
358 __u64 last_pfn;
359};
360
361struct mshv_vtl_set_poll_file {
362 __u32 cpu;
363 __u32 fd;
364};
365
366struct mshv_vtl_hvcall_setup {
367 __u64 bitmap_array_size; /* stores number of bytes */
368 __u64 allow_bitmap_ptr;
369};
370
371struct mshv_vtl_hvcall {
372 __u64 control; /* Hypercall control code */
373 __u64 input_size; /* Size of the input data */
374 __u64 input_ptr; /* Pointer to the input struct */
375 __u64 status; /* Status of the hypercall (output) */
376 __u64 output_size; /* Size of the output data */
377 __u64 output_ptr; /* Pointer to the output struct */
378};
379
380struct mshv_sint_mask {
381 __u8 mask;
382 __u8 reserved[7];
383};
384
385/* /dev/mshv device IOCTL */
386#define MSHV_CHECK_EXTENSION _IOW(MSHV_IOCTL, 0x00, __u32)
387
388/* vtl device */
389#define MSHV_CREATE_VTL _IOR(MSHV_IOCTL, 0x1D, char)
390#define MSHV_ADD_VTL0_MEMORY _IOW(MSHV_IOCTL, 0x21, struct mshv_vtl_ram_disposition)
391#define MSHV_SET_POLL_FILE _IOW(MSHV_IOCTL, 0x25, struct mshv_vtl_set_poll_file)
392#define MSHV_RETURN_TO_LOWER_VTL _IO(MSHV_IOCTL, 0x27)
393#define MSHV_GET_VP_REGISTERS _IOWR(MSHV_IOCTL, 0x05, struct mshv_vp_registers)
394#define MSHV_SET_VP_REGISTERS _IOW(MSHV_IOCTL, 0x06, struct mshv_vp_registers)
395
396/* VMBus device IOCTLs */
397#define MSHV_SINT_SIGNAL_EVENT _IOW(MSHV_IOCTL, 0x22, struct mshv_vtl_signal_event)
398#define MSHV_SINT_POST_MESSAGE _IOW(MSHV_IOCTL, 0x23, struct mshv_vtl_sint_post_msg)
399#define MSHV_SINT_SET_EVENTFD _IOW(MSHV_IOCTL, 0x24, struct mshv_vtl_set_eventfd)
400#define MSHV_SINT_PAUSE_MESSAGE_STREAM _IOW(MSHV_IOCTL, 0x25, struct mshv_sint_mask)
401
402/* hv_hvcall device */
403#define MSHV_HVCALL_SETUP _IOW(MSHV_IOCTL, 0x1E, struct mshv_vtl_hvcall_setup)
404#define MSHV_HVCALL _IOWR(MSHV_IOCTL, 0x1F, struct mshv_vtl_hvcall)
325#endif405#endif