srivatsa bhat
unread,Apr 7, 2011, 8:08:47 AM4/7/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to min...@googlegroups.com
Hello all,
In servers/vm/arch/i386/pagetable.c, in the function pt_init() we find the following code:
/* Initial (current) range of our virtual address space. */
lo = CLICK2ABS(vmprocess->vm_arch.vm_seg[T].mem_phys);
hi = CLICK2ABS(vmprocess->vm_arch.vm_seg[S].mem_phys +
vmprocess->vm_arch.vm_seg[S].mem_len);
...
if(lo < VM_PROCSTART) {
moveup = VM_PROCSTART - lo;
...
}
...
/* Move segments up too. */
vmprocess->vm_arch.vm_seg[T].mem_phys += ABS2CLICK(moveup);
vmprocess->vm_arch.vm_seg[D].mem_phys += ABS2CLICK(moveup);
vmprocess->vm_arch.vm_seg[S].mem_phys += ABS2CLICK(moveup);
...
/* Increase our hardware data segment to create virtual address
* space above our stack. We want to increase it to VM_DATATOP,
* like regular processes have.
*/
extra_clicks = ABS2CLICK(VM_DATATOP - hi);
vmprocess->vm_arch.vm_seg[S].mem_len += extra_clicks;
/* We pretend to the kernel we have a huge stack segment to
* increase our data segment.
*/
...
Here is my question:
I feel the line "extra_clicks..." should have been:
extra_clicks = ABS2CLICK(VM_DATATOP - (hi + moveup));
That is, should we not add 'moveup' to 'hi' and then compute the extra clicks, since 'hi' refers to the top end of VM's address space before VM was moved up?
So shouldn't we be using the new end of VM's address space (the one we get after moving VM by 'moveup') to compute the extra clicks?
I added appropriate print statements in the code and upon testing I found that due to the above "bug" (correct me if I am wrong), the value of CLICK2ABS(vmprocess->vm_arch.vm_seg[S].mem_phys + vmprocess->vm_arch.vm_seg[S].mem_len) [before [S].mem_len is restored to its original length], had gone beyond VM_DATATOP (0xFFFFF000) and had in fact overshot the value that can be accommodated in a 32 bit number!
I have attached screenshots of the outputs with and without adding 'moveup' as explained above. (I have used MINIX 3.1.7 for testing. But the relevant parts of the code in pt_init() are still the same even in the latest code in the trunk.)
Regards,
Srivatsa S. Bhat
With moveup(correct value).png
Without moveup(overflowed value).png