Confusion of NULL selectors in 64bit processors

Viewed 96

I'm sorry my English is not good.

In protection mode, Out of segment limit will trigger #GP. But I have a strange problem on 64 bit processor(I7-3840,i5-3540): initialize DS or ES to 0 in real mode, then switch to protection mode, and still use the loaded descriptor cache value of real mode:(DS_base_address = 0, limit = 0xFFFF.) At this time, if I access the memory over 0xFFFF through DS or ES, it will not trigger #GP.

code snippet

.code16
start.1:
    cli
    xor cx,cx           #
    mov ds,cx
    mov es,cx
    mov ss,cx
    mov sp,0x7c00
main:
    lgdt    gdtr
    lidt    idtr

    mov eax,cr0
    or  al,1
    mov cr0,eax

    jmp $+2          #CS_BASE=DS_BASE=ES_BASE=0
                        #CS_SEL=DS_SEL=ES_SEL=0
                        #LIMIT = 0xFFFF
                        #

    mov edi,0x40000     #DS ES 16bit segment ,exceeding the segment limit
    mov [edi],eax       #i386 will trigger #GP

    jmp $
0 Answers
Related