From owner-freebsd-hackers@FreeBSD.ORG Tue Aug 9 13:31:43 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7FF0116A41F for ; Tue, 9 Aug 2005 13:31:43 +0000 (GMT) (envelope-from arundel@h3c.de) Received: from enterprise4.noxa.de (enterprise.noxa.de [212.60.197.71]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7424E43D45 for ; Tue, 9 Aug 2005 13:31:41 +0000 (GMT) (envelope-from arundel@h3c.de) Received: (qmail 4290 invoked from network); 9 Aug 2005 15:31:39 +0200 Received: from p508ffce4.dip.t-dialin.net (HELO localhost.skatecity) (80.143.252.228) by enterprise.noxa.de with AES256-SHA encrypted SMTP; 9 Aug 2005 15:31:39 +0200 Received: from localhost.skatecity (nobody@localhost.skatecity [127.0.0.1]) by localhost.skatecity (8.13.4/8.13.4) with ESMTP id j79DV9gI015483 for ; Tue, 9 Aug 2005 15:31:09 +0200 (CEST) (envelope-from arundel@localhost.skatecity) Received: (from arundel@localhost) by localhost.skatecity (8.13.4/8.13.4/Submit) id j79DV90P015482 for freebsd-hackers@freebsd.org; Tue, 9 Aug 2005 15:31:09 +0200 (CEST) (envelope-from arundel) From: alexander Date: Tue, 9 Aug 2005 15:31:09 +0200 To: freebsd-hackers@freebsd.org Message-ID: <20050809133109.GA15300@skatecity> Mail-Followup-To: freebsd-hackers@freebsd.org References: <20050808202039.C988B43D48@mx1.FreeBSD.org> <20050809101409.Y73394@fledge.watson.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050809101409.Y73394@fledge.watson.org> Subject: Re: Using sysarch specific syscalls in assembly? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Aug 2005 13:31:43 -0000 On Tue Aug 9 05, Robert Watson wrote: > > In general, it is much preferable that applications link against libc to > get the system call stubs than that they directly invoke system calls. > That way, if compatibility interfaces are introduced, etc, the application > will continue to function. For example, there was at one point a > migration away from explicit system calls to set certain kernel > parameters, such as hostname and domainname, towards using sysctl, with > the system calls being marked obsolete. The C library still provides a > sethostname() interface, which is actually a wrapper in user space around > sysctl(). So invoking the C function provided by libc for a system call > will generally be preferred, even if the originating code is assembly. > > Robert N M Watson Thx. I'll try that. Unfortunately I'm experiencing some problems right now. From time to time I'm getting a 'Bus error: 10 (core dumped)' This however appears randomly. One time I run the app everything works fine,the next time it core dumps. Are there any errors in my code? %define SYSARCH 165 ; syscall sysarch(2) %define I386_SET_IOPERM 4 ; i386_set_ioperm(2) number ioperm_args dd 378h dd 3 dd 1 OpenIO: push byte ioperm_args push dword I386_SET_IOPERM mov eax,SYSARCH Call _syscall lea esp,[esp+8] ret I'm really confused by the fact that it works sometimes and sometimes it doesn't. I loaded the app into ddd and found more oddities. When I set a breakpoint before the first in/out and then hit continue everything works allright. However when I set a breakpoint after the first in/out the app core dumps with a bus error. Any ideas? Maybe a timing issue? I added a i386_get_ioperm(2) call just to check if the permsissions are being handled correctly. i386_get_ioperm(2) tells me everything is allright. Port range and enable argument are set according to my specs in ioperm_args.