Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ASM_X86_ACRN_H
0003 #define _ASM_X86_ACRN_H
0004 
0005 /*
0006  * This CPUID returns feature bitmaps in EAX.
0007  * Guest VM uses this to detect the appropriate feature bit.
0008  */
0009 #define ACRN_CPUID_FEATURES     0x40000001
0010 /* Bit 0 indicates whether guest VM is privileged */
0011 #define ACRN_FEATURE_PRIVILEGED_VM  BIT(0)
0012 
0013 void acrn_setup_intr_handler(void (*handler)(void));
0014 void acrn_remove_intr_handler(void);
0015 
0016 static inline u32 acrn_cpuid_base(void)
0017 {
0018     if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
0019         return hypervisor_cpuid_base("ACRNACRNACRN", 0);
0020 
0021     return 0;
0022 }
0023 
0024 /*
0025  * Hypercalls for ACRN
0026  *
0027  * - VMCALL instruction is used to implement ACRN hypercalls.
0028  * - ACRN hypercall ABI:
0029  *   - Hypercall number is passed in R8 register.
0030  *   - Up to 2 arguments are passed in RDI, RSI.
0031  *   - Return value will be placed in RAX.
0032  *
0033  * Because GCC doesn't support R8 register as direct register constraints, use
0034  * supported constraint as input with a explicit MOV to R8 in beginning of asm.
0035  */
0036 static inline long acrn_hypercall0(unsigned long hcall_id)
0037 {
0038     long result;
0039 
0040     asm volatile("movl %1, %%r8d\n\t"
0041              "vmcall\n\t"
0042              : "=a" (result)
0043              : "g" (hcall_id)
0044              : "r8", "memory");
0045 
0046     return result;
0047 }
0048 
0049 static inline long acrn_hypercall1(unsigned long hcall_id,
0050                    unsigned long param1)
0051 {
0052     long result;
0053 
0054     asm volatile("movl %1, %%r8d\n\t"
0055              "vmcall\n\t"
0056              : "=a" (result)
0057              : "g" (hcall_id), "D" (param1)
0058              : "r8", "memory");
0059 
0060     return result;
0061 }
0062 
0063 static inline long acrn_hypercall2(unsigned long hcall_id,
0064                    unsigned long param1,
0065                    unsigned long param2)
0066 {
0067     long result;
0068 
0069     asm volatile("movl %1, %%r8d\n\t"
0070              "vmcall\n\t"
0071              : "=a" (result)
0072              : "g" (hcall_id), "D" (param1), "S" (param2)
0073              : "r8", "memory");
0074 
0075     return result;
0076 }
0077 
0078 #endif /* _ASM_X86_ACRN_H */