From owner-freebsd-hackers@FreeBSD.ORG Wed Aug 10 13:09:22 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 87E3316A41F for ; Wed, 10 Aug 2005 13:09:22 +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 6F74243D45 for ; Wed, 10 Aug 2005 13:09:20 +0000 (GMT) (envelope-from arundel@h3c.de) Received: (qmail 29330 invoked from network); 10 Aug 2005 15:09:19 +0200 Received: from p508fc0d6.dip.t-dialin.net (HELO localhost.skatecity) (80.143.192.214) by enterprise.noxa.de with AES256-SHA encrypted SMTP; 10 Aug 2005 15:09:19 +0200 Received: from localhost.skatecity (nobody@localhost.skatecity [127.0.0.1]) by localhost.skatecity (8.13.4/8.13.4) with ESMTP id j7AD9TdH002179 for ; Wed, 10 Aug 2005 15:09:29 +0200 (CEST) (envelope-from arundel@localhost.skatecity) Received: (from arundel@localhost) by localhost.skatecity (8.13.4/8.13.4/Submit) id j7AD9Tbm002178 for freebsd-hackers@freebsd.org; Wed, 10 Aug 2005 15:09:29 +0200 (CEST) (envelope-from arundel) From: alexander Date: Wed, 10 Aug 2005 15:09:28 +0200 To: freebsd-hackers@freebsd.org Message-ID: <20050810130928.GA2027@skatecity> Mail-Followup-To: freebsd-hackers@freebsd.org References: <20050809133109.GA15300@skatecity> <20050809154541.C057243D45@mx1.FreeBSD.org> <20050809192530.GA19230@skatecity> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050809192530.GA19230@skatecity> 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: Wed, 10 Aug 2005 13:09:22 -0000 I tried to write a little C app that uses sysarch and i386_set_ioperm to gain access to certain ports and after a bit of testing I'm pretty sure that there is a bug or better a timing issue with the sysarch syscall or the i386_set_ioperm procedure. Please have a look at the following code: //CODE START #include int main (void) { unsigned int port = 0x378; unsigned char val = 'A'; int number = 4; static inline void outb (unsigned short int port, unsigned char val) { __asm__ volatile ("outb %0,%1\n"::"a" (val), "d" (port) ); } struct i386_ioperm_args { unsigned int start; unsigned int length; int enable; }; struct i386_ioperm_args *args; struct i386_ioperm_args arg; args = &arg; args->start = 0x378; args->length = 1; args->enable = 1; if(sysarch(number,args) == 0) { /* int i; for(i=0; i < 100; i++) { printf("DELAY\n"); } */ outb(0x378,0xF); exit(0); } else { printf("Error during syscall"); exit(1); } } //eof //CODE END On my PC this code will cause a core dump (Bus error: 10). If I however add a delay (the code that's commented out) the app will end without any errors. It seems FBSD needs some time to set the I/O permissions for an app. Can somebody test this code on his computer? Maybe this is a bug in RELENG_6. I'm running: FreeBSD 6.0-BETA1 #0: Mon Jul 18 03:00:45 CEST 2005 Thx a bunch.