History

mshv: Extend create partition ioctl to support cpu features

The existing mshv create partition ioctl does not provide a way to specify which cpu features are enabled in the guest. Instead, it attempts to enable all features and those that are not supported are silently disabled by the hypervisor. This was done to reduce unnecessary complexity and is sufficient for many cases. However, new scenarios require fine-grained control over these features. Define a new mshv_create_partition_v2 structure which supports passing the disabled processor and xsave feature bits through to the create partition hypercall directly. Introduce a new flag MSHV_PT_BIT_CPU_AND_XSAVE_FEATURES which enables the new structure. If unset, the original mshv_create_partition struct is used, with the old behavior of enabling all features.

Muminul Islam committed 1 year ago

Commit c91fe5f1 parent f91bc8f2 files · +131 −21Browse files

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

Unified · Split

include/uapi/linux/mshv.h+34−0
@@ -26,6 +26,7 @@ enum { · 25 unmodified lines
2626 MSHV_PT_BIT_LAPIC,
2727 MSHV_PT_BIT_X2APIC,
2828 MSHV_PT_BIT_GPA_SUPER_PAGES,
29+ MSHV_PT_BIT_CPU_AND_XSAVE_FEATURES,
2930 MSHV_PT_BIT_COUNT,
3031 };
3132
@@ -41,6 +42,8 @@ enum { · 9 unmodified lines
4142 * @pt_flags: Bitmask of 1 << MSHV_PT_BIT_*
4243 * @pt_isolation: MSHV_PT_ISOLATION_*
4344 *
45+ * This is the initial/v1 version for backward compatibility.
46+ *
4447 * Returns a file descriptor to act as a handle to a guest partition.
4548 * At this point the partition is not yet initialized in the hypervisor.
4649 * Some operations must be done with the partition in this state, e.g. setting
@@ -52,6 +55,37 @@ struct mshv_create_partition { · 5 unmodified lines
5255 __u64 pt_isolation;
5356 };
5457
58+#define MSHV_NUM_CPU_FEATURES_BANKS 2
59+
60+/**
61+ * struct mshv_create_partition_v2
62+ *
63+ * This is extended version of the above initial MSHV_CREATE_PARTITION
64+ * ioctl and allows for following additional parameters:
65+ *
66+ * @pt_num_cpu_fbanks: Must be set to MSHV_NUM_CPU_FEATURES_BANKS.
67+ * @pt_cpu_fbanks: Disabled processor feature banks array.
68+ * @pt_disabled_xsave: Disabled xsave feature bits.
69+ *
70+ * pt_cpu_fbanks and pt_disabled_xsave are passed through as-is to the create
71+ * partition hypercall.
72+ *
73+ * Returns : same as above original mshv_create_partition
74+ */
75+struct mshv_create_partition_v2 {
76+ __u64 pt_flags;
77+ __u64 pt_isolation;
78+ __u16 pt_num_cpu_fbanks;
79+ __u8 pt_rsvd[6]; /* MBZ */
80+ __u64 pt_cpu_fbanks[MSHV_NUM_CPU_FEATURES_BANKS];
81+ __u64 pt_rsvd1[2]; /* MBZ */
82+#if defined(__x86_64__)
83+ __u64 pt_disabled_xsave;
84+#else
85+ __u64 pt_rsvd2; /* MBZ */
86+#endif
87+} __packed;
88+
5589 /* /dev/mshv */
5690 #define MSHV_CREATE_PARTITION _IOW(MSHV_IOCTL, 0x00, struct mshv_create_partition)
5791