nvidia machdep.c patch still useful ?
David Cuthbert
dacut at kanga.org
Wed Apr 7 00:13:50 PDT 2004
Matthew Dillon wrote:
%fs cannot be set to anything useful by userland, at least I don't
think it can. %gs can be set to a user-defined custom segment.
My kernel's not quite up-to-date, but the snippet below successfully
queries and sets %fs.
I'm fairly certain that setting any i386 segment register (except %cs)
is a non-privileged instruction. Of course, the descriptor must support
the appropriate access to actually *use* it...
---
#include <stdio.h>
unsigned short get_fs(void)
{
unsigned short result;
__asm__("movw %%fs, %0" : "=r" (result));
return result;
}
void set_fs(unsigned short value)
{
__asm__("movw %0, %%fs" : : "r" (value));
return;
}
int main()
{
printf("fs is %d\n", get_fs());
set_fs(0);
printf("fs is %d\n", get_fs());
return 0;
}
More information about the Kernel
mailing list