1 /*****************************************************************************
2  *
3  * include/xen/viridian.h
4  *
5  * Copyright (c) 2008 Citrix Corp.
6  *
7  */
8 
9 #ifndef __ASM_X86_HVM_VIRIDIAN_H__
10 #define __ASM_X86_HVM_VIRIDIAN_H__
11 
12 #include <asm/guest/hyperv-tlfs.h>
13 
14 struct viridian_page
15 {
16     union hv_vp_assist_page_msr msr;
17     void *ptr;
18 };
19 
20 struct viridian_stimer {
21     struct vcpu *v;
22     struct timer timer;
23     union hv_stimer_config config;
24     uint64_t count;
25     uint64_t expiration;
26     bool started;
27 };
28 
29 struct viridian_vcpu
30 {
31     struct viridian_page vp_assist;
32     bool apic_assist_pending;
33     bool polled;
34     unsigned int msg_pending;
35     uint64_t scontrol;
36     uint64_t siefp;
37     struct viridian_page simp;
38     union hv_synic_sint sint[16];
39     uint8_t vector_to_sintx[256];
40     struct viridian_stimer stimer[4];
41     unsigned int stimer_enabled;
42     unsigned int stimer_pending;
43     uint64_t crash_param[5];
44 };
45 
46 struct viridian_time_ref_count
47 {
48     unsigned long flags;
49 
50 #define _TRC_accessed 0
51 #define TRC_accessed (1 << _TRC_accessed)
52 #define _TRC_running 1
53 #define TRC_running (1 << _TRC_running)
54 
55     uint64_t val;
56     int64_t off;
57 };
58 
59 struct viridian_domain
60 {
61     union hv_guest_os_id guest_os_id;
62     union hv_vp_assist_page_msr hypercall_gpa;
63     struct viridian_time_ref_count time_ref_count;
64     struct viridian_page reference_tsc;
65 };
66 
67 void cpuid_viridian_leaves(const struct vcpu *v, uint32_t leaf,
68                            uint32_t subleaf, struct cpuid_leaf *res);
69 
70 int guest_wrmsr_viridian(struct vcpu *v, uint32_t idx, uint64_t val);
71 int guest_rdmsr_viridian(const struct vcpu *v, uint32_t idx, uint64_t *val);
72 
73 int
74 viridian_hypercall(struct cpu_user_regs *regs);
75 
76 void viridian_time_domain_freeze(const struct domain *d);
77 void viridian_time_domain_thaw(const struct domain *d);
78 
79 int viridian_vcpu_init(struct vcpu *v);
80 int viridian_domain_init(struct domain *d);
81 
82 void viridian_vcpu_deinit(struct vcpu *v);
83 void viridian_domain_deinit(struct domain *d);
84 
85 void viridian_apic_assist_set(const struct vcpu *v);
86 bool viridian_apic_assist_completed(const struct vcpu *v);
87 void viridian_apic_assist_clear(const struct vcpu *v);
88 
89 void viridian_synic_poll(struct vcpu *v);
90 bool viridian_synic_is_auto_eoi_sint(const struct vcpu *v,
91                                      unsigned int vector);
92 void viridian_synic_ack_sint(const struct vcpu *v, unsigned int vector);
93 
94 #endif /* __ASM_X86_HVM_VIRIDIAN_H__ */
95 
96 /*
97  * Local variables:
98  * mode: C
99  * c-file-style: "BSD"
100  * c-basic-offset: 4
101  * tab-width: 4
102  * indent-tabs-mode: nil
103  * End:
104  */
105