Coverage Report

Created: 2026-10-31 08:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qemu/include/hw/hyperv/hyperv.h
Line
Count
Source
1
/*
2
 * Hyper-V guest/hypervisor interaction
3
 *
4
 * Copyright (c) 2015-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_H
11
#define HW_HYPERV_HYPERV_H
12
13
#include "exec/hwaddr.h"
14
#include "hw/core/cpu.h"
15
#include "hw/hyperv/hyperv-proto.h"
16
17
typedef struct HvSintRoute HvSintRoute;
18
19
/*
20
 * Callback executed in a bottom-half when the status of posting the message
21
 * becomes known, before unblocking the connection for further messages
22
 */
23
typedef void (*HvSintMsgCb)(void *data, int status);
24
25
HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint,
26
                                   HvSintMsgCb cb, void *cb_data);
27
void hyperv_sint_route_ref(HvSintRoute *sint_route);
28
void hyperv_sint_route_unref(HvSintRoute *sint_route);
29
30
int hyperv_sint_route_set_sint(HvSintRoute *sint_route);
31
32
/*
33
 * Submit a message to be posted in vcpu context.  If the submission succeeds,
34
 * the status of posting the message is reported via the callback associated
35
 * with the @sint_route; until then no more messages are accepted.
36
 */
37
int hyperv_post_msg(HvSintRoute *sint_route, struct hyperv_message *msg);
38
/*
39
 * Set event flag @eventno, and signal the SINT if the flag has changed.
40
 */
41
int hyperv_set_event_flag(HvSintRoute *sint_route, unsigned eventno);
42
43
/*
44
 * Handler for messages arriving from the guest via HV_POST_MESSAGE hypercall.
45
 * Executed in vcpu context.
46
 */
47
typedef uint16_t (*HvMsgHandler)(const struct hyperv_post_message_input *msg,
48
                                 void *data);
49
/*
50
 * Associate @handler with the message connection @conn_id, such that @handler
51
 * is called with @data when the guest executes HV_POST_MESSAGE hypercall on
52
 * @conn_id.  If @handler is NULL clear the association.
53
 */
54
int hyperv_set_msg_handler(uint32_t conn_id, HvMsgHandler handler, void *data);
55
/*
56
 * Associate @notifier with the event connection @conn_id, such that @notifier
57
 * is signaled when the guest executes HV_SIGNAL_EVENT hypercall on @conn_id.
58
 * If @notifier is NULL clear the association.
59
 */
60
int hyperv_set_event_flag_handler(uint32_t conn_id, EventNotifier *notifier);
61
62
/*
63
 * Process HV_POST_MESSAGE hypercall: parse the data in the guest memory as
64
 * specified in @param, and call the HvMsgHandler associated with the
65
 * connection on the message contained therein.
66
 */
67
uint16_t hyperv_hcall_post_message(uint64_t param, bool fast);
68
/*
69
 * Process HV_SIGNAL_EVENT hypercall: signal the EventNotifier associated with
70
 * the connection as specified in @param.
71
 */
72
uint16_t hyperv_hcall_signal_event(uint64_t param, bool fast);
73
74
static inline uint32_t hyperv_vp_index(CPUState *cs)
75
0
{
76
0
    return cs->cpu_index;
77
0
}
Unexecuted instantiation: hyperv.c:hyperv_vp_index
Unexecuted instantiation: hyperv_testdev.c:hyperv_vp_index
Unexecuted instantiation: vmbus.c:hyperv_vp_index
Unexecuted instantiation: syndbg.c:hyperv_vp_index
Unexecuted instantiation: machine.c:hyperv_vp_index
Unexecuted instantiation: kvm.c:hyperv_vp_index
78
79
void hyperv_synic_add(CPUState *cs);
80
void hyperv_synic_reset(CPUState *cs);
81
void hyperv_synic_update(CPUState *cs, bool enable,
82
                         hwaddr msg_page_addr, hwaddr event_page_addr);
83
bool hyperv_is_synic_enabled(void);
84
bool hyperv_is_synic_present(CPUState *cs);
85
86
/*
87
 * Process HVCALL_RESET_DEBUG_SESSION hypercall.
88
 */
89
uint16_t hyperv_hcall_reset_dbg_session(uint64_t outgpa);
90
/*
91
 * Process HVCALL_RETREIVE_DEBUG_DATA hypercall.
92
 */
93
uint16_t hyperv_hcall_retreive_dbg_data(uint64_t ingpa, uint64_t outgpa,
94
                                        bool fast);
95
/*
96
 * Process HVCALL_POST_DEBUG_DATA hypercall.
97
 */
98
uint16_t hyperv_hcall_post_dbg_data(uint64_t ingpa, uint64_t outgpa, bool fast);
99
100
uint32_t hyperv_syndbg_send(uint64_t ingpa, uint32_t count);
101
uint32_t hyperv_syndbg_recv(uint64_t ingpa, uint32_t count);
102
void hyperv_syndbg_set_pending_page(uint64_t ingpa);
103
uint64_t hyperv_syndbg_query_options(void);
104
105
typedef enum HvSynthDbgMsgType {
106
    HV_SYNDBG_MSG_CONNECTION_INFO,
107
    HV_SYNDBG_MSG_SEND,
108
    HV_SYNDBG_MSG_RECV,
109
    HV_SYNDBG_MSG_SET_PENDING_PAGE,
110
    HV_SYNDBG_MSG_QUERY_OPTIONS
111
} HvDbgSynthMsgType;
112
113
typedef struct HvSynDbgMsg {
114
    HvDbgSynthMsgType type;
115
    union {
116
        struct {
117
            uint32_t host_ip;
118
            uint16_t host_port;
119
        } connection_info;
120
        struct {
121
            uint64_t buf_gpa;
122
            uint32_t count;
123
            uint32_t pending_count;
124
            bool is_raw;
125
        } send;
126
        struct {
127
            uint64_t buf_gpa;
128
            uint32_t count;
129
            uint32_t options;
130
            uint64_t timeout;
131
            uint32_t retrieved_count;
132
            bool is_raw;
133
        } recv;
134
        struct {
135
            uint64_t buf_gpa;
136
        } pending_page;
137
        struct {
138
            uint64_t options;
139
        } query_options;
140
    } u;
141
} HvSynDbgMsg;
142
typedef uint16_t (*HvSynDbgHandler)(void *context, HvSynDbgMsg *msg);
143
void hyperv_set_syndbg_handler(HvSynDbgHandler handler, void *context);
144
145
bool hyperv_are_vmbus_recommended_features_enabled(void);
146
void hyperv_set_vmbus_recommended_features_enabled(void);
147
148
#endif