Skip to content

Commit 9512da9

Browse files
committed
mshv: add function to query vmm capabilities
Use the passthrough hvcall IOCTL on the /dev/mshv fd to perform a self query for VMM capabilities. Signed-off-by: Anirudh Rayabharam <[email protected]>
1 parent e71e511 commit 9512da9

File tree

6 files changed

+1134
-0
lines changed

6 files changed

+1134
-0
lines changed

hv-headers/hvgdk_mini.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ struct hv_u128 {
173173
#define HVCALL_COMPLETE_ISOLATED_IMPORT 0x00f1
174174
#define HVCALL_ISSUE_SNP_PSP_GUEST_REQUEST 0x00f2
175175
#define HVCALL_GET_VP_CPUID_VALUES 0x00f4
176+
#define HVCALL_GET_PARTITION_PROPERTY_EX 0x0101
176177

177178
/* HvFlushGuestPhysicalAddressList, HvExtCallMemoryHeatHint hypercall */
178179
union hv_gpa_page_range {

hv-headers/hvhdk.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,42 @@ struct hv_input_set_partition_property {
471471
__u64 property_value;
472472
} __packed;
473473

474+
union hv_partition_property_arg {
475+
__u64 as_uint64;
476+
struct {
477+
union {
478+
__u32 arg;
479+
__u32 vp_index;
480+
};
481+
__u16 reserved0;
482+
__u8 reserved1;
483+
__u8 object_type;
484+
};
485+
} __packed;
486+
487+
struct hv_input_get_partition_property_ex {
488+
__u64 partition_id;
489+
__u32 property_code; /* enum hv_partition_property_code */
490+
__u32 padding;
491+
union {
492+
union hv_partition_property_arg arg_data;
493+
__u64 arg;
494+
};
495+
} __packed;
496+
497+
#define HV_PARTITION_PROPERTY_EX_MAX_VAR_SIZE \
498+
(HV_HYP_PAGE_SIZE - sizeof(struct hv_input_get_partition_property_ex))
499+
500+
union hv_partition_property_ex {
501+
__u8 buffer[HV_PARTITION_PROPERTY_EX_MAX_VAR_SIZE];
502+
struct hv_partition_property_vmm_capabilities vmm_capabilities;
503+
/* More fields to be filled in when needed */
504+
} __packed;
505+
506+
struct hv_output_get_partition_property_ex {
507+
union hv_partition_property_ex property_value;
508+
} __packed;
509+
474510
struct hv_cpuid_leaf_info {
475511
__u32 eax;
476512
__u32 ecx;

hv-headers/hvhdk_mini.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,14 @@ enum hv_partition_property_code {
8888

8989
/* Nested virtualization properties */
9090
HV_PARTITION_PROPERTY_PROCESSOR_VIRTUALIZATION_FEATURES = 0x00080000,
91+
92+
/* Extended properties with larger property values */
93+
HV_PARTITION_PROPERTY_VMM_CAPABILITIES = 0x00090007,
9194
};
9295

96+
#define HV_PARTITION_VMM_CAPABILITIES_BANK_COUNT 1
97+
#define HV_PARTITION_VMM_CAPABILITIES_RESERVED_BITFIELD_COUNT 59
98+
9399
/* HV Map GPA (Guest Physical Address) Flags */
94100
#define HV_MAP_GPA_PERMISSIONS_NONE 0x0
95101
#define HV_MAP_GPA_READABLE 0x1
@@ -164,4 +170,24 @@ struct hv_input_complete_isolated_import {
164170
union hv_partition_complete_isolated_import_data import_data;
165171
} __packed;
166172

173+
struct hv_partition_property_vmm_capabilities {
174+
__u16 bank_count;
175+
__u16 reserved[3];
176+
union {
177+
__u64 as_uint64[HV_PARTITION_VMM_CAPABILITIES_BANK_COUNT];
178+
struct {
179+
__u64 map_gpa_preserve_adjustable : 1;
180+
__u64 vmm_can_provide_overlay_gpfn : 1;
181+
__u64 vp_affinity_property : 1;
182+
#if defined(__aarch64__)
183+
__u64 vmm_can_provide_gic_overlay_locations : 1;
184+
#else
185+
__u64 reservedbit3 : 1;
186+
#endif
187+
__u64 assignable_synthetic_proc_features : 1;
188+
__u64 reserved0 : HV_PARTITION_VMM_CAPABILITIES_RESERVED_BITFIELD_COUNT;
189+
} __packed;
190+
};
191+
} __packed;
192+
167193
#endif /* _HVHDK_MINI_H */

0 commit comments

Comments
 (0)