So, I've got a couple questions.
1. Is it feasible to "mirror" a mapped region automatically? For example, assume that I want to allocate a shared memory buffer in a userspace process to allow access to hardware. Then assume that that very same buffer needs access by another process. I could change the BARs associated with the device to use an address in physical memory that's associated with the first process, but if I change the BARs for the second process, the first process can no longer access the memory.
2. Is it a good idea to allow a userspace process to have access to, say, the ATA BAR regions if the process in question is an ATA driver in a microkernel? Or should that be conducted through IPC or syscalls?
Mirror memory mapping?
Re: Mirror memory mapping?
For me, it makes total sense that each process has a separate mapping in its own virtual memory.Ethin wrote:1. Is it feasible to "mirror" a mapped region automatically? For example, assume that I want to allocate a shared memory buffer in a userspace process to allow access to hardware. Then assume that that very same buffer needs access by another process. I could change the BARs associated with the device to use an address in physical memory that's associated with the first process, but if I change the BARs for the second process, the first process can no longer access the memory.
I'm not writing a microkernel so, I might not be the right person to answer this question but, my 2 cents are: yes, in a microkernel it makes sense to have some special userspace processes that can control some hardware devices directly. Doing everything through IPC/syscalls might lead to unacceptable performance issues.Ethin wrote:2. Is it a good idea to allow a userspace process to have access to, say, the ATA BAR regions if the process in question is an ATA driver in a microkernel? Or should that be conducted through IPC or syscalls?
Tilck, a Tiny Linux-Compatible Kernel: https://github.com/vvaltchev/tilck
-
- Member
- Posts: 5568
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Mirror memory mapping?
Yes: put the same physical address into your page tables more than once.Ethin wrote:1. Is it feasible to "mirror" a mapped region automatically?
I'm not sure why you bring up BARs. Those control the physical addresses of MMIO, not ordinary memory. Why would two userspace programs want to access the same MMIO?
Yes. Direct access to I/O will always be faster than IPC or syscalls. You can limit a driver to only accessing its own I/O using paging for MMIO and the IOPB in the TSS for port I/O. Note that this doesn't include the PCI configuration space; you don't want drivers to mess with that without going through your kernel.Ethin wrote:2. Is it a good idea to allow a userspace process to have access to, say, the ATA BAR regions if the process in question is an ATA driver in a microkernel?
Re: Mirror memory mapping?
Fair question, and just a hypothetical scenario. I was thinking about the Unix philosophy when I wrote that.Octocontrabass wrote:Yes: put the same physical address into your page tables more than once.
I'm not sure why you bring up BARs. Those control the physical addresses of MMIO, not ordinary memory. Why would two userspace programs want to access the same MMIO?