Imagine a 32-bit x86 computer with less than 3 gigabytes of memory with CPU set up with disabled paging and flat segment descriptors (0x0
as base, 0xffffffff
as an effective limit for both data and code).
What happens when an instruction in ring0 tries to use a mov
instruction to reference a physical address that is not backed by any memory address?
QEMU emulation just stalls with an error like "fatal: Trying to execute code outside RAM or ROM".
These exceptions are related to memory issues:
#NP
)": it only happens when segment registers are loaded, but I can actually load flat segments without problems.#SS
)" should not be generated, because the code doesn't reference stack.#GP
)" shouldn't happen because the code is running in ring-0 and segments are set up to allow access to every physical address.#PF
)" either.#AC
)".I ran out of options and I don't know what should happen.
If paging is disabled and the current segment's limit is 4GiB (in 32-bit mode) there are no "nonexisting" addresses:
All 2^32 possible addresses exist in this case and can be read and written.
What happens if a read or write operation to an address where no RAM, ROM, etc is located is done depends on the hardware outside the CPU and not on the CPU itself.
A write operation to such an address will typically be ignored and a read operation will typically result in a non-sense value (on most PCs the "all-ones" value like 0xFF, 0xFFFF, 0xFFFFFFFF).
Theoretically such an address access may cause an interrupt or even crash the computer depending on the address. However this is not done by the CPU itself but by other hardware components.
Execution of code on such an address is basically nothing but a read access from that address.