Drivers: hv: Introduce new driver - mshv_vtl
Subsystems (2)
v3 cover Drivers: hv: Introduce new driver - mshv_vtl
Introduce a new mshv_vtl driver to 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.
OpenVMM : https://openvmm.dev/guide/
Changes since v2:
https://lore.kernel.org/all/[email protected]/
* Removed CONFIG_OF dependency (addressed Saurabh's comments
* Fixed typo in "allow_map_intialized" variable name
Changes since v1:
https://lore.kernel.org/all/[email protected]/
Addressed Saurabh's comments:
* Split the patch in 2 to keep export symbols separate
* Make MSHV_VTL module tristate and fixed compilation warning that would come when HYPERV is compiled as a module.
* Remove the use of ref_count
* Split functionality of mshv_vtl_ioctl_get_set_regs to different functions mshv_vtl_ioctl_(get|set)_regs as it actually make things simpler
* Fixed use of copy_from_user in atomic context in mshv_vtl_hvcall_call. Added ToDo comment for info.
* Added extra code to free memory for vtl in error scenarios in mshv_ioctl_create_vtl()
Addressed Alok's comments regarding:
* Additional conditional checks
* corrected typo in HV_X64_REGISTER_MSR_MTRR_PHYS_MASKB case
* empty lines before return statement
* Added/edited comments, variable names, structure field names as suggested to improve documentation - no functional change here.
Naman Jain (2):
Drivers: hv: Export some symbols for mshv_vtl
Drivers: hv: Introduce mshv_vtl driver
drivers/hv/Kconfig | 20 + drivers/hv/Makefile | 7 +- drivers/hv/hv.c | 2 + drivers/hv/hyperv_vmbus.h | 1 + drivers/hv/mshv_vtl.h | 52 + drivers/hv/mshv_vtl_main.c | 1783 +++++++++++++++++++++++++++++++++++ drivers/hv/vmbus_drv.c | 3 +- include/hyperv/hvgdk_mini.h | 81 ++ include/hyperv/hvhdk.h | 1 + include/uapi/linux/mshv.h | 82 ++ 10 files changed, 2030 insertions(+), 2 deletions(-) create mode 100644 drivers/hv/mshv_vtl.h create mode 100644 drivers/hv/mshv_vtl_main.c
base-commit: 8566fc3b96539e3235909d6bdda198e1282beaed
Signature · 1 line
2.34.1
PATCH v3 1/2 Drivers: hv: Export some symbols for mshv_vtl
MSHV_VTL driver is going to be introduced, which is supposed to provide interface for Virtual Machine Monitors (VMMs) to control Virtual Trust Level (VTL). Export the symbols needed to make it work (vmbus_isr, hv_context and hv_post_message).
Message-ID: <[email protected]>
--- drivers/hv/hv.c | 2 ++ drivers/hv/hyperv_vmbus.h | 1 + drivers/hv/vmbus_drv.c | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-)
drivers/hv/hv.c +2 -0
@@ -25,6 +25,7 @@/* The one and only */ struct hv_context hv_context; +EXPORT_SYMBOL_GPL (hv_context);/* * hv_init - Main initialization routine.
@@ -93,6 +94,7 @@ int hv_post_message(union hv_connection_id connection_id,return hv_result (status); } +EXPORT_SYMBOL_GPL (hv_post_message);int hv_synic_alloc (void ) {
drivers/hv/hyperv_vmbus.h +1 -0
@@ -32,6 +32,7 @@*/ #define HV_UTIL_NEGO_TIMEOUT 55 +void vmbus_isr (void );/* Definitions for the monitored notification facility */ union hv_monitor_trigger_group {
drivers/hv/vmbus_drv.c +2 -1
@@ -1283,7 +1283,7 @@ static void vmbus_chan_sched(struct hv_per_cpu_context *hv_cpu) } } -static void vmbus_isr (void ) +void vmbus_isr (void ) {struct hv_per_cpu_context *hv_cpu =this_cpu_ptr (hv_context.cpu_context);
@@ -1306,6 +1306,7 @@ static void vmbus_isr(void)add_interrupt_randomness (vmbus_interrupt); } +EXPORT_SYMBOL_GPL (vmbus_isr);static irqreturn_t vmbus_percpu_isr (int irq,void *dev_id) {
Signature · 1 line
2.34.1
PATCH v3 2/2 Drivers: hv: Introduce mshv_vtl driver
In reply to Naman JainProvide 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.
Message-ID: <[email protected]>
--- drivers/hv/Kconfig | 20 + drivers/hv/Makefile | 7 +- drivers/hv/mshv_vtl.h | 52 + drivers/hv/mshv_vtl_main.c | 1783 +++++++++++++++++++++++++++++++++++ include/hyperv/hvgdk_mini.h | 81 ++ include/hyperv/hvhdk.h | 1 + include/uapi/linux/mshv.h | 82 ++ 7 files changed, 2025 insertions(+), 1 deletion(-) create mode 100644 drivers/hv/mshv_vtl.h create mode 100644 drivers/hv/mshv_vtl_main.c
drivers/hv/Kconfig +20 -0
@@ -72,4 +72,24 @@ config MSHV_ROOT If unsure, say N. +config MSHV_VTL + tristate "Microsoft Hyper-V VTL driver" + depends on HYPERV && X86_64 + depends on TRANSPARENT_HUGEPAGE + # MTRRs are controlled by VTL0, and are not specific to individual VTLs. + # Therefore, do not attempt to access or modify MTRRs here. + depends on !MTRR + select CPUMASK_OFFSTACK + select HYPERV_VTL_MODE + default n + help + Select this option to enable Hyper-V VTL driver support. + This driver provides interfaces for Virtual Machine Manager (VMM) running in VTL2 + userspace to create VTLs and partitions, setup and manage VTL0 memory and + allow userspace to make direct hypercalls. This also allows to map VTL0's address + space to a usermode process in VTL2 and supports getting new VMBus messages and channel + events in VTL2. + + If unsure, say N. + endmenu
drivers/hv/Makefile +6 -1
@@ -3,6 +3,7 @@ obj-$(CONFIG_HYPERV) += hv_vmbus.o obj-$(CONFIG_HYPERV_UTILS) += hv_utils.o obj-$(CONFIG_HYPERV_BALLOON) += hv_balloon.o obj-$(CONFIG_MSHV_ROOT) += mshv_root.o +obj-$(CONFIG_MSHV_VTL) += mshv_vtl.o CFLAGS_hv_trace.o = -I$(src) CFLAGS_hv_balloon.o = -I$(src)
@@ -14,7 +15,11 @@ hv_vmbus-$(CONFIG_HYPERV_TESTING) += hv_debugfs.o hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o hv_utils_transport.o mshv_root-y := mshv_root_main.o mshv_synic.o mshv_eventfd.o mshv_irq.o \ mshv_root_hv_call.o mshv_portid_table.o +mshv_vtl-y := mshv_vtl_main.o # Code that must be built-in obj-$(subst m,y,$(CONFIG_HYPERV)) += hv_common.o -obj-$(subst m,y,$(CONFIG_MSHV_ROOT)) += hv_proc.o mshv_common.o +obj-$(subst m,y,$(CONFIG_MSHV_ROOT)) += hv_proc.o +ifneq ($(CONFIG_MSHV_ROOT) $(CONFIG_MSHV_VTL),) + obj-y += mshv_common.o +endif
drivers/hv/mshv_vtl.h new file +52 -0
52 lines not on this page · raw message
drivers/hv/mshv_vtl_main.c new file +1783 -0
1,783 lines not on this page · raw message
include/hyperv/hvgdk_mini.h +81 -0
93 lines not on this page · raw message
include/hyperv/hvhdk.h +1 -0
@@ -479,6 +479,7 @@ struct hv_connection_info {#define HV_EVENT_FLAGS_COUNT (256 * 8)#define HV_EVENT_FLAGS_BYTE_COUNT (256)#define HV_EVENT_FLAGS32_COUNT (256 / sizeof(u32)) +#define HV_EVENT_FLAGS_LONG_COUNT (HV_EVENT_FLAGS_BYTE_COUNT / sizeof(__u64))/* linux side we create long version of flags to use long bit ops on flags */ #define HV_EVENT_FLAGS_UL_COUNT (256 / sizeof(ulong))
include/uapi/linux/mshv.h +82 -0
86 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v3 2/2] Drivers: hv: Introduce mshv_vtl driver
Quoted 32 lines · Naman Jain
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.
Co-developed-by Roman Kisel <[email protected]>Signed-off-by Roman Kisel <[email protected]>Co-developed-by Saurabh Sengar <[email protected]>Signed-off-by Saurabh Sengar <[email protected]>Reviewed-by Roman Kisel <[email protected]>Reviewed-by Alok Tiwari <[email protected]>Message-ID: <[email protected]>
Signed-off-by Naman Jain <[email protected]>--- drivers/hv/Kconfig | 20 + drivers/hv/Makefile | 7 +- drivers/hv/mshv_vtl.h | 52 + drivers/hv/mshv_vtl_main.c | 1783 +++++++++++++++++++++++++++++++++++ include/hyperv/hvgdk_mini.h | 81 ++ include/hyperv/hvhdk.h | 1 + include/uapi/linux/mshv.h | 82 ++ 7 files changed, 2025 insertions(+), 1 deletion(-) create mode 100644 drivers/hv/mshv_vtl.h create mode 100644 drivers/hv/mshv_vtl_main.cdrivers/hv/Kconfig +0
-0
drivers/hv/Kconfig config MSHV_ROOT · line 78
Quoted 7 lines
drivers/hv/Kconfig +4
-0@@ -72,4 +72,24 @@ config MSHV_ROOT If unsure, say N. +config MSHV_VTL + tristate "Microsoft Hyper-V VTL driver" + depends on HYPERV && X86_64 + depends on TRANSPARENT_HUGEPAGE
Why does it depend on TRANSPARENT_HUGEPAGE?
<snip>
include/hyperv/hvgdk_mini.h struct hv_get_vp_from_apic_id_in { · line 886
Quoted 10 lines
include/hyperv/hvgdk_mini.h +2
-0@@ -882,6 +882,23 @@ struct hv_get_vp_from_apic_id_in {u32 apic_ids[]; } __packed; +union hv_register_vsm_partition_config { +__u64 as_u64;
Please, follow the file pattern: as_u64 -> as_uint64
include/hyperv/hvgdk_mini.h struct hv_get_vp_from_apic_id_in { · line 888
Quoted 2 lines
include/hyperv/hvgdk_mini.h +2
-0+struct { +__u64 enable_vtl_protection :1 ;
Ditto: __u64 -> u64
Quoted 20 lines
include/hyperv/hvgdk_mini.h +13
-0+ __u64 default_vtl_protection_mask : 4; + __u64 zero_memory_on_reset : 1; + __u64 deny_lower_vtl_startup : 1; + __u64 intercept_acceptance : 1; + __u64 intercept_enable_vtl_protection : 1; + __u64 intercept_vp_startup : 1; + __u64 intercept_cpuid_unimplemented : 1; + __u64 intercept_unrecoverable_exception : 1; + __u64 intercept_page : 1; + __u64 mbz : 51; + }; +}; +/* include/hyperv/hvhdk.h +0
-0
include/hyperv/hvhdk.h struct hv_connection_info { · line 482
Quoted 4 lines
include/hyperv/hvhdk.h +1
-0@@ -479,6 +479,7 @@ struct hv_connection_info {#define HV_EVENT_FLAGS_COUNT (256 * 8)#define HV_EVENT_FLAGS_BYTE_COUNT (256)#define HV_EVENT_FLAGS32_COUNT (256 / sizeof(u32)) +#define HV_EVENT_FLAGS_LONG_COUNT (HV_EVENT_FLAGS_BYTE_COUNT / sizeof(__u64))
Ditto
Quoted 13 lines
include/hyperv/hvhdk.h +0
-0/* linux side we create long version of flags to use long bit ops on flags */ #define HV_EVENT_FLAGS_UL_COUNT (256 / sizeof(ulong))include/uapi/linux/mshv.h +2
-0@@ -288,4 +288,86 @@ struct mshv_get_set_vp_state {* #define MSHV_ROOT_HVCALL _IOWR(MSHV_IOCTL, 0x07, struct mshv_root_hvcall) */ +/* Structure definitions, macros and IOCTLs for mshv_vtl */ +
include/uapi/linux/mshv.h struct mshv_get_set_vp_state { · line 302
Quoted 10 lines
include/uapi/linux/mshv.h +10
-0+#define MSHV_CAP_CORE_API_STABLE 0x0 +#define MSHV_CAP_REGISTER_PAGE 0x1 +#define MSHV_CAP_VTL_RETURN_ACTION 0x2 +#define MSHV_CAP_DR6_SHARED 0x3 +#define MSHV_MAX_RUN_MSG_SIZE 256 + +#define MSHV_VP_MAX_REGISTERS 128 + +struct mshv_vp_registers { +__u32 count;/* at most MSHV_VP_MAX_REGISTERS */
Same here: __u{32,64} -> u{32,64}.
Please, address everywhere.
<snip>
Quoted 8 lines
include/uapi/linux/mshv.h +8
-0+ +/* vtl device */ +#define MSHV_CREATE_VTL _IOR(MSHV_IOCTL, 0x1D, char) +#define MSHV_VTL_ADD_VTL0_MEMORY _IOW(MSHV_IOCTL, 0x21, struct mshv_vtl_ram_disposition) +#define MSHV_VTL_SET_POLL_FILE _IOW(MSHV_IOCTL, 0x25, struct mshv_vtl_set_poll_file) +#define MSHV_VTL_RETURN_TO_LOWER_VTL _IO(MSHV_IOCTL, 0x27) +#define MSHV_GET_VP_REGISTERS _IOWR(MSHV_IOCTL, 0x05, struct mshv_vp_registers) +#define MSHV_SET_VP_REGISTERS _IOW(MSHV_IOCTL, 0x06, struct mshv_vp_registers)
include/uapi/linux/mshv.h struct mshv_get_set_vp_state { · line 372
Quoted 10 lines
include/uapi/linux/mshv.h +10
-0+ +/* VMBus device IOCTLs */ +#define MSHV_SINT_SIGNAL_EVENT _IOW(MSHV_IOCTL, 0x22, struct mshv_vtl_signal_event) +#define MSHV_SINT_POST_MESSAGE _IOW(MSHV_IOCTL, 0x23, struct mshv_vtl_sint_post_msg) +#define MSHV_SINT_SET_EVENTFD _IOW(MSHV_IOCTL, 0x24, struct mshv_vtl_set_eventfd) +#define MSHV_SINT_PAUSE_MESSAGE_STREAM _IOW(MSHV_IOCTL, 0x25, struct mshv_sint_mask) + +/* hv_hvcall device */ +#define MSHV_HVCALL_SETUP _IOW(MSHV_IOCTL, 0x1E, struct mshv_vtl_hvcall_setup) +#define MSHV_HVCALL _IOWR(MSHV_IOCTL, 0x1F, struct mshv_vtl_hvcall)
How many of these ioctls are actually used by the mshv root driver? Should those which are VTl-specific be named as such (like MSHV_VTL_SET_POLL_FILE)? Another option would be to keep all the names generic.
Thanks,
Stanislav
Quoted 4 lines
include/uapi/linux/mshv.h +0
-0#endif Signature · 1 line
2.34.1
Re: [PATCH v3 2/2] Drivers: hv: Introduce mshv_vtl driver
Quoted 34 lines · Stanislav Kinsburskii
Quoted 33 lines · Naman Jain
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.
Co-developed-by Roman Kisel <[email protected]>Signed-off-by Roman Kisel <[email protected]>Co-developed-by Saurabh Sengar <[email protected]>Signed-off-by Saurabh Sengar <[email protected]>Reviewed-by Roman Kisel <[email protected]>Reviewed-by Alok Tiwari <[email protected]>Message-ID: <[email protected]>
Signed-off-by Naman Jain <[email protected]>--- drivers/hv/Kconfig | 20 + drivers/hv/Makefile | 7 +- drivers/hv/mshv_vtl.h | 52 + drivers/hv/mshv_vtl_main.c | 1783 +++++++++++++++++++++++++++++++++++ include/hyperv/hvgdk_mini.h | 81 ++ include/hyperv/hvhdk.h | 1 + include/uapi/linux/mshv.h | 82 ++ 7 files changed, 2025 insertions(+), 1 deletion(-)create mode 100644
drivers/hv/mshv_vtl.h
create mode 100644drivers/hv/mshv_vtl_main.cdrivers/hv/Kconfig +0
-0@@ -72,4 +72,24 @@ config MSHV_ROOT
Quoted 9 lines
drivers/hv/Kconfig config MSHV_ROOT · line 78
Quoted 6 lines
drivers/hv/Kconfig +4
-0If unsure, say N. +config MSHV_VTL + tristate "Microsoft Hyper-V VTL driver" + depends on HYPERV && X86_64 + depends on TRANSPARENT_HUGEPAGEWhy does it depend on
TRANSPARENT_HUGEPAGE?
Thanks for reviewing. This config is required for below functions which are used for mshv_vtl_low device.
vm_fault_t mshv_vtl_low_huge_fault ->
* vmf_insert_pfn_pmd
* vmf_insert_pfn_pud
Quoted 73 lines
<snip>
include/hyperv/hvgdk_mini.h struct hv_get_vp_from_apic_id_in { · line 886
Quoted 10 lines
include/hyperv/hvgdk_mini.h +2
-0@@ -882,6 +882,23 @@ struct hv_get_vp_from_apic_id_in {u32 apic_ids[]; } __packed; +union hv_register_vsm_partition_config { +__u64 as_u64;Please, follow the file pattern:
as_u64->as_uint64include/hyperv/hvgdk_mini.h struct hv_get_vp_from_apic_id_in { · line 888
Quoted 2 lines
include/hyperv/hvgdk_mini.h +2
-0+struct { +__u64 enable_vtl_protection :1 ;Ditto:
__u64-> u64Quoted 20 lines
include/hyperv/hvgdk_mini.h +13
-0+ __u64 default_vtl_protection_mask : 4; + __u64 zero_memory_on_reset : 1; + __u64 deny_lower_vtl_startup : 1; + __u64 intercept_acceptance : 1; + __u64 intercept_enable_vtl_protection : 1; + __u64 intercept_vp_startup : 1; + __u64 intercept_cpuid_unimplemented : 1; + __u64 intercept_unrecoverable_exception : 1; + __u64 intercept_page : 1; + __u64 mbz : 51; + }; +}; +/* include/hyperv/hvhdk.h +0
-0include/hyperv/hvhdk.h struct hv_connection_info { · line 482
Quoted 4 lines
include/hyperv/hvhdk.h +1
-0@@ -479,6 +479,7 @@ struct hv_connection_info {#define HV_EVENT_FLAGS_COUNT (256 * 8)#define HV_EVENT_FLAGS_BYTE_COUNT (256)#define HV_EVENT_FLAGS32_COUNT (256 / sizeof(u32)) +#define HV_EVENT_FLAGS_LONG_COUNT (HV_EVENT_FLAGS_BYTE_COUNT / sizeof(__u64))Ditto
Quoted 13 lines
include/hyperv/hvhdk.h +0
-0/* linux side we create long version of flags to use long bit ops on flags */ #define HV_EVENT_FLAGS_UL_COUNT (256 / sizeof(ulong))include/uapi/linux/mshv.h +2
-0@@ -288,4 +288,86 @@ struct mshv_get_set_vp_state {* #define MSHV_ROOT_HVCALL _IOWR(MSHV_IOCTL, 0x07, struct mshv_root_hvcall) */ +/* Structure definitions, macros and IOCTLs for mshv_vtl */ +include/uapi/linux/mshv.h struct mshv_get_set_vp_state { · line 302
Quoted 10 lines
include/uapi/linux/mshv.h +10
-0+#define MSHV_CAP_CORE_API_STABLE 0x0 +#define MSHV_CAP_REGISTER_PAGE 0x1 +#define MSHV_CAP_VTL_RETURN_ACTION 0x2 +#define MSHV_CAP_DR6_SHARED 0x3 +#define MSHV_MAX_RUN_MSG_SIZE 256 + +#define MSHV_VP_MAX_REGISTERS 128 + +struct mshv_vp_registers { +__u32 count;/* at most MSHV_VP_MAX_REGISTERS */ Same here: __u{32,64} -> u{32,64}.
Quoted 2 lines
Please, address everywhere.
I'll take care of all of these in my next patch.
Quoted 25 lines
<snip>
Quoted 8 lines
include/uapi/linux/mshv.h +8
-0+ +/* vtl device */ +#define MSHV_CREATE_VTL _IOR(MSHV_IOCTL, 0x1D, char) +#define MSHV_VTL_ADD_VTL0_MEMORY _IOW(MSHV_IOCTL, 0x21, struct mshv_vtl_ram_disposition) +#define MSHV_VTL_SET_POLL_FILE _IOW(MSHV_IOCTL, 0x25, struct mshv_vtl_set_poll_file) +#define MSHV_VTL_RETURN_TO_LOWER_VTL _IO(MSHV_IOCTL, 0x27) +#define MSHV_GET_VP_REGISTERS _IOWR(MSHV_IOCTL, 0x05, struct mshv_vp_registers) +#define MSHV_SET_VP_REGISTERS _IOW(MSHV_IOCTL, 0x06, struct mshv_vp_registers)include/uapi/linux/mshv.h struct mshv_get_set_vp_state { · line 372
Quoted 10 lines
include/uapi/linux/mshv.h +10
-0+ +/* VMBus device IOCTLs */ +#define MSHV_SINT_SIGNAL_EVENT _IOW(MSHV_IOCTL, 0x22, struct mshv_vtl_signal_event) +#define MSHV_SINT_POST_MESSAGE _IOW(MSHV_IOCTL, 0x23, struct mshv_vtl_sint_post_msg) +#define MSHV_SINT_SET_EVENTFD _IOW(MSHV_IOCTL, 0x24, struct mshv_vtl_set_eventfd) +#define MSHV_SINT_PAUSE_MESSAGE_STREAM _IOW(MSHV_IOCTL, 0x25, struct mshv_sint_mask) + +/* hv_hvcall device */ +#define MSHV_HVCALL_SETUP _IOW(MSHV_IOCTL, 0x1E, struct mshv_vtl_hvcall_setup) +#define MSHV_HVCALL _IOWR(MSHV_IOCTL, 0x1F, struct mshv_vtl_hvcall)How many of these ioctls are actually used by the mshv root driver? Should those which are VTl-specific be named as such (like
MSHV_VTL_SET_POLL_FILE)? Another option would be to keep all the names generic.
Quoted 2 lines
Thanks,
Stanislav
None of the IOCTLs in mshv_vtl section, introduced in this patch is used by mshv_root driver. Since IOCTLs of mshv_root does not have MSHV_ROOT prefix, I am OK with removing MSHV_VTL_* prefix from these IOCTL names. You can let me know if you want me to prefix them with MSHV_VTL.
Thanks again for reviewing.
Regards,
Naman
Quoted 5 lines
Quoted 5 lines
#endif
Signature · 1 line
2.34.1
Re: [PATCH v3 2/2] Drivers: hv: Introduce mshv_vtl driver
Quoted 123 lines · Naman Jain
Quoted 28 lines · Stanislav Kinsburskii
Quoted 27 lines · Naman Jain
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.
Co-developed-by Roman Kisel <[email protected]>Signed-off-by Roman Kisel <[email protected]>Co-developed-by Saurabh Sengar <[email protected]>Signed-off-by Saurabh Sengar <[email protected]>Reviewed-by Roman Kisel <[email protected]>Reviewed-by Alok Tiwari <[email protected]>Message-ID: <[email protected]>
Signed-off-by Naman Jain <[email protected]>---
drivers/hv/Kconfig | 20 +
drivers/hv/Makefile | 7 +- drivers/hv/mshv_vtl.h | 52 + drivers/hv/mshv_vtl_main.c | 1783 +++++++++++++++++++++++++++++++++++include/hyperv/hvgdk_mini.h| 81 ++ include/hyperv/hvhdk.h | 1 + include/uapi/linux/mshv.h | 82 ++7 files changed, 2025 insertions(+), 1 deletion(-)create mode 100644
drivers/hv/mshv_vtl.h
create mode 100644drivers/hv/mshv_vtl_main.cQuoted 13 lines
Quoted 10 lines
drivers/hv/Kconfig +0
-0@@ -72,4 +72,24 @@ config MSHV_ROOTIf unsure, say N.
+configMSHV_VTL
+ tristate "Microsoft Hyper-V VTL driver"
+ depends on HYPERV &&X86_64
+ depends onTRANSPARENT_HUGEPAGEWhy does it depend on
TRANSPARENT_HUGEPAGE?Thanks for reviewing. This config is required for below functions which are used for
mshv_vtl_lowdevice.
vm_fault_tmshv_vtl_low_huge_fault->
*vmf_insert_pfn_pmd
*vmf_insert_pfn_pudQuoted 70 lines
<snip>
include/hyperv/hvgdk_mini.h struct hv_get_vp_from_apic_id_in { · line 885
Quoted 9 lines
include/hyperv/hvgdk_mini.h +2
-0@@ -882,6 +882,23 @@ struct hv_get_vp_from_apic_id_in { u32 apic_ids[]; } __packed; +union hv_register_vsm_partition_config { + __u64 as_u64;Please, follow the file pattern:
as_u64->as_uint64include/hyperv/hvgdk_mini.h struct hv_get_vp_from_apic_id_in { · line 888
Quoted 2 lines
include/hyperv/hvgdk_mini.h +2
-0+ struct { + __u64 enable_vtl_protection : 1;Ditto:
__u64-> u64Quoted 19 lines
include/hyperv/hvgdk_mini.h +13
-0+ __u64 default_vtl_protection_mask : 4; + __u64 zero_memory_on_reset : 1; + __u64 deny_lower_vtl_startup : 1; + __u64 intercept_acceptance : 1; + __u64 intercept_enable_vtl_protection : 1; + __u64 intercept_vp_startup : 1; + __u64 intercept_cpuid_unimplemented : 1; + __u64 intercept_unrecoverable_exception : 1; + __u64 intercept_page : 1; + __u64 mbz : 51; + }; +}; + /*include/hyperv/hvhdk.h +0
-0include/hyperv/hvhdk.h struct hv_connection_info { · line 483
Quoted 5 lines
include/hyperv/hvhdk.h +1
-0@@ -479,6 +479,7 @@ struct hv_connection_info { #define HV_EVENT_FLAGS_COUNT (256 * 8) #define HV_EVENT_FLAGS_BYTE_COUNT (256) #define HV_EVENT_FLAGS32_COUNT (256 / sizeof(u32)) +#define HV_EVENT_FLAGS_LONG_COUNT (HV_EVENT_FLAGS_BYTE_COUNT / sizeof(__u64))Ditto
Quoted 11 lines
include/hyperv/hvhdk.h +0
-0/* linux side we create long version of flags to use long bit ops on flags */ #define HV_EVENT_FLAGS_UL_COUNT (256 / sizeof(ulong))include/uapi/linux/mshv.h +2
-0@@ -288,4 +288,86 @@ struct mshv_get_set_vp_state {* #define MSHV_ROOT_HVCALL _IOWR(MSHV_IOCTL, 0x07, struct mshv_root_hvcall) */ +/* Structure definitions, macros and IOCTLs for mshv_vtl */ +include/uapi/linux/mshv.h struct mshv_get_set_vp_state { · line 301
Quoted 10 lines
include/uapi/linux/mshv.h +10
-0+#define MSHV_CAP_CORE_API_STABLE 0x0 +#define MSHV_CAP_REGISTER_PAGE 0x1 +#define MSHV_CAP_VTL_RETURN_ACTION 0x2 +#define MSHV_CAP_DR6_SHARED 0x3 +#define MSHV_MAX_RUN_MSG_SIZE 256 + +#define MSHV_VP_MAX_REGISTERS 128 + +struct mshv_vp_registers { + __u32 count; /* at most MSHV_VP_MAX_REGISTERS */Same here: __u{32,64} -> u{32,64}.
Quoted 5 lines
Quoted 2 lines
Please, address everywhere.
I'll take care of all of these in my next patch.
One concern about this change in include/uapi/linux/mshv.h. I see the convention of using '__' family of data types in this file. Whatever we do here, will be applicable to existing code as well. Do you suggest we should change it to u{32,64} variants or keep it in current form?
Regards,
Naman
Quoted 54 lines
Quoted 35 lines
<snip>
Quoted 25 lines
include/uapi/linux/mshv.h +4
-0+ +/* vtl device */ +#define MSHV_CREATE_VTL _IOR(MSHV_IOCTL, 0x1D, char) +#define MSHV_VTL_ADD_VTL0_MEMORY _IOW(MSHV_IOCTL, 0x21, struct
mshv_vtl_ram_disposition)
+#define MSHV_VTL_SET_POLL_FILE_IOW(MSHV_IOCTL, 0x25, struct mshv_vtl_set_poll_file)include/uapi/linux/mshv.h +2
-0+#define MSHV_VTL_RETURN_TO_LOWER_VTL _IO(MSHV_IOCTL, 0x27) +#define MSHV_GET_VP_REGISTERS _IOWR(MSHV_IOCTL, 0x05, struct
mshv_vp_registers)
+#define MSHV_SET_VP_REGISTERS_IOW(MSHV_IOCTL, 0x06, struct mshv_vp_registers)include/uapi/linux/mshv.h +3
-0+ +/* VMBus device IOCTLs */ +#define MSHV_SINT_SIGNAL_EVENT _IOW(MSHV_IOCTL, 0x22, struct
mshv_vtl_signal_event)
+#define MSHV_SINT_POST_MESSAGE_IOW(MSHV_IOCTL, 0x23, struct mshv_vtl_sint_post_msg)
+#define MSHV_SINT_SET_EVENTFD_IOW(MSHV_IOCTL, 0x24, struct mshv_vtl_set_eventfd)
+#define MSHV_SINT_PAUSE_MESSAGE_STREAM_IOW(MSHV_IOCTL, 0x25, struct mshv_sint_mask)include/uapi/linux/mshv.h +3
-0+ +/* hv_hvcall device */ +#define MSHV_HVCALL_SETUP _IOW(MSHV_IOCTL, 0x1E, structQuoted 3 lines
mshv_vtl_hvcall_setup)
+#define MSHV_HVCALL_IOWR(MSHV_IOCTL, 0x1F, struct mshv_vtl_hvcall)How many of these ioctls are actually used by the mshv root driver? Should those which are VTl-specific be named as such (like
MSHV_VTL_SET_POLL_FILE)? Another option would be to keep all the names generic.Quoted 2 lines
Thanks,
StanislavNone of the IOCTLs in
mshv_vtlsection, introduced in this patch is used bymshv_rootdriver. Since IOCTLs ofmshv_rootdoes not haveMSHV_ROOTprefix, I am OK with removing MSHV_VTL_* prefix from these IOCTL names. You can let me know if you want me to prefix them withMSHV_VTL.Thanks again for reviewing.
Regards,
NamanQuoted 5 lines
Quoted 5 lines
#endif
Signature · 1 line
2.34.1
Re: [PATCH v3 2/2] Drivers: hv: Introduce mshv_vtl driver
Quoted 132 lines · Naman Jain
Quoted 122 lines · Naman Jain
Quoted 28 lines · Stanislav Kinsburskii
Quoted 27 lines · Naman Jain
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.
Co-developed-by Roman Kisel <[email protected]>Signed-off-by Roman Kisel <[email protected]>Co-developed-by Saurabh Sengar <[email protected]>Signed-off-by Saurabh Sengar <[email protected]>Reviewed-by Roman Kisel <[email protected]>Reviewed-by Alok Tiwari <[email protected]>Message-ID: <[email protected]>
Signed-off-by Naman Jain <[email protected]>---
drivers/hv/Kconfig | 20 +
drivers/hv/Makefile | 7 +- drivers/hv/mshv_vtl.h | 52 + drivers/hv/mshv_vtl_main.c | 1783 +++++++++++++++++++++++++++++++++++include/hyperv/hvgdk_mini.h| 81 ++ include/hyperv/hvhdk.h | 1 + include/uapi/linux/mshv.h | 82 ++7 files changed, 2025 insertions(+), 1 deletion(-)create mode 100644
drivers/hv/mshv_vtl.h
create mode 100644drivers/hv/mshv_vtl_main.cQuoted 13 lines
Quoted 10 lines
drivers/hv/Kconfig +0
-0@@ -72,4 +72,24 @@ config MSHV_ROOTIf unsure, say N.
+configMSHV_VTL
+ tristate "Microsoft Hyper-V VTL driver"
+ depends on HYPERV &&X86_64
+ depends onTRANSPARENT_HUGEPAGEWhy does it depend on
TRANSPARENT_HUGEPAGE?Thanks for reviewing. This config is required for below functions which are used for
mshv_vtl_lowdevice.
vm_fault_tmshv_vtl_low_huge_fault->
*vmf_insert_pfn_pmd
*vmf_insert_pfn_pudQuoted 69 lines
<snip>
include/hyperv/hvgdk_mini.h struct hv_get_vp_from_apic_id_in { · line 885
Quoted 9 lines
include/hyperv/hvgdk_mini.h +2
-0@@ -882,6 +882,23 @@ struct hv_get_vp_from_apic_id_in { u32 apic_ids[]; } __packed; +union hv_register_vsm_partition_config { + __u64 as_u64;Please, follow the file pattern:
as_u64->as_uint64include/hyperv/hvgdk_mini.h struct hv_get_vp_from_apic_id_in { · line 888
Quoted 2 lines
include/hyperv/hvgdk_mini.h +2
-0+ struct { + __u64 enable_vtl_protection : 1;Ditto:
__u64-> u64Quoted 19 lines
include/hyperv/hvgdk_mini.h +13
-0+ __u64 default_vtl_protection_mask : 4; + __u64 zero_memory_on_reset : 1; + __u64 deny_lower_vtl_startup : 1; + __u64 intercept_acceptance : 1; + __u64 intercept_enable_vtl_protection : 1; + __u64 intercept_vp_startup : 1; + __u64 intercept_cpuid_unimplemented : 1; + __u64 intercept_unrecoverable_exception : 1; + __u64 intercept_page : 1; + __u64 mbz : 51; + }; +}; + /*include/hyperv/hvhdk.h +0
-0include/hyperv/hvhdk.h struct hv_connection_info { · line 482
Quoted 4 lines
include/hyperv/hvhdk.h +1
-0@@ -479,6 +479,7 @@ struct hv_connection_info { #define HV_EVENT_FLAGS_COUNT (256 * 8) #define HV_EVENT_FLAGS_BYTE_COUNT (256) #define HV_EVENT_FLAGS32_COUNT (256 / sizeof(u32)) +#define HV_EVENT_FLAGS_LONG_COUNT (HV_EVENT_FLAGS_BYTE_COUNT / sizeof(__u64))Ditto
Quoted 11 lines
include/hyperv/hvhdk.h +0
-0/* linux side we create long version of flags to use long bit ops on flags */ #define HV_EVENT_FLAGS_UL_COUNT (256 / sizeof(ulong))include/uapi/linux/mshv.h +2
-0@@ -288,4 +288,86 @@ struct mshv_get_set_vp_state {* #define MSHV_ROOT_HVCALL _IOWR(MSHV_IOCTL, 0x07, struct mshv_root_hvcall) */ +/* Structure definitions, macros and IOCTLs for mshv_vtl */ +include/uapi/linux/mshv.h struct mshv_get_set_vp_state { · line 301
Quoted 10 lines
include/uapi/linux/mshv.h +10
-0+#define MSHV_CAP_CORE_API_STABLE 0x0 +#define MSHV_CAP_REGISTER_PAGE 0x1 +#define MSHV_CAP_VTL_RETURN_ACTION 0x2 +#define MSHV_CAP_DR6_SHARED 0x3 +#define MSHV_MAX_RUN_MSG_SIZE 256 + +#define MSHV_VP_MAX_REGISTERS 128 + +struct mshv_vp_registers { + __u32 count; /* at most MSHV_VP_MAX_REGISTERS */Same here: __u{32,64} -> u{32,64}.
Quoted 5 lines
Quoted 2 lines
Please, address everywhere.
I'll take care of all of these in my next patch.
Quoted 6 lines
One concern about this change in
include/uapi/linux/mshv.h. I see the convention of using '__' family of data types in this file. Whatever we do here, will be applicable to existing code as well. Do you suggest we should change it to u{32,64} variants or keep it in current form?
uapi code uses the '__' versions of these types, so they should stay as they are.
Thanks
Nuno
Quoted 47 lines
Regards,
NamanQuoted 44 lines
Quoted 25 lines
<snip>
Quoted 8 lines
include/uapi/linux/mshv.h +8
-0+ +/* vtl device */ +#define MSHV_CREATE_VTL _IOR(MSHV_IOCTL, 0x1D, char) +#define MSHV_VTL_ADD_VTL0_MEMORY _IOW(MSHV_IOCTL, 0x21, struct mshv_vtl_ram_disposition) +#define MSHV_VTL_SET_POLL_FILE _IOW(MSHV_IOCTL, 0x25, struct mshv_vtl_set_poll_file) +#define MSHV_VTL_RETURN_TO_LOWER_VTL _IO(MSHV_IOCTL, 0x27) +#define MSHV_GET_VP_REGISTERS _IOWR(MSHV_IOCTL, 0x05, struct mshv_vp_registers) +#define MSHV_SET_VP_REGISTERS _IOW(MSHV_IOCTL, 0x06, struct mshv_vp_registers)include/uapi/linux/mshv.h struct mshv_get_set_vp_state { · line 372
Quoted 10 lines
include/uapi/linux/mshv.h +10
-0+ +/* VMBus device IOCTLs */ +#define MSHV_SINT_SIGNAL_EVENT _IOW(MSHV_IOCTL, 0x22, struct mshv_vtl_signal_event) +#define MSHV_SINT_POST_MESSAGE _IOW(MSHV_IOCTL, 0x23, struct mshv_vtl_sint_post_msg) +#define MSHV_SINT_SET_EVENTFD _IOW(MSHV_IOCTL, 0x24, struct mshv_vtl_set_eventfd) +#define MSHV_SINT_PAUSE_MESSAGE_STREAM _IOW(MSHV_IOCTL, 0x25, struct mshv_sint_mask) + +/* hv_hvcall device */ +#define MSHV_HVCALL_SETUP _IOW(MSHV_IOCTL, 0x1E, struct mshv_vtl_hvcall_setup) +#define MSHV_HVCALL _IOWR(MSHV_IOCTL, 0x1F, struct mshv_vtl_hvcall)How many of these ioctls are actually used by the mshv root driver? Should those which are VTl-specific be named as such (like
MSHV_VTL_SET_POLL_FILE)? Another option would be to keep all the names generic.Quoted 2 lines
Thanks,
StanislavNone of the IOCTLs in
mshv_vtlsection, introduced in this patch is used bymshv_rootdriver. Since IOCTLs ofmshv_rootdoes not haveMSHV_ROOTprefix, I am OK with removing MSHV_VTL_* prefix from these IOCTL names. You can let me know if you want me to prefix them withMSHV_VTL.Thanks again for reviewing.
Regards,
NamanQuoted 5 lines
Quoted 5 lines
#endif
--
2.34.1
Re: [PATCH v3 2/2] Drivers: hv: Introduce mshv_vtl driver
Quoted 140 lines · Nuno Das Neves
Quoted 132 lines · Naman Jain
Quoted 122 lines · Naman Jain
Quoted 28 lines · Stanislav Kinsburskii
Quoted 27 lines · Naman Jain
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.
Co-developed-by Roman Kisel <[email protected]>Signed-off-by Roman Kisel <[email protected]>Co-developed-by Saurabh Sengar <[email protected]>Signed-off-by Saurabh Sengar <[email protected]>Reviewed-by Roman Kisel <[email protected]>Reviewed-by Alok Tiwari <[email protected]>Message-ID: <[email protected]>
Signed-off-by Naman Jain <[email protected]>--- drivers/hv/Kconfig | 20 + drivers/hv/Makefile | 7 +- drivers/hv/mshv_vtl.h | 52 + drivers/hv/mshv_vtl_main.c | 1783 +++++++++++++++++++++++++++++++++++ include/hyperv/hvgdk_mini.h | 81 ++ include/hyperv/hvhdk.h | 1 + include/uapi/linux/mshv.h | 82 ++ 7 files changed, 2025 insertions(+), 1 deletion(-)create mode 100644
drivers/hv/mshv_vtl.h
create mode 100644drivers/hv/mshv_vtl_main.cQuoted 13 lines
drivers/hv/Kconfig config MSHV_ROOT · line 76
Quoted 10 lines
drivers/hv/Kconfig +4
-0@@ -72,4 +72,24 @@ config MSHV_ROOT If unsure, say N. +config MSHV_VTL + tristate "Microsoft Hyper-V VTL driver" + depends on HYPERV && X86_64 + depends on TRANSPARENT_HUGEPAGEWhy does it depend on
TRANSPARENT_HUGEPAGE?Thanks for reviewing. This config is required for below functions which are used for
mshv_vtl_lowdevice.
vm_fault_tmshv_vtl_low_huge_fault->
*vmf_insert_pfn_pmd
*vmf_insert_pfn_pudQuoted 69 lines
<snip>
include/hyperv/hvgdk_mini.h struct hv_get_vp_from_apic_id_in { · line 885
Quoted 9 lines
include/hyperv/hvgdk_mini.h +2
-0@@ -882,6 +882,23 @@ struct hv_get_vp_from_apic_id_in { u32 apic_ids[]; } __packed; +union hv_register_vsm_partition_config { + __u64 as_u64;Please, follow the file pattern:
as_u64->as_uint64include/hyperv/hvgdk_mini.h struct hv_get_vp_from_apic_id_in { · line 888
Quoted 2 lines
include/hyperv/hvgdk_mini.h +2
-0+ struct { + __u64 enable_vtl_protection : 1;Ditto:
__u64-> u64Quoted 19 lines
include/hyperv/hvgdk_mini.h +13
-0+ __u64 default_vtl_protection_mask : 4; + __u64 zero_memory_on_reset : 1; + __u64 deny_lower_vtl_startup : 1; + __u64 intercept_acceptance : 1; + __u64 intercept_enable_vtl_protection : 1; + __u64 intercept_vp_startup : 1; + __u64 intercept_cpuid_unimplemented : 1; + __u64 intercept_unrecoverable_exception : 1; + __u64 intercept_page : 1; + __u64 mbz : 51; + }; +}; + /*include/hyperv/hvhdk.h +0
-0include/hyperv/hvhdk.h struct hv_connection_info { · line 482
Quoted 4 lines
include/hyperv/hvhdk.h +1
-0@@ -479,6 +479,7 @@ struct hv_connection_info { #define HV_EVENT_FLAGS_COUNT (256 * 8) #define HV_EVENT_FLAGS_BYTE_COUNT (256) #define HV_EVENT_FLAGS32_COUNT (256 / sizeof(u32)) +#define HV_EVENT_FLAGS_LONG_COUNT (HV_EVENT_FLAGS_BYTE_COUNT / sizeof(__u64))Ditto
Quoted 11 lines
include/hyperv/hvhdk.h +0
-0/* linux side we create long version of flags to use long bit ops on flags */ #define HV_EVENT_FLAGS_UL_COUNT (256 / sizeof(ulong))include/uapi/linux/mshv.h +2
-0@@ -288,4 +288,86 @@ struct mshv_get_set_vp_state {* #define MSHV_ROOT_HVCALL _IOWR(MSHV_IOCTL, 0x07, struct mshv_root_hvcall) */ +/* Structure definitions, macros and IOCTLs for mshv_vtl */ +include/uapi/linux/mshv.h struct mshv_get_set_vp_state { · line 301
Quoted 10 lines
include/uapi/linux/mshv.h +10
-0+#define MSHV_CAP_CORE_API_STABLE 0x0 +#define MSHV_CAP_REGISTER_PAGE 0x1 +#define MSHV_CAP_VTL_RETURN_ACTION 0x2 +#define MSHV_CAP_DR6_SHARED 0x3 +#define MSHV_MAX_RUN_MSG_SIZE 256 + +#define MSHV_VP_MAX_REGISTERS 128 + +struct mshv_vp_registers { + __u32 count; /* at most MSHV_VP_MAX_REGISTERS */Same here: __u{32,64} -> u{32,64}.
Quoted 5 lines
Quoted 2 lines
Please, address everywhere.
I'll take care of all of these in my next patch.
Quoted 6 lines
One concern about this change in
include/uapi/linux/mshv.h. I see the convention of using '__' family of data types in this file. Whatever we do here, will be applicable to existing code as well. Do you suggest we should change it to u{32,64} variants or keep it in current form?
Quoted 5 lines
uapi code uses the '__' versions of these types, so they should stay as they are.
Thanks
Nuno
Thanks Nuno. Acked.
Regards,
Naman
Re: [PATCH v3 2/2] Drivers: hv: Introduce mshv_vtl driver
In reply to Naman JainQuoted 31 lines · Naman Jain
Quoted 28 lines · Stanislav Kinsburskii
Quoted 27 lines · Naman Jain
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.
Co-developed-by Roman Kisel <[email protected]>Signed-off-by Roman Kisel <[email protected]>Co-developed-by Saurabh Sengar <[email protected]>Signed-off-by Saurabh Sengar <[email protected]>Reviewed-by Roman Kisel <[email protected]>Reviewed-by Alok Tiwari <[email protected]>Message-ID: <[email protected]>
Signed-off-by Naman Jain <[email protected]>--- drivers/hv/Kconfig | 20 + drivers/hv/Makefile | 7 +- drivers/hv/mshv_vtl.h | 52 + drivers/hv/mshv_vtl_main.c | 1783 +++++++++++++++++++++++++++++++++++ include/hyperv/hvgdk_mini.h | 81 ++ include/hyperv/hvhdk.h | 1 + include/uapi/linux/mshv.h | 82 ++ 7 files changed, 2025 insertions(+), 1 deletion(-)create mode 100644
drivers/hv/mshv_vtl.h
create mode 100644drivers/hv/mshv_vtl_main.c
Quoted 14 lines
Quoted 4 lines
Quoted 4 lines
drivers/hv/Kconfig +0
-0Quoted 9 lines
drivers/hv/Kconfig config MSHV_ROOT · line 76
Quoted 6 lines
drivers/hv/Kconfig +4
-0@@ -72,4 +72,24 @@ config MSHV_ROOT If unsure, say N. +config MSHV_VTL + tristate "Microsoft Hyper-V VTL driver" + depends on HYPERV && X86_64 + depends on TRANSPARENT_HUGEPAGEWhy does it depend on
TRANSPARENT_HUGEPAGE?
Let me rephrase: can this driver work without transparent huge pages? If yes, then it shouldn't depend on the option and rather select it. If not, then it should be either fixed to be able to or have an expalanation why this dependecy was introduced.
Quoted 31 lines
Quoted 23 lines
Quoted 8 lines
drivers/hv/Kconfig +8
-0+ +/* vtl device */ +#define MSHV_CREATE_VTL _IOR(MSHV_IOCTL, 0x1D, char) +#define MSHV_VTL_ADD_VTL0_MEMORY _IOW(MSHV_IOCTL, 0x21, struct mshv_vtl_ram_disposition) +#define MSHV_VTL_SET_POLL_FILE _IOW(MSHV_IOCTL, 0x25, struct mshv_vtl_set_poll_file) +#define MSHV_VTL_RETURN_TO_LOWER_VTL _IO(MSHV_IOCTL, 0x27) +#define MSHV_GET_VP_REGISTERS _IOWR(MSHV_IOCTL, 0x05, struct mshv_vp_registers) +#define MSHV_SET_VP_REGISTERS _IOW(MSHV_IOCTL, 0x06, struct mshv_vp_registers)drivers/hv/Kconfig config MSHV_ROOT · line 94
Quoted 10 lines
drivers/hv/Kconfig +10
-0+ +/* VMBus device IOCTLs */ +#define MSHV_SINT_SIGNAL_EVENT _IOW(MSHV_IOCTL, 0x22, struct mshv_vtl_signal_event) +#define MSHV_SINT_POST_MESSAGE _IOW(MSHV_IOCTL, 0x23, struct mshv_vtl_sint_post_msg) +#define MSHV_SINT_SET_EVENTFD _IOW(MSHV_IOCTL, 0x24, struct mshv_vtl_set_eventfd) +#define MSHV_SINT_PAUSE_MESSAGE_STREAM _IOW(MSHV_IOCTL, 0x25, struct mshv_sint_mask) + +/* hv_hvcall device */ +#define MSHV_HVCALL_SETUP _IOW(MSHV_IOCTL, 0x1E, struct mshv_vtl_hvcall_setup) +#define MSHV_HVCALL _IOWR(MSHV_IOCTL, 0x1F, struct mshv_vtl_hvcall)How many of these ioctls are actually used by the mshv root driver? Should those which are VTl-specific be named as such (like
MSHV_VTL_SET_POLL_FILE)? Another option would be to keep all the names generic.Quoted 2 lines
Thanks,
StanislavNone of the IOCTLs in
mshv_vtlsection, introduced in this patch is used bymshv_rootdriver. Since IOCTLs ofmshv_rootdoes not haveMSHV_ROOTprefix, I am OK with removing MSHV_VTL_* prefix from these IOCTL names. You can let me know if you want me to prefix them withMSHV_VTL.
Quoted 5 lines
Thanks again for reviewing.
Regards,
Naman
As these ioctls share the same "namespace" (MSHV_IOCTL), removal os the VTL suffix looks a better optio to me.
Thanks,
Stanislav.
Re: [PATCH v3 2/2] Drivers: hv: Introduce mshv_vtl driver
Quoted 47 lines · Stanislav Kinsburskii
Quoted 31 lines · Naman Jain
Quoted 28 lines · Stanislav Kinsburskii
Quoted 27 lines · Naman Jain
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.
Co-developed-by Roman Kisel <[email protected]>Signed-off-by Roman Kisel <[email protected]>Co-developed-by Saurabh Sengar <[email protected]>Signed-off-by Saurabh Sengar <[email protected]>Reviewed-by Roman Kisel <[email protected]>Reviewed-by Alok Tiwari <[email protected]>Message-ID: <[email protected]>
Signed-off-by Naman Jain <[email protected]>--- drivers/hv/Kconfig | 20 + drivers/hv/Makefile | 7 +- drivers/hv/mshv_vtl.h | 52 + drivers/hv/mshv_vtl_main.c | 1783 +++++++++++++++++++++++++++++++++++ include/hyperv/hvgdk_mini.h | 81 ++ include/hyperv/hvhdk.h | 1 + include/uapi/linux/mshv.h | 82 ++ 7 files changed, 2025 insertions(+), 1 deletion(-)create mode 100644
drivers/hv/mshv_vtl.h
create mode 100644drivers/hv/mshv_vtl_main.cQuoted 14 lines
Quoted 4 lines
Quoted 4 lines
drivers/hv/Kconfig +0
-0Quoted 9 lines
drivers/hv/Kconfig config MSHV_ROOT · line 76
Quoted 6 lines
drivers/hv/Kconfig +4
-0@@ -72,4 +72,24 @@ config MSHV_ROOT If unsure, say N. +config MSHV_VTL + tristate "Microsoft Hyper-V VTL driver" + depends on HYPERV && X86_64 + depends on TRANSPARENT_HUGEPAGEWhy does it depend on
TRANSPARENT_HUGEPAGE?
Quoted 4 lines
Let me rephrase: can this driver work without transparent huge pages? If yes, then it shouldn't depend on the option and rather select it. If not, then it should be either fixed to be able to or have an expalanation why this dependecy was introduced.
No, it won't work. Reason being - we are adding support to map VTL0 address space to a user-mode process in VTL2. VTL2 for OpenHCL makes use of Huge pages to improve performance on VMs having large memory requirements. Thus, we need TRANSPARENT_HUGEPAGE.
I will add this as a comment in Kconfig.
Quoted 38 lines
Quoted 32 lines
Quoted 24 lines
Quoted 9 lines
drivers/hv/Kconfig +8
-0+ +/* vtl device */ +#define MSHV_CREATE_VTL _IOR(MSHV_IOCTL, 0x1D, char) +#define MSHV_VTL_ADD_VTL0_MEMORY _IOW(MSHV_IOCTL, 0x21, struct mshv_vtl_ram_disposition) +#define MSHV_VTL_SET_POLL_FILE _IOW(MSHV_IOCTL, 0x25, struct mshv_vtl_set_poll_file) +#define MSHV_VTL_RETURN_TO_LOWER_VTL _IO(MSHV_IOCTL, 0x27) +#define MSHV_GET_VP_REGISTERS _IOWR(MSHV_IOCTL, 0x05, struct mshv_vp_registers) +#define MSHV_SET_VP_REGISTERS _IOW(MSHV_IOCTL, 0x06, struct mshv_vp_registers)drivers/hv/Kconfig config MSHV_ROOT · line 94
Quoted 10 lines
drivers/hv/Kconfig +10
-0+ +/* VMBus device IOCTLs */ +#define MSHV_SINT_SIGNAL_EVENT _IOW(MSHV_IOCTL, 0x22, struct mshv_vtl_signal_event) +#define MSHV_SINT_POST_MESSAGE _IOW(MSHV_IOCTL, 0x23, struct mshv_vtl_sint_post_msg) +#define MSHV_SINT_SET_EVENTFD _IOW(MSHV_IOCTL, 0x24, struct mshv_vtl_set_eventfd) +#define MSHV_SINT_PAUSE_MESSAGE_STREAM _IOW(MSHV_IOCTL, 0x25, struct mshv_sint_mask) + +/* hv_hvcall device */ +#define MSHV_HVCALL_SETUP _IOW(MSHV_IOCTL, 0x1E, struct mshv_vtl_hvcall_setup) +#define MSHV_HVCALL _IOWR(MSHV_IOCTL, 0x1F, struct mshv_vtl_hvcall)How many of these ioctls are actually used by the mshv root driver? Should those which are VTl-specific be named as such (like
MSHV_VTL_SET_POLL_FILE)? Another option would be to keep all the names generic.Quoted 2 lines
Thanks,
StanislavNone of the IOCTLs in
mshv_vtlsection, introduced in this patch is used bymshv_rootdriver. Since IOCTLs ofmshv_rootdoes not haveMSHV_ROOTprefix, I am OK with removing MSHV_VTL_* prefix from these IOCTL names. You can let me know if you want me to prefix them withMSHV_VTL.Quoted 5 lines
Thanks again for reviewing.
Regards,
Naman
Quoted 5 lines
As these ioctls share the same "namespace" (
MSHV_IOCTL), removal os the VTL suffix looks a better optio to me.Thanks,
Stanislav.
Will make the changes in next patch. Thanks.
Regards,
Naman
Re: [PATCH v3 2/2] Drivers: hv: Introduce mshv_vtl driver
Quoted 55 lines · Naman Jain
Quoted 47 lines · Stanislav Kinsburskii
Quoted 31 lines · Naman Jain
Quoted 28 lines · Stanislav Kinsburskii
Quoted 27 lines · Naman Jain
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.
Co-developed-by Roman Kisel <[email protected]>Signed-off-by Roman Kisel <[email protected]>Co-developed-by Saurabh Sengar <[email protected]>Signed-off-by Saurabh Sengar <[email protected]>Reviewed-by Roman Kisel <[email protected]>Reviewed-by Alok Tiwari <[email protected]>Message-ID: <[email protected]>
Signed-off-by Naman Jain <[email protected]>--- drivers/hv/Kconfig | 20 + drivers/hv/Makefile | 7 +- drivers/hv/mshv_vtl.h | 52 + drivers/hv/mshv_vtl_main.c | 1783 +++++++++++++++++++++++++++++++++++ include/hyperv/hvgdk_mini.h | 81 ++ include/hyperv/hvhdk.h | 1 + include/uapi/linux/mshv.h | 82 ++ 7 files changed, 2025 insertions(+), 1 deletion(-)create mode 100644
drivers/hv/mshv_vtl.h
create mode 100644drivers/hv/mshv_vtl_main.cQuoted 14 lines
Quoted 4 lines
Quoted 4 lines
drivers/hv/Kconfig +0
-0Quoted 9 lines
drivers/hv/Kconfig config MSHV_ROOT · line 76
Quoted 6 lines
drivers/hv/Kconfig +4
-0@@ -72,4 +72,24 @@ config MSHV_ROOT If unsure, say N. +config MSHV_VTL + tristate "Microsoft Hyper-V VTL driver" + depends on HYPERV && X86_64 + depends on TRANSPARENT_HUGEPAGEWhy does it depend on
TRANSPARENT_HUGEPAGE?Quoted 4 lines
Let me rephrase: can this driver work without transparent huge pages? If yes, then it shouldn't depend on the option and rather select it. If not, then it should be either fixed to be able to or have an expalanation why this dependecy was introduced.
Quoted 7 lines
No, it won't work. Reason being - we are adding support to map VTL0 address space to a user-mode process in VTL2. VTL2 for OpenHCL makes use of Huge pages to improve performance on VMs having large memory requirements. Thus, we need
TRANSPARENT_HUGEPAGE.I will add this as a comment in
Kconfig.
Then I'd suggest selecting huge pages instead of depending on them: it's kinda weird that one need to select huge pages first to be able to even find out, that there is some virtualization driver, depending on it.
Thanks,
Stanislav
Quoted 54 lines · Naman Jain
Introduce a new
mshv_vtldriver to 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.OpenVMM : https://openvmm.dev/guide/
Changes since v2:
https://lore.kernel.org/all/[email protected]/
* RemovedCONFIG_OFdependency (addressed Saurabh's comments
* Fixed typo in "allow_map_intialized" variable nameChanges since v1:
https://lore.kernel.org/all/[email protected]/
Addressed Saurabh's comments:
* Split the patch in 2 to keep export symbols separate
* MakeMSHV_VTLmodule tristate and fixed compilation warning that would come when HYPERV is compiled as a module.
* Remove the use ofref_count
* Split functionality ofmshv_vtl_ioctl_get_set_regsto different functions mshv_vtl_ioctl_(get|set)_regs as it actually make things simpler
* Fixed use ofcopy_from_userin atomic context inmshv_vtl_hvcall_call. Added ToDo comment for info.
* Added extra code to free memory for vtl in error scenarios inmshv_ioctl_create_vtl()Addressed Alok's comments regarding:
* Additional conditional checks
* corrected typo inHV_X64_REGISTER_MSR_MTRR_PHYS_MASKBcase
* empty lines before return statement
* Added/edited comments, variable names, structure field names as suggested to improve documentation - no functional change here.Naman Jain (2):
Drivers: hv: Export some symbols formshv_vtl
Drivers: hv: Introducemshv_vtldriverdrivers/hv/Kconfig | 20 + drivers/hv/Makefile | 7 +- drivers/hv/hv.c | 2 + drivers/hv/hyperv_vmbus.h | 1 + drivers/hv/mshv_vtl.h | 52 + drivers/hv/mshv_vtl_main.c | 1783 +++++++++++++++++++++++++++++++++++ drivers/hv/vmbus_drv.c | 3 +- include/hyperv/hvgdk_mini.h | 81 ++ include/hyperv/hvhdk.h | 1 + include/uapi/linux/mshv.h | 82 ++ 10 files changed, 2030 insertions(+), 2 deletions(-) create mode 100644 drivers/hv/mshv_vtl.h create mode 100644 drivers/hv/mshv_vtl_main.c
Quoted 4 lines
base-commit:
8566fc3b96539e3235909d6bdda198e1282beaedSignature · 1 line
2.34.1
For both the patches,