NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

port-sparc/55292: Better fix for dealing with a misaligned PC on sparc [ptrace]



>Number:         55292
>Category:       port-sparc
>Synopsis:       Better fix for dealing with a misaligned PC on sparc [ptrace]
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    port-sparc-maintainer
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat May 23 16:00:00 +0000 2020
>Originator:     Kamil Rytarowski
>Release:        NetBSD 9.99.63
>Organization:
The NetBSD Foundation, Inc.
>Environment:
NetBSD 9.99.63 sparc (32-bit)
>Description:
	Running the program below wil crash the machine.  The message on the
	console after the crash reads:

	Watchdog Reset
	Level 6 interrupt
	Type  help  for more information
	ok 

	At that point, the output of .registers seems to suggest that the
	kernel crashed at the end of the function winuf_invalid, in
	locore.s, just when executing the RETT, i.e. upon returning to
	user space.  It looks as if the misalligned program counter causes
	a double trap which the kernel cannot handle.


A workaround to the problem is returning EINVAL from ptrace(2) for setting an unaligned PC. This change has been landed the NetBSD sources in CVS src/sys/arch/sparc/sparc/process_machdep.c r1.20.

The workaround was picked from OpenBSD.

mlelstv@ suggested that this could be fixed differently in the code returning to user and checking for correctly aligned PC there.

NetBSD kernel backtrace is documented in http://gnats.netbsd.org/54734

 access_regs_set_unaligned_pc_0x1: [0.225264s] Passed.
 access_regs_set_unaligned_pc_0x3: qemu: fatal: Trap 0x07 while interrupts disabled, Error state
 pc: f00095b8  npc: f00095bc
 %g0-7: 00000000 00000d3e 30beb38e 30800000 007ace38 00028f74 00000000 ede4ab58
 %o0-7: f0002000 f895ffb0 edd425d4 f045a8f0 f045a8e0 f14058c0 f895ff50 f0008834
 %l0-7: 04400082 00028f77 00028f7b 00000fc1 00000008 00000002 f895e000 00000528
 %i0-7: 00000000 00000000 00000000 00000000 edd98b58 00000000 effff528 00028f6c
 %f00:  ffffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffff
 %f08:  ffffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffff
 %f16:  ffffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffff
 %f24:  ffffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffff
 psr: 04400082 (icc: -Z-- SPE: S--) wim: 00000010
 fsr: 0f800000 y: 0e66726b

 [1]   Abort trap (core dumped) qemu-system-sparc -m 128 -drive file=/ccd/spar...

>How-To-Repeat:
Revert src/sys/arch/sparc/sparc/process_machdep.c r.1.20.
Run ATF t_ptrace* regression tests.
See panic.
>Fix:
Not known.



Home | Main Index | Thread Index | Old Index