xref: /linux/arch/x86/include/asm/mshyperv.h (revision fb92a1ffc121e65ffed13c6bfe01c190487d791e)
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>
8060f2b97SZhiHu #include <linux/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);
2908e9d120SDexuan Cui DECLARE_STATIC_KEY_FALSE(isolation_type_tdx);
300cc4f6d9STianyu Lan 
31cc4edae4SLan Tianyu typedef int (*hyperv_fill_flush_list_func)(
32cc4edae4SLan Tianyu 		struct hv_guest_mapping_flush_list *flush,
33cc4edae4SLan Tianyu 		void *data);
34cc4edae4SLan Tianyu 
35bc2b0331SK. Y. Srinivasan void hyperv_vector_handler(struct pt_regs *regs);
368730046cSK. Y. Srinivasan 
hv_get_nmi_reason(void)370a7a0058SSaurabh Sengar static inline unsigned char hv_get_nmi_reason(void)
380a7a0058SSaurabh Sengar {
390a7a0058SSaurabh Sengar 	return 0;
400a7a0058SSaurabh Sengar }
410a7a0058SSaurabh Sengar 
428730046cSK. Y. Srinivasan #if IS_ENABLED(CONFIG_HYPERV)
43d3a9d7e4SDexuan Cui extern bool hyperv_paravisor_present;
44dfe94d40SDexuan Cui 
45fc53662fSVitaly Kuznetsov extern void *hv_hypercall_pg;
46fc53662fSVitaly Kuznetsov 
4799a0f46aSWei Liu extern u64 hv_current_partition_id;
4899a0f46aSWei Liu 
49e1878402SMichael Kelley extern union hv_ghcb * __percpu *hv_ghcb_pg;
500cc4f6d9STianyu Lan 
51e3131f1cSDexuan Cui bool hv_isolation_type_snp(void);
5208e9d120SDexuan Cui bool hv_isolation_type_tdx(void);
53d6e0228dSDexuan Cui u64 hv_tdx_hypercall(u64 control, u64 param1, u64 param2);
5408e9d120SDexuan Cui 
5544676bb9STianyu Lan /*
5644676bb9STianyu Lan  * DEFAULT INIT GPAT and SEGMENT LIMIT value in struct VMSA
5744676bb9STianyu Lan  * to start AP in enlightened SEV guest.
5844676bb9STianyu Lan  */
5944676bb9STianyu Lan #define HV_AP_INIT_GPAT_DEFAULT		0x0007040600070406ULL
6044676bb9STianyu Lan #define HV_AP_SEGMENT_LIMIT		0xffffffff
6148b1f683STianyu Lan 
6286b5ec35SWei Liu int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages);
6386b5ec35SWei Liu int hv_call_add_logical_proc(int node, u32 lp_index, u32 acpi_id);
6486b5ec35SWei Liu int hv_call_create_vp(int node, u64 partition_id, u32 vp_index, u32 flags);
6586b5ec35SWei Liu 
66d6e0228dSDexuan Cui /*
67d6e0228dSDexuan Cui  * If the hypercall involves no input or output parameters, the hypervisor
68d6e0228dSDexuan Cui  * ignores the corresponding GPA pointer.
69d6e0228dSDexuan Cui  */
hv_do_hypercall(u64 control,void * input,void * output)70fc53662fSVitaly Kuznetsov static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
71fc53662fSVitaly Kuznetsov {
72fc53662fSVitaly Kuznetsov 	u64 input_address = input ? virt_to_phys(input) : 0;
73fc53662fSVitaly Kuznetsov 	u64 output_address = output ? virt_to_phys(output) : 0;
74fc53662fSVitaly Kuznetsov 	u64 hv_status;
75fc53662fSVitaly Kuznetsov 
76fc53662fSVitaly Kuznetsov #ifdef CONFIG_X86_64
77d3a9d7e4SDexuan Cui 	if (hv_isolation_type_tdx() && !hyperv_paravisor_present)
78d6e0228dSDexuan Cui 		return hv_tdx_hypercall(control, input_address, output_address);
79d6e0228dSDexuan Cui 
80e3131f1cSDexuan Cui 	if (hv_isolation_type_snp() && !hyperv_paravisor_present) {
8148b1f683STianyu Lan 		__asm__ __volatile__("mov %4, %%r8\n"
8248b1f683STianyu Lan 				     "vmmcall"
8348b1f683STianyu Lan 				     : "=a" (hv_status), ASM_CALL_CONSTRAINT,
8448b1f683STianyu Lan 				       "+c" (control), "+d" (input_address)
8548b1f683STianyu Lan 				     :  "r" (output_address)
8648b1f683STianyu Lan 				     : "cc", "memory", "r8", "r9", "r10", "r11");
8748b1f683STianyu Lan 		return hv_status;
8848b1f683STianyu Lan 	}
8948b1f683STianyu Lan 
90fc53662fSVitaly Kuznetsov 	if (!hv_hypercall_pg)
91fc53662fSVitaly Kuznetsov 		return U64_MAX;
92fc53662fSVitaly Kuznetsov 
93fc53662fSVitaly Kuznetsov 	__asm__ __volatile__("mov %4, %%r8\n"
94e70e5892SDavid Woodhouse 			     CALL_NOSPEC
95f5caf621SJosh Poimboeuf 			     : "=a" (hv_status), ASM_CALL_CONSTRAINT,
96fc53662fSVitaly Kuznetsov 			       "+c" (control), "+d" (input_address)
97e70e5892SDavid Woodhouse 			     :  "r" (output_address),
98e70e5892SDavid Woodhouse 				THUNK_TARGET(hv_hypercall_pg)
99fc53662fSVitaly Kuznetsov 			     : "cc", "memory", "r8", "r9", "r10", "r11");
100fc53662fSVitaly Kuznetsov #else
101fc53662fSVitaly Kuznetsov 	u32 input_address_hi = upper_32_bits(input_address);
102fc53662fSVitaly Kuznetsov 	u32 input_address_lo = lower_32_bits(input_address);
103fc53662fSVitaly Kuznetsov 	u32 output_address_hi = upper_32_bits(output_address);
104fc53662fSVitaly Kuznetsov 	u32 output_address_lo = lower_32_bits(output_address);
105fc53662fSVitaly Kuznetsov 
106fc53662fSVitaly Kuznetsov 	if (!hv_hypercall_pg)
107fc53662fSVitaly Kuznetsov 		return U64_MAX;
108fc53662fSVitaly Kuznetsov 
109e70e5892SDavid Woodhouse 	__asm__ __volatile__(CALL_NOSPEC
110fc53662fSVitaly Kuznetsov 			     : "=A" (hv_status),
111f5caf621SJosh Poimboeuf 			       "+c" (input_address_lo), ASM_CALL_CONSTRAINT
112fc53662fSVitaly Kuznetsov 			     : "A" (control),
113fc53662fSVitaly Kuznetsov 			       "b" (input_address_hi),
114fc53662fSVitaly Kuznetsov 			       "D"(output_address_hi), "S"(output_address_lo),
115e70e5892SDavid Woodhouse 			       THUNK_TARGET(hv_hypercall_pg)
116fc53662fSVitaly Kuznetsov 			     : "cc", "memory");
117fc53662fSVitaly Kuznetsov #endif /* !x86_64 */
118fc53662fSVitaly Kuznetsov 	return hv_status;
119fc53662fSVitaly Kuznetsov }
120dee863b5SVitaly Kuznetsov 
121f0d2f5c2SJinank Jain /* Hypercall to the L0 hypervisor */
hv_do_nested_hypercall(u64 control,void * input,void * output)122f0d2f5c2SJinank Jain static inline u64 hv_do_nested_hypercall(u64 control, void *input, void *output)
1236a8edbd0SVitaly Kuznetsov {
124f0d2f5c2SJinank Jain 	return hv_do_hypercall(control | HV_HYPERCALL_NESTED, input, output);
125f0d2f5c2SJinank Jain }
126f0d2f5c2SJinank Jain 
127f0d2f5c2SJinank Jain /* Fast hypercall with 8 bytes of input and no output */
_hv_do_fast_hypercall8(u64 control,u64 input1)128f0d2f5c2SJinank Jain static inline u64 _hv_do_fast_hypercall8(u64 control, u64 input1)
129f0d2f5c2SJinank Jain {
130f0d2f5c2SJinank Jain 	u64 hv_status;
1316a8edbd0SVitaly Kuznetsov 
1326a8edbd0SVitaly Kuznetsov #ifdef CONFIG_X86_64
133d3a9d7e4SDexuan Cui 	if (hv_isolation_type_tdx() && !hyperv_paravisor_present)
134d6e0228dSDexuan Cui 		return hv_tdx_hypercall(control, input1, 0);
135d6e0228dSDexuan Cui 
136e3131f1cSDexuan Cui 	if (hv_isolation_type_snp() && !hyperv_paravisor_present) {
13748b1f683STianyu Lan 		__asm__ __volatile__(
13848b1f683STianyu Lan 				"vmmcall"
13948b1f683STianyu Lan 				: "=a" (hv_status), ASM_CALL_CONSTRAINT,
14048b1f683STianyu Lan 				"+c" (control), "+d" (input1)
14148b1f683STianyu Lan 				:: "cc", "r8", "r9", "r10", "r11");
14248b1f683STianyu Lan 	} else {
143e70e5892SDavid Woodhouse 		__asm__ __volatile__(CALL_NOSPEC
144f5caf621SJosh Poimboeuf 				     : "=a" (hv_status), ASM_CALL_CONSTRAINT,
1456a8edbd0SVitaly Kuznetsov 				       "+c" (control), "+d" (input1)
146e70e5892SDavid Woodhouse 				     : THUNK_TARGET(hv_hypercall_pg)
1476a8edbd0SVitaly Kuznetsov 				     : "cc", "r8", "r9", "r10", "r11");
1486a8edbd0SVitaly Kuznetsov 	}
1496a8edbd0SVitaly Kuznetsov #else
1506a8edbd0SVitaly Kuznetsov 	{
1516a8edbd0SVitaly Kuznetsov 		u32 input1_hi = upper_32_bits(input1);
1526a8edbd0SVitaly Kuznetsov 		u32 input1_lo = lower_32_bits(input1);
1536a8edbd0SVitaly Kuznetsov 
154e70e5892SDavid Woodhouse 		__asm__ __volatile__ (CALL_NOSPEC
1556a8edbd0SVitaly Kuznetsov 				      : "=A"(hv_status),
1566a8edbd0SVitaly Kuznetsov 					"+c"(input1_lo),
157f5caf621SJosh Poimboeuf 					ASM_CALL_CONSTRAINT
1586a8edbd0SVitaly Kuznetsov 				      :	"A" (control),
1596a8edbd0SVitaly Kuznetsov 					"b" (input1_hi),
160e70e5892SDavid Woodhouse 					THUNK_TARGET(hv_hypercall_pg)
1616a8edbd0SVitaly Kuznetsov 				      : "cc", "edi", "esi");
1626a8edbd0SVitaly Kuznetsov 	}
1636a8edbd0SVitaly Kuznetsov #endif
1646a8edbd0SVitaly Kuznetsov 		return hv_status;
1656a8edbd0SVitaly Kuznetsov }
1666a8edbd0SVitaly Kuznetsov 
hv_do_fast_hypercall8(u16 code,u64 input1)167f0d2f5c2SJinank Jain static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1)
16853e52966SVitaly Kuznetsov {
169f0d2f5c2SJinank Jain 	u64 control = (u64)code | HV_HYPERCALL_FAST_BIT;
170f0d2f5c2SJinank Jain 
171f0d2f5c2SJinank Jain 	return _hv_do_fast_hypercall8(control, input1);
172f0d2f5c2SJinank Jain }
173f0d2f5c2SJinank Jain 
hv_do_fast_nested_hypercall8(u16 code,u64 input1)174f0d2f5c2SJinank Jain static inline u64 hv_do_fast_nested_hypercall8(u16 code, u64 input1)
175f0d2f5c2SJinank Jain {
176f0d2f5c2SJinank Jain 	u64 control = (u64)code | HV_HYPERCALL_FAST_BIT | HV_HYPERCALL_NESTED;
177f0d2f5c2SJinank Jain 
178f0d2f5c2SJinank Jain 	return _hv_do_fast_hypercall8(control, input1);
179f0d2f5c2SJinank Jain }
180f0d2f5c2SJinank Jain 
181f0d2f5c2SJinank Jain /* Fast hypercall with 16 bytes of input */
_hv_do_fast_hypercall16(u64 control,u64 input1,u64 input2)182f0d2f5c2SJinank Jain static inline u64 _hv_do_fast_hypercall16(u64 control, u64 input1, u64 input2)
183f0d2f5c2SJinank Jain {
184f0d2f5c2SJinank Jain 	u64 hv_status;
18553e52966SVitaly Kuznetsov 
18653e52966SVitaly Kuznetsov #ifdef CONFIG_X86_64
187d3a9d7e4SDexuan Cui 	if (hv_isolation_type_tdx() && !hyperv_paravisor_present)
188d6e0228dSDexuan Cui 		return hv_tdx_hypercall(control, input1, input2);
189d6e0228dSDexuan Cui 
190e3131f1cSDexuan Cui 	if (hv_isolation_type_snp() && !hyperv_paravisor_present) {
19148b1f683STianyu Lan 		__asm__ __volatile__("mov %4, %%r8\n"
19248b1f683STianyu Lan 				     "vmmcall"
19348b1f683STianyu Lan 				     : "=a" (hv_status), ASM_CALL_CONSTRAINT,
19448b1f683STianyu Lan 				       "+c" (control), "+d" (input1)
19548b1f683STianyu Lan 				     : "r" (input2)
19648b1f683STianyu Lan 				     : "cc", "r8", "r9", "r10", "r11");
19748b1f683STianyu Lan 	} else {
19853e52966SVitaly Kuznetsov 		__asm__ __volatile__("mov %4, %%r8\n"
19953e52966SVitaly Kuznetsov 				     CALL_NOSPEC
20053e52966SVitaly Kuznetsov 				     : "=a" (hv_status), ASM_CALL_CONSTRAINT,
20153e52966SVitaly Kuznetsov 				       "+c" (control), "+d" (input1)
20253e52966SVitaly Kuznetsov 				     : "r" (input2),
20353e52966SVitaly Kuznetsov 				       THUNK_TARGET(hv_hypercall_pg)
20453e52966SVitaly Kuznetsov 				     : "cc", "r8", "r9", "r10", "r11");
20553e52966SVitaly Kuznetsov 	}
20653e52966SVitaly Kuznetsov #else
20753e52966SVitaly Kuznetsov 	{
20853e52966SVitaly Kuznetsov 		u32 input1_hi = upper_32_bits(input1);
20953e52966SVitaly Kuznetsov 		u32 input1_lo = lower_32_bits(input1);
21053e52966SVitaly Kuznetsov 		u32 input2_hi = upper_32_bits(input2);
21153e52966SVitaly Kuznetsov 		u32 input2_lo = lower_32_bits(input2);
21253e52966SVitaly Kuznetsov 
21353e52966SVitaly Kuznetsov 		__asm__ __volatile__ (CALL_NOSPEC
21453e52966SVitaly Kuznetsov 				      : "=A"(hv_status),
21553e52966SVitaly Kuznetsov 					"+c"(input1_lo), ASM_CALL_CONSTRAINT
21653e52966SVitaly Kuznetsov 				      :	"A" (control), "b" (input1_hi),
21753e52966SVitaly Kuznetsov 					"D"(input2_hi), "S"(input2_lo),
21853e52966SVitaly Kuznetsov 					THUNK_TARGET(hv_hypercall_pg)
21953e52966SVitaly Kuznetsov 				      : "cc");
22053e52966SVitaly Kuznetsov 	}
22153e52966SVitaly Kuznetsov #endif
22253e52966SVitaly Kuznetsov 	return hv_status;
22353e52966SVitaly Kuznetsov }
22453e52966SVitaly Kuznetsov 
hv_do_fast_hypercall16(u16 code,u64 input1,u64 input2)225f0d2f5c2SJinank Jain static inline u64 hv_do_fast_hypercall16(u16 code, u64 input1, u64 input2)
226f0d2f5c2SJinank Jain {
227f0d2f5c2SJinank Jain 	u64 control = (u64)code | HV_HYPERCALL_FAST_BIT;
228f0d2f5c2SJinank Jain 
229f0d2f5c2SJinank Jain 	return _hv_do_fast_hypercall16(control, input1, input2);
230f0d2f5c2SJinank Jain }
231f0d2f5c2SJinank Jain 
hv_do_fast_nested_hypercall16(u16 code,u64 input1,u64 input2)232f0d2f5c2SJinank Jain static inline u64 hv_do_fast_nested_hypercall16(u16 code, u64 input1, u64 input2)
233f0d2f5c2SJinank Jain {
234f0d2f5c2SJinank Jain 	u64 control = (u64)code | HV_HYPERCALL_FAST_BIT | HV_HYPERCALL_NESTED;
235f0d2f5c2SJinank Jain 
236f0d2f5c2SJinank Jain 	return _hv_do_fast_hypercall16(control, input1, input2);
237f0d2f5c2SJinank Jain }
238f0d2f5c2SJinank Jain 
239a46d15ccSVitaly Kuznetsov extern struct hv_vp_assist_page **hv_vp_assist_page;
240a46d15ccSVitaly Kuznetsov 
hv_get_vp_assist_page(unsigned int cpu)241a46d15ccSVitaly Kuznetsov static inline struct hv_vp_assist_page *hv_get_vp_assist_page(unsigned int cpu)
242a46d15ccSVitaly Kuznetsov {
243a46d15ccSVitaly Kuznetsov 	if (!hv_vp_assist_page)
244a46d15ccSVitaly Kuznetsov 		return NULL;
245a46d15ccSVitaly Kuznetsov 
246a46d15ccSVitaly Kuznetsov 	return hv_vp_assist_page[cpu];
247a46d15ccSVitaly Kuznetsov }
2487415aea6SVitaly Kuznetsov 
2496b48cb5fSK. Y. Srinivasan void __init hyperv_init(void);
2502ffd9e33SVitaly Kuznetsov void hyperv_setup_mmu_ops(void);
25193286261SVitaly Kuznetsov void set_hv_tscchange_cb(void (*cb)(void));
25293286261SVitaly Kuznetsov void clear_hv_tscchange_cb(void);
25393286261SVitaly Kuznetsov void hyperv_stop_tsc_emulation(void);
254eb914cfeSTianyu Lan int hyperv_flush_guest_mapping(u64 as);
255cc4edae4SLan Tianyu int hyperv_flush_guest_mapping_range(u64 as,
256cc4edae4SLan Tianyu 		hyperv_fill_flush_list_func fill_func, void *data);
257cc4edae4SLan Tianyu int hyperv_fill_flush_guest_mapping_list(
258cc4edae4SLan Tianyu 		struct hv_guest_mapping_flush_list *flush,
259cc4edae4SLan Tianyu 		u64 start_gfn, u64 end_gfn);
2602d2ccf24SThomas Gleixner 
2612d2ccf24SThomas Gleixner #ifdef CONFIG_X86_64
2626b48cb5fSK. Y. Srinivasan void hv_apic_init(void);
2633a025de6SYi Sun void __init hv_init_spinlocks(void);
2643a025de6SYi Sun bool hv_vcpu_is_preempted(int vcpu);
2652d2ccf24SThomas Gleixner #else
hv_apic_init(void)2662d2ccf24SThomas Gleixner static inline void hv_apic_init(void) {}
2672d2ccf24SThomas Gleixner #endif
2682d2ccf24SThomas Gleixner 
269e39397d1SWei Liu struct irq_domain *hv_create_pci_msi_domain(void);
270e39397d1SWei Liu 
271fb5ef351SWei Liu int hv_map_ioapic_interrupt(int ioapic_id, bool level, int vcpu, int vector,
272fb5ef351SWei Liu 		struct hv_interrupt_entry *entry);
273fb5ef351SWei Liu int hv_unmap_ioapic_interrupt(int ioapic_id, struct hv_interrupt_entry *entry);
274faff4406STianyu Lan 
275faff4406STianyu Lan #ifdef CONFIG_AMD_MEM_ENCRYPT
27649d6a3c0STianyu Lan bool hv_ghcb_negotiate_protocol(void);
277611d4c71SGuilherme G. Piccoli void __noreturn hv_ghcb_terminate(unsigned int set, unsigned int reason);
27892fe9bb7SIngo Molnar int hv_snp_boot_ap(u32 cpu, unsigned long start_ip);
279faff4406STianyu Lan #else
hv_ghcb_negotiate_protocol(void)28049d6a3c0STianyu Lan static inline bool hv_ghcb_negotiate_protocol(void) { return false; }
hv_ghcb_terminate(unsigned int set,unsigned int reason)28149d6a3c0STianyu Lan static inline void hv_ghcb_terminate(unsigned int set, unsigned int reason) {}
hv_snp_boot_ap(u32 cpu,unsigned long start_ip)28292fe9bb7SIngo Molnar static inline int hv_snp_boot_ap(u32 cpu, unsigned long start_ip) { return 0; }
283faff4406STianyu Lan #endif
284faff4406STianyu Lan 
285d3a9d7e4SDexuan Cui #if defined(CONFIG_AMD_MEM_ENCRYPT) || defined(CONFIG_INTEL_TDX_GUEST)
286d3a9d7e4SDexuan Cui void hv_vtom_init(void);
287b9b4fe3aSDexuan Cui void hv_ivm_msr_write(u64 msr, u64 value);
288b9b4fe3aSDexuan Cui void hv_ivm_msr_read(u64 msr, u64 *value);
289d3a9d7e4SDexuan Cui #else
hv_vtom_init(void)290d3a9d7e4SDexuan Cui static inline void hv_vtom_init(void) {}
hv_ivm_msr_write(u64 msr,u64 value)291b9b4fe3aSDexuan Cui static inline void hv_ivm_msr_write(u64 msr, u64 value) {}
hv_ivm_msr_read(u64 msr,u64 * value)292b9b4fe3aSDexuan Cui static inline void hv_ivm_msr_read(u64 msr, u64 *value) {}
293d3a9d7e4SDexuan Cui #endif
294faff4406STianyu Lan 
hv_is_synic_msr(unsigned int reg)295*0e3f7d12SNuno Das Neves static inline bool hv_is_synic_msr(unsigned int reg)
296faff4406STianyu Lan {
297*0e3f7d12SNuno Das Neves 	return (reg >= HV_X64_MSR_SCONTROL) &&
298*0e3f7d12SNuno Das Neves 	       (reg <= HV_X64_MSR_SINT15);
299b14033a3SNuno Das Neves }
300b14033a3SNuno Das Neves 
hv_is_sint_msr(unsigned int reg)301*0e3f7d12SNuno Das Neves static inline bool hv_is_sint_msr(unsigned int reg)
302b14033a3SNuno Das Neves {
303*0e3f7d12SNuno Das Neves 	return (reg >= HV_X64_MSR_SINT0) &&
304*0e3f7d12SNuno Das Neves 	       (reg <= HV_X64_MSR_SINT15);
305faff4406STianyu Lan }
306faff4406STianyu Lan 
307*0e3f7d12SNuno Das Neves u64 hv_get_msr(unsigned int reg);
308*0e3f7d12SNuno Das Neves void hv_set_msr(unsigned int reg, u64 value);
309*0e3f7d12SNuno Das Neves u64 hv_get_non_nested_msr(unsigned int reg);
310*0e3f7d12SNuno Das Neves void hv_set_non_nested_msr(unsigned int reg, u64 value);
311faff4406STianyu Lan 
hv_raw_get_msr(unsigned int reg)312*0e3f7d12SNuno Das Neves static __always_inline u64 hv_raw_get_msr(unsigned int reg)
313e39acc37SPeter Zijlstra {
314e39acc37SPeter Zijlstra 	return __rdmsr(reg);
315e39acc37SPeter Zijlstra }
316e39acc37SPeter Zijlstra 
31779cadff2SVitaly Kuznetsov #else /* CONFIG_HYPERV */
hyperv_init(void)31879cadff2SVitaly Kuznetsov static inline void hyperv_init(void) {}
hyperv_setup_mmu_ops(void)3192ffd9e33SVitaly Kuznetsov static inline void hyperv_setup_mmu_ops(void) {}
set_hv_tscchange_cb(void (* cb)(void))32093286261SVitaly Kuznetsov static inline void set_hv_tscchange_cb(void (*cb)(void)) {}
clear_hv_tscchange_cb(void)32193286261SVitaly Kuznetsov static inline void clear_hv_tscchange_cb(void) {}
hyperv_stop_tsc_emulation(void)32293286261SVitaly Kuznetsov static inline void hyperv_stop_tsc_emulation(void) {};
hv_get_vp_assist_page(unsigned int cpu)323a46d15ccSVitaly Kuznetsov static inline struct hv_vp_assist_page *hv_get_vp_assist_page(unsigned int cpu)
324a46d15ccSVitaly Kuznetsov {
325a46d15ccSVitaly Kuznetsov 	return NULL;
326a46d15ccSVitaly Kuznetsov }
hyperv_flush_guest_mapping(u64 as)327eb914cfeSTianyu Lan static inline int hyperv_flush_guest_mapping(u64 as) { return -1; }
hyperv_flush_guest_mapping_range(u64 as,hyperv_fill_flush_list_func fill_func,void * data)328cc4edae4SLan Tianyu static inline int hyperv_flush_guest_mapping_range(u64 as,
329cc4edae4SLan Tianyu 		hyperv_fill_flush_list_func fill_func, void *data)
330cc4edae4SLan Tianyu {
331cc4edae4SLan Tianyu 	return -1;
332cc4edae4SLan Tianyu }
hv_set_msr(unsigned int reg,u64 value)333*0e3f7d12SNuno Das Neves static inline void hv_set_msr(unsigned int reg, u64 value) { }
hv_get_msr(unsigned int reg)334*0e3f7d12SNuno Das Neves static inline u64 hv_get_msr(unsigned int reg) { return 0; }
hv_set_non_nested_msr(unsigned int reg,u64 value)335*0e3f7d12SNuno Das Neves static inline void hv_set_non_nested_msr(unsigned int reg, u64 value) { }
hv_get_non_nested_msr(unsigned int reg)336*0e3f7d12SNuno Das Neves static inline u64 hv_get_non_nested_msr(unsigned int reg) { return 0; }
33779cadff2SVitaly Kuznetsov #endif /* CONFIG_HYPERV */
33879cadff2SVitaly Kuznetsov 
339765e33f5SMichael Kelley 
3403be1bc2fSSaurabh Sengar #ifdef CONFIG_HYPERV_VTL_MODE
3413be1bc2fSSaurabh Sengar void __init hv_vtl_init_platform(void);
34214058f72SSaurabh Sengar int __init hv_vtl_early_init(void);
3433be1bc2fSSaurabh Sengar #else
hv_vtl_init_platform(void)3443be1bc2fSSaurabh Sengar static inline void __init hv_vtl_init_platform(void) {}
hv_vtl_early_init(void)34514058f72SSaurabh Sengar static inline int __init hv_vtl_early_init(void) { return 0; }
3463be1bc2fSSaurabh Sengar #endif
3473be1bc2fSSaurabh Sengar 
348765e33f5SMichael Kelley #include <asm-generic/mshyperv.h>
349765e33f5SMichael Kelley 
350a2a47c6cSKy Srinivasan #endif
351