OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 4:39 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Mirror memory mapping?
PostPosted: Sun Jun 06, 2021 3:01 pm 
Offline
Member
Member

Joined: Sun Jun 23, 2019 5:36 pm
Posts: 618
Location: North Dakota, United States
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?


Top
 Profile  
 
 Post subject: Re: Mirror memory mapping?
PostPosted: Sun Jun 06, 2021 3:49 pm 
Offline
Member
Member

Joined: Fri May 11, 2018 6:51 am
Posts: 274
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.
For me, it makes total sense that each process has a separate mapping in its own virtual memory.

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?
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.

_________________
Tilck, a Tiny Linux-Compatible Kernel: https://github.com/vvaltchev/tilck


Top
 Profile  
 
 Post subject: Re: Mirror memory mapping?
PostPosted: Sun Jun 06, 2021 4:26 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
Ethin wrote:
1. Is it feasible to "mirror" a mapped region automatically?

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?

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?

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.


Top
 Profile  
 
 Post subject: Re: Mirror memory mapping?
PostPosted: Sun Jun 06, 2021 9:37 pm 
Offline
Member
Member

Joined: Sun Jun 23, 2019 5:36 pm
Posts: 618
Location: North Dakota, United States
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?

Fair question, and just a hypothetical scenario. I was thinking about the Unix philosophy when I wrote that.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 90 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group