Skip to content

Commit 8a0a871

Browse files
Shuo Liugregkh
authored andcommitted
x86/acrn: Introduce hypercall interfaces
The Service VM communicates with the hypervisor via conventional hypercalls. VMCALL instruction is used to make the hypercalls. ACRN hypercall ABI: * Hypercall number is in R8 register. * Up to 2 parameters are in RDI and RSI registers. * Return value is in RAX register. Introduce the ACRN hypercall interfaces. Because GCC doesn't support R8 register as direct register constraints, use supported constraint as input with a explicit MOV to R8 in beginning of asm. Cc: Dave Hansen <[email protected]> Cc: Sean Christopherson <[email protected]> Cc: Dan Williams <[email protected]> Cc: Fengwei Yin <[email protected]> Cc: Zhi Wang <[email protected]> Cc: Zhenyu Wang <[email protected]> Cc: Yu Wang <[email protected]> Cc: Reinette Chatre <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Arvind Sankar <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Nick Desaulniers <[email protected]> Cc: Segher Boessenkool <[email protected]> Originally-by: Yakui Zhao <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]> Acked-by: Borislav Petkov <[email protected]> Signed-off-by: Shuo Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ebbfc97 commit 8a0a871

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

arch/x86/include/asm/acrn.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff 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 */

0 commit comments

Comments
 (0)