+static u8 __init get_vtl(void)The cast to struct hv_get_vp_registers_input isn't needed here. Just do:
+{
+ u64 control = HV_HYPERCALL_REP_COMP_1 | HVCALL_GET_VP_REGISTERS;
+ struct hv_get_vp_registers_input *input;
+ struct hv_get_vp_registers_output *output;
+ u64 vtl = 0;
+ u64 ret;
+ unsigned long flags;
+
+ local_irq_save(flags);
+ input = *(struct hv_get_vp_registers_input **)this_cpu_ptr(hyperv_pcpu_input_arg);
input = *this_cpu_ptr(hyperv_pcpu_input_arg);
I know we have other code that references hyperv_pcpu_input_arg with a more
complicated code sequence, but it's really not necessary. At some point, we
should go back and clean those up, but let's not add any new cases. 😄
+ output = (struct hv_get_vp_registers_output *)input;Use struct_size() to calculate the size of a structure plus a trailing
+ if (!input) {
+ local_irq_restore(flags);
+ goto done;
+ }
+
+ memset(input, 0, sizeof(*input) + sizeof(input->element[0]));
variable size array.
+ input->header.partitionid = HV_PARTITION_ID_SELF;Let's include the hypercall status in the failure message. If a failure ever
+ input->header.vpindex = HV_VP_INDEX_SELF;
+ input->header.inputvtl = 0;
+ input->element[0].name0 = HV_X64_REGISTER_VSM_VP_STATUS;
+
+ ret = hv_do_hypercall(control, input, output);
+ if (hv_result_success(ret))
+ vtl = output->as64.low & HV_X64_VTL_MASK;
+ else
+ pr_err("Hyper-V: failed to get VTL!");
happens, we will really want to know what that status is. 😄
rv;
extern bool hv_nested;
@@ -58,6 +59,7 @@ extern void * __percpu *hyperv_pcpu_output_arg;
extern u64 hv_do_hypercall(u64 control, void *inputaddr, void *outputaddr);
extern u64 hv_do_fast_hypercall8(u16 control, u64 input8);
extern bool hv_isolation_type_snp(void);
+extern bool hv_isolation_type_en_snp(void);