Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/tools/testing/selftests/arm64/mte/mte_helper.S
26296 views
1
/* SPDX-License-Identifier: GPL-2.0 */
2
/* Copyright (C) 2020 ARM Limited */
3
4
#include "mte_def.h"
5
6
.arch armv8.5-a+memtag
7
8
#define ENTRY(name) \
9
.globl name ;\
10
.p2align 2;\
11
.type name, @function ;\
12
name:
13
14
#define ENDPROC(name) \
15
.size name, .-name ;
16
17
.text
18
/*
19
* mte_insert_random_tag: Insert random tag and might be same as the source tag if
20
* the source pointer has it.
21
* Input:
22
* x0 - source pointer with a tag/no-tag
23
* Return:
24
* x0 - pointer with random tag
25
*/
26
ENTRY(mte_insert_random_tag)
27
irg x0, x0, xzr
28
ret
29
ENDPROC(mte_insert_random_tag)
30
31
/*
32
* mte_insert_new_tag: Insert new tag and different from the source tag if
33
* source pointer has it.
34
* Input:
35
* x0 - source pointer with a tag/no-tag
36
* Return:
37
* x0 - pointer with random tag
38
*/
39
ENTRY(mte_insert_new_tag)
40
gmi x1, x0, xzr
41
irg x0, x0, x1
42
ret
43
ENDPROC(mte_insert_new_tag)
44
45
/*
46
* mte_get_tag_address: Get the tag from given address.
47
* Input:
48
* x0 - source pointer
49
* Return:
50
* x0 - pointer with appended tag
51
*/
52
ENTRY(mte_get_tag_address)
53
ldg x0, [x0]
54
ret
55
ENDPROC(mte_get_tag_address)
56
57
/*
58
* mte_set_tag_address_range: Set the tag range from the given address
59
* Input:
60
* x0 - source pointer with tag data
61
* x1 - range
62
* Return:
63
* none
64
*/
65
ENTRY(mte_set_tag_address_range)
66
cbz x1, 2f
67
1:
68
stg x0, [x0, #0x0]
69
add x0, x0, #MT_GRANULE_SIZE
70
sub x1, x1, #MT_GRANULE_SIZE
71
cbnz x1, 1b
72
2:
73
ret
74
ENDPROC(mte_set_tag_address_range)
75
76
/*
77
* mt_clear_tag_address_range: Clear the tag range from the given address
78
* Input:
79
* x0 - source pointer with tag data
80
* x1 - range
81
* Return:
82
* none
83
*/
84
ENTRY(mte_clear_tag_address_range)
85
cbz x1, 2f
86
1:
87
stzg x0, [x0, #0x0]
88
add x0, x0, #MT_GRANULE_SIZE
89
sub x1, x1, #MT_GRANULE_SIZE
90
cbnz x1, 1b
91
2:
92
ret
93
ENDPROC(mte_clear_tag_address_range)
94
95
/*
96
* mte_enable_pstate_tco: Enable PSTATE.TCO (tag check override) field
97
* Input:
98
* none
99
* Return:
100
* none
101
*/
102
ENTRY(mte_enable_pstate_tco)
103
msr tco, #MT_PSTATE_TCO_EN
104
ret
105
ENDPROC(mte_enable_pstate_tco)
106
107
/*
108
* mte_disable_pstate_tco: Disable PSTATE.TCO (tag check override) field
109
* Input:
110
* none
111
* Return:
112
* none
113
*/
114
ENTRY(mte_disable_pstate_tco)
115
msr tco, #MT_PSTATE_TCO_DIS
116
ret
117
ENDPROC(mte_disable_pstate_tco)
118
119
/*
120
* mte_get_pstate_tco: Get PSTATE.TCO (tag check override) field
121
* Input:
122
* none
123
* Return:
124
* x0
125
*/
126
ENTRY(mte_get_pstate_tco)
127
mrs x0, tco
128
ubfx x0, x0, #MT_PSTATE_TCO_SHIFT, #1
129
ret
130
ENDPROC(mte_get_pstate_tco)
131
132