Conceptual
Login

Telling the Kernel Which Addresses a Device Can Reach

A device that moves data by itself can only generate addresses of a certain width: an old card may only reach the first four gigabytes. Before allocating any memory for it, the driver announces that limit, and the kernel then only hands out buffers the device can actually address, using a bounce buffer if it must. Forgetting this in C means the allocator happily returns high memory, the device writes to a truncated address, and something unrelated is corrupted with no clue where it came from. In Rust the call still has to be made; what you gain is an error you must handle if the limit cannot be met.

Questions this Concept answers

  • Why must the addressing mask be set before any memory is allocated for the device to write into?