Page 1 of 1
Port access
Posted: Thu Feb 22, 2007 10:07 am
by hunter
Hello,
is it possible to disable the ports and cli,sti,... for ring3 tasks ??
Could somebody give me a example ?
Hunter
Re: Port access
Posted: Thu Feb 22, 2007 10:10 am
by Jeko
hunter wrote:Hello,
is it possible to disable the ports and cli,sti,... for ring3 tasks ??
Could somebody give me a example ?
Hunter
I think you must use the TSS. cli and sti are already disabled in ring3.
Posted: Thu Feb 22, 2007 10:18 am
by AJ
Hi,
If you want to disable all ports in ring 3, simply set the IOPL bits in EFLAGS to zero. This means that any ring 3 task attempting port access will cause a GP fault. This needs to be appropriately handled by your kernel, which can decide whether or not to allow the read/write.
Cheers,
Adam
Posted: Thu Feb 22, 2007 10:32 am
by hunter
cli and sti are already disabled in ring3
But if i use cli in a ring3 task the system stops ... Should i have to do something to disable them ??
Hunter
Posted: Thu Feb 22, 2007 10:45 am
by AJ
No. If you are really running in ring 3, you will generate a GPF if you try to cli.
Also, you *cannot* modify IF with the POPF instruction if IOPL is set below the current privilege level.
Cheers,
Adam
Posted: Thu Feb 22, 2007 11:10 am
by Combuster
Once again: check IOPL
Also, some people forgot to read the manual page on CLI:
AMD's Big Book of Patterns wrote:In protected mode and virtual-8086-mode, this instruction is IOPL-sensitive. If the CPL is less than or equal to the rFLAGS.IOPL field, the instruction clears IF to 0.
In protected mode, if IOPL < 3, CPL = 3, and protected mode virtual interrupts are enabled (CR4.PVI = 1), then the instruction instead clears rFLAGS.VIF to 0. If none of these conditions apply, the processor raises a general-purpose exception (#GP).