* [PATCH v1 0/4] Improve ptrace selftest usability
@ 2023-07-25 0:58 Benjamin Gray
2023-07-25 0:58 ` [PATCH v1 1/4] Documentation/powerpc: Fix ptrace request names Benjamin Gray
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Benjamin Gray @ 2023-07-25 0:58 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Benjamin Gray
While trying to test changes to the breakpoint implementation in the kernel, I
tried to run the ptrace tests and met many unexplained skips and failures.
This series addresses the pain points of trying to run these tests and learn
what they are doing.
Benjamin Gray (4):
Documentation/powerpc: Fix ptrace request names
selftests/powerpc/ptrace: Explain why tests are skipped
selftests/powerpc/ptrace: Fix typo in pid_max search error
selftests/powerpc/ptrace: Declare test temporary variables as volatile
Documentation/powerpc/ptrace.rst | 8 +++---
.../testing/selftests/powerpc/ptrace/child.h | 4 +--
.../selftests/powerpc/ptrace/core-pkey.c | 2 +-
.../selftests/powerpc/ptrace/perf-hwbreak.c | 2 +-
.../selftests/powerpc/ptrace/ptrace-hwbreak.c | 26 +++++++++----------
.../powerpc/ptrace/ptrace-perf-hwbreak.c | 6 ++---
.../selftests/powerpc/ptrace/ptrace-pkey.c | 2 +-
.../selftests/powerpc/ptrace/ptrace-tar.c | 2 +-
.../selftests/powerpc/ptrace/ptrace-tm-gpr.c | 4 +--
.../powerpc/ptrace/ptrace-tm-spd-gpr.c | 4 +--
.../powerpc/ptrace/ptrace-tm-spd-tar.c | 4 +--
.../powerpc/ptrace/ptrace-tm-spd-vsx.c | 4 +--
.../selftests/powerpc/ptrace/ptrace-tm-spr.c | 4 +--
.../selftests/powerpc/ptrace/ptrace-tm-tar.c | 4 +--
.../selftests/powerpc/ptrace/ptrace-tm-vsx.c | 4 +--
.../selftests/powerpc/ptrace/ptrace-vsx.c | 2 +-
16 files changed, 41 insertions(+), 41 deletions(-)
--
2.41.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v1 1/4] Documentation/powerpc: Fix ptrace request names
2023-07-25 0:58 [PATCH v1 0/4] Improve ptrace selftest usability Benjamin Gray
@ 2023-07-25 0:58 ` Benjamin Gray
2023-07-25 0:58 ` [PATCH v1 2/4] selftests/powerpc/ptrace: Explain why tests are skipped Benjamin Gray
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Benjamin Gray @ 2023-07-25 0:58 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Benjamin Gray
The documented ptrace request names are currently wrong/incomplete.
Fix this to improve correctness and searchability.
Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
---
Documentation/powerpc/ptrace.rst | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Documentation/powerpc/ptrace.rst b/Documentation/powerpc/ptrace.rst
index 77725d69eb4a..5629edf4d56e 100644
--- a/Documentation/powerpc/ptrace.rst
+++ b/Documentation/powerpc/ptrace.rst
@@ -15,7 +15,7 @@ that's extendable and that covers both BookE and server processors, so
that GDB doesn't need to special-case each of them. We added the
following 3 new ptrace requests.
-1. PTRACE_PPC_GETHWDEBUGINFO
+1. PPC_PTRACE_GETHWDBGINFO
============================
Query for GDB to discover the hardware debug features. The main info to
@@ -48,7 +48,7 @@ features will have bits indicating whether there is support for::
#define PPC_DEBUG_FEATURE_DATA_BP_DAWR 0x10
#define PPC_DEBUG_FEATURE_DATA_BP_ARCH_31 0x20
-2. PTRACE_SETHWDEBUG
+2. PPC_PTRACE_SETHWDEBUG
Sets a hardware breakpoint or watchpoint, according to the provided structure::
@@ -88,7 +88,7 @@ that the BookE supports. COMEFROM breakpoints available in server processors
are not contemplated, but that is out of the scope of this work.
ptrace will return an integer (handle) uniquely identifying the breakpoint or
-watchpoint just created. This integer will be used in the PTRACE_DELHWDEBUG
+watchpoint just created. This integer will be used in the PPC_PTRACE_DELHWDEBUG
request to ask for its removal. Return -ENOSPC if the requested breakpoint
can't be allocated on the registers.
@@ -150,7 +150,7 @@ Some examples of using the structure to:
p.addr2 = (uint64_t) end_range;
p.condition_value = 0;
-3. PTRACE_DELHWDEBUG
+3. PPC_PTRACE_DELHWDEBUG
Takes an integer which identifies an existing breakpoint or watchpoint
(i.e., the value returned from PTRACE_SETHWDEBUG), and deletes the
--
2.41.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v1 2/4] selftests/powerpc/ptrace: Explain why tests are skipped
2023-07-25 0:58 [PATCH v1 0/4] Improve ptrace selftest usability Benjamin Gray
2023-07-25 0:58 ` [PATCH v1 1/4] Documentation/powerpc: Fix ptrace request names Benjamin Gray
@ 2023-07-25 0:58 ` Benjamin Gray
2023-07-25 0:58 ` [PATCH v1 3/4] selftests/powerpc/ptrace: Fix typo in pid_max search error Benjamin Gray
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Benjamin Gray @ 2023-07-25 0:58 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Benjamin Gray
Many tests require specific hardware features/configurations that a
typical machine might not have. As a result, it's common to see a test
is skipped. But it is tedious to find out why a test is skipped
when all it gives is the file location of the skip macro.
Convert SKIP_IF() to SKIP_IF_MSG(), with appropriate descriptions of why
the test is being skipped. This gives a general idea of why a test is
skipped, which can be looked into further if it doesn't make sense.
Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
---
tools/testing/selftests/powerpc/ptrace/child.h | 4 ++--
tools/testing/selftests/powerpc/ptrace/core-pkey.c | 2 +-
tools/testing/selftests/powerpc/ptrace/perf-hwbreak.c | 2 +-
tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c | 2 +-
tools/testing/selftests/powerpc/ptrace/ptrace-perf-hwbreak.c | 4 ++--
tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c | 2 +-
tools/testing/selftests/powerpc/ptrace/ptrace-tar.c | 2 +-
tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c | 4 ++--
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-gpr.c | 4 ++--
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-tar.c | 4 ++--
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-vsx.c | 4 ++--
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c | 4 ++--
tools/testing/selftests/powerpc/ptrace/ptrace-tm-tar.c | 4 ++--
tools/testing/selftests/powerpc/ptrace/ptrace-tm-vsx.c | 4 ++--
tools/testing/selftests/powerpc/ptrace/ptrace-vsx.c | 2 +-
15 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/tools/testing/selftests/powerpc/ptrace/child.h b/tools/testing/selftests/powerpc/ptrace/child.h
index d7275b7b33dc..df62ff0735f7 100644
--- a/tools/testing/selftests/powerpc/ptrace/child.h
+++ b/tools/testing/selftests/powerpc/ptrace/child.h
@@ -48,12 +48,12 @@ struct child_sync {
} \
} while (0)
-#define PARENT_SKIP_IF_UNSUPPORTED(x, sync) \
+#define PARENT_SKIP_IF_UNSUPPORTED(x, sync, msg) \
do { \
if ((x) == -1 && (errno == ENODEV || errno == EINVAL)) { \
(sync)->parent_gave_up = true; \
prod_child(sync); \
- SKIP_IF(1); \
+ SKIP_IF_MSG(1, msg); \
} \
} while (0)
diff --git a/tools/testing/selftests/powerpc/ptrace/core-pkey.c b/tools/testing/selftests/powerpc/ptrace/core-pkey.c
index f6f8596ce8e1..f6da4cb30cd6 100644
--- a/tools/testing/selftests/powerpc/ptrace/core-pkey.c
+++ b/tools/testing/selftests/powerpc/ptrace/core-pkey.c
@@ -266,7 +266,7 @@ static int parent(struct shared_info *info, pid_t pid)
* to the child.
*/
ret = ptrace_read_regs(pid, NT_PPC_PKEY, regs, 3);
- PARENT_SKIP_IF_UNSUPPORTED(ret, &info->child_sync);
+ PARENT_SKIP_IF_UNSUPPORTED(ret, &info->child_sync, "PKEYs not supported");
PARENT_FAIL_IF(ret, &info->child_sync);
info->amr = regs[0];
diff --git a/tools/testing/selftests/powerpc/ptrace/perf-hwbreak.c b/tools/testing/selftests/powerpc/ptrace/perf-hwbreak.c
index f75739bbad28..e374c6b7ace6 100644
--- a/tools/testing/selftests/powerpc/ptrace/perf-hwbreak.c
+++ b/tools/testing/selftests/powerpc/ptrace/perf-hwbreak.c
@@ -884,7 +884,7 @@ static int perf_hwbreak(void)
{
srand ( time(NULL) );
- SKIP_IF(!perf_breakpoint_supported());
+ SKIP_IF_MSG(!perf_breakpoint_supported(), "Perf breakpoints not supported");
return runtest();
}
diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c b/tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c
index 1345e9b9af0f..a16239277a6f 100644
--- a/tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c
+++ b/tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c
@@ -603,7 +603,7 @@ static int ptrace_hwbreak(void)
wait(NULL);
get_dbginfo(child_pid, &dbginfo);
- SKIP_IF(dbginfo.num_data_bps == 0);
+ SKIP_IF_MSG(dbginfo.num_data_bps == 0, "No data breakpoints present");
dawr = dawr_present(&dbginfo);
run_tests(child_pid, &dbginfo, dawr);
diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-perf-hwbreak.c b/tools/testing/selftests/powerpc/ptrace/ptrace-perf-hwbreak.c
index 3344e74a97b4..16c653600124 100644
--- a/tools/testing/selftests/powerpc/ptrace/ptrace-perf-hwbreak.c
+++ b/tools/testing/selftests/powerpc/ptrace/ptrace-perf-hwbreak.c
@@ -641,10 +641,10 @@ static int ptrace_perf_hwbreak(void)
wait(NULL); /* <-- child (SIGUSR1) */
get_dbginfo(child_pid, &dbginfo);
- SKIP_IF(dbginfo.num_data_bps <= 1);
+ SKIP_IF_MSG(dbginfo.num_data_bps <= 1, "Not enough data watchpoints (need at least 2)");
ret = perf_cpu_event_open(0, (__u64)perf_data1, sizeof(*perf_data1));
- SKIP_IF(ret < 0);
+ SKIP_IF_MSG(ret < 0, "perf_event_open syscall failed");
close(ret);
ret = test(child_pid);
diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c b/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c
index bc454f899124..d89474377f11 100644
--- a/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c
+++ b/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c
@@ -192,7 +192,7 @@ static int parent(struct shared_info *info, pid_t pid)
* to the child.
*/
ret = ptrace_read_regs(pid, NT_PPC_PKEY, regs, 3);
- PARENT_SKIP_IF_UNSUPPORTED(ret, &info->child_sync);
+ PARENT_SKIP_IF_UNSUPPORTED(ret, &info->child_sync, "PKEYs not supported");
PARENT_FAIL_IF(ret, &info->child_sync);
info->amr1 = info->amr2 = regs[0];
diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-tar.c b/tools/testing/selftests/powerpc/ptrace/ptrace-tar.c
index 4436ca9d3caf..14726c77a6ce 100644
--- a/tools/testing/selftests/powerpc/ptrace/ptrace-tar.c
+++ b/tools/testing/selftests/powerpc/ptrace/ptrace-tar.c
@@ -79,7 +79,7 @@ int ptrace_tar(void)
int ret, status;
// TAR was added in v2.07
- SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_2_07));
+ SKIP_IF_MSG(!have_hwcap2(PPC_FEATURE2_ARCH_2_07), "TAR requires ISA 2.07 compatible hardware");
shm_id = shmget(IPC_PRIVATE, sizeof(int) * 3, 0777|IPC_CREAT);
pid = fork();
diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c b/tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c
index 5dc152b162df..7c70d62587c2 100644
--- a/tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c
+++ b/tools/testing/selftests/powerpc/ptrace/ptrace-tm-gpr.c
@@ -112,8 +112,8 @@ int ptrace_tm_gpr(void)
pid_t pid;
int ret, status;
- SKIP_IF(!have_htm());
- SKIP_IF(htm_is_synthetic());
+ SKIP_IF_MSG(!have_htm(), "Don't have transactional memory");
+ SKIP_IF_MSG(htm_is_synthetic(), "Transactional memory is synthetic");
shm_id = shmget(IPC_PRIVATE, sizeof(int) * 2, 0777|IPC_CREAT);
pid = fork();
if (pid < 0) {
diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-gpr.c b/tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-gpr.c
index 458cc1a70ccf..6c17ed099969 100644
--- a/tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-gpr.c
+++ b/tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-gpr.c
@@ -118,8 +118,8 @@ int ptrace_tm_spd_gpr(void)
pid_t pid;
int ret, status;
- SKIP_IF(!have_htm());
- SKIP_IF(htm_is_synthetic());
+ SKIP_IF_MSG(!have_htm(), "Don't have transactional memory");
+ SKIP_IF_MSG(htm_is_synthetic(), "Transactional memory is synthetic");
shm_id = shmget(IPC_PRIVATE, sizeof(int) * 3, 0777|IPC_CREAT);
pid = fork();
if (pid < 0) {
diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-tar.c b/tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-tar.c
index e112a34fbe59..afd8dc2e2097 100644
--- a/tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-tar.c
+++ b/tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-tar.c
@@ -128,8 +128,8 @@ int ptrace_tm_spd_tar(void)
pid_t pid;
int ret, status;
- SKIP_IF(!have_htm());
- SKIP_IF(htm_is_synthetic());
+ SKIP_IF_MSG(!have_htm(), "Don't have transactional memory");
+ SKIP_IF_MSG(htm_is_synthetic(), "Transactional memory is synthetic");
shm_id = shmget(IPC_PRIVATE, sizeof(int) * 3, 0777|IPC_CREAT);
pid = fork();
if (pid == 0)
diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-vsx.c b/tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-vsx.c
index 40133d49fe39..14d2fac8f237 100644
--- a/tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-vsx.c
+++ b/tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-vsx.c
@@ -128,8 +128,8 @@ int ptrace_tm_spd_vsx(void)
pid_t pid;
int ret, status, i;
- SKIP_IF(!have_htm());
- SKIP_IF(htm_is_synthetic());
+ SKIP_IF_MSG(!have_htm(), "Don't have transactional memory");
+ SKIP_IF_MSG(htm_is_synthetic(), "Transactional memory is synthetic");
shm_id = shmget(IPC_PRIVATE, sizeof(int) * 3, 0777|IPC_CREAT);
for (i = 0; i < 128; i++) {
diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c b/tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c
index 880ba6a29a48..e64cdb04cecf 100644
--- a/tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c
+++ b/tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c
@@ -113,8 +113,8 @@ int ptrace_tm_spr(void)
pid_t pid;
int ret, status;
- SKIP_IF(!have_htm());
- SKIP_IF(htm_is_synthetic());
+ SKIP_IF_MSG(!have_htm(), "Don't have transactional memory");
+ SKIP_IF_MSG(htm_is_synthetic(), "Transactional memory is synthetic");
shm_id = shmget(IPC_PRIVATE, sizeof(struct shared), 0777|IPC_CREAT);
shm_id1 = shmget(IPC_PRIVATE, sizeof(int), 0777|IPC_CREAT);
pid = fork();
diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-tm-tar.c b/tools/testing/selftests/powerpc/ptrace/ptrace-tm-tar.c
index d0db6df0f0ea..3963d4b0429f 100644
--- a/tools/testing/selftests/powerpc/ptrace/ptrace-tm-tar.c
+++ b/tools/testing/selftests/powerpc/ptrace/ptrace-tm-tar.c
@@ -116,8 +116,8 @@ int ptrace_tm_tar(void)
pid_t pid;
int ret, status;
- SKIP_IF(!have_htm());
- SKIP_IF(htm_is_synthetic());
+ SKIP_IF_MSG(!have_htm(), "Don't have transactional memory");
+ SKIP_IF_MSG(htm_is_synthetic(), "Transactional memory is synthetic");
shm_id = shmget(IPC_PRIVATE, sizeof(int) * 2, 0777|IPC_CREAT);
pid = fork();
if (pid == 0)
diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-tm-vsx.c b/tools/testing/selftests/powerpc/ptrace/ptrace-tm-vsx.c
index 4f05ce4fd282..8c925d734a72 100644
--- a/tools/testing/selftests/powerpc/ptrace/ptrace-tm-vsx.c
+++ b/tools/testing/selftests/powerpc/ptrace/ptrace-tm-vsx.c
@@ -112,8 +112,8 @@ int ptrace_tm_vsx(void)
pid_t pid;
int ret, status, i;
- SKIP_IF(!have_htm());
- SKIP_IF(htm_is_synthetic());
+ SKIP_IF_MSG(!have_htm(), "Don't have transactional memory");
+ SKIP_IF_MSG(htm_is_synthetic(), "Transactional memory is synthetic");
shm_id = shmget(IPC_PRIVATE, sizeof(int) * 2, 0777|IPC_CREAT);
for (i = 0; i < 128; i++) {
diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-vsx.c b/tools/testing/selftests/powerpc/ptrace/ptrace-vsx.c
index cb9875f764ca..11bc624574fe 100644
--- a/tools/testing/selftests/powerpc/ptrace/ptrace-vsx.c
+++ b/tools/testing/selftests/powerpc/ptrace/ptrace-vsx.c
@@ -61,7 +61,7 @@ int ptrace_vsx(void)
pid_t pid;
int ret, status, i;
- SKIP_IF(!have_hwcap(PPC_FEATURE_HAS_VSX));
+ SKIP_IF_MSG(!have_hwcap(PPC_FEATURE_HAS_VSX), "Don't have VSX");
shm_id = shmget(IPC_PRIVATE, sizeof(int) * 2, 0777|IPC_CREAT);
--
2.41.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v1 3/4] selftests/powerpc/ptrace: Fix typo in pid_max search error
2023-07-25 0:58 [PATCH v1 0/4] Improve ptrace selftest usability Benjamin Gray
2023-07-25 0:58 ` [PATCH v1 1/4] Documentation/powerpc: Fix ptrace request names Benjamin Gray
2023-07-25 0:58 ` [PATCH v1 2/4] selftests/powerpc/ptrace: Explain why tests are skipped Benjamin Gray
@ 2023-07-25 0:58 ` Benjamin Gray
2023-07-25 0:58 ` [PATCH v1 4/4] selftests/powerpc/ptrace: Declare test temporary variables as volatile Benjamin Gray
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Benjamin Gray @ 2023-07-25 0:58 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Benjamin Gray
pid_max_addr() searches for the 'pid_max' symbol in /proc/kallsyms, and
prints an error if it cannot find it. The error message has a typo,
calling it pix_max.
Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
---
tools/testing/selftests/powerpc/ptrace/ptrace-perf-hwbreak.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-perf-hwbreak.c b/tools/testing/selftests/powerpc/ptrace/ptrace-perf-hwbreak.c
index 16c653600124..d8a9e95fc03d 100644
--- a/tools/testing/selftests/powerpc/ptrace/ptrace-perf-hwbreak.c
+++ b/tools/testing/selftests/powerpc/ptrace/ptrace-perf-hwbreak.c
@@ -46,7 +46,7 @@ static unsigned long pid_max_addr(void)
return strtoul(addr, &c, 16);
}
fclose(fp);
- printf("Could not find pix_max. Exiting..\n");
+ printf("Could not find pid_max. Exiting..\n");
exit(EXIT_FAILURE);
return -1;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v1 4/4] selftests/powerpc/ptrace: Declare test temporary variables as volatile
2023-07-25 0:58 [PATCH v1 0/4] Improve ptrace selftest usability Benjamin Gray
` (2 preceding siblings ...)
2023-07-25 0:58 ` [PATCH v1 3/4] selftests/powerpc/ptrace: Fix typo in pid_max search error Benjamin Gray
@ 2023-07-25 0:58 ` Benjamin Gray
2023-08-10 6:02 ` (subset) [PATCH v1 0/4] Improve ptrace selftest usability Michael Ellerman
2023-08-23 11:55 ` Michael Ellerman
5 siblings, 0 replies; 7+ messages in thread
From: Benjamin Gray @ 2023-07-25 0:58 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Benjamin Gray
While the target is volatile, the temporary variables used to access the
target cast away the volatile. This is undefined behaviour, and a
compiler may optimise away/reorder these accesses, breaking the test.
This was observed with GCC 13.1.1, but it can be difficult to reproduce
because of the dependency on compiler behaviour.
Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
---
.../selftests/powerpc/ptrace/ptrace-hwbreak.c | 24 +++++++++----------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c b/tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c
index a16239277a6f..75d30d61ab0e 100644
--- a/tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c
+++ b/tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c
@@ -64,26 +64,26 @@ static bool dawr_present(struct ppc_debug_info *dbginfo)
static void write_var(int len)
{
- __u8 *pcvar;
- __u16 *psvar;
- __u32 *pivar;
- __u64 *plvar;
+ volatile __u8 *pcvar;
+ volatile __u16 *psvar;
+ volatile __u32 *pivar;
+ volatile __u64 *plvar;
switch (len) {
case 1:
- pcvar = (__u8 *)&glvar;
+ pcvar = (volatile __u8 *)&glvar;
*pcvar = 0xff;
break;
case 2:
- psvar = (__u16 *)&glvar;
+ psvar = (volatile __u16 *)&glvar;
*psvar = 0xffff;
break;
case 4:
- pivar = (__u32 *)&glvar;
+ pivar = (volatile __u32 *)&glvar;
*pivar = 0xffffffff;
break;
case 8:
- plvar = (__u64 *)&glvar;
+ plvar = (volatile __u64 *)&glvar;
*plvar = 0xffffffffffffffffLL;
break;
}
@@ -98,16 +98,16 @@ static void read_var(int len)
switch (len) {
case 1:
- cvar = (__u8)glvar;
+ cvar = (volatile __u8)glvar;
break;
case 2:
- svar = (__u16)glvar;
+ svar = (volatile __u16)glvar;
break;
case 4:
- ivar = (__u32)glvar;
+ ivar = (volatile __u32)glvar;
break;
case 8:
- lvar = (__u64)glvar;
+ lvar = (volatile __u64)glvar;
break;
}
}
--
2.41.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: (subset) [PATCH v1 0/4] Improve ptrace selftest usability
2023-07-25 0:58 [PATCH v1 0/4] Improve ptrace selftest usability Benjamin Gray
` (3 preceding siblings ...)
2023-07-25 0:58 ` [PATCH v1 4/4] selftests/powerpc/ptrace: Declare test temporary variables as volatile Benjamin Gray
@ 2023-08-10 6:02 ` Michael Ellerman
2023-08-23 11:55 ` Michael Ellerman
5 siblings, 0 replies; 7+ messages in thread
From: Michael Ellerman @ 2023-08-10 6:02 UTC (permalink / raw)
To: linuxppc-dev, Benjamin Gray
On Tue, 25 Jul 2023 10:58:37 +1000, Benjamin Gray wrote:
> While trying to test changes to the breakpoint implementation in the kernel, I
> tried to run the ptrace tests and met many unexplained skips and failures.
>
> This series addresses the pain points of trying to run these tests and learn
> what they are doing.
>
> Benjamin Gray (4):
> Documentation/powerpc: Fix ptrace request names
> selftests/powerpc/ptrace: Explain why tests are skipped
> selftests/powerpc/ptrace: Fix typo in pid_max search error
> selftests/powerpc/ptrace: Declare test temporary variables as volatile
>
> [...]
Applied to powerpc/next.
[2/4] selftests/powerpc/ptrace: Explain why tests are skipped
https://git.kernel.org/powerpc/c/68877ff20a7f4f773069784cfe4f6fe9c7b9a841
[3/4] selftests/powerpc/ptrace: Fix typo in pid_max search error
https://git.kernel.org/powerpc/c/fc6732a8556c1099b89f4777a96bd6a1ae5a4378
[4/4] selftests/powerpc/ptrace: Declare test temporary variables as volatile
https://git.kernel.org/powerpc/c/c3062ede9927053754ba27b280afe00b9b31b37a
cheers
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: (subset) [PATCH v1 0/4] Improve ptrace selftest usability
2023-07-25 0:58 [PATCH v1 0/4] Improve ptrace selftest usability Benjamin Gray
` (4 preceding siblings ...)
2023-08-10 6:02 ` (subset) [PATCH v1 0/4] Improve ptrace selftest usability Michael Ellerman
@ 2023-08-23 11:55 ` Michael Ellerman
5 siblings, 0 replies; 7+ messages in thread
From: Michael Ellerman @ 2023-08-23 11:55 UTC (permalink / raw)
To: linuxppc-dev, Benjamin Gray
On Tue, 25 Jul 2023 10:58:37 +1000, Benjamin Gray wrote:
> While trying to test changes to the breakpoint implementation in the kernel, I
> tried to run the ptrace tests and met many unexplained skips and failures.
>
> This series addresses the pain points of trying to run these tests and learn
> what they are doing.
>
> Benjamin Gray (4):
> Documentation/powerpc: Fix ptrace request names
> selftests/powerpc/ptrace: Explain why tests are skipped
> selftests/powerpc/ptrace: Fix typo in pid_max search error
> selftests/powerpc/ptrace: Declare test temporary variables as volatile
>
> [...]
Patch 1 applied to powerpc/next.
[1/4] Documentation/powerpc: Fix ptrace request names
https://git.kernel.org/powerpc/c/0e216fa576e1cdea3913fe82b7283fdfb58c5c07
cheers
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-08-23 12:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-25 0:58 [PATCH v1 0/4] Improve ptrace selftest usability Benjamin Gray
2023-07-25 0:58 ` [PATCH v1 1/4] Documentation/powerpc: Fix ptrace request names Benjamin Gray
2023-07-25 0:58 ` [PATCH v1 2/4] selftests/powerpc/ptrace: Explain why tests are skipped Benjamin Gray
2023-07-25 0:58 ` [PATCH v1 3/4] selftests/powerpc/ptrace: Fix typo in pid_max search error Benjamin Gray
2023-07-25 0:58 ` [PATCH v1 4/4] selftests/powerpc/ptrace: Declare test temporary variables as volatile Benjamin Gray
2023-08-10 6:02 ` (subset) [PATCH v1 0/4] Improve ptrace selftest usability Michael Ellerman
2023-08-23 11:55 ` Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).