xref: /openbmc/qemu/include/hw/hyperv/hyperv-proto.h (revision 10df8ff1)
1 /*
2  * Definitions for Hyper-V guest/hypervisor interaction
3  *
4  * Copyright (c) 2017-2018 Virtuozzo International GmbH.
5  *
6  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7  * See the COPYING file in the top-level directory.
8  */
9 
10 #ifndef HW_HYPERV_HYPERV_PROTO_H
11 #define HW_HYPERV_HYPERV_PROTO_H
12 
13 #include "qemu/bitmap.h"
14 
15 /*
16  * Hypercall status code
17  */
18 #define HV_STATUS_SUCCESS                     0
19 #define HV_STATUS_INVALID_HYPERCALL_CODE      2
20 #define HV_STATUS_INVALID_HYPERCALL_INPUT     3
21 #define HV_STATUS_INVALID_ALIGNMENT           4
22 #define HV_STATUS_INVALID_PARAMETER           5
23 #define HV_STATUS_INSUFFICIENT_MEMORY         11
24 #define HV_STATUS_INVALID_PORT_ID             17
25 #define HV_STATUS_INVALID_CONNECTION_ID       18
26 #define HV_STATUS_INSUFFICIENT_BUFFERS        19
27 
28 /*
29  * Hypercall numbers
30  */
31 #define HV_POST_MESSAGE                       0x005c
32 #define HV_SIGNAL_EVENT                       0x005d
33 #define HV_HYPERCALL_FAST                     (1u << 16)
34 
35 /*
36  * Message size
37  */
38 #define HV_MESSAGE_PAYLOAD_SIZE               240
39 
40 /*
41  * Message types
42  */
43 #define HV_MESSAGE_NONE                       0x00000000
44 #define HV_MESSAGE_VMBUS                      0x00000001
45 #define HV_MESSAGE_UNMAPPED_GPA               0x80000000
46 #define HV_MESSAGE_GPA_INTERCEPT              0x80000001
47 #define HV_MESSAGE_TIMER_EXPIRED              0x80000010
48 #define HV_MESSAGE_INVALID_VP_REGISTER_VALUE  0x80000020
49 #define HV_MESSAGE_UNRECOVERABLE_EXCEPTION    0x80000021
50 #define HV_MESSAGE_UNSUPPORTED_FEATURE        0x80000022
51 #define HV_MESSAGE_EVENTLOG_BUFFERCOMPLETE    0x80000040
52 #define HV_MESSAGE_X64_IOPORT_INTERCEPT       0x80010000
53 #define HV_MESSAGE_X64_MSR_INTERCEPT          0x80010001
54 #define HV_MESSAGE_X64_CPUID_INTERCEPT        0x80010002
55 #define HV_MESSAGE_X64_EXCEPTION_INTERCEPT    0x80010003
56 #define HV_MESSAGE_X64_APIC_EOI               0x80010004
57 #define HV_MESSAGE_X64_LEGACY_FP_ERROR        0x80010005
58 
59 /*
60  * Message flags
61  */
62 #define HV_MESSAGE_FLAG_PENDING               0x1
63 
64 /*
65  * Number of synthetic interrupts
66  */
67 #define HV_SINT_COUNT                         16
68 
69 /*
70  * Event flags number per SINT
71  */
72 #define HV_EVENT_FLAGS_COUNT                  (256 * 8)
73 
74 /*
75  * Connection id valid bits
76  */
77 #define HV_CONNECTION_ID_MASK                 0x00ffffff
78 
79 /*
80  * Input structure for POST_MESSAGE hypercall
81  */
82 struct hyperv_post_message_input {
83     uint32_t connection_id;
84     uint32_t _reserved;
85     uint32_t message_type;
86     uint32_t payload_size;
87     uint8_t  payload[HV_MESSAGE_PAYLOAD_SIZE];
88 };
89 
90 /*
91  * Input structure for SIGNAL_EVENT hypercall
92  */
93 struct hyperv_signal_event_input {
94     uint32_t connection_id;
95     uint16_t flag_number;
96     uint16_t _reserved_zero;
97 };
98 
99 /*
100  * SynIC message structures
101  */
102 struct hyperv_message_header {
103     uint32_t message_type;
104     uint8_t  payload_size;
105     uint8_t  message_flags; /* HV_MESSAGE_FLAG_XX */
106     uint8_t  _reserved[2];
107     uint64_t sender;
108 };
109 
110 struct hyperv_message {
111     struct hyperv_message_header header;
112     uint8_t payload[HV_MESSAGE_PAYLOAD_SIZE];
113 };
114 
115 struct hyperv_message_page {
116     struct hyperv_message slot[HV_SINT_COUNT];
117 };
118 
119 /*
120  * SynIC event flags structures
121  */
122 struct hyperv_event_flags {
123     DECLARE_BITMAP(flags, HV_EVENT_FLAGS_COUNT);
124 };
125 
126 struct hyperv_event_flags_page {
127     struct hyperv_event_flags slot[HV_SINT_COUNT];
128 };
129 
130 #endif
131