From nobody Fri Oct 3 15:37:45 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A0C9D190477; Fri, 29 Aug 2025 00:43:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756428237; cv=none; b=grhsMbPbxZtiNMvcEChFyr3ZuYWfbiIbVuTJLeEYzzjkowhj/J6OHsHWpO9hofAdTvXCTRmAe9w/WrsGfRh3x6yObmVaAsRPJzELr7tcrGT1XGTlH2uvhGTG+lpLbx4PUNnV9ED8kHBt0EqQrYsxS7KMKZymY9aIzGRMlCnLU4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756428237; c=relaxed/simple; bh=n2ZLL7BuPP8iw/WYrr7IxLhVe6bEgdF9a/4RZFsFVqs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=c3Eioh3waPO9H8J8PTeYH3nzEjIo53EvjPhQd7IB3I52Ybah2SCDdCanwxdURXZ0b7S/gzG9wM1w24IEgns+/sd6X8Ct9kJUgcGizn8lOfvOBWt5b8SDp9r5Va2RGvTObd7FYs4N4OT73nkwji6Bze/Ot/6JjXeCQYG1wfui0+Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=mUcZ7Nrn; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="mUcZ7Nrn" Received: by linux.microsoft.com (Postfix, from userid 1032) id 5751A2110814; Thu, 28 Aug 2025 17:43:55 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5751A2110814 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1756428235; bh=NsMPM8GP79gm+90qKi0vu2XTz2eD+i9B727sNuU/f6I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mUcZ7NrnktniwWl1eoFA/XElG0CmluMn+J8MpJ1h8oN/U81/h44qnWx3hc5KHyeFb FEGOiiQxWDBXLmvyAx4i28YNC24RGaItpwof2g0Huv/jWrjamjy2dTdeUPVcyGl0i3 ReoEUadptsYSR85TUGHjWNmVqb5T/Ua7yIsv2loU= From: Nuno Das Neves To: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, mhklinux@outlook.com, decui@microsoft.com, paekkaladevi@linux.microsoft.com, Nuno Das Neves Subject: [PATCH 2/6] mshv: Ignore second stats page map result failure Date: Thu, 28 Aug 2025 17:43:46 -0700 Message-Id: <1756428230-3599-3-git-send-email-nunodasneves@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1756428230-3599-1-git-send-email-nunodasneves@linux.microsoft.com> References: <1756428230-3599-1-git-send-email-nunodasneves@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Purna Pavan Chandra Aekkaladevi Some versions of the hypervisor do not support HV_STATUS_AREA_PARENT and return HV_STATUS_INVALID_PARAMETER for the second stats page mapping request. This results a failure in module init. Instead of failing, gracefully fall back to populating stats_pages[HV_STATS_AREA_PARENT] with the already-mapped stats_pages[HV_STATS_AREA_SELF]. Signed-off-by: Purna Pavan Chandra Aekkaladevi Signed-off-by: Nuno Das Neves Reviewed-by: Tianyu Lan --- drivers/hv/mshv_root_hv_call.c | 43 ++++++++++++++++++++++++++++++---- drivers/hv/mshv_root_main.c | 3 +++ 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/drivers/hv/mshv_root_hv_call.c b/drivers/hv/mshv_root_hv_call.c index c9c274f29c3c..1c38576a673c 100644 --- a/drivers/hv/mshv_root_hv_call.c +++ b/drivers/hv/mshv_root_hv_call.c @@ -724,6 +724,24 @@ hv_call_notify_port_ring_empty(u32 sint_index) return hv_result_to_errno(status); } =20 +static int +hv_stats_get_area_type(enum hv_stats_object_type type, + const union hv_stats_object_identity *identity) +{ + switch (type) { + case HV_STATS_OBJECT_HYPERVISOR: + return identity->hv.stats_area_type; + case HV_STATS_OBJECT_LOGICAL_PROCESSOR: + return identity->lp.stats_area_type; + case HV_STATS_OBJECT_PARTITION: + return identity->partition.stats_area_type; + case HV_STATS_OBJECT_VP: + return identity->vp.stats_area_type; + } + + return -EINVAL; +} + int hv_call_map_stat_page(enum hv_stats_object_type type, const union hv_stats_object_identity *identity, void **addr) @@ -732,7 +750,7 @@ int hv_call_map_stat_page(enum hv_stats_object_type typ= e, struct hv_input_map_stats_page *input; struct hv_output_map_stats_page *output; u64 status, pfn; - int ret =3D 0; + int hv_status, ret =3D 0; =20 do { local_irq_save(flags); @@ -747,11 +765,28 @@ int hv_call_map_stat_page(enum hv_stats_object_type t= ype, pfn =3D output->map_location; =20 local_irq_restore(flags); - if (hv_result(status) !=3D HV_STATUS_INSUFFICIENT_MEMORY) { - ret =3D hv_result_to_errno(status); + + hv_status =3D hv_result(status); + if (hv_status !=3D HV_STATUS_INSUFFICIENT_MEMORY) { if (hv_result_success(status)) break; - return ret; + + /* + * Some versions of the hypervisor do not support the + * PARENT stats area. In this case return "success" but + * set the page to NULL. The caller checks for this + * case instead just uses the SELF area. + */ + if (hv_stats_get_area_type(type, identity) =3D=3D HV_STATS_AREA_PARENT = && + hv_status =3D=3D HV_STATUS_INVALID_PARAMETER) { + pr_debug_once("%s: PARENT area type is unsupported\n", + __func__); + *addr =3D NULL; + return 0; + } + + hv_status_debug(status, "\n"); + return hv_result_to_errno(status); } =20 ret =3D hv_call_deposit_pages(NUMA_NO_NODE, diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c index bbdefe8a2e9c..56ababab57ce 100644 --- a/drivers/hv/mshv_root_main.c +++ b/drivers/hv/mshv_root_main.c @@ -929,6 +929,9 @@ static int mshv_vp_stats_map(u64 partition_id, u32 vp_i= ndex, if (err) goto unmap_self; =20 + if (!stats_pages[HV_STATS_AREA_PARENT]) + stats_pages[HV_STATS_AREA_PARENT] =3D stats_pages[HV_STATS_AREA_SELF]; + return 0; =20 unmap_self: --=20 2.34.1