assembly - Current x86 privilege level on a custom OS -
in custom os running on x86 in protected mode, there way obtain current privilege level, other e.g. executing privileged instruction , seeing if crashes?
for instance, register cr0
contains pe
bit, indicates if running on real mode or protected mode, , can retrieved using assembly code.
is there equivalent privilege level?
the intel architecture software developer manual mentions eflags
register contains 2 iopl
bits related i/o privilege levels. same current privilege level (cpl)?
no it's not same. represent io privilege level. instructions such in
, out
, cli
require io privileges determined using iopl
, cpl
.
see also:
iopl i/o privilege level field (bits 12 , 13) -- indicates i/o privilege level (iopl) of running program or task. cpl of running program or task must less or equal iopl access i/o address space.
the cpl
can read cs
selector 2 lowest bits:
mov ax, cs , ax, 3
this of course works in protected mode.
Comments
Post a Comment