Skip to contentSkip to conversation

powerpc/mm: Allow user space to map rtas_rmo_buf

PATCH Applied Vasant Hegde 5 participants 9 messages Jan 21, 2016 – Jan 29, 2016 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/mm: Allow user space to map rtas_rmo_buf

With commit 90a545e9 (restrict /dev/mem to idle io memory ranges) mapping rtas_rmo_buf from user space is failing. Hence we are not able to make RTAS syscall.

This patch calls page_is_rtas_user_buf before calling iomem_is_exclusive in devmem_is_allowed(). This will allow user space to map rtas_rmo_buf and we are able to make RTAS syscall.

CC Dan Williams <[email protected]>
CC Nathan Fontenot <[email protected]>
CC Michael Ellerman <[email protected]>
---
 arch/powerpc/mm/mem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/mm/mem.c +2 -2
index 22d94c3..d0f0a51 100644
@@ -560,12 +560,12 @@ subsys_initcall(add_system_ram_resources);
  */
 int devmem_is_allowed(unsigned long pfn)
 {
+	if (page_is_rtas_user_buf(pfn))
+		return 1;
 	if (iomem_is_exclusive(PFN_PHYS(pfn)))
 		return 0;
 	if (!page_is_ram(pfn))
 		return 1;
-	if (page_is_rtas_user_buf(pfn))
-		return 1;
 	return 0;
 }
 #endif /* CONFIG_STRICT_DEVMEM */
Signature · 1 line
2.1.0
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Vasant Hegde

With commit 90a545e9 (restrict /dev/mem to idle io memory ranges) mapping rtas_rmo_buf from user space is failing. Hence we are not able to make RTAS syscall.

This patch calls page_is_rtas_user_buf before calling iomem_is_exclusive in devmem_is_allowed(). This will allow user space to map rtas_rmo_buf and we are able to make RTAS syscall.

#2 lore raw
In reply to Vasant Hegde
Quoted 7 lines · Vasant Hegde

With commit 90a545e9 (restrict /dev/mem to idle io memory ranges) mapping rtas_rmo_buf from user space is failing. Hence we are not able to make RTAS syscall.

This patch calls page_is_rtas_user_buf before calling iomem_is_exclusive in devmem_is_allowed(). This will allow user space to map rtas_rmo_buf and we are able to make RTAS syscall.

Thanks for the patch.

I'll put it in my fixes branch for next week.

Having said that, why the <expletive deleted> is librtas mapping /dev/mem in the first place? Unless there is a very good reason, and probably even if there is, we should fix that to use a sane API.

cheers

#3 lore raw
Quoted 9 lines · Michael Ellerman
Quoted 7 lines · Vasant Hegde

With commit 90a545e9 (restrict /dev/mem to idle io memory ranges) mapping rtas_rmo_buf from user space is failing. Hence we are not able to make RTAS syscall.

This patch calls page_is_rtas_user_buf before calling iomem_is_exclusive in devmem_is_allowed(). This will allow user space to map rtas_rmo_buf and we are able to make RTAS syscall.

Michael,

Quoted 4 lines

Thanks for the patch.

I'll put it in my fixes branch for next week.

Thanks!

Quoted 5 lines

Having said that, why the <expletive deleted> is librtas mapping /dev/mem in the first place? Unless there is a very good reason, and probably even if there is, we should fix that to use a sane API.

We use rtas system call. We use /dev/mem interface to map the RTAS memory region (allocated by kernel and information is passed to user space via procfs) so that we can read/write to RTAS memory.

I do not have historical information. May be Nathan has more information on this.

-Vasant

#4 lore raw
Quoted 11 lines · Vasant Hegde
Quoted 9 lines · Michael Ellerman
Quoted 3 lines · Vasant Hegde

With commit 90a545e9 (restrict /dev/mem to idle io memory ranges) mapping rtas_rmo_buf from user space is failing. Hence we are not able to make RTAS syscall.

Having said that, why the <expletive deleted> is librtas mapping /dev/mem in the first place? Unless there is a very good reason, and probably even if there is, we should fix that to use a sane API.

Quoted 5 lines

We use rtas system call. We use /dev/mem interface to map the RTAS memory region (allocated by kernel and information is passed to user space via procfs) so that we can read/write to RTAS memory.

I do not have historical information. May be Nathan has more information on this.

Yeah, we need to dig into what it's actually doing and why. I had a quick look but it wasn't obvious.

We should not need 1) a system call, 2) a proc interface, and 3) a mmap of /dev/mem.

If the syscall's not sufficient and we really need to mmap, we should create a device which can then be mmapped in a more standard way.

Having said that, Nathan's been moving more of the hotplug logic into the kernel, so I'm also not clear on how much of the existing API we will need in the future. So yep hopefully Nathan can chime in.

cheers

#5 lore raw
Quoted 31 lines · Michael Ellerman
Quoted 14 lines · Vasant Hegde
Quoted 7 lines · Michael Ellerman
Quoted 4 lines · Vasant Hegde

With commit 90a545e9 (restrict /dev/mem to idle io memory ranges) mapping
rtas_rmo_buf from user space is failing. Hence we are not able to make RTAS syscall.

Quoted 5 lines

Having said that, why the <expletive deleted> is librtas mapping /dev/mem in
the first place? Unless there is a very good reason, and probably even if there
is, we should fix that to use a sane API.

Quoted 8 lines

We use rtas system call. We use /dev/mem interface to map the RTAS memory region
(allocated by kernel and information is passed to user space via procfs) so that
we can read/write to RTAS memory.

I do not have historical information. May be Nathan has more information on this.

Yeah, we need to dig into what it's actually doing and why. I had a quick look
but it wasn't obvious.

We should not need 1) a system call, 2) a proc interface, and 3) a mmap of /dev/mem.

Quoted 8 lines

If the syscall's not sufficient and we really need to mmap, we should create a
device which can then be mmapped in a more standard way.

Having said that, Nathan's been moving more of the hotplug logic into the kernel, so I'm also not clear on how much of the existing API we will need in
the future. So yep hopefully Nathan can chime in.

Yeah, but if we're going to move to only one interface to work with RTAS we can break existing applications.

Quoted 7 lines

cheers

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

#7 lore raw
In reply to Michael Ellerman
Quoted 12 lines · Michael Ellerman
Quoted 11 lines · Vasant Hegde
Quoted 9 lines · Michael Ellerman
Quoted 3 lines · Vasant Hegde

With commit 90a545e9 (restrict /dev/mem to idle io memory ranges) mapping rtas_rmo_buf from user space is failing. Hence we are not able to make RTAS syscall.

Having said that, why the <expletive deleted> is librtas mapping /dev/mem in the first place? Unless there is a very good reason, and probably even if there is, we should fix that to use a sane API.

Quoted 8 lines
Quoted 5 lines

We use rtas system call. We use /dev/mem interface to map the RTAS memory region (allocated by kernel and information is passed to user space via procfs) so that we can read/write to RTAS memory.

I do not have historical information. May be Nathan has more information on this.

Yeah, we need to dig into what it's actually doing and why. I had a quick look but it wasn't obvious.

This was done many years ago, going on memory for now...

I will have to dig back into this code further but what I remember is that the following process is used. At boot time a piece of low memory (buffers passed to rtas have to be in low memory) is reserved to use for rtas calls. This memory is made available to userspace, namely the librtas library. The code in librtas will then reserve pieces of this memory to use for buffers when making rtas calls that require large buffers. I think the biggest user of this is the rtas configure-connector call which can require two 1-page buffers.

If I remember correctly this was done to avoid having the kernel do all of the copying to/from user of the buffers used.

Quoted 4 lines

We should not need 1) a system call, 2) a proc interface, and 3) a mmap of /dev/mem.

It seems that we could move to an interface that just uses a syscall and have the kernel copy the buffers in from userspace into the kernels reserved rtas buffer space.

Quoted 3 lines

If the syscall's not sufficient and we really need to mmap, we should create a device which can then be mmapped in a more standard way.

This would also work if having the kernel copy the buffers is not what we want to do.

-Nathan

Quoted 6 lines

Having said that, Nathan's been moving more of the hotplug logic into the kernel, so I'm also not clear on how much of the existing API we will need in the future. So yep hopefully Nathan can chime in.

cheers

#6 lore raw
In reply to Denis Kirjanov
Quoted 36 lines · Denis Kirjanov
Quoted 35 lines · Michael Ellerman
Quoted 14 lines · Vasant Hegde
Quoted 7 lines · Michael Ellerman
Quoted 4 lines · Vasant Hegde

With commit 90a545e9 (restrict /dev/mem to idle io memory ranges) mapping
rtas_rmo_buf from user space is failing. Hence we are not able to make RTAS syscall.

Quoted 5 lines

Having said that, why the <expletive deleted> is librtas mapping /dev/mem in
the first place? Unless there is a very good reason, and probably even if there
is, we should fix that to use a sane API.

Quoted 8 lines

We use rtas system call. We use /dev/mem interface to map the RTAS memory region
(allocated by kernel and information is passed to user space via procfs) so that
we can read/write to RTAS memory.

I do not have historical information. May be Nathan has more information on this.

Yeah, we need to dig into what it's actually doing and why. I had a quick look
but it wasn't obvious.

We should not need 1) a system call, 2) a proc interface, and 3) a mmap of /dev/mem.

If the syscall's not sufficient and we really need to mmap, we should create a
device which can then be mmapped in a more standard way.

Quoted 8 lines
Quoted 4 lines

Having said that, Nathan's been moving more of the hotplug logic into the kernel, so I'm also not clear on how much of the existing API we will need in
the future. So yep hopefully Nathan can chime in.

Yeah, but if we're going to move to only one interface to work with RTAS we can break existing applications.

Yes, but I doubt that anything other than librtas is using this. I don't think this interface was ever documented anywhere.

-Nathan

Quoted 8 lines
Quoted 7 lines

cheers

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

reviewer Applied
#8 lore raw
In reply to Vasant Hegde
Quoted 8 lines · Vasant Hegde

With commit 90a545e9 (restrict /dev/mem to idle io memory ranges) mapping rtas_rmo_buf from user space is failing. Hence we are not able to make RTAS syscall.

This patch calls page_is_rtas_user_buf before calling iomem_is_exclusive in devmem_is_allowed(). This will allow user space to map rtas_rmo_buf and we are able to make RTAS syscall.

Quoted 6 lines

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/e256caa7d0515e301f8c8c6e7d

cheers