From nobody Sun May 10 06:26:31 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E02AF1AAA2C; Mon, 30 Dec 2024 18:09:43 +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=1735582185; cv=none; b=XqyW2qdLja8g7lsOD5Sk9e5Y4ET7rYv4R0IZICjv5eQlK++8U8ESTdzNb6J3kiqY76oii0DQpzcp6eYAxRdnhA8g1/c5Pb7nXiQjlToQj6Oqi8tv3lTiTu/FOxU5nCOpXWeKt6ArVQE/yEc35KUSeeXk+cBA/lograKVd2j0+1c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735582185; c=relaxed/simple; bh=q1kkFkBG+MDcXdsQLHGr+JLc+o4F3AcSoiEu5nL8GYI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Nt6/wfxPZ0pAipmItykV/Lrnv2EadfQl7hnTZmvBN87ZV1v3DiS6yChBhGMvOqxEejd3156SInQNmn/liJFguxZz1dUQPxXSRUHJBbG59ai3yh0zyuh4jdQw9alJZnLiltsomkkSVXPTImZkJKvHO0CDoO8ad88jBMJPFLEEQ/M= 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=Aqhvdvb8; 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="Aqhvdvb8" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id 4D6CA205A750; Mon, 30 Dec 2024 10:09:43 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4D6CA205A750 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1735582183; bh=V3r7eiTyEw6zyMZkhiaqTwssurL0nihzW0DLTQHyZ1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Aqhvdvb8GML83Zx84fLw+ha4O9T/xW5a0pOQIdPk8pOnlC+imkJuRpZAJj8EUmppi P7LJI439b9oESPTzZITE8c18+fmxQARdJ9FYSRhF87SjRbkLwUOkn1v5BJp95jXs7k b8LC4Nx3tfjrAHsMHYKu6RY3yxD+XLg03AeTbE68= From: Roman Kisel To: hpa@zytor.com, kys@microsoft.com, bp@alien8.de, dave.hansen@linux.intel.com, decui@microsoft.com, eahariha@linux.microsoft.com, haiyangz@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, nunodasneves@linux.microsoft.com, tglx@linutronix.de, tiala@microsoft.com, wei.liu@kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, ssengar@microsoft.com, sunilmut@microsoft.com, vdso@hexbites.dev Subject: [PATCH v5 1/5] hyperv: Define struct hv_output_get_vp_registers Date: Mon, 30 Dec 2024 10:09:37 -0800 Message-Id: <20241230180941.244418-2-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241230180941.244418-1-romank@linux.microsoft.com> References: <20241230180941.244418-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is no definition of the output structure for the GetVpRegisters hypercall. Hence, using the hypercall is not possible when the output value has some structure to it. Even getting a datum of a primitive type reads as ad-hoc without that definition. Define struct hv_output_get_vp_registers to enable using the GetVpRegisters hypercall. Make provisions for all supported architectures. No functional changes. Signed-off-by: Roman Kisel --- include/hyperv/hvgdk_mini.h | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/include/hyperv/hvgdk_mini.h b/include/hyperv/hvgdk_mini.h index db3d1aaf7330..e8e3faa78e15 100644 --- a/include/hyperv/hvgdk_mini.h +++ b/include/hyperv/hvgdk_mini.h @@ -1068,6 +1068,35 @@ union hv_dispatch_suspend_register { } __packed; }; =20 +union hv_arm64_pending_interruption_register { + u64 as_uint64; + struct { + u64 interruption_pending : 1; + u64 interruption_type : 1; + u64 reserved : 30; + u32 error_code; + } __packed; +}; + +union hv_arm64_interrupt_state_register { + u64 as_uint64; + struct { + u64 interrupt_shadow : 1; + u64 reserved : 63; + } __packed; +}; + +union hv_arm64_pending_synthetic_exception_event { + u64 as_uint64[2]; + struct { + u32 event_pending : 1; + u32 event_type : 3; + u32 reserved : 4; + u32 exception_type; + u64 context; + } __packed; +}; + union hv_x64_interrupt_state_register { u64 as_uint64; struct { @@ -1103,8 +1132,28 @@ union hv_register_value { union hv_explicit_suspend_register explicit_suspend; union hv_intercept_suspend_register intercept_suspend; union hv_dispatch_suspend_register dispatch_suspend; +#ifdef CONFIG_ARM64 + union hv_arm64_interrupt_state_register interrupt_state; + union hv_arm64_pending_interruption_register pending_interruption; +#endif +#ifdef CONFIG_X86 union hv_x64_interrupt_state_register interrupt_state; union hv_x64_pending_interruption_register pending_interruption; +#endif + union hv_arm64_pending_synthetic_exception_event pending_synthetic_except= ion_event; +}; + +/* + * NOTE: Linux helper struct - NOT from Hyper-V code. + * DECLARE_FLEX_ARRAY() needs to be wrapped into + * a structure and have at least one more member besides + * DECLARE_FLEX_ARRAY. + */ +struct hv_output_get_vp_registers { + struct { + DECLARE_FLEX_ARRAY(union hv_register_value, values); + struct {} values_end; + }; }; =20 #if defined(CONFIG_ARM64) --=20 2.34.1 From nobody Sun May 10 06:26:31 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 220581ACEC1; Mon, 30 Dec 2024 18:09:44 +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=1735582185; cv=none; b=eHPeTn0FSF0DISJpS6/LhZi3P7jkg6AfOyUuYzaRLSxVJ6kujHN1W7e157SpauHC/p8CFVy6N+EftMxehVYnkO0H79hXusNr6RatRLnDfgK/wNc48jkKnr9NElcZHSYw03N3yOopt/d6QEtFSd7a1dUisN+Rh9BQf3u59rFWt1c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735582185; c=relaxed/simple; bh=lnd2bW+mEWgcyHDSppSYygV+U0xWEf88EcV6/K+ANU0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tOZdyUqhNzEAuCFYqaUlKxwdbsGWKXh4HSGRq2jA8G7RrV5kF1RxPCRXUwFbyzP6Bjtb/aU4KBF9KYSAXnhYz4oyWa7YcsyGpwSnmi8fga1ItdU3bRWHzD3hVBmiu/8z5RhBOT/IV2iWcaV0PrK9AU58k2DtBJBeFYaQNLMg1a0= 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=HSsEE1lu; 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="HSsEE1lu" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id 8E987205A751; Mon, 30 Dec 2024 10:09:43 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 8E987205A751 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1735582183; bh=Klz7yPqD0Eckrc+SA7sLQw6zV3C1NtM+cNODXl922cM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HSsEE1lul2GGlCXRsnarXApL+W1iRn9Az1Ak2Sfh0FqPX1zB7Gmm7QC6ajEiSxea7 LZNc+jWhnHpGnyv8NouN9W0bMBUN4Rsk9PGUouwECWNcDnnxTGJqUkmhKaABQehcNr 9JX/lAz20dJu+c0u2Ss2L6jnwxn/bu9j36ts90go= From: Roman Kisel To: hpa@zytor.com, kys@microsoft.com, bp@alien8.de, dave.hansen@linux.intel.com, decui@microsoft.com, eahariha@linux.microsoft.com, haiyangz@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, nunodasneves@linux.microsoft.com, tglx@linutronix.de, tiala@microsoft.com, wei.liu@kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, ssengar@microsoft.com, sunilmut@microsoft.com, vdso@hexbites.dev Subject: [PATCH v5 2/5] hyperv: Fix pointer type in get_vtl(void) Date: Mon, 30 Dec 2024 10:09:38 -0800 Message-Id: <20241230180941.244418-3-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241230180941.244418-1-romank@linux.microsoft.com> References: <20241230180941.244418-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Commit bc905fa8b633 ("hyperv: Switch from hyperv-tlfs.h to hyperv/hvhdk.h") changed the type of the output pointer to `struct hv_register_assoc` from `struct hv_get_vp_registers_output`. That leads to an incorrect computation, and leaves the system broken. Use the correct pointer type for the output of the GetVpRegisters hypercall. Signed-off-by: Roman Kisel Reviewed-by: Nuno Das Neves --- arch/x86/hyperv/hv_init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c index 9e5e8328df6b..f82d1aefaa8a 100644 --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c @@ -416,13 +416,13 @@ static u8 __init get_vtl(void) { u64 control =3D HV_HYPERCALL_REP_COMP_1 | HVCALL_GET_VP_REGISTERS; struct hv_input_get_vp_registers *input; - struct hv_register_assoc *output; + struct hv_output_get_vp_registers *output; unsigned long flags; u64 ret; =20 local_irq_save(flags); input =3D *this_cpu_ptr(hyperv_pcpu_input_arg); - output =3D (struct hv_register_assoc *)input; + output =3D (struct hv_output_get_vp_registers *)input; =20 memset(input, 0, struct_size(input, names, 1)); input->partition_id =3D HV_PARTITION_ID_SELF; @@ -432,7 +432,7 @@ static u8 __init get_vtl(void) =20 ret =3D hv_do_hypercall(control, input, output); if (hv_result_success(ret)) { - ret =3D output->value.reg8 & HV_X64_VTL_MASK; + ret =3D output->values[0].reg8 & HV_X64_VTL_MASK; } else { pr_err("Failed to get VTL(error: %lld) exiting...\n", ret); BUG(); --=20 2.34.1 From nobody Sun May 10 06:26:31 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 690551ACEC4; Mon, 30 Dec 2024 18:09:44 +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=1735582185; cv=none; b=sCFhFjN80oBKSQBQOorCu9arm6sxAAIUemzrsS1l7RdAulNTk6uH9eGp3Q6YDHruJJ11tBgne846b1a7Rm6Wpkq2FS2MQzdpH07DJDUfuvEny1ZdEzl1wM2C0apfOxUimloa1C1vkdonV7MAcNY1uafMpWg1n+fcTcaFuQsilbA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735582185; c=relaxed/simple; bh=EQ8qFQw69BNvqk+V1uNigvZI2v/00r9VxWFjPaIcGIk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kNdXugDaO5biw9/vhLbM624S6xzK6xsP9aHV/n5wn1GcBUgy6XOhJTmM2B+BHREK0FuqbMl7PSxFbHiZ4M837FZGAWI2TuEJSMlb30Ihk/y1jqClw86C/yAbSdezUFxlvGnceTFD00D6bowTGaoZd2YI9hj0TArOb0+HfKWVMyI= 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=XSe/fGTa; 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="XSe/fGTa" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id CE02D205A752; Mon, 30 Dec 2024 10:09:43 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com CE02D205A752 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1735582184; bh=VeuGFw7q+Hc9N0d/4qq8GlAi1foElxnJ5LOQzooRJZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XSe/fGTaSfpxFEUW2oQ1pNfJEGJoiFVxM/jNqfsbHdtFcRJv34sNok4ahNkGDc41c AOGcHmQw1IHU/wuVo25XfhTpkuJs2rqPfaf4HzPjDOZ+stmYjDdzATpIfdrUUsreAj uKRFqu+17IaF46ChzmWR6TBIo31gKd0qiKmtZaEk= From: Roman Kisel To: hpa@zytor.com, kys@microsoft.com, bp@alien8.de, dave.hansen@linux.intel.com, decui@microsoft.com, eahariha@linux.microsoft.com, haiyangz@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, nunodasneves@linux.microsoft.com, tglx@linutronix.de, tiala@microsoft.com, wei.liu@kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, ssengar@microsoft.com, sunilmut@microsoft.com, vdso@hexbites.dev Subject: [PATCH v5 3/5] hyperv: Enable the hypercall output page for the VTL mode Date: Mon, 30 Dec 2024 10:09:39 -0800 Message-Id: <20241230180941.244418-4-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241230180941.244418-1-romank@linux.microsoft.com> References: <20241230180941.244418-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Due to the hypercall page not being allocated in the VTL mode, the code resorts to using a part of the input page. Allocate the hypercall output page in the VTL mode thus enabling it to use it for output and share code with dom0. Signed-off-by: Roman Kisel --- drivers/hv/hv_common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c index c6ed3ba4bf61..c983cfd4d6c0 100644 --- a/drivers/hv/hv_common.c +++ b/drivers/hv/hv_common.c @@ -340,7 +340,7 @@ int __init hv_common_init(void) BUG_ON(!hyperv_pcpu_input_arg); =20 /* Allocate the per-CPU state for output arg for root */ - if (hv_root_partition) { + if (hv_root_partition || IS_ENABLED(CONFIG_HYPERV_VTL_MODE)) { hyperv_pcpu_output_arg =3D alloc_percpu(void *); BUG_ON(!hyperv_pcpu_output_arg); } @@ -435,7 +435,7 @@ int hv_common_cpu_init(unsigned int cpu) void **inputarg, **outputarg; u64 msr_vp_index; gfp_t flags; - int pgcount =3D hv_root_partition ? 2 : 1; + const int pgcount =3D (hv_root_partition || IS_ENABLED(CONFIG_HYPERV_VTL_= MODE)) ? 2 : 1; void *mem; int ret; =20 @@ -453,7 +453,7 @@ int hv_common_cpu_init(unsigned int cpu) if (!mem) return -ENOMEM; =20 - if (hv_root_partition) { + if (hv_root_partition || IS_ENABLED(CONFIG_HYPERV_VTL_MODE)) { outputarg =3D (void **)this_cpu_ptr(hyperv_pcpu_output_arg); *outputarg =3D (char *)mem + HV_HYP_PAGE_SIZE; } --=20 2.34.1 From nobody Sun May 10 06:26:31 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 918D61ACED2; Mon, 30 Dec 2024 18:09:44 +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=1735582185; cv=none; b=O8VxU6+hgSmvdtIswyI8Lc5kdIsS+9oXLZkM/Gxx8xN/TAtOka5EbI1hpi1Q78KXpnR5MBu3fr82Bbi/wW7snEbhtalj8sdFILeD7Za+OEppq9S87aDemdUQNgLJB9RWznjSVcYyI5aYg8WRpEIk6Z9o4qXbWZYFG7oYj6qg/74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735582185; c=relaxed/simple; bh=zBviSLS9kQ/mVfxhHrN0UYzdLgDlBknZGPuabwGuqt8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bAg3MrdCKPE9U78EUJbvLnaHDPqDyfe/v/136ekxR6OPHODYlYkXLAIGPxtSU+WESwGJt85jhYycBxVOiG0aZedpaf+orRp1vteCBe5ptXY9p9U745RjPHhXfLmjRGBty4+LeVONA3EfnnjNqIVYL6eP11PgWbdaDnh0hPtWBzs= 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=SoF8AlMu; 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="SoF8AlMu" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id 18B77206ADF4; Mon, 30 Dec 2024 10:09:44 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 18B77206ADF4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1735582184; bh=ciyKd7rGPt5CsHeucplU1xQpzjYtFfnwDF7tcKA0qZ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SoF8AlMu8oMdfSP75lCMFgxRCijSeXNF9MubO6LrOHA8iirLpFuImb8qM/Zblmfae woq5oRv1DUH5+GqVDSn+0F5fIPoJsLIahrUm9YZxKVOaN52FOnTCdupQ4sswuU0NVf 2l8/glopMZ9KAm+qXZJDraGbYkdTFol79Og09//M= From: Roman Kisel To: hpa@zytor.com, kys@microsoft.com, bp@alien8.de, dave.hansen@linux.intel.com, decui@microsoft.com, eahariha@linux.microsoft.com, haiyangz@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, nunodasneves@linux.microsoft.com, tglx@linutronix.de, tiala@microsoft.com, wei.liu@kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, ssengar@microsoft.com, sunilmut@microsoft.com, vdso@hexbites.dev Subject: [PATCH v5 4/5] hyperv: Do not overlap the hvcall IO areas in get_vtl() Date: Mon, 30 Dec 2024 10:09:40 -0800 Message-Id: <20241230180941.244418-5-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241230180941.244418-1-romank@linux.microsoft.com> References: <20241230180941.244418-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Top-Level Functional Specification for Hyper-V, Section 3.6 [1, 2], disallows overlapping of the input and output hypercall areas, and get_vtl(void) does overlap them. Use the output hypercall page of the current vCPU for the hypercall. [1] https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/tlf= s/hypercall-interface [2] https://github.com/MicrosoftDocs/Virtualization-Documentation/tree/main= /tlfs Fixes: 8387ce06d70b ("x86/hyperv: Set Virtual Trust Level in VMBus init mes= sage") Signed-off-by: Roman Kisel --- arch/x86/hyperv/hv_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c index f82d1aefaa8a..173005e6a95d 100644 --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c @@ -422,7 +422,7 @@ static u8 __init get_vtl(void) =20 local_irq_save(flags); input =3D *this_cpu_ptr(hyperv_pcpu_input_arg); - output =3D (struct hv_output_get_vp_registers *)input; + output =3D *this_cpu_ptr(hyperv_pcpu_output_arg); =20 memset(input, 0, struct_size(input, names, 1)); input->partition_id =3D HV_PARTITION_ID_SELF; --=20 2.34.1 From nobody Sun May 10 06:26:31 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6B3FB1B0410; Mon, 30 Dec 2024 18:09:45 +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=1735582186; cv=none; b=V3zV81pzbHyUOJsUvlFkFD3+lxqjy82J9Wh6zmIpijNgmBBnVY6k/A1OIOsubKhvWxr9FQdCTQ09tiK7uB+V1ltZ61uMaQ8v/WnHG/MS9tZrJIZmRVI1c456UZnFQth6yjBB7K0whft6cOIeQmTQR8HE+4/Zj2uk5EzDpL2AEOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735582186; c=relaxed/simple; bh=vbNPknnBFyyaONbs72riXQ40KDNtAJSol5gXMtlxeHo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tUPLsi+vwzhbntnAjUCuCC3jpy3MTbzDogcLJ0jRgK2xex3BHyde2nJnC0HoA6hYonKpuNJmhzQXZbz9OaCiahvK0qNuy+AMyraZfIezXdofDuH6ecdHCTvVtXNIBzZIo4hMqp8Y+YNxjQfXQm4H4CCRImmYbOefL8s2XcGFulc= 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=lXLwhj51; 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="lXLwhj51" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id 5949B23718AC; Mon, 30 Dec 2024 10:09:44 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5949B23718AC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1735582184; bh=k2UmY66ftWXp8kYKen18EASwtXppJQxpkXiN3eKJ4Ns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lXLwhj51YWPGMmZf80FPl80UqBBuSoZLiiKgROcTLU1WyxtJlT9pVi09kLcb20L7c DlACxz6rSU1i1obrLX56f5Gxn44vqhlokR9zR4x2z/npGSuh/2Mz+LSGJubsB/h4/V ttAnp6oS5vAhFOX/7hEVz7foade/xbfyOTd5GCbs= From: Roman Kisel To: hpa@zytor.com, kys@microsoft.com, bp@alien8.de, dave.hansen@linux.intel.com, decui@microsoft.com, eahariha@linux.microsoft.com, haiyangz@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, nunodasneves@linux.microsoft.com, tglx@linutronix.de, tiala@microsoft.com, wei.liu@kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, ssengar@microsoft.com, sunilmut@microsoft.com, vdso@hexbites.dev Subject: [PATCH v5 5/5] hyperv: Do not overlap the hvcall IO areas in hv_vtl_apicid_to_vp_id() Date: Mon, 30 Dec 2024 10:09:41 -0800 Message-Id: <20241230180941.244418-6-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241230180941.244418-1-romank@linux.microsoft.com> References: <20241230180941.244418-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Top-Level Functional Specification for Hyper-V, Section 3.6 [1, 2], disallows overlapping of the input and output hypercall areas, and hv_vtl_apicid_to_vp_id() overlaps them. Use the output hypercall page of the current vCPU for the hypercall. [1] https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/tlf= s/hypercall-interface [2] https://github.com/MicrosoftDocs/Virtualization-Documentation/tree/main= /tlfs Reported-by: Michael Kelley Closes: https://lore.kernel.org/lkml/SN6PR02MB4157B98CD34781CC87A9D921D40D2= @SN6PR02MB4157.namprd02.prod.outlook.com/ Signed-off-by: Roman Kisel --- arch/x86/hyperv/hv_vtl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/hyperv/hv_vtl.c b/arch/x86/hyperv/hv_vtl.c index 04775346369c..4e1b1e3b5658 100644 --- a/arch/x86/hyperv/hv_vtl.c +++ b/arch/x86/hyperv/hv_vtl.c @@ -189,7 +189,7 @@ static int hv_vtl_apicid_to_vp_id(u32 apic_id) input->partition_id =3D HV_PARTITION_ID_SELF; input->apic_ids[0] =3D apic_id; =20 - output =3D (u32 *)input; + output =3D *this_cpu_ptr(hyperv_pcpu_output_arg); =20 control =3D HV_HYPERCALL_REP_COMP_1 | HVCALL_GET_VP_ID_FROM_APIC_ID; status =3D hv_do_hypercall(control, input, output); --=20 2.34.1