VirtualBox

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

Last change on this file since 78377 was 76585, checked in by vboxsync, 6 years ago

*: scm --fix-header-guard-endif

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