The priviledge level of data segment

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
leetow2003
Member
Member
Posts: 70
Joined: Fri Nov 19, 2010 6:54 pm

The priviledge level of data segment

Post 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
galahad
Posts: 3
Joined: Mon Aug 01, 2011 8:24 pm

Re: The priviledge level of data segment

Post 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
Post Reply