From: Christopher Clark Date: Thu, 28 Jan 2021 06:26:35 +0000 (-0800) Subject: Add HYPERCALL5 and hypercall_argo_op() X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=7cd8f381d0fe1736d00a568e1381956197e66699;p=people%2Fandrewcoop%2Fxen-test-framework.git Add HYPERCALL5 and hypercall_argo_op() [Split out from argo patch] Signed-off-by: Christopher Clark Reviewed-by: Andrew Cooper [Also implement HYPERCALL0 as it is frequently opencoded] Signed-off-by: Andrew Cooper --- diff --git a/arch/x86/hypercall_page.S b/arch/x86/hypercall_page.S index b77c1b9..cc6ddc2 100644 --- a/arch/x86/hypercall_page.S +++ b/arch/x86/hypercall_page.S @@ -59,7 +59,7 @@ DECLARE_HYPERCALL(sysctl) DECLARE_HYPERCALL(domctl) DECLARE_HYPERCALL(kexec_op) DECLARE_HYPERCALL(tmem_op) -DECLARE_HYPERCALL(xc_reserved_op) +DECLARE_HYPERCALL(argo_op) DECLARE_HYPERCALL(xenpmu_op) DECLARE_HYPERCALL(arch_0) diff --git a/arch/x86/include/arch/hypercall-x86_32.h b/arch/x86/include/arch/hypercall-x86_32.h index 34a7026..eabb7b1 100644 --- a/arch/x86/include/arch/hypercall-x86_32.h +++ b/arch/x86/include/arch/hypercall-x86_32.h @@ -7,6 +7,17 @@ * Inputs: %ebx, %ecx, %edx, %esi, %edi, %ebp (arguments 1-6) */ +#define _hypercall32_0(type, hcall) \ + ({ \ + long res; \ + asm volatile ( \ + "call hypercall_page + %c[offset]" \ + : "=a" (res) \ + : [offset] "i" (hcall * 32) \ + : "memory" ); \ + (type)res; \ + }) + #define _hypercall32_1(type, hcall, a1) \ ({ \ long res, _a1 = (long)(a1); \ @@ -53,6 +64,19 @@ (type)res; \ }) +#define _hypercall32_5(type, hcall, a1, a2, a3, a4, a5) \ + ({ \ + long res, _a1 = (long)(a1), _a2 = (long)(a2), _a3 = (long)(a3), \ + _a4 = (long)(a4), _a5 = (long)(a5); \ + asm volatile ( \ + "call hypercall_page + %c[offset]" \ + : "=a" (res), "+b" (_a1), "+c" (_a2), "+d" (_a3), \ + "+S" (_a4), "+D" (_a5) \ + : [offset] "i" (hcall * 32) \ + : "memory" ); \ + (type)res; \ + }) + #endif /* XTF_X86_32_HYPERCALL_H */ /* diff --git a/arch/x86/include/arch/hypercall-x86_64.h b/arch/x86/include/arch/hypercall-x86_64.h index d283ad3..6cb6728 100644 --- a/arch/x86/include/arch/hypercall-x86_64.h +++ b/arch/x86/include/arch/hypercall-x86_64.h @@ -7,6 +7,17 @@ * Inputs: %rdi, %rsi, %rdx, %r10, %r8, %r9 (arguments 1-6) */ +#define _hypercall64_0(type, hcall) \ + ({ \ + long res; \ + asm volatile ( \ + "call hypercall_page + %c[offset]" \ + : "=a" (res) \ + : [offset] "i" (hcall * 32) \ + : "memory" ); \ + (type)res; \ + }) + #define _hypercall64_1(type, hcall, a1) \ ({ \ long res, _a1 = (long)(a1); \ @@ -53,6 +64,20 @@ (type)res; \ }) +#define _hypercall64_5(type, hcall, a1, a2, a3, a4, a5) \ + ({ \ + long res, _a1 = (long)(a1), _a2 = (long)(a2), _a3 = (long)(a3); \ + register long _a4 asm ("r10") = (long)(a4); \ + register long _a5 asm ("r8") = (long)(a5); \ + asm volatile ( \ + "call hypercall_page + %c[offset]" \ + : "=a" (res), "+D" (_a1), "+S" (_a2), "+d" (_a3), \ + "+r" (_a4), "+r" (_a5) \ + : [offset] "i" (hcall * 32) \ + : "memory" ); \ + (type)res; \ + }) + #endif /* XTF_X86_64_HYPERCALL_H */ /* diff --git a/include/xen/xen.h b/include/xen/xen.h index 877f2f0..11af167 100644 --- a/include/xen/xen.h +++ b/include/xen/xen.h @@ -49,7 +49,7 @@ #define __HYPERVISOR_domctl 36 #define __HYPERVISOR_kexec_op 37 #define __HYPERVISOR_tmem_op 38 -#define __HYPERVISOR_xc_reserved_op 39 /* reserved for XenClient */ +#define __HYPERVISOR_argo_op 39 #define __HYPERVISOR_xenpmu_op 40 /* Architecture-specific hypercall definitions. */ diff --git a/include/xtf/hypercall.h b/include/xtf/hypercall.h index acda592..fcd16dc 100644 --- a/include/xtf/hypercall.h +++ b/include/xtf/hypercall.h @@ -9,18 +9,22 @@ #if defined(__x86_64__) # include +# define HYPERCALL0 _hypercall64_0 # define HYPERCALL1 _hypercall64_1 # define HYPERCALL2 _hypercall64_2 # define HYPERCALL3 _hypercall64_3 # define HYPERCALL4 _hypercall64_4 +# define HYPERCALL5 _hypercall64_5 #elif defined(__i386__) # include +# define HYPERCALL0 _hypercall32_0 # define HYPERCALL1 _hypercall32_1 # define HYPERCALL2 _hypercall32_2 # define HYPERCALL3 _hypercall32_3 # define HYPERCALL4 _hypercall32_4 +# define HYPERCALL5 _hypercall32_5 #else # error Bad architecture for hypercalls @@ -170,6 +174,12 @@ static inline long hypercall_sysctl(xen_sysctl_t *arg) return HYPERCALL1(long, __HYPERVISOR_sysctl, arg); } +static inline long hypercall_argo_op(unsigned int cmd, void *arg1, void *arg2, + unsigned long arg3, unsigned long arg4) +{ + return HYPERCALL5(long, __HYPERVISOR_argo_op, cmd, arg1, arg2, arg3, arg4); +} + /* * Higher level hypercall helpers */