From nobody Tue Feb 10 04:23:27 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B588413C80D; Thu, 26 Dec 2024 21:31:12 +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=1735248674; cv=none; b=ox/m0We0cyCEpgzD9o0yIfTmaFVhu5l6NgFvCw6S/EyN1+qZPoisflcrRPAfl4CcNAcl3DXOoc88UqJ+4qDzCTYZtrr/hJsLCV4dIc/mXaBSSiQHfFMu7MJyzNSdjW8sLgPQMBITZCPO/+Y8H3S7opSijCjThiN17KwmjytOYDE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735248674; c=relaxed/simple; bh=NRkCjRnkhySE+BcClf+onZvPISWdYGLXxqfdEBq6MW4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OGa9kvP1JQfSj/8sco+EpcBCfcAQOG7Pvy+PGBnxiK3q4cE8b52fgQ06i8QnYR+VN0A4SK9kA5M0oMUJmB/mclamwleApnRWe8rh/h8RWdz02JbjWtyDuRZgnqRh229SYuR1iKuwr5t74WByA0fucUeYb719D30YErc8ICnDW54= 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=mCP1RPIn; 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="mCP1RPIn" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id 356FB203EC25; Thu, 26 Dec 2024 13:31:12 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 356FB203EC25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1735248672; bh=ry0dde5x4r+6U0CVAjvuGCMTA9d6rF8pmhm+rOPKAfo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mCP1RPInqFse7xfQ8xBnIe7QVRvyzxoD8dEJZf2ez5/3XVjnXldr1EmhgKvZssouz InaPnf81lEeBoiyZSi9zDiEGIEKupM7eiL9gn9cyfkzNJiseFQql0785+fFJ6QKcOr fcxYukrbNjqUkmtvcNchBz5GHM1nHBXXvm+V5564= 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 v3 1/5] hyperv: Define struct hv_output_get_vp_registers Date: Thu, 26 Dec 2024 13:31:06 -0800 Message-Id: <20241226213110.899497-2-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241226213110.899497-1-romank@linux.microsoft.com> References: <20241226213110.899497-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 | 58 +++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/include/hyperv/hvgdk_mini.h b/include/hyperv/hvgdk_mini.h index db3d1aaf7330..31c11550af73 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,26 @@ 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; +#elif 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; +#else + #error "This architecture is not supported" +#endif +}; + +/* NOTE: Linux helper struct - NOT from Hyper-V code */ +struct hv_output_get_vp_registers { + DECLARE_FLEX_ARRAY(union hv_register_value, values); }; =20 #if defined(CONFIG_ARM64) --=20 2.34.1 From nobody Tue Feb 10 04:23:27 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 126101411EB; Thu, 26 Dec 2024 21:31:12 +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=1735248674; cv=none; b=of28iS+XYd9lmxzXTPPkMhptv2e+8G0TwGWDsuvx+ZCbD03QcqMNAdq/+jYFHNKDiBYI+R2q0B7z2jfqkcAhOv/iy9xcsksFQUrKDj8kxQzLRPMi2qyz/hlCt6Qov3feHgMv+NzJlK+T1jy1umz7sui6pPr7M9Rb/PGvgAL4jZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735248674; c=relaxed/simple; bh=HoFMyxPQ4+vHjO5aNu8dprTKaB0BfQ/OCxXps0eLfws=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=djWwPaHvwq2ykd1sOO+4z4BVa6GDpbUzWMG/gEyI5IHPZZJThSBKf7D1q2y679A5qga6O/STLQqf7aKgzqW5ei9hEAGrHj9eZ0tRMA3gBNXDZm+kJwYdkPo5NGrfCF4YfOg1zGzDBSAIT/589uXFe861mNM/O0dLsjiwSWq+JxY= 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=r4da50yv; 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="r4da50yv" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id 75011203EC26; Thu, 26 Dec 2024 13:31:12 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 75011203EC26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1735248672; bh=n/7BbD0J/6ZyeZxeLEf6nxi13TKSTWUcLtaICTY9HoA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r4da50yvdLFm/hm9IPe7stmWuYCPFZSznNoHw50pT84OOCeEZktoEyF7qGm2TH0wR YXlMFLt/4SDr3LFidMuws6092zNnktJy0FPxY/CA+0/i/jiNyswb0knWspAp5eXKgA B9iX1fisSm8NOFZNE9vVd2I4SEmhTP2CPoTZhQVQ= 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 v3 2/5] hyperv: Fix pointer type for the output of the hypercall in get_vtl(void) Date: Thu, 26 Dec 2024 13:31:07 -0800 Message-Id: <20241226213110.899497-3-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241226213110.899497-1-romank@linux.microsoft.com> References: <20241226213110.899497-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 3cf2a227d666..ba469d6b8250 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 Tue Feb 10 04:23:27 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3FB9F142E77; Thu, 26 Dec 2024 21:31:13 +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=1735248674; cv=none; b=gPuzS2KO6JOl4IM+t0f52t0YsPvqXuXgc+h4fLqpUTojQ38HvuGW0spRys6ZI+rQxe4V/3Rn0Mx12IWFSEIfOuOtaLrK8yPaPfoo49H0grfvozFnXATyModwDI7CWGcfgNtF4wm7ddQlNe15RqrhxPzv6aNYuw42rUTkPp6tuYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735248674; c=relaxed/simple; bh=vLL1eBPjjd9wbqXKXWV5UrSjdrRV8iQA3u143kGbdKU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lWkWZk/Sj+D+4SvaLaahSvsUhL6EMCAuHaGqNhcD+pB/uRFnXqWXiNgHW8TyuCYBzPfeoIXYOnfhnNTBRGwxNfuCcJVhsrGi7Kny2VF814IVLhNTwQyAuPO1us4/LHWimraYmiO6tpjx1aBMTn9x8Sut6+cHjNg0aSknaVY8SLg= 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=F4tg5BYr; 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="F4tg5BYr" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id AEB22203EC27; Thu, 26 Dec 2024 13:31:12 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com AEB22203EC27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1735248672; bh=M0DbV+IuAkncb3w992OdU1iMW20x26mTm5JKuj17aCs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F4tg5BYrldKPXJyP0lgRQOrwGAnAaNL/nPD3LPNrdmLm88BbtYXItlIkCjzIvumA/ S/89qlm3OjQJQ6PLid3lCWz5KnjopKMXMjo9BOEhFSOk5W9zuD74iIArBKNtpTxIyx NcJXiNUsX9B7AzSI4SS1q2nOfBm2XTu6OjPl7Q2U= 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 v3 3/5] hyperv: Enable the hypercall output page for the VTL mode Date: Thu, 26 Dec 2024 13:31:08 -0800 Message-Id: <20241226213110.899497-4-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241226213110.899497-1-romank@linux.microsoft.com> References: <20241226213110.899497-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 c4fd07d9bf1a..5178beed6ca8 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 Tue Feb 10 04:23:27 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8314D146A9B; Thu, 26 Dec 2024 21:31:13 +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=1735248674; cv=none; b=Ci9gBj5nPKell6PPS/WqdUsD1OybNqph1UM1xUET+PoiZKuWYPqlyMnYa/EBWL1bmueh7jPHZwc6S5rEREm4eD6oqa32dLEnOZXhCXQur0iHnOQZHopjPOo1aOVXdW0yjvtR7wUpMaSML1t/scWbIp1vJ1axjKsDTuB2iAD6xAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735248674; c=relaxed/simple; bh=sR3Ef6BwCvtBM3nr55FMPN7FB8Oam8zRJ+m1vTQbmok=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lxvofwF/FKc20gZNtwo93WMoyACMIGweFAlHdNUC0HqHvQLz+wnNtdkPEOPQydZ6uahlmLObMAtowa8HGIMkFZKIB/tXnv1bFaTyptXdujmfRj7RTStvRUXpkS9LgXZMD0U1P78JN736qNsV+M5aAewxag+Bmp4isOvFRHE2pYU= 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=XCj3NBgo; 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="XCj3NBgo" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id ECBDD203EC28; Thu, 26 Dec 2024 13:31:12 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com ECBDD203EC28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1735248673; bh=F720DUCpejtJaA15Ay8bwdRJWpUJ3EJ3rEv0YprqleM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XCj3NBgo8u5x0wO08EzPjCzwnfnCNKrwIQxwPcyAO8egkWpa3E1rfZG5RMWbNQSgr g4ayJOZtfXzqSP3zFamEowbqz2mR1796i7hvOn4eOl1/3CWcrXISIFJa/aCziXYdPC utq2m5tur4Op1O5WT0Fp4U06Ylpwu4pvj2wh7kj0= 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 v3 4/5] hyperv: Do not overlap the hvcall IO areas in get_vtl() Date: Thu, 26 Dec 2024 13:31:09 -0800 Message-Id: <20241226213110.899497-5-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241226213110.899497-1-romank@linux.microsoft.com> References: <20241226213110.899497-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 ba469d6b8250..cf3f7d30fcdd 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 Tue Feb 10 04:23:27 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E0F61B21B7; Thu, 26 Dec 2024 21:31:14 +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=1735248676; cv=none; b=mMpGyx+D8BbOSpwlgdBfacRakPYOMDB01qQHb2t4sgZybPGv+flGpJXvMCMn96DwWOxOwPu+Ge7lcDxaXENdItG3D/6CRCHPFzKTu5EyVdKhDfZ6kSxcuNjvC4bHHHon2S0lpEzretHyVBfHlO8FkH5CZ+XK9zu3RwL9RCtjtoc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735248676; c=relaxed/simple; bh=ZkGeGz02JwKVdH+eTEJhF2x4i4dlGF1Fw4okzydrmuc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qrXBK0Ti90nws+K0/VnnhbmjfxkCLp6EKx5V1CM9z/mNGAlLuNNfhYNr+2lvtPH/ISOBVptW6OQ83vvvBFSkR7DJs0Gesgc4z7PLP4pAHfLuLUyWQpK2x6BStrSfeujytl+NWdq3nJB+r7ZNsTW2csnY0ASFp4lTvirlAoJ+rUI= 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=cg6DA7V7; 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="cg6DA7V7" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id 37623203EC29; Thu, 26 Dec 2024 13:31:13 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 37623203EC29 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1735248673; bh=XPqSsjJyd0TXcrSTZNSxY+Z9BhscJIkfl20tJAgG8gI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cg6DA7V7TN21ZRCRngJic2eSTDxQ9tqziu3YSST/OIVDH7opuV8gLmne4cYPjTjVK sWb3shstJKjZrKar0Oz+Z9BFhok91fTvCSKhAAahY9M8bt1xM7TIyfKn7MCs7wvgsE SkwPXOj+8gZZC58EvCYZkdqvJTeoC7T7+anQZ9dM= 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 v3 5/5] hyperv: Do not overlap the hvcall IO areas in hv_vtl_apicid_to_vp_id() Date: Thu, 26 Dec 2024 13:31:10 -0800 Message-Id: <20241226213110.899497-6-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241226213110.899497-1-romank@linux.microsoft.com> References: <20241226213110.899497-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 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..ec5716960162 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 (u32*)*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