3 * Copyright (c) 2009, Microsoft Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 * Place - Suite 330, Boston, MA 02111-1307 USA.
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
27 * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
28 * is set by CPUID(HvCpuIdFunctionVersionAndFeatures).
30 enum hv_cpuid_function
{
31 HvCpuIdFunctionVersionAndFeatures
= 0x00000001,
32 HvCpuIdFunctionHvVendorAndMaxFunction
= 0x40000000,
33 HvCpuIdFunctionHvInterface
= 0x40000001,
36 * The remaining functions depend on the value of
37 * HvCpuIdFunctionInterface
39 HvCpuIdFunctionMsHvVersion
= 0x40000002,
40 HvCpuIdFunctionMsHvFeatures
= 0x40000003,
41 HvCpuIdFunctionMsHvEnlightenmentInformation
= 0x40000004,
42 HvCpuIdFunctionMsHvImplementationLimits
= 0x40000005,
45 /* Define the virtual APIC registers */
46 #define HV_X64_MSR_EOI (0x40000070)
47 #define HV_X64_MSR_ICR (0x40000071)
48 #define HV_X64_MSR_TPR (0x40000072)
49 #define HV_X64_MSR_APIC_ASSIST_PAGE (0x40000073)
51 /* Define version of the synthetic interrupt controller. */
52 #define HV_SYNIC_VERSION (1)
54 /* Define synthetic interrupt controller model specific registers. */
55 #define HV_X64_MSR_SCONTROL (0x40000080)
56 #define HV_X64_MSR_SVERSION (0x40000081)
57 #define HV_X64_MSR_SIEFP (0x40000082)
58 #define HV_X64_MSR_SIMP (0x40000083)
59 #define HV_X64_MSR_EOM (0x40000084)
60 #define HV_X64_MSR_SINT0 (0x40000090)
61 #define HV_X64_MSR_SINT1 (0x40000091)
62 #define HV_X64_MSR_SINT2 (0x40000092)
63 #define HV_X64_MSR_SINT3 (0x40000093)
64 #define HV_X64_MSR_SINT4 (0x40000094)
65 #define HV_X64_MSR_SINT5 (0x40000095)
66 #define HV_X64_MSR_SINT6 (0x40000096)
67 #define HV_X64_MSR_SINT7 (0x40000097)
68 #define HV_X64_MSR_SINT8 (0x40000098)
69 #define HV_X64_MSR_SINT9 (0x40000099)
70 #define HV_X64_MSR_SINT10 (0x4000009A)
71 #define HV_X64_MSR_SINT11 (0x4000009B)
72 #define HV_X64_MSR_SINT12 (0x4000009C)
73 #define HV_X64_MSR_SINT13 (0x4000009D)
74 #define HV_X64_MSR_SINT14 (0x4000009E)
75 #define HV_X64_MSR_SINT15 (0x4000009F)
77 /* Define the expected SynIC version. */
78 #define HV_SYNIC_VERSION_1 (0x1)
80 /* Define synthetic interrupt controller message constants. */
81 #define HV_MESSAGE_SIZE (256)
82 #define HV_MESSAGE_PAYLOAD_BYTE_COUNT (240)
83 #define HV_MESSAGE_PAYLOAD_QWORD_COUNT (30)
84 #define HV_ANY_VP (0xFFFFFFFF)
86 /* Define synthetic interrupt controller flag constants. */
87 #define HV_EVENT_FLAGS_COUNT (256 * 8)
88 #define HV_EVENT_FLAGS_BYTE_COUNT (256)
89 #define HV_EVENT_FLAGS_DWORD_COUNT (256 / sizeof(u32))
91 /* Define hypervisor message types. */
92 enum hv_message_type
{
93 HvMessageTypeNone
= 0x00000000,
95 /* Memory access messages. */
96 HvMessageTypeUnmappedGpa
= 0x80000000,
97 HvMessageTypeGpaIntercept
= 0x80000001,
99 /* Timer notification messages. */
100 HvMessageTimerExpired
= 0x80000010,
102 /* Error messages. */
103 HvMessageTypeInvalidVpRegisterValue
= 0x80000020,
104 HvMessageTypeUnrecoverableException
= 0x80000021,
105 HvMessageTypeUnsupportedFeature
= 0x80000022,
107 /* Trace buffer complete messages. */
108 HvMessageTypeEventLogBufferComplete
= 0x80000040,
110 /* Platform-specific processor intercept messages. */
111 HvMessageTypeX64IoPortIntercept
= 0x80010000,
112 HvMessageTypeX64MsrIntercept
= 0x80010001,
113 HvMessageTypeX64CpuidIntercept
= 0x80010002,
114 HvMessageTypeX64ExceptionIntercept
= 0x80010003,
115 HvMessageTypeX64ApicEoi
= 0x80010004,
116 HvMessageTypeX64LegacyFpError
= 0x80010005
119 /* Define the number of synthetic interrupt sources. */
120 #define HV_SYNIC_SINT_COUNT (16)
121 #define HV_SYNIC_STIMER_COUNT (4)
123 /* Define invalid partition identifier. */
124 #define HV_PARTITION_ID_INVALID ((u64)0x0)
126 /* Define connection identifier type. */
127 union hv_connection_id
{
135 /* Define port identifier type. */
144 /* Define port type. */
146 HvPortTypeMessage
= 1,
148 HvPortTypeMonitor
= 3
151 /* Define port information structure. */
152 struct hv_port_info
{
153 enum hv_port_type PortType
;
175 struct hv_connection_info
{
176 enum hv_port_type PortType
;
181 } MessageConnectionInfo
;
184 } EventConnectionInfo
;
187 } MonitorConnectionInfo
;
191 /* Define synthetic interrupt controller message flags. */
192 union hv_message_flags
{
200 /* Define synthetic interrupt controller message header. */
201 struct hv_message_header
{
202 enum hv_message_type MessageType
;
204 union hv_message_flags MessageFlags
;
208 union hv_port_id Port
;
212 /* Define timer message payload structure. */
213 struct hv_timer_message_payload
{
216 u64 ExpirationTime
; /* When the timer expired */
217 u64 DeliveryTime
; /* When the message was delivered */
220 /* Define synthetic interrupt controller message format. */
222 struct hv_message_header Header
;
224 u64 Payload
[HV_MESSAGE_PAYLOAD_QWORD_COUNT
];
228 /* Define the number of message buffers associated with each port. */
229 #define HV_PORT_MESSAGE_BUFFER_COUNT (16)
231 /* Define the synthetic interrupt message page layout. */
232 struct hv_message_page
{
233 struct hv_message SintMessage
[HV_SYNIC_SINT_COUNT
];
236 /* Define the synthetic interrupt controller event flags format. */
237 union hv_synic_event_flags
{
238 u8 Flags8
[HV_EVENT_FLAGS_BYTE_COUNT
];
239 u32 Flags32
[HV_EVENT_FLAGS_DWORD_COUNT
];
242 /* Define the synthetic interrupt flags page layout. */
243 struct hv_synic_event_flags_page
{
244 union hv_synic_event_flags SintEventFlags
[HV_SYNIC_SINT_COUNT
];
247 /* Define SynIC control register. */
248 union hv_synic_scontrol
{
256 /* Define synthetic interrupt source. */
257 union hv_synic_sint
{
268 /* Define the format of the SIMP register */
269 union hv_synic_simp
{
278 /* Define the format of the SIEFP register */
279 union hv_synic_siefp
{
288 /* Definitions for the monitored notification facility */
289 union hv_monitor_trigger_group
{
297 struct hv_monitor_parameter
{
298 union hv_connection_id ConnectionId
;
303 union hv_monitor_trigger_state
{
312 /* struct hv_monitor_page Layout */
313 /* ------------------------------------------------------ */
314 /* | 0 | TriggerState (4 bytes) | Rsvd1 (4 bytes) | */
315 /* | 8 | TriggerGroup[0] | */
316 /* | 10 | TriggerGroup[1] | */
317 /* | 18 | TriggerGroup[2] | */
318 /* | 20 | TriggerGroup[3] | */
319 /* | 28 | Rsvd2[0] | */
320 /* | 30 | Rsvd2[1] | */
321 /* | 38 | Rsvd2[2] | */
322 /* | 40 | NextCheckTime[0][0] | NextCheckTime[0][1] | */
324 /* | 240 | Latency[0][0..3] | */
325 /* | 340 | Rsvz3[0] | */
326 /* | 440 | Parameter[0][0] | */
327 /* | 448 | Parameter[0][1] | */
329 /* | 840 | Rsvd4[0] | */
330 /* ------------------------------------------------------ */
331 struct hv_monitor_page
{
332 union hv_monitor_trigger_state TriggerState
;
335 union hv_monitor_trigger_group TriggerGroup
[4];
338 s32 NextCheckTime
[4][32];
343 struct hv_monitor_parameter Parameter
[4][32];
348 /* Declare the various hypercall operations. */
350 HvCallPostMessage
= 0x005c,
351 HvCallSignalEvent
= 0x005d,
354 /* Definition of the HvPostMessage hypercall input structure. */
355 struct hv_input_post_message
{
356 union hv_connection_id ConnectionId
;
358 enum hv_message_type MessageType
;
360 u64 Payload
[HV_MESSAGE_PAYLOAD_QWORD_COUNT
];
363 /* Definition of the HvSignalEvent hypercall input structure. */
364 struct hv_input_signal_event
{
365 union hv_connection_id ConnectionId
;
371 * Versioning definitions used for guests reporting themselves to the
372 * hypervisor, and visa versa.
375 /* Version info reported by guest OS's */
376 enum hv_guest_os_vendor
{
377 HvGuestOsVendorMicrosoft
= 0x0001
380 enum hv_guest_os_microsoft_ids
{
381 HvGuestOsMicrosoftUndefined
= 0x00,
382 HvGuestOsMicrosoftMSDOS
= 0x01,
383 HvGuestOsMicrosoftWindows3x
= 0x02,
384 HvGuestOsMicrosoftWindows9x
= 0x03,
385 HvGuestOsMicrosoftWindowsNT
= 0x04,
386 HvGuestOsMicrosoftWindowsCE
= 0x05
390 * Declare the MSR used to identify the guest OS.
392 #define HV_X64_MSR_GUEST_OS_ID 0x40000000
394 union hv_x64_msr_guest_os_id_contents
{
398 u64 ServiceVersion
:8; /* Service Pack, etc. */
401 u64 OsId
:8; /* enum hv_guest_os_microsoft_ids (if Vendor=MS) */
402 u64 VendorId
:16; /* enum hv_guest_os_vendor */
407 * Declare the MSR used to setup pages used to communicate with the hypervisor.
409 #define HV_X64_MSR_HYPERCALL 0x40000001
411 union hv_x64_msr_hypercall_contents
{
416 u64 GuestPhysicalAddress
:52;