NetBSD Problem Report #33320

From www@netbsd.org  Thu Apr 20 20:23:06 2006
Return-Path: <www@netbsd.org>
Received: by narn.netbsd.org (Postfix, from userid 31301)
	id A69E963B8C7; Thu, 20 Apr 2006 20:23:06 +0000 (UTC)
Message-Id: <20060420202306.A69E963B8C7@narn.netbsd.org>
Date: Thu, 20 Apr 2006 20:23:06 +0000 (UTC)
From: M.Drochner@fz-juelich.de
Reply-To: M.Drochner@fz-juelich.de
To: gnats-bugs@netbsd.org
Subject: i386_iopl(2) is not LWP aware
X-Send-Pr-Version: www-1.0

>Number:         33320
>Category:       port-i386
>Synopsis:       i386_iopl(2) is not LWP aware
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    port-i386-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 20 20:25:00 +0000 2006
>Originator:     Matthias Drochner
>Release:        current
>Organization:
KFA Juelich
>Environment:
NetBSD zel216 3.99.18 NetBSD 3.99.18 (ZEL216+ACPI.DEBUG) #26: Thu Apr 20 11:56:4
3 MEST 2006  drochner@zel216:/home/drochner/netbsd/sys.work/arch/i386/compile/ZE
L216+ACPI.DEBUG i386

>Description:
i386_iopl(2) does only set the iopl bits for the currently
active LWP. It should work per-process.

This also applies to i386_{get,set}_ioperm(2),
but since this is being revoked (guess by whom:-)
I don't think this needs to be fixed.

>How-To-Repeat:
#include <stdlib.h>
#include <unistd.h>
#include <err.h>
#include <pthread.h>
#include <sys/types.h>
#include <machine/sysarch.h>
#include <machine/pio.h>

void *
ioperm(void *d)
{
        int res;
        char buf[1];

        res = i386_iopl(1);
        if (res < 0)
                err(1, "iopl");
        read(0, &buf, sizeof(buf)); /* block, force new LWP */
        return (0);
}

int
main()
{
        int res;
        pthread_t t;

        res = pthread_create(&t, 0, ioperm, 0);
        if (res)
                err(1, "pthread_create");
        sleep(1); /* wait for thread to block */
        inb(0x61);
        exit (0);
}

>Fix:
The only solution I can imagine which would also work with
multiple threads on multiple processors is to lazy-evaluate
the io permission on faults.

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.