Skip to content

Commit 9b28388

Browse files
brooniewilldeacon
authored andcommitted
kselftest/arm64: Print ASCII version of unknown signal frame magic values
The signal magic values are supposed to be allocated as somewhat meaningful ASCII so if we encounter a bad magic value print the any alphanumeric characters we find in it as well as the hex value to aid debuggability. Signed-off-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 2004734 commit 9b28388

File tree

1 file changed

+17
-4
lines changed
  • tools/testing/selftests/arm64/signal/testcases

1 file changed

+17
-4
lines changed

tools/testing/selftests/arm64/signal/testcases/testcases.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/* Copyright (C) 2019 ARM Limited */
3+
4+
#include <ctype.h>
5+
#include <string.h>
6+
37
#include "testcases.h"
48

59
struct _aarch64_ctx *get_header(struct _aarch64_ctx *head, uint32_t magic,
@@ -109,14 +113,15 @@ bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err)
109113
bool terminated = false;
110114
size_t offs = 0;
111115
int flags = 0;
112-
int new_flags;
116+
int new_flags, i;
113117
struct extra_context *extra = NULL;
114118
struct sve_context *sve = NULL;
115119
struct za_context *za = NULL;
116120
struct _aarch64_ctx *head =
117121
(struct _aarch64_ctx *)uc->uc_mcontext.__reserved;
118122
void *extra_data = NULL;
119123
size_t extra_sz = 0;
124+
char magic[4];
120125

121126
if (!err)
122127
return false;
@@ -194,11 +199,19 @@ bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err)
194199
/*
195200
* A still unknown Magic: potentially freshly added
196201
* to the Kernel code and still unknown to the
197-
* tests.
202+
* tests. Magic numbers are supposed to be allocated
203+
* as somewhat meaningful ASCII strings so try to
204+
* print as such as well as the raw number.
198205
*/
206+
memcpy(magic, &head->magic, sizeof(magic));
207+
for (i = 0; i < sizeof(magic); i++)
208+
if (!isalnum(magic[i]))
209+
magic[i] = '?';
210+
199211
fprintf(stdout,
200-
"SKIP Unknown MAGIC: 0x%X - Is KSFT arm64/signal up to date ?\n",
201-
head->magic);
212+
"SKIP Unknown MAGIC: 0x%X (%c%c%c%c) - Is KSFT arm64/signal up to date ?\n",
213+
head->magic,
214+
magic[3], magic[2], magic[1], magic[0]);
202215
break;
203216
}
204217

0 commit comments

Comments
 (0)