- Timestamp:
- Oct 4, 2018 3:53:02 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp
r74606 r74616 1966 1966 * 1967 1967 * On Windows the Hyper-V root partition (dom0 in zen terminology) does not have 1968 * nested VT-x or AMD-V capabilities. For a while raw-mode worked inside it,1969 * but for a while now we've been getting \#GPwhen trying to modify CR4 in the1968 * nested VT-x or AMD-V capabilities. Early on raw-mode worked inside it, but 1969 * for a while now we've been getting \#GPs when trying to modify CR4 in the 1970 1970 * world switcher. So, when Hyper-V is active on Windows we have little choice 1971 1971 * but to use Hyper-V to run our VMs. … … 1975 1975 * 1976 1976 * Since Windows 10 build 17083 there is a documented API for managing Hyper-V 1977 * VMs ,header file WinHvPlatform.h and implementation in WinHvPlatform.dll.1977 * VMs: header file WinHvPlatform.h and implementation in WinHvPlatform.dll. 1978 1978 * This interface is a wrapper around the undocumented Virtualization 1979 1979 * Infrastructure Driver (VID) API - VID.DLL and VID.SYS. The wrapper is … … 1987 1987 * WHvSetPartitionProperty. Since the VID API is just a very thin wrapper 1988 1988 * around CreateFile and NtDeviceIoControlFile, it returns an actual HANDLE for 1989 * the partition WinHvPlatform. We fish this HANDLE out of the WinHvPlatform1989 * the partition to WinHvPlatform. We fish this HANDLE out of the WinHvPlatform 1990 1990 * partition structures because we need to talk directly to VID for reasons 1991 1991 * we'll get to in a bit. (Btw. we could also intercept the CreateFileW or … … 2000 2000 * WinHvRunVpDispatchLoop(). When for instance a VMEXIT is encountered, hyper-V 2001 2001 * sends a message that the WHvRunVirtualProcessor API retrieves (and later 2002 * acknowledges) via VidMessageSlotHandleAndGetNext. It should be noteded that 2003 * WHvDeleteVirtualProcessor doesn't do much as there seems to be no partner 2004 * function VidMessagesSlotMap that reverses what it did. 2002 * acknowledges) via VidMessageSlotHandleAndGetNext. Since or about build 2003 * 17757 a register page is also mapped into user space when creating the 2004 * virtual CPU. It should be noteded that WHvDeleteVirtualProcessor doesn't do 2005 * much as there seems to be no partner function VidMessagesSlotMap that 2006 * reverses what it did. 2005 2007 * 2006 2008 * Memory is managed thru calls to WHvMapGpaRange and WHvUnmapGpaRange (GPA does … … 2011 2013 * of ranges are limited and probably their total size as well. Obviously 2012 2014 * VID.SYS keeps track of the ranges, but so does WinHvPlatform, which means 2013 * there is a bit of overhead involved and quota restrctions makes sense. For 2014 * some reason though, regions are lazily mapped on VMEXIT/memory by 2015 * WHvRunVirtualProcessor. 2016 * 2017 * Running guest code is done thru the WHvRunVirtualProcessor function. It 2015 * there is a bit of overhead involved and quota restrctions makes sense. 2016 * 2017 * Running guest code is done through the WHvRunVirtualProcessor function. It 2018 2018 * asynchronously starts or resumes hyper-V CPU execution and then waits for an 2019 2019 * VMEXIT message. Hyper-V / VID.SYS will return information about the message … … 2022 2022 * 2023 2023 * Other threads can interrupt the execution by using WHvCancelVirtualProcessor, 2024 * which which case the thread in WHvRunVirtualProcessor is woken up via a dummy 2025 * QueueUserAPC and will call VidStopVirtualProcessor to asynchronously end 2026 * execution. The stop CPU call not immediately succeed if the CPU encountered 2027 * a VMEXIT before the stop was processed, in which case the VMEXIT needs to be 2028 * processed first, and the pending stop will be processed in a subsequent call 2029 * to WHvRunVirtualProcessor. 2024 * which since or about build 17757 uses VidMessageSlotHandleAndGetNext to do 2025 * the work (earlier builds would open the waiting thread, do a dummy 2026 * QueueUserAPC on it, and let it upon return use VidStopVirtualProcessor to 2027 * do the actual stopping). While there is certainly a race between cancelation 2028 * and the CPU causing a natural VMEXIT, it is not known whether this still 2029 * causes extra work on subsequent WHvRunVirtualProcessor calls (it did in and 2030 * earlier 17134). 2030 2031 * 2031 2032 * Registers are retrieved and set via WHvGetVirtualProcessorRegisters and … … 2070 2071 * packed. 2071 2072 * 2072 * Update: S omewhere along the security fixes or/and microcode updates this2073 * summer (2018), performancedropped even more.2073 * Update: Security fixes during the summer of 2018 caused the performance to 2074 * dropped even more. 2074 2075 * 2075 2076 * Update [build 17757]: Some performance improvements here, but they don't … … 2111 2112 * with the replacement code. By spurious returns we mean that the 2112 2113 * subsequent call to WHvRunVirtualProcessor would return immediately. 2114 * 2115 * Update [build 17757]: New cancelation code might have addressed this, but 2116 * haven't had time to test it yet. 2113 2117 * 2114 2118 *
Note:
See TracChangeset
for help on using the changeset viewer.