VirtualBox

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

Last change on this file since 84509 was 84509, checked in by vboxsync, 5 years ago

iprt/cdefs.h,*: Introducing RT_FLEXIBLE_ARRAY_EXTENSION as a g++ hack that allows us to use RT_FLEXIBLE_ARRAY without the compiler going all pendantic on us. Only tested with 10.1.0. bugref:9746

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