VirtualBox

source: vbox/trunk/src/VBox/VMM/include/GIMHvInternal.h@ 100111

Last change on this file since 100111 was 99208, checked in by vboxsync, 20 months ago

Disassembler,VMM,Runtime: Get rid of deprecated DISCPUSTATE types (preparation for architecture specific separation in order to support ARMv8), bugref:10394

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 59.0 KB
Line 
1/* $Id: GIMHvInternal.h 99208 2023-03-29 14:13:56Z vboxsync $ */
2/** @file
3 * GIM - Hyper-V, Internal header file.
4 */
5
6/*
7 * Copyright (C) 2014-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef VMM_INCLUDED_SRC_include_GIMHvInternal_h
29#define VMM_INCLUDED_SRC_include_GIMHvInternal_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include <VBox/vmm/gim.h>
35#include <VBox/vmm/cpum.h>
36
37#include <iprt/net.h>
38
39/** @name Hyper-V base feature identification.
40 * Features based on current partition privileges (per-VM).
41 * @{
42 */
43/** Virtual processor runtime MSR available. */
44#define GIM_HV_BASE_FEAT_VP_RUNTIME_MSR RT_BIT(0)
45/** Partition reference counter MSR available. */
46#define GIM_HV_BASE_FEAT_PART_TIME_REF_COUNT_MSR RT_BIT(1)
47/** Basic Synthetic Interrupt Controller MSRs available. */
48#define GIM_HV_BASE_FEAT_BASIC_SYNIC_MSRS RT_BIT(2)
49/** Synthetic Timer MSRs available. */
50#define GIM_HV_BASE_FEAT_STIMER_MSRS RT_BIT(3)
51/** APIC access MSRs (EOI, ICR, TPR) available. */
52#define GIM_HV_BASE_FEAT_APIC_ACCESS_MSRS RT_BIT(4)
53/** Hypercall MSRs available. */
54#define GIM_HV_BASE_FEAT_HYPERCALL_MSRS RT_BIT(5)
55/** Access to VCPU index MSR available. */
56#define GIM_HV_BASE_FEAT_VP_ID_MSR RT_BIT(6)
57/** Virtual system reset MSR available. */
58#define GIM_HV_BASE_FEAT_VIRT_SYS_RESET_MSR RT_BIT(7)
59/** Statistic pages MSRs available. */
60#define GIM_HV_BASE_FEAT_STAT_PAGES_MSR RT_BIT(8)
61/** Paritition reference TSC MSR available. */
62#define GIM_HV_BASE_FEAT_PART_REF_TSC_MSR RT_BIT(9)
63/** Virtual guest idle state MSR available. */
64#define GIM_HV_BASE_FEAT_GUEST_IDLE_STATE_MSR RT_BIT(10)
65/** Timer frequency MSRs (TSC and APIC) available. */
66#define GIM_HV_BASE_FEAT_TIMER_FREQ_MSRS RT_BIT(11)
67/** Debug MSRs available. */
68#define GIM_HV_BASE_FEAT_DEBUG_MSRS RT_BIT(12)
69/** @} */
70
71/** @name Hyper-V partition-creation feature identification.
72 * Indicates flags specified during partition creation.
73 * @{
74 */
75/** Create partitions. */
76#define GIM_HV_PART_FLAGS_CREATE_PART RT_BIT(0)
77/** Access partition Id. */
78#define GIM_HV_PART_FLAGS_ACCESS_PART_ID RT_BIT(1)
79/** Access memory pool. */
80#define GIM_HV_PART_FLAGS_ACCESS_MEMORY_POOL RT_BIT(2)
81/** Adjust message buffers. */
82#define GIM_HV_PART_FLAGS_ADJUST_MSG_BUFFERS RT_BIT(3)
83/** Post messages. */
84#define GIM_HV_PART_FLAGS_POST_MSGS RT_BIT(4)
85/** Signal events. */
86#define GIM_HV_PART_FLAGS_SIGNAL_EVENTS RT_BIT(5)
87/** Create port. */
88#define GIM_HV_PART_FLAGS_CREATE_PORT RT_BIT(6)
89/** Connect port. */
90#define GIM_HV_PART_FLAGS_CONNECT_PORT RT_BIT(7)
91/** Access statistics. */
92#define GIM_HV_PART_FLAGS_ACCESS_STATS RT_BIT(8)
93/** Debugging.*/
94#define GIM_HV_PART_FLAGS_DEBUGGING RT_BIT(11)
95/** CPU management. */
96#define GIM_HV_PART_FLAGS_CPU_MGMT RT_BIT(12)
97/** CPU profiler. */
98#define GIM_HV_PART_FLAGS_CPU_PROFILER RT_BIT(13)
99/** Enable expanded stack walking. */
100#define GIM_HV_PART_FLAGS_EXPANDED_STACK_WALK RT_BIT(14)
101/** Access VSM. */
102#define GIM_HV_PART_FLAGS_ACCESS_VSM RT_BIT(16)
103/** Access VP registers. */
104#define GIM_HV_PART_FLAGS_ACCESS_VP_REGS RT_BIT(17)
105/** Enable extended hypercalls. */
106#define GIM_HV_PART_FLAGS_EXTENDED_HYPERCALLS RT_BIT(20)
107/** Start virtual processor. */
108#define GIM_HV_PART_FLAGS_START_VP RT_BIT(21)
109/** @} */
110
111/** @name Hyper-V power management feature identification.
112 * @{
113 */
114/** Maximum CPU power state C0. */
115#define GIM_HV_PM_MAX_CPU_POWER_STATE_C0 RT_BIT(0)
116/** Maximum CPU power state C1. */
117#define GIM_HV_PM_MAX_CPU_POWER_STATE_C1 RT_BIT(1)
118/** Maximum CPU power state C2. */
119#define GIM_HV_PM_MAX_CPU_POWER_STATE_C2 RT_BIT(2)
120/** Maximum CPU power state C3. */
121#define GIM_HV_PM_MAX_CPU_POWER_STATE_C3 RT_BIT(3)
122/** HPET is required to enter C3 power state. */
123#define GIM_HV_PM_HPET_REQD_FOR_C3 RT_BIT(4)
124/** @} */
125
126/** @name Hyper-V miscellaneous feature identification.
127 * Miscellaneous features available for the current partition.
128 * @{
129 */
130/** MWAIT instruction available. */
131#define GIM_HV_MISC_FEAT_MWAIT RT_BIT(0)
132/** Guest debugging support available. */
133#define GIM_HV_MISC_FEAT_GUEST_DEBUGGING RT_BIT(1)
134/** Performance monitor support is available. */
135#define GIM_HV_MISC_FEAT_PERF_MON RT_BIT(2)
136/** Support for physical CPU dynamic partitioning events. */
137#define GIM_HV_MISC_FEAT_PCPU_DYN_PART_EVENT RT_BIT(3)
138/** Support for passing hypercall input parameter block via XMM registers. */
139#define GIM_HV_MISC_FEAT_XMM_HYPERCALL_INPUT RT_BIT(4)
140/** Support for virtual guest idle state. */
141#define GIM_HV_MISC_FEAT_GUEST_IDLE_STATE RT_BIT(5)
142/** Support for hypervisor sleep state. */
143#define GIM_HV_MISC_FEAT_HYPERVISOR_SLEEP_STATE RT_BIT(6)
144/** Support for querying NUMA distances. */
145#define GIM_HV_MISC_FEAT_QUERY_NUMA_DISTANCE RT_BIT(7)
146/** Support for determining timer frequencies. */
147#define GIM_HV_MISC_FEAT_TIMER_FREQ RT_BIT(8)
148/** Support for injecting synthetic machine checks. */
149#define GIM_HV_MISC_FEAT_INJECT_SYNMC_XCPT RT_BIT(9)
150/** Support for guest crash MSRs. */
151#define GIM_HV_MISC_FEAT_GUEST_CRASH_MSRS RT_BIT(10)
152/** Support for debug MSRs. */
153#define GIM_HV_MISC_FEAT_DEBUG_MSRS RT_BIT(11)
154/** Npiep1 Available */ /** @todo What the heck is this? */
155#define GIM_HV_MISC_FEAT_NPIEP1 RT_BIT(12)
156/** Disable hypervisor available. */
157#define GIM_HV_MISC_FEAT_DISABLE_HYPERVISOR RT_BIT(13)
158/** Extended GVA ranges for FlushVirtualAddressList available. */
159#define GIM_HV_MISC_FEAT_EXT_GVA_RANGE_FOR_FLUSH_VA_LIST RT_BIT(14)
160/** Support for returning hypercall output via XMM registers. */
161#define GIM_HV_MISC_FEAT_HYPERCALL_OUTPUT_XMM RT_BIT(15)
162/** Synthetic interrupt source polling mode available. */
163#define GIM_HV_MISC_FEAT_SINT_POLLING_MODE RT_BIT(17)
164/** Hypercall MSR lock available. */
165#define GIM_HV_MISC_FEAT_HYPERCALL_MSR_LOCK RT_BIT(18)
166/** Use direct synthetic MSRs. */
167#define GIM_HV_MISC_FEAT_USE_DIRECT_SYNTH_MSRS RT_BIT(19)
168/** @} */
169
170/** @name Hyper-V implementation recommendations.
171 * Recommendations from the hypervisor for the guest for optimal performance.
172 * @{
173 */
174/** Use hypercall for address space switches rather than MOV CR3. */
175#define GIM_HV_HINT_HYPERCALL_FOR_PROCESS_SWITCH RT_BIT(0)
176/** Use hypercall for local TLB flushes rather than INVLPG/MOV CR3. */
177#define GIM_HV_HINT_HYPERCALL_FOR_TLB_FLUSH RT_BIT(1)
178/** Use hypercall for inter-CPU TLB flushes rather than IPIs. */
179#define GIM_HV_HINT_HYPERCALL_FOR_TLB_SHOOTDOWN RT_BIT(2)
180/** Use MSRs for APIC access (EOI, ICR, TPR) rather than MMIO. */
181#define GIM_HV_HINT_MSR_FOR_APIC_ACCESS RT_BIT(3)
182/** Use hypervisor provided MSR for a system reset. */
183#define GIM_HV_HINT_MSR_FOR_SYS_RESET RT_BIT(4)
184/** Relax timer-related checks (watchdogs/deadman timeouts) that rely on
185 * timely deliver of external interrupts. */
186#define GIM_HV_HINT_RELAX_TIME_CHECKS RT_BIT(5)
187/** Recommend using DMA remapping. */
188#define GIM_HV_HINT_DMA_REMAPPING RT_BIT(6)
189/** Recommend using interrupt remapping. */
190#define GIM_HV_HINT_INTERRUPT_REMAPPING RT_BIT(7)
191/** Recommend using X2APIC MSRs rather than MMIO. */
192#define GIM_HV_HINT_X2APIC_MSRS RT_BIT(8)
193/** Recommend deprecating Auto EOI (end of interrupt). */
194#define GIM_HV_HINT_DEPRECATE_AUTO_EOI RT_BIT(9)
195/** Recommend using SyntheticClusterIpi hypercall. */
196#define GIM_HV_HINT_SYNTH_CLUSTER_IPI_HYPERCALL RT_BIT(10)
197/** Recommend using newer ExProcessMasks interface. */
198#define GIM_HV_HINT_EX_PROC_MASKS_INTERFACE RT_BIT(11)
199/** Indicate that Hyper-V is nested within a Hyper-V partition. */
200#define GIM_HV_HINT_NESTED_HYPERV RT_BIT(12)
201/** Recommend using INT for MBEC system calls. */
202#define GIM_HV_HINT_INT_FOR_MBEC_SYSCALLS RT_BIT(13)
203/** Recommend using enlightened VMCS interfacea and nested enlightenments. */
204#define GIM_HV_HINT_NESTED_ENLIGHTENED_VMCS_INTERFACE RT_BIT(14)
205/** @} */
206
207
208/** @name Hyper-V implementation hardware features.
209 * Which hardware features are in use by the hypervisor.
210 * @{
211 */
212/** APIC overlay is used. */
213#define GIM_HV_HOST_FEAT_AVIC RT_BIT(0)
214/** MSR bitmaps is used. */
215#define GIM_HV_HOST_FEAT_MSR_BITMAP RT_BIT(1)
216/** Architectural performance counter supported. */
217#define GIM_HV_HOST_FEAT_PERF_COUNTER RT_BIT(2)
218/** Nested paging is used. */
219#define GIM_HV_HOST_FEAT_NESTED_PAGING RT_BIT(3)
220/** DMA remapping is used. */
221#define GIM_HV_HOST_FEAT_DMA_REMAPPING RT_BIT(4)
222/** Interrupt remapping is used. */
223#define GIM_HV_HOST_FEAT_INTERRUPT_REMAPPING RT_BIT(5)
224/** Memory patrol scrubber is present. */
225#define GIM_HV_HOST_FEAT_MEM_PATROL_SCRUBBER RT_BIT(6)
226/** DMA protection is in use. */
227#define GIM_HV_HOST_FEAT_DMA_PROT_IN_USE RT_BIT(7)
228/** HPET is requested. */
229#define GIM_HV_HOST_FEAT_HPET_REQUESTED RT_BIT(8)
230/** Synthetic timers are volatile. */
231#define GIM_HV_HOST_FEAT_STIMER_VOLATILE RT_BIT(9)
232/** @} */
233
234
235/** @name Hyper-V MSRs.
236 * @{
237 */
238/** Start of range 0. */
239#define MSR_GIM_HV_RANGE0_FIRST UINT32_C(0x40000000)
240/** Guest OS identification (R/W) */
241#define MSR_GIM_HV_GUEST_OS_ID UINT32_C(0x40000000)
242/** Enable hypercall interface (R/W) */
243#define MSR_GIM_HV_HYPERCALL UINT32_C(0x40000001)
244/** Virtual processor's (VCPU) index (R) */
245#define MSR_GIM_HV_VP_INDEX UINT32_C(0x40000002)
246/** Reset operation (R/W) */
247#define MSR_GIM_HV_RESET UINT32_C(0x40000003)
248/** End of range 0. */
249#define MSR_GIM_HV_RANGE0_LAST MSR_GIM_HV_RESET
250
251/** Start of range 1. */
252#define MSR_GIM_HV_RANGE1_FIRST UINT32_C(0x40000010)
253/** Virtual processor's (VCPU) runtime (R) */
254#define MSR_GIM_HV_VP_RUNTIME UINT32_C(0x40000010)
255/** End of range 1. */
256#define MSR_GIM_HV_RANGE1_LAST MSR_GIM_HV_VP_RUNTIME
257
258/** Start of range 2. */
259#define MSR_GIM_HV_RANGE2_FIRST UINT32_C(0x40000020)
260/** Per-VM reference counter (R) */
261#define MSR_GIM_HV_TIME_REF_COUNT UINT32_C(0x40000020)
262/** Per-VM TSC page (R/W) */
263#define MSR_GIM_HV_REF_TSC UINT32_C(0x40000021)
264/** Frequency of TSC in Hz as reported by the hypervisor (R) */
265#define MSR_GIM_HV_TSC_FREQ UINT32_C(0x40000022)
266/** Frequency of LAPIC in Hz as reported by the hypervisor (R) */
267#define MSR_GIM_HV_APIC_FREQ UINT32_C(0x40000023)
268/** End of range 2. */
269#define MSR_GIM_HV_RANGE2_LAST MSR_GIM_HV_APIC_FREQ
270
271/** Start of range 3. */
272#define MSR_GIM_HV_RANGE3_FIRST UINT32_C(0x40000070)
273/** Access to APIC EOI (End-Of-Interrupt) register (W) */
274#define MSR_GIM_HV_EOI UINT32_C(0x40000070)
275/** Access to APIC ICR (Interrupt Command) register (R/W) */
276#define MSR_GIM_HV_ICR UINT32_C(0x40000071)
277/** Access to APIC TPR (Task Priority) register (R/W) */
278#define MSR_GIM_HV_TPR UINT32_C(0x40000072)
279/** Enables lazy EOI processing (R/W) */
280#define MSR_GIM_HV_APIC_ASSIST_PAGE UINT32_C(0x40000073)
281/** End of range 3. */
282#define MSR_GIM_HV_RANGE3_LAST MSR_GIM_HV_APIC_ASSIST_PAGE
283
284/** Start of range 4. */
285#define MSR_GIM_HV_RANGE4_FIRST UINT32_C(0x40000080)
286/** Control behaviour of synthetic interrupt controller (R/W) */
287#define MSR_GIM_HV_SCONTROL UINT32_C(0x40000080)
288/** Synthetic interrupt controller version (R) */
289#define MSR_GIM_HV_SVERSION UINT32_C(0x40000081)
290/** Base address of synthetic interrupt event flag (R/W) */
291#define MSR_GIM_HV_SIEFP UINT32_C(0x40000082)
292/** Base address of synthetic interrupt message page (R/W) */
293#define MSR_GIM_HV_SIMP UINT32_C(0x40000083)
294/** End-Of-Message in synthetic interrupt parameter page (W) */
295#define MSR_GIM_HV_EOM UINT32_C(0x40000084)
296/** End of range 4. */
297#define MSR_GIM_HV_RANGE4_LAST MSR_GIM_HV_EOM
298
299/** Start of range 5. */
300#define MSR_GIM_HV_RANGE5_FIRST UINT32_C(0x40000090)
301/** Configures synthetic interrupt source 0 (R/W) */
302#define MSR_GIM_HV_SINT0 UINT32_C(0x40000090)
303/** Configures synthetic interrupt source 1 (R/W) */
304#define MSR_GIM_HV_SINT1 UINT32_C(0x40000091)
305/** Configures synthetic interrupt source 2 (R/W) */
306#define MSR_GIM_HV_SINT2 UINT32_C(0x40000092)
307/** Configures synthetic interrupt source 3 (R/W) */
308#define MSR_GIM_HV_SINT3 UINT32_C(0x40000093)
309/** Configures synthetic interrupt source 4 (R/W) */
310#define MSR_GIM_HV_SINT4 UINT32_C(0x40000094)
311/** Configures synthetic interrupt source 5 (R/W) */
312#define MSR_GIM_HV_SINT5 UINT32_C(0x40000095)
313/** Configures synthetic interrupt source 6 (R/W) */
314#define MSR_GIM_HV_SINT6 UINT32_C(0x40000096)
315/** Configures synthetic interrupt source 7 (R/W) */
316#define MSR_GIM_HV_SINT7 UINT32_C(0x40000097)
317/** Configures synthetic interrupt source 8 (R/W) */
318#define MSR_GIM_HV_SINT8 UINT32_C(0x40000098)
319/** Configures synthetic interrupt source 9 (R/W) */
320#define MSR_GIM_HV_SINT9 UINT32_C(0x40000099)
321/** Configures synthetic interrupt source 10 (R/W) */
322#define MSR_GIM_HV_SINT10 UINT32_C(0x4000009A)
323/** Configures synthetic interrupt source 11 (R/W) */
324#define MSR_GIM_HV_SINT11 UINT32_C(0x4000009B)
325/** Configures synthetic interrupt source 12 (R/W) */
326#define MSR_GIM_HV_SINT12 UINT32_C(0x4000009C)
327/** Configures synthetic interrupt source 13 (R/W) */
328#define MSR_GIM_HV_SINT13 UINT32_C(0x4000009D)
329/** Configures synthetic interrupt source 14 (R/W) */
330#define MSR_GIM_HV_SINT14 UINT32_C(0x4000009E)
331/** Configures synthetic interrupt source 15 (R/W) */
332#define MSR_GIM_HV_SINT15 UINT32_C(0x4000009F)
333/** End of range 5. */
334#define MSR_GIM_HV_RANGE5_LAST MSR_GIM_HV_SINT15
335
336/** Start of range 6. */
337#define MSR_GIM_HV_RANGE6_FIRST UINT32_C(0x400000B0)
338/** Configures register for synthetic timer 0 (R/W) */
339#define MSR_GIM_HV_STIMER0_CONFIG UINT32_C(0x400000B0)
340/** Expiration time or period for synthetic timer 0 (R/W) */
341#define MSR_GIM_HV_STIMER0_COUNT UINT32_C(0x400000B1)
342/** Configures register for synthetic timer 1 (R/W) */
343#define MSR_GIM_HV_STIMER1_CONFIG UINT32_C(0x400000B2)
344/** Expiration time or period for synthetic timer 1 (R/W) */
345#define MSR_GIM_HV_STIMER1_COUNT UINT32_C(0x400000B3)
346/** Configures register for synthetic timer 2 (R/W) */
347#define MSR_GIM_HV_STIMER2_CONFIG UINT32_C(0x400000B4)
348/** Expiration time or period for synthetic timer 2 (R/W) */
349#define MSR_GIM_HV_STIMER2_COUNT UINT32_C(0x400000B5)
350/** Configures register for synthetic timer 3 (R/W) */
351#define MSR_GIM_HV_STIMER3_CONFIG UINT32_C(0x400000B6)
352/** Expiration time or period for synthetic timer 3 (R/W) */
353#define MSR_GIM_HV_STIMER3_COUNT UINT32_C(0x400000B7)
354/** End of range 6. */
355#define MSR_GIM_HV_RANGE6_LAST MSR_GIM_HV_STIMER3_COUNT
356
357/** Start of range 7. */
358#define MSR_GIM_HV_RANGE7_FIRST UINT32_C(0x400000C1)
359/** Trigger to transition to power state C1 (R) */
360#define MSR_GIM_HV_POWER_STATE_TRIGGER_C1 UINT32_C(0x400000C1)
361/** Trigger to transition to power state C2 (R) */
362#define MSR_GIM_HV_POWER_STATE_TRIGGER_C2 UINT32_C(0x400000C2)
363/** Trigger to transition to power state C3 (R) */
364#define MSR_GIM_HV_POWER_STATE_TRIGGER_C3 UINT32_C(0x400000C3)
365/** End of range 7. */
366#define MSR_GIM_HV_RANGE7_LAST MSR_GIM_HV_POWER_STATE_TRIGGER_C3
367
368/** Start of range 8. */
369#define MSR_GIM_HV_RANGE8_FIRST UINT32_C(0x400000D1)
370/** Configure the recipe for power state transitions to C1 (R/W) */
371#define MSR_GIM_HV_POWER_STATE_CONFIG_C1 UINT32_C(0x400000D1)
372/** Configure the recipe for power state transitions to C2 (R/W) */
373#define MSR_GIM_HV_POWER_STATE_CONFIG_C2 UINT32_C(0x400000D2)
374/** Configure the recipe for power state transitions to C3 (R/W) */
375#define MSR_GIM_HV_POWER_STATE_CONFIG_C3 UINT32_C(0x400000D3)
376/** End of range 8. */
377#define MSR_GIM_HV_RANGE8_LAST MSR_GIM_HV_POWER_STATE_CONFIG_C3
378
379/** Start of range 9. */
380#define MSR_GIM_HV_RANGE9_FIRST UINT32_C(0x400000E0)
381/** Map the guest's retail partition stats page (R/W) */
382#define MSR_GIM_HV_STATS_PART_RETAIL_PAGE UINT32_C(0x400000E0)
383/** Map the guest's internal partition stats page (R/W) */
384#define MSR_GIM_HV_STATS_PART_INTERNAL_PAGE UINT32_C(0x400000E1)
385/** Map the guest's retail VP stats page (R/W) */
386#define MSR_GIM_HV_STATS_VP_RETAIL_PAGE UINT32_C(0x400000E2)
387/** Map the guest's internal VP stats page (R/W) */
388#define MSR_GIM_HV_STATS_VP_INTERNAL_PAGE UINT32_C(0x400000E3)
389/** End of range 9. */
390#define MSR_GIM_HV_RANGE9_LAST MSR_GIM_HV_STATS_VP_INTERNAL_PAGE
391
392/** Start of range 10. */
393#define MSR_GIM_HV_RANGE10_FIRST UINT32_C(0x400000F0)
394/** Trigger the guest's transition to idle power state (R) */
395#define MSR_GIM_HV_GUEST_IDLE UINT32_C(0x400000F0)
396/** Synthetic debug control. */
397#define MSR_GIM_HV_SYNTH_DEBUG_CONTROL UINT32_C(0x400000F1)
398/** Synthetic debug status. */
399#define MSR_GIM_HV_SYNTH_DEBUG_STATUS UINT32_C(0x400000F2)
400/** Synthetic debug send buffer. */
401#define MSR_GIM_HV_SYNTH_DEBUG_SEND_BUFFER UINT32_C(0x400000F3)
402/** Synthetic debug receive buffer. */
403#define MSR_GIM_HV_SYNTH_DEBUG_RECEIVE_BUFFER UINT32_C(0x400000F4)
404/** Synthetic debug pending buffer. */
405#define MSR_GIM_HV_SYNTH_DEBUG_PENDING_BUFFER UINT32_C(0x400000F5)
406/** End of range 10. */
407#define MSR_GIM_HV_RANGE10_LAST MSR_GIM_HV_SYNTH_DEBUG_PENDING_BUFFER
408
409/** Start of range 11. */
410#define MSR_GIM_HV_RANGE11_FIRST UINT32_C(0x400000FF)
411/** Undocumented debug options MSR. */
412#define MSR_GIM_HV_DEBUG_OPTIONS_MSR UINT32_C(0x400000FF)
413/** End of range 11. */
414#define MSR_GIM_HV_RANGE11_LAST MSR_GIM_HV_DEBUG_OPTIONS_MSR
415
416/** Start of range 12. */
417#define MSR_GIM_HV_RANGE12_FIRST UINT32_C(0x40000100)
418/** Guest crash MSR 0. */
419#define MSR_GIM_HV_CRASH_P0 UINT32_C(0x40000100)
420/** Guest crash MSR 1. */
421#define MSR_GIM_HV_CRASH_P1 UINT32_C(0x40000101)
422/** Guest crash MSR 2. */
423#define MSR_GIM_HV_CRASH_P2 UINT32_C(0x40000102)
424/** Guest crash MSR 3. */
425#define MSR_GIM_HV_CRASH_P3 UINT32_C(0x40000103)
426/** Guest crash MSR 4. */
427#define MSR_GIM_HV_CRASH_P4 UINT32_C(0x40000104)
428/** Guest crash control. */
429#define MSR_GIM_HV_CRASH_CTL UINT32_C(0x40000105)
430/** End of range 12. */
431#define MSR_GIM_HV_RANGE12_LAST MSR_GIM_HV_CRASH_CTL
432/** @} */
433
434AssertCompile(MSR_GIM_HV_RANGE0_FIRST <= MSR_GIM_HV_RANGE0_LAST);
435AssertCompile(MSR_GIM_HV_RANGE1_FIRST <= MSR_GIM_HV_RANGE1_LAST);
436AssertCompile(MSR_GIM_HV_RANGE2_FIRST <= MSR_GIM_HV_RANGE2_LAST);
437AssertCompile(MSR_GIM_HV_RANGE3_FIRST <= MSR_GIM_HV_RANGE3_LAST);
438AssertCompile(MSR_GIM_HV_RANGE4_FIRST <= MSR_GIM_HV_RANGE4_LAST);
439AssertCompile(MSR_GIM_HV_RANGE5_FIRST <= MSR_GIM_HV_RANGE5_LAST);
440AssertCompile(MSR_GIM_HV_RANGE6_FIRST <= MSR_GIM_HV_RANGE6_LAST);
441AssertCompile(MSR_GIM_HV_RANGE7_FIRST <= MSR_GIM_HV_RANGE7_LAST);
442AssertCompile(MSR_GIM_HV_RANGE8_FIRST <= MSR_GIM_HV_RANGE8_LAST);
443AssertCompile(MSR_GIM_HV_RANGE9_FIRST <= MSR_GIM_HV_RANGE9_LAST);
444AssertCompile(MSR_GIM_HV_RANGE10_FIRST <= MSR_GIM_HV_RANGE10_LAST);
445AssertCompile(MSR_GIM_HV_RANGE11_FIRST <= MSR_GIM_HV_RANGE11_LAST);
446
447/** @name Hyper-V MSR - Reset (MSR_GIM_HV_RESET).
448 * @{
449 */
450/** The reset enable mask. */
451#define MSR_GIM_HV_RESET_ENABLE RT_BIT_64(0)
452/** Whether the reset MSR is enabled. */
453#define MSR_GIM_HV_RESET_IS_ENABLED(a) RT_BOOL((a) & MSR_GIM_HV_RESET_ENABLE)
454/** @} */
455
456/** @name Hyper-V MSR - Hypercall (MSR_GIM_HV_HYPERCALL).
457 * @{
458 */
459/** Guest-physical page frame number of the hypercall-page. */
460#define MSR_GIM_HV_HYPERCALL_GUEST_PFN(a) ((a) >> 12)
461/** The hypercall enable mask. */
462#define MSR_GIM_HV_HYPERCALL_PAGE_ENABLE RT_BIT_64(0)
463/** Whether the hypercall-page is enabled or not. */
464#define MSR_GIM_HV_HYPERCALL_PAGE_IS_ENABLED(a) RT_BOOL((a) & MSR_GIM_HV_HYPERCALL_PAGE_ENABLE)
465/** @} */
466
467/** @name Hyper-V MSR - Reference TSC (MSR_GIM_HV_REF_TSC).
468 * @{
469 */
470/** Guest-physical page frame number of the TSC-page. */
471#define MSR_GIM_HV_REF_TSC_GUEST_PFN(a) ((a) >> 12)
472/** The TSC-page enable mask. */
473#define MSR_GIM_HV_REF_TSC_ENABLE RT_BIT_64(0)
474/** Whether the TSC-page is enabled or not. */
475#define MSR_GIM_HV_REF_TSC_IS_ENABLED(a) RT_BOOL((a) & MSR_GIM_HV_REF_TSC_ENABLE)
476/** @} */
477
478/** @name Hyper-V MSR - Guest crash control (MSR_GIM_HV_CRASH_CTL).
479 * @{
480 */
481/** The Crash Control notify mask. */
482#define MSR_GIM_HV_CRASH_CTL_NOTIFY RT_BIT_64(63)
483/** @} */
484
485/** @name Hyper-V MSR - Guest OS ID (MSR_GIM_HV_GUEST_OS_ID).
486 * @{
487 */
488/** An open-source operating system. */
489#define MSR_GIM_HV_GUEST_OS_ID_IS_OPENSOURCE(a) RT_BOOL((a) & RT_BIT_64(63))
490/** Vendor ID. */
491#define MSR_GIM_HV_GUEST_OS_ID_VENDOR(a) (uint32_t)(((a) >> 48) & 0xfff)
492/** Guest OS variant, depending on the vendor ID. */
493#define MSR_GIM_HV_GUEST_OS_ID_OS_VARIANT(a) (uint32_t)(((a) >> 40) & 0xff)
494/** Guest OS major version. */
495#define MSR_GIM_HV_GUEST_OS_ID_MAJOR_VERSION(a) (uint32_t)(((a) >> 32) & 0xff)
496/** Guest OS minor version. */
497#define MSR_GIM_HV_GUEST_OS_ID_MINOR_VERSION(a) (uint32_t)(((a) >> 24) & 0xff)
498/** Guest OS service version (e.g. service pack number in case of Windows). */
499#define MSR_GIM_HV_GUEST_OS_ID_SERVICE_VERSION(a) (uint32_t)(((a) >> 16) & 0xff)
500/** Guest OS build number. */
501#define MSR_GIM_HV_GUEST_OS_ID_BUILD(a) (uint32_t)((a) & 0xffff)
502/** @} */
503
504/** @name Hyper-V MSR - APIC-assist page (MSR_GIM_HV_APIC_ASSIST_PAGE).
505 * @{
506 */
507/** Guest-physical page frame number of the APIC-assist page. */
508#define MSR_GIM_HV_APICASSIST_GUEST_PFN(a) ((a) >> 12)
509/** The APIC-assist page enable mask. */
510#define MSR_GIM_HV_APICASSIST_PAGE_ENABLE RT_BIT_64(0)
511/** Whether the APIC-assist page is enabled or not. */
512#define MSR_GIM_HV_APICASSIST_PAGE_IS_ENABLED(a) RT_BOOL((a) & MSR_GIM_HV_APICASSIST_PAGE_ENABLE)
513/** @} */
514
515/** @name Hyper-V MSR - Synthetic Interrupt Event Flags page
516 * (MSR_GIM_HV_SIEFP).
517 * @{
518 */
519/** Guest-physical page frame number of the APIC-assist page. */
520#define MSR_GIM_HV_SIEF_GUEST_PFN(a) ((a) >> 12)
521/** The SIEF enable mask. */
522#define MSR_GIM_HV_SIEF_PAGE_ENABLE RT_BIT_64(0)
523/** Whether the SIEF page is enabled or not. */
524#define MSR_GIM_HV_SIEF_PAGE_IS_ENABLED(a) RT_BOOL((a) & MSR_GIM_HV_SIEF_PAGE_ENABLE)
525/** @} */
526
527/** @name Hyper-V MSR - Synthetic Interrupt Control (MSR_GIM_HV_CONTROL).
528 * @{
529 */
530/** The SControl enable mask. */
531#define MSR_GIM_HV_SCONTROL_ENABLE RT_BIT_64(0)
532/** Whether SControl is enabled or not. */
533#define MSR_GIM_HV_SCONTROL_IS_ENABLED(a) RT_BOOL((a) & MSR_GIM_HV_SCONTROL_ENABLE)
534/** @} */
535
536/** @name Hyper-V MSR - Synthetic Timer Config (MSR_GIM_HV_STIMER_CONFIG).
537 * @{
538 */
539/** The Stimer enable mask. */
540#define MSR_GIM_HV_STIMER_ENABLE RT_BIT_64(0)
541/** Whether Stimer is enabled or not. */
542#define MSR_GIM_HV_STIMER_IS_ENABLED(a) RT_BOOL((a) & MSR_GIM_HV_STIMER_ENABLE)
543/** The Stimer periodic mask. */
544#define MSR_GIM_HV_STIMER_PERIODIC RT_BIT_64(1)
545/** Whether Stimer is enabled or not. */
546#define MSR_GIM_HV_STIMER_IS_PERIODIC(a) RT_BOOL((a) & MSR_GIM_HV_STIMER_PERIODIC)
547/** The Stimer lazy mask. */
548#define MSR_GIM_HV_STIMER_LAZY RT_BIT_64(2)
549/** Whether Stimer is enabled or not. */
550#define MSR_GIM_HV_STIMER_IS_LAZY(a) RT_BOOL((a) & MSR_GIM_HV_STIMER_LAZY)
551/** The Stimer auto-enable mask. */
552#define MSR_GIM_HV_STIMER_AUTO_ENABLE RT_BIT_64(3)
553/** Whether Stimer is enabled or not. */
554#define MSR_GIM_HV_STIMER_IS_AUTO_ENABLED(a) RT_BOOL((a) & MSR_GIM_HV_STIMER_AUTO_ENABLE)
555/** The Stimer SINTx mask (bits 16:19). */
556#define MSR_GIM_HV_STIMER_SINTX UINT64_C(0xf0000)
557/** Gets the Stimer synthetic interrupt source. */
558#define MSR_GIM_HV_STIMER_GET_SINTX(a) (((a) >> 16) & 0xf)
559/** The Stimer valid read/write mask. */
560#define MSR_GIM_HV_STIMER_RW_VALID ( MSR_GIM_HV_STIMER_ENABLE | MSR_GIM_HV_STIMER_PERIODIC \
561 | MSR_GIM_HV_STIMER_LAZY | MSR_GIM_HV_STIMER_AUTO_ENABLE \
562 | MSR_GIM_HV_STIMER_SINTX)
563/** @} */
564
565/**
566 * Hyper-V APIC-assist (HV_REFERENCE_TSC_PAGE) structure placed in the TSC
567 * reference page.
568 */
569typedef struct GIMHVAPICASSIST
570{
571 uint32_t fNoEoiRequired : 1;
572 uint32_t u31Reserved0 : 31;
573} GIMHVAPICASSIST;
574/** Pointer to Hyper-V reference TSC. */
575typedef GIMHVAPICASSIST *PGIMHVAPICASSIST;
576/** Pointer to a const Hyper-V reference TSC. */
577typedef GIMHVAPICASSIST const *PCGIMHVAPICASSIST;
578AssertCompileSize(GIMHVAPICASSIST, 4);
579
580/**
581 * Hypercall parameter type.
582 */
583typedef enum GIMHVHYPERCALLPARAM
584{
585 GIMHVHYPERCALLPARAM_IN = 0,
586 GIMHVHYPERCALLPARAM_OUT
587} GIMHVHYPERCALLPARAM;
588
589
590/** @name Hyper-V hypercall op codes.
591 * @{
592 */
593/** Post message to hypervisor or VMs. */
594#define GIM_HV_HYPERCALL_OP_POST_MESSAGE 0x5C
595/** Post debug data to hypervisor. */
596#define GIM_HV_HYPERCALL_OP_POST_DEBUG_DATA 0x69
597/** Retreive debug data from hypervisor. */
598#define GIM_HV_HYPERCALL_OP_RETREIVE_DEBUG_DATA 0x6A
599/** Reset debug session. */
600#define GIM_HV_HYPERCALL_OP_RESET_DEBUG_SESSION 0x6B
601/** @} */
602
603/** @name Hyper-V extended hypercall op codes.
604 * @{
605 */
606/** Query extended hypercall capabilities. */
607#define GIM_HV_EXT_HYPERCALL_OP_QUERY_CAP 0x8001
608/** Query guest physical address range that has zero'd filled memory. */
609#define GIM_HV_EXT_HYPERCALL_OP_GET_BOOT_ZEROED_MEM 0x8002
610/** @} */
611
612
613/** @name Hyper-V Extended hypercall - HvExtCallQueryCapabilities.
614 * @{
615 */
616/** Boot time zeroed pages. */
617#define GIM_HV_EXT_HYPERCALL_CAP_ZERO_MEM RT_BIT_64(0)
618/** Whether boot time zeroed pages capability is enabled. */
619#define GIM_HV_EXT_HYPERCALL_CAP_IS_ZERO_MEM_ENABLED(a) RT_BOOL((a) & GIM_HV_EXT_HYPERCALL_CAP_ZERO_MEM)
620/** @} */
621
622
623/** @name Hyper-V hypercall inputs.
624 * @{
625 */
626/** The hypercall call operation code. */
627#define GIM_HV_HYPERCALL_IN_CALL_CODE(a) ((a) & UINT64_C(0xffff))
628/** Whether it's a fast (register based) hypercall or not (memory-based). */
629#define GIM_HV_HYPERCALL_IN_IS_FAST(a) RT_BOOL((a) & RT_BIT_64(16))
630/** Total number of reps for a rep hypercall. */
631#define GIM_HV_HYPERCALL_IN_REP_COUNT(a) (((a) << 32) & UINT64_C(0xfff))
632/** Rep start index for a rep hypercall. */
633#define GIM_HV_HYPERCALL_IN_REP_START_IDX(a) (((a) << 48) & UINT64_C(0xfff))
634/** Reserved bits range 1. */
635#define GIM_HV_HYPERCALL_IN_RSVD_1(a) (((a) << 17) & UINT64_C(0x7fff))
636/** Reserved bits range 2. */
637#define GIM_HV_HYPERCALL_IN_RSVD_2(a) (((a) << 44) & UINT64_C(0xf))
638/** Reserved bits range 3. */
639#define GIM_HV_HYPERCALL_IN_RSVD_3(a) (((a) << 60) & UINT64_C(0x7))
640/** @} */
641
642
643/** @name Hyper-V hypercall status codes.
644 * @{
645 */
646/** Success. */
647#define GIM_HV_STATUS_SUCCESS 0x00
648/** Unrecognized hypercall. */
649#define GIM_HV_STATUS_INVALID_HYPERCALL_CODE 0x02
650/** Invalid hypercall input (rep count, rsvd bits). */
651#define GIM_HV_STATUS_INVALID_HYPERCALL_INPUT 0x03
652/** Hypercall guest-physical address not 8-byte aligned or crosses page boundary. */
653#define GIM_HV_STATUS_INVALID_ALIGNMENT 0x04
654/** Invalid hypercall parameters. */
655#define GIM_HV_STATUS_INVALID_PARAMETER 0x05
656/** Access denied. */
657#define GIM_HV_STATUS_ACCESS_DENIED 0x06
658/** The partition state not valid for specified op. */
659#define GIM_HV_STATUS_INVALID_PARTITION_STATE 0x07
660/** The hypercall operation could not be performed. */
661#define GIM_HV_STATUS_OPERATION_DENIED 0x08
662/** Specified partition property ID not recognized. */
663#define GIM_HV_STATUS_UNKNOWN_PROPERTY 0x09
664/** Specified partition property value not within range. */
665#define GIM_HV_STATUS_PROPERTY_VALUE_OUT_OF_RANGE 0x0a
666/** Insufficient memory for performing the hypercall. */
667#define GIM_HV_STATUS_INSUFFICIENT_MEMORY 0x0b
668/** Maximum partition depth has been exceeded for the partition hierarchy. */
669#define GIM_HV_STATUS_PARTITION_TOO_DEEP 0x0c
670/** The specified partition ID is not valid. */
671#define GIM_HV_STATUS_INVALID_PARTITION_ID 0x0d
672/** The specified virtual processor index in invalid. */
673#define GIM_HV_STATUS_INVALID_VP_INDEX 0x0e
674/** The specified port ID is not unique or doesn't exist. */
675#define GIM_HV_STATUS_INVALID_PORT_ID 0x11
676/** The specified connection ID is not unique or doesn't exist. */
677#define GIM_HV_STATUS_INVALID_CONNECTION_ID 0x12
678/** The target port doesn't have sufficient buffers for the caller to post a message. */
679#define GIM_HV_STATUS_INSUFFICIENT_BUFFERS 0x13
680/** External interrupt not acknowledged.*/
681#define GIM_HV_STATUS_NOT_ACKNOWLEDGED 0x14
682/** External interrupt acknowledged. */
683#define GIM_HV_STATUS_ACKNOWLEDGED 0x16
684/** Invalid state due to misordering Hv[Save|Restore]PartitionState. */
685#define GIM_HV_STATUS_INVALID_SAVE_RESTORE_STATE 0x17
686/** Operation not perform due to a required feature of SynIc was disabled. */
687#define GIM_HV_STATUS_INVALID_SYNIC_STATE 0x18
688/** Object or value already in use. */
689#define GIM_HV_STATUS_OBJECT_IN_USE 0x19
690/** Invalid proximity domain information. */
691#define GIM_HV_STATUS_INVALID_PROXIMITY_DOMAIN_INFO 0x1A
692/** Attempt to retrieve data failed. */
693#define GIM_HV_STATUS_NO_DATA 0x1B
694/** Debug connection has not recieved any new data since the last time. */
695#define GIM_HV_STATUS_INACTIVE 0x1C
696/** A resource is unavailable for allocation. */
697#define GIM_HV_STATUS_NO_RESOURCES 0x1D
698/** A hypervisor feature is not available to the caller. */
699#define GIM_HV_STATUS_FEATURE_UNAVAILABLE 0x1E
700/** The debug packet returned is partial due to an I/O error. */
701#define GIM_HV_STATUS_PARTIAL_PACKET 0x1F
702/** Processor feature SSE3 unsupported. */
703#define GIM_HV_STATUS_PROC_FEAT_SSE3_NOT_SUPPORTED 0x20
704/** Processor feature LAHSAHF unsupported. */
705#define GIM_HV_STATUS_PROC_FEAT_LAHSAHF_NOT_SUPPORTED 0x21
706/** Processor feature SSSE3 unsupported. */
707#define GIM_HV_STATUS_PROC_FEAT_SSSE3_NOT_SUPPORTED 0x22
708/** Processor feature SSE4.1 unsupported. */
709#define GIM_HV_STATUS_PROC_FEAT_SSE4_1_NOT_SUPPORTED 0x23
710/** Processor feature SSE4.2 unsupported. */
711#define GIM_HV_STATUS_PROC_FEAT_SSE4_2_NOT_SUPPORTED 0x24
712/** Processor feature SSE4A unsupported. */
713#define GIM_HV_STATUS_PROC_FEAT_SSE4A_NOT_SUPPORTED 0x25
714/** Processor feature XOP unsupported. */
715#define GIM_HV_STATUS_PROC_FEAT_XOP_NOT_SUPPORTED 0x26
716/** Processor feature POPCNT unsupported. */
717#define GIM_HV_STATUS_PROC_FEAT_POPCNT_NOT_SUPPORTED 0x27
718/** Processor feature CMPXCHG16B unsupported. */
719#define GIM_HV_STATUS_PROC_FEAT_CMPXCHG16B_NOT_SUPPORTED 0x28
720/** Processor feature ALTMOVCR8 unsupported. */
721#define GIM_HV_STATUS_PROC_FEAT_ALTMOVCR8_NOT_SUPPORTED 0x29
722/** Processor feature LZCNT unsupported. */
723#define GIM_HV_STATUS_PROC_FEAT_LZCNT_NOT_SUPPORTED 0x2A
724/** Processor feature misaligned SSE unsupported. */
725#define GIM_HV_STATUS_PROC_FEAT_MISALIGNED_SSE_NOT_SUPPORTED 0x2B
726/** Processor feature MMX extensions unsupported. */
727#define GIM_HV_STATUS_PROC_FEAT_MMX_EXT_NOT_SUPPORTED 0x2C
728/** Processor feature 3DNow! unsupported. */
729#define GIM_HV_STATUS_PROC_FEAT_3DNOW_NOT_SUPPORTED 0x2D
730/** Processor feature Extended 3DNow! unsupported. */
731#define GIM_HV_STATUS_PROC_FEAT_EXTENDED_3DNOW_NOT_SUPPORTED 0x2E
732/** Processor feature 1GB large page unsupported. */
733#define GIM_HV_STATUS_PROC_FEAT_PAGE_1GB_NOT_SUPPORTED 0x2F
734/** Processor cache line flush size incompatible. */
735#define GIM_HV_STATUS_PROC_CACHE_LINE_FLUSH_SIZE_INCOMPATIBLE 0x30
736/** Processor feature XSAVE unsupported. */
737#define GIM_HV_STATUS_PROC_FEAT_XSAVE_NOT_SUPPORTED 0x31
738/** Processor feature XSAVEOPT unsupported. */
739#define GIM_HV_STATUS_PROC_FEAT_XSAVEOPT_NOT_SUPPORTED 0x32
740/** The specified buffer was too small for all requested data. */
741#define GIM_HV_STATUS_INSUFFICIENT_BUFFER 0x33
742/** Processor feature XSAVEOPT unsupported. */
743#define GIM_HV_STATUS_PROC_FEAT_XSAVE_AVX_NOT_SUPPORTED 0x34
744/** Processor feature XSAVEOPT unsupported. */
745#define GIM_HV_STATUS_PROC_FEAT_XSAVE_FEAT_NOT_SUPPORTED 0x35 /** Huh, isn't this same as 0x31? */
746/** Processor feature XSAVEOPT unsupported. */
747#define GIM_HV_STATUS_PROC_FEAT_PAGE_XSAVE_SAVE_AREA_INCOMPATIBLE 0x36
748/** Processor architecture unsupoorted. */
749#define GIM_HV_STATUS_INCOMPATIBLE_PROCESSOR 0x37
750/** Max. domains for platform I/O remapping reached. */
751#define GIM_HV_STATUS_INSUFFICIENT_DEVICE_DOMAINS 0x38
752/** Processor feature AES unsupported. */
753#define GIM_HV_STATUS_PROC_FEAT_AES_NOT_SUPPORTED 0x39
754/** Processor feature PCMULQDQ unsupported. */
755#define GIM_HV_STATUS_PROC_FEAT_PCMULQDQ_NOT_SUPPORTED 0x3A
756/** Processor feature XSAVE features unsupported. */
757#define GIM_HV_STATUS_PROC_FEAT_XSAVE_FEATURES_INCOMPATIBLE 0x3B
758/** Generic CPUID validation error. */
759#define GIM_HV_STATUS_CPUID_FEAT_VALIDATION_ERROR 0x3C
760/** XSAVE CPUID validation error. */
761#define GIM_HV_STATUS_CPUID_XSAVE_FEAT_VALIDATION_ERROR 0x3D
762/** Processor startup timed out. */
763#define GIM_HV_STATUS_PROCESSOR_STARTUP_TIMEOUT 0x3E
764/** SMX enabled by the BIOS. */
765#define GIM_HV_STATUS_SMX_ENABLED 0x3F
766/** Processor feature PCID unsupported. */
767#define GIM_HV_STATUS_PROC_FEAT_PCID_NOT_SUPPORTED 0x40
768/** Invalid LP index. */
769#define GIM_HV_STATUS_INVALID_LP_INDEX 0x41
770/** Processor feature PCID unsupported. */
771#define GIM_HV_STATUS_FEAT_FMA4_NOT_SUPPORTED 0x42
772/** Processor feature PCID unsupported. */
773#define GIM_HV_STATUS_FEAT_F16C_NOT_SUPPORTED 0x43
774/** Processor feature PCID unsupported. */
775#define GIM_HV_STATUS_PROC_FEAT_RDRAND_NOT_SUPPORTED 0x44
776/** Processor feature RDWRFSGS unsupported. */
777#define GIM_HV_STATUS_PROC_FEAT_RDWRFSGS_NOT_SUPPORTED 0x45
778/** Processor feature SMEP unsupported. */
779#define GIM_HV_STATUS_PROC_FEAT_SMEP_NOT_SUPPORTED 0x46
780/** Processor feature enhanced fast string unsupported. */
781#define GIM_HV_STATUS_PROC_FEAT_ENHANCED_FAST_STRING_NOT_SUPPORTED 0x47
782/** Processor feature MOVBE unsupported. */
783#define GIM_HV_STATUS_PROC_FEAT_MOVBE_NOT_SUPPORTED 0x48
784/** Processor feature BMI1 unsupported. */
785#define GIM_HV_STATUS_PROC_FEAT_BMI1_NOT_SUPPORTED 0x49
786/** Processor feature BMI2 unsupported. */
787#define GIM_HV_STATUS_PROC_FEAT_BMI2_NOT_SUPPORTED 0x4A
788/** Processor feature HLE unsupported. */
789#define GIM_HV_STATUS_PROC_FEAT_HLE_NOT_SUPPORTED 0x4B
790/** Processor feature RTM unsupported. */
791#define GIM_HV_STATUS_PROC_FEAT_RTM_NOT_SUPPORTED 0x4C
792/** Processor feature XSAVE FMA unsupported. */
793#define GIM_HV_STATUS_PROC_FEAT_XSAVE_FMA_NOT_SUPPORTED 0x4D
794/** Processor feature XSAVE AVX2 unsupported. */
795#define GIM_HV_STATUS_PROC_FEAT_XSAVE_AVX2_NOT_SUPPORTED 0x4E
796/** Processor feature NPIEP1 unsupported. */
797#define GIM_HV_STATUS_PROC_FEAT_NPIEP1_NOT_SUPPORTED 0x4F
798/** @} */
799
800
801/** @name Hyper-V MSR - Debug control (MSR_GIM_HV_SYNTH_DEBUG_CONTROL).
802 * @{
803 */
804/** Perform debug write. */
805#define MSR_GIM_HV_SYNTH_DEBUG_CONTROL_IS_WRITE(a) RT_BOOL((a) & RT_BIT_64(0))
806/** Perform debug read. */
807#define MSR_GIM_HV_SYNTH_DEBUG_CONTROL_IS_READ(a) RT_BOOL((a) & RT_BIT_64(1))
808/** Returns length of the debug write buffer. */
809#define MSR_GIM_HV_SYNTH_DEBUG_CONTROL_W_LEN(a) (((a) & UINT64_C(0xffff0000)) >> 16)
810/** @} */
811
812
813/** @name Hyper-V MSR - Debug status (MSR_GIM_HV_SYNTH_DEBUG_STATUS).
814 * @{
815 */
816/** Debug send buffer operation success. */
817#define MSR_GIM_HV_SYNTH_DEBUG_STATUS_W_SUCCESS RT_BIT_64(0)
818/** Debug receive buffer operation success. */
819#define MSR_GIM_HV_SYNTH_DEBUG_STATUS_R_SUCCESS RT_BIT_64(2)
820/** Debug connection was reset. */
821#define MSR_GIM_HV_SYNTH_DEBUG_STATUS_CONN_RESET RT_BIT_64(3)
822/** @} */
823
824
825/** @name Hyper-V MSR - synthetic interrupt (MSR_GIM_HV_SINTx).
826 * @{
827 */
828/** The interrupt masked mask. */
829#define MSR_GIM_HV_SINT_MASKED RT_BIT_64(16)
830/** Whether the interrupt source is masked. */
831#define MSR_GIM_HV_SINT_IS_MASKED(a) RT_BOOL((a) & MSR_GIM_HV_SINT_MASKED)
832/** Gets the interrupt vector. */
833#define MSR_GIM_HV_SINT_GET_VECTOR(a) ((a) & UINT64_C(0xff))
834/** The AutoEoi mask. */
835#define MSR_GIM_HV_SINT_AUTOEOI RT_BIT_64(17)
836/** Gets whether AutoEoi is enabled for the synthetic interrupt. */
837#define MSR_GIM_HV_SINT_IS_AUTOEOI(a) RT_BOOL((a) & MSR_GIM_HV_SINT_AUTOEOI)
838/** @} */
839
840
841/** @name Hyper-V MSR - synthetic interrupt message page (MSR_GIM_HV_SIMP).
842 * @{
843 */
844/** The SIMP enable mask. */
845#define MSR_GIM_HV_SIMP_ENABLE RT_BIT_64(0)
846/** Whether the SIMP is enabled. */
847#define MSR_GIM_HV_SIMP_IS_ENABLED(a) RT_BOOL((a) & MSR_GIM_HV_SIMP_ENABLE)
848/** The SIMP guest-physical address. */
849#define MSR_GIM_HV_SIMP_GPA(a) ((a) & UINT64_C(0xfffffffffffff000))
850/** @} */
851
852
853/** @name Hyper-V hypercall debug options.
854 * @{ */
855/** Maximum debug data payload size in bytes. */
856#define GIM_HV_DEBUG_MAX_DATA_SIZE 4088
857
858/** The undocumented bit for MSR_GIM_HV_DEBUG_OPTIONS_MSR that makes it all
859 * work. */
860#define GIM_HV_DEBUG_OPTIONS_USE_HYPERCALLS RT_BIT(2)
861
862/** Guest will perform the HvPostDebugData hypercall until completion. */
863#define GIM_HV_DEBUG_POST_LOOP RT_BIT_32(0)
864/** Mask of valid HvPostDebugData options. */
865#define GIM_HV_DEBUG_POST_OPTIONS_MASK RT_BIT_32(0)
866
867/** Guest will perform the HvRetrieveDebugData hypercall until completion. */
868#define GIM_HV_DEBUG_RETREIVE_LOOP RT_BIT_32(0)
869/** Guest checks if any global debug session is active. */
870#define GIM_HV_DEBUG_RETREIVE_TEST_ACTIVITY RT_BIT_32(1)
871/** Mask of valid HvRetrieveDebugData options. */
872#define GIM_HV_DEBUG_RETREIVE_OPTIONS_MASK RT_BIT_32(0) | RT_BIT_32(1)
873
874/** Guest requests purging of incoming debug data. */
875#define GIM_HV_DEBUG_PURGE_INCOMING_DATA RT_BIT_32(0)
876/** Guest requests purging of outgoing debug data. */
877#define GIM_HV_DEBUG_PURGE_OUTGOING_DATA RT_BIT_32(1)
878/** @} */
879
880
881/** @name VMBus.
882 * These are just arbitrary definitions made up by Microsoft without
883 * any publicly available specification behind it.
884 * @{ */
885/** VMBus connection ID. */
886#define GIM_HV_VMBUS_MSG_CONNECTION_ID 1
887/** VMBus synthetic interrupt source (see VMBUS_MESSAGE_SINT in linux
888 * sources). */
889#define GIM_HV_VMBUS_MSG_SINT 2
890/** @} */
891
892/** @name SynIC.
893 * Synthetic Interrupt Controller definitions.
894 * @{ */
895/** SynIC version register. */
896#define GIM_HV_SVERSION 1
897/** Number of synthetic interrupt sources (warning, fixed in saved-states!). */
898#define GIM_HV_SINT_COUNT 16
899/** Lowest valid vector for synthetic interrupt. */
900#define GIM_HV_SINT_VECTOR_VALID_MIN 16
901/** Highest valid vector for synthetic interrupt. */
902#define GIM_HV_SINT_VECTOR_VALID_MAX 255
903/** Number of synthetic timers. */
904#define GIM_HV_STIMER_COUNT 4
905/** @} */
906
907/** @name Hyper-V synthetic interrupt message type.
908 * See 14.8.2 "SynIC Message Types"
909 * @{
910 */
911typedef enum GIMHVMSGTYPE
912{
913 GIMHVMSGTYPE_NONE = 0, /* Common messages */
914 GIMHVMSGTYPE_VMBUS = 1, /* Guest messages */
915 GIMHVMSGTYPE_UNMAPPEDGPA = 0x80000000, /* Hypervisor messages */
916 GIMHVMSGTYPE_GPAINTERCEPT = 0x80000001,
917 GIMHVMSGTYPE_TIMEREXPIRED = 0x80000010,
918 GIMHVMSGTYPE_INVALIDVPREGVAL = 0x80000020,
919 GIMHVMSGTYPE_UNRECOVERABLEXCPT = 0x80000021,
920 GIMHVMSGTYPE_UNSUPPORTEDFEAT = 0x80000022,
921 GIMHVMSGTYPE_APICEOI = 0x80000030,
922 GIMHVMSGTYPE_X64LEGACYFPERROR = 0x80000031,
923 GIMHVMSGTYPE_EVENTLOGBUFSCOMPLETE = 0x80000040,
924 GIMHVMSGTYPE_X64IOPORTINTERCEPT = 0x80010000,
925 GIMHVMSGTYPE_X64MSRINTERCEPT = 0x80010001,
926 GIMHVMSGTYPE_X64CPUIDINTERCEPT = 0x80010002,
927 GIMHVMSGTYPE_X64XCPTINTERCEPT = 0x80010003
928} GIMHVMSGTYPE;
929AssertCompileSize(GIMHVMSGTYPE, 4);
930/** @} */
931
932
933/** @name Hyper-V synthetic interrupt message format.
934 * @{ */
935#define GIM_HV_MSG_SIZE 256
936#define GIM_HV_MSG_MAX_PAYLOAD_SIZE 240
937#define GIM_HV_MSG_MAX_PAYLOAD_UNITS 30
938
939/**
940 * Synthetic interrupt message flags.
941 */
942typedef union GIMHVMSGFLAGS
943{
944 struct
945 {
946 uint8_t u1Pending : 1;
947 uint8_t u7Reserved : 7;
948 } n;
949 uint8_t u;
950} GIMHVMSGFLAGS;
951AssertCompileSize(GIMHVMSGFLAGS, sizeof(uint8_t));
952
953/**
954 * Synthetic interrupt message header.
955 *
956 * @remarks The layout of this structure differs from
957 * the Hyper-V spec. Aug 8, 2013 v4.0a. Layout
958 * in accordance w/ VMBus client expectations.
959 */
960typedef struct GIMHVMSGHDR
961{
962 GIMHVMSGTYPE enmMessageType;
963 uint8_t cbPayload;
964 GIMHVMSGFLAGS MessageFlags;
965 uint16_t uRsvd;
966 union
967 {
968 uint64_t uOriginatorId;
969 uint64_t uPartitionId;
970 uint64_t uPortId;
971 } msgid;
972} GIMHVMSGHDR;
973/** Pointer to a synthetic interrupt message header. */
974typedef GIMHVMSGHDR *PGIMHVMSGHDR;
975AssertCompileMemberOffset(GIMHVMSGHDR, cbPayload, 4);
976AssertCompileMemberOffset(GIMHVMSGHDR, MessageFlags, 5);
977AssertCompileMemberOffset(GIMHVMSGHDR, msgid, 8);
978AssertCompileSize(GIMHVMSGHDR, GIM_HV_MSG_SIZE - GIM_HV_MSG_MAX_PAYLOAD_SIZE);
979
980/**
981 * Synthetic interrupt message.
982 */
983typedef struct GIMHVMSG
984{
985 GIMHVMSGHDR MsgHdr;
986 uint64_t aPayload[GIM_HV_MSG_MAX_PAYLOAD_UNITS];
987} GIMHVMSG;
988/** Pointer to a synthetic interrupt message. */
989typedef GIMHVMSG *PGIMHVMSG;
990AssertCompileSize(GIMHVMSG, GIM_HV_MSG_SIZE);
991/** @} */
992
993
994/** @name Hyper-V hypercall parameters.
995 * @{ */
996/**
997 * HvPostMessage hypercall input.
998 */
999typedef struct GIMHVPOSTMESSAGEIN
1000{
1001 uint32_t uConnectionId;
1002 uint32_t uPadding;
1003 GIMHVMSGTYPE enmMessageType;
1004 uint32_t cbPayload;
1005} GIMHVPOSTMESSAGEIN;
1006/** Pointer to a HvPostMessage input struct. */
1007typedef GIMHVPOSTMESSAGEIN *PGIMHVPOSTMESSAGEIN;
1008AssertCompileSize(GIMHVPOSTMESSAGEIN, 16);
1009
1010/**
1011 * HvResetDebugData hypercall input.
1012 */
1013typedef struct GIMHVDEBUGRESETIN
1014{
1015 uint32_t fFlags;
1016 uint32_t uPadding;
1017} GIMHVDEBUGRESETIN;
1018/** Pointer to a HvResetDebugData input struct. */
1019typedef GIMHVDEBUGRESETIN *PGIMHVDEBUGRESETIN;
1020AssertCompileSize(GIMHVDEBUGRESETIN, 8);
1021
1022/**
1023 * HvPostDebugData hypercall input.
1024 */
1025typedef struct GIMHVDEBUGPOSTIN
1026{
1027 uint32_t cbWrite;
1028 uint32_t fFlags;
1029} GIMHVDEBUGPOSTIN;
1030/** Pointer to a HvPostDebugData input struct. */
1031typedef GIMHVDEBUGPOSTIN *PGIMHVDEBUGPOSTIN;
1032AssertCompileSize(GIMHVDEBUGPOSTIN, 8);
1033
1034/**
1035 * HvPostDebugData hypercall output.
1036 */
1037typedef struct GIMHVDEBUGPOSTOUT
1038{
1039 uint32_t cbPending;
1040 uint32_t uPadding;
1041} GIMHVDEBUGPOSTOUT;
1042/** Pointer to a HvPostDebugData output struct. */
1043typedef GIMHVDEBUGPOSTOUT *PGIMHVDEBUGPOSTOUT;
1044AssertCompileSize(GIMHVDEBUGPOSTOUT, 8);
1045
1046/**
1047 * HvRetrieveDebugData hypercall input.
1048 */
1049typedef struct GIMHVDEBUGRETRIEVEIN
1050{
1051 uint32_t cbRead;
1052 uint32_t fFlags;
1053 uint64_t u64Timeout;
1054} GIMHVDEBUGRETRIEVEIN;
1055/** Pointer to a HvRetrieveDebugData input struct. */
1056typedef GIMHVDEBUGRETRIEVEIN *PGIMHVDEBUGRETRIEVEIN;
1057AssertCompileSize(GIMHVDEBUGRETRIEVEIN, 16);
1058
1059/**
1060 * HvRetriveDebugData hypercall output.
1061 */
1062typedef struct GIMHVDEBUGRETRIEVEOUT
1063{
1064 uint32_t cbRead;
1065 uint32_t cbRemaining;
1066} GIMHVDEBUGRETRIEVEOUT;
1067/** Pointer to a HvRetrieveDebugData output struct. */
1068typedef GIMHVDEBUGRETRIEVEOUT *PGIMHVDEBUGRETRIEVEOUT;
1069AssertCompileSize(GIMHVDEBUGRETRIEVEOUT, 8);
1070
1071/**
1072 * HvExtCallQueryCapabilities hypercall output.
1073 */
1074typedef struct GIMHVEXTQUERYCAP
1075{
1076 uint64_t fCapabilities;
1077} GIMHVEXTQUERYCAP;
1078/** Pointer to a HvExtCallQueryCapabilities output struct. */
1079typedef GIMHVEXTQUERYCAP *PGIMHVEXTQUERYCAP;
1080AssertCompileSize(GIMHVEXTQUERYCAP, 8);
1081
1082/**
1083 * HvExtCallGetBootZeroedMemory hypercall output.
1084 */
1085typedef struct GIMHVEXTGETBOOTZEROMEM
1086{
1087 RTGCPHYS GCPhysStart;
1088 uint64_t cPages;
1089} GIMHVEXTGETBOOTZEROMEM;
1090/** Pointer to a HvExtCallGetBootZeroedMemory output struct. */
1091typedef GIMHVEXTGETBOOTZEROMEM *PGIMHVEXTGETBOOTZEROMEM;
1092AssertCompileSize(GIMHVEXTGETBOOTZEROMEM, 16);
1093/** @} */
1094
1095
1096/** Hyper-V page size. */
1097#define GIM_HV_PAGE_SIZE 4096
1098/** Hyper-V page shift. */
1099#define GIM_HV_PAGE_SHIFT 12
1100
1101/** Microsoft Hyper-V vendor signature. */
1102#define GIM_HV_VENDOR_MICROSOFT "Microsoft Hv"
1103
1104/**
1105 * MMIO2 region indices.
1106 */
1107/** The hypercall page region. */
1108#define GIM_HV_HYPERCALL_PAGE_REGION_IDX UINT8_C(0)
1109/** The TSC page region. */
1110#define GIM_HV_REF_TSC_PAGE_REGION_IDX UINT8_C(1)
1111/** The maximum region index (must be <= UINT8_MAX). */
1112#define GIM_HV_REGION_IDX_MAX GIM_HV_REF_TSC_PAGE_REGION_IDX
1113
1114/**
1115 * Hyper-V TSC (HV_REFERENCE_TSC_PAGE) structure placed in the TSC reference
1116 * page.
1117 */
1118typedef struct GIMHVREFTSC
1119{
1120 uint32_t u32TscSequence;
1121 uint32_t uReserved0;
1122 uint64_t u64TscScale;
1123 int64_t i64TscOffset;
1124} GIMHVTSCPAGE;
1125/** Pointer to Hyper-V reference TSC. */
1126typedef GIMHVREFTSC *PGIMHVREFTSC;
1127/** Pointer to a const Hyper-V reference TSC. */
1128typedef GIMHVREFTSC const *PCGIMHVREFTSC;
1129
1130/**
1131 * Type of the next reply to be sent to the debug connection of the guest.
1132 *
1133 * @remarks This is saved as part of saved-state, so don't re-order or
1134 * alter the size!
1135 */
1136typedef enum GIMHVDEBUGREPLY
1137{
1138 /** Send UDP packet. */
1139 GIMHVDEBUGREPLY_UDP = 0,
1140 /** Send DHCP offer for DHCP discover. */
1141 GIMHVDEBUGREPLY_DHCP_OFFER,
1142 /** DHCP offer sent. */
1143 GIMHVDEBUGREPLY_DHCP_OFFER_SENT,
1144 /** Send DHCP acknowledgement for DHCP request. */
1145 GIMHVDEBUGREPLY_DHCP_ACK,
1146 /** DHCP acknowledgement sent. */
1147 GIMHVDEBUGREPLY_DHCP_ACK_SENT,
1148 /** Sent ARP reply. */
1149 GIMHVDEBUGREPLY_ARP_REPLY,
1150 /** ARP reply sent. */
1151 GIMHVDEBUGREPLY_ARP_REPLY_SENT,
1152 /** Customary 32-bit type hack. */
1153 GIMHVDEBUGREPLY_32BIT_HACK = 0x7fffffff
1154} GIMHVDEBUGREPLY;
1155AssertCompileSize(GIMHVDEBUGREPLY, sizeof(uint32_t));
1156
1157/**
1158 * GIM Hyper-V VM instance data.
1159 * Changes to this must checked against the padding of the gim union in VM!
1160 */
1161typedef struct GIMHV
1162{
1163 /** @name Primary MSRs.
1164 * @{ */
1165 /** Guest OS identity MSR. */
1166 uint64_t u64GuestOsIdMsr;
1167 /** Hypercall MSR. */
1168 uint64_t u64HypercallMsr;
1169 /** Reference TSC page MSR. */
1170 uint64_t u64TscPageMsr;
1171 /** @} */
1172
1173 /** @name CPUID features.
1174 * @{ */
1175 /** Basic features. */
1176 uint32_t uBaseFeat;
1177 /** Partition flags. */
1178 uint32_t uPartFlags;
1179 /** Power management. */
1180 uint32_t uPowMgmtFeat;
1181 /** Miscellaneous. */
1182 uint32_t uMiscFeat;
1183 /** Hypervisor hints to the guest. */
1184 uint32_t uHyperHints;
1185 /** Hypervisor capabilities. */
1186 uint32_t uHyperCaps;
1187 /** @} */
1188
1189 /** @name Guest Crash MSRs.
1190 * @{
1191 */
1192 /** Guest crash control MSR. */
1193 uint64_t uCrashCtlMsr;
1194 /** Guest crash parameter 0 MSR. */
1195 uint64_t uCrashP0Msr;
1196 /** Guest crash parameter 1 MSR. */
1197 uint64_t uCrashP1Msr;
1198 /** Guest crash parameter 2 MSR. */
1199 uint64_t uCrashP2Msr;
1200 /** Guest crash parameter 3 MSR. */
1201 uint64_t uCrashP3Msr;
1202 /** Guest crash parameter 4 MSR. */
1203 uint64_t uCrashP4Msr;
1204 /** @} */
1205
1206 /** @name Time management.
1207 * @{ */
1208 /** Per-VM R0 Spinlock for protecting EMT writes to the TSC page. */
1209 RTSPINLOCK hSpinlockR0;
1210 /** The TSC frequency (in HZ) reported to the guest. */
1211 uint64_t cTscTicksPerSecond;
1212 /** @} */
1213
1214 /** @name Hypercalls.
1215 * @{ */
1216 /** Guest address of the hypercall input parameter page. */
1217 RTGCPHYS GCPhysHypercallIn;
1218 /** Guest address of the hypercall output parameter page. */
1219 RTGCPHYS GCPhysHypercallOut;
1220 /** Pointer to the hypercall input parameter page - R3. */
1221 R3PTRTYPE(uint8_t *) pbHypercallIn;
1222 /** Pointer to the hypercall output parameter page - R3. */
1223 R3PTRTYPE(uint8_t *) pbHypercallOut;
1224 /** @} */
1225
1226 /** @name Guest debugging.
1227 * @{ */
1228 /** Whether we're posing as the Microsoft vendor. */
1229 bool fIsVendorMsHv;
1230 /** Whether we're posing as the Microsoft virtualization service. */
1231 bool fIsInterfaceVs;
1232 /** Whether debugging support is enabled. */
1233 bool fDbgEnabled;
1234 /** Whether we should suggest a hypercall-based debug interface to the guest. */
1235 bool fDbgHypercallInterface;
1236 bool afAlignment0[4];
1237 /** The action to take while sending replies. */
1238 GIMHVDEBUGREPLY enmDbgReply;
1239 /** The IP address chosen by/assigned to the guest. */
1240 RTNETADDRIPV4 DbgGuestIp4Addr;
1241 /** Transaction ID for the BOOTP+DHCP sequence. */
1242 uint32_t uDbgBootpXId;
1243 /** The source UDP port used by the guest while sending debug packets. */
1244 uint16_t uUdpGuestSrcPort;
1245 /** The destination UDP port used by the guest while sending debug packets. */
1246 uint16_t uUdpGuestDstPort;
1247 /** Debug send buffer MSR. */
1248 uint64_t uDbgSendBufferMsr;
1249 /** Debug receive buffer MSR. */
1250 uint64_t uDbgRecvBufferMsr;
1251 /** Debug pending buffer MSR. */
1252 uint64_t uDbgPendingBufferMsr;
1253 /** Debug status MSR. */
1254 uint64_t uDbgStatusMsr;
1255 /** Intermediate debug I/O buffer (GIM_HV_PAGE_SIZE). */
1256 R3PTRTYPE(void *) pvDbgBuffer;
1257 R3PTRTYPE(void *) pvAlignment0;
1258 /** @} */
1259
1260 /** Array of MMIO2 regions. */
1261 GIMMMIO2REGION aMmio2Regions[GIM_HV_REGION_IDX_MAX + 1];
1262} GIMHV;
1263/** Pointer to per-VM GIM Hyper-V instance data. */
1264typedef GIMHV *PGIMHV;
1265/** Pointer to const per-VM GIM Hyper-V instance data. */
1266typedef GIMHV const *PCGIMHV;
1267AssertCompileMemberAlignment(GIMHV, aMmio2Regions, 8);
1268AssertCompileMemberAlignment(GIMHV, hSpinlockR0, sizeof(uintptr_t));
1269
1270/**
1271 * Hyper-V per-VCPU synthetic timer.
1272 */
1273typedef struct GIMHVSTIMER
1274{
1275 /** Synthetic timer handle. */
1276 TMTIMERHANDLE hTimer;
1277 /** Virtual CPU ID this timer belongs to (for reverse mapping). */
1278 VMCPUID idCpu;
1279 /** The index of this timer in the auStimers array (for reverse mapping). */
1280 uint32_t idxStimer;
1281 /** Synthetic timer config MSR. */
1282 uint64_t uStimerConfigMsr;
1283 /** Synthetic timer count MSR. */
1284 uint64_t uStimerCountMsr;
1285} GIMHVSTIMER;
1286/** Pointer to per-VCPU Hyper-V synthetic timer. */
1287typedef GIMHVSTIMER *PGIMHVSTIMER;
1288/** Pointer to a const per-VCPU Hyper-V synthetic timer. */
1289typedef GIMHVSTIMER const *PCGIMHVSTIMER;
1290AssertCompileSizeAlignment(GIMHVSTIMER, 8);
1291
1292/**
1293 * Hyper-V VCPU instance data.
1294 * Changes to this must checked against the padding of the gim union in VMCPU!
1295 */
1296typedef struct GIMHVCPU
1297{
1298 /** @name Synthetic interrupt MSRs.
1299 * @{ */
1300 /** Synthetic interrupt message page MSR. */
1301 uint64_t uSimpMsr;
1302 /** Interrupt source MSRs. */
1303 uint64_t auSintMsrs[GIM_HV_SINT_COUNT];
1304 /** Synethtic interrupt events flag page MSR. */
1305 uint64_t uSiefpMsr;
1306 /** APIC-assist page MSR. */
1307 uint64_t uApicAssistPageMsr;
1308 /** Synthetic interrupt control MSR. */
1309 uint64_t uSControlMsr;
1310 /** Synthetic timers. */
1311 GIMHVSTIMER aStimers[GIM_HV_STIMER_COUNT];
1312 /** @} */
1313
1314 /** @name Statistics.
1315 * @{ */
1316 STAMCOUNTER aStatStimerFired[GIM_HV_STIMER_COUNT];
1317 /** @} */
1318} GIMHVCPU;
1319/** Pointer to per-VCPU GIM Hyper-V instance data. */
1320typedef GIMHVCPU *PGIMHVCPU;
1321/** Pointer to const per-VCPU GIM Hyper-V instance data. */
1322typedef GIMHVCPU const *PCGIMHVCPU;
1323
1324
1325RT_C_DECLS_BEGIN
1326
1327#ifdef IN_RING0
1328VMMR0_INT_DECL(int) gimR0HvInitVM(PVMCC pVM);
1329VMMR0_INT_DECL(int) gimR0HvTermVM(PVMCC pVM);
1330VMMR0_INT_DECL(int) gimR0HvUpdateParavirtTsc(PVMCC pVM, uint64_t u64Offset);
1331#endif /* IN_RING0 */
1332
1333#ifdef IN_RING3
1334VMMR3_INT_DECL(int) gimR3HvInit(PVM pVM, PCFGMNODE pGimCfg);
1335VMMR3_INT_DECL(int) gimR3HvInitCompleted(PVM pVM);
1336VMMR3_INT_DECL(int) gimR3HvTerm(PVM pVM);
1337VMMR3_INT_DECL(void) gimR3HvRelocate(PVM pVM, RTGCINTPTR offDelta);
1338VMMR3_INT_DECL(void) gimR3HvReset(PVM pVM);
1339VMMR3_INT_DECL(int) gimR3HvSave(PVM pVM, PSSMHANDLE pSSM);
1340VMMR3_INT_DECL(int) gimR3HvLoad(PVM pVM, PSSMHANDLE pSSM);
1341VMMR3_INT_DECL(int) gimR3HvLoadDone(PVM pVM, PSSMHANDLE pSSM);
1342VMMR3_INT_DECL(int) gimR3HvGetDebugSetup(PVM pVM, PGIMDEBUGSETUP pDbgSetup);
1343
1344VMMR3_INT_DECL(int) gimR3HvDisableSiefPage(PVMCPU pVCpu);
1345VMMR3_INT_DECL(int) gimR3HvEnableSiefPage(PVMCPU pVCpu, RTGCPHYS GCPhysSiefPage);
1346VMMR3_INT_DECL(int) gimR3HvEnableSimPage(PVMCPU pVCpu, RTGCPHYS GCPhysSimPage);
1347VMMR3_INT_DECL(int) gimR3HvDisableSimPage(PVMCPU pVCpu);
1348VMMR3_INT_DECL(int) gimR3HvDisableApicAssistPage(PVMCPU pVCpu);
1349VMMR3_INT_DECL(int) gimR3HvEnableApicAssistPage(PVMCPU pVCpu, RTGCPHYS GCPhysTscPage);
1350VMMR3_INT_DECL(int) gimR3HvDisableTscPage(PVM pVM);
1351VMMR3_INT_DECL(int) gimR3HvEnableTscPage(PVM pVM, RTGCPHYS GCPhysTscPage, bool fUseThisTscSeq, uint32_t uTscSeq);
1352VMMR3_INT_DECL(int) gimR3HvDisableHypercallPage(PVM pVM);
1353VMMR3_INT_DECL(int) gimR3HvEnableHypercallPage(PVM pVM, RTGCPHYS GCPhysHypercallPage);
1354
1355VMMR3_INT_DECL(int) gimR3HvHypercallPostDebugData(PVM pVM, int *prcHv);
1356VMMR3_INT_DECL(int) gimR3HvHypercallRetrieveDebugData(PVM pVM, int *prcHv);
1357VMMR3_INT_DECL(int) gimR3HvDebugWrite(PVM pVM, void *pvData, uint32_t cbWrite, uint32_t *pcbWritten, bool fUdpPkt);
1358VMMR3_INT_DECL(int) gimR3HvDebugRead(PVM pVM, void *pvBuf, uint32_t cbBuf, uint32_t cbRead, uint32_t *pcbRead,
1359 uint32_t cMsTimeout, bool fUdpPkt);
1360VMMR3_INT_DECL(int) gimR3HvHypercallExtQueryCap(PVM pVM, int *prcHv);
1361VMMR3_INT_DECL(int) gimR3HvHypercallExtGetBootZeroedMem(PVM pVM, int *prcHv);
1362
1363#endif /* IN_RING3 */
1364
1365VMM_INT_DECL(PGIMMMIO2REGION) gimHvGetMmio2Regions(PVM pVM, uint32_t *pcRegions);
1366VMM_INT_DECL(bool) gimHvIsParavirtTscEnabled(PVM pVM);
1367VMM_INT_DECL(bool) gimHvAreHypercallsEnabled(PCVM pVM);
1368VMM_INT_DECL(bool) gimHvShouldTrapXcptUD(PVMCPU pVCpu);
1369VMM_INT_DECL(VBOXSTRICTRC) gimHvXcptUD(PVMCPUCC pVCpu, PCPUMCTX pCtx, PDISSTATE pDis, uint8_t *pcbInstr);
1370VMM_INT_DECL(VBOXSTRICTRC) gimHvHypercall(PVMCPUCC pVCpu, PCPUMCTX pCtx);
1371VMM_INT_DECL(VBOXSTRICTRC) gimHvHypercallEx(PVMCPUCC pVCpu, PCPUMCTX pCtx, unsigned uDisOpcode, uint8_t cbInstr);
1372#if !defined(VBOX_VMM_TARGET_ARMV8)
1373VMM_INT_DECL(VBOXSTRICTRC) gimHvReadMsr(PVMCPUCC pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue);
1374VMM_INT_DECL(VBOXSTRICTRC) gimHvWriteMsr(PVMCPUCC pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uRawValue);
1375#endif
1376
1377VMM_INT_DECL(void) gimHvStartStimer(PVMCPUCC pVCpu, PCGIMHVSTIMER pHvStimer);
1378
1379RT_C_DECLS_END
1380
1381#endif /* !VMM_INCLUDED_SRC_include_GIMHvInternal_h */
1382
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