xref: /openbmc/linux/arch/x86/include/asm/mshyperv.h (revision b9b4fe3a72b60c8d74a9ffb61aa778f04eaddd87)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2e08cae41SH. Peter Anvin #ifndef _ASM_X86_MSHYPER_H
3e08cae41SH. Peter Anvin #define _ASM_X86_MSHYPER_H
4a2a47c6cSKy Srinivasan 
5e08cae41SH. Peter Anvin #include <linux/types.h>
6806c8927SVitaly Kuznetsov #include <linux/nmi.h>
71cf106d9SBoqun Feng #include <linux/msi.h>
8fc53662fSVitaly Kuznetsov #include <asm/io.h>
95a485803SVitaly Kuznetsov #include <asm/hyperv-tlfs.h>
10e70e5892SDavid Woodhouse #include <asm/nospec-branch.h>
11b9d8cf2eSMichael Kelley #include <asm/paravirt.h>
12753ed9c9SJoseph Salisbury #include <asm/mshyperv.h>
13e08cae41SH. Peter Anvin 
14812b0597SMichael Kelley /*
15812b0597SMichael Kelley  * Hyper-V always provides a single IO-APIC at this MMIO address.
16812b0597SMichael Kelley  * Ideally, the value should be looked up in ACPI tables, but it
17812b0597SMichael Kelley  * is needed for mapping the IO-APIC early in boot on Confidential
18812b0597SMichael Kelley  * VMs, before ACPI functions can be used.
19812b0597SMichael Kelley  */
20812b0597SMichael Kelley #define HV_IOAPIC_BASE_ADDRESS 0xfec00000
21812b0597SMichael Kelley 
223be1bc2fSSaurabh Sengar #define HV_VTL_NORMAL 0x0
233be1bc2fSSaurabh Sengar #define HV_VTL_SECURE 0x1
243be1bc2fSSaurabh Sengar #define HV_VTL_MGMT   0x2
253be1bc2fSSaurabh Sengar 
26faff4406STianyu Lan union hv_ghcb;
27faff4406STianyu Lan 
280cc4f6d9STianyu Lan DECLARE_STATIC_KEY_FALSE(isolation_type_snp);
29d6e2d652STianyu Lan DECLARE_STATIC_KEY_FALSE(isolation_type_en_snp);
3008e9d120SDexuan Cui DECLARE_STATIC_KEY_FALSE(isolation_type_tdx);
310cc4f6d9STianyu Lan 
32cc4edae4SLan Tianyu typedef int (*hyperv_fill_flush_list_func)(
33cc4edae4SLan Tianyu 		struct hv_guest_mapping_flush_list *flush,
34cc4edae4SLan Tianyu 		void *data);
35cc4edae4SLan Tianyu 
36bc2b0331SK. Y. Srinivasan void hyperv_vector_handler(struct pt_regs *regs);
378730046cSK. Y. Srinivasan 
380a7a0058SSaurabh Sengar static inline unsigned char hv_get_nmi_reason(void)
390a7a0058SSaurabh Sengar {
400a7a0058SSaurabh Sengar 	return 0;
410a7a0058SSaurabh Sengar }
420a7a0058SSaurabh Sengar 
438730046cSK. Y. Srinivasan #if IS_ENABLED(CONFIG_HYPERV)
44dfe94d40SDexuan Cui extern int hyperv_init_cpuhp;
45d3a9d7e4SDexuan Cui extern bool hyperv_paravisor_present;
46dfe94d40SDexuan Cui 
47fc53662fSVitaly Kuznetsov extern void *hv_hypercall_pg;
48fc53662fSVitaly Kuznetsov 
4999a0f46aSWei Liu extern u64 hv_current_partition_id;
5099a0f46aSWei Liu 
51e1878402SMichael Kelley extern union hv_ghcb * __percpu *hv_ghcb_pg;
520cc4f6d9STianyu Lan 
5348b1f683STianyu Lan extern bool hv_isolation_type_en_snp(void);
5408e9d120SDexuan Cui bool hv_isolation_type_tdx(void);
55d6e0228dSDexuan Cui u64 hv_tdx_hypercall(u64 control, u64 param1, u64 param2);
5608e9d120SDexuan Cui 
5744676bb9STianyu Lan /*
5844676bb9STianyu Lan  * DEFAULT INIT GPAT and SEGMENT LIMIT value in struct VMSA
5944676bb9STianyu Lan  * to start AP in enlightened SEV guest.
6044676bb9STianyu Lan  */
6144676bb9STianyu Lan #define HV_AP_INIT_GPAT_DEFAULT		0x0007040600070406ULL
6244676bb9STianyu Lan #define HV_AP_SEGMENT_LIMIT		0xffffffff
6348b1f683STianyu Lan 
6486b5ec35SWei Liu int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages);
6586b5ec35SWei Liu int hv_call_add_logical_proc(int node, u32 lp_index, u32 acpi_id);
6686b5ec35SWei Liu int hv_call_create_vp(int node, u64 partition_id, u32 vp_index, u32 flags);
6786b5ec35SWei Liu 
68d6e0228dSDexuan Cui /*
69d6e0228dSDexuan Cui  * If the hypercall involves no input or output parameters, the hypervisor
70d6e0228dSDexuan Cui  * ignores the corresponding GPA pointer.
71d6e0228dSDexuan Cui  */
72fc53662fSVitaly Kuznetsov static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
73fc53662fSVitaly Kuznetsov {
74fc53662fSVitaly Kuznetsov 	u64 input_address = input ? virt_to_phys(input) : 0;
75fc53662fSVitaly Kuznetsov 	u64 output_address = output ? virt_to_phys(output) : 0;
76fc53662fSVitaly Kuznetsov 	u64 hv_status;
77fc53662fSVitaly Kuznetsov 
78fc53662fSVitaly Kuznetsov #ifdef CONFIG_X86_64
79d3a9d7e4SDexuan Cui 	if (hv_isolation_type_tdx() && !hyperv_paravisor_present)
80d6e0228dSDexuan Cui 		return hv_tdx_hypercall(control, input_address, output_address);
81d6e0228dSDexuan Cui 
8248b1f683STianyu Lan 	if (hv_isolation_type_en_snp()) {
8348b1f683STianyu Lan 		__asm__ __volatile__("mov %4, %%r8\n"
8448b1f683STianyu Lan 				     "vmmcall"
8548b1f683STianyu Lan 				     : "=a" (hv_status), ASM_CALL_CONSTRAINT,
8648b1f683STianyu Lan 				       "+c" (control), "+d" (input_address)
8748b1f683STianyu Lan 				     :  "r" (output_address)
8848b1f683STianyu Lan 				     : "cc", "memory", "r8", "r9", "r10", "r11");
8948b1f683STianyu Lan 		return hv_status;
9048b1f683STianyu Lan 	}
9148b1f683STianyu Lan 
92fc53662fSVitaly Kuznetsov 	if (!hv_hypercall_pg)
93fc53662fSVitaly Kuznetsov 		return U64_MAX;
94fc53662fSVitaly Kuznetsov 
95fc53662fSVitaly Kuznetsov 	__asm__ __volatile__("mov %4, %%r8\n"
96e70e5892SDavid Woodhouse 			     CALL_NOSPEC
97f5caf621SJosh Poimboeuf 			     : "=a" (hv_status), ASM_CALL_CONSTRAINT,
98fc53662fSVitaly Kuznetsov 			       "+c" (control), "+d" (input_address)
99e70e5892SDavid Woodhouse 			     :  "r" (output_address),
100e70e5892SDavid Woodhouse 				THUNK_TARGET(hv_hypercall_pg)
101fc53662fSVitaly Kuznetsov 			     : "cc", "memory", "r8", "r9", "r10", "r11");
102fc53662fSVitaly Kuznetsov #else
103fc53662fSVitaly Kuznetsov 	u32 input_address_hi = upper_32_bits(input_address);
104fc53662fSVitaly Kuznetsov 	u32 input_address_lo = lower_32_bits(input_address);
105fc53662fSVitaly Kuznetsov 	u32 output_address_hi = upper_32_bits(output_address);
106fc53662fSVitaly Kuznetsov 	u32 output_address_lo = lower_32_bits(output_address);
107fc53662fSVitaly Kuznetsov 
108fc53662fSVitaly Kuznetsov 	if (!hv_hypercall_pg)
109fc53662fSVitaly Kuznetsov 		return U64_MAX;
110fc53662fSVitaly Kuznetsov 
111e70e5892SDavid Woodhouse 	__asm__ __volatile__(CALL_NOSPEC
112fc53662fSVitaly Kuznetsov 			     : "=A" (hv_status),
113f5caf621SJosh Poimboeuf 			       "+c" (input_address_lo), ASM_CALL_CONSTRAINT
114fc53662fSVitaly Kuznetsov 			     : "A" (control),
115fc53662fSVitaly Kuznetsov 			       "b" (input_address_hi),
116fc53662fSVitaly Kuznetsov 			       "D"(output_address_hi), "S"(output_address_lo),
117e70e5892SDavid Woodhouse 			       THUNK_TARGET(hv_hypercall_pg)
118fc53662fSVitaly Kuznetsov 			     : "cc", "memory");
119fc53662fSVitaly Kuznetsov #endif /* !x86_64 */
120fc53662fSVitaly Kuznetsov 	return hv_status;
121fc53662fSVitaly Kuznetsov }
122dee863b5SVitaly Kuznetsov 
123f0d2f5c2SJinank Jain /* Hypercall to the L0 hypervisor */
124f0d2f5c2SJinank Jain static inline u64 hv_do_nested_hypercall(u64 control, void *input, void *output)
1256a8edbd0SVitaly Kuznetsov {
126f0d2f5c2SJinank Jain 	return hv_do_hypercall(control | HV_HYPERCALL_NESTED, input, output);
127f0d2f5c2SJinank Jain }
128f0d2f5c2SJinank Jain 
129f0d2f5c2SJinank Jain /* Fast hypercall with 8 bytes of input and no output */
130f0d2f5c2SJinank Jain static inline u64 _hv_do_fast_hypercall8(u64 control, u64 input1)
131f0d2f5c2SJinank Jain {
132f0d2f5c2SJinank Jain 	u64 hv_status;
1336a8edbd0SVitaly Kuznetsov 
1346a8edbd0SVitaly Kuznetsov #ifdef CONFIG_X86_64
135d3a9d7e4SDexuan Cui 	if (hv_isolation_type_tdx() && !hyperv_paravisor_present)
136d6e0228dSDexuan Cui 		return hv_tdx_hypercall(control, input1, 0);
137d6e0228dSDexuan Cui 
13848b1f683STianyu Lan 	if (hv_isolation_type_en_snp()) {
13948b1f683STianyu Lan 		__asm__ __volatile__(
14048b1f683STianyu Lan 				"vmmcall"
14148b1f683STianyu Lan 				: "=a" (hv_status), ASM_CALL_CONSTRAINT,
14248b1f683STianyu Lan 				"+c" (control), "+d" (input1)
14348b1f683STianyu Lan 				:: "cc", "r8", "r9", "r10", "r11");
14448b1f683STianyu Lan 	} else {
145e70e5892SDavid Woodhouse 		__asm__ __volatile__(CALL_NOSPEC
146f5caf621SJosh Poimboeuf 				     : "=a" (hv_status), ASM_CALL_CONSTRAINT,
1476a8edbd0SVitaly Kuznetsov 				       "+c" (control), "+d" (input1)
148e70e5892SDavid Woodhouse 				     : THUNK_TARGET(hv_hypercall_pg)
1496a8edbd0SVitaly Kuznetsov 				     : "cc", "r8", "r9", "r10", "r11");
1506a8edbd0SVitaly Kuznetsov 	}
1516a8edbd0SVitaly Kuznetsov #else
1526a8edbd0SVitaly Kuznetsov 	{
1536a8edbd0SVitaly Kuznetsov 		u32 input1_hi = upper_32_bits(input1);
1546a8edbd0SVitaly Kuznetsov 		u32 input1_lo = lower_32_bits(input1);
1556a8edbd0SVitaly Kuznetsov 
156e70e5892SDavid Woodhouse 		__asm__ __volatile__ (CALL_NOSPEC
1576a8edbd0SVitaly Kuznetsov 				      : "=A"(hv_status),
1586a8edbd0SVitaly Kuznetsov 					"+c"(input1_lo),
159f5caf621SJosh Poimboeuf 					ASM_CALL_CONSTRAINT
1606a8edbd0SVitaly Kuznetsov 				      :	"A" (control),
1616a8edbd0SVitaly Kuznetsov 					"b" (input1_hi),
162e70e5892SDavid Woodhouse 					THUNK_TARGET(hv_hypercall_pg)
1636a8edbd0SVitaly Kuznetsov 				      : "cc", "edi", "esi");
1646a8edbd0SVitaly Kuznetsov 	}
1656a8edbd0SVitaly Kuznetsov #endif
1666a8edbd0SVitaly Kuznetsov 		return hv_status;
1676a8edbd0SVitaly Kuznetsov }
1686a8edbd0SVitaly Kuznetsov 
169f0d2f5c2SJinank Jain static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1)
17053e52966SVitaly Kuznetsov {
171f0d2f5c2SJinank Jain 	u64 control = (u64)code | HV_HYPERCALL_FAST_BIT;
172f0d2f5c2SJinank Jain 
173f0d2f5c2SJinank Jain 	return _hv_do_fast_hypercall8(control, input1);
174f0d2f5c2SJinank Jain }
175f0d2f5c2SJinank Jain 
176f0d2f5c2SJinank Jain static inline u64 hv_do_fast_nested_hypercall8(u16 code, u64 input1)
177f0d2f5c2SJinank Jain {
178f0d2f5c2SJinank Jain 	u64 control = (u64)code | HV_HYPERCALL_FAST_BIT | HV_HYPERCALL_NESTED;
179f0d2f5c2SJinank Jain 
180f0d2f5c2SJinank Jain 	return _hv_do_fast_hypercall8(control, input1);
181f0d2f5c2SJinank Jain }
182f0d2f5c2SJinank Jain 
183f0d2f5c2SJinank Jain /* Fast hypercall with 16 bytes of input */
184f0d2f5c2SJinank Jain static inline u64 _hv_do_fast_hypercall16(u64 control, u64 input1, u64 input2)
185f0d2f5c2SJinank Jain {
186f0d2f5c2SJinank Jain 	u64 hv_status;
18753e52966SVitaly Kuznetsov 
18853e52966SVitaly Kuznetsov #ifdef CONFIG_X86_64
189d3a9d7e4SDexuan Cui 	if (hv_isolation_type_tdx() && !hyperv_paravisor_present)
190d6e0228dSDexuan Cui 		return hv_tdx_hypercall(control, input1, input2);
191d6e0228dSDexuan Cui 
19248b1f683STianyu Lan 	if (hv_isolation_type_en_snp()) {
19348b1f683STianyu Lan 		__asm__ __volatile__("mov %4, %%r8\n"
19448b1f683STianyu Lan 				     "vmmcall"
19548b1f683STianyu Lan 				     : "=a" (hv_status), ASM_CALL_CONSTRAINT,
19648b1f683STianyu Lan 				       "+c" (control), "+d" (input1)
19748b1f683STianyu Lan 				     : "r" (input2)
19848b1f683STianyu Lan 				     : "cc", "r8", "r9", "r10", "r11");
19948b1f683STianyu Lan 	} else {
20053e52966SVitaly Kuznetsov 		__asm__ __volatile__("mov %4, %%r8\n"
20153e52966SVitaly Kuznetsov 				     CALL_NOSPEC
20253e52966SVitaly Kuznetsov 				     : "=a" (hv_status), ASM_CALL_CONSTRAINT,
20353e52966SVitaly Kuznetsov 				       "+c" (control), "+d" (input1)
20453e52966SVitaly Kuznetsov 				     : "r" (input2),
20553e52966SVitaly Kuznetsov 				       THUNK_TARGET(hv_hypercall_pg)
20653e52966SVitaly Kuznetsov 				     : "cc", "r8", "r9", "r10", "r11");
20753e52966SVitaly Kuznetsov 	}
20853e52966SVitaly Kuznetsov #else
20953e52966SVitaly Kuznetsov 	{
21053e52966SVitaly Kuznetsov 		u32 input1_hi = upper_32_bits(input1);
21153e52966SVitaly Kuznetsov 		u32 input1_lo = lower_32_bits(input1);
21253e52966SVitaly Kuznetsov 		u32 input2_hi = upper_32_bits(input2);
21353e52966SVitaly Kuznetsov 		u32 input2_lo = lower_32_bits(input2);
21453e52966SVitaly Kuznetsov 
21553e52966SVitaly Kuznetsov 		__asm__ __volatile__ (CALL_NOSPEC
21653e52966SVitaly Kuznetsov 				      : "=A"(hv_status),
21753e52966SVitaly Kuznetsov 					"+c"(input1_lo), ASM_CALL_CONSTRAINT
21853e52966SVitaly Kuznetsov 				      :	"A" (control), "b" (input1_hi),
21953e52966SVitaly Kuznetsov 					"D"(input2_hi), "S"(input2_lo),
22053e52966SVitaly Kuznetsov 					THUNK_TARGET(hv_hypercall_pg)
22153e52966SVitaly Kuznetsov 				      : "cc");
22253e52966SVitaly Kuznetsov 	}
22353e52966SVitaly Kuznetsov #endif
22453e52966SVitaly Kuznetsov 	return hv_status;
22553e52966SVitaly Kuznetsov }
22653e52966SVitaly Kuznetsov 
227f0d2f5c2SJinank Jain static inline u64 hv_do_fast_hypercall16(u16 code, u64 input1, u64 input2)
228f0d2f5c2SJinank Jain {
229f0d2f5c2SJinank Jain 	u64 control = (u64)code | HV_HYPERCALL_FAST_BIT;
230f0d2f5c2SJinank Jain 
231f0d2f5c2SJinank Jain 	return _hv_do_fast_hypercall16(control, input1, input2);
232f0d2f5c2SJinank Jain }
233f0d2f5c2SJinank Jain 
234f0d2f5c2SJinank Jain static inline u64 hv_do_fast_nested_hypercall16(u16 code, u64 input1, u64 input2)
235f0d2f5c2SJinank Jain {
236f0d2f5c2SJinank Jain 	u64 control = (u64)code | HV_HYPERCALL_FAST_BIT | HV_HYPERCALL_NESTED;
237f0d2f5c2SJinank Jain 
238f0d2f5c2SJinank Jain 	return _hv_do_fast_hypercall16(control, input1, input2);
239f0d2f5c2SJinank Jain }
240f0d2f5c2SJinank Jain 
241a46d15ccSVitaly Kuznetsov extern struct hv_vp_assist_page **hv_vp_assist_page;
242a46d15ccSVitaly Kuznetsov 
243a46d15ccSVitaly Kuznetsov static inline struct hv_vp_assist_page *hv_get_vp_assist_page(unsigned int cpu)
244a46d15ccSVitaly Kuznetsov {
245a46d15ccSVitaly Kuznetsov 	if (!hv_vp_assist_page)
246a46d15ccSVitaly Kuznetsov 		return NULL;
247a46d15ccSVitaly Kuznetsov 
248a46d15ccSVitaly Kuznetsov 	return hv_vp_assist_page[cpu];
249a46d15ccSVitaly Kuznetsov }
2507415aea6SVitaly Kuznetsov 
2516b48cb5fSK. Y. Srinivasan void __init hyperv_init(void);
2522ffd9e33SVitaly Kuznetsov void hyperv_setup_mmu_ops(void);
25393286261SVitaly Kuznetsov void set_hv_tscchange_cb(void (*cb)(void));
25493286261SVitaly Kuznetsov void clear_hv_tscchange_cb(void);
25593286261SVitaly Kuznetsov void hyperv_stop_tsc_emulation(void);
256eb914cfeSTianyu Lan int hyperv_flush_guest_mapping(u64 as);
257cc4edae4SLan Tianyu int hyperv_flush_guest_mapping_range(u64 as,
258cc4edae4SLan Tianyu 		hyperv_fill_flush_list_func fill_func, void *data);
259cc4edae4SLan Tianyu int hyperv_fill_flush_guest_mapping_list(
260cc4edae4SLan Tianyu 		struct hv_guest_mapping_flush_list *flush,
261cc4edae4SLan Tianyu 		u64 start_gfn, u64 end_gfn);
2622d2ccf24SThomas Gleixner 
2632d2ccf24SThomas Gleixner #ifdef CONFIG_X86_64
2646b48cb5fSK. Y. Srinivasan void hv_apic_init(void);
2653a025de6SYi Sun void __init hv_init_spinlocks(void);
2663a025de6SYi Sun bool hv_vcpu_is_preempted(int vcpu);
2672d2ccf24SThomas Gleixner #else
2682d2ccf24SThomas Gleixner static inline void hv_apic_init(void) {}
2692d2ccf24SThomas Gleixner #endif
2702d2ccf24SThomas Gleixner 
271e39397d1SWei Liu struct irq_domain *hv_create_pci_msi_domain(void);
272e39397d1SWei Liu 
273fb5ef351SWei Liu int hv_map_ioapic_interrupt(int ioapic_id, bool level, int vcpu, int vector,
274fb5ef351SWei Liu 		struct hv_interrupt_entry *entry);
275fb5ef351SWei Liu int hv_unmap_ioapic_interrupt(int ioapic_id, struct hv_interrupt_entry *entry);
276faff4406STianyu Lan 
277faff4406STianyu Lan #ifdef CONFIG_AMD_MEM_ENCRYPT
27849d6a3c0STianyu Lan bool hv_ghcb_negotiate_protocol(void);
279611d4c71SGuilherme G. Piccoli void __noreturn hv_ghcb_terminate(unsigned int set, unsigned int reason);
28044676bb9STianyu Lan int hv_snp_boot_ap(int cpu, unsigned long start_ip);
281faff4406STianyu Lan #else
28249d6a3c0STianyu Lan static inline bool hv_ghcb_negotiate_protocol(void) { return false; }
28349d6a3c0STianyu Lan static inline void hv_ghcb_terminate(unsigned int set, unsigned int reason) {}
284f0a3d1deSNathan Chancellor static inline int hv_snp_boot_ap(int cpu, unsigned long start_ip) { return 0; }
285faff4406STianyu Lan #endif
286faff4406STianyu Lan 
287faff4406STianyu Lan extern bool hv_isolation_type_snp(void);
288faff4406STianyu Lan 
289d3a9d7e4SDexuan Cui #if defined(CONFIG_AMD_MEM_ENCRYPT) || defined(CONFIG_INTEL_TDX_GUEST)
290d3a9d7e4SDexuan Cui void hv_vtom_init(void);
291*b9b4fe3aSDexuan Cui void hv_ivm_msr_write(u64 msr, u64 value);
292*b9b4fe3aSDexuan Cui void hv_ivm_msr_read(u64 msr, u64 *value);
293d3a9d7e4SDexuan Cui #else
294d3a9d7e4SDexuan Cui static inline void hv_vtom_init(void) {}
295*b9b4fe3aSDexuan Cui static inline void hv_ivm_msr_write(u64 msr, u64 value) {}
296*b9b4fe3aSDexuan Cui static inline void hv_ivm_msr_read(u64 msr, u64 *value) {}
297d3a9d7e4SDexuan Cui #endif
298d3a9d7e4SDexuan Cui 
299faff4406STianyu Lan static inline bool hv_is_synic_reg(unsigned int reg)
300faff4406STianyu Lan {
301b14033a3SNuno Das Neves 	return (reg >= HV_REGISTER_SCONTROL) &&
302b14033a3SNuno Das Neves 	       (reg <= HV_REGISTER_SINT15);
303b14033a3SNuno Das Neves }
304b14033a3SNuno Das Neves 
305b14033a3SNuno Das Neves static inline bool hv_is_sint_reg(unsigned int reg)
306b14033a3SNuno Das Neves {
307b14033a3SNuno Das Neves 	return (reg >= HV_REGISTER_SINT0) &&
308b14033a3SNuno Das Neves 	       (reg <= HV_REGISTER_SINT15);
309faff4406STianyu Lan }
310faff4406STianyu Lan 
3117fec185aSJinank Jain u64 hv_get_register(unsigned int reg);
3127fec185aSJinank Jain void hv_set_register(unsigned int reg, u64 value);
3137fec185aSJinank Jain u64 hv_get_non_nested_register(unsigned int reg);
3147fec185aSJinank Jain void hv_set_non_nested_register(unsigned int reg, u64 value);
315faff4406STianyu Lan 
316e39acc37SPeter Zijlstra static __always_inline u64 hv_raw_get_register(unsigned int reg)
317e39acc37SPeter Zijlstra {
318e39acc37SPeter Zijlstra 	return __rdmsr(reg);
319e39acc37SPeter Zijlstra }
320e39acc37SPeter Zijlstra 
32179cadff2SVitaly Kuznetsov #else /* CONFIG_HYPERV */
32279cadff2SVitaly Kuznetsov static inline void hyperv_init(void) {}
3232ffd9e33SVitaly Kuznetsov static inline void hyperv_setup_mmu_ops(void) {}
32493286261SVitaly Kuznetsov static inline void set_hv_tscchange_cb(void (*cb)(void)) {}
32593286261SVitaly Kuznetsov static inline void clear_hv_tscchange_cb(void) {}
32693286261SVitaly Kuznetsov static inline void hyperv_stop_tsc_emulation(void) {};
327a46d15ccSVitaly Kuznetsov static inline struct hv_vp_assist_page *hv_get_vp_assist_page(unsigned int cpu)
328a46d15ccSVitaly Kuznetsov {
329a46d15ccSVitaly Kuznetsov 	return NULL;
330a46d15ccSVitaly Kuznetsov }
331eb914cfeSTianyu Lan static inline int hyperv_flush_guest_mapping(u64 as) { return -1; }
332cc4edae4SLan Tianyu static inline int hyperv_flush_guest_mapping_range(u64 as,
333cc4edae4SLan Tianyu 		hyperv_fill_flush_list_func fill_func, void *data)
334cc4edae4SLan Tianyu {
335cc4edae4SLan Tianyu 	return -1;
336cc4edae4SLan Tianyu }
337faff4406STianyu Lan static inline void hv_set_register(unsigned int reg, u64 value) { }
338faff4406STianyu Lan static inline u64 hv_get_register(unsigned int reg) { return 0; }
3397fec185aSJinank Jain static inline void hv_set_non_nested_register(unsigned int reg, u64 value) { }
3407fec185aSJinank Jain static inline u64 hv_get_non_nested_register(unsigned int reg) { return 0; }
34179cadff2SVitaly Kuznetsov #endif /* CONFIG_HYPERV */
34279cadff2SVitaly Kuznetsov 
343765e33f5SMichael Kelley 
3443be1bc2fSSaurabh Sengar #ifdef CONFIG_HYPERV_VTL_MODE
3453be1bc2fSSaurabh Sengar void __init hv_vtl_init_platform(void);
3463be1bc2fSSaurabh Sengar #else
3473be1bc2fSSaurabh Sengar static inline void __init hv_vtl_init_platform(void) {}
3483be1bc2fSSaurabh Sengar #endif
3493be1bc2fSSaurabh Sengar 
350765e33f5SMichael Kelley #include <asm-generic/mshyperv.h>
351765e33f5SMichael Kelley 
352a2a47c6cSKy Srinivasan #endif
353