summaryrefslogtreecommitdiffstats
path: root/arch/x86/include/asm/mcsafe_test.h
blob: eb59804b6201c35c85f66230522c663904ffada1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _MCSAFE_TEST_H_
#define _MCSAFE_TEST_H_

#ifndef __ASSEMBLY__
#ifdef CONFIG_MCSAFE_TEST
extern unsigned long mcsafe_test_src;
extern unsigned long mcsafe_test_dst;

static inline void mcsafe_inject_src(void *addr)
{
	if (addr)
		mcsafe_test_src = (unsigned long) addr;
	else
		mcsafe_test_src = ~0UL;
}

static inline void mcsafe_inject_dst(void *addr)
{
	if (addr)
		mcsafe_test_dst = (unsigned long) addr;
	else
		mcsafe_test_dst = ~0UL;
}
#else /* CONFIG_MCSAFE_TEST */
static inline void mcsafe_inject_src(void *addr)
{
}

static inline void mcsafe_inject_dst(void *addr)
{
}
#endif /* CONFIG_MCSAFE_TEST */

#else /* __ASSEMBLY__ */
#include <asm/export.h>

#ifdef CONFIG_MCSAFE_TEST
.macro MCSAFE_TEST_CTL
	.pushsection .data
	.align 8
	.globl mcsafe_test_src
	mcsafe_test_src:
		.quad 0
	EXPORT_SYMBOL_GPL(mcsafe_test_src)
	.globl mcsafe_test_dst
	mcsafe_test_dst:
		.quad 0
	EXPORT_SYMBOL_GPL(mcsafe_test_dst)
	.popsection
.endm

.macro MCSAFE_TEST_SRC reg count target
	leaq \count(\reg), %r9
	cmp mcsafe_test_src, %r9
	ja \target
.endm

.macro MCSAFE_TEST_DST reg count target
	leaq \count(\reg), %r9
	cmp mcsafe_test_dst, %r9
	ja \target
.endm
#else
.macro MCSAFE_TEST_CTL
.endm

.macro MCSAFE_TEST_SRC reg count target
.endm

.macro MCSAFE_TEST_DST reg count target
.endm
#endif /* CONFIG_MCSAFE_TEST */
#endif /* __ASSEMBLY__ */
#endif /* _MCSAFE_TEST_H_ */
OpenPOWER on IntegriCloud