From: Jan Kiszka <[email protected]> Just the argument types differ. Factoring that out allows to move all stub definitions to the common header.
Signed-off-by: Jan Kiszka <[email protected]> --- .../arch/arm-common/asm/jailhouse_hypercall.h | 58 +++++++++++++++++ include/arch/arm/asm/jailhouse_hypercall.h | 63 +------------------ include/arch/arm64/asm/jailhouse_hypercall.h | 63 +------------------ 3 files changed, 64 insertions(+), 120 deletions(-) diff --git a/include/arch/arm-common/asm/jailhouse_hypercall.h b/include/arch/arm-common/asm/jailhouse_hypercall.h index 6f2e0b30..3988fd79 100644 --- a/include/arch/arm-common/asm/jailhouse_hypercall.h +++ b/include/arch/arm-common/asm/jailhouse_hypercall.h @@ -57,4 +57,62 @@ struct jailhouse_comm_region { __u32 vpci_irq_base; } __attribute__((packed)); +static inline __jh_arg jailhouse_call(__jh_arg num) +{ + register __jh_arg num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num; + + asm volatile( + JAILHOUSE_CALL_INS + : "+r" (num_result) + : : "memory", JAILHOUSE_CALL_ARG1, JAILHOUSE_CALL_ARG2, + JAILHOUSE_CALL_CLOBBERED); + return num_result; +} + +static inline __jh_arg jailhouse_call_arg1(__jh_arg num, __jh_arg arg1) +{ + register __jh_arg num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num; + register __jh_arg __arg1 asm(JAILHOUSE_CALL_ARG1) = arg1; + + asm volatile( + JAILHOUSE_CALL_INS + : "+r" (num_result), "+r" (__arg1) + : : "memory", JAILHOUSE_CALL_ARG2, JAILHOUSE_CALL_CLOBBERED); + return num_result; +} + +static inline __jh_arg jailhouse_call_arg2(__jh_arg num, __jh_arg arg1, + __jh_arg arg2) +{ + register __jh_arg num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num; + register __jh_arg __arg1 asm(JAILHOUSE_CALL_ARG1) = arg1; + register __jh_arg __arg2 asm(JAILHOUSE_CALL_ARG2) = arg2; + + asm volatile( + JAILHOUSE_CALL_INS + : "+r" (num_result), "+r" (__arg1), "+r" (__arg2) + : : "memory", JAILHOUSE_CALL_CLOBBERED); + return num_result; +} + +static inline void +jailhouse_send_msg_to_cell(struct jailhouse_comm_region *comm_region, + __jh_arg msg) +{ + comm_region->reply_from_cell = JAILHOUSE_MSG_NONE; + /* ensure reply was cleared before sending new message */ + asm volatile("dmb ishst" : : : "memory"); + comm_region->msg_to_cell = msg; +} + +static inline void +jailhouse_send_reply_from_cell(struct jailhouse_comm_region *comm_region, + __jh_arg reply) +{ + comm_region->msg_to_cell = JAILHOUSE_MSG_NONE; + /* ensure message was cleared before sending reply */ + asm volatile("dmb ishst" : : : "memory"); + comm_region->reply_from_cell = reply; +} + #endif /* !__ASSEMBLY__ */ diff --git a/include/arch/arm/asm/jailhouse_hypercall.h b/include/arch/arm/asm/jailhouse_hypercall.h index 4a16ab19..7cd6bc63 100644 --- a/include/arch/arm/asm/jailhouse_hypercall.h +++ b/include/arch/arm/asm/jailhouse_hypercall.h @@ -36,8 +36,6 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include "../arm-common/asm/jailhouse_hypercall.h" - #define JAILHOUSE_CALL_INS ".arch_extension virt\n\t" \ "hvc #0x4a48" #define JAILHOUSE_CALL_NUM_RESULT "r0" @@ -50,62 +48,7 @@ #define JAILHOUSE_NUM_CPU_STATS JAILHOUSE_GENERIC_CPU_STATS + 6 #ifndef __ASSEMBLY__ +typedef __u32 __jh_arg; +#endif -static inline __u32 jailhouse_call(__u32 num) -{ - register __u32 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num; - - asm volatile( - JAILHOUSE_CALL_INS - : "+r" (num_result) - : : "memory", JAILHOUSE_CALL_ARG1, JAILHOUSE_CALL_ARG2, - JAILHOUSE_CALL_CLOBBERED); - return num_result; -} - -static inline __u32 jailhouse_call_arg1(__u32 num, __u32 arg1) -{ - register __u32 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num; - register __u32 __arg1 asm(JAILHOUSE_CALL_ARG1) = arg1; - - asm volatile( - JAILHOUSE_CALL_INS - : "+r" (num_result), "+r" (__arg1) - : : "memory", JAILHOUSE_CALL_ARG2, JAILHOUSE_CALL_CLOBBERED); - return num_result; -} - -static inline __u32 jailhouse_call_arg2(__u32 num, __u32 arg1, __u32 arg2) -{ - register __u32 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num; - register __u32 __arg1 asm(JAILHOUSE_CALL_ARG1) = arg1; - register __u32 __arg2 asm(JAILHOUSE_CALL_ARG2) = arg2; - - asm volatile( - JAILHOUSE_CALL_INS - : "+r" (num_result), "+r" (__arg1), "+r" (__arg2) - : : "memory", JAILHOUSE_CALL_CLOBBERED); - return num_result; -} - -static inline void -jailhouse_send_msg_to_cell(struct jailhouse_comm_region *comm_region, - __u32 msg) -{ - comm_region->reply_from_cell = JAILHOUSE_MSG_NONE; - /* ensure reply was cleared before sending new message */ - asm volatile("dmb ishst" : : : "memory"); - comm_region->msg_to_cell = msg; -} - -static inline void -jailhouse_send_reply_from_cell(struct jailhouse_comm_region *comm_region, - __u32 reply) -{ - comm_region->msg_to_cell = JAILHOUSE_MSG_NONE; - /* ensure message was cleared before sending reply */ - asm volatile("dmb ishst" : : : "memory"); - comm_region->reply_from_cell = reply; -} - -#endif /* !__ASSEMBLY__ */ +#include "../arm-common/asm/jailhouse_hypercall.h" diff --git a/include/arch/arm64/asm/jailhouse_hypercall.h b/include/arch/arm64/asm/jailhouse_hypercall.h index 7f30a0cd..9c94930f 100644 --- a/include/arch/arm64/asm/jailhouse_hypercall.h +++ b/include/arch/arm64/asm/jailhouse_hypercall.h @@ -36,8 +36,6 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include "../arm-common/asm/jailhouse_hypercall.h" - #define JAILHOUSE_CALL_INS "hvc #0x4a48" #define JAILHOUSE_CALL_NUM_RESULT "x0" #define JAILHOUSE_CALL_ARG1 "x1" @@ -48,62 +46,7 @@ #define JAILHOUSE_NUM_CPU_STATS JAILHOUSE_GENERIC_CPU_STATS + 5 #ifndef __ASSEMBLY__ +typedef __u64 __jh_arg; +#endif -static inline __u64 jailhouse_call(__u64 num) -{ - register __u64 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num; - - asm volatile( - JAILHOUSE_CALL_INS - : "+r" (num_result) - : : "memory", JAILHOUSE_CALL_ARG1, JAILHOUSE_CALL_ARG2, - JAILHOUSE_CALL_CLOBBERED); - return num_result; -} - -static inline __u64 jailhouse_call_arg1(__u64 num, __u64 arg1) -{ - register __u64 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num; - register __u64 __arg1 asm(JAILHOUSE_CALL_ARG1) = arg1; - - asm volatile( - JAILHOUSE_CALL_INS - : "+r" (num_result), "+r" (__arg1) - : : "memory", JAILHOUSE_CALL_ARG2, JAILHOUSE_CALL_CLOBBERED); - return num_result; -} - -static inline __u64 jailhouse_call_arg2(__u64 num, __u64 arg1, __u64 arg2) -{ - register __u64 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num; - register __u64 __arg1 asm(JAILHOUSE_CALL_ARG1) = arg1; - register __u64 __arg2 asm(JAILHOUSE_CALL_ARG2) = arg2; - - asm volatile( - JAILHOUSE_CALL_INS - : "+r" (num_result), "+r" (__arg1), "+r" (__arg2) - : : "memory", JAILHOUSE_CALL_CLOBBERED); - return num_result; -} - -static inline void -jailhouse_send_msg_to_cell(struct jailhouse_comm_region *comm_region, - __u64 msg) -{ - comm_region->reply_from_cell = JAILHOUSE_MSG_NONE; - /* ensure reply was cleared before sending new message */ - asm volatile("dmb ishst" : : : "memory"); - comm_region->msg_to_cell = msg; -} - -static inline void -jailhouse_send_reply_from_cell(struct jailhouse_comm_region *comm_region, - __u64 reply) -{ - comm_region->msg_to_cell = JAILHOUSE_MSG_NONE; - /* ensure message was cleared before sending reply */ - asm volatile("dmb ishst" : : : "memory"); - comm_region->reply_from_cell = reply; -} - -#endif /* !__ASSEMBLY__ */ +#include "../arm-common/asm/jailhouse_hypercall.h" -- 2.26.2 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jailhouse-dev/743298f9-b9bb-4ebc-9211-ad809aa94502%40siemens.com.
