[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241226203050.800524-1-romank@linux.microsoft.com>
Date: Thu, 26 Dec 2024 12:30:47 -0800
From: Roman Kisel <romank@...ux.microsoft.com>
To: hpa@...or.com,
kys@...rosoft.com,
bp@...en8.de,
dave.hansen@...ux.intel.com,
decui@...rosoft.com,
eahariha@...ux.microsoft.com,
haiyangz@...rosoft.com,
mingo@...hat.com,
mhklinux@...look.com,
nunodasneves@...ux.microsoft.com,
tglx@...utronix.de,
tiala@...rosoft.com,
wei.liu@...nel.org,
linux-hyperv@...r.kernel.org,
linux-kernel@...r.kernel.org,
x86@...nel.org
Cc: apais@...rosoft.com,
benhill@...rosoft.com,
ssengar@...rosoft.com,
sunilmut@...rosoft.com,
vdso@...bites.dev
Subject: [PATCH v2 0/3] hyperv: Fixes for get_vtl(void)
The get_vtl(void) function
* has got one bug when the code started using a wrong pointer type after
refactoring, and also
* it doesn't adhere to the requirements of the Hypervisor Top-Level Funactional
Specification[1, 2] as the code overlaps the input and output areas for a hypercall.
The first issue leads to a wrong 100% reproducible computation due to reading
a byte worth of data at a wrong offset. That in turn leads to using a nonsensical
value ("fortunately", could catch it easily!) for the current VTL when initiating
VMBus communications. As a repercussion from that, the system wouldn't boot. The
fix is straightforward: use the correct pointer type.
The second issue doesn't seem to lead to any reproducible breakage just yet. It is
fixed with using the output hypercall pages allocated per-CPU, and that isn't the
only or the most obvious choice so let me elaborate why that fix appears to be the
best one in my opinion out of the options I could conceive of.
The approach chosen for fixing the second issue makes two things shine through:
* `get_vtl(void)` is just getting a vCPU register, no special treatment needs
to be involved,
* VTLs and dom0 can and should share code as both exist to provide services to
a guest(s), be that from within the partition or from outside of it.
The projected benefits include replacing the function in question with a future
`hv_get_vp_registers` one shared between dom0 and VTLs to allow for a better test
coverage.
I have validated the fixes by booting the fixed kernel in VTL2 up using OpenVMM and
OpenHCL[3, 4].
[1] https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/tlfs/hypercall-interface
[2] https://github.com/MicrosoftDocs/Virtualization-Documentation/tree/main/tlfs
[3] https://openvmm.dev/guide/user_guide/openhcl.html
[4] https://github.com/microsoft/OpenVMM
[v2]
- Used the suggestions to define an additional structure to improve code readability,
- Split out the patch with that definition.
[v1]: https://lore.kernel.org/lkml/20241218205421.319969-1-romank@linux.microsoft.com/
Roman Kisel (3):
hyperv: Define struct hv_output_get_vp_registers
hyperv: Fix pointer type for the output of the hypercall in
get_vtl(void)
hyperv: Do not overlap the input and output hypercall areas in
get_vtl(void)
arch/x86/hyperv/hv_init.c | 6 ++--
drivers/hv/hv_common.c | 6 ++--
include/hyperv/hvgdk_mini.h | 58 +++++++++++++++++++++++++++++++++++--
3 files changed, 62 insertions(+), 8 deletions(-)
base-commit: 4d4ace979a3066e5c940331571e6c1c3f280d1d3
--
2.34.1
Powered by blists - more mailing lists