File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -21,4 +21,58 @@ static inline u32 acrn_cpuid_base(void)
2121 return 0 ;
2222}
2323
24+ /*
25+ * Hypercalls for ACRN
26+ *
27+ * - VMCALL instruction is used to implement ACRN hypercalls.
28+ * - ACRN hypercall ABI:
29+ * - Hypercall number is passed in R8 register.
30+ * - Up to 2 arguments are passed in RDI, RSI.
31+ * - Return value will be placed in RAX.
32+ *
33+ * Because GCC doesn't support R8 register as direct register constraints, use
34+ * supported constraint as input with a explicit MOV to R8 in beginning of asm.
35+ */
36+ static inline long acrn_hypercall0 (unsigned long hcall_id )
37+ {
38+ long result ;
39+
40+ asm volatile ("movl %1, %%r8d\n\t"
41+ "vmcall\n\t"
42+ : "=a" (result )
43+ : "g" (hcall_id )
44+ : "r8" , "memory" );
45+
46+ return result ;
47+ }
48+
49+ static inline long acrn_hypercall1 (unsigned long hcall_id ,
50+ unsigned long param1 )
51+ {
52+ long result ;
53+
54+ asm volatile ("movl %1, %%r8d\n\t"
55+ "vmcall\n\t"
56+ : "=a" (result )
57+ : "g" (hcall_id ), "D" (param1 )
58+ : "r8" , "memory" );
59+
60+ return result ;
61+ }
62+
63+ static inline long acrn_hypercall2 (unsigned long hcall_id ,
64+ unsigned long param1 ,
65+ unsigned long param2 )
66+ {
67+ long result ;
68+
69+ asm volatile ("movl %1, %%r8d\n\t"
70+ "vmcall\n\t"
71+ : "=a" (result )
72+ : "g" (hcall_id ), "D" (param1 ), "S" (param2 )
73+ : "r8" , "memory" );
74+
75+ return result ;
76+ }
77+
2478#endif /* _ASM_X86_ACRN_H */
You can’t perform that action at this time.
0 commit comments