NetBSD Problem Report #55292

From www@netbsd.org  Sat May 23 15:56:14 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 7C4761A9241
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 23 May 2020 15:56:14 +0000 (UTC)
Message-Id: <20200523155613.698981A9244@mollari.NetBSD.org>
Date: Sat, 23 May 2020 15:56:13 +0000 (UTC)
From: n54@gmx.com
Reply-To: n54@gmx.com
To: gnats-bugs@NetBSD.org
Subject: Better fix for dealing with a misaligned PC on sparc [ptrace]
X-Send-Pr-Version: www-1.0

>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.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.