As mentioned on this comment, using pointers into the memory array with virtual memory addresses is dangerous and will corrupt memory or cause crashes if the data being accessed crosses the boundary of two or more virtual pages that map to non-contiguous physical addresses.
The goal here is to create a mechanism that allows host code to manipulate guest data using virtual addresses as transparently and lightweight as possible, ideally reproducing the behavior of the CPU, including causing exceptions such as General Protection Faults if the code attempts to read from or write to inaccessible memory pages. The existing StructRef template class can be used as a starting point for research.
Pointers are still safe to use when the address is known to be physical. Most (if not all) Mm* functions and kernel initialization code can continue using ToPointer. Stack variables might be safe as well; this needs investigation.
As mentioned on this comment, using pointers into the memory array with virtual memory addresses is dangerous and will corrupt memory or cause crashes if the data being accessed crosses the boundary of two or more virtual pages that map to non-contiguous physical addresses.
The goal here is to create a mechanism that allows host code to manipulate guest data using virtual addresses as transparently and lightweight as possible, ideally reproducing the behavior of the CPU, including causing exceptions such as General Protection Faults if the code attempts to read from or write to inaccessible memory pages. The existing
StructRef
template class can be used as a starting point for research.Pointers are still safe to use when the address is known to be physical. Most (if not all) Mm* functions and kernel initialization code can continue using
ToPointer
. Stack variables might be safe as well; this needs investigation.