11
11
12
12
#define NEXT_PROGRAM "./vstate_exec_nolibc"
13
13
14
- int test_and_compare_child (long provided , long expected , int inherit )
14
+ int test_and_compare_child (long provided , long expected , int inherit , int xtheadvector )
15
15
{
16
16
int rc ;
17
17
@@ -21,7 +21,7 @@ int test_and_compare_child(long provided, long expected, int inherit)
21
21
provided , rc );
22
22
return -1 ;
23
23
}
24
- rc = launch_test (NEXT_PROGRAM , inherit );
24
+ rc = launch_test (NEXT_PROGRAM , inherit , xtheadvector );
25
25
if (rc != expected ) {
26
26
printf ("Test failed, check %d != %ld\n" , rc , expected );
27
27
return -2 ;
@@ -36,7 +36,7 @@ TEST(get_control_no_v)
36
36
{
37
37
long rc ;
38
38
39
- if (is_vector_supported ())
39
+ if (is_vector_supported () || is_xtheadvector_supported () )
40
40
SKIP (return , "Test expects vector to be not supported" );
41
41
42
42
rc = prctl (PR_RISCV_V_GET_CONTROL );
@@ -50,7 +50,7 @@ TEST(set_control_no_v)
50
50
{
51
51
long rc ;
52
52
53
- if (is_vector_supported ())
53
+ if (is_vector_supported () || is_xtheadvector_supported () )
54
54
SKIP (return , "Test expects vector to be not supported" );
55
55
56
56
rc = prctl (PR_RISCV_V_SET_CONTROL , PR_RISCV_V_VSTATE_CTRL_ON );
@@ -65,20 +65,20 @@ TEST(vstate_on_current)
65
65
long flag ;
66
66
long rc ;
67
67
68
- if (!is_vector_supported ())
68
+ if (!is_vector_supported () && ! is_xtheadvector_supported () )
69
69
SKIP (return , "Vector not supported" );
70
70
71
71
flag = PR_RISCV_V_VSTATE_CTRL_ON ;
72
72
rc = prctl (PR_RISCV_V_SET_CONTROL , flag );
73
- EXPECT_EQ (0 , rc ) TH_LOG ("Enabling V for current should always success " );
73
+ EXPECT_EQ (0 , rc ) TH_LOG ("Enabling V for current should always succeed " );
74
74
}
75
75
76
76
TEST (vstate_off_eperm )
77
77
{
78
78
long flag ;
79
79
long rc ;
80
80
81
- if (!is_vector_supported ())
81
+ if (!is_vector_supported () && ! is_xtheadvector_supported () )
82
82
SKIP (return , "Vector not supported" );
83
83
84
84
flag = PR_RISCV_V_VSTATE_CTRL_OFF ;
@@ -92,97 +92,124 @@ TEST(vstate_off_eperm)
92
92
TEST (vstate_on_no_nesting )
93
93
{
94
94
long flag ;
95
+ int xtheadvector = 0 ;
95
96
96
- if (!is_vector_supported ())
97
- SKIP (return , "Vector not supported" );
97
+ if (!is_vector_supported ()) {
98
+ if (is_xtheadvector_supported ())
99
+ xtheadvector = 1 ;
100
+ else
101
+ SKIP (return , "Vector not supported" );
102
+ }
98
103
99
104
/* Turn on next's vector explicitly and test */
100
105
flag = PR_RISCV_V_VSTATE_CTRL_ON << PR_RISCV_V_VSTATE_CTRL_NEXT_SHIFT ;
101
106
102
- EXPECT_EQ (0 ,
103
- test_and_compare_child (flag , PR_RISCV_V_VSTATE_CTRL_ON , 0 ));
107
+ EXPECT_EQ (0 , test_and_compare_child (flag , PR_RISCV_V_VSTATE_CTRL_ON , 0 , xtheadvector ));
104
108
}
105
109
106
110
TEST (vstate_off_nesting )
107
111
{
108
112
long flag ;
113
+ int xtheadvector = 0 ;
109
114
110
- if (!is_vector_supported ())
111
- SKIP (return , "Vector not supported" );
115
+ if (!is_vector_supported ()) {
116
+ if (is_xtheadvector_supported ())
117
+ xtheadvector = 1 ;
118
+ else
119
+ SKIP (return , "Vector not supported" );
120
+ }
112
121
113
122
/* Turn off next's vector explicitly and test */
114
123
flag = PR_RISCV_V_VSTATE_CTRL_OFF << PR_RISCV_V_VSTATE_CTRL_NEXT_SHIFT ;
115
124
116
- EXPECT_EQ (0 ,
117
- test_and_compare_child (flag , PR_RISCV_V_VSTATE_CTRL_OFF , 1 ));
125
+ EXPECT_EQ (0 , test_and_compare_child (flag , PR_RISCV_V_VSTATE_CTRL_OFF , 1 , xtheadvector ));
118
126
}
119
127
120
128
TEST (vstate_on_inherit_no_nesting )
121
129
{
122
130
long flag , expected ;
131
+ int xtheadvector = 0 ;
123
132
124
- if (!is_vector_supported ())
125
- SKIP (return , "Vector not supported" );
133
+ if (!is_vector_supported ()) {
134
+ if (is_xtheadvector_supported ())
135
+ xtheadvector = 1 ;
136
+ else
137
+ SKIP (return , "Vector not supported" );
138
+ }
126
139
127
140
/* Turn on next's vector explicitly and test no inherit */
128
141
flag = PR_RISCV_V_VSTATE_CTRL_ON << PR_RISCV_V_VSTATE_CTRL_NEXT_SHIFT ;
129
142
flag |= PR_RISCV_V_VSTATE_CTRL_INHERIT ;
130
143
expected = flag | PR_RISCV_V_VSTATE_CTRL_ON ;
131
144
132
- EXPECT_EQ (0 , test_and_compare_child (flag , expected , 0 ));
145
+ EXPECT_EQ (0 , test_and_compare_child (flag , expected , 0 , xtheadvector ));
133
146
}
134
147
135
148
TEST (vstate_on_inherit )
136
149
{
137
150
long flag , expected ;
151
+ int xtheadvector = 0 ;
138
152
139
- if (!is_vector_supported ())
140
- SKIP (return , "Vector not supported" );
153
+ if (!is_vector_supported ()) {
154
+ if (is_xtheadvector_supported ())
155
+ xtheadvector = 1 ;
156
+ else
157
+ SKIP (return , "Vector not supported" );
158
+ }
141
159
142
160
/* Turn on next's vector explicitly and test inherit */
143
161
flag = PR_RISCV_V_VSTATE_CTRL_ON << PR_RISCV_V_VSTATE_CTRL_NEXT_SHIFT ;
144
162
flag |= PR_RISCV_V_VSTATE_CTRL_INHERIT ;
145
163
expected = flag | PR_RISCV_V_VSTATE_CTRL_ON ;
146
164
147
- EXPECT_EQ (0 , test_and_compare_child (flag , expected , 1 ));
165
+ EXPECT_EQ (0 , test_and_compare_child (flag , expected , 1 , xtheadvector ));
148
166
}
149
167
150
168
TEST (vstate_off_inherit_no_nesting )
151
169
{
152
170
long flag , expected ;
171
+ int xtheadvector = 0 ;
153
172
154
- if (!is_vector_supported ())
155
- SKIP (return , "Vector not supported" );
156
-
173
+ if (!is_vector_supported ()) {
174
+ if (is_xtheadvector_supported ())
175
+ xtheadvector = 1 ;
176
+ else
177
+ SKIP (return , "Vector not supported" );
178
+ }
157
179
/* Turn off next's vector explicitly and test no inherit */
158
180
flag = PR_RISCV_V_VSTATE_CTRL_OFF << PR_RISCV_V_VSTATE_CTRL_NEXT_SHIFT ;
159
181
flag |= PR_RISCV_V_VSTATE_CTRL_INHERIT ;
160
182
expected = flag | PR_RISCV_V_VSTATE_CTRL_OFF ;
161
183
162
- EXPECT_EQ (0 , test_and_compare_child (flag , expected , 0 ));
184
+ EXPECT_EQ (0 , test_and_compare_child (flag , expected , 0 , xtheadvector ));
163
185
}
164
186
165
187
TEST (vstate_off_inherit )
166
188
{
167
189
long flag , expected ;
190
+ int xtheadvector = 0 ;
168
191
169
- if (!is_vector_supported ())
170
- SKIP (return , "Vector not supported" );
192
+ if (!is_vector_supported ()) {
193
+ if (is_xtheadvector_supported ())
194
+ xtheadvector = 1 ;
195
+ else
196
+ SKIP (return , "Vector not supported" );
197
+ }
171
198
172
199
/* Turn off next's vector explicitly and test inherit */
173
200
flag = PR_RISCV_V_VSTATE_CTRL_OFF << PR_RISCV_V_VSTATE_CTRL_NEXT_SHIFT ;
174
201
flag |= PR_RISCV_V_VSTATE_CTRL_INHERIT ;
175
202
expected = flag | PR_RISCV_V_VSTATE_CTRL_OFF ;
176
203
177
- EXPECT_EQ (0 , test_and_compare_child (flag , expected , 1 ));
204
+ EXPECT_EQ (0 , test_and_compare_child (flag , expected , 1 , xtheadvector ));
178
205
}
179
206
180
207
/* arguments should fail with EINVAL */
181
208
TEST (inval_set_control_1 )
182
209
{
183
210
int rc ;
184
211
185
- if (!is_vector_supported ())
212
+ if (!is_vector_supported () && ! is_xtheadvector_supported () )
186
213
SKIP (return , "Vector not supported" );
187
214
188
215
rc = prctl (PR_RISCV_V_SET_CONTROL , 0xff0 );
@@ -195,7 +222,7 @@ TEST(inval_set_control_2)
195
222
{
196
223
int rc ;
197
224
198
- if (!is_vector_supported ())
225
+ if (!is_vector_supported () && ! is_xtheadvector_supported () )
199
226
SKIP (return , "Vector not supported" );
200
227
201
228
rc = prctl (PR_RISCV_V_SET_CONTROL , 0x3 );
@@ -208,7 +235,7 @@ TEST(inval_set_control_3)
208
235
{
209
236
int rc ;
210
237
211
- if (!is_vector_supported ())
238
+ if (!is_vector_supported () && ! is_xtheadvector_supported () )
212
239
SKIP (return , "Vector not supported" );
213
240
214
241
rc = prctl (PR_RISCV_V_SET_CONTROL , 0xc );
0 commit comments