0

What hardware if any can a process in user-mode (as opposed to kernel mode) access without using system calls, e.g. without relying on the OS to do anything for it? This question should be operating system independent since I'm only asking for the hardware restrictions that apply.

  • 2
    "... This question should be operating system independent ..." - The access restrictions are controlled by the software. Which means that the answer depends on both OS and its specific configuration. – Steffen Ullrich Mar 2 '17 at 20:19
  • You mean the OS can actually change the list of allowed instructions that the CPU executes in ring 3 of an x86? – John Smith Mar 2 '17 at 21:22
  • 3
    @JohnSmith - I think not; it may vary on x64/ARM/etc. However, when the CPU traps on a non-allowed operation, the OS can do what it wants. It could emulate the instruction then continue the user-space process. In very rough terms, that's how virtualisation (VMWare etc.) works. – paj28 Mar 2 '17 at 22:06
1

I am not entirely sure of this, so please feel free to correct me.

I read up on how user space device drivers on linux work in this article: Device drivers in user space.

As far as I can tell they work because the kernel maps the memory that the device uses for configuration and buffers into user space. This memory contains the device configuration and any related buffer and therefor changes to it do indirectly affect the device without switching to kernel mode.

But user space processes cannot directly communicate with the device. They can only read and write to this shared memory. If the user space driver wants to inform the device of a change in this memory it has to use a system call (→ interrupt, kernel mode invocation).

Interrupts from the device are processed by the UIO (User-IO) Driver in kernel mode which passes it on to the user space driver.

So the answer to my question is (if I am not completely mistaken): user mode processes cannot access any hardware directly and of course without any system call they cannot request the shared memory either.

Edit: This should be true on any operating system since the mechanisms used to implement it are hardwired in the CPU. In turn it might not hold to be true on certain CPUs no matter the operating system, since the CPU might not support this kind of protection.

  • 1
    I think you're about right. I'd just add that in the traditional I/O model, user space can't access hardware at all. It must make a call to the kernel, where a driver accesses the hardware. Directly mapping memory is a performance enhancement. – paj28 Mar 2 '17 at 22:11
  • 1
    Mostly user space can't access hardware directly. But there are several mechanism in modern systems which could allow for example a virtual machine to fully own a network card, i.e. give up some of the restrictions for more performance. – Steffen Ullrich Mar 3 '17 at 5:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.