Skip to content

Commit 791d703

Browse files
brooniewilldeacon
authored andcommitted
kselftest/arm64: Log error codes in sve-ptrace
Use ksft_perror() to report error codes from failing ptrace operations to make it easier to interpret logs when things go wrong. Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Will Deacon <will@kernel.org>
1 parent a679e56 commit 791d703

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

tools/testing/selftests/arm64/fp/sve-ptrace.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,27 @@ static int do_child(void)
9595
static int get_fpsimd(pid_t pid, struct user_fpsimd_state *fpsimd)
9696
{
9797
struct iovec iov;
98+
int ret;
9899

99100
iov.iov_base = fpsimd;
100101
iov.iov_len = sizeof(*fpsimd);
101-
return ptrace(PTRACE_GETREGSET, pid, NT_PRFPREG, &iov);
102+
ret = ptrace(PTRACE_GETREGSET, pid, NT_PRFPREG, &iov);
103+
if (ret == -1)
104+
ksft_perror("ptrace(PTRACE_GETREGSET)");
105+
return ret;
102106
}
103107

104108
static int set_fpsimd(pid_t pid, struct user_fpsimd_state *fpsimd)
105109
{
106110
struct iovec iov;
111+
int ret;
107112

108113
iov.iov_base = fpsimd;
109114
iov.iov_len = sizeof(*fpsimd);
110-
return ptrace(PTRACE_SETREGSET, pid, NT_PRFPREG, &iov);
115+
ret = ptrace(PTRACE_SETREGSET, pid, NT_PRFPREG, &iov);
116+
if (ret == -1)
117+
ksft_perror("ptrace(PTRACE_SETREGSET)");
118+
return ret;
111119
}
112120

113121
static struct user_sve_header *get_sve(pid_t pid, const struct vec_type *type,
@@ -117,6 +125,7 @@ static struct user_sve_header *get_sve(pid_t pid, const struct vec_type *type,
117125
void *p;
118126
size_t sz = sizeof *sve;
119127
struct iovec iov;
128+
int ret;
120129

121130
while (1) {
122131
if (*size < sz) {
@@ -132,8 +141,11 @@ static struct user_sve_header *get_sve(pid_t pid, const struct vec_type *type,
132141

133142
iov.iov_base = *buf;
134143
iov.iov_len = sz;
135-
if (ptrace(PTRACE_GETREGSET, pid, type->regset, &iov))
144+
ret = ptrace(PTRACE_GETREGSET, pid, type->regset, &iov);
145+
if (ret) {
146+
ksft_perror("ptrace(PTRACE_GETREGSET)");
136147
goto error;
148+
}
137149

138150
sve = *buf;
139151
if (sve->size <= sz)
@@ -152,10 +164,14 @@ static int set_sve(pid_t pid, const struct vec_type *type,
152164
const struct user_sve_header *sve)
153165
{
154166
struct iovec iov;
167+
int ret;
155168

156169
iov.iov_base = (void *)sve;
157170
iov.iov_len = sve->size;
158-
return ptrace(PTRACE_SETREGSET, pid, type->regset, &iov);
171+
ret = ptrace(PTRACE_SETREGSET, pid, type->regset, &iov);
172+
if (ret == -1)
173+
ksft_perror("ptrace(PTRACE_SETREGSET)");
174+
return ret;
159175
}
160176

161177
/* Validate setting and getting the inherit flag */

0 commit comments

Comments
 (0)