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 /* Define the virtual APIC registers */
29 #define HV_X64_MSR_EOI (0x40000070)
30 #define HV_X64_MSR_ICR (0x40000071)
31 #define HV_X64_MSR_TPR (0x40000072)
32 #define HV_X64_MSR_APIC_ASSIST_PAGE (0x40000073)
35 /* Define version of the synthetic interrupt controller. */
38 #define HV_SYNIC_VERSION (1)
42 /* Define synthetic interrupt controller model specific registers. */
45 #define HV_X64_MSR_SCONTROL (0x40000080)
46 #define HV_X64_MSR_SVERSION (0x40000081)
47 #define HV_X64_MSR_SIEFP (0x40000082)
48 #define HV_X64_MSR_SIMP (0x40000083)
49 #define HV_X64_MSR_EOM (0x40000084)
50 #define HV_X64_MSR_SINT0 (0x40000090)
51 #define HV_X64_MSR_SINT1 (0x40000091)
52 #define HV_X64_MSR_SINT2 (0x40000092)
53 #define HV_X64_MSR_SINT3 (0x40000093)
54 #define HV_X64_MSR_SINT4 (0x40000094)
55 #define HV_X64_MSR_SINT5 (0x40000095)
56 #define HV_X64_MSR_SINT6 (0x40000096)
57 #define HV_X64_MSR_SINT7 (0x40000097)
58 #define HV_X64_MSR_SINT8 (0x40000098)
59 #define HV_X64_MSR_SINT9 (0x40000099)
60 #define HV_X64_MSR_SINT10 (0x4000009A)
61 #define HV_X64_MSR_SINT11 (0x4000009B)
62 #define HV_X64_MSR_SINT12 (0x4000009C)
63 #define HV_X64_MSR_SINT13 (0x4000009D)
64 #define HV_X64_MSR_SINT14 (0x4000009E)
65 #define HV_X64_MSR_SINT15 (0x4000009F)
68 /* Define the expected SynIC version. */
70 #define HV_SYNIC_VERSION_1 (0x1)
73 /* Define synthetic interrupt controller message constants. */
76 #define HV_MESSAGE_SIZE (256)
77 #define HV_MESSAGE_PAYLOAD_BYTE_COUNT (240)
78 #define HV_MESSAGE_PAYLOAD_QWORD_COUNT (30)
79 #define HV_ANY_VP (0xFFFFFFFF)
82 /* Define synthetic interrupt controller flag constants. */
85 #define HV_EVENT_FLAGS_COUNT (256 * 8)
86 #define HV_EVENT_FLAGS_BYTE_COUNT (256)
87 #define HV_EVENT_FLAGS_DWORD_COUNT (256 / sizeof(u32))
90 /* Define hypervisor message types. */
92 typedef enum _HV_MESSAGE_TYPE
94 HvMessageTypeNone
= 0x00000000,
97 /* Memory access messages. */
99 HvMessageTypeUnmappedGpa
= 0x80000000,
100 HvMessageTypeGpaIntercept
= 0x80000001,
103 /* Timer notification messages. */
105 HvMessageTimerExpired
= 0x80000010,
108 /* Error messages. */
110 HvMessageTypeInvalidVpRegisterValue
= 0x80000020,
111 HvMessageTypeUnrecoverableException
= 0x80000021,
112 HvMessageTypeUnsupportedFeature
= 0x80000022,
115 /* Trace buffer complete messages. */
117 HvMessageTypeEventLogBufferComplete
= 0x80000040,
120 /* Platform-specific processor intercept messages. */
122 HvMessageTypeX64IoPortIntercept
= 0x80010000,
123 HvMessageTypeX64MsrIntercept
= 0x80010001,
124 HvMessageTypeX64CpuidIntercept
= 0x80010002,
125 HvMessageTypeX64ExceptionIntercept
= 0x80010003,
126 HvMessageTypeX64ApicEoi
= 0x80010004,
127 HvMessageTypeX64LegacyFpError
= 0x80010005
129 } HV_MESSAGE_TYPE
, *PHV_MESSAGE_TYPE
;
132 /* Define the number of synthetic interrupt sources. */
135 #define HV_SYNIC_SINT_COUNT (16)
136 #define HV_SYNIC_STIMER_COUNT (4)
139 /* Define the synthetic interrupt source index type. */
142 typedef u32 HV_SYNIC_SINT_INDEX
, *PHV_SYNIC_SINT_INDEX
;
145 /* Define partition identifier type. */
148 typedef u64 HV_PARTITION_ID
, *PHV_PARTITION_ID
;
151 /* Define invalid partition identifier. */
153 #define HV_PARTITION_ID_INVALID ((HV_PARTITION_ID) 0x0)
156 /* Define connection identifier type. */
159 typedef union _HV_CONNECTION_ID
169 } HV_CONNECTION_ID
, *PHV_CONNECTION_ID
;
172 /* Define port identifier type. */
175 typedef union _HV_PORT_ID
185 } HV_PORT_ID
, *PHV_PORT_ID
;
188 /* Define port type. */
191 typedef enum _HV_PORT_TYPE
193 HvPortTypeMessage
= 1,
195 HvPortTypeMonitor
= 3
196 } HV_PORT_TYPE
, *PHV_PORT_TYPE
;
199 /* Define port information structure. */
202 typedef struct _HV_PORT_INFO
204 HV_PORT_TYPE PortType
;
211 HV_SYNIC_SINT_INDEX TargetSint
;
212 HV_VP_INDEX TargetVp
;
218 HV_SYNIC_SINT_INDEX TargetSint
;
219 HV_VP_INDEX TargetVp
;
231 } HV_PORT_INFO
, *PHV_PORT_INFO
;
233 typedef const HV_PORT_INFO
*PCHV_PORT_INFO
;
235 typedef struct _HV_CONNECTION_INFO
237 HV_PORT_TYPE PortType
;
245 } MessageConnectionInfo
;
250 } EventConnectionInfo
;
255 } MonitorConnectionInfo
;
257 } HV_CONNECTION_INFO
, *PHV_CONNECTION_INFO
;
259 typedef const HV_CONNECTION_INFO
*PCHV_CONNECTION_INFO
;
262 /* Define synthetic interrupt controller message flags. */
265 typedef union _HV_MESSAGE_FLAGS
273 } HV_MESSAGE_FLAGS
, *PHV_MESSAGE_FLAGS
;
277 /* Define synthetic interrupt controller message header. */
280 typedef struct _HV_MESSAGE_HEADER
282 HV_MESSAGE_TYPE MessageType
;
284 HV_MESSAGE_FLAGS MessageFlags
;
288 HV_PARTITION_ID Sender
;
292 } HV_MESSAGE_HEADER
, *PHV_MESSAGE_HEADER
;
295 /* Define timer message payload structure. */
297 typedef struct _HV_TIMER_MESSAGE_PAYLOAD
301 HV_NANO100_TIME ExpirationTime
; /* When the timer expired */
302 HV_NANO100_TIME DeliveryTime
; /* When the message was delivered */
303 } HV_TIMER_MESSAGE_PAYLOAD
, *PHV_TIMER_MESSAGE_PAYLOAD
;
306 /* Define synthetic interrupt controller message format. */
309 typedef struct _HV_MESSAGE
311 HV_MESSAGE_HEADER Header
;
314 u64 Payload
[HV_MESSAGE_PAYLOAD_QWORD_COUNT
];
316 } HV_MESSAGE
, *PHV_MESSAGE
;
319 /* Define the number of message buffers associated with each port. */
322 #define HV_PORT_MESSAGE_BUFFER_COUNT (16)
325 /* Define the synthetic interrupt message page layout. */
328 typedef struct _HV_MESSAGE_PAGE
330 volatile HV_MESSAGE SintMessage
[HV_SYNIC_SINT_COUNT
];
331 } HV_MESSAGE_PAGE
, *PHV_MESSAGE_PAGE
;
335 /* Define the synthetic interrupt controller event flags format. */
338 typedef union _HV_SYNIC_EVENT_FLAGS
340 u8 Flags8
[HV_EVENT_FLAGS_BYTE_COUNT
];
341 u32 Flags32
[HV_EVENT_FLAGS_DWORD_COUNT
];
342 } HV_SYNIC_EVENT_FLAGS
, *PHV_SYNIC_EVENT_FLAGS
;
346 /* Define the synthetic interrupt flags page layout. */
349 typedef struct _HV_SYNIC_EVENT_FLAGS_PAGE
351 volatile HV_SYNIC_EVENT_FLAGS SintEventFlags
[HV_SYNIC_SINT_COUNT
];
352 } HV_SYNIC_EVENT_FLAGS_PAGE
, *PHV_SYNIC_EVENT_FLAGS_PAGE
;
356 /* Define SynIC control register. */
358 typedef union _HV_SYNIC_SCONTROL
366 } HV_SYNIC_SCONTROL
, *PHV_SYNIC_SCONTROL
;
369 /* Define synthetic interrupt source. */
372 typedef union _HV_SYNIC_SINT
383 } HV_SYNIC_SINT
, *PHV_SYNIC_SINT
;
386 /* Define the format of the SIMP register */
389 typedef union _HV_SYNIC_SIMP
396 u64 BaseSimpGpa
: 52;
398 } HV_SYNIC_SIMP
, *PHV_SYNIC_SIMP
;
401 /* Define the format of the SIEFP register */
404 typedef union _HV_SYNIC_SIEFP
409 u64 SiefpEnabled
: 1;
411 u64 BaseSiefpGpa
: 52;
413 } HV_SYNIC_SIEFP
, *PHV_SYNIC_SIEFP
;
416 /* Definitions for the monitored notification facility */
419 typedef union _HV_MONITOR_TRIGGER_GROUP
429 } HV_MONITOR_TRIGGER_GROUP
, *PHV_MONITOR_TRIGGER_GROUP
;
431 typedef struct _HV_MONITOR_PARAMETER
433 HV_CONNECTION_ID ConnectionId
;
436 } HV_MONITOR_PARAMETER
, *PHV_MONITOR_PARAMETER
;
438 typedef union _HV_MONITOR_TRIGGER_STATE
448 } HV_MONITOR_TRIGGER_STATE
, *PHV_MONITOR_TRIGGER_STATE
;
451 /* HV_MONITOR_PAGE Layout */
452 /* ------------------------------------------------------ */
453 /* | 0 | TriggerState (4 bytes) | Rsvd1 (4 bytes) | */
454 /* | 8 | TriggerGroup[0] | */
455 /* | 10 | TriggerGroup[1] | */
456 /* | 18 | TriggerGroup[2] | */
457 /* | 20 | TriggerGroup[3] | */
458 /* | 28 | Rsvd2[0] | */
459 /* | 30 | Rsvd2[1] | */
460 /* | 38 | Rsvd2[2] | */
461 /* | 40 | NextCheckTime[0][0] | NextCheckTime[0][1] | */
463 /* | 240 | Latency[0][0..3] | */
464 /* | 340 | Rsvz3[0] | */
465 /* | 440 | Parameter[0][0] | */
466 /* | 448 | Parameter[0][1] | */
468 /* | 840 | Rsvd4[0] | */
469 /* ------------------------------------------------------ */
471 typedef struct _HV_MONITOR_PAGE
473 HV_MONITOR_TRIGGER_STATE TriggerState
;
476 HV_MONITOR_TRIGGER_GROUP TriggerGroup
[4];
479 s32 NextCheckTime
[4][32];
484 HV_MONITOR_PARAMETER Parameter
[4][32];
488 } HV_MONITOR_PAGE
, *PHV_MONITOR_PAGE
;
490 typedef volatile HV_MONITOR_PAGE
* PVHV_MONITOR_PAGE
;