Bugs in virtual machines
Posted: Fri Mar 29, 2013 4:48 am
It might be that I found a bug in VirtualBox but I cannot say for sure yet. It seems that "rep stosb" does not trigger a page fault when it goes beyond the mapped memory area. In real hardware everything works as expected and a page fault occurs. Maybe this is not a bug but a feature and it may be that I am not interested in to analyze it very thoroughly. Have you ever found out similar kind of features in virtual machines?
Simple memset implementation:
Code: Select all
char *memory = (char *)0xEFFFF000; /* Correctly mapped */
memory[0] = 1; /* No page fault */
memory[4095] = 2; /* No page fault */
memory[4096] = 3; /* Expected page fault (0xF0000000 is not mapped) */
memset(memory, 0, 4096) /* No page fault */
memset(memory, 0, 4097) /* No page fault in VirtualBox!!! */
memset(memory, 0, 5000) /* No page fault in VirtualBox!!! */
memory += 0x1000;
memset(memory, 0, 1) /* Page fault (also in VirtualBox)
Code: Select all
/*
* void *memset(void *destination, int value, unsigned long num);
*/
memset:
movl 4(%esp), %edi
movl 8(%esp), %eax
movl 12(%esp), %ecx
rep stosb
movl 4(%esp), %eax
retl