1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _COPY_MC_TEST_H_
3 #define _COPY_MC_TEST_H_
4 
5 #ifndef __ASSEMBLY__
6 #ifdef CONFIG_COPY_MC_TEST
7 extern unsigned long copy_mc_test_src;
8 extern unsigned long copy_mc_test_dst;
9 
copy_mc_inject_src(void * addr)10 static inline void copy_mc_inject_src(void *addr)
11 {
12 	if (addr)
13 		copy_mc_test_src = (unsigned long) addr;
14 	else
15 		copy_mc_test_src = ~0UL;
16 }
17 
copy_mc_inject_dst(void * addr)18 static inline void copy_mc_inject_dst(void *addr)
19 {
20 	if (addr)
21 		copy_mc_test_dst = (unsigned long) addr;
22 	else
23 		copy_mc_test_dst = ~0UL;
24 }
25 #else /* CONFIG_COPY_MC_TEST */
copy_mc_inject_src(void * addr)26 static inline void copy_mc_inject_src(void *addr)
27 {
28 }
29 
copy_mc_inject_dst(void * addr)30 static inline void copy_mc_inject_dst(void *addr)
31 {
32 }
33 #endif /* CONFIG_COPY_MC_TEST */
34 
35 #else /* __ASSEMBLY__ */
36 #include <asm/export.h>
37 
38 #ifdef CONFIG_COPY_MC_TEST
39 .macro COPY_MC_TEST_CTL
40 	.pushsection .data
41 	.align 8
42 	.globl copy_mc_test_src
43 	copy_mc_test_src:
44 		.quad 0
45 	EXPORT_SYMBOL_GPL(copy_mc_test_src)
46 	.globl copy_mc_test_dst
47 	copy_mc_test_dst:
48 		.quad 0
49 	EXPORT_SYMBOL_GPL(copy_mc_test_dst)
50 	.popsection
51 .endm
52 
53 .macro COPY_MC_TEST_SRC reg count target
54 	leaq \count(\reg), %r9
55 	cmp copy_mc_test_src, %r9
56 	ja \target
57 .endm
58 
59 .macro COPY_MC_TEST_DST reg count target
60 	leaq \count(\reg), %r9
61 	cmp copy_mc_test_dst, %r9
62 	ja \target
63 .endm
64 #else
65 .macro COPY_MC_TEST_CTL
66 .endm
67 
68 .macro COPY_MC_TEST_SRC reg count target
69 .endm
70 
71 .macro COPY_MC_TEST_DST reg count target
72 .endm
73 #endif /* CONFIG_COPY_MC_TEST */
74 #endif /* __ASSEMBLY__ */
75 #endif /* _COPY_MC_TEST_H_ */
76