VirtualBox

source: vbox/trunk/include/iprt/nt/hyperv.h@ 104212

Last change on this file since 104212 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 73.5 KB
Line 
1/** @file
2 * Hyper-V related types and definitions.
3 */
4
5/*
6 * Copyright (C) 2018-2023 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * The contents of this file may alternatively be used under the terms
25 * of the Common Development and Distribution License Version 1.0
26 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
27 * in the VirtualBox distribution, in which case the provisions of the
28 * CDDL are applicable instead of those of the GPL.
29 *
30 * You may elect to license modified versions of this file under the
31 * terms and conditions of either the GPL or the CDDL or both.
32 *
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
34 */
35
36#ifndef IPRT_INCLUDED_nt_hyperv_h
37#define IPRT_INCLUDED_nt_hyperv_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42
43#ifndef IN_IDA_PRO
44# include <iprt/types.h>
45# include <iprt/assertcompile.h>
46#else
47# define RT_FLEXIBLE_ARRAY
48# define RT_FLEXIBLE_ARRAY_EXTENSION
49# define AssertCompile(expr)
50# define AssertCompileSize(type, size)
51# define AssertCompileMemberOffset(type, member, off)
52typedef unsigned char uint8_t;
53typedef unsigned __int32 uint32_t;
54typedef unsigned __int64 uint64_t;
55#endif
56
57
58/** Hyper-V partition ID. */
59typedef uint64_t HV_PARTITION_ID;
60/** Invalid Hyper-V partition ID. */
61#define HV_PARTITION_ID_INVALID UINT64_C(0)
62/** Hyper-V virtual processor index (== VMCPUID). */
63typedef uint32_t HV_VP_INDEX;
64/** Guest physical address (== RTGCPHYS). */
65typedef uint64_t HV_GPA;
66/** Guest physical page number. */
67typedef uint64_t HV_GPA_PAGE_NUMBER;
68/** System(/parent) physical page number. */
69typedef uint64_t HV_SPA_PAGE_NUMBER;
70/** Hyper-V unsigned 128-bit integer type. */
71typedef struct { uint64_t Low64, High64; } HV_UINT128;
72/** Hyper-V port ID. */
73typedef union
74{
75 uint32_t AsUINT32;
76 struct
77 {
78 uint32_t Id : 24;
79 uint32_t Reserved : 8;
80 };
81} HV_PORT_ID;
82/** Pointer to a Hyper-V port ID. */
83typedef HV_PORT_ID *PHV_PORT_ID;
84
85
86/**
87 * Hypercall IDs.
88 */
89typedef enum
90{
91 HvCallReserved0000 = 0,
92
93 HvCallSwitchVirtualAddressSpace,
94 HvCallFlushVirtualAddressSpace,
95 HvCallFlushVirtualAddressList,
96 HvCallGetLogicalProcessorRunTime,
97 /* 5, 6 & 7 are deprecated / reserved. */
98 HvCallNotifyLongSpinWait = 8,
99 HvCallParkLogicalProcessors, /**< @since v2 */
100 HvCallInvokeHypervisorDebugger, /**< @since v2 - not mentioned in TLFS v5.0b */
101 HvCallSendSyntheticClusterIpi, /**< @since v? */
102 HvCallModifyVtlProtectionMask, /**< @since v? */
103 HvCallEnablePartitionVtl, /**< @since v? */
104 HvCallDisablePartitionVtl, /**< @since v? */
105 HvCallEnableVpVtl, /**< @since v? */
106 HvCallDisableVpVtl, /**< @since v? */
107 HvCallVtlCall, /**< @since v? */
108 HvCallVtlReturn, /**< @since v? */
109 HvCallFlushVirtualAddressSpaceEx, /**< @since v? */
110 HvCallFlushVirtualAddressListEx, /**< @since v? */
111 HvCallSendSyntheticClusterIpiEx, /**< @since v? */
112 /* Reserved: 0x16..0x3f */
113
114 HvCallCreatePartition = 0x40,
115 HvCallInitializePartition,
116 HvCallFinalizePartition,
117 HvCallDeletePartition,
118 HvCallGetPartitionProperty,
119 HvCallSetPartitionProperty,
120 HvCallGetPartitionId,
121 HvCallGetNextChildPartition,
122 HvCallDepositMemory, /**< 0x48 - Repeat call. */
123 HvCallWithdrawMemory, /**< 0x49 - Repeat call. */
124 HvCallGetMemoryBalance,
125 HvCallMapGpaPages, /**< 0X4b - Repeat call. */
126 HvCallUnmapGpaPages, /**< 0X4c - Repeat call. */
127 HvCallInstallIntercept,
128 HvCallCreateVp,
129 HvCallDeleteVp, /**< 0x4f - Fast call. */
130 HvCallGetVpRegisters, /**< 0x50 - Repeat call. */
131 HvCallSetVpRegisters, /**< 0x51 - Repeat call. */
132 HvCallTranslateVirtualAddress,
133 HvCallReadGpa,
134 HvCallWriteGpa,
135 HvCallAssertVirtualInterruptV1,
136 HvCallClearVirtualInterrupt, /**< 0x56 - Fast call. */
137 HvCallCreatePortV1,
138 HvCallDeletePort, /**< 0x58 - Fast call. */
139 HvCallConnectPortV1,
140 HvCallGetPortProperty,
141 HvCallDisconnectPort,
142 HvCallPostMessage,
143 HvCallSignalEvent,
144 HvCallSavePartitionState,
145 HvCallRestorePartitionState,
146 HvCallInitializeEventLogBufferGroup,
147 HvCallFinalizeEventLogBufferGroup,
148 HvCallCreateEventLogBuffer,
149 HvCallDeleteEventLogBuffer,
150 HvCallMapEventLogBuffer,
151 HvCallUnmapEventLogBuffer,
152 HvCallSetEventLogGroupSources,
153 HvCallReleaseEventLogBuffer,
154 HvCallFlushEventLogBuffer,
155 HvCallPostDebugData,
156 HvCallRetrieveDebugData,
157 HvCallResetDebugSession,
158 HvCallMapStatsPage,
159 HvCallUnmapStatsPage,
160 HvCallMapSparseGpaPages, /**< @since v2 */
161 HvCallSetSystemProperty, /**< @since v2 */
162 HvCallSetPortProperty, /**< @since v2 */
163 /* 0x71..0x75 reserved/deprecated (was v2 test IDs). */
164 HvCallAddLogicalProcessor = 0x76,
165 HvCallRemoveLogicalProcessor,
166 HvCallQueryNumaDistance,
167 HvCallSetLogicalProcessorProperty,
168 HvCallGetLogicalProcessorProperty,
169 HvCallGetSystemProperty,
170 HvCallMapDeviceInterrupt,
171 HvCallUnmapDeviceInterrupt,
172 HvCallRetargetDeviceInterrupt,
173 /* 0x7f is reserved. */
174 HvCallMapDevicePages = 0x80,
175 HvCallUnmapDevicePages,
176 HvCallAttachDevice,
177 HvCallDetachDevice,
178 HvCallNotifyStandbyTransition,
179 HvCallPrepareForSleep,
180 HvCallPrepareForHibernate,
181 HvCallNotifyPartitionEvent,
182 HvCallGetLogicalProcessorRegisters,
183 HvCallSetLogicalProcessorRegisters,
184 HvCallQueryAssociatedLpsforMca,
185 HvCallNotifyRingEmpty,
186 HvCallInjectSyntheticMachineCheck,
187 HvCallScrubPartition,
188 HvCallCollectLivedump,
189 HvCallDisableHypervisor,
190 HvCallModifySparseGpaPages,
191 HvCallRegisterInterceptResult,
192 HvCallUnregisterInterceptResult,
193 /* 0x93 is reserved/undocumented. */
194 HvCallAssertVirtualInterrupt = 0x94,
195 HvCallCreatePort,
196 HvCallConnectPort,
197 HvCallGetSpaPageList,
198 /* 0x98 is reserved. */
199 HvCallStartVirtualProcessor = 0x99,
200 HvCallGetVpIndexFromApicId,
201 /* 0x9b..0xae are reserved/undocumented.
202 0xad: New version of HvCallGetVpRegisters? Perhaps on logical CPU or smth. */
203 HvCallFlushGuestPhysicalAddressSpace = 0xaf,
204 HvCallFlushGuestPhysicalAddressList,
205 /* 0xb1..0xb4 are unknown */
206 HvCallCreateCpuGroup = 0xb5,
207 HvCallDeleteCpuGroup,
208 HvCallGetCpuGroupProperty,
209 HvCallSetCpuGroupProperty,
210 HvCallGetCpuGroupAffinit,
211 HvCallGetNextCpuGroup = 0xba,
212 HvCallGetNextCpuGroupPartition,
213 HvCallPrecommitGpaPages = 0xbe,
214 HvCallUncommitGpaPages, /**< Happens when VidDestroyGpaRangeCheckSecure/WHvUnmapGpaRange is called. */
215 /* 0xc0 is unknown */
216 HvCallVpRunloopRelated = 0xc2, /**< Fast */
217 /* 0xc3..0xcb are unknown */
218 HvCallQueryVtlProtectionMaskRange = 0xcc,
219 HvCallModifyVtlProtectionMaskRange,
220 /* 0xce..0xd1 are unknown */
221 HvCallAcquireSparseGpaPageHostAccess = 0xd2,
222 HvCallReleaseSparseGpaPageHostAccess,
223 HvCallCheckSparseGpaPageVtlAccess,
224 HvCallAcquireSparseSpaPageHostAccess = 0xd7,
225 HvCallReleaseSparseSpaPageHostAccess,
226 HvCallAcceptGpaPages, /**< 0x18 byte input, zero rep, no output. */
227 /* 0xda..0xe0 are unknown (not dug out yet) */
228 HvCallMapVpRegisterPage = 0xe1, /**< Takes partition id + VP index (16 bytes). Returns a physical address (8 bytes). */
229 HvCallUnmapVpRegisterPage, /**< Takes partition id + VP index. */
230 HvCallUnknownE3,
231 HvCallUnknownE4,
232 HvCallUnknownE5,
233 HvCallUnknownE6,
234 /** Number of defined hypercalls (varies with version). */
235 HvCallCount
236} HV_CALL_CODE;
237AssertCompile(HvCallSendSyntheticClusterIpiEx == 0x15);
238AssertCompile(HvCallMapGpaPages == 0x4b);
239AssertCompile(HvCallSetPortProperty == 0x70);
240AssertCompile(HvCallRetargetDeviceInterrupt == 0x7e);
241AssertCompile(HvCallUnregisterInterceptResult == 0x92);
242AssertCompile(HvCallGetSpaPageList == 0x97);
243AssertCompile(HvCallFlushGuestPhysicalAddressList == 0xb0);
244AssertCompile(HvCallUncommitGpaPages == 0xbf);
245AssertCompile(HvCallCount == 0xe7);
246
247/** Makes the first parameter to a hypercall (rcx). */
248#define HV_MAKE_CALL_INFO(a_enmCallCode, a_cReps) ( (uint64_t)(a_enmCallCode) | ((uint64_t)(a_cReps) << 32) )
249/** Makes the return value (success) for a rep hypercall. */
250#define HV_MAKE_CALL_REP_RET(a_cReps) ((uint64_t)(a_cReps) << 32)
251
252/** Hypercall status code. */
253typedef uint16_t HV_STATUS;
254
255/** @name Hyper-V Hypercall status codes
256 * @{ */
257#define HV_STATUS_SUCCESS (0x0000)
258#define HV_STATUS_RESERVED_1 (0x0001)
259#define HV_STATUS_INVALID_HYPERCALL_CODE (0x0002)
260#define HV_STATUS_INVALID_HYPERCALL_INPUT (0x0003)
261#define HV_STATUS_INVALID_ALIGNMENT (0x0004)
262#define HV_STATUS_INVALID_PARAMETER (0x0005)
263#define HV_STATUS_ACCESS_DENIED (0x0006)
264#define HV_STATUS_INVALID_PARTITION_STATE (0x0007)
265#define HV_STATUS_OPERATION_DENIED (0x0008)
266#define HV_STATUS_UNKNOWN_PROPERTY (0x0009)
267#define HV_STATUS_PROPERTY_VALUE_OUT_OF_RANGE (0x000a)
268#define HV_STATUS_INSUFFICIENT_MEMORY (0x000b)
269#define HV_STATUS_PARTITION_TOO_DEEP (0x000c)
270#define HV_STATUS_INVALID_PARTITION_ID (0x000d)
271#define HV_STATUS_INVALID_VP_INDEX (0x000e)
272#define HV_STATUS_RESERVED_F (0x000f)
273#define HV_STATUS_NOT_FOUND (0x0010)
274#define HV_STATUS_INVALID_PORT_ID (0x0011)
275#define HV_STATUS_INVALID_CONNECTION_ID (0x0012)
276#define HV_STATUS_INSUFFICIENT_BUFFERS (0x0013)
277#define HV_STATUS_NOT_ACKNOWLEDGED (0x0014)
278#define HV_STATUS_INVALID_VP_STATE (0x0015)
279#define HV_STATUS_ACKNOWLEDGED (0x0016)
280#define HV_STATUS_INVALID_SAVE_RESTORE_STATE (0x0017)
281#define HV_STATUS_INVALID_SYNIC_STATE (0x0018)
282#define HV_STATUS_OBJECT_IN_USE (0x0019)
283#define HV_STATUS_INVALID_PROXIMITY_DOMAIN_INFO (0x001a)
284#define HV_STATUS_NO_DATA (0x001b)
285#define HV_STATUS_INACTIVE (0x001c)
286#define HV_STATUS_NO_RESOURCES (0x001d)
287#define HV_STATUS_FEATURE_UNAVAILABLE (0x001e)
288#define HV_STATUS_PARTIAL_PACKET (0x001f)
289#define HV_STATUS_PROCESSOR_FEATURE_SSE3_NOT_SUPPORTED (0x0020)
290#define HV_STATUS_PROCESSOR_FEATURE_LAHFSAHF_NOT_SUPPORTED (0x0021)
291#define HV_STATUS_PROCESSOR_FEATURE_SSSE3_NOT_SUPPORTED (0x0022)
292#define HV_STATUS_PROCESSOR_FEATURE_SSE4_1_NOT_SUPPORTED (0x0023)
293#define HV_STATUS_PROCESSOR_FEATURE_SSE4_2_NOT_SUPPORTED (0x0024)
294#define HV_STATUS_PROCESSOR_FEATURE_SSE4A_NOT_SUPPORTED (0x0025)
295#define HV_STATUS_PROCESSOR_FEATURE_XOP_NOT_SUPPORTED (0x0026)
296#define HV_STATUS_PROCESSOR_FEATURE_POPCNT_NOT_SUPPORTED (0x0027)
297#define HV_STATUS_PROCESSOR_FEATURE_CMPXCHG16B_NOT_SUPPORTED (0x0028)
298#define HV_STATUS_PROCESSOR_FEATURE_ALTMOVCR8_NOT_SUPPORTED (0x0029)
299#define HV_STATUS_PROCESSOR_FEATURE_LZCNT_NOT_SUPPORTED (0x002a)
300#define HV_STATUS_PROCESSOR_FEATURE_MISALIGNED_SSE_NOT_SUPPORTED (0x002b)
301#define HV_STATUS_PROCESSOR_FEATURE_MMX_EXT_NOT_SUPPORTED (0x002c)
302#define HV_STATUS_PROCESSOR_FEATURE_3DNOW_NOT_SUPPORTED (0x002d)
303#define HV_STATUS_PROCESSOR_FEATURE_EXTENDED_3DNOW_NOT_SUPPORTED (0x002e)
304#define HV_STATUS_PROCESSOR_FEATURE_PAGE_1GB_NOT_SUPPORTED (0x002f)
305#define HV_STATUS_PROCESSOR_CACHE_LINE_FLUSH_SIZE_INCOMPATIBLE (0x0030)
306#define HV_STATUS_PROCESSOR_FEATURE_XSAVE_NOT_SUPPORTED (0x0031)
307#define HV_STATUS_PROCESSOR_FEATURE_XSAVEOPT_NOT_SUPPORTED (0x0032)
308#define HV_STATUS_INSUFFICIENT_BUFFER (0x0033)
309#define HV_STATUS_PROCESSOR_FEATURE_XSAVE_AVX_NOT_SUPPORTED (0x0034)
310#define HV_STATUS_PROCESSOR_FEATURE_XSAVE_ FEATURE_NOT_SUPPORTED (0x0035)
311#define HV_STATUS_PROCESSOR_XSAVE_SAVE_AREA_INCOMPATIBLE (0x0036)
312#define HV_STATUS_INCOMPATIBLE_PROCESSOR (0x0037)
313#define HV_STATUS_INSUFFICIENT_DEVICE_DOMAINS (0x0038)
314#define HV_STATUS_PROCESSOR_FEATURE_AES_NOT_SUPPORTED (0x0039)
315#define HV_STATUS_PROCESSOR_FEATURE_PCLMULQDQ_NOT_SUPPORTED (0x003a)
316#define HV_STATUS_PROCESSOR_FEATURE_INCOMPATIBLE_XSAVE_FEATURES (0x003b)
317#define HV_STATUS_CPUID_FEATURE_VALIDATION_ERROR (0x003c)
318#define HV_STATUS_CPUID_XSAVE_FEATURE_VALIDATION_ERROR (0x003d)
319#define HV_STATUS_PROCESSOR_STARTUP_TIMEOUT (0x003e)
320#define HV_STATUS_SMX_ENABLED (0x003f)
321#define HV_STATUS_PROCESSOR_FEATURE_PCID_NOT_SUPPORTED (0x0040)
322#define HV_STATUS_INVALID_LP_INDEX (0x0041)
323#define HV_STATUS_FEATURE_FMA4_NOT_SUPPORTED (0x0042)
324#define HV_STATUS_FEATURE_F16C_NOT_SUPPORTED (0x0043)
325#define HV_STATUS_PROCESSOR_FEATURE_RDRAND_NOT_SUPPORTED (0x0044)
326#define HV_STATUS_PROCESSOR_FEATURE_RDWRFSGS_NOT_SUPPORTED (0x0045)
327#define HV_STATUS_PROCESSOR_FEATURE_SMEP_NOT_SUPPORTED (0x0046)
328#define HV_STATUS_PROCESSOR_FEATURE_ENHANCED_FAST_STRING_NOT_SUPPORTED (0x0047)
329#define HV_STATUS_PROCESSOR_FEATURE_MOVBE_NOT_SUPPORTED (0x0048)
330#define HV_STATUS_PROCESSOR_FEATURE_BMI1_NOT_SUPPORTED (0x0049)
331#define HV_STATUS_PROCESSOR_FEATURE_BMI2_NOT_SUPPORTED (0x004a)
332#define HV_STATUS_PROCESSOR_FEATURE_HLE_NOT_SUPPORTED (0x004b)
333#define HV_STATUS_PROCESSOR_FEATURE_RTM_NOT_SUPPORTED (0x004c)
334#define HV_STATUS_PROCESSOR_FEATURE_XSAVE_FMA_NOT_SUPPORTED (0x004d)
335#define HV_STATUS_PROCESSOR_FEATURE_XSAVE_AVX2_NOT_SUPPORTED (0x004e)
336#define HV_STATUS_PROCESSOR_FEATURE_NPIEP1_NOT_SUPPORTED (0x004f)
337#define HV_STATUS_INVALID_REGISTER_VALUE (0x0050)
338#define HV_STATUS_PROCESSOR_FEATURE_RDSEED_NOT_SUPPORTED (0x0052)
339#define HV_STATUS_PROCESSOR_FEATURE_ADX_NOT_SUPPORTED (0x0053)
340#define HV_STATUS_PROCESSOR_FEATURE_SMAP_NOT_SUPPORTED (0x0054)
341#define HV_STATUS_NX_NOT_DETECTED (0x0055)
342#define HV_STATUS_PROCESSOR_FEATURE_INTEL_PREFETCH_NOT_SUPPORTED (0x0056)
343#define HV_STATUS_INVALID_DEVICE_ID (0x0057)
344#define HV_STATUS_INVALID_DEVICE_STATE (0x0058)
345#define HV_STATUS_PENDING_PAGE_REQUESTS (0x0059)
346#define HV_STATUS_PAGE_REQUEST_INVALID (0x0060)
347#define HV_STATUS_OPERATION_FAILED (0x0071)
348#define HV_STATUS_NOT_ALLOWED_WITH_NESTED_VIRT_ACTIVE (0x0072)
349/** @} */
350
351
352/** Hyper-V partition property value. */
353typedef uint64_t HV_PARTITION_PROPERTY;
354/** Pointer to a partition property value. */
355typedef HV_PARTITION_PROPERTY *PHV_PARTITION_PROPERTY;
356/**
357 * Hyper-V partition property code.
358 * This is documented in TLFS, except version 5.x.
359 */
360typedef enum
361{
362 HvPartitionPropertyPrivilegeFlags = 0x00010000,
363 HvPartitionPropertySyntheticProcessorFeaturesBanks, /**< Read by WHvApi::Capabilities::GetSyntheticProcessorFeaturesBanks (build 22000) */
364
365 HvPartitionPropertyCpuReserve = 0x00020001,
366 HvPartitionPropertyCpuCap,
367 HvPartitionPropertyCpuWeight,
368 HvPartitionPropertyUnknown20004, /**< On exo partition (build 17134), initial value zero. */
369
370 HvPartitionPropertyEmulatedTimerPeriod = 0x00030000, /**< @note Fails on exo partition (build 17134). */
371 HvPartitionPropertyEmulatedTimerControl, /**< @note Fails on exo partition (build 17134). */
372 HvPartitionPropertyPmTimerAssist, /**< @note Fails on exo partition (build 17134). */
373 HvPartitionPropertyUnknown30003, /**< @note WHvSetupPartition writes this (build 22000). */
374 HvPartitionPropertyUnknown30004, /**< ? */
375 HvPartitionPropertyUnknown30005, /**< WHvPartitionPropertyCodeReferenceTime maps to this (build 22000) */
376
377 HvPartitionPropertyDebugChannelId = 0x00040000, /**< @note Hangs system on exo partition hangs (build 17134). */
378
379 HvPartitionPropertyVirtualTlbPageCount = 0x00050000,
380 HvPartitionPropertyUnknown50001, /**< On exo partition (build 17134), initial value zero. */
381 HvPartitionPropertyUnknown50002, /**< On exo partition (build 17134), initial value zero. */
382 HvPartitionPropertyUnknown50003, /**< On exo partition (build 17134), initial value zero. */
383 HvPartitionPropertyUnknown50004, /**< On exo partition (build 17134), initial value zero. */
384 HvPartitionPropertyUnknown50005, /**< On exo partition (build 17134), initial value one. */
385 HvPartitionPropertyUnknown50006, /**< On exo partition (build 17134), initial value zero.
386 * @note build 22000/w11-ga fends this off in VID.SYS. */
387 HvPartitionPropertyUnknown50007,
388 HvPartitionPropertyUnknown50008,
389 HvPartitionPropertyUnknown50009,
390 HvPartitionPropertyUnknown5000a,
391 HvPartitionPropertyUnknown5000b,
392 HvPartitionPropertyUnknown5000c,
393 HvPartitionPropertyUnknown5000d,
394 HvPartitionPropertyUnknown5000e,
395 HvPartitionPropertyUnknown5000f,
396 HvPartitionPropertyUnknown50010,
397 HvPartitionPropertyUnknown50012,
398 HvPartitionPropertyUnknown50013, /**< Set by WHvSetupPartition (build 22000) */
399 HvPartitionPropertyUnknown50014,
400 HvPartitionPropertyUnknown50015,
401 HvPartitionPropertyUnknown50016,
402 HvPartitionPropertyUnknown50017, /**< Set by WHvSetupPartition (build 22000) */
403
404 HvPartitionPropertyProcessorVendor = 0x00060000,
405 HvPartitionPropertyProcessorFeatures, /**< On exo/17134/threadripper: 0x6cb26f39fbf */
406 HvPartitionPropertyProcessorXsaveFeatures,
407 HvPartitionPropertyProcessorCLFlushSize, /**< On exo/17134/threadripper: 8 */
408 HvPartitionPropertyUnknown60004, /**< On exo partition (build 17134), initial value zero. */
409 HvPartitionPropertyUnknown60005, /**< On exo partition (build 17134), initial value 0x603. */
410 HvPartitionPropertyUnknown60006, /**< On exo partition (build 17134), initial value 0x2c. */
411 HvPartitionPropertyUnknown60007, /**< WHvSetupPartition reads this (build 22000). */
412 HvPartitionPropertyUnknown60008, /**< WHvSetupPartition reads this (build 22000). */
413 HvPartitionPropertyProcessorClockFrequency, /**< Read by WHvApi::Capabilities::GetProcessorClockFrequency (build 22000). */
414 HvPartitionPropertyProcessorFeaturesBank0, /**< Read by WHvApi::Capabilities::GetProcessorFeaturesBanks (build 22000). */
415 HvPartitionPropertyProcessorFeaturesBank1, /**< Read by WHvApi::Capabilities::GetProcessorFeaturesBanks (build 22000). */
416
417 HvPartitionPropertyGuestOsId = 0x00070000, /**< @since v4 */
418
419 HvPartitionPropertyUnknown800000 = 0x00080000 /**< On exo partition (build 17134), initial value zero. */
420} HV_PARTITION_PROPERTY_CODE;
421AssertCompileSize(HV_PARTITION_PROPERTY_CODE, 4);
422/** Pointer to a partition property code. */
423typedef HV_PARTITION_PROPERTY_CODE *PHV_PARTITION_PROPERTY_CODE;
424
425
426/** Input for HvCallGetPartitionProperty. */
427typedef struct
428{
429 HV_PARTITION_ID PartitionId;
430 HV_PARTITION_PROPERTY_CODE PropertyCode;
431 uint32_t uPadding;
432} HV_INPUT_GET_PARTITION_PROPERTY;
433AssertCompileSize(HV_INPUT_GET_PARTITION_PROPERTY, 16);
434/** Pointer to input for HvCallGetPartitionProperty. */
435typedef HV_INPUT_GET_PARTITION_PROPERTY *PHV_INPUT_GET_PARTITION_PROPERTY;
436
437/** Output for HvCallGetPartitionProperty. */
438typedef struct
439{
440 HV_PARTITION_PROPERTY PropertyValue;
441} HV_OUTPUT_GET_PARTITION_PROPERTY;
442/** Pointer to output for HvCallGetPartitionProperty. */
443typedef HV_OUTPUT_GET_PARTITION_PROPERTY *PHV_OUTPUT_GET_PARTITION_PROPERTY;
444
445
446/** Input for HvCallSetPartitionProperty. */
447typedef struct
448{
449 HV_PARTITION_ID PartitionId;
450 HV_PARTITION_PROPERTY_CODE PropertyCode;
451 uint32_t uPadding;
452 HV_PARTITION_PROPERTY PropertyValue;
453} HV_INPUT_SET_PARTITION_PROPERTY;
454AssertCompileSize(HV_INPUT_SET_PARTITION_PROPERTY, 24);
455/** Pointer to input for HvCallSetPartitionProperty. */
456typedef HV_INPUT_SET_PARTITION_PROPERTY *PHV_INPUT_SET_PARTITION_PROPERTY;
457
458
459/** Hyper-V NUMA node ID.
460 * On systems without NUMA, i.e. a single node, it uses 0 as identifier. */
461typedef uint32_t HV_PROXIMITY_DOMAIN_ID;
462/** Pointer to NUMA node ID. */
463typedef HV_PROXIMITY_DOMAIN_ID *PHV_PROXIMITY_DOMAIN_ID;
464
465/** Hyper-V NUMA flags. */
466typedef struct
467{
468 uint32_t ProximityPreferred : 1; /**< When set, allocations may come from other NUMA nodes. */
469 uint32_t Reserved : 30; /**< Reserved for future (as of circa v2). */
470 uint32_t ProxyimityInfoValid : 1; /**< Set if the NUMA information is valid. */
471} HV_PROXIMITY_DOMAIN_FLAGS;
472/** Pointer to Hyper-V NUMA flags. */
473typedef HV_PROXIMITY_DOMAIN_FLAGS *PHV_PROXIMITY_DOMAIN_FLAGS;
474
475/** Hyper-V NUMA information. */
476typedef struct
477{
478 HV_PROXIMITY_DOMAIN_ID Id; /**< NUMA node identifier. */
479 HV_PROXIMITY_DOMAIN_FLAGS Flags; /**< NUMA flags. */
480} HV_PROXIMITY_DOMAIN_INFO;
481/** Pointer to Hyper-V NUMA information. */
482typedef HV_PROXIMITY_DOMAIN_INFO *PHV_PROXIMITY_DOMAIN_INFO;
483
484/** Input for HvCallGetMemoryBalance. */
485typedef struct
486{
487 HV_PARTITION_ID TargetPartitionId;
488 HV_PROXIMITY_DOMAIN_INFO ProximityDomainInfo;
489} HV_INPUT_GET_MEMORY_BALANCE;
490AssertCompileSize(HV_INPUT_GET_MEMORY_BALANCE, 16);
491/** Pointer to the input for HvCallGetMemoryBalance. */
492typedef HV_INPUT_GET_MEMORY_BALANCE *PHV_INPUT_GET_MEMORY_BALANCE;
493
494/** Output for HvCallGetMemoryBalance. */
495typedef struct
496{
497 uint64_t PagesAvailable;
498 uint64_t PagesInUse;
499} HV_OUTPUT_GET_MEMORY_BALANCE;
500/** Pointer to the output for HvCallGetMemoryBalance. */
501typedef HV_OUTPUT_GET_MEMORY_BALANCE *PHV_OUTPUT_GET_MEMORY_BALANCE;
502
503
504/** @name Flags used with HvCallMapGpaPages and HvCallMapSparseGpaPages.
505 * @note There seems to be a more flags defined after v2.
506 * @{ */
507typedef uint32_t HV_MAP_GPA_FLAGS;
508#define HV_MAP_GPA_READABLE UINT32_C(0x0001)
509#define HV_MAP_GPA_WRITABLE UINT32_C(0x0002)
510#define HV_MAP_GPA_EXECUTABLE UINT32_C(0x0004)
511/** Seems this have to be set when HV_MAP_GPA_EXECUTABLE is (17101). */
512#define HV_MAP_GPA_EXECUTABLE_AGAIN UINT32_C(0x0008)
513/** Dunno what this is yet, but it requires HV_MAP_GPA_DUNNO_1000.
514 * The readable bit gets put here when both HV_MAP_GPA_DUNNO_1000 and
515 * HV_MAP_GPA_DUNNO_MASK_0700 are clear. */
516#define HV_MAP_GPA_DUNNO_ACCESS UINT32_C(0x0010)
517/** Guess work. */
518#define HV_MAP_GPA_MAYBE_ACCESS_MASK UINT32_C(0x001f)
519/** Some kind of mask. */
520#define HV_MAP_GPA_DUNNO_MASK_0700 UINT32_C(0x0700)
521/** Dunno what this is, but required for HV_MAP_GPA_DUNNO_ACCESS. */
522#define HV_MAP_GPA_DUNNO_1000 UINT32_C(0x1000)
523/** Working with large 2MB pages. */
524#define HV_MAP_GPA_LARGE UINT32_C(0x2000)
525/** Valid mask as per build 17101. */
526#define HV_MAP_GPA_VALID_MASK UINT32_C(0x7f1f)
527/** @} */
528
529/** Input for HvCallMapGpaPages. */
530typedef struct
531{
532 HV_PARTITION_ID TargetPartitionId;
533 HV_GPA_PAGE_NUMBER TargetGpaBase;
534 HV_MAP_GPA_FLAGS MapFlags;
535 uint32_t u32ExplicitPadding;
536 /* The repeating part: */
537 RT_FLEXIBLE_ARRAY_EXTENSION
538 HV_SPA_PAGE_NUMBER PageList[RT_FLEXIBLE_ARRAY];
539} HV_INPUT_MAP_GPA_PAGES;
540AssertCompileMemberOffset(HV_INPUT_MAP_GPA_PAGES, PageList, 24);
541/** Pointer to the input for HvCallMapGpaPages. */
542typedef HV_INPUT_MAP_GPA_PAGES *PHV_INPUT_MAP_GPA_PAGES;
543
544
545/** A parent to guest mapping pair for HvCallMapSparseGpaPages. */
546typedef struct
547{
548 HV_GPA_PAGE_NUMBER TargetGpaPageNumber;
549 HV_SPA_PAGE_NUMBER SourceSpaPageNumber;
550} HV_GPA_MAPPING;
551/** Pointer to a parent->guest mapping pair for HvCallMapSparseGpaPages. */
552typedef HV_GPA_MAPPING *PHV_GPA_MAPPING;
553
554/** Input for HvCallMapSparseGpaPages. */
555typedef struct
556{
557 HV_PARTITION_ID TargetPartitionId;
558 HV_MAP_GPA_FLAGS MapFlags;
559 uint32_t u32ExplicitPadding;
560 /* The repeating part: */
561 RT_FLEXIBLE_ARRAY_EXTENSION
562 HV_GPA_MAPPING PageList[RT_FLEXIBLE_ARRAY];
563} HV_INPUT_MAP_SPARSE_GPA_PAGES;
564AssertCompileMemberOffset(HV_INPUT_MAP_SPARSE_GPA_PAGES, PageList, 16);
565/** Pointer to the input for HvCallMapSparseGpaPages. */
566typedef HV_INPUT_MAP_SPARSE_GPA_PAGES *PHV_INPUT_MAP_SPARSE_GPA_PAGES;
567
568
569/** Input for HvCallUnmapGpaPages. */
570typedef struct
571{
572 HV_PARTITION_ID TargetPartitionId;
573 HV_GPA_PAGE_NUMBER TargetGpaBase;
574 /** This field is either an omission in the 7600 WDK or a later additions.
575 * Anyway, not quite sure what it does. Bit 2 seems to indicate 2MB pages. */
576 uint64_t fFlags;
577} HV_INPUT_UNMAP_GPA_PAGES;
578AssertCompileSize(HV_INPUT_UNMAP_GPA_PAGES, 24);
579/** Pointer to the input for HvCallUnmapGpaPages. */
580typedef HV_INPUT_UNMAP_GPA_PAGES *PHV_INPUT_UNMAP_GPA_PAGES;
581
582
583
584/** Cache types used by HvCallReadGpa and HvCallWriteGpa. */
585typedef enum
586{
587 HvCacheTypeX64Uncached = 0,
588 HvCacheTypeX64WriteCombining,
589 /* 2 & 3 are undefined. */
590 HvCacheTypeX64WriteThrough = 4,
591 HvCacheTypeX64WriteProtected,
592 HvCacheTypeX64WriteBack
593} HV_CACHE_TYPE;
594
595/** Control flags for HvCallReadGpa and HvCallWriteGpa. */
596typedef union
597{
598 uint64_t AsUINT64;
599 struct
600 {
601 uint64_t CacheType : 8; /**< HV_CACHE_TYPE */
602#ifndef IN_IDA_PRO
603 uint64_t Reserved : 56;
604#endif
605 };
606} HV_ACCESS_GPA_CONTROL_FLAGS;
607
608/** Results codes for HvCallReadGpa and HvCallWriteGpa. */
609typedef enum
610{
611 HvAccessGpaSuccess = 0,
612 HvAccessGpaUnmapped,
613 HvAccessGpaReadIntercept,
614 HvAccessGpaWriteIntercept,
615 HvAccessGpaIllegalOverlayAccess
616} HV_ACCESS_GPA_RESULT_CODE;
617
618/** The result of HvCallReadGpa and HvCallWriteGpa. */
619typedef union
620{
621 uint64_t AsUINT64;
622 struct
623 {
624 HV_ACCESS_GPA_RESULT_CODE ResultCode;
625 uint32_t Reserved;
626 };
627} HV_ACCESS_GPA_RESULT;
628
629
630/** Input for HvCallReadGpa. */
631typedef struct
632{
633 HV_PARTITION_ID PartitionId;
634 HV_VP_INDEX VpIndex;
635 uint32_t ByteCount;
636 HV_GPA BaseGpa;
637 HV_ACCESS_GPA_CONTROL_FLAGS ControlFlags;
638} HV_INPUT_READ_GPA;
639AssertCompileSize(HV_INPUT_READ_GPA, 32);
640/** Pointer to the input for HvCallReadGpa. */
641typedef HV_INPUT_READ_GPA *PHV_INPUT_READ_GPA;
642
643/** Output for HvCallReadGpa. */
644typedef struct
645{
646 HV_ACCESS_GPA_RESULT AccessResult;
647 uint8_t Data[16];
648} HV_OUTPUT_READ_GPA;
649AssertCompileSize(HV_OUTPUT_READ_GPA, 24);
650/** Pointer to the output for HvCallReadGpa. */
651typedef HV_OUTPUT_READ_GPA *PHV_OUTPUT_READ_GPA;
652
653
654/** Input for HvCallWriteGpa. */
655typedef struct
656{
657 HV_PARTITION_ID PartitionId;
658 HV_VP_INDEX VpIndex;
659 uint32_t ByteCount;
660 HV_GPA BaseGpa;
661 HV_ACCESS_GPA_CONTROL_FLAGS ControlFlags;
662 uint8_t Data[16];
663} HV_INPUT_WRITE_GPA;
664AssertCompileSize(HV_INPUT_READ_GPA, 32);
665/** Pointer to the input for HvCallWriteGpa. */
666typedef HV_INPUT_READ_GPA *PHV_INPUT_READ_GPA;
667
668/** Output for HvCallWriteGpa. */
669typedef struct
670{
671 HV_ACCESS_GPA_RESULT AccessResult;
672} HV_OUTPUT_WRITE_GPA;
673AssertCompileSize(HV_OUTPUT_WRITE_GPA, 8);
674/** Pointer to the output for HvCallWriteGpa. */
675typedef HV_OUTPUT_WRITE_GPA *PHV_OUTPUT_WRITE_GPA;
676
677
678/**
679 * Register names used by HvCallGetVpRegisters and HvCallSetVpRegisters.
680 */
681typedef enum _HV_REGISTER_NAME
682{
683 HvRegisterExplicitSuspend = 0x00000000,
684 HvRegisterInterceptSuspend,
685 HvRegisterUnknown02, /**< Reads as 0 initially on exo part. */
686 HvRegisterUnknown03, /**< Reads as 0 initially on exo part. */
687 HvRegisterInternalActivityState, /**< @since about build 17758 */
688
689 HvRegisterHypervisorVersion = 0x00000100, /**< @since v5 @note Not readable on exo part. */
690
691 HvRegisterPrivilegesAndFeaturesInfo = 0x00000200, /**< @since v5 @note Not readable on exo part. */
692 HvRegisterFeaturesInfo, /**< @since v5 @note Not readable on exo part. */
693 HvRegisterImplementationLimitsInfo, /**< @since v5 @note Not readable on exo part. */
694 HvRegisterHardwareFeaturesInfo, /**< @since v5 @note Not readable on exo part. */
695
696 HvRegisterGuestCrashP0 = 0x00000210, /**< @since v5 @note Not readable on exo part. */
697 HvRegisterGuestCrashP1, /**< @since v5 @note Not readable on exo part. */
698 HvRegisterGuestCrashP2, /**< @since v5 @note Not readable on exo part. */
699 HvRegisterGuestCrashP3, /**< @since v5 @note Not readable on exo part. */
700 HvRegisterGuestCrashP4, /**< @since v5 @note Not readable on exo part. */
701 HvRegisterGuestCrashCtl, /**< @since v5 @note Not readable on exo part. */
702
703 HvRegisterPowerStateConfigC1 = 0x00000220, /**< @since v5 @note Not readable on exo part. */
704 HvRegisterPowerStateTriggerC1, /**< @since v5 @note Not readable on exo part. */
705 HvRegisterPowerStateConfigC2, /**< @since v5 @note Not readable on exo part. */
706 HvRegisterPowerStateTriggerC2, /**< @since v5 @note Not readable on exo part. */
707 HvRegisterPowerStateConfigC3, /**< @since v5 @note Not readable on exo part. */
708 HvRegisterPowerStateTriggerC3, /**< @since v5 @note Not readable on exo part. */
709
710 HvRegisterSystemReset = 0x00000230, /**< @since v5 @note Not readable on exo part. */
711
712 HvRegisterProcessorClockFrequency = 0x00000240, /**< @since v5 @note Not readable on exo part. */
713 HvRegisterInterruptClockFrequency, /**< @since v5 @note Not readable on exo part. */
714
715 HvRegisterGuestIdle = 0x00000250, /**< @since v5 @note Not readable on exo part. */
716
717 HvRegisterDebugDeviceOptions = 0x00000260, /**< @since v5 @note Not readable on exo part. */
718
719 HvRegisterPendingInterruption = 0x00010002,
720 HvRegisterInterruptState,
721 HvRegisterPendingEvent0, /**< @since v5 */
722 HvRegisterPendingEvent1, /**< @since v5 */
723 HvX64RegisterDeliverabilityNotifications, /**< @since v5c? Late 2017? */
724
725 HvX64RegisterRax = 0x00020000,
726 HvX64RegisterRcx,
727 HvX64RegisterRdx,
728 HvX64RegisterRbx,
729 HvX64RegisterRsp,
730 HvX64RegisterRbp,
731 HvX64RegisterRsi,
732 HvX64RegisterRdi,
733 HvX64RegisterR8,
734 HvX64RegisterR9,
735 HvX64RegisterR10,
736 HvX64RegisterR11,
737 HvX64RegisterR12,
738 HvX64RegisterR13,
739 HvX64RegisterR14,
740 HvX64RegisterR15,
741 HvX64RegisterRip,
742 HvX64RegisterRflags,
743
744 HvX64RegisterXmm0 = 0x00030000,
745 HvX64RegisterXmm1,
746 HvX64RegisterXmm2,
747 HvX64RegisterXmm3,
748 HvX64RegisterXmm4,
749 HvX64RegisterXmm5,
750 HvX64RegisterXmm6,
751 HvX64RegisterXmm7,
752 HvX64RegisterXmm8,
753 HvX64RegisterXmm9,
754 HvX64RegisterXmm10,
755 HvX64RegisterXmm11,
756 HvX64RegisterXmm12,
757 HvX64RegisterXmm13,
758 HvX64RegisterXmm14,
759 HvX64RegisterXmm15,
760 HvX64RegisterFpMmx0,
761 HvX64RegisterFpMmx1,
762 HvX64RegisterFpMmx2,
763 HvX64RegisterFpMmx3,
764 HvX64RegisterFpMmx4,
765 HvX64RegisterFpMmx5,
766 HvX64RegisterFpMmx6,
767 HvX64RegisterFpMmx7,
768 HvX64RegisterFpControlStatus,
769 HvX64RegisterXmmControlStatus,
770
771 HvX64RegisterCr0 = 0x00040000,
772 HvX64RegisterCr2,
773 HvX64RegisterCr3,
774 HvX64RegisterCr4,
775 HvX64RegisterCr8,
776 HvX64RegisterXfem,
777
778 HvX64RegisterIntermediateCr0 = 0x00041000, /**< @since v5 */
779 HvX64RegisterIntermediateCr4 = 0x00041003, /**< @since v5 */
780 HvX64RegisterIntermediateCr8, /**< @since v5 */
781
782 HvX64RegisterDr0 = 0x00050000,
783 HvX64RegisterDr1,
784 HvX64RegisterDr2,
785 HvX64RegisterDr3,
786 HvX64RegisterDr6,
787 HvX64RegisterDr7,
788
789 HvX64RegisterEs = 0x00060000,
790 HvX64RegisterCs,
791 HvX64RegisterSs,
792 HvX64RegisterDs,
793 HvX64RegisterFs,
794 HvX64RegisterGs,
795 HvX64RegisterLdtr,
796 HvX64RegisterTr,
797
798 HvX64RegisterIdtr = 0x00070000,
799 HvX64RegisterGdtr,
800
801 HvX64RegisterTsc = 0x00080000,
802 HvX64RegisterEfer,
803 HvX64RegisterKernelGsBase,
804 HvX64RegisterApicBase,
805 HvX64RegisterPat,
806 HvX64RegisterSysenterCs,
807 HvX64RegisterSysenterEip,
808 HvX64RegisterSysenterEsp,
809 HvX64RegisterStar,
810 HvX64RegisterLstar,
811 HvX64RegisterCstar,
812 HvX64RegisterSfmask,
813 HvX64RegisterInitialApicId,
814
815 HvX64RegisterMtrrCap, /**< Not readable in exo partitions? */
816 HvX64RegisterMtrrDefType,
817
818 HvX64RegisterMtrrPhysBase0 = 0x00080010,
819 HvX64RegisterMtrrPhysBase1,
820 HvX64RegisterMtrrPhysBase2,
821 HvX64RegisterMtrrPhysBase3,
822 HvX64RegisterMtrrPhysBase4,
823 HvX64RegisterMtrrPhysBase5,
824 HvX64RegisterMtrrPhysBase6,
825 HvX64RegisterMtrrPhysBase7,
826 HvX64RegisterMtrrPhysBase8, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
827 HvX64RegisterMtrrPhysBase9, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
828 HvX64RegisterMtrrPhysBaseA, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
829 HvX64RegisterMtrrPhysBaseB, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
830 HvX64RegisterMtrrPhysBaseC, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
831 HvX64RegisterMtrrPhysBaseD, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
832 HvX64RegisterMtrrPhysBaseE, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
833 HvX64RegisterMtrrPhysBaseF, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
834
835 HvX64RegisterMtrrPhysMask0 = 0x00080040,
836 HvX64RegisterMtrrPhysMask1,
837 HvX64RegisterMtrrPhysMask2,
838 HvX64RegisterMtrrPhysMask3,
839 HvX64RegisterMtrrPhysMask4,
840 HvX64RegisterMtrrPhysMask5,
841 HvX64RegisterMtrrPhysMask6,
842 HvX64RegisterMtrrPhysMask7,
843 HvX64RegisterMtrrPhysMask8, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
844 HvX64RegisterMtrrPhysMask9, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
845 HvX64RegisterMtrrPhysMaskA, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
846 HvX64RegisterMtrrPhysMaskB, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
847 HvX64RegisterMtrrPhysMaskC, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
848 HvX64RegisterMtrrPhysMaskD, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
849 HvX64RegisterMtrrPhysMaskE, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
850 HvX64RegisterMtrrPhysMaskF, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
851
852 HvX64RegisterMtrrFix64k00000 = 0x00080070,
853 HvX64RegisterMtrrFix16k80000,
854 HvX64RegisterMtrrFix16kA0000,
855 HvX64RegisterMtrrFix4kC0000,
856 HvX64RegisterMtrrFix4kC8000,
857 HvX64RegisterMtrrFix4kD0000,
858 HvX64RegisterMtrrFix4kD8000,
859 HvX64RegisterMtrrFix4kE0000,
860 HvX64RegisterMtrrFix4kE8000,
861 HvX64RegisterMtrrFix4kF0000,
862 HvX64RegisterMtrrFix4kF8000,
863 HvX64RegisterTscAux, /**< @since v5c? late 2017? */
864
865 HvX64RegisterUnknown8007d = 0x0008007d, /**< Readable on exo partition (17134), initial value is zero. */
866
867 HvX64RegisterSpecCtrl = 0x00080084, /**< @since build about 17758 */
868 HvX64RegisterPredCmd, /**< @since build about 17758 */
869
870 HvX64RegisterIa32MiscEnable = 0x000800a0, /**< @since v5 @note Appears not to be readable on exo partition (Threadripper). */
871 HvX64RegisterIa32FeatureControl, /**< @since v5 @note Appears not to be readable on exo partition (Threadripper). */
872
873 HvX64RegisterApicId = 0x00084802, /**< @since build 17758 */
874 HvX64RegisterApicVersion, /**< @since build 17758 */
875
876 /** Uptime counter or some such thing. Unit is different than HvRegisterTimeRefCount or the accounting is different. */
877 HvX64RegisterVpRuntime = 0x00090000,
878 HvX64RegisterHypercall,
879 HvRegisterGuestOsId,
880 HvRegisterVpIndex,
881 HvRegisterTimeRefCount, /**< Time counter since partition creation, 100ns units. */
882
883 HvRegisterCpuManagementVersion = 0x00090007, /**< @since v5 @note Appears not to be readable on exo partition. */
884
885 HvX64RegisterEoi = 0x00090010, /**< @note Appears not to be readable on exo partition. */
886 HvX64RegisterIcr, /**< @note Appears not to be readable on exo partition. */
887 HvX64RegisterTpr, /**< @note Appears not to be readable on exo partition. */
888 HvRegisterVpAssistPage,
889 /** Readable on exo partition (17134). Some kind of counter. */
890 HvRegisterUnknown90014,
891
892 HvRegisterStatsPartitionRetail = 0x00090020,
893 HvRegisterStatsPartitionInternal,
894 HvRegisterStatsVpRetail,
895 HvRegisterStatsVpInternal,
896
897 HvRegisterSint0 = 0x000a0000,
898 HvRegisterSint1,
899 HvRegisterSint2,
900 HvRegisterSint3,
901 HvRegisterSint4,
902 HvRegisterSint5,
903 HvRegisterSint6,
904 HvRegisterSint7,
905 HvRegisterSint8,
906 HvRegisterSint9,
907 HvRegisterSint10,
908 HvRegisterSint11,
909 HvRegisterSint12,
910 HvRegisterSint13,
911 HvRegisterSint14,
912 HvRegisterSint15,
913 HvRegisterScontrol,
914 HvRegisterSversion,
915 HvRegisterSifp,
916 HvRegisterSipp,
917 HvRegisterEom,
918 HvRegisterSirbp, /**< @since v4 */
919
920 HvRegisterStimer0Config = 0x000b0000,
921 HvRegisterStimer0Count,
922 HvRegisterStimer1Config,
923 HvRegisterStimer1Count,
924 HvRegisterStimer2Config,
925 HvRegisterStimer2Count,
926 HvRegisterStimer3Config,
927 HvRegisterStimer3Count,
928
929 HvRegisterUnknown0b0100 = 0x000b0100, /**< Readable on exo partition (17134), initial value is zero. */
930 HvRegisterUnknown0b0101, /**< Readable on exo partition (17134), initial value is zero. */
931
932 HvX64RegisterYmm0Low = 0x000c0000, /**< @note Not readable on exo partition. Need something enabled? */
933 HvX64RegisterYmm1Low,
934 HvX64RegisterYmm2Low,
935 HvX64RegisterYmm3Low,
936 HvX64RegisterYmm4Low,
937 HvX64RegisterYmm5Low,
938 HvX64RegisterYmm6Low,
939 HvX64RegisterYmm7Low,
940 HvX64RegisterYmm8Low,
941 HvX64RegisterYmm9Low,
942 HvX64RegisterYmm10Low,
943 HvX64RegisterYmm11Low,
944 HvX64RegisterYmm12Low,
945 HvX64RegisterYmm13Low,
946 HvX64RegisterYmm14Low,
947 HvX64RegisterYmm15Low,
948 HvX64RegisterYmm0High,
949 HvX64RegisterYmm1High,
950 HvX64RegisterYmm2High,
951 HvX64RegisterYmm3High,
952 HvX64RegisterYmm4High,
953 HvX64RegisterYmm5High,
954 HvX64RegisterYmm6High,
955 HvX64RegisterYmm7High,
956 HvX64RegisterYmm8High,
957 HvX64RegisterYmm9High,
958 HvX64RegisterYmm10High,
959 HvX64RegisterYmm11High,
960 HvX64RegisterYmm12High,
961 HvX64RegisterYmm13High,
962 HvX64RegisterYmm14High,
963 HvX64RegisterYmm15High,
964
965 HvRegisterVsmVpVtlControl = 0x000d0000, /**< @note Not readable on exo partition. */
966
967 HvRegisterVsmCodePageOffsets = 0x000d0002,
968 HvRegisterVsmVpStatus,
969 HvRegisterVsmPartitionStatus,
970 HvRegisterVsmVina, /**< @note Not readable on exo partition. */
971 HvRegisterVsmCapabilities,
972 HvRegisterVsmPartitionConfig, /**< @note Not readable on exo partition. */
973
974 HvRegisterVsmVpSecureConfigVtl0 = 0x000d0010, /**< @since v5 */
975 HvRegisterVsmVpSecureConfigVtl1, /**< @since v5 */
976 HvRegisterVsmVpSecureConfigVtl2, /**< @since v5 */
977 HvRegisterVsmVpSecureConfigVtl3, /**< @since v5 */
978 HvRegisterVsmVpSecureConfigVtl4, /**< @since v5 */
979 HvRegisterVsmVpSecureConfigVtl5, /**< @since v5 */
980 HvRegisterVsmVpSecureConfigVtl6, /**< @since v5 */
981 HvRegisterVsmVpSecureConfigVtl7, /**< @since v5 */
982 HvRegisterVsmVpSecureConfigVtl8, /**< @since v5 */
983 HvRegisterVsmVpSecureConfigVtl9, /**< @since v5 */
984 HvRegisterVsmVpSecureConfigVtl10, /**< @since v5 */
985 HvRegisterVsmVpSecureConfigVtl11, /**< @since v5 */
986 HvRegisterVsmVpSecureConfigVtl12, /**< @since v5 */
987 HvRegisterVsmVpSecureConfigVtl13, /**< @since v5 */
988 HvRegisterVsmVpSecureConfigVtl14, /**< @since v5 */
989
990 HvRegisterUnknown0e0000 = 0x000e0000, /**< Readable on exo partition (17134), initial value zero. */
991 HvRegisterUnknown0e0001, /**< Readable on exo partition (17134), initial value zero. */
992 HvRegisterUnknown0e0002, /**< Readable on exo partition (17134), initial value zero. */
993 HvRegisterUnknown0e0003 /**< Readable on exo partition (17134), initial value zero. */
994} HV_REGISTER_NAME;
995AssertCompile(HvRegisterInterceptSuspend == 0x00000001);
996AssertCompile(HvRegisterPendingEvent1 == 0x00010005);
997AssertCompile(HvX64RegisterDeliverabilityNotifications == 0x00010006);
998AssertCompile(HvX64RegisterRflags == 0x00020011);
999AssertCompile(HvX64RegisterXmmControlStatus == 0x00030019);
1000AssertCompile(HvX64RegisterXfem == 0x00040005);
1001AssertCompile(HvX64RegisterIntermediateCr0 == 0x00041000);
1002AssertCompile(HvX64RegisterIntermediateCr4 == 0x00041003);
1003AssertCompile(HvX64RegisterDr7 == 0x00050005);
1004AssertCompile(HvX64RegisterTr == 0x00060007);
1005AssertCompile(HvX64RegisterGdtr == 0x00070001);
1006AssertCompile(HvX64RegisterInitialApicId == 0x0008000c);
1007AssertCompile(HvX64RegisterMtrrCap == 0x0008000d);
1008AssertCompile(HvX64RegisterMtrrDefType == 0x0008000e);
1009AssertCompile(HvX64RegisterMtrrPhysBaseF == 0x0008001f);
1010AssertCompile(HvX64RegisterMtrrPhysMaskF == 0x0008004f);
1011AssertCompile(HvX64RegisterMtrrFix4kF8000 == 0x0008007a);
1012AssertCompile(HvRegisterTimeRefCount == 0x00090004);
1013AssertCompile(HvRegisterCpuManagementVersion == 0x00090007);
1014AssertCompile(HvRegisterVpAssistPage == 0x00090013);
1015AssertCompile(HvRegisterStatsVpInternal == 0x00090023);
1016AssertCompile(HvRegisterSirbp == 0x000a0015);
1017AssertCompile(HvRegisterStimer3Count == 0x000b0007);
1018AssertCompile(HvX64RegisterYmm15High == 0x000c001f);
1019AssertCompile(HvRegisterVsmVpSecureConfigVtl14 == 0x000d001e);
1020AssertCompileSize(HV_REGISTER_NAME, 4);
1021
1022
1023/** Value format for HvRegisterExplicitSuspend. */
1024typedef union
1025{
1026 uint64_t AsUINT64;
1027 struct
1028 {
1029 uint64_t Suspended : 1;
1030#ifndef IN_IDA_PRO
1031 uint64_t Reserved : 63;
1032#endif
1033 };
1034} HV_EXPLICIT_SUSPEND_REGISTER;
1035/** Pointer to a value of HvRegisterExplicitSuspend. */
1036typedef HV_EXPLICIT_SUSPEND_REGISTER *PHV_EXPLICIT_SUSPEND_REGISTER;
1037
1038/** Value format for HvRegisterInterceptSuspend. */
1039typedef union
1040{
1041 uint64_t AsUINT64;
1042 struct
1043 {
1044 uint64_t Suspended : 1;
1045 uint64_t TlbLocked : 1;
1046#ifndef IN_IDA_PRO
1047 uint64_t Reserved : 62;
1048#endif
1049 };
1050} HV_INTERCEPT_SUSPEND_REGISTER;
1051/** Pointer to a value of HvRegisterInterceptSuspend. */
1052typedef HV_INTERCEPT_SUSPEND_REGISTER *PHV_INTERCEPT_SUSPEND_REGISTER;
1053
1054/** Value format for HvRegisterInterruptState.
1055 * @sa WHV_X64_INTERRUPT_STATE_REGISTER */
1056typedef union
1057{
1058 uint64_t AsUINT64;
1059 struct
1060 {
1061 uint64_t InterruptShadow : 1;
1062 uint64_t NmiMasked : 1;
1063#ifndef IN_IDA_PRO
1064 uint64_t Reserved : 62;
1065#endif
1066 };
1067} HV_X64_INTERRUPT_STATE_REGISTER;
1068/** Pointer to a value of HvRegisterInterruptState. */
1069typedef HV_X64_INTERRUPT_STATE_REGISTER *PHV_X64_INTERRUPT_STATE_REGISTER;
1070
1071/** Pending exception type for HvRegisterPendingInterruption.
1072 * @sa WHV_X64_PENDING_INTERRUPTION_TYPE */
1073typedef enum
1074{
1075 HvX64PendingInterrupt = 0,
1076 /* what is/was 1? */
1077 HvX64PendingNmi = 2,
1078 HvX64PendingException
1079 /* any more? */
1080} HV_X64_PENDING_INTERRUPTION_TYPE;
1081
1082/** Value format for HvRegisterPendingInterruption.
1083 * @sa WHV_X64_PENDING_INTERRUPTION_REGISTER */
1084typedef union
1085{
1086 uint64_t AsUINT64;
1087 struct
1088 {
1089 uint32_t InterruptionPending : 1;
1090 uint32_t InterruptionType : 3; /**< HV_X64_PENDING_INTERRUPTION_TYPE */
1091 uint32_t DeliverErrorCode : 1;
1092 uint32_t InstructionLength : 4; /**< @since v5? Wasn't in 7600 WDK */
1093 uint32_t NestedEvent : 1; /**< @since v5? Wasn't in 7600 WDK */
1094 uint32_t Reserved : 6;
1095 uint32_t InterruptionVector : 16;
1096 uint32_t ErrorCode;
1097 };
1098} HV_X64_PENDING_INTERRUPTION_REGISTER;
1099/** Pointer to a value of HvRegisterPendingInterruption. */
1100typedef HV_X64_PENDING_INTERRUPTION_REGISTER *PHV_X64_PENDING_INTERRUPTION_REGISTER;
1101
1102/** Value format for HvX64RegisterDeliverabilityNotifications.
1103 * Value format for HvRegisterPendingEvent0/1.
1104 * @sa WHV_X64_DELIVERABILITY_NOTIFICATIONS_REGISTER */
1105typedef union
1106{
1107 uint64_t AsUINT64;
1108 struct
1109 {
1110 uint64_t NmiNotification : 1;
1111 uint64_t InterruptNotification : 1;
1112 uint64_t InterruptPriority : 4;
1113#ifndef IN_IDA_PRO
1114 uint64_t Reserved : 58;
1115#endif
1116 };
1117} HV_X64_DELIVERABILITY_NOTIFICATIONS_REGISTER;
1118/** Pointer to a value of HvRegisterPendingEvent0/1. */
1119typedef HV_X64_DELIVERABILITY_NOTIFICATIONS_REGISTER *PHV_X64_DELIVERABILITY_NOTIFICATIONS_REGISTER;
1120
1121
1122/** Value format for HvX64RegisterEs..Tr.
1123 * @sa WHV_X64_SEGMENT_REGISTER */
1124typedef struct _HV_X64_SEGMENT_REGISTER
1125{
1126 uint64_t Base;
1127 uint32_t Limit;
1128 uint16_t Selector;
1129 union
1130 {
1131 struct
1132 {
1133 uint16_t SegmentType : 4;
1134 uint16_t NonSystemSegment : 1;
1135 uint16_t DescriptorPrivilegeLevel : 2;
1136 uint16_t Present : 1;
1137 uint16_t Reserved : 4;
1138 uint16_t Available : 1;
1139 uint16_t Long : 1;
1140 uint16_t Default : 1;
1141 uint16_t Granularity : 1;
1142 };
1143 uint16_t Attributes;
1144 };
1145} HV_X64_SEGMENT_REGISTER;
1146AssertCompileSize(HV_X64_SEGMENT_REGISTER, 16);
1147/** Pointer to a value of HvX64RegisterEs..Tr. */
1148typedef HV_X64_SEGMENT_REGISTER *PHV_X64_SEGMENT_REGISTER;
1149
1150/** Value format for HvX64RegisterIdtr/Gdtr.
1151 * @sa WHV_X64_TABLE_REGISTER */
1152typedef struct
1153{
1154 uint16_t Pad[3];
1155 uint16_t Limit;
1156 uint64_t Base;
1157} HV_X64_TABLE_REGISTER;
1158AssertCompileSize(HV_X64_TABLE_REGISTER, 16);
1159/** Pointer to a value of HvX64RegisterIdtr/Gdtrr. */
1160typedef HV_X64_TABLE_REGISTER *PHV_X64_TABLE_REGISTER;
1161
1162/** Value format for HvX64RegisterFpMmx0..7 in floating pointer mode.
1163 * @sa WHV_X64_FP_REGISTER, RTFLOAT80U2 */
1164typedef union
1165{
1166 HV_UINT128 AsUINT128;
1167 struct
1168 {
1169 uint64_t Mantissa;
1170 uint64_t BiasedExponent : 15;
1171 uint64_t Sign : 1;
1172#ifndef IN_IDA_PRO
1173 uint64_t Reserved : 48;
1174#endif
1175 };
1176} HV_X64_FP_REGISTER;
1177/** Pointer to a value of HvX64RegisterFpMmx0..7 in floating point mode. */
1178typedef HV_X64_FP_REGISTER *PHV_X64_FP_REGISTER;
1179
1180/** Value union for HvX64RegisterFpMmx0..7. */
1181typedef union
1182{
1183 HV_UINT128 AsUINT128;
1184 HV_X64_FP_REGISTER Fp;
1185 uint64_t Mmx;
1186} HV_X64_FP_MMX_REGISTER;
1187/** Pointer to a value of HvX64RegisterFpMmx0..7. */
1188typedef HV_X64_FP_MMX_REGISTER *PHV_X64_FP_MMX_REGISTER;
1189
1190/** Value format for HvX64RegisterFpControlStatus.
1191 * @sa WHV_X64_FP_CONTROL_STATUS_REGISTER */
1192typedef union
1193{
1194 HV_UINT128 AsUINT128;
1195 struct
1196 {
1197 uint16_t FpControl;
1198 uint16_t FpStatus;
1199 uint8_t FpTag;
1200 uint8_t IgnNe : 1;
1201 uint8_t Reserved : 7;
1202 uint16_t LastFpOp;
1203 union
1204 {
1205 uint64_t LastFpRip;
1206 struct
1207 {
1208 uint32_t LastFpEip;
1209 uint16_t LastFpCs;
1210 };
1211 };
1212 };
1213} HV_X64_FP_CONTROL_STATUS_REGISTER;
1214/** Pointer to a value of HvX64RegisterFpControlStatus. */
1215typedef HV_X64_FP_CONTROL_STATUS_REGISTER *PHV_X64_FP_CONTROL_STATUS_REGISTER;
1216
1217/** Value format for HvX64RegisterXmmControlStatus.
1218 * @sa WHV_X64_XMM_CONTROL_STATUS_REGISTER */
1219typedef union
1220{
1221 HV_UINT128 AsUINT128;
1222 struct
1223 {
1224 union
1225 {
1226 uint64_t LastFpRdp;
1227 struct
1228 {
1229 uint32_t LastFpDp;
1230 uint16_t LastFpDs;
1231 };
1232 };
1233 uint32_t XmmStatusControl;
1234 uint32_t XmmStatusControlMask;
1235 };
1236} HV_X64_XMM_CONTROL_STATUS_REGISTER;
1237/** Pointer to a value of HvX64RegisterXmmControlStatus. */
1238typedef HV_X64_XMM_CONTROL_STATUS_REGISTER *PHV_X64_XMM_CONTROL_STATUS_REGISTER;
1239
1240/** Register value union.
1241 * @sa WHV_REGISTER_VALUE */
1242typedef union
1243{
1244 HV_UINT128 Reg128;
1245 uint64_t Reg64;
1246 uint32_t Reg32;
1247 uint16_t Reg16;
1248 uint8_t Reg8;
1249 HV_EXPLICIT_SUSPEND_REGISTER ExplicitSuspend;
1250 HV_INTERCEPT_SUSPEND_REGISTER InterceptSuspend;
1251 HV_X64_INTERRUPT_STATE_REGISTER InterruptState;
1252 HV_X64_PENDING_INTERRUPTION_REGISTER PendingInterruption;
1253 HV_X64_DELIVERABILITY_NOTIFICATIONS_REGISTER DeliverabilityNotifications;
1254 HV_X64_TABLE_REGISTER Table;
1255 HV_X64_SEGMENT_REGISTER Segment;
1256 HV_X64_FP_REGISTER Fp;
1257 HV_X64_FP_CONTROL_STATUS_REGISTER FpControlStatus;
1258 HV_X64_XMM_CONTROL_STATUS_REGISTER XmmControlStatus;
1259} HV_REGISTER_VALUE;
1260AssertCompileSize(HV_REGISTER_VALUE, 16);
1261/** Pointer to a Hyper-V register value union. */
1262typedef HV_REGISTER_VALUE *PHV_REGISTER_VALUE;
1263/** Pointer to a const Hyper-V register value union. */
1264typedef HV_REGISTER_VALUE const *PCHV_REGISTER_VALUE;
1265
1266
1267/** Input for HvCallGetVpRegisters. */
1268typedef struct
1269{
1270 HV_PARTITION_ID PartitionId;
1271 HV_VP_INDEX VpIndex;
1272 /** Was this introduced after v2? Dunno what it it really is. */
1273 uint32_t fFlags;
1274 /* The repeating part: */
1275 RT_FLEXIBLE_ARRAY_EXTENSION
1276 HV_REGISTER_NAME Names[RT_FLEXIBLE_ARRAY];
1277} HV_INPUT_GET_VP_REGISTERS;
1278AssertCompileMemberOffset(HV_INPUT_GET_VP_REGISTERS, Names, 16);
1279/** Pointer to input for HvCallGetVpRegisters. */
1280typedef HV_INPUT_GET_VP_REGISTERS *PHV_INPUT_GET_VP_REGISTERS;
1281/* Output for HvCallGetVpRegisters is an array of HV_REGISTER_VALUE parallel to HV_INPUT_GET_VP_REGISTERS::Names. */
1282
1283
1284/** Register and value pair for HvCallSetVpRegisters. */
1285typedef struct
1286{
1287 HV_REGISTER_NAME Name;
1288 uint32_t Pad0;
1289 uint64_t Pad1;
1290 HV_REGISTER_VALUE Value;
1291} HV_REGISTER_ASSOC;
1292AssertCompileSize(HV_REGISTER_ASSOC, 32);
1293AssertCompileMemberOffset(HV_REGISTER_ASSOC, Value, 16);
1294/** Pointer to a register and value pair for HvCallSetVpRegisters. */
1295typedef HV_REGISTER_ASSOC *PHV_REGISTER_ASSOC;
1296/** Helper for clearing the alignment padding members. */
1297#define HV_REGISTER_ASSOC_ZERO_PADDING(a_pRegAssoc) do { (a_pRegAssoc)->Pad0 = 0; (a_pRegAssoc)->Pad1 = 0; } while (0)
1298/** Helper for clearing the alignment padding members and the high 64-bit
1299 * part of the value. */
1300#define HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(a_pRegAssoc) \
1301 do { (a_pRegAssoc)->Pad0 = 0; (a_pRegAssoc)->Pad1 = 0; (a_pRegAssoc)->Value.Reg128.High64 = 0; } while (0)
1302
1303/** Input for HvCallSetVpRegisters. */
1304typedef struct
1305{
1306 HV_PARTITION_ID PartitionId;
1307 HV_VP_INDEX VpIndex;
1308 uint32_t RsvdZ;
1309 /* The repeating part: */
1310 RT_FLEXIBLE_ARRAY_EXTENSION
1311 HV_REGISTER_ASSOC Elements[RT_FLEXIBLE_ARRAY];
1312} HV_INPUT_SET_VP_REGISTERS;
1313AssertCompileMemberOffset(HV_INPUT_SET_VP_REGISTERS, Elements, 16);
1314/** Pointer to input for HvCallSetVpRegisters. */
1315typedef HV_INPUT_SET_VP_REGISTERS *PHV_INPUT_SET_VP_REGISTERS;
1316
1317
1318
1319/**
1320 * Hyper-V SyncIC message types.
1321 */
1322typedef enum
1323{
1324 HvMessageTypeNone = 0x00000000,
1325
1326 HvMessageTypeUnmappedGpa = 0x80000000,
1327 HvMessageTypeGpaIntercept,
1328
1329 HvMessageTimerExpired = 0x80000010,
1330
1331 HvMessageTypeInvalidVpRegisterValue = 0x80000020,
1332 HvMessageTypeUnrecoverableException,
1333 HvMessageTypeUnsupportedFeature,
1334 HvMessageTypeTlbPageSizeMismatch, /**< @since v5 */
1335
1336 /** @note Same as HvMessageTypeX64ApicEoi? Gone in 5.0. Missing from 7600 WDK
1337 * headers even if it's in the 2.0 docs. */
1338 HvMessageTypeApicEoi = 0x80000030,
1339 /** @note Same as HvMessageTypeX64LegacyFpError? Gone in 5.0, whereas 4.0b
1340 * calls it HvMessageTypeX64LegacyFpError. Missing from 7600 WDK
1341 * headers even if it's in the 2.0 docs. */
1342 HvMessageTypeFerrAsserted,
1343
1344 HvMessageTypeEventLogBufferComplete = 0x80000040,
1345
1346 HvMessageTypeX64IoPortIntercept = 0x80010000,
1347 HvMessageTypeX64MsrIntercept,
1348 HvMessageTypeX64CpuidIntercept,
1349 HvMessageTypeX64ExceptionIntercept,
1350 /** @note Appeared in 5.0 docs, but were here in 7600 WDK headers already. */
1351 HvMessageTypeX64ApicEoi,
1352 /** @note Appeared in 5.0 docs, but were here in 7600 WDK headers already. */
1353 HvMessageTypeX64LegacyFpError,
1354 /** @since v5 */
1355 HvMessageTypeX64RegisterIntercept,
1356 /** @since WinHvPlatform? */
1357 HvMessageTypeX64Halt,
1358 /** @since WinHvPlatform? */
1359 HvMessageTypeX64InterruptWindow
1360
1361} HV_MESSAGE_TYPE;
1362AssertCompileSize(HV_MESSAGE_TYPE, 4);
1363AssertCompile(HvMessageTypeX64RegisterIntercept == 0x80010006);
1364AssertCompile(HvMessageTypeX64Halt == 0x80010007);
1365AssertCompile(HvMessageTypeX64InterruptWindow == 0x80010008);
1366/** Pointer to a Hyper-V SyncIC message type. */
1367typedef HV_MESSAGE_TYPE *PHV_MESSAGE_TYPE;
1368
1369/** Flag set for hypervisor messages, guest cannot send messages with this
1370 * flag set. */
1371#define HV_MESSAGE_TYPE_HYPERVISOR_MASK UINT32_C(0x80000000)
1372
1373/** Hyper-V SynIC message size (they are fixed sized). */
1374#define HV_MESSAGE_SIZE 256
1375/** Maximum Hyper-V SynIC message payload size in bytes. */
1376#define HV_MESSAGE_MAX_PAYLOAD_BYTE_COUNT (HV_MESSAGE_SIZE - 16)
1377/** Maximum Hyper-V SynIC message payload size in QWORDs (uint64_t). */
1378#define HV_MESSAGE_MAX_PAYLOAD_QWORD_COUNT (HV_MESSAGE_MAX_PAYLOAD_BYTE_COUNT / 8)
1379
1380/** SynIC message flags. */
1381typedef union
1382{
1383 uint8_t AsUINT8;
1384 struct
1385 {
1386 /** Messages are pending in the queue. */
1387 uint8_t MessagePending : 1;
1388 uint8_t Reserved : 7;
1389 };
1390} HV_MESSAGE_FLAGS;
1391AssertCompileSize(HV_MESSAGE_FLAGS, 1);
1392
1393/** SynIC message header. */
1394typedef struct
1395{
1396 HV_MESSAGE_TYPE MessageType;
1397 /** The 2.0-5.0b docs all have this incorrectly switched with 'Reserved', WDK 7600 got it right. */
1398 uint8_t PayloadSize;
1399 HV_MESSAGE_FLAGS MessageFlags;
1400 uint16_t Reserved;
1401 union
1402 {
1403 uint64_t OriginationId;
1404 HV_PARTITION_ID Sender;
1405 HV_PORT_ID Port;
1406 };
1407} HV_MESSAGE_HEADER;
1408AssertCompileSize(HV_MESSAGE_HEADER, 16);
1409/** Pointer to a Hyper-V message header. */
1410typedef HV_MESSAGE_HEADER *PHV_MESSAGE_HEADER;
1411/** Pointer to a const Hyper-V message header. */
1412typedef HV_MESSAGE_HEADER const *PCHV_MESSAGE_HEADER;
1413
1414
1415
1416/** @name Intercept access type.
1417 * @{ */
1418typedef uint8_t HV_INTERCEPT_ACCESS_TYPE;
1419#define HV_INTERCEPT_ACCESS_READ 0
1420#define HV_INTERCEPT_ACCESS_WRITE 1
1421#define HV_INTERCEPT_ACCESS_EXECUTE 2
1422/** @} */
1423
1424/** @name Intercept access type mask.
1425 * @{ */
1426typedef uint32_t HV_INTERCEPT_ACCESS_TYPE_MASK;
1427#define HV_INTERCEPT_ACCESS_MASK_NONE 0
1428#define HV_INTERCEPT_ACCESS_MASK_READ 1
1429#define HV_INTERCEPT_ACCESS_MASK_WRITE 2
1430#define HV_INTERCEPT_ACCESS_MASK_EXECUTE 4
1431/** @} */
1432
1433/** X64 intercept execution state.
1434 * @sa WHV_X64_VP_EXECUTION_STATE */
1435typedef union
1436{
1437 uint16_t AsUINT16;
1438 struct
1439 {
1440 uint16_t Cpl : 2;
1441 uint16_t Cr0Pe : 1;
1442 uint16_t Cr0Am : 1;
1443 uint16_t EferLma : 1;
1444 uint16_t DebugActive : 1;
1445 uint16_t InterruptionPending : 1;
1446 uint16_t Reserved0 : 5;
1447 uint16_t InterruptShadow : 1;
1448 uint16_t Reserved1 : 3;
1449 };
1450} HV_X64_VP_EXECUTION_STATE;
1451AssertCompileSize(HV_X64_VP_EXECUTION_STATE, 2);
1452/** Pointer to X86 intercept execution state. */
1453typedef HV_X64_VP_EXECUTION_STATE *PHV_X64_VP_EXECUTION_STATE;
1454/** Pointer to const X86 intercept execution state. */
1455typedef HV_X64_VP_EXECUTION_STATE const *PCHV_X64_VP_EXECUTION_STATE;
1456
1457/** X64 intercept message header. */
1458typedef struct
1459{
1460 HV_VP_INDEX VpIndex; /**< 0x00 */
1461 uint8_t InstructionLength : 4; /**< 0x04[3:0]: Zero if not available, instruction fetch exit, ... */
1462 uint8_t Cr8 : 4; /**< 0x04[7:4]: Not sure since when, but after v2. */
1463 HV_INTERCEPT_ACCESS_TYPE InterceptAccessType; /**< 0x05 */
1464 HV_X64_VP_EXECUTION_STATE ExecutionState; /**< 0x06 */
1465 HV_X64_SEGMENT_REGISTER CsSegment; /**< 0x08 */
1466 uint64_t Rip; /**< 0x18 */
1467 uint64_t Rflags; /**< 0x20 */
1468} HV_X64_INTERCEPT_MESSAGE_HEADER;
1469AssertCompileSize(HV_X64_INTERCEPT_MESSAGE_HEADER, 40);
1470/** Pointer to a x86 intercept message header. */
1471typedef HV_X64_INTERCEPT_MESSAGE_HEADER *PHV_X64_INTERCEPT_MESSAGE_HEADER;
1472
1473
1474/** X64 memory access flags (HvMessageTypeGpaIntercept, HvMessageTypeUnmappedGpa).
1475 * @sa WHV_MEMORY_ACCESS_INFO */
1476typedef union
1477{
1478 uint8_t AsUINT8;
1479 struct
1480 {
1481 uint8_t GvaValid : 1;
1482 uint8_t Reserved : 7;
1483 };
1484} HV_X64_MEMORY_ACCESS_INFO;
1485AssertCompileSize(HV_X64_MEMORY_ACCESS_INFO, 1);
1486
1487/** The payload format for HvMessageTypeGpaIntercept and HvMessageTypeUnmappedGpa.
1488 * @sa WHV_MEMORY_ACCESS_CONTEXT
1489 * @note max message size. */
1490typedef struct
1491{
1492 HV_X64_INTERCEPT_MESSAGE_HEADER Header; /**< 0x00 */
1493 HV_CACHE_TYPE CacheType; /**< 0x28 */
1494 uint8_t InstructionByteCount; /**< 0x2c */
1495 HV_X64_MEMORY_ACCESS_INFO MemoryAccessInfo; /**< 0x2d */
1496 uint16_t Reserved1; /**< 0x2e */
1497 uint64_t GuestVirtualAddress; /**< 0x30 */
1498 uint64_t GuestPhysicalAddress; /**< 0x38 */
1499 uint8_t InstructionBytes[16]; /**< 0x40 */
1500 /* We don't the following (v5 / WinHvPlatform): */
1501 HV_X64_SEGMENT_REGISTER DsSegment; /**< 0x50 */
1502 HV_X64_SEGMENT_REGISTER SsSegment; /**< 0x60 */
1503 uint64_t Rax; /**< 0x70 */
1504 uint64_t Rcx; /**< 0x78 */
1505 uint64_t Rdx; /**< 0x80 */
1506 uint64_t Rbx; /**< 0x88 */
1507 uint64_t Rsp; /**< 0x90 */
1508 uint64_t Rbp; /**< 0x98 */
1509 uint64_t Rsi; /**< 0xa0 */
1510 uint64_t Rdi; /**< 0xa8 */
1511 uint64_t R8; /**< 0xb0 */
1512 uint64_t R9; /**< 0xb8 */
1513 uint64_t R10; /**< 0xc0 */
1514 uint64_t R11; /**< 0xc8 */
1515 uint64_t R12; /**< 0xd0 */
1516 uint64_t R13; /**< 0xd8 */
1517 uint64_t R14; /**< 0xe0 */
1518 uint64_t R15; /**< 0xe8 */
1519} HV_X64_MEMORY_INTERCEPT_MESSAGE;
1520AssertCompileSize(HV_X64_MEMORY_INTERCEPT_MESSAGE, 0xf0);
1521AssertCompileMemberOffset(HV_X64_MEMORY_INTERCEPT_MESSAGE, DsSegment, 0x50);
1522/** Pointer to a HvMessageTypeGpaIntercept or HvMessageTypeUnmappedGpa payload. */
1523typedef HV_X64_MEMORY_INTERCEPT_MESSAGE *PHV_X64_MEMORY_INTERCEPT_MESSAGE;
1524/** Pointer to a const HvMessageTypeGpaIntercept or HvMessageTypeUnmappedGpa payload. */
1525typedef HV_X64_MEMORY_INTERCEPT_MESSAGE const *PCHV_X64_MEMORY_INTERCEPT_MESSAGE;
1526
1527
1528/** The payload format for HvMessageTypeX64MsrIntercept. */
1529typedef struct _HV_X64_MSR_INTERCEPT_MESSAGE
1530{
1531 HV_X64_INTERCEPT_MESSAGE_HEADER Header; /**< 0x00 */
1532 uint32_t MsrNumber; /**< 0x28 (ecx) */
1533 uint32_t Reserved; /**< 0x2c */
1534 uint64_t Rdx; /**< 0x30 */
1535 uint64_t Rax; /**< 0x38 */
1536} HV_X64_MSR_INTERCEPT_MESSAGE;
1537AssertCompileSize(HV_X64_MSR_INTERCEPT_MESSAGE, 0x40);
1538/** Pointer to a HvMessageTypeX64MsrIntercept payload. */
1539typedef HV_X64_MSR_INTERCEPT_MESSAGE *PHV_X64_MSR_INTERCEPT_MESSAGE;
1540/** Pointer to a const HvMessageTypeX64MsrIntercept payload. */
1541typedef HV_X64_MSR_INTERCEPT_MESSAGE const *PCHV_X64_MSR_INTERCEPT_MESSAGE;
1542
1543/** Full MSR message. */
1544typedef struct
1545{
1546 HV_MESSAGE_HEADER MsgHdr;
1547 HV_X64_MSR_INTERCEPT_MESSAGE Payload;
1548} HV_X64_MSR_INTERCEPT_MESSAGE_FULL;
1549
1550
1551/** X64 I/O port access information (HvMessageTypeX64IoPortIntercept). */
1552typedef union HV_X64_IO_PORT_ACCESS_INFO
1553{
1554 uint8_t AsUINT8;
1555 struct
1556 {
1557 uint8_t AccessSize : 3;
1558 uint8_t StringOp : 1;
1559 uint8_t RepPrefix : 1;
1560 uint8_t Reserved : 3;
1561 };
1562} HV_X64_IO_PORT_ACCESS_INFO;
1563AssertCompileSize(HV_X64_IO_PORT_ACCESS_INFO, 1);
1564
1565/** The payload format for HvMessageTypeX64IoPortIntercept. */
1566typedef struct _HV_X64_IO_PORT_INTERCEPT_MESSAGE
1567{
1568 HV_X64_INTERCEPT_MESSAGE_HEADER Header; /**< 0x00 */
1569 uint16_t PortNumber; /**< 0x28 */
1570 HV_X64_IO_PORT_ACCESS_INFO AccessInfo; /**< 0x2a */
1571 uint8_t InstructionByteCount; /**< 0x2b */
1572 uint32_t Reserved; /**< 0x2c */
1573 uint64_t Rax; /**< 0x30 */
1574 uint8_t InstructionBytes[16]; /**< 0x38 */
1575 HV_X64_SEGMENT_REGISTER DsSegment; /**< 0x48 */
1576 HV_X64_SEGMENT_REGISTER EsSegment; /**< 0x58 */
1577 uint64_t Rcx; /**< 0x68 */
1578 uint64_t Rsi; /**< 0x70 */
1579 uint64_t Rdi; /**< 0x78 */
1580} HV_X64_IO_PORT_INTERCEPT_MESSAGE;
1581AssertCompileSize(HV_X64_IO_PORT_INTERCEPT_MESSAGE, 128);
1582/** Pointer to a HvMessageTypeX64IoPortIntercept payload. */
1583typedef HV_X64_IO_PORT_INTERCEPT_MESSAGE *PHV_X64_IO_PORT_INTERCEPT_MESSAGE;
1584/** Pointer to a const HvMessageTypeX64IoPortIntercept payload. */
1585typedef HV_X64_IO_PORT_INTERCEPT_MESSAGE const *PCHV_X64_IO_PORT_INTERCEPT_MESSAGE;
1586
1587/** Full I/O port message. */
1588typedef struct
1589{
1590 HV_MESSAGE_HEADER MsgHdr;
1591 HV_X64_IO_PORT_INTERCEPT_MESSAGE Payload;
1592} HV_X64_IO_PORT_INTERCEPT_MESSAGE_FULL;
1593
1594
1595/**
1596 * The payload format for HvMessageTypeX64CpuidIntercept,
1597 *
1598 * @note This message does not include HV_X64_INTERCEPT_MESSAGE_HEADER!
1599 */
1600typedef struct
1601{
1602 HV_X64_INTERCEPT_MESSAGE_HEADER Header; /**< 0x00: The usual intercept header. */
1603 uint64_t Rax; /**< 0x28: Input RAX. */
1604 uint64_t Rcx; /**< 0x30: Input RCX. */
1605 uint64_t Rdx; /**< 0x38: Input RDX. */
1606 uint64_t Rbx; /**< 0x40: Input RBX. */
1607 uint64_t DefaultResultRax; /**< 0x48: Default result RAX. */
1608 uint64_t DefaultResultRcx; /**< 0x50: Default result RCX. */
1609 uint64_t DefaultResultRdx; /**< 0x58: Default result RDX. */
1610 uint64_t DefaultResultRbx; /**< 0x60: Default result RBX. */
1611} HV_X64_CPUID_INTERCEPT_MESSAGE;
1612AssertCompileSize(HV_X64_CPUID_INTERCEPT_MESSAGE, 0x68);
1613/** Pointer to a HvMessageTypeX64CpuidIntercept payload. */
1614typedef HV_X64_CPUID_INTERCEPT_MESSAGE *PHV_X64_CPUID_INTERCEPT_MESSAGE;
1615/** Pointer to a const HvMessageTypeX64CpuidIntercept payload. */
1616typedef HV_X64_CPUID_INTERCEPT_MESSAGE const *PCHV_X64_CPUID_INTERCEPT_MESSAGE;
1617
1618/** Full HvMessageTypeX64CpuidIntercept message. */
1619typedef struct
1620{
1621 HV_MESSAGE_HEADER MsgHdr;
1622 HV_X64_CPUID_INTERCEPT_MESSAGE Payload;
1623} HV_X64_CPUID_INTERCEPT_MESSAGE_FULL;
1624
1625
1626/** X64 exception information (HvMessageTypeX64ExceptionIntercept).
1627 * @sa WHV_VP_EXCEPTION_INFO */
1628typedef union
1629{
1630 uint8_t AsUINT8;
1631 struct
1632 {
1633 uint8_t ErrorCodeValid : 1;
1634 /** @todo WHV_VP_EXCEPTION_INFO::SoftwareException */
1635 uint8_t Reserved : 7;
1636 };
1637} HV_X64_EXCEPTION_INFO;
1638AssertCompileSize(HV_X64_EXCEPTION_INFO, 1);
1639
1640/** The payload format for HvMessageTypeX64ExceptionIntercept.
1641 * @sa WHV_VP_EXCEPTION_CONTEXT
1642 * @note max message size. */
1643typedef struct
1644{
1645 HV_X64_INTERCEPT_MESSAGE_HEADER Header; /**< 0x00 */
1646 uint16_t ExceptionVector; /**< 0x28 */
1647 HV_X64_EXCEPTION_INFO ExceptionInfo; /**< 0x2a */
1648 uint8_t InstructionByteCount; /**< 0x2b */
1649 uint32_t ErrorCode; /**< 0x2c */
1650 uint64_t ExceptionParameter; /**< 0x30 */
1651 uint64_t Reserved; /**< 0x38 */
1652 uint8_t InstructionBytes[16]; /**< 0x40 */
1653 HV_X64_SEGMENT_REGISTER DsSegment; /**< 0x50 */
1654 HV_X64_SEGMENT_REGISTER SsSegment; /**< 0x60 */
1655 uint64_t Rax; /**< 0x70 */
1656 uint64_t Rcx; /**< 0x78 */
1657 uint64_t Rdx; /**< 0x80 */
1658 uint64_t Rbx; /**< 0x88 */
1659 uint64_t Rsp; /**< 0x90 */
1660 uint64_t Rbp; /**< 0x98 */
1661 uint64_t Rsi; /**< 0xa0 */
1662 uint64_t Rdi; /**< 0xa8 */
1663 uint64_t R8; /**< 0xb0 */
1664 uint64_t R9; /**< 0xb8 */
1665 uint64_t R10; /**< 0xc0 */
1666 uint64_t R11; /**< 0xc8 */
1667 uint64_t R12; /**< 0xd0 */
1668 uint64_t R13; /**< 0xd8 */
1669 uint64_t R14; /**< 0xe0 */
1670 uint64_t R15; /**< 0xe8 */
1671} HV_X64_EXCEPTION_INTERCEPT_MESSAGE;
1672AssertCompileSize(HV_X64_EXCEPTION_INTERCEPT_MESSAGE, 0xf0);
1673/** Pointer to a HvMessageTypeX64ExceptionIntercept payload. */
1674typedef HV_X64_EXCEPTION_INTERCEPT_MESSAGE *PHV_X64_EXCEPTION_INTERCEPT_MESSAGE;
1675/** Pointer to a ocnst HvMessageTypeX64ExceptionIntercept payload. */
1676typedef HV_X64_EXCEPTION_INTERCEPT_MESSAGE const *PCHV_X64_EXCEPTION_INTERCEPT_MESSAGE;
1677
1678
1679/**
1680 * The payload format for HvMessageTypeX64Halt,
1681 *
1682 * @note This message does not include HV_X64_INTERCEPT_MESSAGE_HEADER!
1683 */
1684typedef struct
1685{
1686 /** Seems to be a zero 64-bit field here. */
1687 uint64_t u64Reserved;
1688} HV_X64_HALT_MESSAGE;
1689/** Pointer to a HvMessageTypeX64Halt payload. */
1690typedef HV_X64_HALT_MESSAGE *PHV_X64_HALT_MESSAGE;
1691/** Pointer to a const HvMessageTypeX64Halt payload. */
1692typedef HV_X64_HALT_MESSAGE const *PCHV_X64_HALT_MESSAGE;
1693
1694/** Full HvMessageTypeX64Halt message. */
1695typedef struct
1696{
1697 HV_MESSAGE_HEADER MsgHdr;
1698 HV_X64_HALT_MESSAGE Payload;
1699} HV_X64_HALT_MESSAGE_FULL;
1700
1701
1702/**
1703 * The payload format for HvMessageTypeX64InterruptWindow,
1704 *
1705 * @note This message does not include HV_X64_INTERCEPT_MESSAGE_HEADER!
1706 */
1707typedef struct
1708{
1709 /** 0x00: The usual intercept header. */
1710 HV_X64_INTERCEPT_MESSAGE_HEADER Header;
1711 /** 0x28: What's pending. */
1712 HV_X64_PENDING_INTERRUPTION_TYPE Type;
1713 /** 0x2c: Explicit structure alignment padding. */
1714 uint32_t u32ExplicitPadding;
1715} HV_X64_INTERRUPT_WINDOW_MESSAGE;
1716AssertCompileSize(HV_X64_INTERRUPT_WINDOW_MESSAGE, 0x30);
1717/** Pointer to a HvMessageTypeX64InterruptWindow payload. */
1718typedef HV_X64_INTERRUPT_WINDOW_MESSAGE *PHV_X64_INTERRUPT_WINDOW_MESSAGE;
1719/** Pointer to a const HvMessageTypeX64InterruptWindow payload. */
1720typedef HV_X64_INTERRUPT_WINDOW_MESSAGE const *PCHV_X64_INTERRUPT_WINDOW_MESSAGE;
1721
1722/** Full HvMessageTypeX64InterruptWindow message. */
1723typedef struct
1724{
1725 /** Payload size is 0x30. */
1726 HV_MESSAGE_HEADER MsgHdr;
1727 HV_X64_INTERRUPT_WINDOW_MESSAGE Payload;
1728} HV_X64_INTERRUPT_WINDOW_MESSAGE_FULL;
1729
1730
1731
1732/** Hyper-V SynIC message. */
1733typedef struct
1734{
1735 HV_MESSAGE_HEADER Header;
1736 /** 0x10 */
1737 union
1738 {
1739 uint64_t Payload[HV_MESSAGE_MAX_PAYLOAD_QWORD_COUNT];
1740
1741 /** Common header for X64 intercept messages.
1742 * The HvMessageTypeUnrecoverableException message only has this. */
1743 HV_X64_INTERCEPT_MESSAGE_HEADER X64InterceptHeader;
1744 /** HvMessageTypeGpaIntercept, HvMessageTypeUnmappedGpa. */
1745 HV_X64_MEMORY_INTERCEPT_MESSAGE X64MemoryIntercept;
1746 /** HvMessageTypeX64IoPortIntercept */
1747 HV_X64_IO_PORT_INTERCEPT_MESSAGE X64IoPortIntercept;
1748 /** HvMessageTypeX64MsrIntercept */
1749 HV_X64_MSR_INTERCEPT_MESSAGE X64MsrIntercept;
1750 /** HvMessageTypeX64CpuidIntercept */
1751 HV_X64_CPUID_INTERCEPT_MESSAGE X64CpuIdIntercept;
1752 /** HvMessageTypeX64ExceptionIntercept */
1753 HV_X64_EXCEPTION_INTERCEPT_MESSAGE X64ExceptionIntercept;
1754 /** HvMessageTypeX64Halt.
1755 * @note No intercept header? */
1756 HV_X64_HALT_MESSAGE X64Halt;
1757 /** HvMessageTypeX64InterruptWindow. */
1758 HV_X64_INTERRUPT_WINDOW_MESSAGE X64InterruptWindow;
1759 };
1760} HV_MESSAGE;
1761AssertCompileSize(HV_MESSAGE, HV_MESSAGE_SIZE);
1762/** Pointer to a Hyper-V SynIC message. */
1763typedef HV_MESSAGE *PHV_MESSAGE;
1764/** Pointer to const a Hyper-V SynIC message. */
1765typedef HV_MESSAGE const *PCHV_MESSAGE;
1766
1767#endif /* !IPRT_INCLUDED_nt_hyperv_h */
1768
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette