Minimal Kernel-Support for Graphics Hardware

Morten Welinder (terra@diku.dk)
Mon, 30 Mar 1998 04:42:48 +0200 (METDST)


Hello,

This, I think, is about as bare-bones as support for graphics mode
switching in kernel can get. Heck, it'll even work for other kinds
of hardware as well!

One syscall only is needed. To switch into a new mode, the caller
provides code to do some and code to switch back. Both code
sequences are copied to kernel memory (so they had better be
position independent!) where the setup code is run right away
while the restore code is saved. Any (root) process can switch
back by calling the restore function.

The obvious extension is to parameterise on hardware.

This code does not prevent anyone from shooting himself in the foot.
(Just send bogus setup/restore code, for example.) But an X server
crash should no longer be a problem.

[Thinking aloud:] Alternatively, one could have a sys_hardware which
does nothing until a module tells it what to do. That way, the kernel
would not get anouther place where arbitrary code gets injected.

Morten

static int gotsome = 0;

sys_hardware_mode (int what,
void *setup, int setup_length,
void *restore, int restore_length)
{
if (!suser ()) return complain_fiercely ();

if (what == 0) {
/* Enter a non-default hardware mode. */
<copy setup and restore code to kernel memory>
<cli all processors>
<execute setup code>
<sti>
<free setup code>
if (gotsome)
<free old -- from previous mode -- memory for restore function>
else
gotsome = 1;
return 0;
} else if (what == 1) {
/* Restore default hardware mode. */
if (!gotsome) return EPERM;
<cli all processors>
<execure restore code>
<sti>
gotsome = 0;
<free restore code>
return 0;
} else
return EAAARRG;
}

(I think this needs some work in order to work without having SMP
races.)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu