Merge tag 'pull-loongarch-20241016' of https://gitlab.com/gaosong/qemu into staging
[qemu/armbru.git] / include / hw / hyperv / hyperv.h
blobd717b4e13d40d3ee6f7351038538545c202f9210
1 /*
2 * Hyper-V guest/hypervisor interaction
4 * Copyright (c) 2015-2018 Virtuozzo International GmbH.
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 */
10 #ifndef HW_HYPERV_HYPERV_H
11 #define HW_HYPERV_HYPERV_H
13 #include "cpu-qom.h"
14 #include "hw/hyperv/hyperv-proto.h"
16 typedef struct HvSintRoute HvSintRoute;
19 * Callback executed in a bottom-half when the status of posting the message
20 * becomes known, before unblocking the connection for further messages
22 typedef void (*HvSintMsgCb)(void *data, int status);
24 HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint,
25 HvSintMsgCb cb, void *cb_data);
26 void hyperv_sint_route_ref(HvSintRoute *sint_route);
27 void hyperv_sint_route_unref(HvSintRoute *sint_route);
29 int hyperv_sint_route_set_sint(HvSintRoute *sint_route);
32 * Submit a message to be posted in vcpu context. If the submission succeeds,
33 * the status of posting the message is reported via the callback associated
34 * with the @sint_route; until then no more messages are accepted.
36 int hyperv_post_msg(HvSintRoute *sint_route, struct hyperv_message *msg);
38 * Set event flag @eventno, and signal the SINT if the flag has changed.
40 int hyperv_set_event_flag(HvSintRoute *sint_route, unsigned eventno);
43 * Handler for messages arriving from the guest via HV_POST_MESSAGE hypercall.
44 * Executed in vcpu context.
46 typedef uint16_t (*HvMsgHandler)(const struct hyperv_post_message_input *msg,
47 void *data);
49 * Associate @handler with the message connection @conn_id, such that @handler
50 * is called with @data when the guest executes HV_POST_MESSAGE hypercall on
51 * @conn_id. If @handler is NULL clear the association.
53 int hyperv_set_msg_handler(uint32_t conn_id, HvMsgHandler handler, void *data);
55 * Associate @notifier with the event connection @conn_id, such that @notifier
56 * is signaled when the guest executes HV_SIGNAL_EVENT hypercall on @conn_id.
57 * If @notifier is NULL clear the association.
59 int hyperv_set_event_flag_handler(uint32_t conn_id, EventNotifier *notifier);
62 * Process HV_POST_MESSAGE hypercall: parse the data in the guest memory as
63 * specified in @param, and call the HvMsgHandler associated with the
64 * connection on the message contained therein.
66 uint16_t hyperv_hcall_post_message(uint64_t param, bool fast);
68 * Process HV_SIGNAL_EVENT hypercall: signal the EventNotifier associated with
69 * the connection as specified in @param.
71 uint16_t hyperv_hcall_signal_event(uint64_t param, bool fast);
73 static inline uint32_t hyperv_vp_index(CPUState *cs)
75 return cs->cpu_index;
78 void hyperv_synic_add(CPUState *cs);
79 void hyperv_synic_reset(CPUState *cs);
80 void hyperv_synic_update(CPUState *cs, bool enable,
81 hwaddr msg_page_addr, hwaddr event_page_addr);
82 bool hyperv_is_synic_enabled(void);
85 * Process HVCALL_RESET_DEBUG_SESSION hypercall.
87 uint16_t hyperv_hcall_reset_dbg_session(uint64_t outgpa);
89 * Process HVCALL_RETREIVE_DEBUG_DATA hypercall.
91 uint16_t hyperv_hcall_retreive_dbg_data(uint64_t ingpa, uint64_t outgpa,
92 bool fast);
94 * Process HVCALL_POST_DEBUG_DATA hypercall.
96 uint16_t hyperv_hcall_post_dbg_data(uint64_t ingpa, uint64_t outgpa, bool fast);
98 uint32_t hyperv_syndbg_send(uint64_t ingpa, uint32_t count);
99 uint32_t hyperv_syndbg_recv(uint64_t ingpa, uint32_t count);
100 void hyperv_syndbg_set_pending_page(uint64_t ingpa);
101 uint64_t hyperv_syndbg_query_options(void);
103 typedef enum HvSynthDbgMsgType {
104 HV_SYNDBG_MSG_CONNECTION_INFO,
105 HV_SYNDBG_MSG_SEND,
106 HV_SYNDBG_MSG_RECV,
107 HV_SYNDBG_MSG_SET_PENDING_PAGE,
108 HV_SYNDBG_MSG_QUERY_OPTIONS
109 } HvDbgSynthMsgType;
111 typedef struct HvSynDbgMsg {
112 HvDbgSynthMsgType type;
113 union {
114 struct {
115 uint32_t host_ip;
116 uint16_t host_port;
117 } connection_info;
118 struct {
119 uint64_t buf_gpa;
120 uint32_t count;
121 uint32_t pending_count;
122 bool is_raw;
123 } send;
124 struct {
125 uint64_t buf_gpa;
126 uint32_t count;
127 uint32_t options;
128 uint64_t timeout;
129 uint32_t retrieved_count;
130 bool is_raw;
131 } recv;
132 struct {
133 uint64_t buf_gpa;
134 } pending_page;
135 struct {
136 uint64_t options;
137 } query_options;
138 } u;
139 } HvSynDbgMsg;
140 typedef uint16_t (*HvSynDbgHandler)(void *context, HvSynDbgMsg *msg);
141 void hyperv_set_syndbg_handler(HvSynDbgHandler handler, void *context);
143 bool hyperv_are_vmbus_recommended_features_enabled(void);
144 void hyperv_set_vmbus_recommended_features_enabled(void);
146 #endif