1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_ACRN_H
3 #define _ASM_X86_ACRN_H
6 * This CPUID returns feature bitmaps in EAX.
7 * Guest VM uses this to detect the appropriate feature bit.
9 #define ACRN_CPUID_FEATURES 0x40000001
10 /* Bit 0 indicates whether guest VM is privileged */
11 #define ACRN_FEATURE_PRIVILEGED_VM BIT(0)
15 * This leaf returns the current TSC frequency in kHz.
17 * EAX: (Virtual) TSC frequency in kHz.
18 * EBX, ECX, EDX: RESERVED (reserved fields are set to zero).
20 #define ACRN_CPUID_TIMING_INFO 0x40000010
22 void acrn_setup_intr_handler(void (*handler)(void));
23 void acrn_remove_intr_handler(void);
25 static inline u32 acrn_cpuid_base(void)
27 if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
28 return hypervisor_cpuid_base("ACRNACRNACRN", 0);
33 static inline unsigned long acrn_get_tsc_khz(void)
35 return cpuid_eax(ACRN_CPUID_TIMING_INFO);
41 * - VMCALL instruction is used to implement ACRN hypercalls.
42 * - ACRN hypercall ABI:
43 * - Hypercall number is passed in R8 register.
44 * - Up to 2 arguments are passed in RDI, RSI.
45 * - Return value will be placed in RAX.
47 * Because GCC doesn't support R8 register as direct register constraints, use
48 * supported constraint as input with a explicit MOV to R8 in beginning of asm.
50 static inline long acrn_hypercall0(unsigned long hcall_id)
54 asm volatile("movl %1, %%r8d\n\t"
63 static inline long acrn_hypercall1(unsigned long hcall_id,
68 asm volatile("movl %1, %%r8d\n\t"
71 : "g" (hcall_id), "D" (param1)
77 static inline long acrn_hypercall2(unsigned long hcall_id,
83 asm volatile("movl %1, %%r8d\n\t"
86 : "g" (hcall_id), "D" (param1), "S" (param2)
92 #endif /* _ASM_X86_ACRN_H */