Hi -
On 2016-11-21 at 14:10 "Ronald G. Minnich" <[email protected]> wrote:
> diff --git a/tests/vmm/vmrunkernel.c b/tests/vmm/vmrunkernel.c
> @@ -814,7 +808,9 @@ int main(int argc, char **argv)
> * PTEs with only one entry filled to point to a page of 1 GiB
> * PTEs; a page of 1 GiB PTEs with only one entry filled to
> * point to a page of 2 MiB PTEs; and a page of 2 MiB PTEs,
> - * only a subset of which will be filled. */
> + * all of which may be filled. For now, we don't handle
> + * starting addresses not aligned on 512 GiB boundaries or
> + * sizes > GiB */
We should check these alignment and size restrictions.
> @@ -832,13 +828,20 @@ int main(int argc, char **argv)
> p1 = &p512[NPTENTRIES];
> p2m = &p512[2 * NPTENTRIES];
>
> - size = kernend - kernstart;
> - fprintf(stderr, "Map %p for %zu bytes\n", kernstart, size);
> - p512[PML4(kernstart)] = (uint64_t)p1 | PTE_KERN_RW;
> - p1[PML3(kernstart)] = (uint64_t)p2m | PTE_KERN_RW;
> - for (uintptr_t i = 0; i < size; i += PML2_PTE_REACH) {
> - p2m[PML2(kernstart + i)] =
> - (uint64_t)(kernstart + i) | PTE_KERN_RW | PTE_PS;
> + fprintf(stderr, "Map %p for %zu bytes\n", memstart, memsize);
> + /* TODO: fix this nested loop so it's correct for more than
> + * one GiB. */
Can we fix this now? 1 GB is a small amount of memory for a guest, and
I think Fergus is already running into issues with it. Let's get it
right and then put it in a library so we don't have to keep doing page
table code. =)
> + for(uintptr_t p4 = memstart; p4 < memstart + memsize;
> + p4 += PML4_PTE_REACH) {
> + p512[PML4(p4)] = (uint64_t)p1 | PTE_KERN_RW;
> + for (uintptr_t p3 = p4; p3 < memstart + memsize;
> + p3 += PML3_PTE_REACH) {
> + p1[PML3(p3)] = (uint64_t)p2m | PTE_KERN_RW;
> + for (uintptr_t p2 = p3; p2 < memstart + memsize; p2 +=
> PML2_PTE_REACH) {
> + p2m[PML2(p2)] =
> + (uint64_t)(p2) | PTE_KERN_RW | PTE_PS;
> + }
> + }
It looks like the main issue is the static nature of "p1" and "p2m", so
we only have a single PML3 and a single PML2. Maybe we replace p1 and
p2m with a helper function that mmaps a fresh page (killing the process
on error), and also call them something other than p1 and p2m, which is
highly similar to the loop variables p2,p3,p4.
Don't forget to run checkpatch on this too.
Barret
--
You received this message because you are subscribed to the Google Groups
"Akaros" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.