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
26 MSHV_PT_BIT_LAPIC,26 MSHV_PT_BIT_LAPIC,
27 MSHV_PT_BIT_X2APIC,27 MSHV_PT_BIT_X2APIC,
28 MSHV_PT_BIT_GPA_SUPER_PAGES,28 MSHV_PT_BIT_GPA_SUPER_PAGES,
29 MSHV_PT_BIT_CPU_AND_XSAVE_FEATURES,
29 MSHV_PT_BIT_COUNT,30 MSHV_PT_BIT_COUNT,
30};31};
31 32
@@ -41,6 +42,8 @@ enum { · 9 unmodified lines
41 * @pt_flags: Bitmask of 1 << MSHV_PT_BIT_*42 * @pt_flags: Bitmask of 1 << MSHV_PT_BIT_*
42 * @pt_isolation: MSHV_PT_ISOLATION_*43 * @pt_isolation: MSHV_PT_ISOLATION_*
43 *44 *
45 * This is the initial/v1 version for backward compatibility.
46 *
44 * Returns a file descriptor to act as a handle to a guest partition.47 * Returns a file descriptor to act as a handle to a guest partition.
45 * At this point the partition is not yet initialized in the hypervisor.48 * At this point the partition is not yet initialized in the hypervisor.
46 * Some operations must be done with the partition in this state, e.g. setting49 * 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
52 __u64 pt_isolation;55 __u64 pt_isolation;
53};56};
54 57
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 */
75struct 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
55/* /dev/mshv */89/* /dev/mshv */
56#define MSHV_CREATE_PARTITION _IOW(MSHV_IOCTL, 0x00, struct mshv_create_partition)90#define MSHV_CREATE_PARTITION _IOW(MSHV_IOCTL, 0x00, struct mshv_create_partition)
57 91