qemu/include/hw/hyperv/hyperv.h
<<
>>
Prefs
   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 "cpu-qom.h"
  14#include "hw/hyperv/hyperv-proto.h"
  15
  16typedef struct HvSintRoute HvSintRoute;
  17
  18/*
  19 * Callback executed in a bottom-half when the status of posting the message
  20 * becomes known, before unblocking the connection for further messages
  21 */
  22typedef void (*HvSintMsgCb)(void *data, int status);
  23
  24HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint,
  25                                   HvSintMsgCb cb, void *cb_data);
  26void hyperv_sint_route_ref(HvSintRoute *sint_route);
  27void hyperv_sint_route_unref(HvSintRoute *sint_route);
  28
  29int hyperv_sint_route_set_sint(HvSintRoute *sint_route);
  30
  31/*
  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.
  35 */
  36int hyperv_post_msg(HvSintRoute *sint_route, struct hyperv_message *msg);
  37/*
  38 * Set event flag @eventno, and signal the SINT if the flag has changed.
  39 */
  40int hyperv_set_event_flag(HvSintRoute *sint_route, unsigned eventno);
  41
  42/*
  43 * Handler for messages arriving from the guest via HV_POST_MESSAGE hypercall.
  44 * Executed in vcpu context.
  45 */
  46typedef uint16_t (*HvMsgHandler)(const struct hyperv_post_message_input *msg,
  47                                 void *data);
  48/*
  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.
  52 */
  53int hyperv_set_msg_handler(uint32_t conn_id, HvMsgHandler handler, void *data);
  54/*
  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.
  58 */
  59int hyperv_set_event_flag_handler(uint32_t conn_id, EventNotifier *notifier);
  60
  61/*
  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.
  65 */
  66uint16_t hyperv_hcall_post_message(uint64_t param, bool fast);
  67/*
  68 * Process HV_SIGNAL_EVENT hypercall: signal the EventNotifier associated with
  69 * the connection as specified in @param.
  70 */
  71uint16_t hyperv_hcall_signal_event(uint64_t param, bool fast);
  72
  73static inline uint32_t hyperv_vp_index(CPUState *cs)
  74{
  75    return cs->cpu_index;
  76}
  77
  78void hyperv_synic_add(CPUState *cs);
  79void hyperv_synic_reset(CPUState *cs);
  80void hyperv_synic_update(CPUState *cs, bool enable,
  81                         hwaddr msg_page_addr, hwaddr event_page_addr);
  82bool hyperv_is_synic_enabled(void);
  83
  84/*
  85 * Process HVCALL_RESET_DEBUG_SESSION hypercall.
  86 */
  87uint16_t hyperv_hcall_reset_dbg_session(uint64_t outgpa);
  88/*
  89 * Process HVCALL_RETREIVE_DEBUG_DATA hypercall.
  90 */
  91uint16_t hyperv_hcall_retreive_dbg_data(uint64_t ingpa, uint64_t outgpa,
  92                                        bool fast);
  93/*
  94 * Process HVCALL_POST_DEBUG_DATA hypercall.
  95 */
  96uint16_t hyperv_hcall_post_dbg_data(uint64_t ingpa, uint64_t outgpa, bool fast);
  97
  98uint32_t hyperv_syndbg_send(uint64_t ingpa, uint32_t count);
  99uint32_t hyperv_syndbg_recv(uint64_t ingpa, uint32_t count);
 100void hyperv_syndbg_set_pending_page(uint64_t ingpa);
 101uint64_t hyperv_syndbg_query_options(void);
 102
 103typedef 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;
 110
 111typedef 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;
 140typedef uint16_t (*HvSynDbgHandler)(void *context, HvSynDbgMsg *msg);
 141void hyperv_set_syndbg_handler(HvSynDbgHandler handler, void *context);
 142#endif
 143