Re: [RFC PATCH 4/6] powerpc/powernv: Convert pointers to physical addresses in OPAL call args

From
Christophe Leroy <hidden>
Date
2022-11-08 16:22:36
Also in
linux-hardening
Reply to
Andrew Donnellan, 2022-11-04

Le 04/11/2022 à 18:27, Andrew Donnellan a écrit :
A number of OPAL calls take addresses as arguments (e.g. buffers with
strings to print, etc). These addresses need to be physical addresses, as
OPAL runs in real mode.

Since the hardware ignores the top two bits of the address in real mode,
passing addresses in the kernel's linear map works fine even if we don't
wrap them in __pa().

With VMAP_STACK, however, we're going to have to use vmalloc_to_phys() to
convert addresses from the stack into an address that OPAL can use.

I think you should then avoid using the stack for all those parameters. 
It should be handled just like DMA in drivers : Don't use the stack, use 
kmalloc memory instead.
Introduce a new macro, stack_pa(), that uses vmalloc_to_phys() for
addresses in the vmalloc area, and __pa() for linear map addresses. Add it
to all the existing callsites where we pass pointers to OPAL.
You should avoid that. Instead, just use kmalloc for local data. If 
that's data you get from outside the function, use kmemdup().

Christophe
Thread (17 messages) 17 messages, 4 authors, last reply 2023-04-26
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help