problem changing page table in bochs
Posted: Wed Jun 06, 2012 10:22 pm
Hi,
I am trying to copy the contents of two arrays to two different pages allocated by physical memory manager.
I have a function - vmmgr_temp_map_page() which maps any physical address to a fixed virtual address - 0xC0000000
so that I can write to that page using the fixed virtual address.
Now the problem is that at one point, when vmmgr_temp_map_page() is called, the page table entry is not getting modified.
Here is the code :
[/size]
Here the first call to vmmgr_temp_map_page() works but the second one doesn't.
The physical address of code_frame is 0x8000 and that of data frame is 0x116000.
I am using the command 'info tab' on bochs debugger to check the mappings. After the firs call to vmmgr_temp_map_page()
info tab shows the entry
[/size]
but after second call also it shows the same entry.
Now the strange thing here is that when I check the page table entry using the physical address of the page table
it shows that the entry is changed after the second call but 'info tab' still shows the old entry.
[/size]
This is PTE of the page table at physical address 0x2000 which maps addresses starting from 0xC0000000. It clearly shows that
the physical address mapped to 0xC0000000 is 0x116000
But the output from info tab differs :
[/size]
When I continue, the code fails as the frame at 0x8000 is modified again in place of the frame at 0x116000.
What is more confusing is that once in a while info tab shows correct mappings and the code runs correctly but mostly it is
failing. I have been debugging this for a few hours now and don't know what else to do.
-Thanks
Vaibhav Jain
I am trying to copy the contents of two arrays to two different pages allocated by physical memory manager.
I have a function - vmmgr_temp_map_page() which maps any physical address to a fixed virtual address - 0xC0000000
so that I can write to that page using the fixed virtual address.
Now the problem is that at one point, when vmmgr_temp_map_page() is called, the page table entry is not getting modified.
Here is the code :
Code: Select all
char[] code_array = { ... }
char[] data_array = { ... }
void* code_frame = pmmgr_alloc_block(); //Allocate a page
void* code_virt = vmmgr_temp_map_page(code_frame); //Map page to 0xC000 0000 << WORKS
char* dest = (char*)code_virt;
int j, k = 0;
//Copy contents of code_array to page
for(j = 0; j < 0x23 ; j ++)
{
dest[j] = code_array[j];
}
void* data_frame = pmmgr_alloc_block(); //Allocate a page
void* data_virt = vmmgr_temp_map_page(data_frame); //Map page to 0xC000 0000 << DOESNT WORK
dest = (char*)data_virt;
//Copy contents of data_array to page
for(k =0 ; k < 0x31; k++)
{
dest[k] = data_array[k];
}
Here the first call to vmmgr_temp_map_page() works but the second one doesn't.
The physical address of code_frame is 0x8000 and that of data frame is 0x116000.
I am using the command 'info tab' on bochs debugger to check the mappings. After the firs call to vmmgr_temp_map_page()
info tab shows the entry
Code: Select all
0xc0000000-0xc0000fff -> 0x0000000000008000-0x0000000000008fff
but after second call also it shows the same entry.
Now the strange thing here is that when I check the page table entry using the physical address of the page table
it shows that the entry is changed after the second call but 'info tab' still shows the old entry.
Code: Select all
<bochs:5> xp /4bx 0x2000
[bochs]:
0x00002000 <bogus+ 0>: 0x67 0x60 0x11 0x00
This is PTE of the page table at physical address 0x2000 which maps addresses starting from 0xC0000000. It clearly shows that
the physical address mapped to 0xC0000000 is 0x116000
But the output from info tab differs :
Code: Select all
<bochs:6> info tab
cr3: 0x0a8fb5c800003000
0x00000000-0x003fffff -> 0x0000000000000000-0x00000000003fffff
0xc0000000-0xc0000fff -> 0x0000000000008000-0x0000000000008fff <<<<<<<<<<<<<<<<
0xc0001000-0xc03fffff -> 0x0000000000101000-0x00000000004fffff
0xd0000000-0xd00fffff -> 0x0000000000009000-0x0000000000108fff
0xffc00000-0xffc00fff -> 0x0000000000001000-0x0000000000001fff
0xfff00000-0xfff00fff -> 0x0000000000002000-0x0000000000002fff
0xfff40000-0xfff40fff -> 0x0000000000006000-0x0000000000006fff
0xfffff000-0xffffffff -> 0x0000000000003000-0x0000000000003fff
When I continue, the code fails as the frame at 0x8000 is modified again in place of the frame at 0x116000.
What is more confusing is that once in a while info tab shows correct mappings and the code runs correctly but mostly it is
failing. I have been debugging this for a few hours now and don't know what else to do.
-Thanks
Vaibhav Jain