Skip to content

Commit 55b9893

Browse files
committed
feat(inc/hypercall): introduce arch-specific hypercall in/out convention
This commit introduces a separation of input and output conventions for hypercalls, addressing architecture-specific differences between ARM and RISC-V. On ARM, the x0 register is used to pass both the extid, fid, and the return value, while additional parameters (hypercalls arguments) are passed via registers x1 to xn. On RISC-V, while the return value is passed in a0, the extid and fid are handled by the a7 and a6 registers, respectively. This means that the hypercall input arguments on RISC-V should be passed through registers a0 to a5, while output hypercall arguments are passed via a1 and onward. To accommodate these differences and provide a uniform interface, two macros were introduced to abstract the handling of input and output hypercall arguments across architectures. Signed-off-by: João Peixoto <[email protected]>
1 parent 22d8f64 commit 55b9893

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/arch/armv8/inc/arch/hypercall.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#ifndef ARCH_HYPERCALL_H
77
#define ARCH_HYPERCALL_H
88

9-
#define HYPCALL_ARG_REG(ARG) ((ARG) + 1)
9+
#define HYPCALL_IN_ARG_REG(ARG) ((ARG) + 1)
10+
#define HYPCALL_OUT_ARG_REG(ARG) (HYPCALL_IN_ARG_REG(ARG))
1011

1112
#endif /* ARCH_HYPERCALL_H */

src/arch/riscv/inc/arch/hypercall.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#ifndef ARCH_HYPERCALL_H
77
#define ARCH_HYPERCALL_H
88

9-
#define HYPCALL_ARG_REG(ARG) ((ARG) + REG_A0)
9+
#define HYPCALL_IN_ARG_REG(ARG) ((ARG) + REG_A0)
10+
#define HYPCALL_OUT_ARG_REG(ARG) (HYPCALL_IN_ARG_REG((ARG) + 1))
1011

1112
#endif /* ARCH_HYPERCALL_H */

src/core/hypercall.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ long int hypercall(unsigned long id)
1212
{
1313
long int ret = -HC_E_INVAL_ID;
1414

15-
unsigned long arg0 = vcpu_readreg(cpu()->vcpu, HYPCALL_ARG_REG(0));
16-
unsigned long arg1 = vcpu_readreg(cpu()->vcpu, HYPCALL_ARG_REG(1));
17-
unsigned long arg2 = vcpu_readreg(cpu()->vcpu, HYPCALL_ARG_REG(2));
15+
unsigned long arg0 = vcpu_readreg(cpu()->vcpu, HYPCALL_IN_ARG_REG(0));
16+
unsigned long arg1 = vcpu_readreg(cpu()->vcpu, HYPCALL_IN_ARG_REG(1));
17+
unsigned long arg2 = vcpu_readreg(cpu()->vcpu, HYPCALL_IN_ARG_REG(2));
1818

1919
switch (id) {
2020
case HC_IPC:

0 commit comments

Comments
 (0)