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.
So when a process tries to access a virtual address in unmapped memory, the hardware notices there is no physical memory mapped to the virtual address in question. The operating system is signaled, it prints a rude message, and terminates the process.
Registers do have addresses, even though they don't generally reside in memory. Think about it a minute : an address denotes a location in some space, where memory is just one instance of a space.
The address generation unit (AGU), sometimes also called address computation unit (ACU), is an execution unit inside central processing units (CPUs) that calculates addresses used by the CPU to access main memory.
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.
My understanding is that non-paged memory accesses go directly to bus, leading to undefined behavior (depends on the chipset, bus type etc.) -- See Manual Probing
Note: You will never get an error from trying to read/write memory that does not exist -- this is important to understand: you will not get valid results, but you won't get an error, either.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With