From nobody Sun May 10 07:13:34 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 608FE1F3D3F; Fri, 27 Dec 2024 18:31:57 +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=1735324318; cv=none; b=kUDEiDp7W2ts8WuOkIFvyrrkYJ6eI/ku/bSq0pHj/1eKrx8iXZvtbw2ajHavMYjB2dwG4wBpoluDbzCkvzPufaAXfFc+4rlsNZhM4a1wOBsk6+XNJVTH/mNnvwT9bkwwiDJMgG0QMUSepK6WPZrYl2HWnar9pno0D1tiovxm590= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735324318; c=relaxed/simple; bh=4Jyuc+ffyw2DPcfTMSQ1RAZin8tjZuGQZQsUwjg4JRM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mZl8NuqnOkd0sgkY2cYejZAr0BdBMKLTQeIgJm3+ocJ1kcT6Ap4zsy6ICDbxMOXals6li2gMR4J9NOBtYIzRpkhemWRCS+oh91ItOi+7awYM8LrYwanJd2vQRA6v46YSIpjBOo3fEXeHkdH/SNMq2VzIO+eN5WBmOPh+5ZOBZ8U= 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=kJ0UAyzL; 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="kJ0UAyzL" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id ABEDE203EC3C; Fri, 27 Dec 2024 10:31:56 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com ABEDE203EC3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1735324316; bh=/ype7uZEpe5xHc678iTj/2AT9nHkiZEOccSLzIQb1I4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kJ0UAyzLCLcvujCLicUTafOri7Ih75fzDkcMoWY7zEZ4usZFibh+1wm8CIgH/uCnv SUHMbr5oTyt+tgMKlyUXhfQJsm7AZT7JwZPit0FlBfWKUTvH0jLOJQVcN7NGf3irBE q1698ABSjfOcovYfSvMloLgtoj9Ql9bQxCBxNgVw= 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 v4 1/5] hyperv: Define struct hv_output_get_vp_registers Date: Fri, 27 Dec 2024 10:31:51 -0800 Message-Id: <20241227183155.122827-2-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241227183155.122827-1-romank@linux.microsoft.com> References: <20241227183155.122827-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 Reviewed-by: Easwar Hariharan --- include/hyperv/hvgdk_mini.h | 65 +++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/include/hyperv/hvgdk_mini.h b/include/hyperv/hvgdk_mini.h index db3d1aaf7330..c2f5cc231dce 100644 --- a/include/hyperv/hvgdk_mini.h +++ b/include/hyperv/hvgdk_mini.h @@ -781,6 +781,8 @@ struct hv_timer_message_payload { __u64 delivery_time; /* When the message was delivered */ } __packed; =20 +#if defined(CONFIG_X86) + struct hv_x64_segment_register { u64 base; u32 limit; @@ -807,6 +809,8 @@ struct hv_x64_table_register { u64 base; } __packed; =20 +#endif + union hv_input_vtl { u8 as_uint8; struct { @@ -1068,6 +1072,41 @@ union hv_dispatch_suspend_register { } __packed; }; =20 +#if defined(CONFIG_ARM64) + +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; +}; + +#endif + +#if defined(CONFIG_X86) + union hv_x64_interrupt_state_register { u64 as_uint64; struct { @@ -1091,6 +1130,8 @@ union hv_x64_pending_interruption_register { } __packed; }; =20 +#endif + union hv_register_value { struct hv_u128 reg128; u64 reg64; @@ -1098,13 +1139,33 @@ union hv_register_value { u16 reg16; u8 reg8; =20 - struct hv_x64_segment_register segment; - struct hv_x64_table_register table; union hv_explicit_suspend_register explicit_suspend; union hv_intercept_suspend_register intercept_suspend; union hv_dispatch_suspend_register dispatch_suspend; +#if defined(CONFIG_X86) + struct hv_x64_segment_register segment; + struct hv_x64_table_register table; union hv_x64_interrupt_state_register interrupt_state; union hv_x64_pending_interruption_register pending_interruption; +#endif +#if defined(CONFIG_ARM64) + union hv_arm64_pending_interruption_register pending_interruption; + union hv_arm64_interrupt_state_register interrupt_state; + union hv_arm64_pending_synthetic_exception_event pending_synthetic_except= ion_event; +#endif +}; + +/* + * 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 07:13:34 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A30D71F8662; Fri, 27 Dec 2024 18:31:57 +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=1735324319; cv=none; b=nxjS6ym/qdpp+eppR2YsCP9NFDLOT/xteVL20lCtbU+HhblOWoOk+jn+QzRSxF76JGB2eAhLcZeRJ5f30xIEzUVQBxiNy2dUeqomVPUIgvSG1HQ2kNg8Oh+0/c4w164C82kFPW4aXCnMFa+maMh6I3WgPVWxdjCCTL20vJXC36c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735324319; c=relaxed/simple; bh=lnd2bW+mEWgcyHDSppSYygV+U0xWEf88EcV6/K+ANU0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kgsGMVk3kKLlglBEWcnAGjxvr7XjmGbOyOJ1lyUiBEV2bYmg+CSSmcY75gF9+QlzMi53Pgtcm1ql6rx8cB6CaPQcEMZTJnH8jYTX9HIisntXhqJ7WIdAlNgqvxrfGyVxAMRcT6wiaZyDgOMvlw952alWhnEXuf3+Idq9Vib+Ops= 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=r/y5tYhI; 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="r/y5tYhI" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id EBED3203EC3D; Fri, 27 Dec 2024 10:31:56 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com EBED3203EC3D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1735324317; bh=Klz7yPqD0Eckrc+SA7sLQw6zV3C1NtM+cNODXl922cM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r/y5tYhI8kccOiIXSQnc1k0ZeQaoCrrSwwCm5HgE5r5l1Yt2PafC286+Jxba/1I5y fko71pLGAA4sE1CYgc67sQVPhjGWx49CLhsnLCVZPc//RSurP3qR0pc4bRmSsnc90a eACnksnlkh1T9U+wx8doPdrJp59LE6GY/8qQF0x4= 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 v4 2/5] hyperv: Fix pointer type in get_vtl(void) Date: Fri, 27 Dec 2024 10:31:52 -0800 Message-Id: <20241227183155.122827-3-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241227183155.122827-1-romank@linux.microsoft.com> References: <20241227183155.122827-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: Easwar Hariharan --- 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 07:13:34 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A313B1F8693; Fri, 27 Dec 2024 18:31:57 +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=1735324319; cv=none; b=ERANNn/sT5DVWNbL/nLG4NY0tIRCi04FC5ORfWD4uu+9cf9CIGBNvoBkN2C2dPZyTInWLU5khwIWq9yWp+FrKGsHpPrPbF9Ls9wFFRfXAKbe9iei7EAanrqW4S2adNTpJQ14uesM2Jt+QqCBzlWsYUr9LQDvmLWAwpqHSRL46mI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735324319; c=relaxed/simple; bh=EQ8qFQw69BNvqk+V1uNigvZI2v/00r9VxWFjPaIcGIk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OqCQrPItSo+XmeIbJNa76D4uY540R8ZbSUjhYyWxOHRrAfdJPZSl/gUPkYOXqXLoJfFEILjrplyDmdBWFe8cJAGJj3WnLgY4IPu7G8Qm1+zpLIfXLynhmOnSINbYwqmDgkWFGFcviKPqb3miNNb3uAgt8EfH7YGbhiiMHr87jaA= 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=BhngCs8g; 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="BhngCs8g" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id 377B6203EC3E; Fri, 27 Dec 2024 10:31:57 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 377B6203EC3E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1735324317; bh=VeuGFw7q+Hc9N0d/4qq8GlAi1foElxnJ5LOQzooRJZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BhngCs8gX58ll6YdEPAPAtnJ7AcuOTllcmC0l38vT9n+i5i6HnOdw8mZ2pHy87Pyd bbvm9CxmK65oGyM3M1pVkWTPrMekd9PZ0xBmaORXIgr5WVCFI6Ce17+rFI1HDSVjQJ SWIGgoP2ieizgFx7F2lLCzpg4ssdWiho05YBx7wg= 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 v4 3/5] hyperv: Enable the hypercall output page for the VTL mode Date: Fri, 27 Dec 2024 10:31:53 -0800 Message-Id: <20241227183155.122827-4-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241227183155.122827-1-romank@linux.microsoft.com> References: <20241227183155.122827-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 Reviewed-by: Easwar Hariharan --- 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 07:13:34 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5CA213BAEE; Fri, 27 Dec 2024 18:31:57 +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=1735324319; cv=none; b=r6UHcsBEw33MJuZjO6BnZh0AInOzmGVrHSVPOqdMf/7CeW3tGZI5HYcMO9roC0sGiiAiWUwRDWd7rk8A99M8ZZhD4uGuCsK56oVvLVKq8Gq534a+hdRFDox7GlZGFSEtKAbVKBJJpdF4bFpBRGLsbUX0cV6RqudKHS2RMDB1N5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735324319; c=relaxed/simple; bh=zBviSLS9kQ/mVfxhHrN0UYzdLgDlBknZGPuabwGuqt8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gTY+eblUOmNSac0GsX+xiGQoTATwfNDOm9X8rQVR+xVS5qy05f+fcJ26vusfVh0IKKNbRjm7qzcYU8eff8tKHmrBOjJPAU5X9G1unou1+ujnklDomNhsAg4pAg3pMqGtCYlqUFq0RbjyFazMYF+cQS54gPahRtAySY7GbzPLPT4= 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=JlR/IeFf; 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="JlR/IeFf" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id 777E1203EC3F; Fri, 27 Dec 2024 10:31:57 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 777E1203EC3F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1735324317; bh=ciyKd7rGPt5CsHeucplU1xQpzjYtFfnwDF7tcKA0qZ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JlR/IeFfzQvscg53Mtf1iQLxmzWMfW+YkW76C/jz/uUiHlyJcc+SwiEqcDvzmjXES RAVyoAGzHgLxfrpbkp2S28Uydtq6Lw6PIOKrvSFzAuzoIavQ47ZlGIhx4d0zopaxAG uRMRYquRTln4+vSln4U9qutBaKgtIh3PFP7PkBpw= 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 v4 4/5] hyperv: Do not overlap the hvcall IO areas in get_vtl() Date: Fri, 27 Dec 2024 10:31:54 -0800 Message-Id: <20241227183155.122827-5-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241227183155.122827-1-romank@linux.microsoft.com> References: <20241227183155.122827-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 Reviewed-by: Easwar Hariharan --- 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 07:13:34 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5E311F8ACB; Fri, 27 Dec 2024 18:31:58 +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=1735324320; cv=none; b=l5OsBeHrJjkG6jmb0L/bLHEhvqqeL4BscUNKPIveTU2DFcIBfudYSeXr0j13ZOtQnZaCcCAc1I8lwnHs6GOh04PGjiYxrwpBg0wu8LyG3eaUP1k+aNR1JgEVQ/Nox3L1Hc0uRM8ZQxiiALRU80ENpSlJDRA+lK5kI5B/j0XayVQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735324320; c=relaxed/simple; bh=vbNPknnBFyyaONbs72riXQ40KDNtAJSol5gXMtlxeHo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QOUIC8cBv2voBpRcWL0uBEbBULFXXfvaGcanhZ0VE7Gw1H5O6WuOIzbM/o/DmM1c5m3rpZk6/x90tkwACzfSW8YgeZlOCReISVsAUJdIJpTuhaWj+g3giBqRRGbn6vfVUVWSsu0v8prvBMtb1d8aGeIZRw25ez1vI88p3UYte1k= 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=ROoZBgoC; 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="ROoZBgoC" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id B5E752047212; Fri, 27 Dec 2024 10:31:57 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B5E752047212 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1735324317; bh=k2UmY66ftWXp8kYKen18EASwtXppJQxpkXiN3eKJ4Ns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ROoZBgoCsuxebOtttz/BV8nVsapLUpAaESKlLl0P9CsZNBvwyEO3wA2MWwRX0Mgwf LdzhdCSNvTJejSt87tYmS6+6ASZJ37+2T6zigEG3JOvNJ/LLQJeZJ21PpVAut6OUwS PovsslUcd9jjkTy/2tczZ1L7/ZvGeVabOnVqQgMQ= 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 v4 5/5] hyperv: Do not overlap the hvcall IO areas in hv_vtl_apicid_to_vp_id() Date: Fri, 27 Dec 2024 10:31:55 -0800 Message-Id: <20241227183155.122827-6-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241227183155.122827-1-romank@linux.microsoft.com> References: <20241227183155.122827-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 Reviewed-by: Easwar Hariharan --- 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