From nobody Sun Feb 8 02:34:57 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C0E119D8A3; Wed, 8 Jan 2025 22:21:40 +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=1736374901; cv=none; b=kaViurQ+S7Ju36LBb0ORffsDfQZ/j6fT5/b3Yutz5EjLcniudk/DC1PL7xMx28t41fceiSK72mlr8cCY4rL/g0NwvSvslhdVEGzE2yrB4ddTROmaTvUh2+QzWs1zQztm+nf1giCyPQxsWlCMlX9rvUYauBB90CRvuogJidJLoRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736374901; c=relaxed/simple; bh=qcafMXV1WerZOL9+iELEnwK79b3MrkBNbG5ndg57gCI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AE07LER3jQHIEC1bxF3rUUTM18ml1PozK7oJBEJblsoWIglR5xFfv265AYfsZqUba9Ip9RxJc0FThjA5VPHjvzskS7SD0qpU9l221HL2DRtspIQa/9o1Eg+X5PawoPWkE6NGCjNJhfxlkb6rgSPnXqfvq4r2YhJAaJXGGzxJW6I= 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=qKXkSIBJ; 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="qKXkSIBJ" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id CB96B203E3AC; Wed, 8 Jan 2025 14:21:39 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com CB96B203E3AC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1736374900; bh=vwwWa71Zd50P34+bo52kV00/vqPmYY6R52Sz0B4X140=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qKXkSIBJNQYru0xoUE9y20f8XCr+s5p4r4lPYGKEf2WjCw+2EHWicqnW3v6VUzBz4 r+LAHql86rPrRUTPrUuOzveE3/VIkbxfjFyoLtyl+GLhvM/P2Ww6aEhCXS17t+aIJo FnDnj/dYQrbzBpOgkuBdNTQ2y4Nk595LA3o43NQQ= 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 v6 1/5] hyperv: Define struct hv_output_get_vp_registers Date: Wed, 8 Jan 2025 14:21:34 -0800 Message-Id: <20250108222138.1623703-2-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250108222138.1623703-1-romank@linux.microsoft.com> References: <20250108222138.1623703-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 | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/include/hyperv/hvgdk_mini.h b/include/hyperv/hvgdk_mini.h index db3d1aaf7330..4fffca9e16df 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; + u64 error_code : 32; + } __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 { + u8 event_pending : 1; + u8 event_type : 3; + u8 reserved : 4; + u8 rsvd[3]; + u64 context; + } __packed; +}; + union hv_x64_interrupt_state_register { u64 as_uint64; struct { @@ -1103,8 +1132,20 @@ 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. */ +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 Sun Feb 8 02:34:57 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 96CF01A070E; Wed, 8 Jan 2025 22:21:40 +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=1736374901; cv=none; b=qhC6+GlTM9xcvXfCpMWpOztKExYuedqd654MOSofj1k4Sg1DGH7GD3gRcTJm5uDdck03j+F1qI6KgnBqEd5c8hPfg55UG9Wb11FxyROPSeKMi7JujHiMSssJe12VzenvnxHPhAddFM/qxOsRlE7OihZ7CsEEqmVm6P9IkM6jn4c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736374901; c=relaxed/simple; bh=eheEiYFZ3ecvWH92ToTltGWJ+i40cLuC3Bo1qct+0Wo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fSW2FlZ6k2K+GSdco0642ePzpY6bU3BafboxRTIkPze7xdGagDyrzuFUujFwdjI/mz/gkHaNuMcki8y+VwB9/OfVIlIZSzMgA1BDQR5aN1pn3gssuUOKto8UPst3sqwp7IAc8jEMJge4J5DQThgUU+ZyR1wFQN7jqyLNEmxBwlg= 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=KmeTC5Bu; 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="KmeTC5Bu" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id 15BE1203E3AD; Wed, 8 Jan 2025 14:21:40 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 15BE1203E3AD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1736374900; bh=NNIK9O8tqPQmhbHWuF6fEy3lgReXdhCmNwdOmKsHi4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KmeTC5Bu1+peWxH1qSNI3/I7fjGx6I6L+8STPiFruOATe7trPRDIxHphXpiP0pajU J1zDVQsYiO9N3lS7gQwsdIDUdDGYUJovZRLzxRJwjzU5P+xYX1s0KJdsGs6vFVK11Y gzQzQR1iV9oE9A9I+WzMTfZhtjTgssidmFWCkZDA= 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 v6 2/5] hyperv: Fix pointer type in get_vtl(void) Date: Wed, 8 Jan 2025 14:21:35 -0800 Message-Id: <20250108222138.1623703-3-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250108222138.1623703-1-romank@linux.microsoft.com> References: <20250108222138.1623703-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 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 Feb 8 02:34:57 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C3E871E1C3B; Wed, 8 Jan 2025 22:21:40 +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=1736374902; cv=none; b=hBs0GK5wROPbqrEE6ST31Y5Sv7kSlBhElBlpzDlBZ+4FHt+NQgl95qhDjmyjtUtEkADryctZx7Ydnk2l2EgYXUN/CAMzWvoNyr+2fes+pWrU9hGm0Io7uP4/B4MGB1hq6YCGZlChScCrmJqXN0DPnTIQKIZosRHgTUu1/wCw6Zs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736374902; c=relaxed/simple; bh=yqySHNYOR7JGkEPuN+DLh9ECpz6ZXbtctwZrk+ie7Ck=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TuMa7J94KrMsBDPZZUHIobyw1yjHx05gJC2vaY0YaxXQYYw1OGNX5LyI2rPt3+newH1qtF8aCciHVV64DFqUnPrDLWIRffqCZsH8J5C6JoyuKWFdI99fPbTzi0h10uGGiHbgjpvwoBGr0tkiDpdDGmO51SYMLBNo/Huu5X3QBk4= 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=Nu5xVvo0; 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="Nu5xVvo0" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id 56C32203E3AE; Wed, 8 Jan 2025 14:21:40 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 56C32203E3AE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1736374900; bh=ZywFVF8Yt9VYckKPyJkIwnvBVKrrGO227UQIbP1TxE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nu5xVvo0EGwRql491N4u3a4hy58mIJwJYihAY+vzdvgP2y3mVWD3QukHHV01kyKRG 8qAKhXaj44GygcjSv3tUCWh+pEgOYLFP8X2FGda+EefxJ0L61IHg9bXRDJXydA+G6x HAhjRYk2DMDD1E9Km6kHAihU33bpteLserlUhGJ0= 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 v6 3/5] hyperv: Enable the hypercall output page for the VTL mode Date: Wed, 8 Jan 2025 14:21:36 -0800 Message-Id: <20250108222138.1623703-4-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250108222138.1623703-1-romank@linux.microsoft.com> References: <20250108222138.1623703-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: Nuno Das Neves --- drivers/hv/hv_common.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c index c6ed3ba4bf61..af5d1dc451f6 100644 --- a/drivers/hv/hv_common.c +++ b/drivers/hv/hv_common.c @@ -278,6 +278,11 @@ static void hv_kmsg_dump_register(void) } } =20 +static inline bool hv_output_page_exists(void) +{ + return hv_root_partition || IS_ENABLED(CONFIG_HYPERV_VTL_MODE); +} + int __init hv_common_init(void) { int i; @@ -340,7 +345,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_output_page_exists()) { hyperv_pcpu_output_arg =3D alloc_percpu(void *); BUG_ON(!hyperv_pcpu_output_arg); } @@ -435,7 +440,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_output_page_exists() ? 2 : 1; void *mem; int ret; =20 @@ -453,7 +458,7 @@ int hv_common_cpu_init(unsigned int cpu) if (!mem) return -ENOMEM; =20 - if (hv_root_partition) { + if (hv_output_page_exists()) { 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 Feb 8 02:34:57 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AEDD0204096; Wed, 8 Jan 2025 22:21:41 +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=1736374903; cv=none; b=Y1OE00BFEVDy3L7P84dGBUV+q8M6qeROe4/Srb950LSZx4o+CDIUpp6LhfNiGLTCJVSzZNgYBZ+Q3ZmJzYIeUQ+z2C6ilOdoSDG0f6k8g8lAwiikGown9ZNmbqbpZsX00FGDgBDZ8gtyOOfrgUrv4Op/bodkAkVROgAHioNlvAI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736374903; c=relaxed/simple; bh=G4rn+yvSAzNF/clV9Ip6RW2KAw4DOZ+LxH8wpoequwM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=byvDu/uiFgZnSqbjTjYozi4bmE/5aLZFQWyMPAxA2KBZQX6KB7rfp/z8cGCHxTybvWo9WOVvpOwvHCOrheaWibGaE/I5W+Zodfy+7TorVN7FQx+g0WV9D0vJdUyNOjdtejHM1q8yz1Nl36TSBH+k00RE0FQEXCIVDcB+rVixyFk= 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=CG8UMldJ; 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="CG8UMldJ" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id 98103203E3AF; Wed, 8 Jan 2025 14:21:40 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 98103203E3AF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1736374900; bh=448SOSWTgWAOry7zPz/Sg+z2e0JVJKUfOy+ZzFqPyLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CG8UMldJ1WYnCifYnTEdcPliXRYnGt900/EmRW37uWaLIl4Lw1fvuS8QChlaL3r/i bOv4Q4vjEGzHgEYqdUUnRI12r56sDBamyeQ6VgoCGfDNeZGchrzLSnEtURQvGan/9r WZd+ezyrRAb/5jVbvlzLw7EDgSEO3GV8fWXxB/yM= 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 v6 4/5] hyperv: Do not overlap the hvcall IO areas in get_vtl() Date: Wed, 8 Jan 2025 14:21:37 -0800 Message-Id: <20250108222138.1623703-5-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250108222138.1623703-1-romank@linux.microsoft.com> References: <20250108222138.1623703-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: Tianyu Lan 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 Feb 8 02:34:57 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AED75204095; Wed, 8 Jan 2025 22:21:41 +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=1736374904; cv=none; b=Bde3kxqjEvsfQkK74M/mpc0//T863DR5Zoou2rsvJ+oK0cgWDZvqxclZFT3gmsENbA3zTMfXYOBwdKGs/T+VWdCD5u/dU+RcFpkgPGorpF0VUCh+rEBAVTPeSlGNueJMn1JqTVba70ciaaHEZi8ktKmMb39tDXtxSpG6Nga1DiU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736374904; c=relaxed/simple; bh=5SiC6CGRokdAmWq10sS4FRECfu4OtPdVhJAkYMlzJKc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n6QvKbTSUU/Hm0rPRF5ber8QD3FLe4GucccYXzgJgaSIvm66SYZ3uY63Lv2F4wL32B+MYmfvgjEkproDQSj4A2q2CJN0REqbdIyJqUyO0B6zZmB+6W/CRkQTpdMnHQpKkWKNwc6yNept8kvmTEdF6ragUM5JE1R3V8OSMx89azE= 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=FoEpZ+B5; 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="FoEpZ+B5" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id D73F2203E3B0; Wed, 8 Jan 2025 14:21:40 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D73F2203E3B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1736374901; bh=8WiwdrwxYid9TP2KN6SPCoazL0yGKj1OCkPzSlA+1hs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FoEpZ+B5qF13JGzezKgnuM6s8YcLIvt9PWVsQ2ECO6V1Gqg2Z7tBK6xq4lrHsBSsa nYi/wP4Y2HnC4pvx3y9TKNxvgAhhMXG4qR7mMqsHZWJLgbreOHxGBKHfMoLQyy9f1R EaAxnUFOIWEBEp2R1wuCMcUk51d4esG7VxEBtlv8= 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 v6 5/5] hyperv: Do not overlap the hvcall IO areas in hv_vtl_apicid_to_vp_id() Date: Wed, 8 Jan 2025 14:21:38 -0800 Message-Id: <20250108222138.1623703-6-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250108222138.1623703-1-romank@linux.microsoft.com> References: <20250108222138.1623703-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 Reviewed-by: Nuno Das Neves --- 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