frank wrote:Does it work in other emulators? Also did you try printing the value of the function parameter cr3?
Doesn't work in VPC, and I do print the parameter and get the correct value.
@Brynet: That was my implementation before, it still didn't work. I've since changed it to what's in my first post.
Edit: it appears the problem lies here (rewritten into Intel syntax):
Code: Select all
mov eax,<pagedir addy>
mov cr3,eax
Any read of cr3 will give the correct value, but in Bochs (and, it seems, VPC) the actual system does not recognize the value of CR3:
Code: Select all
00125160000i[CPU0 ] protected mode
00125160000i[CPU0 ] CS.d_b = 32 bit
00125160000i[CPU0 ] SS.d_b = 32 bit
00125160000i[CPU0 ] | EAX=0009c000 EBX=0010e020 ECX=0009c000 EDX=00000ffc
00125160000i[CPU0 ] | ESP=00112148 EBP=00112148 ESI=0002bea8 EDI=0002bead
00125160000i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df IF tf sf zf AF pf cf
00125160000i[CPU0 ] | SEG selector base limit G D
00125160000i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00125160000i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 000fffff 1 1
00125160000i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00125160000i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00125160000i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 000fffff 1 1
00125160000i[CPU0 ] | FS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00125160000i[CPU0 ] | GS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00125160000i[CPU0 ] | EIP=00100072 (00100072)
00125160000i[CPU0 ] | CR0=0x00000011 CR1=0 CR2=0x00000000
00125160000i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00125160000i[CPU0 ] >> jmp .+0xfffffffe (0x00100072) : EBFE
From the execution of:
Code: Select all
__asm_write_cr3:
push %ebp # use a standard prologue because it's faster than ENTER ...
movl %esp,%ebp
movl 8(%ebp),%eax # set CR3 to the page directory address
movl %eax,%cr3
movl %cr3,%ecx
l: # debugging: this allows us to quit bochs and see if CR3 and EAX are right
jmp .
leave # ... but use LEAVE because it takes less cycles
ret
As you can see from the Bochs log, EAX and ECX equal 0x9C000, but the value of CR3 still equals 0x0.
Any ideas why this happens? Does anyone agree with me when I say that there is no reason why this should not be working?