Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Dec 1998 18:48:28 +1100
From:      Peter Jeremy <peter.jeremy@auss2.alcatel.com.au>
To:        current@FreeBSD.ORG
Subject:   Re: sio breakage
Message-ID:  <98Dec2.184751est.40352@border.alcanet.com.au>

next in thread | raw e-mail | index | archive | help
Bruce Evans <bde@zeta.org.au> wrote:

>something_more_likely()
>{
>	asm("cli");
>	var = 0;
>	asm("sti");
>}

>Fixes:
>kernel: send a fatal signal to applications that do this.

I'd suggest sending SIGBUS, with the interrupts enabled.  This would
allow the application to recover if necessary.

>applications: don't do this.

I don't believe this is reasonable.  We should provide some safe way
for an application program to execute code with interrupts disabled.
Amongst other applications, XFree86 needs this.

>  If interrupts must be disabled, then all
>              critical code and data must be within one page.

The restriction is slightly more liberal than this: all code in the
flow of control between the CLI and STI (inclusive), together with all
data referenced by such code must be resident at the time the CLI is
executed.

For short sequences where no memory is accessed (eg a block of I/O
instructions), including a `.align 4,0x90' before the CLI will be
sufficient (as long as the total code is less than 16 bytes).

Where sufficient memory is available to ensure that recently
referenced pages will not get reused, including a series of tests (or
similar) - for each data location and the terminating STI - before the
CLI should be sufficient.  This approach does have the downside that
if the system is thrashing, the pages may get reused anyway.

The guaranteed approach is to use mlock(2) on the affected regions.
This is also the most expensive (since multiple system calls are
required).  Whilst this only works for root, only root can normally
open /dev/io (and hence use CLI/STI).

Peter
--
Peter Jeremy (VK2PJ)                    peter.jeremy@alcatel.com.au
Alcatel Australia Limited
41 Mandible St                          Phone: +61 2 9690 5019
ALEXANDRIA  NSW  2015                   Fax:   +61 2 9690 5247

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?98Dec2.184751est.40352>