From owner-freebsd-emulation@FreeBSD.ORG Fri May 14 09:52:49 2004 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D9F9916A4CE; Fri, 14 May 2004 09:52:49 -0700 (PDT) Received: from fed1rmmtao04.cox.net (fed1rmmtao04.cox.net [68.230.241.35]) by mx1.FreeBSD.org (Postfix) with ESMTP id C286D43D48; Fri, 14 May 2004 09:52:48 -0700 (PDT) (envelope-from housel@acm.org) Received: from housel.dyndns.org ([68.5.206.145]) by fed1rmmtao04.cox.net ESMTP <20040514165128.FYLY13758.fed1rmmtao04.cox.net@housel.dyndns.org>; Fri, 14 May 2004 12:51:28 -0400 Received: from housel7352a (localhost [127.0.0.1]) by housel.dyndns.org (8.12.11/8.12.11) with SMTP id i4EGpRx5026941; Fri, 14 May 2004 09:51:28 -0700 (PDT) (envelope-from housel@acm.org) Message-ID: <001701c439d3$b88df410$dd22010a@housel7352a> From: "Peter S. Housel" To: , Date: Fri, 14 May 2004 09:51:35 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Subject: Page fault traps in the linuxulator X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2004 16:52:50 -0000 In 5.2-CURRENT I'm running some Linux code (a garbage collector) that needs to trap page faults. There are a couple of problems with the i386 code that builds linux signal context: /* ... */ frame.sf_sc.sc_err = regs->tf_err; frame.sf_sc.sc_trapno = bsd_to_linux_trapcode(code); The first problem is that the sc_cr2 field of the linux sigcontext is not initialized with the faulting address (obtained at page fault time from the cr2 register). The second problem is that sc_err is being initialized incorrectly, because in trap_pfault the original tf_err field provided by the processor has already been overwritten: /* kludge to pass faulting virtual address to sendsig */ frame->tf_err = eva; The trap handler has worked this way since trap.c revision 1.25 (soon to be having its tenth anniversary). Surely there is some better way to pass eva to sendsig so thtat the 3-bit err field is not lost. (It would be nice if said field were available in the FreeBSD sigcontext, too, but that would likely involve an ABI change.) -Peter-