VirtualBox

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

Last change on this file since 94311 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 73.2 KB
Line 
1/** @file
2 * Hyper-V related types and definitions.
3 */
4
5/*
6 * Copyright (C) 2018-2022 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 HvPartitionPropertySyntheticProcessorFeaturesBanks, /**< Read by WHvApi::Capabilities::GetSyntheticProcessorFeaturesBanks (build 22000) */
354
355 HvPartitionPropertyCpuReserve = 0x00020001,
356 HvPartitionPropertyCpuCap,
357 HvPartitionPropertyCpuWeight,
358 HvPartitionPropertyUnknown20004, /**< On exo partition (build 17134), initial value zero. */
359
360 HvPartitionPropertyEmulatedTimerPeriod = 0x00030000, /**< @note Fails on exo partition (build 17134). */
361 HvPartitionPropertyEmulatedTimerControl, /**< @note Fails on exo partition (build 17134). */
362 HvPartitionPropertyPmTimerAssist, /**< @note Fails on exo partition (build 17134). */
363 HvPartitionPropertyUnknown30003, /**< @note WHvSetupPartition writes this (build 22000). */
364 HvPartitionPropertyUnknown30004, /**< ? */
365 HvPartitionPropertyUnknown30005, /**< WHvPartitionPropertyCodeReferenceTime maps to this (build 22000) */
366
367 HvPartitionPropertyDebugChannelId = 0x00040000, /**< @note Hangs system on exo partition hangs (build 17134). */
368
369 HvPartitionPropertyVirtualTlbPageCount = 0x00050000,
370 HvPartitionPropertyUnknown50001, /**< On exo partition (build 17134), initial value zero. */
371 HvPartitionPropertyUnknown50002, /**< On exo partition (build 17134), initial value zero. */
372 HvPartitionPropertyUnknown50003, /**< On exo partition (build 17134), initial value zero. */
373 HvPartitionPropertyUnknown50004, /**< On exo partition (build 17134), initial value zero. */
374 HvPartitionPropertyUnknown50005, /**< On exo partition (build 17134), initial value one. */
375 HvPartitionPropertyUnknown50006, /**< On exo partition (build 17134), initial value zero.
376 * @note build 22000/w11-ga fends this off in VID.SYS. */
377 HvPartitionPropertyUnknown50007,
378 HvPartitionPropertyUnknown50008,
379 HvPartitionPropertyUnknown50009,
380 HvPartitionPropertyUnknown5000a,
381 HvPartitionPropertyUnknown5000b,
382 HvPartitionPropertyUnknown5000c,
383 HvPartitionPropertyUnknown5000d,
384 HvPartitionPropertyUnknown5000e,
385 HvPartitionPropertyUnknown5000f,
386 HvPartitionPropertyUnknown50010,
387 HvPartitionPropertyUnknown50012,
388 HvPartitionPropertyUnknown50013, /**< Set by WHvSetupPartition (build 22000) */
389 HvPartitionPropertyUnknown50014,
390 HvPartitionPropertyUnknown50015,
391 HvPartitionPropertyUnknown50016,
392 HvPartitionPropertyUnknown50017, /**< Set by WHvSetupPartition (build 22000) */
393
394 HvPartitionPropertyProcessorVendor = 0x00060000,
395 HvPartitionPropertyProcessorFeatures, /**< On exo/17134/threadripper: 0x6cb26f39fbf */
396 HvPartitionPropertyProcessorXsaveFeatures,
397 HvPartitionPropertyProcessorCLFlushSize, /**< On exo/17134/threadripper: 8 */
398 HvPartitionPropertyUnknown60004, /**< On exo partition (build 17134), initial value zero. */
399 HvPartitionPropertyUnknown60005, /**< On exo partition (build 17134), initial value 0x603. */
400 HvPartitionPropertyUnknown60006, /**< On exo partition (build 17134), initial value 0x2c. */
401 HvPartitionPropertyUnknown60007, /**< WHvSetupPartition reads this (build 22000). */
402 HvPartitionPropertyUnknown60008, /**< WHvSetupPartition reads this (build 22000). */
403 HvPartitionPropertyProcessorClockFrequency, /**< Read by WHvApi::Capabilities::GetProcessorClockFrequency (build 22000). */
404 HvPartitionPropertyProcessorFeaturesBank0, /**< Read by WHvApi::Capabilities::GetProcessorFeaturesBanks (build 22000). */
405 HvPartitionPropertyProcessorFeaturesBank1, /**< Read by WHvApi::Capabilities::GetProcessorFeaturesBanks (build 22000). */
406
407 HvPartitionPropertyGuestOsId = 0x00070000, /**< @since v4 */
408
409 HvPartitionPropertyUnknown800000 = 0x00080000 /**< On exo partition (build 17134), initial value zero. */
410} HV_PARTITION_PROPERTY_CODE;
411AssertCompileSize(HV_PARTITION_PROPERTY_CODE, 4);
412/** Pointer to a partition property code. */
413typedef HV_PARTITION_PROPERTY_CODE *PHV_PARTITION_PROPERTY_CODE;
414
415
416/** Input for HvCallGetPartitionProperty. */
417typedef struct
418{
419 HV_PARTITION_ID PartitionId;
420 HV_PARTITION_PROPERTY_CODE PropertyCode;
421 uint32_t uPadding;
422} HV_INPUT_GET_PARTITION_PROPERTY;
423AssertCompileSize(HV_INPUT_GET_PARTITION_PROPERTY, 16);
424/** Pointer to input for HvCallGetPartitionProperty. */
425typedef HV_INPUT_GET_PARTITION_PROPERTY *PHV_INPUT_GET_PARTITION_PROPERTY;
426
427/** Output for HvCallGetPartitionProperty. */
428typedef struct
429{
430 HV_PARTITION_PROPERTY PropertyValue;
431} HV_OUTPUT_GET_PARTITION_PROPERTY;
432/** Pointer to output for HvCallGetPartitionProperty. */
433typedef HV_OUTPUT_GET_PARTITION_PROPERTY *PHV_OUTPUT_GET_PARTITION_PROPERTY;
434
435
436/** Input for HvCallSetPartitionProperty. */
437typedef struct
438{
439 HV_PARTITION_ID PartitionId;
440 HV_PARTITION_PROPERTY_CODE PropertyCode;
441 uint32_t uPadding;
442 HV_PARTITION_PROPERTY PropertyValue;
443} HV_INPUT_SET_PARTITION_PROPERTY;
444AssertCompileSize(HV_INPUT_SET_PARTITION_PROPERTY, 24);
445/** Pointer to input for HvCallSetPartitionProperty. */
446typedef HV_INPUT_SET_PARTITION_PROPERTY *PHV_INPUT_SET_PARTITION_PROPERTY;
447
448
449/** Hyper-V NUMA node ID.
450 * On systems without NUMA, i.e. a single node, it uses 0 as identifier. */
451typedef uint32_t HV_PROXIMITY_DOMAIN_ID;
452/** Pointer to NUMA node ID. */
453typedef HV_PROXIMITY_DOMAIN_ID *PHV_PROXIMITY_DOMAIN_ID;
454
455/** Hyper-V NUMA flags. */
456typedef struct
457{
458 uint32_t ProximityPreferred : 1; /**< When set, allocations may come from other NUMA nodes. */
459 uint32_t Reserved : 30; /**< Reserved for future (as of circa v2). */
460 uint32_t ProxyimityInfoValid : 1; /**< Set if the NUMA information is valid. */
461} HV_PROXIMITY_DOMAIN_FLAGS;
462/** Pointer to Hyper-V NUMA flags. */
463typedef HV_PROXIMITY_DOMAIN_FLAGS *PHV_PROXIMITY_DOMAIN_FLAGS;
464
465/** Hyper-V NUMA information. */
466typedef struct
467{
468 HV_PROXIMITY_DOMAIN_ID Id; /**< NUMA node identifier. */
469 HV_PROXIMITY_DOMAIN_FLAGS Flags; /**< NUMA flags. */
470} HV_PROXIMITY_DOMAIN_INFO;
471/** Pointer to Hyper-V NUMA information. */
472typedef HV_PROXIMITY_DOMAIN_INFO *PHV_PROXIMITY_DOMAIN_INFO;
473
474/** Input for HvCallGetMemoryBalance. */
475typedef struct
476{
477 HV_PARTITION_ID TargetPartitionId;
478 HV_PROXIMITY_DOMAIN_INFO ProximityDomainInfo;
479} HV_INPUT_GET_MEMORY_BALANCE;
480AssertCompileSize(HV_INPUT_GET_MEMORY_BALANCE, 16);
481/** Pointer to the input for HvCallGetMemoryBalance. */
482typedef HV_INPUT_GET_MEMORY_BALANCE *PHV_INPUT_GET_MEMORY_BALANCE;
483
484/** Output for HvCallGetMemoryBalance. */
485typedef struct
486{
487 uint64_t PagesAvailable;
488 uint64_t PagesInUse;
489} HV_OUTPUT_GET_MEMORY_BALANCE;
490/** Pointer to the output for HvCallGetMemoryBalance. */
491typedef HV_OUTPUT_GET_MEMORY_BALANCE *PHV_OUTPUT_GET_MEMORY_BALANCE;
492
493
494/** @name Flags used with HvCallMapGpaPages and HvCallMapSparseGpaPages.
495 * @note There seems to be a more flags defined after v2.
496 * @{ */
497typedef uint32_t HV_MAP_GPA_FLAGS;
498#define HV_MAP_GPA_READABLE UINT32_C(0x0001)
499#define HV_MAP_GPA_WRITABLE UINT32_C(0x0002)
500#define HV_MAP_GPA_EXECUTABLE UINT32_C(0x0004)
501/** Seems this have to be set when HV_MAP_GPA_EXECUTABLE is (17101). */
502#define HV_MAP_GPA_EXECUTABLE_AGAIN UINT32_C(0x0008)
503/** Dunno what this is yet, but it requires HV_MAP_GPA_DUNNO_1000.
504 * The readable bit gets put here when both HV_MAP_GPA_DUNNO_1000 and
505 * HV_MAP_GPA_DUNNO_MASK_0700 are clear. */
506#define HV_MAP_GPA_DUNNO_ACCESS UINT32_C(0x0010)
507/** Guess work. */
508#define HV_MAP_GPA_MAYBE_ACCESS_MASK UINT32_C(0x001f)
509/** Some kind of mask. */
510#define HV_MAP_GPA_DUNNO_MASK_0700 UINT32_C(0x0700)
511/** Dunno what this is, but required for HV_MAP_GPA_DUNNO_ACCESS. */
512#define HV_MAP_GPA_DUNNO_1000 UINT32_C(0x1000)
513/** Working with large 2MB pages. */
514#define HV_MAP_GPA_LARGE UINT32_C(0x2000)
515/** Valid mask as per build 17101. */
516#define HV_MAP_GPA_VALID_MASK UINT32_C(0x7f1f)
517/** @} */
518
519/** Input for HvCallMapGpaPages. */
520typedef struct
521{
522 HV_PARTITION_ID TargetPartitionId;
523 HV_GPA_PAGE_NUMBER TargetGpaBase;
524 HV_MAP_GPA_FLAGS MapFlags;
525 uint32_t u32ExplicitPadding;
526 /* The repeating part: */
527 RT_FLEXIBLE_ARRAY_EXTENSION
528 HV_SPA_PAGE_NUMBER PageList[RT_FLEXIBLE_ARRAY];
529} HV_INPUT_MAP_GPA_PAGES;
530AssertCompileMemberOffset(HV_INPUT_MAP_GPA_PAGES, PageList, 24);
531/** Pointer to the input for HvCallMapGpaPages. */
532typedef HV_INPUT_MAP_GPA_PAGES *PHV_INPUT_MAP_GPA_PAGES;
533
534
535/** A parent to guest mapping pair for HvCallMapSparseGpaPages. */
536typedef struct
537{
538 HV_GPA_PAGE_NUMBER TargetGpaPageNumber;
539 HV_SPA_PAGE_NUMBER SourceSpaPageNumber;
540} HV_GPA_MAPPING;
541/** Pointer to a parent->guest mapping pair for HvCallMapSparseGpaPages. */
542typedef HV_GPA_MAPPING *PHV_GPA_MAPPING;
543
544/** Input for HvCallMapSparseGpaPages. */
545typedef struct
546{
547 HV_PARTITION_ID TargetPartitionId;
548 HV_MAP_GPA_FLAGS MapFlags;
549 uint32_t u32ExplicitPadding;
550 /* The repeating part: */
551 RT_FLEXIBLE_ARRAY_EXTENSION
552 HV_GPA_MAPPING PageList[RT_FLEXIBLE_ARRAY];
553} HV_INPUT_MAP_SPARSE_GPA_PAGES;
554AssertCompileMemberOffset(HV_INPUT_MAP_SPARSE_GPA_PAGES, PageList, 16);
555/** Pointer to the input for HvCallMapSparseGpaPages. */
556typedef HV_INPUT_MAP_SPARSE_GPA_PAGES *PHV_INPUT_MAP_SPARSE_GPA_PAGES;
557
558
559/** Input for HvCallUnmapGpaPages. */
560typedef struct
561{
562 HV_PARTITION_ID TargetPartitionId;
563 HV_GPA_PAGE_NUMBER TargetGpaBase;
564 /** This field is either an omission in the 7600 WDK or a later additions.
565 * Anyway, not quite sure what it does. Bit 2 seems to indicate 2MB pages. */
566 uint64_t fFlags;
567} HV_INPUT_UNMAP_GPA_PAGES;
568AssertCompileSize(HV_INPUT_UNMAP_GPA_PAGES, 24);
569/** Pointer to the input for HvCallUnmapGpaPages. */
570typedef HV_INPUT_UNMAP_GPA_PAGES *PHV_INPUT_UNMAP_GPA_PAGES;
571
572
573
574/** Cache types used by HvCallReadGpa and HvCallWriteGpa. */
575typedef enum
576{
577 HvCacheTypeX64Uncached = 0,
578 HvCacheTypeX64WriteCombining,
579 /* 2 & 3 are undefined. */
580 HvCacheTypeX64WriteThrough = 4,
581 HvCacheTypeX64WriteProtected,
582 HvCacheTypeX64WriteBack
583} HV_CACHE_TYPE;
584
585/** Control flags for HvCallReadGpa and HvCallWriteGpa. */
586typedef union
587{
588 uint64_t AsUINT64;
589 struct
590 {
591 uint64_t CacheType : 8; /**< HV_CACHE_TYPE */
592#ifndef IN_IDA_PRO
593 uint64_t Reserved : 56;
594#endif
595 };
596} HV_ACCESS_GPA_CONTROL_FLAGS;
597
598/** Results codes for HvCallReadGpa and HvCallWriteGpa. */
599typedef enum
600{
601 HvAccessGpaSuccess = 0,
602 HvAccessGpaUnmapped,
603 HvAccessGpaReadIntercept,
604 HvAccessGpaWriteIntercept,
605 HvAccessGpaIllegalOverlayAccess
606} HV_ACCESS_GPA_RESULT_CODE;
607
608/** The result of HvCallReadGpa and HvCallWriteGpa. */
609typedef union
610{
611 uint64_t AsUINT64;
612 struct
613 {
614 HV_ACCESS_GPA_RESULT_CODE ResultCode;
615 uint32_t Reserved;
616 };
617} HV_ACCESS_GPA_RESULT;
618
619
620/** Input for HvCallReadGpa. */
621typedef struct
622{
623 HV_PARTITION_ID PartitionId;
624 HV_VP_INDEX VpIndex;
625 uint32_t ByteCount;
626 HV_GPA BaseGpa;
627 HV_ACCESS_GPA_CONTROL_FLAGS ControlFlags;
628} HV_INPUT_READ_GPA;
629AssertCompileSize(HV_INPUT_READ_GPA, 32);
630/** Pointer to the input for HvCallReadGpa. */
631typedef HV_INPUT_READ_GPA *PHV_INPUT_READ_GPA;
632
633/** Output for HvCallReadGpa. */
634typedef struct
635{
636 HV_ACCESS_GPA_RESULT AccessResult;
637 uint8_t Data[16];
638} HV_OUTPUT_READ_GPA;
639AssertCompileSize(HV_OUTPUT_READ_GPA, 24);
640/** Pointer to the output for HvCallReadGpa. */
641typedef HV_OUTPUT_READ_GPA *PHV_OUTPUT_READ_GPA;
642
643
644/** Input for HvCallWriteGpa. */
645typedef struct
646{
647 HV_PARTITION_ID PartitionId;
648 HV_VP_INDEX VpIndex;
649 uint32_t ByteCount;
650 HV_GPA BaseGpa;
651 HV_ACCESS_GPA_CONTROL_FLAGS ControlFlags;
652 uint8_t Data[16];
653} HV_INPUT_WRITE_GPA;
654AssertCompileSize(HV_INPUT_READ_GPA, 32);
655/** Pointer to the input for HvCallWriteGpa. */
656typedef HV_INPUT_READ_GPA *PHV_INPUT_READ_GPA;
657
658/** Output for HvCallWriteGpa. */
659typedef struct
660{
661 HV_ACCESS_GPA_RESULT AccessResult;
662} HV_OUTPUT_WRITE_GPA;
663AssertCompileSize(HV_OUTPUT_WRITE_GPA, 8);
664/** Pointer to the output for HvCallWriteGpa. */
665typedef HV_OUTPUT_WRITE_GPA *PHV_OUTPUT_WRITE_GPA;
666
667
668/**
669 * Register names used by HvCallGetVpRegisters and HvCallSetVpRegisters.
670 */
671typedef enum _HV_REGISTER_NAME
672{
673 HvRegisterExplicitSuspend = 0x00000000,
674 HvRegisterInterceptSuspend,
675 HvRegisterUnknown02, /**< Reads as 0 initially on exo part. */
676 HvRegisterUnknown03, /**< Reads as 0 initially on exo part. */
677 HvRegisterInternalActivityState, /**< @since about build 17758 */
678
679 HvRegisterHypervisorVersion = 0x00000100, /**< @since v5 @note Not readable on exo part. */
680
681 HvRegisterPrivilegesAndFeaturesInfo = 0x00000200, /**< @since v5 @note Not readable on exo part. */
682 HvRegisterFeaturesInfo, /**< @since v5 @note Not readable on exo part. */
683 HvRegisterImplementationLimitsInfo, /**< @since v5 @note Not readable on exo part. */
684 HvRegisterHardwareFeaturesInfo, /**< @since v5 @note Not readable on exo part. */
685
686 HvRegisterGuestCrashP0 = 0x00000210, /**< @since v5 @note Not readable on exo part. */
687 HvRegisterGuestCrashP1, /**< @since v5 @note Not readable on exo part. */
688 HvRegisterGuestCrashP2, /**< @since v5 @note Not readable on exo part. */
689 HvRegisterGuestCrashP3, /**< @since v5 @note Not readable on exo part. */
690 HvRegisterGuestCrashP4, /**< @since v5 @note Not readable on exo part. */
691 HvRegisterGuestCrashCtl, /**< @since v5 @note Not readable on exo part. */
692
693 HvRegisterPowerStateConfigC1 = 0x00000220, /**< @since v5 @note Not readable on exo part. */
694 HvRegisterPowerStateTriggerC1, /**< @since v5 @note Not readable on exo part. */
695 HvRegisterPowerStateConfigC2, /**< @since v5 @note Not readable on exo part. */
696 HvRegisterPowerStateTriggerC2, /**< @since v5 @note Not readable on exo part. */
697 HvRegisterPowerStateConfigC3, /**< @since v5 @note Not readable on exo part. */
698 HvRegisterPowerStateTriggerC3, /**< @since v5 @note Not readable on exo part. */
699
700 HvRegisterSystemReset = 0x00000230, /**< @since v5 @note Not readable on exo part. */
701
702 HvRegisterProcessorClockFrequency = 0x00000240, /**< @since v5 @note Not readable on exo part. */
703 HvRegisterInterruptClockFrequency, /**< @since v5 @note Not readable on exo part. */
704
705 HvRegisterGuestIdle = 0x00000250, /**< @since v5 @note Not readable on exo part. */
706
707 HvRegisterDebugDeviceOptions = 0x00000260, /**< @since v5 @note Not readable on exo part. */
708
709 HvRegisterPendingInterruption = 0x00010002,
710 HvRegisterInterruptState,
711 HvRegisterPendingEvent0, /**< @since v5 */
712 HvRegisterPendingEvent1, /**< @since v5 */
713 HvX64RegisterDeliverabilityNotifications, /**< @since v5c? Late 2017? */
714
715 HvX64RegisterRax = 0x00020000,
716 HvX64RegisterRcx,
717 HvX64RegisterRdx,
718 HvX64RegisterRbx,
719 HvX64RegisterRsp,
720 HvX64RegisterRbp,
721 HvX64RegisterRsi,
722 HvX64RegisterRdi,
723 HvX64RegisterR8,
724 HvX64RegisterR9,
725 HvX64RegisterR10,
726 HvX64RegisterR11,
727 HvX64RegisterR12,
728 HvX64RegisterR13,
729 HvX64RegisterR14,
730 HvX64RegisterR15,
731 HvX64RegisterRip,
732 HvX64RegisterRflags,
733
734 HvX64RegisterXmm0 = 0x00030000,
735 HvX64RegisterXmm1,
736 HvX64RegisterXmm2,
737 HvX64RegisterXmm3,
738 HvX64RegisterXmm4,
739 HvX64RegisterXmm5,
740 HvX64RegisterXmm6,
741 HvX64RegisterXmm7,
742 HvX64RegisterXmm8,
743 HvX64RegisterXmm9,
744 HvX64RegisterXmm10,
745 HvX64RegisterXmm11,
746 HvX64RegisterXmm12,
747 HvX64RegisterXmm13,
748 HvX64RegisterXmm14,
749 HvX64RegisterXmm15,
750 HvX64RegisterFpMmx0,
751 HvX64RegisterFpMmx1,
752 HvX64RegisterFpMmx2,
753 HvX64RegisterFpMmx3,
754 HvX64RegisterFpMmx4,
755 HvX64RegisterFpMmx5,
756 HvX64RegisterFpMmx6,
757 HvX64RegisterFpMmx7,
758 HvX64RegisterFpControlStatus,
759 HvX64RegisterXmmControlStatus,
760
761 HvX64RegisterCr0 = 0x00040000,
762 HvX64RegisterCr2,
763 HvX64RegisterCr3,
764 HvX64RegisterCr4,
765 HvX64RegisterCr8,
766 HvX64RegisterXfem,
767
768 HvX64RegisterIntermediateCr0 = 0x00041000, /**< @since v5 */
769 HvX64RegisterIntermediateCr4 = 0x00041003, /**< @since v5 */
770 HvX64RegisterIntermediateCr8, /**< @since v5 */
771
772 HvX64RegisterDr0 = 0x00050000,
773 HvX64RegisterDr1,
774 HvX64RegisterDr2,
775 HvX64RegisterDr3,
776 HvX64RegisterDr6,
777 HvX64RegisterDr7,
778
779 HvX64RegisterEs = 0x00060000,
780 HvX64RegisterCs,
781 HvX64RegisterSs,
782 HvX64RegisterDs,
783 HvX64RegisterFs,
784 HvX64RegisterGs,
785 HvX64RegisterLdtr,
786 HvX64RegisterTr,
787
788 HvX64RegisterIdtr = 0x00070000,
789 HvX64RegisterGdtr,
790
791 HvX64RegisterTsc = 0x00080000,
792 HvX64RegisterEfer,
793 HvX64RegisterKernelGsBase,
794 HvX64RegisterApicBase,
795 HvX64RegisterPat,
796 HvX64RegisterSysenterCs,
797 HvX64RegisterSysenterEip,
798 HvX64RegisterSysenterEsp,
799 HvX64RegisterStar,
800 HvX64RegisterLstar,
801 HvX64RegisterCstar,
802 HvX64RegisterSfmask,
803 HvX64RegisterInitialApicId,
804
805 HvX64RegisterMtrrCap, /**< Not readable in exo partitions? */
806 HvX64RegisterMtrrDefType,
807
808 HvX64RegisterMtrrPhysBase0 = 0x00080010,
809 HvX64RegisterMtrrPhysBase1,
810 HvX64RegisterMtrrPhysBase2,
811 HvX64RegisterMtrrPhysBase3,
812 HvX64RegisterMtrrPhysBase4,
813 HvX64RegisterMtrrPhysBase5,
814 HvX64RegisterMtrrPhysBase6,
815 HvX64RegisterMtrrPhysBase7,
816 HvX64RegisterMtrrPhysBase8, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
817 HvX64RegisterMtrrPhysBase9, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
818 HvX64RegisterMtrrPhysBaseA, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
819 HvX64RegisterMtrrPhysBaseB, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
820 HvX64RegisterMtrrPhysBaseC, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
821 HvX64RegisterMtrrPhysBaseD, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
822 HvX64RegisterMtrrPhysBaseE, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
823 HvX64RegisterMtrrPhysBaseF, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
824
825 HvX64RegisterMtrrPhysMask0 = 0x00080040,
826 HvX64RegisterMtrrPhysMask1,
827 HvX64RegisterMtrrPhysMask2,
828 HvX64RegisterMtrrPhysMask3,
829 HvX64RegisterMtrrPhysMask4,
830 HvX64RegisterMtrrPhysMask5,
831 HvX64RegisterMtrrPhysMask6,
832 HvX64RegisterMtrrPhysMask7,
833 HvX64RegisterMtrrPhysMask8, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
834 HvX64RegisterMtrrPhysMask9, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
835 HvX64RegisterMtrrPhysMaskA, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
836 HvX64RegisterMtrrPhysMaskB, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
837 HvX64RegisterMtrrPhysMaskC, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
838 HvX64RegisterMtrrPhysMaskD, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
839 HvX64RegisterMtrrPhysMaskE, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
840 HvX64RegisterMtrrPhysMaskF, /**< @since v4 @note Appears not to be readable on exo partition (Threadripper). */
841
842 HvX64RegisterMtrrFix64k00000 = 0x00080070,
843 HvX64RegisterMtrrFix16k80000,
844 HvX64RegisterMtrrFix16kA0000,
845 HvX64RegisterMtrrFix4kC0000,
846 HvX64RegisterMtrrFix4kC8000,
847 HvX64RegisterMtrrFix4kD0000,
848 HvX64RegisterMtrrFix4kD8000,
849 HvX64RegisterMtrrFix4kE0000,
850 HvX64RegisterMtrrFix4kE8000,
851 HvX64RegisterMtrrFix4kF0000,
852 HvX64RegisterMtrrFix4kF8000,
853 HvX64RegisterTscAux, /**< @since v5c? late 2017? */
854
855 HvX64RegisterUnknown8007d = 0x0008007d, /**< Readable on exo partition (17134), initial value is zero. */
856
857 HvX64RegisterSpecCtrl = 0x00080084, /**< @since build about 17758 */
858 HvX64RegisterPredCmd, /**< @since build about 17758 */
859
860 HvX64RegisterIa32MiscEnable = 0x000800a0, /**< @since v5 @note Appears not to be readable on exo partition (Threadripper). */
861 HvX64RegisterIa32FeatureControl, /**< @since v5 @note Appears not to be readable on exo partition (Threadripper). */
862
863 HvX64RegisterApicId = 0x00084802, /**< @since build 17758 */
864 HvX64RegisterApicVersion, /**< @since build 17758 */
865
866 /** Uptime counter or some such thing. Unit is different than HvRegisterTimeRefCount or the accounting is different. */
867 HvX64RegisterVpRuntime = 0x00090000,
868 HvX64RegisterHypercall,
869 HvRegisterGuestOsId,
870 HvRegisterVpIndex,
871 HvRegisterTimeRefCount, /**< Time counter since partition creation, 100ns units. */
872
873 HvRegisterCpuManagementVersion = 0x00090007, /**< @since v5 @note Appears not to be readable on exo partition. */
874
875 HvX64RegisterEoi = 0x00090010, /**< @note Appears not to be readable on exo partition. */
876 HvX64RegisterIcr, /**< @note Appears not to be readable on exo partition. */
877 HvX64RegisterTpr, /**< @note Appears not to be readable on exo partition. */
878 HvRegisterVpAssistPage,
879 /** Readable on exo partition (17134). Some kind of counter. */
880 HvRegisterUnknown90014,
881
882 HvRegisterStatsPartitionRetail = 0x00090020,
883 HvRegisterStatsPartitionInternal,
884 HvRegisterStatsVpRetail,
885 HvRegisterStatsVpInternal,
886
887 HvRegisterSint0 = 0x000a0000,
888 HvRegisterSint1,
889 HvRegisterSint2,
890 HvRegisterSint3,
891 HvRegisterSint4,
892 HvRegisterSint5,
893 HvRegisterSint6,
894 HvRegisterSint7,
895 HvRegisterSint8,
896 HvRegisterSint9,
897 HvRegisterSint10,
898 HvRegisterSint11,
899 HvRegisterSint12,
900 HvRegisterSint13,
901 HvRegisterSint14,
902 HvRegisterSint15,
903 HvRegisterScontrol,
904 HvRegisterSversion,
905 HvRegisterSifp,
906 HvRegisterSipp,
907 HvRegisterEom,
908 HvRegisterSirbp, /**< @since v4 */
909
910 HvRegisterStimer0Config = 0x000b0000,
911 HvRegisterStimer0Count,
912 HvRegisterStimer1Config,
913 HvRegisterStimer1Count,
914 HvRegisterStimer2Config,
915 HvRegisterStimer2Count,
916 HvRegisterStimer3Config,
917 HvRegisterStimer3Count,
918
919 HvRegisterUnknown0b0100 = 0x000b0100, /**< Readable on exo partition (17134), initial value is zero. */
920 HvRegisterUnknown0b0101, /**< Readable on exo partition (17134), initial value is zero. */
921
922 HvX64RegisterYmm0Low = 0x000c0000, /**< @note Not readable on exo partition. Need something enabled? */
923 HvX64RegisterYmm1Low,
924 HvX64RegisterYmm2Low,
925 HvX64RegisterYmm3Low,
926 HvX64RegisterYmm4Low,
927 HvX64RegisterYmm5Low,
928 HvX64RegisterYmm6Low,
929 HvX64RegisterYmm7Low,
930 HvX64RegisterYmm8Low,
931 HvX64RegisterYmm9Low,
932 HvX64RegisterYmm10Low,
933 HvX64RegisterYmm11Low,
934 HvX64RegisterYmm12Low,
935 HvX64RegisterYmm13Low,
936 HvX64RegisterYmm14Low,
937 HvX64RegisterYmm15Low,
938 HvX64RegisterYmm0High,
939 HvX64RegisterYmm1High,
940 HvX64RegisterYmm2High,
941 HvX64RegisterYmm3High,
942 HvX64RegisterYmm4High,
943 HvX64RegisterYmm5High,
944 HvX64RegisterYmm6High,
945 HvX64RegisterYmm7High,
946 HvX64RegisterYmm8High,
947 HvX64RegisterYmm9High,
948 HvX64RegisterYmm10High,
949 HvX64RegisterYmm11High,
950 HvX64RegisterYmm12High,
951 HvX64RegisterYmm13High,
952 HvX64RegisterYmm14High,
953 HvX64RegisterYmm15High,
954
955 HvRegisterVsmVpVtlControl = 0x000d0000, /**< @note Not readable on exo partition. */
956
957 HvRegisterVsmCodePageOffsets = 0x000d0002,
958 HvRegisterVsmVpStatus,
959 HvRegisterVsmPartitionStatus,
960 HvRegisterVsmVina, /**< @note Not readable on exo partition. */
961 HvRegisterVsmCapabilities,
962 HvRegisterVsmPartitionConfig, /**< @note Not readable on exo partition. */
963
964 HvRegisterVsmVpSecureConfigVtl0 = 0x000d0010, /**< @since v5 */
965 HvRegisterVsmVpSecureConfigVtl1, /**< @since v5 */
966 HvRegisterVsmVpSecureConfigVtl2, /**< @since v5 */
967 HvRegisterVsmVpSecureConfigVtl3, /**< @since v5 */
968 HvRegisterVsmVpSecureConfigVtl4, /**< @since v5 */
969 HvRegisterVsmVpSecureConfigVtl5, /**< @since v5 */
970 HvRegisterVsmVpSecureConfigVtl6, /**< @since v5 */
971 HvRegisterVsmVpSecureConfigVtl7, /**< @since v5 */
972 HvRegisterVsmVpSecureConfigVtl8, /**< @since v5 */
973 HvRegisterVsmVpSecureConfigVtl9, /**< @since v5 */
974 HvRegisterVsmVpSecureConfigVtl10, /**< @since v5 */
975 HvRegisterVsmVpSecureConfigVtl11, /**< @since v5 */
976 HvRegisterVsmVpSecureConfigVtl12, /**< @since v5 */
977 HvRegisterVsmVpSecureConfigVtl13, /**< @since v5 */
978 HvRegisterVsmVpSecureConfigVtl14, /**< @since v5 */
979
980 HvRegisterUnknown0e0000 = 0x000e0000, /**< Readable on exo partition (17134), initial value zero. */
981 HvRegisterUnknown0e0001, /**< Readable on exo partition (17134), initial value zero. */
982 HvRegisterUnknown0e0002, /**< Readable on exo partition (17134), initial value zero. */
983 HvRegisterUnknown0e0003 /**< Readable on exo partition (17134), initial value zero. */
984} HV_REGISTER_NAME;
985AssertCompile(HvRegisterInterceptSuspend == 0x00000001);
986AssertCompile(HvRegisterPendingEvent1 == 0x00010005);
987AssertCompile(HvX64RegisterDeliverabilityNotifications == 0x00010006);
988AssertCompile(HvX64RegisterRflags == 0x00020011);
989AssertCompile(HvX64RegisterXmmControlStatus == 0x00030019);
990AssertCompile(HvX64RegisterXfem == 0x00040005);
991AssertCompile(HvX64RegisterIntermediateCr0 == 0x00041000);
992AssertCompile(HvX64RegisterIntermediateCr4 == 0x00041003);
993AssertCompile(HvX64RegisterDr7 == 0x00050005);
994AssertCompile(HvX64RegisterTr == 0x00060007);
995AssertCompile(HvX64RegisterGdtr == 0x00070001);
996AssertCompile(HvX64RegisterInitialApicId == 0x0008000c);
997AssertCompile(HvX64RegisterMtrrCap == 0x0008000d);
998AssertCompile(HvX64RegisterMtrrDefType == 0x0008000e);
999AssertCompile(HvX64RegisterMtrrPhysBaseF == 0x0008001f);
1000AssertCompile(HvX64RegisterMtrrPhysMaskF == 0x0008004f);
1001AssertCompile(HvX64RegisterMtrrFix4kF8000 == 0x0008007a);
1002AssertCompile(HvRegisterTimeRefCount == 0x00090004);
1003AssertCompile(HvRegisterCpuManagementVersion == 0x00090007);
1004AssertCompile(HvRegisterVpAssistPage == 0x00090013);
1005AssertCompile(HvRegisterStatsVpInternal == 0x00090023);
1006AssertCompile(HvRegisterSirbp == 0x000a0015);
1007AssertCompile(HvRegisterStimer3Count == 0x000b0007);
1008AssertCompile(HvX64RegisterYmm15High == 0x000c001f);
1009AssertCompile(HvRegisterVsmVpSecureConfigVtl14 == 0x000d001e);
1010AssertCompileSize(HV_REGISTER_NAME, 4);
1011
1012
1013/** Value format for HvRegisterExplicitSuspend. */
1014typedef union
1015{
1016 uint64_t AsUINT64;
1017 struct
1018 {
1019 uint64_t Suspended : 1;
1020#ifndef IN_IDA_PRO
1021 uint64_t Reserved : 63;
1022#endif
1023 };
1024} HV_EXPLICIT_SUSPEND_REGISTER;
1025/** Pointer to a value of HvRegisterExplicitSuspend. */
1026typedef HV_EXPLICIT_SUSPEND_REGISTER *PHV_EXPLICIT_SUSPEND_REGISTER;
1027
1028/** Value format for HvRegisterInterceptSuspend. */
1029typedef union
1030{
1031 uint64_t AsUINT64;
1032 struct
1033 {
1034 uint64_t Suspended : 1;
1035 uint64_t TlbLocked : 1;
1036#ifndef IN_IDA_PRO
1037 uint64_t Reserved : 62;
1038#endif
1039 };
1040} HV_INTERCEPT_SUSPEND_REGISTER;
1041/** Pointer to a value of HvRegisterInterceptSuspend. */
1042typedef HV_INTERCEPT_SUSPEND_REGISTER *PHV_INTERCEPT_SUSPEND_REGISTER;
1043
1044/** Value format for HvRegisterInterruptState.
1045 * @sa WHV_X64_INTERRUPT_STATE_REGISTER */
1046typedef union
1047{
1048 uint64_t AsUINT64;
1049 struct
1050 {
1051 uint64_t InterruptShadow : 1;
1052 uint64_t NmiMasked : 1;
1053#ifndef IN_IDA_PRO
1054 uint64_t Reserved : 62;
1055#endif
1056 };
1057} HV_X64_INTERRUPT_STATE_REGISTER;
1058/** Pointer to a value of HvRegisterInterruptState. */
1059typedef HV_X64_INTERRUPT_STATE_REGISTER *PHV_X64_INTERRUPT_STATE_REGISTER;
1060
1061/** Pending exception type for HvRegisterPendingInterruption.
1062 * @sa WHV_X64_PENDING_INTERRUPTION_TYPE */
1063typedef enum
1064{
1065 HvX64PendingInterrupt = 0,
1066 /* what is/was 1? */
1067 HvX64PendingNmi = 2,
1068 HvX64PendingException
1069 /* any more? */
1070} HV_X64_PENDING_INTERRUPTION_TYPE;
1071
1072/** Value format for HvRegisterPendingInterruption.
1073 * @sa WHV_X64_PENDING_INTERRUPTION_REGISTER */
1074typedef union
1075{
1076 uint64_t AsUINT64;
1077 struct
1078 {
1079 uint32_t InterruptionPending : 1;
1080 uint32_t InterruptionType : 3; /**< HV_X64_PENDING_INTERRUPTION_TYPE */
1081 uint32_t DeliverErrorCode : 1;
1082 uint32_t InstructionLength : 4; /**< @since v5? Wasn't in 7600 WDK */
1083 uint32_t NestedEvent : 1; /**< @since v5? Wasn't in 7600 WDK */
1084 uint32_t Reserved : 6;
1085 uint32_t InterruptionVector : 16;
1086 uint32_t ErrorCode;
1087 };
1088} HV_X64_PENDING_INTERRUPTION_REGISTER;
1089/** Pointer to a value of HvRegisterPendingInterruption. */
1090typedef HV_X64_PENDING_INTERRUPTION_REGISTER *PHV_X64_PENDING_INTERRUPTION_REGISTER;
1091
1092/** Value format for HvX64RegisterDeliverabilityNotifications.
1093 * Value format for HvRegisterPendingEvent0/1.
1094 * @sa WHV_X64_DELIVERABILITY_NOTIFICATIONS_REGISTER */
1095typedef union
1096{
1097 uint64_t AsUINT64;
1098 struct
1099 {
1100 uint64_t NmiNotification : 1;
1101 uint64_t InterruptNotification : 1;
1102 uint64_t InterruptPriority : 4;
1103#ifndef IN_IDA_PRO
1104 uint64_t Reserved : 58;
1105#endif
1106 };
1107} HV_X64_DELIVERABILITY_NOTIFICATIONS_REGISTER;
1108/** Pointer to a value of HvRegisterPendingEvent0/1. */
1109typedef HV_X64_DELIVERABILITY_NOTIFICATIONS_REGISTER *PHV_X64_DELIVERABILITY_NOTIFICATIONS_REGISTER;
1110
1111
1112/** Value format for HvX64RegisterEs..Tr.
1113 * @sa WHV_X64_SEGMENT_REGISTER */
1114typedef struct _HV_X64_SEGMENT_REGISTER
1115{
1116 uint64_t Base;
1117 uint32_t Limit;
1118 uint16_t Selector;
1119 union
1120 {
1121 struct
1122 {
1123 uint16_t SegmentType : 4;
1124 uint16_t NonSystemSegment : 1;
1125 uint16_t DescriptorPrivilegeLevel : 2;
1126 uint16_t Present : 1;
1127 uint16_t Reserved : 4;
1128 uint16_t Available : 1;
1129 uint16_t Long : 1;
1130 uint16_t Default : 1;
1131 uint16_t Granularity : 1;
1132 };
1133 uint16_t Attributes;
1134 };
1135} HV_X64_SEGMENT_REGISTER;
1136AssertCompileSize(HV_X64_SEGMENT_REGISTER, 16);
1137/** Pointer to a value of HvX64RegisterEs..Tr. */
1138typedef HV_X64_SEGMENT_REGISTER *PHV_X64_SEGMENT_REGISTER;
1139
1140/** Value format for HvX64RegisterIdtr/Gdtr.
1141 * @sa WHV_X64_TABLE_REGISTER */
1142typedef struct
1143{
1144 uint16_t Pad[3];
1145 uint16_t Limit;
1146 uint64_t Base;
1147} HV_X64_TABLE_REGISTER;
1148AssertCompileSize(HV_X64_TABLE_REGISTER, 16);
1149/** Pointer to a value of HvX64RegisterIdtr/Gdtrr. */
1150typedef HV_X64_TABLE_REGISTER *PHV_X64_TABLE_REGISTER;
1151
1152/** Value format for HvX64RegisterFpMmx0..7 in floating pointer mode.
1153 * @sa WHV_X64_FP_REGISTER, RTFLOAT80U2 */
1154typedef union
1155{
1156 HV_UINT128 AsUINT128;
1157 struct
1158 {
1159 uint64_t Mantissa;
1160 uint64_t BiasedExponent : 15;
1161 uint64_t Sign : 1;
1162#ifndef IN_IDA_PRO
1163 uint64_t Reserved : 48;
1164#endif
1165 };
1166} HV_X64_FP_REGISTER;
1167/** Pointer to a value of HvX64RegisterFpMmx0..7 in floating point mode. */
1168typedef HV_X64_FP_REGISTER *PHV_X64_FP_REGISTER;
1169
1170/** Value union for HvX64RegisterFpMmx0..7. */
1171typedef union
1172{
1173 HV_UINT128 AsUINT128;
1174 HV_X64_FP_REGISTER Fp;
1175 uint64_t Mmx;
1176} HV_X64_FP_MMX_REGISTER;
1177/** Pointer to a value of HvX64RegisterFpMmx0..7. */
1178typedef HV_X64_FP_MMX_REGISTER *PHV_X64_FP_MMX_REGISTER;
1179
1180/** Value format for HvX64RegisterFpControlStatus.
1181 * @sa WHV_X64_FP_CONTROL_STATUS_REGISTER */
1182typedef union
1183{
1184 HV_UINT128 AsUINT128;
1185 struct
1186 {
1187 uint16_t FpControl;
1188 uint16_t FpStatus;
1189 uint8_t FpTag;
1190 uint8_t IgnNe : 1;
1191 uint8_t Reserved : 7;
1192 uint16_t LastFpOp;
1193 union
1194 {
1195 uint64_t LastFpRip;
1196 struct
1197 {
1198 uint32_t LastFpEip;
1199 uint16_t LastFpCs;
1200 };
1201 };
1202 };
1203} HV_X64_FP_CONTROL_STATUS_REGISTER;
1204/** Pointer to a value of HvX64RegisterFpControlStatus. */
1205typedef HV_X64_FP_CONTROL_STATUS_REGISTER *PHV_X64_FP_CONTROL_STATUS_REGISTER;
1206
1207/** Value format for HvX64RegisterXmmControlStatus.
1208 * @sa WHV_X64_XMM_CONTROL_STATUS_REGISTER */
1209typedef union
1210{
1211 HV_UINT128 AsUINT128;
1212 struct
1213 {
1214 union
1215 {
1216 uint64_t LastFpRdp;
1217 struct
1218 {
1219 uint32_t LastFpDp;
1220 uint16_t LastFpDs;
1221 };
1222 };
1223 uint32_t XmmStatusControl;
1224 uint32_t XmmStatusControlMask;
1225 };
1226} HV_X64_XMM_CONTROL_STATUS_REGISTER;
1227/** Pointer to a value of HvX64RegisterXmmControlStatus. */
1228typedef HV_X64_XMM_CONTROL_STATUS_REGISTER *PHV_X64_XMM_CONTROL_STATUS_REGISTER;
1229
1230/** Register value union.
1231 * @sa WHV_REGISTER_VALUE */
1232typedef union
1233{
1234 HV_UINT128 Reg128;
1235 uint64_t Reg64;
1236 uint32_t Reg32;
1237 uint16_t Reg16;
1238 uint8_t Reg8;
1239 HV_EXPLICIT_SUSPEND_REGISTER ExplicitSuspend;
1240 HV_INTERCEPT_SUSPEND_REGISTER InterceptSuspend;
1241 HV_X64_INTERRUPT_STATE_REGISTER InterruptState;
1242 HV_X64_PENDING_INTERRUPTION_REGISTER PendingInterruption;
1243 HV_X64_DELIVERABILITY_NOTIFICATIONS_REGISTER DeliverabilityNotifications;
1244 HV_X64_TABLE_REGISTER Table;
1245 HV_X64_SEGMENT_REGISTER Segment;
1246 HV_X64_FP_REGISTER Fp;
1247 HV_X64_FP_CONTROL_STATUS_REGISTER FpControlStatus;
1248 HV_X64_XMM_CONTROL_STATUS_REGISTER XmmControlStatus;
1249} HV_REGISTER_VALUE;
1250AssertCompileSize(HV_REGISTER_VALUE, 16);
1251/** Pointer to a Hyper-V register value union. */
1252typedef HV_REGISTER_VALUE *PHV_REGISTER_VALUE;
1253/** Pointer to a const Hyper-V register value union. */
1254typedef HV_REGISTER_VALUE const *PCHV_REGISTER_VALUE;
1255
1256
1257/** Input for HvCallGetVpRegisters. */
1258typedef struct
1259{
1260 HV_PARTITION_ID PartitionId;
1261 HV_VP_INDEX VpIndex;
1262 /** Was this introduced after v2? Dunno what it it really is. */
1263 uint32_t fFlags;
1264 /* The repeating part: */
1265 RT_FLEXIBLE_ARRAY_EXTENSION
1266 HV_REGISTER_NAME Names[RT_FLEXIBLE_ARRAY];
1267} HV_INPUT_GET_VP_REGISTERS;
1268AssertCompileMemberOffset(HV_INPUT_GET_VP_REGISTERS, Names, 16);
1269/** Pointer to input for HvCallGetVpRegisters. */
1270typedef HV_INPUT_GET_VP_REGISTERS *PHV_INPUT_GET_VP_REGISTERS;
1271/* Output for HvCallGetVpRegisters is an array of HV_REGISTER_VALUE parallel to HV_INPUT_GET_VP_REGISTERS::Names. */
1272
1273
1274/** Register and value pair for HvCallSetVpRegisters. */
1275typedef struct
1276{
1277 HV_REGISTER_NAME Name;
1278 uint32_t Pad0;
1279 uint64_t Pad1;
1280 HV_REGISTER_VALUE Value;
1281} HV_REGISTER_ASSOC;
1282AssertCompileSize(HV_REGISTER_ASSOC, 32);
1283AssertCompileMemberOffset(HV_REGISTER_ASSOC, Value, 16);
1284/** Pointer to a register and value pair for HvCallSetVpRegisters. */
1285typedef HV_REGISTER_ASSOC *PHV_REGISTER_ASSOC;
1286/** Helper for clearing the alignment padding members. */
1287#define HV_REGISTER_ASSOC_ZERO_PADDING(a_pRegAssoc) do { (a_pRegAssoc)->Pad0 = 0; (a_pRegAssoc)->Pad1 = 0; } while (0)
1288/** Helper for clearing the alignment padding members and the high 64-bit
1289 * part of the value. */
1290#define HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(a_pRegAssoc) \
1291 do { (a_pRegAssoc)->Pad0 = 0; (a_pRegAssoc)->Pad1 = 0; (a_pRegAssoc)->Value.Reg128.High64 = 0; } while (0)
1292
1293/** Input for HvCallSetVpRegisters. */
1294typedef struct
1295{
1296 HV_PARTITION_ID PartitionId;
1297 HV_VP_INDEX VpIndex;
1298 uint32_t RsvdZ;
1299 /* The repeating part: */
1300 RT_FLEXIBLE_ARRAY_EXTENSION
1301 HV_REGISTER_ASSOC Elements[RT_FLEXIBLE_ARRAY];
1302} HV_INPUT_SET_VP_REGISTERS;
1303AssertCompileMemberOffset(HV_INPUT_SET_VP_REGISTERS, Elements, 16);
1304/** Pointer to input for HvCallSetVpRegisters. */
1305typedef HV_INPUT_SET_VP_REGISTERS *PHV_INPUT_SET_VP_REGISTERS;
1306
1307
1308
1309/**
1310 * Hyper-V SyncIC message types.
1311 */
1312typedef enum
1313{
1314 HvMessageTypeNone = 0x00000000,
1315
1316 HvMessageTypeUnmappedGpa = 0x80000000,
1317 HvMessageTypeGpaIntercept,
1318
1319 HvMessageTimerExpired = 0x80000010,
1320
1321 HvMessageTypeInvalidVpRegisterValue = 0x80000020,
1322 HvMessageTypeUnrecoverableException,
1323 HvMessageTypeUnsupportedFeature,
1324 HvMessageTypeTlbPageSizeMismatch, /**< @since v5 */
1325
1326 /** @note Same as HvMessageTypeX64ApicEoi? Gone in 5.0. Missing from 7600 WDK
1327 * headers even if it's in the 2.0 docs. */
1328 HvMessageTypeApicEoi = 0x80000030,
1329 /** @note Same as HvMessageTypeX64LegacyFpError? Gone in 5.0, whereas 4.0b
1330 * calls it HvMessageTypeX64LegacyFpError. Missing from 7600 WDK
1331 * headers even if it's in the 2.0 docs. */
1332 HvMessageTypeFerrAsserted,
1333
1334 HvMessageTypeEventLogBufferComplete = 0x80000040,
1335
1336 HvMessageTypeX64IoPortIntercept = 0x80010000,
1337 HvMessageTypeX64MsrIntercept,
1338 HvMessageTypeX64CpuidIntercept,
1339 HvMessageTypeX64ExceptionIntercept,
1340 /** @note Appeared in 5.0 docs, but were here in 7600 WDK headers already. */
1341 HvMessageTypeX64ApicEoi,
1342 /** @note Appeared in 5.0 docs, but were here in 7600 WDK headers already. */
1343 HvMessageTypeX64LegacyFpError,
1344 /** @since v5 */
1345 HvMessageTypeX64RegisterIntercept,
1346 /** @since WinHvPlatform? */
1347 HvMessageTypeX64Halt,
1348 /** @since WinHvPlatform? */
1349 HvMessageTypeX64InterruptWindow
1350
1351} HV_MESSAGE_TYPE;
1352AssertCompileSize(HV_MESSAGE_TYPE, 4);
1353AssertCompile(HvMessageTypeX64RegisterIntercept == 0x80010006);
1354AssertCompile(HvMessageTypeX64Halt == 0x80010007);
1355AssertCompile(HvMessageTypeX64InterruptWindow == 0x80010008);
1356/** Pointer to a Hyper-V SyncIC message type. */
1357typedef HV_MESSAGE_TYPE *PHV_MESSAGE_TYPE;
1358
1359/** Flag set for hypervisor messages, guest cannot send messages with this
1360 * flag set. */
1361#define HV_MESSAGE_TYPE_HYPERVISOR_MASK UINT32_C(0x80000000)
1362
1363/** Hyper-V SynIC message size (they are fixed sized). */
1364#define HV_MESSAGE_SIZE 256
1365/** Maximum Hyper-V SynIC message payload size in bytes. */
1366#define HV_MESSAGE_MAX_PAYLOAD_BYTE_COUNT (HV_MESSAGE_SIZE - 16)
1367/** Maximum Hyper-V SynIC message payload size in QWORDs (uint64_t). */
1368#define HV_MESSAGE_MAX_PAYLOAD_QWORD_COUNT (HV_MESSAGE_MAX_PAYLOAD_BYTE_COUNT / 8)
1369
1370/** SynIC message flags. */
1371typedef union
1372{
1373 uint8_t AsUINT8;
1374 struct
1375 {
1376 /** Messages are pending in the queue. */
1377 uint8_t MessagePending : 1;
1378 uint8_t Reserved : 7;
1379 };
1380} HV_MESSAGE_FLAGS;
1381AssertCompileSize(HV_MESSAGE_FLAGS, 1);
1382
1383/** SynIC message header. */
1384typedef struct
1385{
1386 HV_MESSAGE_TYPE MessageType;
1387 /** The 2.0-5.0b docs all have this incorrectly switched with 'Reserved', WDK 7600 got it right. */
1388 uint8_t PayloadSize;
1389 HV_MESSAGE_FLAGS MessageFlags;
1390 uint16_t Reserved;
1391 union
1392 {
1393 uint64_t OriginationId;
1394 HV_PARTITION_ID Sender;
1395 HV_PORT_ID Port;
1396 };
1397} HV_MESSAGE_HEADER;
1398AssertCompileSize(HV_MESSAGE_HEADER, 16);
1399/** Pointer to a Hyper-V message header. */
1400typedef HV_MESSAGE_HEADER *PHV_MESSAGE_HEADER;
1401/** Pointer to a const Hyper-V message header. */
1402typedef HV_MESSAGE_HEADER const *PCHV_MESSAGE_HEADER;
1403
1404
1405
1406/** @name Intercept access type.
1407 * @{ */
1408typedef uint8_t HV_INTERCEPT_ACCESS_TYPE;
1409#define HV_INTERCEPT_ACCESS_READ 0
1410#define HV_INTERCEPT_ACCESS_WRITE 1
1411#define HV_INTERCEPT_ACCESS_EXECUTE 2
1412/** @} */
1413
1414/** @name Intercept access type mask.
1415 * @{ */
1416typedef uint32_t HV_INTERCEPT_ACCESS_TYPE_MASK;
1417#define HV_INTERCEPT_ACCESS_MASK_NONE 0
1418#define HV_INTERCEPT_ACCESS_MASK_READ 1
1419#define HV_INTERCEPT_ACCESS_MASK_WRITE 2
1420#define HV_INTERCEPT_ACCESS_MASK_EXECUTE 4
1421/** @} */
1422
1423/** X64 intercept execution state.
1424 * @sa WHV_X64_VP_EXECUTION_STATE */
1425typedef union
1426{
1427 uint16_t AsUINT16;
1428 struct
1429 {
1430 uint16_t Cpl : 2;
1431 uint16_t Cr0Pe : 1;
1432 uint16_t Cr0Am : 1;
1433 uint16_t EferLma : 1;
1434 uint16_t DebugActive : 1;
1435 uint16_t InterruptionPending : 1;
1436 uint16_t Reserved0 : 5;
1437 uint16_t InterruptShadow : 1;
1438 uint16_t Reserved1 : 3;
1439 };
1440} HV_X64_VP_EXECUTION_STATE;
1441AssertCompileSize(HV_X64_VP_EXECUTION_STATE, 2);
1442/** Pointer to X86 intercept execution state. */
1443typedef HV_X64_VP_EXECUTION_STATE *PHV_X64_VP_EXECUTION_STATE;
1444/** Pointer to const X86 intercept execution state. */
1445typedef HV_X64_VP_EXECUTION_STATE const *PCHV_X64_VP_EXECUTION_STATE;
1446
1447/** X64 intercept message header. */
1448typedef struct
1449{
1450 HV_VP_INDEX VpIndex; /**< 0x00 */
1451 uint8_t InstructionLength : 4; /**< 0x04[3:0]: Zero if not available, instruction fetch exit, ... */
1452 uint8_t Cr8 : 4; /**< 0x04[7:4]: Not sure since when, but after v2. */
1453 HV_INTERCEPT_ACCESS_TYPE InterceptAccessType; /**< 0x05 */
1454 HV_X64_VP_EXECUTION_STATE ExecutionState; /**< 0x06 */
1455 HV_X64_SEGMENT_REGISTER CsSegment; /**< 0x08 */
1456 uint64_t Rip; /**< 0x18 */
1457 uint64_t Rflags; /**< 0x20 */
1458} HV_X64_INTERCEPT_MESSAGE_HEADER;
1459AssertCompileSize(HV_X64_INTERCEPT_MESSAGE_HEADER, 40);
1460/** Pointer to a x86 intercept message header. */
1461typedef HV_X64_INTERCEPT_MESSAGE_HEADER *PHV_X64_INTERCEPT_MESSAGE_HEADER;
1462
1463
1464/** X64 memory access flags (HvMessageTypeGpaIntercept, HvMessageTypeUnmappedGpa).
1465 * @sa WHV_MEMORY_ACCESS_INFO */
1466typedef union
1467{
1468 uint8_t AsUINT8;
1469 struct
1470 {
1471 uint8_t GvaValid : 1;
1472 uint8_t Reserved : 7;
1473 };
1474} HV_X64_MEMORY_ACCESS_INFO;
1475AssertCompileSize(HV_X64_MEMORY_ACCESS_INFO, 1);
1476
1477/** The payload format for HvMessageTypeGpaIntercept and HvMessageTypeUnmappedGpa.
1478 * @sa WHV_MEMORY_ACCESS_CONTEXT
1479 * @note max message size. */
1480typedef struct
1481{
1482 HV_X64_INTERCEPT_MESSAGE_HEADER Header; /**< 0x00 */
1483 HV_CACHE_TYPE CacheType; /**< 0x28 */
1484 uint8_t InstructionByteCount; /**< 0x2c */
1485 HV_X64_MEMORY_ACCESS_INFO MemoryAccessInfo; /**< 0x2d */
1486 uint16_t Reserved1; /**< 0x2e */
1487 uint64_t GuestVirtualAddress; /**< 0x30 */
1488 uint64_t GuestPhysicalAddress; /**< 0x38 */
1489 uint8_t InstructionBytes[16]; /**< 0x40 */
1490 /* We don't the following (v5 / WinHvPlatform): */
1491 HV_X64_SEGMENT_REGISTER DsSegment; /**< 0x50 */
1492 HV_X64_SEGMENT_REGISTER SsSegment; /**< 0x60 */
1493 uint64_t Rax; /**< 0x70 */
1494 uint64_t Rcx; /**< 0x78 */
1495 uint64_t Rdx; /**< 0x80 */
1496 uint64_t Rbx; /**< 0x88 */
1497 uint64_t Rsp; /**< 0x90 */
1498 uint64_t Rbp; /**< 0x98 */
1499 uint64_t Rsi; /**< 0xa0 */
1500 uint64_t Rdi; /**< 0xa8 */
1501 uint64_t R8; /**< 0xb0 */
1502 uint64_t R9; /**< 0xb8 */
1503 uint64_t R10; /**< 0xc0 */
1504 uint64_t R11; /**< 0xc8 */
1505 uint64_t R12; /**< 0xd0 */
1506 uint64_t R13; /**< 0xd8 */
1507 uint64_t R14; /**< 0xe0 */
1508 uint64_t R15; /**< 0xe8 */
1509} HV_X64_MEMORY_INTERCEPT_MESSAGE;
1510AssertCompileSize(HV_X64_MEMORY_INTERCEPT_MESSAGE, 0xf0);
1511AssertCompileMemberOffset(HV_X64_MEMORY_INTERCEPT_MESSAGE, DsSegment, 0x50);
1512/** Pointer to a HvMessageTypeGpaIntercept or HvMessageTypeUnmappedGpa payload. */
1513typedef HV_X64_MEMORY_INTERCEPT_MESSAGE *PHV_X64_MEMORY_INTERCEPT_MESSAGE;
1514/** Pointer to a const HvMessageTypeGpaIntercept or HvMessageTypeUnmappedGpa payload. */
1515typedef HV_X64_MEMORY_INTERCEPT_MESSAGE const *PCHV_X64_MEMORY_INTERCEPT_MESSAGE;
1516
1517
1518/** The payload format for HvMessageTypeX64MsrIntercept. */
1519typedef struct _HV_X64_MSR_INTERCEPT_MESSAGE
1520{
1521 HV_X64_INTERCEPT_MESSAGE_HEADER Header; /**< 0x00 */
1522 uint32_t MsrNumber; /**< 0x28 (ecx) */
1523 uint32_t Reserved; /**< 0x2c */
1524 uint64_t Rdx; /**< 0x30 */
1525 uint64_t Rax; /**< 0x38 */
1526} HV_X64_MSR_INTERCEPT_MESSAGE;
1527AssertCompileSize(HV_X64_MSR_INTERCEPT_MESSAGE, 0x40);
1528/** Pointer to a HvMessageTypeX64MsrIntercept payload. */
1529typedef HV_X64_MSR_INTERCEPT_MESSAGE *PHV_X64_MSR_INTERCEPT_MESSAGE;
1530/** Pointer to a const HvMessageTypeX64MsrIntercept payload. */
1531typedef HV_X64_MSR_INTERCEPT_MESSAGE const *PCHV_X64_MSR_INTERCEPT_MESSAGE;
1532
1533/** Full MSR message. */
1534typedef struct
1535{
1536 HV_MESSAGE_HEADER MsgHdr;
1537 HV_X64_MSR_INTERCEPT_MESSAGE Payload;
1538} HV_X64_MSR_INTERCEPT_MESSAGE_FULL;
1539
1540
1541/** X64 I/O port access information (HvMessageTypeX64IoPortIntercept). */
1542typedef union HV_X64_IO_PORT_ACCESS_INFO
1543{
1544 uint8_t AsUINT8;
1545 struct
1546 {
1547 uint8_t AccessSize : 3;
1548 uint8_t StringOp : 1;
1549 uint8_t RepPrefix : 1;
1550 uint8_t Reserved : 3;
1551 };
1552} HV_X64_IO_PORT_ACCESS_INFO;
1553AssertCompileSize(HV_X64_IO_PORT_ACCESS_INFO, 1);
1554
1555/** The payload format for HvMessageTypeX64IoPortIntercept. */
1556typedef struct _HV_X64_IO_PORT_INTERCEPT_MESSAGE
1557{
1558 HV_X64_INTERCEPT_MESSAGE_HEADER Header; /**< 0x00 */
1559 uint16_t PortNumber; /**< 0x28 */
1560 HV_X64_IO_PORT_ACCESS_INFO AccessInfo; /**< 0x2a */
1561 uint8_t InstructionByteCount; /**< 0x2b */
1562 uint32_t Reserved; /**< 0x2c */
1563 uint64_t Rax; /**< 0x30 */
1564 uint8_t InstructionBytes[16]; /**< 0x38 */
1565 HV_X64_SEGMENT_REGISTER DsSegment; /**< 0x48 */
1566 HV_X64_SEGMENT_REGISTER EsSegment; /**< 0x58 */
1567 uint64_t Rcx; /**< 0x68 */
1568 uint64_t Rsi; /**< 0x70 */
1569 uint64_t Rdi; /**< 0x78 */
1570} HV_X64_IO_PORT_INTERCEPT_MESSAGE;
1571AssertCompileSize(HV_X64_IO_PORT_INTERCEPT_MESSAGE, 128);
1572/** Pointer to a HvMessageTypeX64IoPortIntercept payload. */
1573typedef HV_X64_IO_PORT_INTERCEPT_MESSAGE *PHV_X64_IO_PORT_INTERCEPT_MESSAGE;
1574/** Pointer to a const HvMessageTypeX64IoPortIntercept payload. */
1575typedef HV_X64_IO_PORT_INTERCEPT_MESSAGE const *PCHV_X64_IO_PORT_INTERCEPT_MESSAGE;
1576
1577/** Full I/O port message. */
1578typedef struct
1579{
1580 HV_MESSAGE_HEADER MsgHdr;
1581 HV_X64_IO_PORT_INTERCEPT_MESSAGE Payload;
1582} HV_X64_IO_PORT_INTERCEPT_MESSAGE_FULL;
1583
1584
1585/**
1586 * The payload format for HvMessageTypeX64CpuidIntercept,
1587 *
1588 * @note This message does not include HV_X64_INTERCEPT_MESSAGE_HEADER!
1589 */
1590typedef struct
1591{
1592 HV_X64_INTERCEPT_MESSAGE_HEADER Header; /**< 0x00: The usual intercept header. */
1593 uint64_t Rax; /**< 0x28: Input RAX. */
1594 uint64_t Rcx; /**< 0x30: Input RCX. */
1595 uint64_t Rdx; /**< 0x38: Input RDX. */
1596 uint64_t Rbx; /**< 0x40: Input RBX. */
1597 uint64_t DefaultResultRax; /**< 0x48: Default result RAX. */
1598 uint64_t DefaultResultRcx; /**< 0x50: Default result RCX. */
1599 uint64_t DefaultResultRdx; /**< 0x58: Default result RDX. */
1600 uint64_t DefaultResultRbx; /**< 0x60: Default result RBX. */
1601} HV_X64_CPUID_INTERCEPT_MESSAGE;
1602AssertCompileSize(HV_X64_CPUID_INTERCEPT_MESSAGE, 0x68);
1603/** Pointer to a HvMessageTypeX64CpuidIntercept payload. */
1604typedef HV_X64_CPUID_INTERCEPT_MESSAGE *PHV_X64_CPUID_INTERCEPT_MESSAGE;
1605/** Pointer to a const HvMessageTypeX64CpuidIntercept payload. */
1606typedef HV_X64_CPUID_INTERCEPT_MESSAGE const *PCHV_X64_CPUID_INTERCEPT_MESSAGE;
1607
1608/** Full HvMessageTypeX64CpuidIntercept message. */
1609typedef struct
1610{
1611 HV_MESSAGE_HEADER MsgHdr;
1612 HV_X64_CPUID_INTERCEPT_MESSAGE Payload;
1613} HV_X64_CPUID_INTERCEPT_MESSAGE_FULL;
1614
1615
1616/** X64 exception information (HvMessageTypeX64ExceptionIntercept).
1617 * @sa WHV_VP_EXCEPTION_INFO */
1618typedef union
1619{
1620 uint8_t AsUINT8;
1621 struct
1622 {
1623 uint8_t ErrorCodeValid : 1;
1624 /** @todo WHV_VP_EXCEPTION_INFO::SoftwareException */
1625 uint8_t Reserved : 7;
1626 };
1627} HV_X64_EXCEPTION_INFO;
1628AssertCompileSize(HV_X64_EXCEPTION_INFO, 1);
1629
1630/** The payload format for HvMessageTypeX64ExceptionIntercept.
1631 * @sa WHV_VP_EXCEPTION_CONTEXT
1632 * @note max message size. */
1633typedef struct
1634{
1635 HV_X64_INTERCEPT_MESSAGE_HEADER Header; /**< 0x00 */
1636 uint16_t ExceptionVector; /**< 0x28 */
1637 HV_X64_EXCEPTION_INFO ExceptionInfo; /**< 0x2a */
1638 uint8_t InstructionByteCount; /**< 0x2b */
1639 uint32_t ErrorCode; /**< 0x2c */
1640 uint64_t ExceptionParameter; /**< 0x30 */
1641 uint64_t Reserved; /**< 0x38 */
1642 uint8_t InstructionBytes[16]; /**< 0x40 */
1643 HV_X64_SEGMENT_REGISTER DsSegment; /**< 0x50 */
1644 HV_X64_SEGMENT_REGISTER SsSegment; /**< 0x60 */
1645 uint64_t Rax; /**< 0x70 */
1646 uint64_t Rcx; /**< 0x78 */
1647 uint64_t Rdx; /**< 0x80 */
1648 uint64_t Rbx; /**< 0x88 */
1649 uint64_t Rsp; /**< 0x90 */
1650 uint64_t Rbp; /**< 0x98 */
1651 uint64_t Rsi; /**< 0xa0 */
1652 uint64_t Rdi; /**< 0xa8 */
1653 uint64_t R8; /**< 0xb0 */
1654 uint64_t R9; /**< 0xb8 */
1655 uint64_t R10; /**< 0xc0 */
1656 uint64_t R11; /**< 0xc8 */
1657 uint64_t R12; /**< 0xd0 */
1658 uint64_t R13; /**< 0xd8 */
1659 uint64_t R14; /**< 0xe0 */
1660 uint64_t R15; /**< 0xe8 */
1661} HV_X64_EXCEPTION_INTERCEPT_MESSAGE;
1662AssertCompileSize(HV_X64_EXCEPTION_INTERCEPT_MESSAGE, 0xf0);
1663/** Pointer to a HvMessageTypeX64ExceptionIntercept payload. */
1664typedef HV_X64_EXCEPTION_INTERCEPT_MESSAGE *PHV_X64_EXCEPTION_INTERCEPT_MESSAGE;
1665/** Pointer to a ocnst HvMessageTypeX64ExceptionIntercept payload. */
1666typedef HV_X64_EXCEPTION_INTERCEPT_MESSAGE const *PCHV_X64_EXCEPTION_INTERCEPT_MESSAGE;
1667
1668
1669/**
1670 * The payload format for HvMessageTypeX64Halt,
1671 *
1672 * @note This message does not include HV_X64_INTERCEPT_MESSAGE_HEADER!
1673 */
1674typedef struct
1675{
1676 /** Seems to be a zero 64-bit field here. */
1677 uint64_t u64Reserved;
1678} HV_X64_HALT_MESSAGE;
1679/** Pointer to a HvMessageTypeX64Halt payload. */
1680typedef HV_X64_HALT_MESSAGE *PHV_X64_HALT_MESSAGE;
1681/** Pointer to a const HvMessageTypeX64Halt payload. */
1682typedef HV_X64_HALT_MESSAGE const *PCHV_X64_HALT_MESSAGE;
1683
1684/** Full HvMessageTypeX64Halt message. */
1685typedef struct
1686{
1687 HV_MESSAGE_HEADER MsgHdr;
1688 HV_X64_HALT_MESSAGE Payload;
1689} HV_X64_HALT_MESSAGE_FULL;
1690
1691
1692/**
1693 * The payload format for HvMessageTypeX64InterruptWindow,
1694 *
1695 * @note This message does not include HV_X64_INTERCEPT_MESSAGE_HEADER!
1696 */
1697typedef struct
1698{
1699 /** 0x00: The usual intercept header. */
1700 HV_X64_INTERCEPT_MESSAGE_HEADER Header;
1701 /** 0x28: What's pending. */
1702 HV_X64_PENDING_INTERRUPTION_TYPE Type;
1703 /** 0x2c: Explicit structure alignment padding. */
1704 uint32_t u32ExplicitPadding;
1705} HV_X64_INTERRUPT_WINDOW_MESSAGE;
1706AssertCompileSize(HV_X64_INTERRUPT_WINDOW_MESSAGE, 0x30);
1707/** Pointer to a HvMessageTypeX64InterruptWindow payload. */
1708typedef HV_X64_INTERRUPT_WINDOW_MESSAGE *PHV_X64_INTERRUPT_WINDOW_MESSAGE;
1709/** Pointer to a const HvMessageTypeX64InterruptWindow payload. */
1710typedef HV_X64_INTERRUPT_WINDOW_MESSAGE const *PCHV_X64_INTERRUPT_WINDOW_MESSAGE;
1711
1712/** Full HvMessageTypeX64InterruptWindow message. */
1713typedef struct
1714{
1715 /** Payload size is 0x30. */
1716 HV_MESSAGE_HEADER MsgHdr;
1717 HV_X64_INTERRUPT_WINDOW_MESSAGE Payload;
1718} HV_X64_INTERRUPT_WINDOW_MESSAGE_FULL;
1719
1720
1721
1722/** Hyper-V SynIC message. */
1723typedef struct
1724{
1725 HV_MESSAGE_HEADER Header;
1726 /** 0x10 */
1727 union
1728 {
1729 uint64_t Payload[HV_MESSAGE_MAX_PAYLOAD_QWORD_COUNT];
1730
1731 /** Common header for X64 intercept messages.
1732 * The HvMessageTypeUnrecoverableException message only has this. */
1733 HV_X64_INTERCEPT_MESSAGE_HEADER X64InterceptHeader;
1734 /** HvMessageTypeGpaIntercept, HvMessageTypeUnmappedGpa. */
1735 HV_X64_MEMORY_INTERCEPT_MESSAGE X64MemoryIntercept;
1736 /** HvMessageTypeX64IoPortIntercept */
1737 HV_X64_IO_PORT_INTERCEPT_MESSAGE X64IoPortIntercept;
1738 /** HvMessageTypeX64MsrIntercept */
1739 HV_X64_MSR_INTERCEPT_MESSAGE X64MsrIntercept;
1740 /** HvMessageTypeX64CpuidIntercept */
1741 HV_X64_CPUID_INTERCEPT_MESSAGE X64CpuIdIntercept;
1742 /** HvMessageTypeX64ExceptionIntercept */
1743 HV_X64_EXCEPTION_INTERCEPT_MESSAGE X64ExceptionIntercept;
1744 /** HvMessageTypeX64Halt.
1745 * @note No intercept header? */
1746 HV_X64_HALT_MESSAGE X64Halt;
1747 /** HvMessageTypeX64InterruptWindow. */
1748 HV_X64_INTERRUPT_WINDOW_MESSAGE X64InterruptWindow;
1749 };
1750} HV_MESSAGE;
1751AssertCompileSize(HV_MESSAGE, HV_MESSAGE_SIZE);
1752/** Pointer to a Hyper-V SynIC message. */
1753typedef HV_MESSAGE *PHV_MESSAGE;
1754/** Pointer to const a Hyper-V SynIC message. */
1755typedef HV_MESSAGE const *PCHV_MESSAGE;
1756
1757#endif /* !IPRT_INCLUDED_nt_hyperv_h */
1758
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