Device Driver Tutorial

User and Kernel Address Spaces on x86 and SPARC Machines

On SPARC machines, the system panics when a kernel module attempts to directly access user address space. You must make sure your driver does not attempt to directly access user address space on a SPARC machine.

On x86 machines, the system does not enter an error state when a kernel module attempts to directly access user address space. You still should make sure your driver does not attempt to directly access user address space on an x86 machine. Drivers should be written to be as portable as possible. Any driver that directly accesses user address space is a poorly written driver.


Caution – Caution –

A driver that works on an x86 machine might not work on a SPARC machine because the driver might access an invalid address.


Do not access user data directly. A driver that directly accesses user address space is using poor programming practice. Such a driver is not portable and is not supportable. Use the ddi_copyin(9F) and ddi_copyout(9F) routines to transfer data to and from user address space. These two routines are the only supported interfaces for accessing user memory. Modifying Data Stored in Kernel Memory shows an example driver that uses ddi_copyin(9F) and ddi_copyout(9F).

The mmap(2) system call maps pages of memory between a process's address space and a file or shared memory object. In response to an mmap(2) system call, the system calls the devmap(9E) entry point to map device memory into user space. This information is then available for direct access by user applications.