Page 1 of 1

The priviledge level of data segment

Posted: Mon May 23, 2011 6:33 am
by leetow2003
I read a book,it said the priviledge level of data segment
should equal 0 before return to R-mode from P-mode,but
in my codes the DPL equal 3 and RPL equal 2 and it run
very well,I want to know:
(1)Is priviledge level of the data segment DPL or RPL? or other?
(2)why does it run well?is the opinoino of book error?
Look:

Code: Select all

;Define a data segment in GDT
dseg        segment   use16     
gdt         label   byte       
dummy       descriptor <>
    
datas       descriptor <0ffffh,8000h,0bh,0F2h,0>   ;DPL=3
datas_sel   =datas-gdt+3
.....
dseg        ends  
  
;Code segment
cseg        segment   use16     
            assume  cs:cseg, ds:dseg
start:
.....
           ;jump into P-mode
     
virtual:    ;P-Mode
            mov ax,datas_sel
            mov ds,ax 
....
            ;return to R-mode
....
real:      ;R-Mode
....
              sti                   
         mov  ax,4c00h         
           int 21h
cseg        ends   
            end start

Re: The priviledge level of data segment

Posted: Mon Aug 01, 2011 9:12 pm
by galahad
the priv lvl your you need to access a data segment must be at most DPL, but can be lower(lower number=higher priv) you can access it as a more privilegded segment if your rpl is set lower and is equal or lower than yoru cpl