Jens Nerche wrote:
> I think it's better to collect ideas and find a real good schema for important
> things (like paging, but also eflags) before writing code. So I tryed to
> express my thoughts on http://os.inf.tu-dresden.de/~jn4/diplom/memory.html.
> Caution, this is still uncompleted, only prompts, but for paging thoughts
> should be clear. All other stuff is very rudimentary...
>From that page:
> Running im FreeMWare, the memory the guest thinks
> it is the physical memory is not real the physical
> memory; we can't give guests access to physical memory
> directly because they can (and will do) scratching host
> os memory; so, a additional layer is needed to translate
> the "physical memory" the guest thinks of to the "real
> physical memory"; this looks like that:
> [PICTURE]
I must say I find your picture quite complicated ;),
but this actual action seems to me to be pretty
trivial: the prerequisite is that you catch all
modifications to the active pagetables; once you
do that, you simply employ a one-to-one mapping between
virtualised physical pages and the host's relevant
part of the pagetable (you have to synchronise with
the host page table, in stead of with directly assigned
physical pages, because otherwise you cannot allow
linux to swap out the guest memory, which is something
we'd like to implement as well. This also means that
a page-table modification requires a switch back to
the host).
> Look at following scenario for establishing a new page directory:
These look sane to me. :)
> Instead of unmapping pages from guests address space
> we can also use the P-bit (present), but this makes memory
> sharing between guest and host (to implement in future?)
> more difficult
I don't get your point here. (a) what's the difference between
"unmapping" and "setting P=0" ?? and (b) what does sharing
memory between guest and host have to do with it ? They run
off a different set of pagetables.
Perhaps with "unmapping" you mean "setting U=0" (supervisor-only
pages), which is in principle something I am for (though I don't
call THAT "unmapping" ;)).
> Caution with paging: if one page is swapped out, the guest may
> try to enter the address of this page on hard disk in page
> table, so we do no page translation!
Uh, you should only activate pages with P=1. I don't see
what the problem is ?
> Easy to detect on the P-bit
Uh, yes :) It would actually be a *bug* if we took changes
to the page table for entries with P=0 seriously !!
> (another argument against use of P-bit for marking a page
> table as "not accessable": guest may page out page tables!)
Once again, I don't see the problem. You've got the *virtual*
page table, which is *not* the same as the real page table
(they reside at different physical addresses altogether !)
This means you also have a *virtual* P-bit, and a *real* P-bit.
There is no possible way to confuse these.
-- Ramon