Skip to content

Commit 59aeea1

Browse files
pupachaliuw
authored andcommitted
mshv: Add the HVCALL_GET_PARTITION_PROPERTY_EX hypercall
This hypercall can be used to fetch extended properties of a partition. Extended properties are properties with values larger than a u64. Some of these also need additional input arguments. Add helper function for using the hypercall in the mshv_root driver. Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com> Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com> Reviewed-by: Anirudh Rayabharam <anirudh@anirudhrb.com> Reviewed-by: Praveen K Paladugu <prapal@linux.microsoft.com> Reviewed-by: Easwar Hariharan <easwar.hariharan@linux.microsoft.com> Reviewed-by: Tianyu Lan <tiala@microsoft.com> Signed-off-by: Wei Liu <wei.liu@kernel.org>
1 parent 9ebc528 commit 59aeea1

5 files changed

Lines changed: 100 additions & 0 deletions

File tree

drivers/hv/mshv_root.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ int hv_call_unmap_stat_page(enum hv_stats_object_type type,
303303
int hv_call_modify_spa_host_access(u64 partition_id, struct page **pages,
304304
u64 page_struct_count, u32 host_access,
305305
u32 flags, u8 acquire);
306+
int hv_call_get_partition_property_ex(u64 partition_id, u64 property_code, u64 arg,
307+
void *property_value, size_t property_value_sz);
306308

307309
extern struct mshv_root mshv_root;
308310
extern enum hv_scheduler_type hv_scheduler_type;

drivers/hv/mshv_root_hv_call.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,37 @@ int hv_call_unmap_vp_state_page(u64 partition_id, u32 vp_index, u32 type,
590590
return hv_result_to_errno(status);
591591
}
592592

593+
int hv_call_get_partition_property_ex(u64 partition_id, u64 property_code,
594+
u64 arg, void *property_value,
595+
size_t property_value_sz)
596+
{
597+
u64 status;
598+
unsigned long flags;
599+
struct hv_input_get_partition_property_ex *input;
600+
struct hv_output_get_partition_property_ex *output;
601+
602+
local_irq_save(flags);
603+
input = *this_cpu_ptr(hyperv_pcpu_input_arg);
604+
output = *this_cpu_ptr(hyperv_pcpu_output_arg);
605+
606+
memset(input, 0, sizeof(*input));
607+
input->partition_id = partition_id;
608+
input->property_code = property_code;
609+
input->arg = arg;
610+
status = hv_do_hypercall(HVCALL_GET_PARTITION_PROPERTY_EX, input, output);
611+
612+
if (!hv_result_success(status)) {
613+
local_irq_restore(flags);
614+
hv_status_debug(status, "\n");
615+
return hv_result_to_errno(status);
616+
}
617+
memcpy(property_value, &output->property_value, property_value_sz);
618+
619+
local_irq_restore(flags);
620+
621+
return 0;
622+
}
623+
593624
int
594625
hv_call_clear_virtual_interrupt(u64 partition_id)
595626
{

include/hyperv/hvgdk_mini.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ union hv_vp_assist_msr_contents { /* HV_REGISTER_VP_ASSIST_PAGE */
491491
#define HVCALL_GET_VP_STATE 0x00e3
492492
#define HVCALL_SET_VP_STATE 0x00e4
493493
#define HVCALL_GET_VP_CPUID_VALUES 0x00f4
494+
#define HVCALL_GET_PARTITION_PROPERTY_EX 0x0101
494495
#define HVCALL_MMIO_READ 0x0106
495496
#define HVCALL_MMIO_WRITE 0x0107
496497

include/hyperv/hvhdk.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,46 @@ struct hv_input_set_partition_property {
376376
u64 property_value;
377377
} __packed;
378378

379+
union hv_partition_property_arg {
380+
u64 as_uint64;
381+
struct {
382+
union {
383+
u32 arg;
384+
u32 vp_index;
385+
};
386+
u16 reserved0;
387+
u8 reserved1;
388+
u8 object_type;
389+
} __packed;
390+
};
391+
392+
struct hv_input_get_partition_property_ex {
393+
u64 partition_id;
394+
u32 property_code; /* enum hv_partition_property_code */
395+
u32 padding;
396+
union {
397+
union hv_partition_property_arg arg_data;
398+
u64 arg;
399+
};
400+
} __packed;
401+
402+
/*
403+
* NOTE: Should use hv_input_set_partition_property_ex_header to compute this
404+
* size, but hv_input_get_partition_property_ex is identical so it suffices
405+
*/
406+
#define HV_PARTITION_PROPERTY_EX_MAX_VAR_SIZE \
407+
(HV_HYP_PAGE_SIZE - sizeof(struct hv_input_get_partition_property_ex))
408+
409+
union hv_partition_property_ex {
410+
u8 buffer[HV_PARTITION_PROPERTY_EX_MAX_VAR_SIZE];
411+
struct hv_partition_property_vmm_capabilities vmm_capabilities;
412+
/* More fields to be filled in when needed */
413+
};
414+
415+
struct hv_output_get_partition_property_ex {
416+
union hv_partition_property_ex property_value;
417+
} __packed;
418+
379419
enum hv_vp_state_page_type {
380420
HV_VP_STATE_PAGE_REGISTERS = 0,
381421
HV_VP_STATE_PAGE_INTERCEPT_MESSAGE = 1,

include/hyperv/hvhdk_mini.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,34 @@ enum hv_partition_property_code {
9696
HV_PARTITION_PROPERTY_XSAVE_STATES = 0x00060007,
9797
HV_PARTITION_PROPERTY_MAX_XSAVE_DATA_SIZE = 0x00060008,
9898
HV_PARTITION_PROPERTY_PROCESSOR_CLOCK_FREQUENCY = 0x00060009,
99+
100+
/* Extended properties with larger property values */
101+
HV_PARTITION_PROPERTY_VMM_CAPABILITIES = 0x00090007,
99102
};
100103

104+
#define HV_PARTITION_VMM_CAPABILITIES_BANK_COUNT 1
105+
#define HV_PARTITION_VMM_CAPABILITIES_RESERVED_BITFIELD_COUNT 59
106+
107+
struct hv_partition_property_vmm_capabilities {
108+
u16 bank_count;
109+
u16 reserved[3];
110+
union {
111+
u64 as_uint64[HV_PARTITION_VMM_CAPABILITIES_BANK_COUNT];
112+
struct {
113+
u64 map_gpa_preserve_adjustable: 1;
114+
u64 vmm_can_provide_overlay_gpfn: 1;
115+
u64 vp_affinity_property: 1;
116+
#if IS_ENABLED(CONFIG_ARM64)
117+
u64 vmm_can_provide_gic_overlay_locations: 1;
118+
#else
119+
u64 reservedbit3: 1;
120+
#endif
121+
u64 assignable_synthetic_proc_features: 1;
122+
u64 reserved0: HV_PARTITION_VMM_CAPABILITIES_RESERVED_BITFIELD_COUNT;
123+
} __packed;
124+
};
125+
} __packed;
126+
101127
enum hv_snp_status {
102128
HV_SNP_STATUS_NONE = 0,
103129
HV_SNP_STATUS_AVAILABLE = 1,

0 commit comments

Comments
 (0)