KVM Virtual Memory limits?
Posted: Sat Sep 12, 2015 9:25 pm
Today I got to working on some elf loading.
Now in my OS, user code is loaded at virtual address 0x80000000, however there's some strange issue with testing the code.
When I map some memory to the location and attempt to copy code to it (well memset it before copying) I get a page fault at 0x80000000 apparently due to a write. Which is strange because not only do I have the entry set as writeable, I'm still in ring 0.The exact same code when relinked to load at 0x30000000 loads and runs just fine, it has the same physical page assigned to it so I doubt it's something in that part either. I also do make sure to flush the TLB after I updated the page tables.
QEMU's 'info tlb' command shows that the mapping is indeed getting through properly.
Additionally, further testing reveals that I can't access any virtual address above 0x40000000. I have PAE enabled and am in 32bit protected mode. If I disable KVM on QEMU and just use software emulation, everything works fine and I can map to any virtual address in the 4GB range.
I've looked all around on the web and can't find much information about what might be causing this. I'm thinking it might have something to do with my hardware, but that doesn't feel like it makes much sense. I have a relatively recent computer with a Haswell i7-4510.
At this point I'm out of ideas, has anyone encountered this kind of problem before? Is there likely just some small detail about PAE paging that I've been missing? My virtual memory management code is at https://github.com/himanshugoel2797/Ape ... _manager.c
Now in my OS, user code is loaded at virtual address 0x80000000, however there's some strange issue with testing the code.
When I map some memory to the location and attempt to copy code to it (well memset it before copying) I get a page fault at 0x80000000 apparently due to a write. Which is strange because not only do I have the entry set as writeable, I'm still in ring 0.The exact same code when relinked to load at 0x30000000 loads and runs just fine, it has the same physical page assigned to it so I doubt it's something in that part either. I also do make sure to flush the TLB after I updated the page tables.
QEMU's 'info tlb' command shows that the mapping is indeed getting through properly.
Additionally, further testing reveals that I can't access any virtual address above 0x40000000. I have PAE enabled and am in 32bit protected mode. If I disable KVM on QEMU and just use software emulation, everything works fine and I can map to any virtual address in the 4GB range.
I've looked all around on the web and can't find much information about what might be causing this. I'm thinking it might have something to do with my hardware, but that doesn't feel like it makes much sense. I have a relatively recent computer with a Haswell i7-4510.
At this point I'm out of ideas, has anyone encountered this kind of problem before? Is there likely just some small detail about PAE paging that I've been missing? My virtual memory management code is at https://github.com/himanshugoel2797/Ape ... _manager.c