NetBSD Problem Report #1430

From gnats  Fri Sep  1 01:54:23 1995
Received: from slip-6-13.ots.utexas.edu (slip-6-13.ots.utexas.edu [128.83.204.93]) by sun-lamp.pc.cs.cmu.edu (8.6.11/8.6.10) with ESMTP id BAA23084 for <gnats-bugs@gnats.netbsd.org>; Fri, 1 Sep 1995 01:54:20 -0400
Message-Id: <199509010544.AAA18134@slip-6-13.ots.utexas.edu>
Date: Fri, 1 Sep 1995 00:44:00 -0500
From: VaX#n8 <vax@ccwf.cc.utexas.edu>
Reply-To: vax@carolina.rr.com (vax@paranoia.com)
To: gnats-bugs@gnats.netbsd.org
Subject: Address Fault Patch (replaces 851)
X-Send-Pr-Version: 3.2

>Number:         1430
>Category:       port-i386
>Synopsis:       Address Fault Patch (replaces 851)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    perry
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 01 02:05:05 +0000 1995
>Closed-Date:    Tue Apr 08 02:20:30 +0000 2003
>Last-Modified:  Tue Apr 08 02:20:30 +0000 2003
>Originator:     VaX#n8
>Release:        19950830
>Organization:
University of Texas at Austin
>Environment:

System: NetBSD slip-6-13.ots.utexas.edu 1.0A NetBSD 1.0A (LINKDEAD) #4: Thu Aug 31 03:00:42 CDT 1995 bashroot@slip-30-1.ots.utexas.edu:/usr/src/sys/arch/i386/compile/LINKDEAD i386


>Description:

Currently NetBSD i386 has no support for returning a protection, SIGBUS,
fault address to a user program signal handler.
>How-To-Repeat:

>Fix:

For details on how other OS's have solved this problem, see the patch
numbered 851.  To make a long story short, SGI Mips, Irix 5.2, OSF/1 2.0,
AIX, and Linux all do it this way.  There are, however, two other ways
to do it, all involving changing the parameters to the signal handler.

NB: The original patch in 851 was mangled.  This one is more current, tested,
and not mangled.  The only incompatibility I might anticipate is stuff that
accesses the last two items in the sigcontext struct (sc_onstack and sc_mask).
This would be fixed by either recompiling the affected programs, or moving
the sc_cr2 field to the end of the structure.  It seemed to "go" with the
other registers, so I put it before the onstack and mask fields.

The original patch (port-i386:851) also has a test program.

diff -cr /root/tmp/sup-current/src/sys/arch/i386/i386/machdep.c /sys/arch/i386/i386/machdep.c
*** /root/tmp/sup-current/src/sys/arch/i386/i386/machdep.c	Mon Aug 28 02:08:51 1995
--- /sys/arch/i386/i386/machdep.c	Wed Aug 30 21:33:33 1995
***************
*** 513,518 ****
--- 513,519 ----

  	frame.sf_code = code;
  	frame.sf_scp = &fp->sf_sc;
+ 	frame.sf_addr = (char *)rcr2();
  	frame.sf_handler = catcher;

  	/*
***************
*** 546,551 ****
--- 547,555 ----
  	frame.sf_sc.sc_eflags = tf->tf_eflags;
  	frame.sf_sc.sc_esp    = tf->tf_esp;
  	frame.sf_sc.sc_ss     = tf->tf_ss;
+ 
+ 	/* Exp. hack */
+ 	frame.sf_sc.sc_cr2    = rcr2();

  	if (copyout(&frame, fp, sizeof(frame)) != 0) {
  		/*
diff -cr /root/tmp/sup-current/src/sys/arch/i386/include/frame.h /sys/arch/i386/include/frame.h
*** /root/tmp/sup-current/src/sys/arch/i386/include/frame.h	Tue May  2 04:59:58 1995
--- /sys/arch/i386/include/frame.h	Wed Aug 30 21:35:11 1995
***************
*** 103,108 ****
--- 103,109 ----
  	int	sf_signum;
  	int	sf_code;
  	struct	sigcontext *sf_scp;
+ 	char	*sf_addr;
  	sig_t	sf_handler;
  	struct	sigcontext sf_sc;
  };
diff -cr /root/tmp/sup-current/src/sys/arch/i386/include/signal.h /sys/arch/i386/include/signal.h
*** /root/tmp/sup-current/src/sys/arch/i386/include/signal.h	Tue May  2 05:00:00 1995
--- /sys/arch/i386/include/signal.h	Wed Aug 30 21:37:52 1995
***************
*** 71,76 ****
--- 71,78 ----
  	int	sc_esp;
  	int	sc_ss;

+ 	int	sc_cr2;			/* page fault linear address */
+ 
  	int	sc_onstack;		/* sigstack state to restore */
  	int	sc_mask;		/* signal mask to restore */
  };
--
MAIL TO THIS ADDRESS: vax@ccwf.cc.utexas.edu
Ask me about BSD Unix for your PC for FREE! (NetBSD) - Yes, it runs fast!
Victimless crimes are a figment of the state's collective imagination.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->port-i386-maintainer 
Responsible-Changed-By: fair 
Responsible-Changed-When: Mon Dec 28 09:48:57 PST 1998 
Responsible-Changed-Why:  
This PR is the responsibility of the portmaster, 
not the GNATS database administrator. 
State-Changed-From-To: open->feedback 
State-Changed-By: darcy 
State-Changed-When: Sun Feb 16 16:16:27 PST 2003 
State-Changed-Why:  
Do you know if this is still an issue?  Can you suggest a way to test it? 
State-Changed-From-To: feedback->open 
State-Changed-By: perry 
State-Changed-When: Thu Apr 3 17:39:13 PST 2003 
State-Changed-Why:  
This is obviously an open problem, not something we should be closing. 
Responsible-Changed-From-To: port-i386-maintainer->perry 
Responsible-Changed-By: perry 
Responsible-Changed-When: Thu Apr 3 17:41:07 PST 2003 
Responsible-Changed-Why:  
I'm going to temporarily assign this to me so I don't lose track of it. 
State-Changed-From-To: open->closed 
State-Changed-By: perry 
State-Changed-When: Mon Apr 7 19:19:02 PDT 2003 
State-Changed-Why:  
This problem has not been solved. However, the PR is being replaced by 
PR kern/21062 which notes we should implement the more general siginfo 
interface. The proposed solution is not considered sufficiently 
machine independent. 
>Unformatted:
 Provides faulted-upon address for virtual memory research

 Please note that this has been replaced by PR kern/21062

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.