[PATCH v2 15/15] Drivers: hv: Add modules to expose /dev/mshv to VMMs running on Hyper-V

Saurabh Singh Sengar ssengar at microsoft.com
Mon Aug 21 11:18:00 PDT 2023



> -----Original Message-----
> From: Nuno Das Neves <nunodasneves at linux.microsoft.com>
> Sent: Friday, August 18, 2023 3:32 AM
> To: linux-hyperv at vger.kernel.org; linux-kernel at vger.kernel.org;
> x86 at kernel.org; linux-arm-kernel at lists.infradead.org; linux-
> arch at vger.kernel.org
> Cc: patches at lists.linux.dev; Michael Kelley (LINUX)
> <mikelley at microsoft.com>; KY Srinivasan <kys at microsoft.com>;
> wei.liu at kernel.org; Haiyang Zhang <haiyangz at microsoft.com>; Dexuan Cui
> <decui at microsoft.com>; apais at linux.microsoft.com; Tianyu Lan
> <Tianyu.Lan at microsoft.com>; ssengar at linux.microsoft.com; MUKESH
> RATHOR <mukeshrathor at microsoft.com>; stanislav.kinsburskiy at gmail.com;
> jinankjain at linux.microsoft.com; vkuznets <vkuznets at redhat.com>;
> tglx at linutronix.de; mingo at redhat.com; bp at alien8.de;
> dave.hansen at linux.intel.com; hpa at zytor.com; will at kernel.org;
> catalin.marinas at arm.com
> Subject: [PATCH v2 15/15] Drivers: hv: Add modules to expose /dev/mshv to
> VMMs running on Hyper-V
> 
> Add mshv, mshv_root, and mshv_vtl modules:
> 

<snip>

> +	ret = mshv_set_vp_registers(vp->index, vp->partition->id,
> +				    1, &dispatch_suspend);
> +	if (ret)
> +		pr_err("%s: failed to suspend partition %llu vp %u\n",
> +			__func__, vp->partition->id, vp->index);
> +
> +	return ret;
> +}
> +
> +static int
> +get_vp_signaled_count(struct mshv_vp *vp, u64 *count)
> +{
> +	int ret;
> +	struct hv_register_assoc root_signal_count = {
> +		.name = HV_REGISTER_VP_ROOT_SIGNAL_COUNT,
> +	};
> +
> +	ret = mshv_get_vp_registers(vp->index, vp->partition->id,
> +				    1, &root_signal_count);
> +
> +	if (ret) {
> +		pr_err("%s: failed to get root signal count for partition %llu vp
> %u",
> +			__func__, vp->partition->id, vp->index);
> +		*count = 0;

Have we missed a return here ?
Moreover, the return type of this function is never checked consider
checking it or change it to void.

<snip>

> +
> +/* Retrieve and stash the supported scheduler type */
> +static int __init mshv_retrieve_scheduler_type(void)
> +{
> +	struct hv_input_get_system_property *input;
> +	struct hv_output_get_system_property *output;
> +	unsigned long flags;
> +	u64 status;
> +
> +	local_irq_save(flags);
> +	input = *this_cpu_ptr(hyperv_pcpu_input_arg);
> +	output = *this_cpu_ptr(hyperv_pcpu_output_arg);
> +
> +	memset(input, 0, sizeof(*input));
> +	memset(output, 0, sizeof(*output));
> +	input->property_id = HV_SYSTEM_PROPERTY_SCHEDULER_TYPE;
> +
> +	status = hv_do_hypercall(HVCALL_GET_SYSTEM_PROPERTY, input,
> output);
> +	if (!hv_result_success(status)) {
> +		local_irq_restore(flags);
> +		pr_err("%s: %s\n", __func__, hv_status_to_string(status));
> +		return hv_status_to_errno(status);
> +	}
> +
> +	hv_scheduler_type = output->scheduler_type;
> +	local_irq_restore(flags);
> +
> +	pr_info("mshv: hypervisor using %s\n",
> scheduler_type_to_string(hv_scheduler_type));

Nit: In this file we are using two styles of prints, few are appended with
"mshv:" and few with "__func__".  It's better to have a single style
for one module.



More information about the linux-arm-kernel mailing list