This source file includes following definitions.
- generate_guest_id
- vmbus_signal_eom
- hv_cpu_number_to_vp_number
- cpumask_to_vpset
- hv_is_hyperv_initialized
- hyperv_cleanup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #ifndef _ASM_GENERIC_MSHYPERV_H
19 #define _ASM_GENERIC_MSHYPERV_H
20
21 #include <linux/types.h>
22 #include <linux/atomic.h>
23 #include <linux/bitops.h>
24 #include <linux/cpumask.h>
25 #include <asm/ptrace.h>
26 #include <asm/hyperv-tlfs.h>
27
28 struct ms_hyperv_info {
29 u32 features;
30 u32 misc_features;
31 u32 hints;
32 u32 nested_features;
33 u32 max_vp_index;
34 u32 max_lp_index;
35 };
36 extern struct ms_hyperv_info ms_hyperv;
37
38 extern u64 hv_do_hypercall(u64 control, void *inputaddr, void *outputaddr);
39 extern u64 hv_do_fast_hypercall8(u16 control, u64 input8);
40
41
42
43 static inline __u64 generate_guest_id(__u64 d_info1, __u64 kernel_version,
44 __u64 d_info2)
45 {
46 __u64 guest_id = 0;
47
48 guest_id = (((__u64)HV_LINUX_VENDOR_ID) << 48);
49 guest_id |= (d_info1 << 48);
50 guest_id |= (kernel_version << 16);
51 guest_id |= d_info2;
52
53 return guest_id;
54 }
55
56
57
58 static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type)
59 {
60
61
62
63
64
65
66
67
68
69
70 if (cmpxchg(&msg->header.message_type, old_msg_type,
71 HVMSG_NONE) != old_msg_type)
72 return;
73
74
75
76
77
78
79
80
81
82 if (msg->header.message_flags.msg_pending) {
83
84
85
86
87
88 hv_signal_eom();
89 }
90 }
91
92 void hv_setup_vmbus_irq(void (*handler)(void));
93 void hv_remove_vmbus_irq(void);
94 void hv_enable_vmbus_irq(void);
95 void hv_disable_vmbus_irq(void);
96
97 void hv_setup_kexec_handler(void (*handler)(void));
98 void hv_remove_kexec_handler(void);
99 void hv_setup_crash_handler(void (*handler)(struct pt_regs *regs));
100 void hv_remove_crash_handler(void);
101
102 #if IS_ENABLED(CONFIG_HYPERV)
103
104
105
106
107
108
109 extern u32 *hv_vp_index;
110 extern u32 hv_max_vp_index;
111
112
113 #define VP_INVAL U32_MAX
114
115
116
117
118
119
120
121
122
123
124
125
126 static inline int hv_cpu_number_to_vp_number(int cpu_number)
127 {
128 return hv_vp_index[cpu_number];
129 }
130
131 static inline int cpumask_to_vpset(struct hv_vpset *vpset,
132 const struct cpumask *cpus)
133 {
134 int cpu, vcpu, vcpu_bank, vcpu_offset, nr_bank = 1;
135
136
137 if (hv_max_vp_index / 64 >= 64)
138 return 0;
139
140
141
142
143
144
145 for (vcpu_bank = 0; vcpu_bank <= hv_max_vp_index / 64; vcpu_bank++)
146 vpset->bank_contents[vcpu_bank] = 0;
147
148
149
150
151 for_each_cpu(cpu, cpus) {
152 vcpu = hv_cpu_number_to_vp_number(cpu);
153 if (vcpu == VP_INVAL)
154 return -1;
155 vcpu_bank = vcpu / 64;
156 vcpu_offset = vcpu % 64;
157 __set_bit(vcpu_offset, (unsigned long *)
158 &vpset->bank_contents[vcpu_bank]);
159 if (vcpu_bank >= nr_bank)
160 nr_bank = vcpu_bank + 1;
161 }
162 vpset->valid_bank_mask = GENMASK_ULL(nr_bank - 1, 0);
163 return nr_bank;
164 }
165
166 void hyperv_report_panic(struct pt_regs *regs, long err, bool in_die);
167 void hyperv_report_panic_msg(phys_addr_t pa, size_t size);
168 bool hv_is_hyperv_initialized(void);
169 void hyperv_cleanup(void);
170 void hv_setup_sched_clock(void *sched_clock);
171 #else
172 static inline bool hv_is_hyperv_initialized(void) { return false; }
173 static inline void hyperv_cleanup(void) {}
174 #endif
175
176 #if IS_ENABLED(CONFIG_HYPERV)
177 extern int hv_setup_stimer0_irq(int *irq, int *vector, void (*handler)(void));
178 extern void hv_remove_stimer0_irq(int irq);
179 #endif
180
181 #endif