[PATCH v8 4/6] arm64: hyperv: Initialize hypervisor on boot

Michael Kelley mikelley at microsoft.com
Fri Mar 5 21:03:24 GMT 2021


From: Sunil Muthuswamy <sunilmut at microsoft.com> Sent: Wednesday, March 3, 2021 12:21 PM
> 
> > +static u64 hypercall_output __initdata;
> > +
> > +static int __init hyperv_init(void)
> > +{
> > +	struct hv_get_vpindex_from_apicid_input *input;
> > +	u64	status;
> > +	int	i;
> nit: both, tabs & spaces are being used to indent variable names. Can we stick
> to one?
> 

Agreed.  Will make this consistent in the next version.

> > +
> > +	/*
> > +	 * Hypercall inputs must not cross a page boundary, so allocate
> > +	 * power of 2 size, which will be aligned to that size.
> > +	 */
> > +	input = kzalloc(roundup_pow_of_two(sizeof(input->header) +
> > +				sizeof(input->element[0])), GFP_KERNEL);
> > +	if (!input)
> > +		return -ENOMEM;
> Similar to the comment on the other patch, can this be done through a
> per-cpu hypercall input page?

Per comments on other previous patch, these allocations can be eliminated
and the problem avoided entirely.

> 
> > +		if ((status & HV_HYPERCALL_RESULT_MASK) == HV_STATUS_SUCCESS)
> > +			hv_vp_index[i] = hypercall_output;
> > +		else {
> CNF suggests using braces even for single line 'if' statements if the 'else' is a multi-line
> statement

Will do.

> 
> > +			pr_warn("Hyper-V: No VP index for CPU %d MPIDR %llx status
> %llx\n",
> > +				i, cpu_logical_map(i), status);
> > +			hv_vp_index[i] = VP_INVAL;
> > +		}
> 
> > +bool hv_is_hyperv_initialized(void)
> > +{
> > +	return hyperv_initialized;
> > +}
> > +EXPORT_SYMBOL_GPL(hv_is_hyperv_initialized);
> 
> This to me seems like more of an indication that whether the hypervisor is Hyper-V or
> something else, rather than if necessary Hyper-V pieces have been initialized. If that is
> the case, suggest renaming. Maybe just call it 'hv_is_hyperv'?

This function also exists on the x86/x64 side and is used in architecture independent
code.  It's meaning is somewhere between "is Hyper-V" and "is Hyper-V initialized".
I'm not sure there's much value in changing the name everywhere.

Michael



More information about the linux-arm-kernel mailing list