Bug 252867 - ptrace_test:ptrace__PT_STEP_with_signal test failed
Summary: ptrace_test:ptrace__PT_STEP_with_signal test failed
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: tests (show other bugs)
Version: CURRENT
Hardware: powerpc Any
: --- Affects Some People
Assignee: freebsd-testing (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-20 19:34 UTC by fernando.valle
Modified: 2021-07-06 16:00 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description fernando.valle 2021-01-20 19:34:25 UTC
The ptrace_test:ptrace__PT_STEP_with_signal test fails to run on powerpc64 architecture:

cd /usr/tests/sys/kern/ && kyua test ptrace_test:ptrace__PT_STEP_with_signal

ptrace_test:ptrace__PT_STEP_with_signal  ->  failed: /usr/src/tests/sys/kern/ptrace_test.c:3552: WSTOPSIG(status) == SIGABRT not met  [0.021s]

This is happening on powerpc64. In amd64 the test runs successfully.

------------
uname -a:
FreeBSD fbsd13-4 13.0-ALPHA1 FreeBSD 13.0-ALPHA1 #0 main-c255938-g7ae27c2d6c4: Thu Jan 14 07:49:56 UTC 2021     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/powerpc.powerpc64/sys/GENERIC64  powerpc
Comment 1 Mark Johnston freebsd_committer freebsd_triage 2021-07-06 15:10:57 UTC
Seems to fail on arm64 as well.
Comment 2 Mark Johnston freebsd_committer freebsd_triage 2021-07-06 16:00:24 UTC
The problem on arm64 is that we don't disable single-stepping before executing a signal handler.  I suspect the problem is the same on powerpc.  This hack fixes the problem for me:

diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index 25f0a108311e..7d7f78760381 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -896,6 +896,8 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
 
        tf->tf_elr = (register_t)catcher;
        tf->tf_sp = (register_t)fp;
+       tf->tf_spsr &= ~PSR_SS;
+       WRITE_SPECIALREG(mdscr_el1, READ_SPECIALREG(mdscr_el1) & ~DBG_MDSCR_SS);
        sysent = p->p_sysent;
        if (sysent->sv_sigcode_base != 0)
                tf->tf_lr = (register_t)sysent->sv_sigcode_base;